emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] org-latex-compile timestamp checks
@ 2016-01-14 23:24 Anthony Cowley
  2016-01-15 12:13 ` Rasmus
  0 siblings, 1 reply; 15+ messages in thread
From: Anthony Cowley @ 2016-01-14 23:24 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 878 bytes --]

I’ve had some trouble with toggling latex fragment previews in a document on OS X. It would sometimes work, sometimes not, so I could just try a few times until it worked and get on with things. Looking into it more, the problem seems to be with the HFS+ filesystem’s second granularity on file timestamps. The Org code checks that the generated file is not older than a (current-time) obtained before starting latex compilation, but the truncated time of the generated file can indeed be older in the sub-second fields of the timestamp.

The attached patch simply compares timestamps truncated to 1-second precision. This does mean that there is the possibility of a false positive in the compilation test if a successful compilation is followed up by an unsuccessful compilation in less than one second. I do not know if anyone encounters such a scenario.

Anthony


[-- Attachment #2: 0001-lisp-ox-latex.el-PDF-generation-timestamp-check.patch --]
[-- Type: application/octet-stream, Size: 1468 bytes --]

From 806fdc4e77ec85dd786d18fc72f49be99899b9cc Mon Sep 17 00:00:00 2001
From: Anthony Cowley <acowley@gmail.com>
Date: Thu, 14 Jan 2016 18:13:45 -0500
Subject: [PATCH] lisp/ox-latex.el: PDF generation timestamp check

* lisp/ox-latex.el (org-latex-compile): Improve timestamp check on HFS+
  filesystem by only considering 1-second clock resolution.

Previously, the call to (current-time) could return a timestamp with
a non-zero microsecond or picosecond fields, while the file attribute
always has zeros for these fields. The check that the generated file is
newer than the reference timestamp only succeeded when the time to
generate the file crossed a 1-second clock interval.

TINYCHANGE
---
 lisp/ox-latex.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index a57677b..188c076 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -3576,7 +3576,8 @@ Return PDF file name or an error if it couldn't be produced."
 	;; Check for process failure.  Provide collected errors if
 	;; possible.
 	(if (or (not (file-exists-p pdffile))
-		(time-less-p (nth 5 (file-attributes pdffile)) time))
+		(time-less-p (take 2 (nth 5 (file-attributes pdffile)))
+			     (take 2 time)))
 	    (error (format "PDF file %s wasn't produced" pdffile))
 	  ;; Else remove log files, when specified, and signal end of
 	  ;; process to user, along with any error encountered.
-- 
2.6.4


[-- Attachment #3: Type: text/plain, Size: 5 bytes --]







^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2016-01-28 15:48 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-14 23:24 [PATCH] org-latex-compile timestamp checks Anthony Cowley
2016-01-15 12:13 ` Rasmus
2016-01-15 20:34   ` Anthony Cowley
2016-01-16 14:16     ` Nicolas Goaziou
2016-01-16 15:17     ` Rasmus
2016-01-16 23:21       ` Anthony Cowley
2016-01-21  9:54       ` Nicolas Goaziou
2016-01-21 15:53         ` Rasmus
2016-01-26 19:56           ` Anthony Cowley
2016-01-26 22:14             ` Rasmus
2016-01-26 22:20               ` Nicolas Goaziou
2016-01-26 22:25                 ` Rasmus
2016-01-28  9:05                   ` Nicolas Goaziou
2016-01-28 10:10                     ` Rasmus
2016-01-28 15:48                       ` Anthony Cowley

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).