Browse Source

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.
Nicolas Goaziou 9 years ago
parent
commit
13427c9029
3 changed files with 30 additions and 13 deletions
  1. 7 1
      contrib/lisp/ox-groff.el
  2. 16 11
      lisp/ox-man.el
  3. 7 1
      lisp/ox-texinfo.el

+ 7 - 1
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

+ 16 - 11
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.

+ 7 - 1
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