From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/78108 Path: news.gmane.org!not-for-mail From: Marco Patzer Newsgroups: gmane.comp.tex.context Subject: TeX expansion within lua Date: Tue, 4 Sep 2012 17:12:43 +0200 Message-ID: <20120904171243.3f70b4a6@homerow> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1346771583 718 80.91.229.3 (4 Sep 2012 15:13:03 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 4 Sep 2012 15:13:03 +0000 (UTC) To: context Original-X-From: ntg-context-bounces@ntg.nl Tue Sep 04 17:13:05 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 1T8uoH-0003M9-Aw for gctc-ntg-context-518@m.gmane.org; Tue, 04 Sep 2012 17:13:01 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id BE30210206; Tue, 4 Sep 2012 17:12:57 +0200 (CEST) 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 8qrd7loHWJaI; Tue, 4 Sep 2012 17:12:55 +0200 (CEST) Original-Received: from balder.ntg.nl (localhost [IPv6:::1]) by balder.ntg.nl (Postfix) with ESMTP id BB7FA101F8; Tue, 4 Sep 2012 17:12:55 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 74C0D101F8 for ; Tue, 4 Sep 2012 17:12:54 +0200 (CEST) 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 UMLzLt+r4jgC for ; Tue, 4 Sep 2012 17:12:49 +0200 (CEST) Original-Received: from filter1-utr.mf.surf.net (filter1-utr.mf.surf.net [195.169.124.152]) by balder.ntg.nl (Postfix) with ESMTP id 98FB8101EB for ; Tue, 4 Sep 2012 17:12:49 +0200 (CEST) Original-Received: from karen.lavabit.com (karen.lavabit.com [72.249.41.33]) by filter1-utr.mf.surf.net (8.14.3/8.14.3/Debian-9.4) with ESMTP id q84FCk0C026882 for ; Tue, 4 Sep 2012 17:12:47 +0200 Original-Received: from b.earth.lavabit.com (b.earth.lavabit.com [192.168.111.11]) by karen.lavabit.com (Postfix) with ESMTP id D603011BD04 for ; Tue, 4 Sep 2012 10:12:45 -0500 (CDT) Original-Received: from homerow (miun108-65.dynamic.miun.se [193.10.108.65]) by lavabit.com with ESMTP id J2DV87C07NKZ for ; Tue, 04 Sep 2012 10:12:45 -0500 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=lavabit; d=lavabit.com; b=EHUTXc7OZgY5JRZNeEHnCD9COIM9vQZqTqWRTb+vWEPZiM/mD859UFdMMjS0RlHj5Fa63gY48yM1LhUU9FeocaMljvJxMfPV005//wHdaZb+py8TJRhKMDdbKiBWpPd9pT7WIpV5DmG06eWS+CPu8mPHXRECQPJ8nI0ZNK471YE=; h=Date:From:To:Subject:Message-ID:X-Mailer:Mime-Version:Content-Type:Content-Transfer-Encoding; X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu) X-Bayes-Prob: 0.7344 (Score 2, tokens from: @@RPTN) X-CanIt-Geo: ip=72.249.41.33; country=US; region=TX; city=Dallas; postalcode=75206; latitude=32.8339; longitude=-96.7715; metrocode=623; areacode=214; http://maps.google.com/maps?q=32.8339,-96.7715&z=6 X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 07HT3cKwG - 5f4127ac7587 - 20120904 X-Scanned-By: CanIt (www . roaringpenguin . com) X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.14 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: ntg-context-bounces@ntg.nl Xref: news.gmane.org gmane.comp.tex.context:78108 Archived-At: Hi, please have a look at the following example: \starttext \def\cmd{% \def\mymacro{Foobar} \newtoks\mytoks \mytoks={mytoks}} \startluacode context.cmd() context.mymacro() -- this fails -- context(tex.toks.mytoks) \stopluacode -- this works \startluacode context(tex.toks.mytoks) \stopluacode \stoptext Why does the first call to tex.toks.mytoks fail? Apparently the luacode environment has to be closed for cmd to be expanded. I guess that the call to mymacro() succeeds is a quirk due to the face that the macro is expanded later, in contrast to tokens, dimens and counters. Is there a command I can use within Lua to expand a macro immediately or to expand the pending macros to be able to access the values like the token register in the example? Another question which is related: Is there a way to access the contents of the macro from within Lua like counters and token registers? \starttext \newtoks\mytoks \mytoks={Foobar} \startluacode local tok = tex.toks.mytoks -- something like this is what I have in mind -- local mac = tex.macros.somemacro \stopluacode \stoptext I am just interested in a text string, not a box with typeset material. I guess that's more difficult, since macros are expanded and not just simply read. Marco ___________________________________________________________________________________ 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 ___________________________________________________________________________________