Heiko Oberdiek wrote:
Hello,
in the TeX world scripts are usually installed below TDS:scripts.
Lua does know a module system.
Example: There is a package "foobar" with module "foobar.hello". Lua then searches in some standard places for foobar/hello.lua
However LuaTeX neglects the texmf trees. Thus "package.loaders" could be extended by a kpse loader, e.g.:
function kpse.module_loader(module) local file if string.find(module, ".", 1, true) then -- What to do? -- the following is just an unreliable emergency workaround: module = string.gsub(module, "^.*\%.", "") file = kpse.find_file(module .. ".lua", "texmfscripts") else file = kpse.find_file(module .. ".lua", "texmfscripts") end if file then local loader, error = loadfile(file) if loader then return loader end return "\n\t KPSE loading error:\n" .. error end return "\n\t KPSE search failed" end table.insert(package.loaders, kpse.module_loader)
However, the problem are modules with dots. I haven't find a solution using kpse functions. kpsewhich --format=texmfscripts foobar/hello.lua doesn't find the file.
well, maybe you could ask for the path variable, and loop over it there's also luainputs
Perhaps a search path could be hacked by using the output of kpsewhich --show-path=texmfscripts and appending the module directories to each path component. But: * LuaTeX's kpse library doesn't have a "show_path" function. * os.execute is not available in safer mode. * Last but not least, a kpse function is missing for searching along the modified path specification.
can't you use lua for that?
* Portability among different operating systems. (directory specificator, ..., LUA_DIRSEP isn't available, ...)
Ideas?
we explicitly didn't hard code these things because each user and/or macro package may want to do it different (the same for suffixes of lua files)
Something like "foobar_hello.lua" isn't the best solution: * Redundancy in the full name: TDS:scripts/foobar/foobar_hello.lua * It doesn't scale well, e.g. it pollutes "package.loaded".
Hans ----------------------------------------------------------------- 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 -----------------------------------------------------------------