From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/54595 Path: news.gmane.org!not-for-mail From: "Kevin D. Robbins" Newsgroups: gmane.comp.tex.context Subject: Re: How to load a lua file into a named lua instance Date: Fri, 20 Nov 2009 17:12:45 -0700 Message-ID: References: <4B0718F1.5070705@wxs.nl> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0679948136==" X-Trace: ger.gmane.org 1258762401 3350 80.91.229.12 (21 Nov 2009 00:13:21 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 21 Nov 2009 00:13:21 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Sat Nov 21 01:13:14 2009 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.50) id 1NBdbD-0005EB-KK for gctc-ntg-context-518@m.gmane.org; Sat, 21 Nov 2009 01:13:11 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 09233C9ADD; Sat, 21 Nov 2009 01:10:38 +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 HXZo-ztd0oSJ; Sat, 21 Nov 2009 01:10:34 +0100 (CET) Original-Received: from balder.ntg.nl (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 93C9DC9AB7; Sat, 21 Nov 2009 01:10:34 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 51F62C9AB7 for ; Sat, 21 Nov 2009 01:10:31 +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 IuwUWrm-7Cp1 for ; Sat, 21 Nov 2009 01:10:17 +0100 (CET) Original-Received: from mail-pz0-f179.google.com (mail-pz0-f179.google.com [209.85.222.179]) by balder.ntg.nl (Postfix) with ESMTP id 5AAB4C9A8A for ; Sat, 21 Nov 2009 01:10:14 +0100 (CET) Original-Received: by pzk9 with SMTP id 9so2584356pzk.16 for ; Fri, 20 Nov 2009 16:12:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=J/kPEwwwBIuL7M3cTf2VJmcPGLC1r5fNLCbMRZwMNDA=; b=HCpXg22UGl7gS2FNAmHU1md9J7xkMAYW1ghjToPdH5Frzb3mUxciUpHMIYTizCeCYT phUqdBKiEy/BdQZsIst1cELDT6RYaMsk3qyJXE4EiTyNN2ftpnx2r7DyVjVBoPryhb1r oIdjRpEnwNVJOkx+4wfksmzX7QNyNem6l5QDw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=qNxoh4cCPIEwjK5oBlRBzFlaRJzSshFbZ88aSb62z7H1HuQaEwzrJ8g1eaz6gv4w+Y fG/4keElREdaH+Ir9IEO5GBBNiFbaeIB/42D6pXN7rKLqxyAHbgDKi6xgwfKG39JZcJk tEmwPXCGMi/1sGeN/9HoT5PByiGgIKmbotAJI= Original-Received: by 10.142.75.14 with SMTP id x14mr230254wfa.151.1258762365265; Fri, 20 Nov 2009 16:12:45 -0800 (PST) In-Reply-To: <4B0718F1.5070705@wxs.nl> 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:54595 Archived-At: --===============0679948136== Content-Type: multipart/alternative; boundary=001636e1fd3fa3683e0478d673c0 --001636e1fd3fa3683e0478d673c0 Content-Type: text/plain; charset=UTF-8 Hi Hans, I started reading at \registerctxluafile in luat-cod.mkiv, but it wasn't quite what I was looking for. But, I then stumbled on \definenamedlua in luat-ini.mkiv. There, I learned of the function 'protect' in luat-ini.lua. So, adding the line protect("moduledata") at the top of t-module.lua and then loading this file with 'dofile (global.kpse.find_file ("t-module.lua", "tex"))' loads all my definitions into the "moduledata" environment, so that I can directly address these definitions in other TeX files within \modulecode{} or \startmodulecode ... \stopmodulecode. Kevin On Fri, Nov 20, 2009 at 3:32 PM, Hans Hagen wrote: > Kevin D. Robbins wrote: > >> Hi all, >> >> I have a module with lots of lua code, and I'd like to move most of the >> lua code to a separate file, say t-module.lua. I have written all of the lua >> code using \modulecode and \startmodulecode ... \stopmodulecode. But, when I >> move the lua code to t-module.lua and load it with dofile, it seems to load >> in the global instance instead of the third party module instance. Is there >> any method to load an external lua file in a named instance? >> > > \registerctxluafile{t-module}{} > > > ----------------------------------------------------------------- > Hans Hagen | PRAGMA ADE > Ridderstraat 27 | 8061 GH Hasselt | The Netherlands > tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com > | www.pragma-pod.nl > ----------------------------------------------------------------- > > ___________________________________________________________________________________ > 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 > > ___________________________________________________________________________________ > --001636e1fd3fa3683e0478d673c0 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi Hans,

I started reading at \registerctxluafile in luat-cod.mkiv, = but it wasn't quite what I was looking for. But, I then stumbled on \de= finenamedlua in luat-ini.mkiv. There, I learned of the function 'protec= t' in luat-ini.lua. So, adding the line

protect("moduledata")

at the top of t-module.lua and t= hen loading this file with 'dofile (global.kpse.find_file ("t-modu= le.lua", "tex"))' loads all my definitions into the &quo= t;moduledata" environment, so that I can directly address these defini= tions in other TeX files within \modulecode{} or \startmodulecode ... \stop= modulecode.

Kevin

On Fri, Nov 20, 2009 at 3:32 PM= , Hans Hagen <pragma@= wxs.nl> wrote:
Kevin D. Robbins wrote:
Hi all,

I have a module with lots of lua code, and I'd like to move most of the= lua code to a separate file, say t-module.lua. I have written all of the l= ua code using \modulecode and \startmodulecode ... \stopmodulecode. But, wh= en I move the lua code to t-module.lua and load it with dofile, it seems to= load in the global instance instead of the third party module instance. Is= there any method to load an external lua file in a named instance?

\registerctxluafile{t-module}{}


-----------------------------------------------------------------
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Ha= ns Hagen | PRAGMA ADE
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Ridderstraat 27 | 8061 GH = Hasselt | The Netherlands
=C2=A0 =C2=A0 tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 | www.pragma-= pod.nl
-----------------------------------------------------------------
___________________________________________________________________________= ________
If your question is of interest to others as well, please add an entry to t= he Wiki!

maillist : ntg-cont= ext@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage =C2=A0: http= ://www.pragma-ade.nl / http://tex.aanhet.net
archive =C2=A0: http://foundry.supelec.fr/projects/contextrev/
wiki =C2=A0 =C2=A0 : http://contextgarden.net
___________________________________________________________________________= ________

--001636e1fd3fa3683e0478d673c0-- --===============0679948136== 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 ___________________________________________________________________________________ --===============0679948136==--