diff options
Diffstat (limited to 'Master/texmf-dist/scripts/texdoc/texdoclib-config.tlu')
-rwxr-xr-x | Master/texmf-dist/scripts/texdoc/texdoclib-config.tlu | 44 |
1 files changed, 35 insertions, 9 deletions
diff --git a/Master/texmf-dist/scripts/texdoc/texdoclib-config.tlu b/Master/texmf-dist/scripts/texdoc/texdoclib-config.tlu index 471fef9fdcb..4eb660873f9 100755 --- a/Master/texmf-dist/scripts/texdoc/texdoclib-config.tlu +++ b/Master/texmf-dist/scripts/texdoc/texdoclib-config.tlu @@ -2,9 +2,12 @@ -- -- The TeX Live Team, GPLv3, see texdoclib.tlu for details +-- dependencies +local lfs = require 'lfs' + -- shortcuts local M = {} -local C = require('texdoclib-const') +local C = require 'texdoclib-const' -- config is local to this file local config = {} @@ -172,8 +175,20 @@ end -- Note: Make sure to set a default value in setup_config_from_defaults() -- if relevant. local function setup_config_from_cl(cl_config) + local err_print = import_function('util', 'err_print') + for _, e in ipairs(cl_config) do - set_config_element(e[1], e[2], {src='cl', name=e[3]}) + if e[3] == '-c' then + local item, value = string.match(e[1], '^([%a%d_]+)%s*=%s*(.+)') + if item and value then + set_config_element(item, value, {src='cl', name='-c'}) + else + err_print('warning', + 'Invalid argument "%s" for Option -c. Ignoring.', e[1]) + end + else + set_config_element(e[1], e[2], {src='cl', name=e[3]}) + end end end @@ -184,6 +199,7 @@ local function setup_config_from_env() local function set_config_elt_from_vars(key, vars) for _, var in ipairs(vars) do local value = os.getenv(var) + value = value and string.gmatch(value, '([^:]+)')() if value then set_config_element(key, value, {src='env', name=var}) end @@ -316,7 +332,7 @@ function M.show_config_files(is_action) or function(s) dbg_print('files', s) end -- show the list of configuration files - print_func('Configuration files are:') + print_func('Configuration file(s):') for i, file in ipairs(config_files) do -- if not verbose, do not show "not found" files for -f if file.status ~= "not found" @@ -329,7 +345,7 @@ function M.show_config_files(is_action) if is_action then print_func('Recommended file(s) for personal settings:') local sep = (os.type == 'windows') and ';' or ':' - local texmfhomes = string.explode(kpse.var_value('TEXMFHOME'), sep) + local texmfhomes = string.explode(kpse.expand_path('$TEXMFHOME'), sep) for _, home in ipairs(texmfhomes) do print_func(indent .. w32_path(home .. '/texdoc/texdoc.cnf')) end @@ -340,12 +356,20 @@ end -- end scope of config_files ---------------------- config from locale settings ------------------------- +-- set up the locale from the system setting +-- Note that luatex set the locale to a neutral value for a reason, so we need +-- to set the locale (for the category 'all') to nil to ignore it. local function setup_config_from_locale() - local current = os.setlocale(nil, 'all') - os.setlocale('', 'all') - local native = os.setlocale(nil, 'time') - os.setlocale(current, 'all') - local lang = string.match(native, '^[a-z][a-z]') + local current, native, lang + current = os.setlocale(nil, 'all') -- save the default value + os.setlocale('', 'all') -- set it to nil temporary + native = os.setlocale(nil, 'all') -- get the actual system locale + os.setlocale(current, 'all') -- put back the default value + if native == 'C' then -- the default C locale is en + lang = 'en' + else + lang = string.match(native, '^[a-z][a-z]') + end if lang then set_config_element('lang', lang, {src='loc'}) end @@ -381,6 +405,8 @@ local function desktop_environment_viewer() end if os.getenv('GNOME_DESKTOP_SESSION_ID') or string.match(xdg_current_desktop, '.*GNOME.*') then -- gnome + if is_in_path('gio') then return '(gio open %s) &' end + -- followings are deplecated commands but keep these for compatibility if is_in_path('gvfs-open') then return '(gvfs-open %s) &' end if is_in_path('gnome-open') then return '(gnome-open %s) &' end end |