On Mon, Dec 10, 2007 at 11:51:28PM +0100, Hans Hagen wrote:
Heiko Oberdiek wrote:
Example: There is a package "foobar" with module "foobar.hello".
I haven't found 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
* "kpsewhich --show-path-name" doesn't help much: * It's not available in library "kpse". * It contains unwanted stuff (!!, //, ...) * kpse.expand_path (kpsewhich --expand-path) does not expand extra colons: texmf.cnf: TEXMFSCRIPTS=$TEXMF/scripts// then TEXMFSCRIPTS=.: kpsewhich --expand-path '$TEXMFSCRIPTS' only returns . * No ls-R lookup.
there's also luainputs
I don't see, how it could help here.
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?
Reimplementing kpse library in Lua with analyzing texmf.cnf files, path expansion, ls-R lookup, ...?
* 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)
The other file types are covered: TeX files, tfm files, type 1 files, ... Missing is a proper support for lua scripts. A user/macro writer says for example: \documentclass{article} \usepackage{longtable} \usepackage[T1]{fontenc} \usepackage{lmodern} But he doesn't implement a search algorithm for finding article.cls or longtable.sty or the latin modern fonts. Also Lua has a module system, thus a user/macro writer wants to write: \directlua0{ require("foobar.hello") -- ... } without implementing, how the module is found. Lua provides four search strategies by default. These can be changed and exended, see the table "package.loader" (latest Lua docu for 5.1)
Something like "foobar_hello.lua" isn't the best solution:
Currently I am using TDS:scripts/foobar/foobar.hello.lua This doesn't follow Lua's conventions (TDS:scripts/foobar/hello.lua). But the search is easier: function kpse.module_loader(module) local script = module .. ".lua" local file = kpse.find_file(script, "texmfscripts") if file then local loader, error = loadfile(file) if loader then return loader end return "\n\tKPSE loading error:\n" .. error end return "\n\tKPSE search failed" end table.insert(package.loaders, kpse.module_loader) and avoids at least:
* It doesn't scale well, e.g. it pollutes "package.loaded".
Yours sincerely
Heiko