From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/67325 Path: news.gmane.org!not-for-mail From: Philipp Gesang Newsgroups: gmane.comp.tex.context Subject: Re: Use date of the tex file in the document Date: Thu, 24 Mar 2011 11:22:02 +0100 Message-ID: <20110324102202.GD3626@orcus> References: Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0135900738==" X-Trace: dough.gmane.org 1300962155 8860 80.91.229.12 (24 Mar 2011 10:22:35 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 24 Mar 2011 10:22:35 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Thu Mar 24 11:22:30 2011 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from balder.ntg.nl ([195.12.62.10]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Q2hgU-0000fj-0D for gctc-ntg-context-518@m.gmane.org; Thu, 24 Mar 2011 11:22:30 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 61664CAAFF; Thu, 24 Mar 2011 11:22:14 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id L0d1LbWTq-7U; Thu, 24 Mar 2011 11:22:11 +0100 (CET) Original-Received: from balder.ntg.nl (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 9C81FCAB2F; Thu, 24 Mar 2011 11:22:11 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id AFA1FCAB2F for ; Thu, 24 Mar 2011 11:22:10 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id szsAjftofu4A for ; Thu, 24 Mar 2011 11:22:08 +0100 (CET) Original-Received: from filter3-ams.mf.surf.net (filter3-ams.mf.surf.net [192.87.102.71]) by balder.ntg.nl (Postfix) with ESMTP id 3E8BFCAAFF for ; Thu, 24 Mar 2011 11:22:08 +0100 (CET) Original-Received: from relay2.uni-heidelberg.de (relay2.uni-heidelberg.de [129.206.210.211]) by filter3-ams.mf.surf.net (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id p2OAM7QT005683 for ; Thu, 24 Mar 2011 11:22:09 +0100 Original-Received: from ix.urz.uni-heidelberg.de (cyrus-portal.urz.uni-heidelberg.de [129.206.100.176]) by relay2.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id p2OAM6uT015529 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 24 Mar 2011 11:22:06 +0100 Original-Received: from extmail.urz.uni-heidelberg.de (extmail.urz.uni-heidelberg.de [129.206.100.140]) by ix.urz.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id p2OAM572021142 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 24 Mar 2011 11:22:05 +0100 Original-Received: from localhost (dslb-188-104-153-096.pools.arcor-ip.net [188.104.153.96]) (authenticated bits=0) by extmail.urz.uni-heidelberg.de (8.13.4/8.13.1) with ESMTP id p2OAM3NO020843 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO) for ; Thu, 24 Mar 2011 11:22:05 +0100 In-Reply-To: X-Operating-System: Linux orcus 2.6.37-ARCH User-Agent: Mutt/1.5.21 (2010-09-15) X-Bayes-Prob: 0.0001 (Score 0, tokens from: @@RPTN) X-CanIt-Geo: ip=129.206.210.211; country=DE; region=01; city=Heidelberg; latitude=49.4167; longitude=8.7000; http://maps.google.com/maps?q=49.4167,8.7000&z=6 X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 0cEmWm7tQ - 5ff402816092 - 20110324 X-Scanned-By: CanIt (www . roaringpenguin . com) on 192.87.102.71 X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.12 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl Xref: news.gmane.org gmane.comp.tex.context:67325 Archived-At: --===============0135900738== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="3oCie2+XPXTnK5a5" Content-Disposition: inline --3oCie2+XPXTnK5a5 Content-Type: multipart/mixed; boundary="0QFb0wBpEddLcDHQ" Content-Disposition: inline --0QFb0wBpEddLcDHQ Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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=E2=80=99d have to extend it if you want it to respect included parts as well. Regards, Philipp PS: Could be optimized but this way the main function allows for lazily adjusting the output =E2=80=A6 >=20 > --=20 > Cecil Westerhof > _________________________________________________________________________= __________ > If your question is of interest to others as well, please add an entry to= the Wiki! >=20 > maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-co= ntext > webpage : http://www.pragma-ade.nl / http://tex.aanhet.net > archive : http://foundry.supelec.fr/projects/contextrev/ > wiki : http://contextgarden.net > _________________________________________________________________________= __________ --0QFb0wBpEddLcDHQ Content-Type: text/x-tex; charset=us-ascii Content-Disposition: attachment; filename="changed.tex" Content-Transfer-Encoding: quoted-printable \startluacode documentdata =3D documentdata or { } documentdata.changed =3D documentdata.changed or { } local p =3D io.popen("ls -l --time-style=3Dlong-iso \jobname.tex", "r") local time =3D p:read("*all") p:close() local P, R, V =3D lpeg.P, lpeg.R, lpeg.V local C, Ct =3D lpeg.C, lpeg.Ct local p_lsout =3D P{ [1] =3D "lsout", lsout =3D V"before" * V"date", before =3D (1 - V"date")^1, date =3D Ct(C(V"four") * V"hyphen" * C(V"two") * V"hyphen" * C(V"two") * V"space" * Ct(C(V"two") * P":" * C(V"two"))), hyphen =3D P"-", space =3D P" ", four =3D V"digit" * V"digit" * V"digit" * V"digit", two =3D V"digit" * V"digit", digit =3D R"09", } =20 local changed =3D p_lsout:match(time) function documentdata.changed.get_changed () if documentdata.changed.__last_changed then return documentdata.changed.__last_changed end local dateform =3D { changed[3], ".", changed[2], ".", changed[1], "\\space ", changed[4][1], ":", changed[4][2], } local datestr =3D table.concat(dateform) documentdata.changed.__last_changed =3D datestr return datestr end \stopluacode \unexpanded\def\getdate{% \ctxlua{context(documentdata.changed.get_changed())}% } \starttext The source of this file was last modified {\os\getdate}. \stoptext --0QFb0wBpEddLcDHQ-- --3oCie2+XPXTnK5a5 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iEYEARECAAYFAk2LG0oACgkQ02lYlJYWs9ICjgCff0EJCT1HceJONA2FcziVS7Vt MvYAoJdy4bplF3+qt9+wwKe80jPC3yfy =YuPm -----END PGP SIGNATURE----- --3oCie2+XPXTnK5a5-- --===============0135900738== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________ --===============0135900738==--