Re: [NTG-context] Use date of the tex file in the document

2011-03-24 Thread Philipp Gesang
On 2011-03-25 <00:30:40>, Hans Hagen wrote: > On 25-3-2011 12:08, Cecil Westerhof wrote: > > >I made the code a little better: > >\startluacode > > os.setlocale("nl_NL") > > blocked in mkiv to prevent unwanted side effects and that will stay Still, one can access context’s language substitutio

Re: [NTG-context] Use date of the tex file in the document

2011-03-24 Thread Hans Hagen
On 25-3-2011 12:08, Cecil Westerhof wrote: I made the code a little better: \startluacode os.setlocale("nl_NL") blocked in mkiv to prevent unwanted side effects and that will stay function modification_date(file, format) local f= file local attr = lfs.attributes(f) why

Re: [NTG-context] Use date of the tex file in the document

2011-03-24 Thread Cecil Westerhof
2011/3/24 Cecil Westerhof > \startluacode > function modification_date(file, format) > local f= file > local attr = lfs.attributes(f) > > assert (type(attr) == "table") > if attr.mode ~= "directory" then > if format == "long" then > return os.date("%Y-%m-%d %H:

Re: [NTG-context] Use date of the tex file in the document

2011-03-24 Thread Florian Wobbe
>> Thanks, nice! I suppose the filename is also directly reachable from inside >> \startluacode ... \stopluacode. How? > > \start-stop luacode expands its contents. So, the following should work > (untested) > > \startluacode > thisfilename = "\thisfilename.tex" > \stopluacode No, that is not

Re: [NTG-context] Use date of the tex file in the document

2011-03-24 Thread Aditya Mahajan
On Thu, 24 Mar 2011, Florian Wobbe wrote: How would you automatically find out the filename which the macro is called from? For instance if the file with the macro is included in a master document. \inputfilename So, if you want the name of the file in which this macro is defined in, then s

Re: [NTG-context] Use date of the tex file in the document

2011-03-24 Thread Cecil Westerhof
2011/3/24 Philipp Gesang > > \getdate > > > > \getdate{"short"} > > \getdate[long] > \getdate[nil] > \getdate[false] > > In context optional args are specified in brackets. I had tried \getdate["long"], but the quotes where wrong. > It’s all > documented on the wiki: > http://wiki.contextga

Re: [NTG-context] Use date of the tex file in the document

2011-03-24 Thread Hans Hagen
On 24-3-2011 6:30, Marco wrote: On 2011-03-24 Cecil Westerhof wrote: \def\dogetdate[#1]% {\ctalua{context(modification_date("\jobname.tex", "#1"))}} ^^^ Try \ctxlua … or \cldcontext{modification_date("\jobname.tex", "#1")} but ... is it clever to define modificatio

Re: [NTG-context] Use date of the tex file in the document

2011-03-24 Thread Florian Wobbe
>> How would you automatically find out the filename which the macro is called >> from? For instance if the file with the macro is included in a master >> document. > > \inputfilename > > So, if you want the name of the file in which this macro is defined in, then > something like this should

Re: [NTG-context] Use date of the tex file in the document

2011-03-24 Thread Philipp Gesang
On 2011-03-24 <18:42:12>, Cecil Westerhof wrote: > 2011/3/24 Philipp Gesang > > > > {\ctalua{context(modification_date("\jobname.tex", "#1"))}} > >^ > > s/\\ctalua/\\ctxlua/ > > > > I have: > \startluacode > function modification_date(file, format) > local f= file >

Re: [NTG-context] Use date of the tex file in the document

2011-03-24 Thread Aditya Mahajan
On Thu, 24 Mar 2011, Florian Wobbe wrote: \def\getdate {\dosingleempty\dogetdate} \def\dogetdate[#1]% {\ctalua{context(modification_date("\jobname.tex", "#1"))}} How would you automatically find out the filename which the macro is called from? For instance if the file with the macro is inc

Re: [NTG-context] Use date of the tex file in the document

2011-03-24 Thread Cecil Westerhof
2011/3/24 Philipp Gesang > > {\ctalua{context(modification_date("\jobname.tex", "#1"))}} >^ > s/\\ctalua/\\ctxlua/ > I have: \startluacode function modification_date(file, format) local f= file local attr = lfs.attributes(f) assert (type(attr) == "table")

Re: [NTG-context] Use date of the tex file in the document

2011-03-24 Thread Florian Wobbe
> \def\getdate > {\dosingleempty\dogetdate} > > \def\dogetdate[#1]% > {\ctalua{context(modification_date("\jobname.tex", "#1"))}} How would you automatically find out the filename which the macro is called from? For instance if the file with the macro is included in a master document. Florian

Re: [NTG-context] Use date of the tex file in the document

2011-03-24 Thread Marco
On 2011-03-24 Cecil Westerhof wrote: > \def\dogetdate[#1]% > {\ctalua{context(modification_date("\jobname.tex", "#1"))}} ^^^ Try \ctxlua … Marco ___ If your question is of interest to others a

Re: [NTG-context] Use date of the tex file in the document

2011-03-24 Thread Philipp Gesang
On 2011-03-24 <18:15:31>, Cecil Westerhof wrote: > 2011/3/24 Wolfgang Schuster > > > > > Am 24.03.2011 um 17:29 schrieb Cecil Westerhof: > > > > > \def\getdate% > > > {\dosinglegroupempty\dogetdate} > > > > > > \def\dogetdate#1% > > > {context{modification_date("\jobname.tex", "#1")}} > > > >

Re: [NTG-context] Use date of the tex file in the document

2011-03-24 Thread Cecil Westerhof
2011/3/24 Wolfgang Schuster > > Am 24.03.2011 um 17:29 schrieb Cecil Westerhof: > > > \def\getdate% > > {\dosinglegroupempty\dogetdate} > > > > \def\dogetdate#1% > > {context{modification_date("\jobname.tex", "#1")}} > > \def\getdate > {\dosingleempty\dogetdate} > > \def\dogetdate[#1]% > {\c

Re: [NTG-context] Use date of the tex file in the document

2011-03-24 Thread Wolfgang Schuster
Am 24.03.2011 um 17:29 schrieb Cecil Westerhof: > \def\getdate% > {\dosinglegroupempty\dogetdate} > > \def\dogetdate#1% > {context{modification_date("\jobname.tex", "#1")}} \def\getdate {\dosingleempty\dogetdate} \def\dogetdate[#1]% {\ctalua{context(modification_date("\jobname.tex", "#1

Re: [NTG-context] Use date of the tex file in the document

2011-03-24 Thread Cecil Westerhof
2011/3/24 Aditya Mahajan > \getdate would return os.date("%Y-%m-%d",attr.modification) >> and >> \getdate{"long"} would return os.date("%Y-%m-%d >> %H:%M",attr.modification) >> >> I have looked at lua, but do not see how to do it. (Something else to >> learn.) >> > I would like to do somethin

Re: [NTG-context] Use date of the tex file in the document

2011-03-24 Thread Aditya Mahajan
On Thu, 24 Mar 2011, Cecil Westerhof wrote: 2011/3/24 Marco On 2011-03-24 Philipp Gesang wrote: This should also work: \starttext \startluacode function modification_date (file) local f = file local attr = lfs.attributes (f) assert (type(attr) == "table") if attr.mode ~= "dir

Re: [NTG-context] Use date of the tex file in the document

2011-03-24 Thread Cecil Westerhof
2011/3/24 Marco > On 2011-03-24 Philipp Gesang wrote: > > This should also work: > > \starttext > > \startluacode > function modification_date (file) >local f = file >local attr = lfs.attributes (f) >assert (type(attr) == "table") >if attr.mode ~= "directory" then > return

Re: [NTG-context] Use date of the tex file in the document

2011-03-24 Thread Marco
On 2011-03-24 Philipp Gesang wrote: This should also work: \starttext \startluacode function modification_date (file) local f = file local attr = lfs.attributes (f) assert (type(attr) == "table") if attr.mode ~= "directory" then return os.date("%Y-%m-%d %H:%M",attr.modif

Re: [NTG-context] Use date of the tex file in the document

2011-03-24 Thread Cecil Westerhof
2011/3/24 Philipp Gesang > On 2011-03-24 <10:26:00>, Cecil Westerhof wrote: > > I would like to use the date of the document in the generated PDF. (It is > > not interesting when the PDF is generated, but when the source was last > > changed.) How would I do this? > > this solution checks only th

Re: [NTG-context] Use date of the tex file in the document

2011-03-24 Thread Philipp Gesang
On 2011-03-24 <10:26:00>, Cecil Westerhof wrote: > I would like to use the date of the document in the generated PDF. (It is > not interesting when the PDF is generated, but when the source was last > changed.) How would I do this? Hi Cecil, this solution checks only the main file, you’d have to

[NTG-context] Use date of the tex file in the document

2011-03-24 Thread Cecil Westerhof
I would like to use the date of the document in the generated PDF. (It is not interesting when the PDF is generated, but when the source was last changed.) How would I do this? -- Cecil Westerhof ___ If your question