[Dev-luatex] Module searching

Hans Hagen pragma at wxs.nl
Tue Dec 11 10:25:57 CET 2007


Heiko Oberdiek wrote:

> Reimplementing kpse library in Lua with analyzing texmf.cnf
> files, path expansion, ls-R lookup, ...?

in this case i was more thinking of looking in the paths reported by 
kpse (given that the path variable can be expanded), so, no lookup, but 
looling at the file system; another option is that you just put the file 
alongside the tex file, lookup the tex file, replace the suffix and load 
the file; personally i see no need to put lua files that belong to tex 
in the scripts path;

> The other file types are covered: TeX files, tfm files, type 1 files, ...
> Missing is a proper support for lua scripts.

lua scripts as such are like perl, ruby, whatever scripts; the 
texmfscript path is not for tex related (runtime embedded or whatever) 
scripts ... makes packaging a mess when we get a duplicate tree there, 
apart from clashes

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

i'd say .. overload require, and put the modules in the tex tree

> Lua provides four search strategies by default.
> These can be changed and exended, see the table "package.loader"
> (latest Lua docu for 5.1)

sure

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

a solution indeed, but as said ... i wonder if texmfscripts is meant for 
that (not sure how easy it is for packaging too)

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


More information about the dev-luatex mailing list