1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-11-23 07:18:53 +00:00

Improve compilation checks for some back-ends

* contrib/lisp/ox-groff.el (org-groff-compile):
* lisp/ox-man.el (org-man-compile):
* lisp/ox-texinfo.el (org-texinfo-compile): Check more carefully if
  output file was produced.
This commit is contained in:
Nicolas Goaziou 2016-01-28 10:02:04 +01:00
parent c17fccf904
commit 13427c9029
3 changed files with 30 additions and 13 deletions

View File

@ -1902,6 +1902,7 @@ Return PDF file name or an error if it couldn't be produced."
(let* ((base-name (file-name-sans-extension (file-name-nondirectory file))) (let* ((base-name (file-name-sans-extension (file-name-nondirectory file)))
(full-name (file-truename file)) (full-name (file-truename file))
(out-dir (file-name-directory file)) (out-dir (file-name-directory file))
(time (current-time))
;; Properly set working directory for compilation. ;; Properly set working directory for compilation.
(default-directory (if (file-name-absolute-p file) (default-directory (if (file-name-absolute-p file)
(file-name-directory full-name) (file-name-directory full-name)
@ -1936,7 +1937,12 @@ Return PDF file name or an error if it couldn't be produced."
(let ((pdffile (concat out-dir base-name ".pdf"))) (let ((pdffile (concat out-dir base-name ".pdf")))
;; Check for process failure. Provide collected errors if ;; Check for process failure. Provide collected errors if
;; possible. ;; possible.
(if (not (file-exists-p pdffile)) (if (or (not (file-exists-p pdffile))
;; Only compare times up to whole seconds as some
;; filesystems (e.g. HFS+) do not retain any finer
;; granularity.
(time-less-p (cl-subseq (nth 5 (file-attributes pdffile)) 0 2)
(cl-subseq time 0 2)))
(error (concat (format "PDF file %s wasn't produced" pdffile) (error (concat (format "PDF file %s wasn't produced" pdffile)
(when errors (concat ": " errors)))) (when errors (concat ": " errors))))
;; Else remove log files, when specified, and signal end of ;; Else remove log files, when specified, and signal end of

View File

@ -1130,6 +1130,7 @@ Return PDF file name or an error if it couldn't be produced."
(let* ((base-name (file-name-sans-extension (file-name-nondirectory file))) (let* ((base-name (file-name-sans-extension (file-name-nondirectory file)))
(full-name (file-truename file)) (full-name (file-truename file))
(out-dir (file-name-directory file)) (out-dir (file-name-directory file))
(time (current-time))
;; Properly set working directory for compilation. ;; Properly set working directory for compilation.
(default-directory (if (file-name-absolute-p file) (default-directory (if (file-name-absolute-p file)
(file-name-directory full-name) (file-name-directory full-name)
@ -1146,25 +1147,29 @@ Return PDF file name or an error if it couldn't be produced."
;; redirected to "*Org PDF Groff Output*" buffer. ;; redirected to "*Org PDF Groff Output*" buffer.
((consp org-man-pdf-process) ((consp org-man-pdf-process)
(let ((outbuf (get-buffer-create "*Org PDF Groff Output*"))) (let ((outbuf (get-buffer-create "*Org PDF Groff Output*")))
(mapc (dolist (command org-man-pdf-process)
(lambda (command) (shell-command
(shell-command (replace-regexp-in-string
"%b" (shell-quote-argument base-name)
(replace-regexp-in-string (replace-regexp-in-string
"%b" (shell-quote-argument base-name) "%f" (shell-quote-argument full-name)
(replace-regexp-in-string (replace-regexp-in-string
"%f" (shell-quote-argument full-name) "%o" (shell-quote-argument out-dir) command t t) t t) t t)
(replace-regexp-in-string outbuf))
"%o" (shell-quote-argument out-dir) command t t) t t) t t)
outbuf))
org-man-pdf-process)
;; Collect standard errors from output buffer. ;; Collect standard errors from output buffer.
(setq errors (org-man-collect-errors outbuf)))) (setq errors (org-man-collect-errors outbuf))))
(t (error "No valid command to process to PDF"))) (t (error "No valid command to process to PDF")))
(let ((pdffile (concat out-dir base-name ".pdf"))) (let ((pdffile (concat out-dir base-name ".pdf")))
;; Check for process failure. Provide collected errors if ;; Check for process failure. Provide collected errors if
;; possible. ;; possible.
(if (not (file-exists-p pdffile)) (if (or (not (file-exists-p pdffile))
(error "PDF file %s wasn't produced%s" pdffile ;; Only compare times up to whole seconds as some
;; filesystems (e.g. HFS+) do not retain any finer
;; granularity.
(time-less-p (cl-subseq (nth 5 (file-attributes pdffile)) 0 2)
(cl-subseq time 0 2)))
(error "PDF file %s wasn't produced%s"
pdffile
(if errors (concat ": " errors) "")) (if errors (concat ": " errors) ""))
;; Else remove log files, when specified, and signal end of ;; Else remove log files, when specified, and signal end of
;; process to user, along with any error encountered. ;; process to user, along with any error encountered.

View File

@ -1568,6 +1568,7 @@ Return INFO file name or an error if it couldn't be produced."
(let* ((base-name (file-name-sans-extension (file-name-nondirectory file))) (let* ((base-name (file-name-sans-extension (file-name-nondirectory file)))
(full-name (file-truename file)) (full-name (file-truename file))
(out-dir (file-name-directory file)) (out-dir (file-name-directory file))
(time (current-time))
;; Properly set working directory for compilation. ;; Properly set working directory for compilation.
(default-directory (if (file-name-absolute-p file) (default-directory (if (file-name-absolute-p file)
(file-name-directory full-name) (file-name-directory full-name)
@ -1594,7 +1595,12 @@ Return INFO file name or an error if it couldn't be produced."
(let ((infofile (concat out-dir base-name ".info"))) (let ((infofile (concat out-dir base-name ".info")))
;; Check for process failure. Provide collected errors if ;; Check for process failure. Provide collected errors if
;; possible. ;; possible.
(if (not (file-exists-p infofile)) (if (or (not (file-exists-p infofile))
;; Only compare times up to whole seconds as some
;; filesystems (e.g. HFS+) do not retain any finer
;; granularity.
(time-less-p (cl-subseq (nth 5 (file-attributes infofile)) 0 2)
(cl-subseq time 0 2)))
(error "INFO file %s wasn't produced%s" infofile (error "INFO file %s wasn't produced%s" infofile
(if errors (concat ": " errors) "")) (if errors (concat ": " errors) ""))
;; Else remove log files, when specified, and signal end of ;; Else remove log files, when specified, and signal end of