Skip to content

Commit a9b9e9c

Browse files
committed
Try LuaTeX when initializing config.texmf_dirs
1 parent f2b6059 commit a9b9e9c

1 file changed

Lines changed: 30 additions & 23 deletions

File tree

digestif/config.lua

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,9 @@ if pre_version then
99
config.version = config.version .. "-" .. pre_version
1010
end
1111

12-
if util.is_command("kpsewhich") then
13-
local pipe = io.popen("kpsewhich -var-brace-value=TEXMF")
14-
local output = pipe:read("l")
15-
local ok, exitt, exitc = pipe:close()
16-
if ok and exitt == "exit" and exitc == 0 then
17-
config.texmf_dirs = util.imap(
18-
function (s) return s:gsub("^!!", "") end,
19-
util.path_list_split(output)
20-
)
21-
elseif config.verbose then
22-
util.log("Error running kpsewhich (%s %d)", exitt, exitc)
23-
end
24-
else -- TODO: What should be the default?
25-
config.texmf_dirs = {
26-
"/usr/local/share/texmf",
27-
"/usr/share/texmf",
28-
"/usr/share/texlive/texmf-local",
29-
"/usr/share/texlive/texmf-dist",
30-
}
31-
end
32-
33-
config.data_dirs = {} -- TODO: What should be the default?
12+
-- TODO: What should be the default?
13+
config.texmf_dirs = {}
14+
config.data_dirs = {}
3415

3516
-- Location of a complete texmf distribution, used for instance to
3617
-- find documentation not installed locally. Passed to format with
@@ -129,15 +110,41 @@ function config.load_from_env()
129110
config.data_dirs = util.path_list_split(DIGESTIF_DATA)
130111
end
131112

113+
local ok, v = pcall(function() return _G.status.list() end)
114+
local lua_type = ok and v.luatex_engine or "lua"
132115
local DIGESTIF_TEXMF = os.getenv("DIGESTIF_TEXMF")
133116
if DIGESTIF_TEXMF then
134117
config.texmf_dirs = util.path_list_split(DIGESTIF_TEXMF)
118+
elseif lua_type == "luametatex" then
119+
-- TODO!
120+
elseif lua_type == "luatex" then
121+
local kpathsea = _G.kpse.new("tex")
122+
local paths = kpathsea:expand_braces(kpathsea:var_value("TEXMF"))
123+
config.texmf_dirs = util.imap(
124+
function(s) return s:gsub("^!!", "") end,
125+
util.path_list_split(paths)
126+
)
127+
elseif util.is_command("kpsewhich") then
128+
local pipe = io.popen("kpsewhich -var-brace-value=TEXMF")
129+
local paths = pipe:read("l")
130+
local ok, exitt, exitc = pipe:close()
131+
if ok and exitt == "exit" and exitc == 0 then
132+
config.texmf_dirs = util.imap(
133+
function(s) return s:gsub("^!!", "") end,
134+
util.path_list_split(paths)
135+
)
136+
elseif config.verbose then
137+
util.log("Error running kpsewhich (%s %d)", exitt, exitc)
138+
end
139+
end
140+
if #config.textmf_dirs == 0 then
141+
util.log("Couldn't initialize DIGESTIF_TEXMF")
135142
end
136143

137144
local DIGESTIF_TLPDB = os.getenv("DIGESTIF_TLPDB")
138145
if DIGESTIF_TLPDB then
139146
config.tlpdb_path = util.path_list_split(DIGESTIF_TLPDB)
140-
end
147+
end -- TODO: copy rest of init from data.lua
141148
end
142149

143150
function config.check_data(dir)

0 commit comments

Comments
 (0)