From mboxrd@z Thu Jan 1 00:00:00 1970 From: Anthony Cowley Subject: Re: [PATCH] org-latex-compile timestamp checks Date: Sat, 16 Jan 2016 18:21:30 -0500 Message-ID: References: <57F8EBE2-E535-423A-828B-BCB3A2B9F797@gmail.com> <87r3hjf3b9.fsf@gmx.us> <87vb6tblkr.fsf@gmx.us> Mime-Version: 1.0 (Mac OS X Mail 9.2 \(3112\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_372A3E0B-2627-48BE-B8BC-B921CAE62C61" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:46969) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aKaA5-0002ui-9G for emacs-orgmode@gnu.org; Sat, 16 Jan 2016 18:21:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aKaA1-0000WZ-Tk for emacs-orgmode@gnu.org; Sat, 16 Jan 2016 18:21:37 -0500 Received: from mail-qg0-x22a.google.com ([2607:f8b0:400d:c04::22a]:35316) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aKaA1-0000VH-KQ for emacs-orgmode@gnu.org; Sat, 16 Jan 2016 18:21:33 -0500 Received: by mail-qg0-x22a.google.com with SMTP id o11so533918231qge.2 for ; Sat, 16 Jan 2016 15:21:33 -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 y133sm7201307qhc.11.2016.01.16.15.21.31 for (version=TLSv1/SSLv3 cipher=OTHER); Sat, 16 Jan 2016 15:21:31 -0800 (PST) In-Reply-To: <87vb6tblkr.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=_372A3E0B-2627-48BE-B8BC-B921CAE62C61 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Jan 16, 2016, at 10:17 AM, Rasmus wrote: >=20 > Hi Anthony and Nicolas, >=20 > Anthony Cowley writes: >=20 >> 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. >=20 > Thanks for carefully explaining exactly what is going on here. >=20 >> 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 > I think the approach is fine now. See below. >=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 >>=20 >> 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. >=20 > Actually, it's part of cl-lib now (in the broadest understanding of > cl-lib). >=20 > Since this is a bugfix I guess you should use org-sublist (*shiver*) = in > maint and cl-subseq in master. We can=E2=80=99t use cl-lib in maint, = right > Nicolas? >=20 > Nicolas Goaziou writes: >=20 >> Anthony Cowley writes: >>=20 >>> * lisp/ox-latex.el (org-latex-compile): Improve timestamp check on = HFS+ >>> filesystem by only considering 1-second clock resolution. >>>=20 >>> 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. >>>=20 >>> TINYCHANGE >>> --- >>> lisp/ox-latex.el | 3 ++- >>> 1 file changed, 2 insertions(+), 1 deletion(-) >>>=20 >>> diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el >>> index a57677b..f803b7e 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 (subseq (nth 5 (file-attributes pdffile)) 0 = 2) >>> + (subseq time 0 2))) >>=20 >> This sounds good. Thank you. >>=20 >> Although, I suggest to use `cl-subseq' instead of its alias. Also, it >> may be worth commenting that trick right into the source. >=20 > Yes, it should. I=E2=80=99ve attached two remixes of the original patch: the first uses = cl-subseq, the second uses org-sublist. Anthony --Apple-Mail=_372A3E0B-2627-48BE-B8BC-B921CAE62C61 Content-Disposition: attachment; filename=ox-latex-timestamp.patch Content-Type: application/octet-stream; name="ox-latex-timestamp.patch" Content-Transfer-Encoding: quoted-printable =46rom=208e152704e3b0a3cc31ef46d31e32c7b914fd4401=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= |=205=20++++-=0A=201=20file=20changed,=204=20insertions(+),=201=20= deletion(-)=0A=0Adiff=20--git=20a/lisp/ox-latex.el=20b/lisp/ox-latex.el=0A= index=20a57677b..eb1ba6c=20100644=0A---=20a/lisp/ox-latex.el=0A+++=20= b/lisp/ox-latex.el=0A@@=20-3576,7=20+3576,10=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;;=20Only=20compare=20times=20up=20to=20= whole=20seconds=20as=20some=20filesystems=0A+=09=09;;=20(e.g.=20HFS+)=20= do=20not=20retain=20any=20finer=20granularity.=0A+=09=09(time-less-p=20= (cl-subseq=20(nth=205=20(file-attributes=20pdffile))=200=202)=0A+=09=09=09= =20=20=20=20=20(cl-subseq=20time=200=202)))=0A=20=09=20=20=20=20(error=20= (format=20"PDF=20file=20%s=20wasn't=20produced"=20pdffile))=0A=20=09=20=20= ;;=20Else=20remove=20log=20files,=20when=20specified,=20and=20signal=20= end=20of=0A=20=09=20=20;;=20process=20to=20user,=20along=20with=20any=20= error=20encountered.=0A--=20=0A2.6.4=0A=0A= --Apple-Mail=_372A3E0B-2627-48BE-B8BC-B921CAE62C61 Content-Disposition: attachment; filename=ox-latex-timestamp-maint.patch Content-Type: application/octet-stream; name="ox-latex-timestamp-maint.patch" Content-Transfer-Encoding: quoted-printable =46rom=209275fd16c8ec51702a63bfc3e8e736bb787b624c=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= |=205=20++++-=0A=201=20file=20changed,=204=20insertions(+),=201=20= deletion(-)=0A=0Adiff=20--git=20a/lisp/ox-latex.el=20b/lisp/ox-latex.el=0A= index=20a57677b..848fe3a=20100644=0A---=20a/lisp/ox-latex.el=0A+++=20= b/lisp/ox-latex.el=0A@@=20-3576,7=20+3576,10=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;;=20Only=20compare=20times=20up=20to=20= whole=20seconds=20as=20some=20filesystems=0A+=09=09;;=20(e.g.=20HFS+)=20= do=20not=20retain=20any=20finer=20granularity.=0A+=09=09(time-less-p=20= (org-sublist=20(nth=205=20(file-attributes=20pdffile))=201=202)=0A+=09=09= =09=20=20=20=20=20(org-sublist=20time=201=202)))=0A=20=09=20=20=20=20= (error=20(format=20"PDF=20file=20%s=20wasn't=20produced"=20pdffile))=0A=20= =09=20=20;;=20Else=20remove=20log=20files,=20when=20specified,=20and=20= signal=20end=20of=0A=20=09=20=20;;=20process=20to=20user,=20along=20with=20= any=20error=20encountered.=0A--=20=0A2.6.4=0A=0A= --Apple-Mail=_372A3E0B-2627-48BE-B8BC-B921CAE62C61--