From c6186ec31d5263fef8bd3a9ef9d450cf93fc7ba2 Mon Sep 17 00:00:00 2001 From: Takuto ASAKURA Date: Sun, 28 Feb 2021 18:54:17 +0900 Subject: [PATCH] show all possible config files for -vf (cf. #60) --- script/texdoclib-config.tlu | 13 ++++++------- script/texdoclib-const.tlu | 4 ++++ script/texdoclib-search.tlu | 5 ++--- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/script/texdoclib-config.tlu b/script/texdoclib-config.tlu index d4f993d..2fc0c99 100644 --- a/script/texdoclib-config.tlu +++ b/script/texdoclib-config.tlu @@ -274,15 +274,15 @@ local function get_config_files() } -- get dirs - local sep = (os.type == 'windows') and ';' or ':' - local texmf_texdoc = kpse.expand_path('$TEXMF/texdoc') - local dirs = texmf_texdoc:explode(sep) + local kpse_texmf = kpse.expand_var('$TEXMF') + local texmfs = kpse.expand_braces(kpse_texmf):explode(C.kpse_sep) -- merge them local ret = {} - for _, dir in ipairs(dirs) do + for _, dir in ipairs(texmfs) do + local path = dir:gsub('^!!', '') for _, name in ipairs(names) do - local pathname = dir .. '/' .. name + local pathname = path .. '/texdoc/' .. name table.insert(ret, pathname) end end @@ -344,9 +344,8 @@ function M.show_config_files(is_action) -- show the recommendation (only for the "files" action) if is_action then print_func('Recommended file(s) for personal settings:') - local sep = (os.type == 'windows') and ';' or ':' -- here TEXMFHOMEs do not have to exist, and thus use kpse.var_value - local texmfhomes = string.explode(kpse.var_value('TEXMFHOME'), sep) + local texmfhomes = kpse.var_value('TEXMFHOME'):explode(C.kpse_sep) for _, home in ipairs(texmfhomes) do print_func(indent .. w32_path(home .. '/texdoc/texdoc.cnf')) end diff --git a/script/texdoclib-const.tlu b/script/texdoclib-const.tlu index a1907c7..b32e571 100644 --- a/script/texdoclib-const.tlu +++ b/script/texdoclib-const.tlu @@ -5,6 +5,7 @@ -- use an empty environment that will become texdoc_env.C (see EOF) local constants = {} local kpse = kpse or require 'kpse' +local os = os or require 'os' local setfenv = setfenv local texdoc_env @@ -133,6 +134,9 @@ data_tlpdb_name = 'texdoc/Data.tlpdb.lua' place_holder = '%%s' -- used for viewer commands +-- kpse path separator +kpse_sep = (os.type == 'windows') and ';' or ':' + -- END constants -- get our previous environment back diff --git a/script/texdoclib-search.tlu b/script/texdoclib-search.tlu index 0340fa6..8718dc8 100644 --- a/script/texdoclib-search.tlu +++ b/script/texdoclib-search.tlu @@ -280,7 +280,7 @@ local function scan_db(patlist, code, lsr_db) end end ---------------------- manage TEXDOCS trees à la kpse ---------------------- +--------------------- manage TEXDOCS trees of the kpse ---------------------- -- build a db from a ls-R file local function init_lsr_db(root, shift) @@ -371,11 +371,10 @@ init_texdocs_database = function() end doc_roots = {} - local sep = (os.type == 'windows') and ';' or ':' local kpse_texdocs = kpse.expand_var('$TEXDOCS') -- expand the path and turn it into a lua list - local raw_doc_roots = kpse.expand_braces(kpse_texdocs):explode(sep) + local raw_doc_roots = kpse.expand_braces(kpse_texdocs):explode(C.kpse_sep) local max = #raw_doc_roots + 1 for j, dir in ipairs(raw_doc_roots) do