From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/74869 Path: news.gmane.org!not-for-mail From: Aditya Mahajan Newsgroups: gmane.comp.tex.context Subject: Re: Including command output Date: Sun, 4 Mar 2012 23:20:09 -0500 (EST) Message-ID: References: <1330916832.17258.45.camel@kip-laptop> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1330921231 30500 80.91.229.3 (5 Mar 2012 04:20:31 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 5 Mar 2012 04:20:31 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Mon Mar 05 05:20:31 2012 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from balder.ntg.nl ([195.12.62.10]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1S4PPS-0004qw-OE for gctc-ntg-context-518@m.gmane.org; Mon, 05 Mar 2012 05:20:30 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id CB15ACB290; Mon, 5 Mar 2012 05:20:29 +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 XgTkBXE3Ie6O; Mon, 5 Mar 2012 05:20:26 +0100 (CET) Original-Received: from balder.ntg.nl (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id E5350CB285; Mon, 5 Mar 2012 05:20:25 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 46D0BCB285 for ; Mon, 5 Mar 2012 05:20:24 +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 GctyWsLiHYcH for ; Mon, 5 Mar 2012 05:20:22 +0100 (CET) Original-Received: from filter3-til.mf.surf.net (filter3-til.mf.surf.net [194.171.167.219]) by balder.ntg.nl (Postfix) with ESMTP id 1C590CB282 for ; Mon, 5 Mar 2012 05:20:22 +0100 (CET) Original-Received: from hackers.mr.itd.umich.edu (smtp.mail.umich.edu [141.211.14.81]) by filter3-til.mf.surf.net (8.14.3/8.14.3/Debian-9.4) with ESMTP id q254KD9R019816 for ; Mon, 5 Mar 2012 05:20:21 +0100 Original-Received: FROM [10.0.2.15] (bas3-montreal02-1096681081.dsl.bell.ca [65.94.6.121]) By hackers.mr.itd.umich.edu ID 4F543EFB.CB110.21986 ; Authuser adityam; 4 Mar 2012 23:20:12 EST In-Reply-To: <1330916832.17258.45.camel@kip-laptop> User-Agent: Alpine 2.02 (LNX 1266 2009-07-14) X-Bayes-Prob: 0.0001 (Score 0, tokens from: @@RPTN) X-CanIt-Geo: ip=141.211.14.81; country=US; region=MI; city=Ann Arbor; postalcode=48109; latitude=42.2923; longitude=-83.7145; metrocode=505; areacode=734; http://maps.google.com/maps?q=42.2923,-83.7145&z=6 X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 0UGFEkdvr - 49de12423e20 - 20120305 (trained as not-spam) X-Scanned-By: CanIt (www . roaringpenguin . com) on 194.171.167.219 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:74869 Archived-At: On Sun, 4 Mar 2012, Kip Warner wrote: > Hey list, > > I'd like to include the output of a command. I am using the following to > define the command, > > \def\BazaarRevision{\cldcontext{os.resultof"bzr revno | tr -d '\\n'"}} > > and the following to use the output of the command, > > \BazaarRevision > > A concern I have is whether this command is executed multiple times > during the typesetting process when it need only be done once with the > result cached. If this is indeed the case, Yes. > does anyone have any suggestions? The cleaner way is to seperate the setup and use. For example: \def\initilizebazaar {\ctxlua{context.setevalue( "usebazaarrevision", os.resultof"bzr revno | tr -d '\\n'")}} \appendtoks \initilizebazaar \to \everystarttext and then use can use \usebazaarrevision in the main text. If you want to use the automagic way, you can define \BazaarRevision to redefined \BazaarRevision, for example: \def\BazaarRevision {\ctxlua{context.setevalue( "BazaarRevision", os.resultof"bzr revno | tr -d '\\n'")}% \BazaarRevision} Aditya ___________________________________________________________________________________ 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 ___________________________________________________________________________________