Re: [NTG-context] Current source directory.

2012-09-29 Thread Sietse Brouwer
Hi André,

Hans is right, it's a version problem.
You're using 2012.05.30 11:26 (from May)
I'm using 2012.09.25 21:44.

resolvers.inputstack is defined in my tex-data.lua.
I looked up your version among the commits on
http://repo.or.cz/w/context.git/shortlog,
and found that resolvers.inputstack is not yet defined in your data-tex.lua.
http://repo.or.cz/w/context.git/blob/ad5540007a2ac6504a47289ace109a76ec759a7e:/tex/context/base/data-tex.lua

So, you'll need to update I think. Which is a bit more work than usual
because minimals.contextgarden.net is down, but Johan Sandblom's
explains quite nicely what to do.
http://thread.gmane.org/gmane.comp.tex.context/78441/focus=78486

Cheers,
Sietse

On Fri, Sep 28, 2012 at 11:56 PM, Andre Caldas
andre.em.cal...@gmail.com wrote:
 My mistake: I tested the code I gave you in \startluacode, but then
 for the e-mail I wrapped it in \cldcontext.

 I had tested it using startluacode, also. :-(


 These two versions both work, and I actually tested them this time:

 \startluacode
  context(environment.runpath .. '/'  ..
  file.pathpart(resolvers.inputstack[#resolvers.inputstack])
  )
 \stopluacode

 I get this:
 ! LuaTeX error main ctx instance:3: attempt to get length of field
 'inputstack' (a nil value)
 stack traceback:
 main ctx instance:3: in main chunk.

 system   tex  error on line 7 in file
 products/topologia_geral.tex: LuaTeX error  ...
 [...]
 })ted text ...resolvers.inputstack])

 \luat_start_lua_code_indeed ...ua \zerocount {#1}}

 l.7 \stopluacode


 \cldcontext{
  environment.runpath .. '/'  ..
  
 file.pathpart(resolvers.inputstack[table.getn(resolvers.inputstack)])
 }

 And this:
 ! LuaTeX error main ctx instance:1: bad argument #1 to 'getn' (table
 expected, got nil)
 stack traceback:
 [C]: in function 'getn'
 main ctx instance:1: in main chunk.

 system   tex  error on line 6 in file
 products/topologia_geral.tex: LuaTeX error  ...

 [...]

 \cldcontext ...\directlua \zerocount {context(#1)}

 l.6 }


 Sorry about that mistake.

 No need to apologize! :-)
 It seems that resolvers.inputstack is not defined in my system. Where
 is it defined in yours? file-res.lua?


 Thank you very very much, :-)
 André Caldas.
 ___
 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
___

Re: [NTG-context] Current source directory.

2012-09-28 Thread Andre Caldas
Dear Sietse,

Thanks a lot!!!

 Finally found it, after lots of trial-and-erroring through
 likely-looking table names in file-job.lua: the stack of input files
 is kept in resolvers.inputstack.

I don't program any lua. But I was taking a look at file-job.lua
myself. I have a lot to learn!! :-)


 Assuming (absolute path of invocation
 dir) + (path of file relative to invocation dir) = the desired path,

I don't mind this assumption.
Actually, I don't mind having a path relative to the currdir.


 the following should work.

 \cldcontext{
 environment.runpath .. '/'  ..
 file.pathpart(resolvers.inputstack[#resolvers.inputstack])
 }

I will try this now.


 You may or may not want to parse out any ./ and ../ components.

No, I don't need that.

 (If you do: helpful filename manipulation functions (such as
 file.pathpart, indeed) may be found in l-file.lua.)

Thanks for the tip. Might be useful someday.


 Hope this helps,

It does! :-)
Although, I think there should be a luatex command for this. That
is, something not related to ConTeXt.


Thank you,
André Caldas.
___
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
___

Re: [NTG-context] Current source directory.

2012-09-28 Thread Hans Hagen

On 28-9-2012 14:34, Andre Caldas wrote:


Although, I think there should be a luatex command for this. That
is, something not related to ConTeXt.


lfs.currentdir()

-
  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
___


Re: [NTG-context] Current source directory.

2012-09-28 Thread Andre Caldas
Hi!

 the following should work.

 \cldcontext{
 environment.runpath .. '/'  ..
 file.pathpart(resolvers.inputstack[#resolvers.inputstack])
 }

Sorry, to ask such a dumb question...
- Do I need to include file-job.lua somehow?


André Caldas.
___
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
___

Re: [NTG-context] Current source directory.

2012-09-28 Thread Sietse Brouwer
Hi André,

 Sorry, to ask such a dumb question...
 - Do I need to include file-job.lua somehow?

No need to include it, it's part of the ConTeXt core.
I only mentioned the filename in case people wanted to see what else
was in that file; the code snippet should Just Work. Is it working for
you?

Regards,
Sietse

On Fri, Sep 28, 2012 at 9:17 PM, Andre Caldas andre.em.cal...@gmail.com wrote:
 Hi!

 the following should work.

 \cldcontext{
 environment.runpath .. '/'  ..
 file.pathpart(resolvers.inputstack[#resolvers.inputstack])
 }

 Sorry, to ask such a dumb question...
 - Do I need to include file-job.lua somehow?


 André Caldas.
 ___
 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
___

Re: [NTG-context] Current source directory.

2012-09-28 Thread Andre Caldas
 - Do I need to include file-job.lua somehow?

 No need to include it, it's part of the ConTeXt core.
 [...]
 Is it working for you?

No. I get:
! LuaTeX error main ctx instance:1: attempt to get length of field
'inputstack' (a nil value)
stack traceback:
main ctx instance:1: in main chunk.

system   tex  error on line 6 in file
products/topologia_geral.tex: LuaTeX error  ...

[*snip]

\cldcontext ...\directlua \zerocount {context(#1)}

l.6 }


By the way, context --version gives:
mtx-context | ConTeXt Process Management 0.52
mtx-context |
mtx-context | main context file:
/usr/share/texmf/tex/context/base/context.mkiv
mtx-context | current version: 2012.05.30 11:26


André Caldas.
___
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
___

Re: [NTG-context] Current source directory.

2012-09-28 Thread Sietse Brouwer
Hi André,

My mistake: I tested the code I gave you in \startluacode, but then
for the e-mail I wrapped it in \cldcontext. This is not the same: in
\startluacode # has its literal value, but in \cldcontext it is
interpreted as part of a macro parameter like #1.
So to get the length of a table t inside \cldcontext, I should have
used the idiom table.getn(t) instead of #t.

These two versions both work, and I actually tested them this time:

\startluacode
 context(environment.runpath .. '/'  ..
 file.pathpart(resolvers.inputstack[#resolvers.inputstack])
 )
\stopluacode

\cldcontext{
 environment.runpath .. '/'  ..
 file.pathpart(resolvers.inputstack[table.getn(resolvers.inputstack)])
}

Sorry about that mistake.
Cheers,
Sietse
___
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
___

Re: [NTG-context] Current source directory.

2012-09-28 Thread Andre Caldas
 My mistake: I tested the code I gave you in \startluacode, but then
 for the e-mail I wrapped it in \cldcontext.

I had tested it using startluacode, also. :-(


 These two versions both work, and I actually tested them this time:

 \startluacode
  context(environment.runpath .. '/'  ..
  file.pathpart(resolvers.inputstack[#resolvers.inputstack])
  )
 \stopluacode

I get this:
! LuaTeX error main ctx instance:3: attempt to get length of field
'inputstack' (a nil value)
stack traceback:
main ctx instance:3: in main chunk.

system   tex  error on line 7 in file
products/topologia_geral.tex: LuaTeX error  ...
[...]
})ted text ...resolvers.inputstack])

\luat_start_lua_code_indeed ...ua \zerocount {#1}}

l.7 \stopluacode


 \cldcontext{
  environment.runpath .. '/'  ..
  file.pathpart(resolvers.inputstack[table.getn(resolvers.inputstack)])
 }

And this:
! LuaTeX error main ctx instance:1: bad argument #1 to 'getn' (table
expected, got nil)
stack traceback:
[C]: in function 'getn'
main ctx instance:1: in main chunk.

system   tex  error on line 6 in file
products/topologia_geral.tex: LuaTeX error  ...

[...]

\cldcontext ...\directlua \zerocount {context(#1)}

l.6 }


 Sorry about that mistake.

No need to apologize! :-)
It seems that resolvers.inputstack is not defined in my system. Where
is it defined in yours? file-res.lua?


Thank you very very much, :-)
André Caldas.
___
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
___

Re: [NTG-context] Current source directory.

2012-09-28 Thread Hans Hagen

On 28-9-2012 23:56, Andre Caldas wrote:

My mistake: I tested the code I gave you in \startluacode, but then
for the e-mail I wrapped it in \cldcontext.


I had tested it using startluacode, also. :-(



These two versions both work, and I actually tested them this time:

\startluacode
  context(environment.runpath .. '/'  ..
  file.pathpart(resolvers.inputstack[#resolvers.inputstack])
  )
\stopluacode


I get this:
! LuaTeX error main ctx instance:3: attempt to get length of field
'inputstack' (a nil value)


are you sure that you use the same version?

btw, keep in mind that you can never really be sure in what file you are 
because of (1) caching and (2) delayed expansion (e.g. macros) or (3) 
info can come from elsewhere


Hans

-
  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
___


Re: [NTG-context] Current source directory.

2012-09-27 Thread Andre Caldas
Thank you for yor time, Peter. But this is not what I wanted... :-(

 Is there a way to know the directory of the currently being processed
 source file?

 This works with mkiv:

 \starttext
 PWD: \cldcontext{io.popenpwd:read()}
 \stoptext

This gives the directory where the context command was called from.
I want the directory where the tex file being processed lives in.

For example, I have a component
products/product/article.tex
Inside a product
products/product.tex
I produce it by calling
context products/product.tex

I want to know a function that returns
/fullpath_to_project/products/
when I call it from the script products/product.tex. And I want it to return
/fullpath_to_project/products/product/
when I call it from the script products/product/article.tex.


Cheers,
André Caldas.
___
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
___

Re: [NTG-context] Current source directory.

2012-09-27 Thread Sietse Brouwer
 I want to know a function that returns
 /fullpath_to_project/products/
 when I call it from the script products/product.tex. And I want it to return
 /fullpath_to_project/products/product/
 when I call it from the script products/product/article.tex.

Finally found it, after lots of trial-and-erroring through
likely-looking table names in file-job.lua: the stack of input files
is kept in resolvers.inputstack. Assuming (absolute path of invocation
dir) + (path of file relative to invocation dir) = the desired path,
the following should work.

\cldcontext{
environment.runpath .. '/'  ..
file.pathpart(resolvers.inputstack[#resolvers.inputstack])
}


You may or may not want to parse out any ./ and ../ components.
(If you do: helpful filename manipulation functions (such as
file.pathpart, indeed) may be found in l-file.lua.)

Hope this helps,
Sietse


On Fri, Sep 28, 2012 at 12:38 AM, Andre Caldas
andre.em.cal...@gmail.com wrote:
 Thank you for yor time, Peter. But this is not what I wanted... :-(

 Is there a way to know the directory of the currently being processed
 source file?

 This works with mkiv:

 \starttext
 PWD: \cldcontext{io.popenpwd:read()}
 \stoptext

 This gives the directory where the context command was called from.
 I want the directory where the tex file being processed lives in.

 For example, I have a component
 products/product/article.tex
 Inside a product
 products/product.tex
 I produce it by calling
 context products/product.tex




 Cheers,
 André Caldas.
 ___
 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
___

Re: [NTG-context] Current source directory.

2012-09-24 Thread Peter Münster
On Mon, Sep 24 2012, Andre Caldas wrote:

 Is there a way to know the directory of the currently being processed
 source file?

This works with mkiv:

\starttext
PWD: \cldcontext{io.popenpwd:read()}
\stoptext

-- 
   Peter
___
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
___


Re: [NTG-context] Current source directory.

2012-09-24 Thread Peter Münster
On Mon, Sep 24 2012, Peter Münster wrote:

 \starttext
 PWD: \cldcontext{io.popenpwd:read()}
 \stoptext

Or better:

\starttext
PWD: \cldcontext{environment.runpath}
\stoptext

-- 
   Peter
___
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
___