From 13427c90291dec367879fcdb7be0b7e612423c5b Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Thu, 28 Jan 2016 10:02:04 +0100 Subject: [PATCH] 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. --- contrib/lisp/ox-groff.el | 8 +++++++- lisp/ox-man.el | 27 ++++++++++++++++----------- lisp/ox-texinfo.el | 8 +++++++- 3 files changed, 30 insertions(+), 13 deletions(-) diff --git a/contrib/lisp/ox-groff.el b/contrib/lisp/ox-groff.el index e6f0781bd..b49edce44 100644 --- a/contrib/lisp/ox-groff.el +++ b/contrib/lisp/ox-groff.el @@ -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))) (full-name (file-truename file)) (out-dir (file-name-directory file)) + (time (current-time)) ;; Properly set working directory for compilation. (default-directory (if (file-name-absolute-p file) (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"))) ;; Check for process failure. Provide collected errors if ;; 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) (when errors (concat ": " errors)))) ;; Else remove log files, when specified, and signal end of diff --git a/lisp/ox-man.el b/lisp/ox-man.el index 813862af5..1a646f587 100644 --- a/lisp/ox-man.el +++ b/lisp/ox-man.el @@ -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))) (full-name (file-truename file)) (out-dir (file-name-directory file)) + (time (current-time)) ;; Properly set working directory for compilation. (default-directory (if (file-name-absolute-p file) (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. ((consp org-man-pdf-process) (let ((outbuf (get-buffer-create "*Org PDF Groff Output*"))) - (mapc - (lambda (command) - (shell-command + (dolist (command org-man-pdf-process) + (shell-command + (replace-regexp-in-string + "%b" (shell-quote-argument base-name) (replace-regexp-in-string - "%b" (shell-quote-argument base-name) + "%f" (shell-quote-argument full-name) (replace-regexp-in-string - "%f" (shell-quote-argument full-name) - (replace-regexp-in-string - "%o" (shell-quote-argument out-dir) command t t) t t) t t) - outbuf)) - org-man-pdf-process) + "%o" (shell-quote-argument out-dir) command t t) t t) t t) + outbuf)) ;; Collect standard errors from output buffer. (setq errors (org-man-collect-errors outbuf)))) (t (error "No valid command to process to PDF"))) (let ((pdffile (concat out-dir base-name ".pdf"))) ;; Check for process failure. Provide collected errors if ;; possible. - (if (not (file-exists-p pdffile)) - (error "PDF file %s wasn't produced%s" 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 "PDF file %s wasn't produced%s" + pdffile (if errors (concat ": " errors) "")) ;; Else remove log files, when specified, and signal end of ;; process to user, along with any error encountered. diff --git a/lisp/ox-texinfo.el b/lisp/ox-texinfo.el index 3d5bfdfd9..ca8efc9d7 100644 --- a/lisp/ox-texinfo.el +++ b/lisp/ox-texinfo.el @@ -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))) (full-name (file-truename file)) (out-dir (file-name-directory file)) + (time (current-time)) ;; Properly set working directory for compilation. (default-directory (if (file-name-absolute-p file) (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"))) ;; Check for process failure. Provide collected errors if ;; 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 (if errors (concat ": " errors) "")) ;; Else remove log files, when specified, and signal end of