summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2016-01-28 10:02:04 +0100
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2016-01-28 10:02:04 +0100
commit13427c90291dec367879fcdb7be0b7e612423c5b (patch)
tree4c6d3fcbbd19b0f43b408be64c2f750cf02dc7bb
parentc17fccf90406e1994a22865b1e3219ee364e0239 (diff)
downloadorg-mode-13427c90291dec367879fcdb7be0b7e612423c5b.tar.gz
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.
-rw-r--r--contrib/lisp/ox-groff.el8
-rw-r--r--lisp/ox-man.el27
-rw-r--r--lisp/ox-texinfo.el8
3 files changed, 30 insertions, 13 deletions
diff --git a/contrib/lisp/ox-groff.el b/contrib/lisp/ox-groff.el
index e6f0781..b49edce 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 813862a..1a646f5 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 3d5bfdf..ca8efc9 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