diff options
author | Karl Berry <karl@freefriends.org> | 2017-05-17 18:11:11 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2017-05-17 18:11:11 +0000 |
commit | dad4e8602c1b3d00021908e8724be9d3d8aa0fdb (patch) | |
tree | 6abe4f1447cacb747680274003eabd39e6640341 | |
parent | 9ec73008397839761e75c813fcebca2448f5258c (diff) |
viewer environment, version 2.017
git-svn-id: svn://tug.org/texlive/trunk@44391 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Master/texmf-dist/scripts/texdoc/constants.tlu | 20 | ||||
-rw-r--r-- | Master/texmf-dist/scripts/texdoc/functions.tlu | 5 | ||||
-rw-r--r-- | Master/texmf-dist/scripts/texdoc/view.tlu | 34 |
3 files changed, 49 insertions, 10 deletions
diff --git a/Master/texmf-dist/scripts/texdoc/constants.tlu b/Master/texmf-dist/scripts/texdoc/constants.tlu index 02d608440da..181cfe54e21 100644 --- a/Master/texmf-dist/scripts/texdoc/constants.tlu +++ b/Master/texmf-dist/scripts/texdoc/constants.tlu @@ -1,6 +1,7 @@ +-- $Id: constants.tlu 13 2017-05-17 18:09:11Z karl $ -- constants.tlu: global "constants" for texdoc. -- --- Manuel Pégourié-Gonnard, GPLv3, see texdoclib.tlu for details +-- Manuel Pégourié-Gonnard, GPLv3+, see texdoclib.tlu for details -- use an empty environment that will become texdoc_env.C (see EOF) local constants = {} @@ -20,7 +21,7 @@ end -- progname and version fullname = kpse.find_file('texdoc/texdoclib', 'lua') progname = 'texdoc' -version = '0.85' +version = '2.017' -- make sure to update setup_config_from_cl() accordingly -- and set a default value in setup_config_from_defaults() if relevant @@ -48,13 +49,17 @@ Options: -v, --verbose Print additional information (eg, viewer command). -d, --debug[=list] Activate debug output (restricted to list). -Environment: PAGER, BROWSER, PDFVIEWER, PSVIEWER, DVIVIEWER. +Environment variables: PAGER, BROWSER, PDFVIEWER, PSVIEWER, DVIVIEWER, +and texdoc_* of each. + Files: <texmf>/texdoc/texdoc.cnf, see output of the --files option. -Report bugs to <texdoc@tug.org>. -Full manual available via `texdoc texdoc'.]] +Full manual available via `texdoc texdoc'. + +Please report bugs to <texdoc@tug.org>. +]] copyright_msg = [[ -Copyright (C) 2008-2013 Manuel P'egouri'e-Gonnard. +Copyright 2008-2017 Manuel P'egouri'e-Gonnard. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it.]] @@ -91,6 +96,7 @@ known_options = { error_msg = [[ Try `texdoc --help' for a short help, `texdoc texdoc' for the user manual.]] + notfound_msg = [[ Sorry, no documentation found for PKGNAME. If you are unsure about the name, try searching CTAN's TeX catalogue at @@ -102,7 +108,7 @@ err_priority = { warning = 2, info = 3, } -min_verbosity='0' +min_verbosity='0' -- (nothing at all) max_verbosity='3' def_verbosity='2' diff --git a/Master/texmf-dist/scripts/texdoc/functions.tlu b/Master/texmf-dist/scripts/texdoc/functions.tlu index f1ff54eca0b..0ab02278450 100644 --- a/Master/texmf-dist/scripts/texdoc/functions.tlu +++ b/Master/texmf-dist/scripts/texdoc/functions.tlu @@ -1,6 +1,7 @@ +-- $Id: functions.tlu 12 2017-05-17 18:07:47Z karl $ -- functions.tlu: general-use functions for texdoc -- --- Manuel Pégourié-Gonnard, GPLv3, see texdoclib.tlu for details +-- Manuel Pégourié-Gonnard, GPLv3+, see texdoclib.tlu for details -- change '/' to '\' on windows -- Use: internal representation of files always use forward slashes. @@ -26,7 +27,7 @@ else end end --- generic error display function (see the error_priority constant) +-- generic error display function (see the err_priority constant) function err_print (lvl, msg) -- be careful: maybe config.verbosity_level is not set yet local verbosity_level = config.verbosity_level or tonumber(C.def_verbosity) diff --git a/Master/texmf-dist/scripts/texdoc/view.tlu b/Master/texmf-dist/scripts/texdoc/view.tlu index 477645adbb2..45e7c9df395 100644 --- a/Master/texmf-dist/scripts/texdoc/view.tlu +++ b/Master/texmf-dist/scripts/texdoc/view.tlu @@ -81,6 +81,7 @@ function try_viewing (view_command, viewer_replacement) else view_command = view_command..' '..viewer_replacement end + -- try to catch problems with missing DISPLAY on Unix if os.type == 'unix' and not (os.name == 'macosx') and os.getenv('DISPLAY') == nil then @@ -90,13 +91,44 @@ function try_viewing (view_command, viewer_replacement) "Try --list to list results instead of displaying them.") end err_print('info', 'View command: '..view_command) + + -- See long comment below this function for the LC_CTYPE story. + -- We only want to reset the environment if we have the value + -- to reset it to. In older versions of luatex, status.lc_* will be nil. + local env_lc_ctype = status.lc_ctype + local luatex_lc_ctype = os.setlocale(nil, 'ctype') + if (env_lc_ctype) then + err_print('info', "Setting environment LC_CTYPE to: "..env_lc_ctype) + os.setenv("LC_CTYPE", env_lc_ctype) + end + + -- the big casino: run the external command. if not os.execute(view_command) then - err_print('error', "Failed to execute '"..view_command.."'") + err_print('error', "Failed to execute: "..view_command) return false end + + -- reset back to "C" (should always be C and always happen, but in case...) + if (luatex_lc_ctype) then + os.setenv("LC_CTYPE", luatex_lc_ctype) + end + return true end +-- Explanation of locale madness: +-- LuaTeX resets LC_CTYPE, LC_COLLATE, LC_NUMERIC to "C". That is good for +-- inside luatex, but when we run an external program, if the user's +-- environment is something else, we want to switch back to it. As of +-- TL 2017 LuaTeX, we can inspect the user's locale with status.lc_ctype, etc. +-- +-- For texdoc purposes, what matters is LC_CTYPE (so we don't bother with +-- the others). For example, with the less pager, when LC_CTYPE=C, +-- non-ASCII bytes are displayed as "<xx>", where xx is the two hex +-- digits for the byte. +-- +-- See <texdoc-dev-source>/tools/Makefile for a standalone test case. + ----------------------------- display results ----------------------------- -- print a list of docfile objects (see search.tlu) as a menu |