It would be REALLY NICE if the functionality of "pathrelativetome" was provided by ConTeXt.
in file-job.lua add around the function 'process':
You make me really happy, Hans! :-) I will change file-job.lua on my system to test. I can do this only on Wednesday.
local function toppath() [...] local pathname = dirname(inputstack[#inputstack] or "")
I didn't check it in lua. But the unix command "dirname" returns "." if given an empty string. That is, $ dirname '' . I don't know when "inputstack" could be empty... but maybe a warning should be issued, and the return value of toppath should be declared undefined. That is, it would be an error to call toppath if "inputstack" is empty.
[...] resolvers.toppath = topath
toppath? (double "p")
Then you can something: [...] \component toppath:/subpath/somefile.tex
Nice.
All given that the top of the inputstack is still ok.
Maybe the code could have some sort of "assertion" to 1. check for "stack underflow"; and/or 2. check if the file "somefile.tex" exists in the directory being popped from the stack. Just for "bug catching"...
If needed I can push/pop some relative code to start/stopcomponent alike code, in which case we will use a different prefix (no clue what name to use)
I don't think it is needed, since the toppath mechanism is rather generic. Writing "\component toppath:/subpath/somefile.tex" is fine by me. Unless you think that "start/stopcomponent" should be deprecated (or, at least, discouraged) in favour of this new version. Maybe it would be nice to have a function that returns the value of "inputstack[#inputstack]". But I don't know if it is useful... Thank you very very much for your time! André Caldas.