From mboxrd@z Thu Jan 1 00:00:00 1970 From: Anthony Cowley Subject: Re: [PATCH] org-latex-compile timestamp checks Date: Fri, 15 Jan 2016 15:34:13 -0500 Message-ID: References: <57F8EBE2-E535-423A-828B-BCB3A2B9F797@gmail.com> <87r3hjf3b9.fsf@gmx.us> Mime-Version: 1.0 (Mac OS X Mail 9.2 \(3112\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_79B73BC0-A5FD-4821-9AA2-18AC84075E60" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:59943) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aKB4f-0007eQ-Hs for emacs-orgmode@gnu.org; Fri, 15 Jan 2016 15:34:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aKB4a-0003EP-IS for emacs-orgmode@gnu.org; Fri, 15 Jan 2016 15:34:21 -0500 Received: from mail-qg0-x22e.google.com ([2607:f8b0:400d:c04::22e]:35777) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aKB4a-0003EL-Cp for emacs-orgmode@gnu.org; Fri, 15 Jan 2016 15:34:16 -0500 Received: by mail-qg0-x22e.google.com with SMTP id o11so516727037qge.2 for ; Fri, 15 Jan 2016 12:34:16 -0800 (PST) Received: from sonmi451.home (pool-72-82-172-59.cmdnnj.east.verizon.net. [72.82.172.59]) by smtp.gmail.com with ESMTPSA id o75sm5167356qgd.12.2016.01.15.12.34.14 for (version=TLSv1/SSLv3 cipher=OTHER); Fri, 15 Jan 2016 12:34:14 -0800 (PST) In-Reply-To: <87r3hjf3b9.fsf@gmx.us> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --Apple-Mail=_79B73BC0-A5FD-4821-9AA2-18AC84075E60 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Jan 15, 2016, at 7:13 AM, Rasmus wrote: >=20 > Hi Anthony, >=20 > Thanks for raising this issue. >=20 > Anthony Cowley writes: >=20 >> I=E2=80=99ve 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=E2=80=99= 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. >>=20 >> The attached patch simply compares timestamps truncated to 1-second >> precision. >=20 > Isn't this a bug in Emacs file-attributes rather than Org? If so, it > should be fixed in Emacs rather than worked around in Org IMO. Thanks for taking a look, Rasmus! The bug is in Org, not Emacs. One may = perhaps assume the invariant that successive calls to `current-time` = will return non-decreasing values. One might also assume the invariant = that successive touches of different files will result in file = attributes with non-decreasing timestamps. It is mixing the two that is = the bug, and Emacs itself shouldn=E2=80=99t try to fix that. To be = clear, the limiting factor in this comparison is the filesystem whose = timestamp granularity is much coarser than the system clock. We could do something like generate an entirely separate temporary file = before compilation, and use its timestamp as the reference by which = compilation output is evaluated. However, the approach of checking file = freshness with a one-second granularity seems like a pretty good = compromise. >=20 > Maybe you could just check the log directly for failures rather than > checking the file attributes, if these are not reliable. >=20 > Also, what is the =E2=80=98take=E2=80=98? I don=E2=80=99t seem to = have it in my Emacs=E2=80=A6 Sorry about that. Believe it or not I had already rewritten those two = lines =E2=80=94 as simple as they are =E2=80=94 trying to not include = extra dependencies. I=E2=80=99ve attached an updated patch that uses = subseq from cl.el. I hope that is okay. Anthony --Apple-Mail=_79B73BC0-A5FD-4821-9AA2-18AC84075E60 Content-Disposition: attachment; filename=0001-lisp-ox-latex.el-PDF-generation-timestamp-check.patch Content-Type: application/octet-stream; name="0001-lisp-ox-latex.el-PDF-generation-timestamp-check.patch" Content-Transfer-Encoding: quoted-printable =46rom=20d7960187c9b4be87ac8811810da3bb500837018c=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20Anthony=20Cowley=20=0ADate:=20= Thu,=2014=20Jan=202016=2018:13:45=20-0500=0ASubject:=20[PATCH]=20= lisp/ox-latex.el:=20PDF=20generation=20timestamp=20check=0A=0A*=20= lisp/ox-latex.el=20(org-latex-compile):=20Improve=20timestamp=20check=20= on=20HFS+=0A=20=20filesystem=20by=20only=20considering=201-second=20= clock=20resolution.=0A=0APreviously,=20the=20call=20to=20(current-time)=20= could=20return=20a=20timestamp=20with=0Aa=20non-zero=20microsecond=20or=20= picosecond=20fields,=20while=20the=20file=20attribute=0Aalways=20has=20= zeros=20for=20these=20fields.=20The=20check=20that=20the=20generated=20= file=20is=0Anewer=20than=20the=20reference=20timestamp=20only=20= succeeded=20when=20the=20time=20to=0Agenerate=20the=20file=20crossed=20a=20= 1-second=20clock=20interval.=0A=0ATINYCHANGE=0A---=0A=20lisp/ox-latex.el=20= |=203=20++-=0A=201=20file=20changed,=202=20insertions(+),=201=20= deletion(-)=0A=0Adiff=20--git=20a/lisp/ox-latex.el=20b/lisp/ox-latex.el=0A= index=20a57677b..f803b7e=20100644=0A---=20a/lisp/ox-latex.el=0A+++=20= b/lisp/ox-latex.el=0A@@=20-3576,7=20+3576,8=20@@=20Return=20PDF=20file=20= name=20or=20an=20error=20if=20it=20couldn't=20be=20produced."=0A=20=09;;=20= Check=20for=20process=20failure.=20=20Provide=20collected=20errors=20if=0A= =20=09;;=20possible.=0A=20=09(if=20(or=20(not=20(file-exists-p=20= pdffile))=0A-=09=09(time-less-p=20(nth=205=20(file-attributes=20= pdffile))=20time))=0A+=09=09(time-less-p=20(subseq=20(nth=205=20= (file-attributes=20pdffile))=200=202)=0A+=09=09=09=20=20=20=20=20(subseq=20= time=200=202)))=0A=20=09=20=20=20=20(error=20(format=20"PDF=20file=20%s=20= wasn't=20produced"=20pdffile))=0A=20=09=20=20;;=20Else=20remove=20log=20= files,=20when=20specified,=20and=20signal=20end=20of=0A=20=09=20=20;;=20= process=20to=20user,=20along=20with=20any=20error=20encountered.=0A--=20=0A= 2.6.4=0A=0A= --Apple-Mail=_79B73BC0-A5FD-4821-9AA2-18AC84075E60--