ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Custom lua script (updating and debugging)
       [not found] <mailman.1.1285668002.22946.ntg-context@ntg.nl>
@ 2010-09-28 10:41 ` Stefan Müller
  2010-09-28 19:30   ` Mojca Miklavec
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Müller @ 2010-09-28 10:41 UTC (permalink / raw)
  To: ntg-context

Hi list,

I'm currently messing around with a custom lua script (a pretty printer) 
and I have some beginner trouble.

First: I put the file in "MyContexDir\tex\texmf\tex\context\base\". What 
do I have to do to let ConTeXt work with the script and to let ConTeXt 
know that something has changed in the script? Is "context --generate" 
enough (after initializing with "setuptex.bat")?

Second: How can I debug errors in my *.lua file? Just put
   print("debug message")
in the function that is (supposed to be) called?

Any help appreciated and thanks in advance!

Stefan
___________________________________________________________________________________
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] 6+ messages in thread

* Re: Custom lua script (updating and debugging)
  2010-09-28 10:41 ` Custom lua script (updating and debugging) Stefan Müller
@ 2010-09-28 19:30   ` Mojca Miklavec
  2010-09-29  6:50     ` Procházka Lukáš Ing. - Pontex s. r. o.
  0 siblings, 1 reply; 6+ messages in thread
From: Mojca Miklavec @ 2010-09-28 19:30 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Tue, Sep 28, 2010 at 12:41, Stefan Müller wrote:
> Hi list,
>
> I'm currently messing around with a custom lua script (a pretty printer) and
> I have some beginner trouble.
>
> First: I put the file in "MyContexDir\tex\texmf\tex\context\base\".

Put them into
    MyContexDir\tex\texmf-local\tex\context\user\
because:
- You need to use texmf-local instead of texmf, else your file might
be deleted when you update the distribution.
- It doesn't really matter where the file is as long as it is under
[TEXMF]\tex\context, but using "user" is somehow more sensible than
"base".

> What do
> I have to do to let ConTeXt work with the script and to let ConTeXt know
> that something has changed in the script? Is "context --generate" enough
> (after initializing with "setuptex.bat")?

You need to use context --generate only when you add the script for
the first time. After you modify it, you don't need to do anything
unless you are changing ConTeXt source. If you change ConTeXt source,
you need to also run "context --make" (but that would be dangerous
anyway).

> Second: How can I debug errors in my *.lua file? Just put
>  print("debug message")
> in the function that is (supposed to be) called?

Yes, or tex.print (depending on how you want to debug).

Mojca
___________________________________________________________________________________
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] 6+ messages in thread

* Re: Custom lua script (updating and debugging)
  2010-09-28 19:30   ` Mojca Miklavec
@ 2010-09-29  6:50     ` Procházka Lukáš Ing. - Pontex s. r. o.
  2010-09-29  7:23       ` Hans Hagen
  0 siblings, 1 reply; 6+ messages in thread
From: Procházka Lukáš Ing. - Pontex s. r. o. @ 2010-09-29  6:50 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hello,

I have also the experience that when the Lua file is placed where the LUA_PATH system variable points (or: see the documentation how exactly LUA_PATH works), than I can use the 'require' command and the Lua file will be found.

E.g.:

LUA_PATH = (...);C:\MyDir\?.lua

C:\MyDir\MyFile.lua:

print("This is MyFile.lua")

And a ctx file:

\startluacode
   require("MyFile")
\stopluacode

- Will print "This is MyFile.lua" to the output stream when converting .tex to (e.g.) .pdf.

Lukas


On Tue, 28 Sep 2010 21:30:32 +0200, Mojca Miklavec <mojca.miklavec.lists@gmail.com> wrote:

> On Tue, Sep 28, 2010 at 12:41, Stefan Müller wrote:
>> Hi list,
>>
>> I'm currently messing around with a custom lua script (a pretty printer) and
>> I have some beginner trouble.
>>
>> First: I put the file in "MyContexDir\tex\texmf\tex\context\base\".
>
> Put them into
>     MyContexDir\tex\texmf-local\tex\context\user\
> because:
> - You need to use texmf-local instead of texmf, else your file might
> be deleted when you update the distribution.
> - It doesn't really matter where the file is as long as it is under
> [TEXMF]\tex\context, but using "user" is somehow more sensible than
> "base".
>
>> What do
>> I have to do to let ConTeXt work with the script and to let ConTeXt know
>> that something has changed in the script? Is "context --generate" enough
>> (after initializing with "setuptex.bat")?
>
> You need to use context --generate only when you add the script for
> the first time. After you modify it, you don't need to do anything
> unless you are changing ConTeXt source. If you change ConTeXt source,
> you need to also run "context --make" (but that would be dangerous
> anyway).
>
>> Second: How can I debug errors in my *.lua file? Just put
>>  print("debug message")
>> in the function that is (supposed to be) called?
>
> Yes, or tex.print (depending on how you want to debug).
>
> Mojca
> ___________________________________________________________________________________
> 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
> ___________________________________________________________________________________
>


-- 
Ing. Lukáš Procházka [mailto:LPr@pontex.cz]
Pontex s. r. o.      [mailto:pontex@pontex.cz] [http://www.pontex.cz]
Bezová 1658
147 14 Praha 4

Tel: +420 244 062 238
Fax: +420 244 461 038

___________________________________________________________________________________
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] 6+ messages in thread

* Re: Custom lua script (updating and debugging)
  2010-09-29  6:50     ` Procházka Lukáš Ing. - Pontex s. r. o.
@ 2010-09-29  7:23       ` Hans Hagen
  0 siblings, 0 replies; 6+ messages in thread
From: Hans Hagen @ 2010-09-29  7:23 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 29-9-2010 8:50, Procházka Lukáš Ing. - Pontex s. r. o. wrote:
> Hello,
>
> I have also the experience that when the Lua file is placed where the
> LUA_PATH system variable points (or: see the documentation how exactly
> LUA_PATH works), than I can use the 'require' command and the Lua file
> will be found.
>
> E.g.:
>
> LUA_PATH = (...);C:\MyDir\?.lua
>
> C:\MyDir\MyFile.lua:
>
> print("This is MyFile.lua")
>
> And a ctx file:
>
> \startluacode
> require("MyFile")
> \stopluacode
>
> - Will print "This is MyFile.lua" to the output stream when converting
> .tex to (e.g.) .pdf.

texmf-[local|project]/scripts/context/lua

should work out ok with require, given that you also have regenerated 
the file database

> Lukas
>
>
> On Tue, 28 Sep 2010 21:30:32 +0200, Mojca Miklavec
> <mojca.miklavec.lists@gmail.com> wrote:
>
>> On Tue, Sep 28, 2010 at 12:41, Stefan Müller wrote:
>>> Hi list,
>>>
>>> I'm currently messing around with a custom lua script (a pretty
>>> printer) and
>>> I have some beginner trouble.
>>>
>>> First: I put the file in "MyContexDir\tex\texmf\tex\context\base\".
>>
>> Put them into
>> MyContexDir\tex\texmf-local\tex\context\user\
>> because:
>> - You need to use texmf-local instead of texmf, else your file might
>> be deleted when you update the distribution.
>> - It doesn't really matter where the file is as long as it is under
>> [TEXMF]\tex\context, but using "user" is somehow more sensible than
>> "base".
>>
>>> What do
>>> I have to do to let ConTeXt work with the script and to let ConTeXt know
>>> that something has changed in the script? Is "context --generate" enough
>>> (after initializing with "setuptex.bat")?
>>
>> You need to use context --generate only when you add the script for
>> the first time. After you modify it, you don't need to do anything
>> unless you are changing ConTeXt source. If you change ConTeXt source,
>> you need to also run "context --make" (but that would be dangerous
>> anyway).
>>
>>> Second: How can I debug errors in my *.lua file? Just put
>>> print("debug message")
>>> in the function that is (supposed to be) called?
>>
>> Yes, or tex.print (depending on how you want to debug).
>>
>> Mojca
>> ___________________________________________________________________________________
>>
>> 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
>> ___________________________________________________________________________________
>>
>>
>
>


-- 

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 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] 6+ messages in thread

* Re: Custom lua script (updating and debugging)
  2010-09-28 21:53   ` Custom lua script (updating and debugging) Stefan Müller
@ 2010-09-29 17:47     ` Stefan Müller
  0 siblings, 0 replies; 6+ messages in thread
From: Stefan Müller @ 2010-09-29 17:47 UTC (permalink / raw)
  To: ntg-context

Sorry for replying to the wrong thread...

I just wanted to say that it works now. I justed started again from 
scratch and did the same as below. No idea what caused the trouble.

Thanks again,
Stefan.

On 28.09.2010 23:53, Stefan Müller wrote:
> Hi,
>
> thanks for the fast reply Mojca! Unfortunately it is still not working. Here
> is what I did. I'm afraid it has possibly more to do with pretty printers in
> particular (than lua scripts in general), but actually I have no idea.
>
> I took the file
>    MyConTeXtDir/tex/texmf-context/tex/context/base/pret-lua.lua
> and copied it to
>    MyConTeXtDir/tex/texmf-local/tex/context/user/pret-pas.lua
> Next I replaced every occurance of "lua" in this new file by "pas" (so this
> changed the name of one function and renamed the visualizer itself). Then I
> ran "context --generate".
>
> My testfile is added below. The "end" is typeset as if pret-pas.lua wouldn't
> exist. If I change "option=PAS" to "option=LUA" it works as intended ("end" is
> green). What is going on here? Any help is appreciated.
>
> \installprettytype[PAS][PAS]
> \setupcolors[state=start]
> \setuptyping[option=color]
> \definetyping[PAS][option=PAS, escape=yes, tab=4, numbering=line]
>
> \starttext \startPAS
> end
> \stopPAS \stoptext
>
> Thanks in advance,
> Stefan.
>
> PS: Additional question: Is it possible to integrate "option=color" into the
> "\definetyping[PAS]"? option={PAS,color}?
> ___________________________________________________________________________________
> 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
> ___________________________________________________________________________________
>
___________________________________________________________________________________
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] 6+ messages in thread

* Re: Custom lua script (updating and debugging)
  2010-09-28 21:18 ` Hans Hagen
@ 2010-09-28 21:53   ` Stefan Müller
  2010-09-29 17:47     ` Stefan Müller
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Müller @ 2010-09-28 21:53 UTC (permalink / raw)
  To: ntg-context

Hi,

thanks for the fast reply Mojca! Unfortunately it is still not working. Here 
is what I did. I'm afraid it has possibly more to do with pretty printers in 
particular (than lua scripts in general), but actually I have no idea.

I took the file
  MyConTeXtDir/tex/texmf-context/tex/context/base/pret-lua.lua
and copied it to
  MyConTeXtDir/tex/texmf-local/tex/context/user/pret-pas.lua
Next I replaced every occurance of "lua" in this new file by "pas" (so this 
changed the name of one function and renamed the visualizer itself). Then I 
ran "context --generate".

My testfile is added below. The "end" is typeset as if pret-pas.lua wouldn't 
exist. If I change "option=PAS" to "option=LUA" it works as intended ("end" is 
green). What is going on here? Any help is appreciated.

\installprettytype[PAS][PAS]
\setupcolors[state=start]
\setuptyping[option=color]
\definetyping[PAS][option=PAS, escape=yes, tab=4, numbering=line]

\starttext \startPAS
end
\stopPAS \stoptext

Thanks in advance,
Stefan.

PS: Additional question: Is it possible to integrate "option=color" into the 
"\definetyping[PAS]"? option={PAS,color}?
___________________________________________________________________________________
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] 6+ messages in thread

end of thread, other threads:[~2010-09-29 17:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <mailman.1.1285668002.22946.ntg-context@ntg.nl>
2010-09-28 10:41 ` Custom lua script (updating and debugging) Stefan Müller
2010-09-28 19:30   ` Mojca Miklavec
2010-09-29  6:50     ` Procházka Lukáš Ing. - Pontex s. r. o.
2010-09-29  7:23       ` Hans Hagen
2010-09-28 14:08 metapost: unable to make mpx file error Alan BRASLAU
2010-09-28 21:18 ` Hans Hagen
2010-09-28 21:53   ` Custom lua script (updating and debugging) Stefan Müller
2010-09-29 17:47     ` Stefan Müller

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).