* How to load a lua file into a named lua instance
@ 2009-11-20 22:15 Kevin D. Robbins
2009-11-20 22:32 ` Hans Hagen
0 siblings, 1 reply; 3+ messages in thread
From: Kevin D. Robbins @ 2009-11-20 22:15 UTC (permalink / raw)
To: mailing list for ConTeXt users
[-- Attachment #1.1: Type: text/plain, Size: 464 bytes --]
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?
Thanks,
Kevin
[-- Attachment #1.2: Type: text/html, Size: 493 bytes --]
[-- Attachment #2: Type: text/plain, Size: 486 bytes --]
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: How to load a lua file into a named lua instance
2009-11-20 22:15 How to load a lua file into a named lua instance Kevin D. Robbins
@ 2009-11-20 22:32 ` Hans Hagen
2009-11-21 0:12 ` Kevin D. Robbins
0 siblings, 1 reply; 3+ messages in thread
From: Hans Hagen @ 2009-11-20 22:32 UTC (permalink / raw)
To: mailing list for ConTeXt users
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: How to load a lua file into a named lua instance
2009-11-20 22:32 ` Hans Hagen
@ 2009-11-21 0:12 ` Kevin D. Robbins
0 siblings, 0 replies; 3+ messages in thread
From: Kevin D. Robbins @ 2009-11-21 0:12 UTC (permalink / raw)
To: mailing list for ConTeXt users
[-- Attachment #1.1: Type: text/plain, Size: 2113 bytes --]
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 <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 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
>
> ___________________________________________________________________________________
>
[-- Attachment #1.2: Type: text/html, Size: 3209 bytes --]
[-- Attachment #2: Type: text/plain, Size: 486 bytes --]
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-11-21 0:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-20 22:15 How to load a lua file into a named lua instance Kevin D. Robbins
2009-11-20 22:32 ` Hans Hagen
2009-11-21 0:12 ` Kevin D. Robbins
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).