summaryrefslogtreecommitdiff
path: root/Master/texmf/scripts
diff options
context:
space:
mode:
authorManuel Pégourié-Gonnard <mpg@elzevir.fr>2010-02-22 13:29:41 +0000
committerManuel Pégourié-Gonnard <mpg@elzevir.fr>2010-02-22 13:29:41 +0000
commitc49d87e1fd943a8309dba938dc8d6900f4295a5e (patch)
treea51c82a6631869cca9a30988236e70b68ecb2058 /Master/texmf/scripts
parent2cb8796c405b33fe218e514526426f2b5c41c8ee (diff)
Texdoc 0.66 addressing various problems.
git-svn-id: svn://tug.org/texlive/trunk@17143 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf/scripts')
-rw-r--r--Master/texmf/scripts/texdoc/config.tlu48
-rw-r--r--Master/texmf/scripts/texdoc/constants.tlu49
-rw-r--r--Master/texmf/scripts/texdoc/functions.tlu4
-rw-r--r--Master/texmf/scripts/texdoc/main.tlu2
-rw-r--r--Master/texmf/scripts/texdoc/search.tlu4
-rwxr-xr-xMaster/texmf/scripts/texdoc/texdoc.tlu2
-rw-r--r--Master/texmf/scripts/texdoc/view.tlu10
7 files changed, 82 insertions, 37 deletions
diff --git a/Master/texmf/scripts/texdoc/config.tlu b/Master/texmf/scripts/texdoc/config.tlu
index edcc59cab2a..475f2f71fbf 100644
--- a/Master/texmf/scripts/texdoc/config.tlu
+++ b/Master/texmf/scripts/texdoc/config.tlu
@@ -52,7 +52,12 @@ function set_config_element (key, value, context)
-- detect the type of the key
if string.match(key, '_list$') then
-- coma-separated list
- local values = string.explode(value, ',')
+ local values
+ if value == '' then
+ values = {}
+ else
+ values = string.explode(value, ',')
+ end
local inverse = {}
for i, j in ipairs(values) do -- sanitize values...
j = string.gsub(j, '%s*$', '')
@@ -139,15 +144,15 @@ function setup_config_from_cl(arg)
-- special options
if (curr_arg == '-h') or (curr_arg == '--help') then
print (C.usage_msg)
- os.exit(0)
+ os.exit(C.exit_ok)
elseif (curr_arg == '-V') or (curr_arg == '--version') then
print (C.progname .. ' ' .. C.version )
- os.exit(0)
+ os.exit(C.exit_ok)
elseif (curr_arg == '-f') or (curr_arg == '--files') then
print (C.progname .. ' ' .. C.version )
setup_config_from_files ()
show_config_files (print, true)
- os.exit(0)
+ os.exit(C.exit_ok)
-- options related to mode
elseif (curr_arg == '-w') or (curr_arg == '--view') then
set_config_elt('mode', 'view')
@@ -185,12 +190,30 @@ function setup_config_from_cl(arg)
elseif string.match(curr_arg, '^%-%-debug=') then
local value = string.gsub(curr_arg, '^%-%-debug=', '')
set_config_elt('debug_list', value)
- -- verbosity
+ -- quiet
+ elseif (curr_arg == '-q') or (curr_arg == '--quiet') then
+ set_config_elt('verbosity_level', C.min_verbosity)
+ -- verbose
+ elseif string.match(curr_arg, '^%-%-verbose') then
+ set_config_elt('verbosity_level', C.max_verbosity)
elseif string.match(curr_arg, '^%-v') then
local value = string.gsub(curr_arg, '^%-v=?', '')
- set_config_elt('verbosity_level', value)
+ if value == '' then
+ set_config_elt('verbosity_level', C.max_verbosity)
+ else -- compatibility syntax
+ err_print('warning',
+ 'The -v option does not accept arguments any more.')
+ err_print('warning',
+ 'Please use the new syntax -v, --verbose (without argument).')
+ set_config_elt('verbosity_level', value)
+ end
elseif string.match(curr_arg, '^%-%-verbosity') then
+ -- compatibility syntax
local value = string.gsub(curr_arg, '^%-%-verbosity=?', '')
+ err_print('warning',
+ '--verbosity is deprecated and will be removed soon.')
+ err_print('warning',
+ 'Please use the new syntax -v, --verbose (without argument).')
set_config_elt('verbosity_level', value)
-- extensions list (deprecated)
elseif string.match(curr_arg, '^%-e') then
@@ -214,8 +237,8 @@ function setup_config_from_cl(arg)
-- problem
else
err_print('error', "unknown option: "..curr_arg)
- print (C.error_msg)
- os.exit(2)
+ err_print('error', C.error_msg)
+ os.exit(C.exit_usage)
end
end
end
@@ -478,9 +501,10 @@ function setup_config_from_defaults()
mode = 'view',
interact_switch = 'true',
machine_switch = 'false',
- verbosity_level = '2',
ext_list = 'pdf, html, txt, ps, dvi, ',
badext_list = 'txt, ',
+ verbosity_level = C.def_verbosity,
+ debug_list = '',
}
-- must be set after mode!
set_config_elt ('alias_switch', alias_from_mode(config.mode))
@@ -521,7 +545,11 @@ function setup_config_and_alias(arg)
if config.machine_switch == true then
real_set_config('interact_switch', false)
end
- -- we were waiting for config.debug_list to be know to do this
+ -- debug implies verbose
+ if table.maxn(config.debug_list) > 0 then
+ real_set_config('verbosity_level', tonumber(C.max_verbosity))
+ end
+ -- we were waiting for config.debug_list to be known to do this
show_config_files(function(s) deb_print('files', s) end)
end
diff --git a/Master/texmf/scripts/texdoc/constants.tlu b/Master/texmf/scripts/texdoc/constants.tlu
index a23d28ec6b0..e7023815cf0 100644
--- a/Master/texmf/scripts/texdoc/constants.tlu
+++ b/Master/texmf/scripts/texdoc/constants.tlu
@@ -15,31 +15,40 @@ load_env(L, {
-- progname and version
fullname = arg[0]
progname = 'texdoc'
-version = '0.65'
+version = '0.66'
-- make sure to update setup_config_from_cl() accordingly
-- and set a default value in setup_config_from_defaults() if relevant
usage_msg = [[
-texdoc tries to find appropriate TeX documentation for the specified NAME(s).
-With no NAME, it can print configuration information (-f, --files);
-the usual --help and --version options are also accepted.
-Usage: texdoc [OPTIONS]... [NAME]...
- -f, --files Print the name of the config files being used.
- -w, --view Use view mode: start a viewer.
+Usage: texdoc [OPTION]... [NAME]...
+
+Try to find appropriate TeX documentation for the specified NAME(s).
+The default (view mode) is to display the documentation.
+
+With no NAME, print information about texdoc (--help, --version, --files).
+
+ -h, --help Print this help message.
+ -V, --version Print the version number.
+ -f, --files Print the list of configuration files used.
+
+ -w, --view Use view mode: start a viewer. (default)
-m, --mixed Use mixed mode (view or list).
-l, --list Use list mode: show a list of results.
-s, --showall Use showall mode: show also "bad" results.
- -r, --regex Use regex mode. (Deprecated.)
- -e, --extensions=L Set ext_list=L. (Deprecated.)
- -a, --alias Use the alias table.
+ -M, --machine Machine-readable output (list or showall modes).
+
+ -a, --alias Use the alias table. (default)
-A, --noalias Don't use the alias table.
- -i, --interact Use interactive menus.
+
+ -i, --interact Use interactive menus. (default)
-I, --nointeract Use plain lists, no interaction required.
- -v, --verbosity=N Set verbosity level to N.
- -d, --debug[=list] Activate debug for selected items (default all).
- -M, --machine Use a more machine-friendly output format.
+
+ -q, --quiet Suppress warnings and most error messages.
+ -v, --verbose Print additional information (eg, viewer command).
+ -d, --debug[=list] Print debug info for selected items (default: all).
+
Environment: PAGER, BROWSER, PDFVIEWER, PSVIEWER, DVIVIEWER.
-Files: <texmf>/texdoc/texdoc.cnf files, see the -f option.
+Files: <texmf>/texdoc/texdoc.cnf, see output of the --files option.
Homepage: http://tug.org/texdoc/
Manual: displayed by `texdoc texdoc'.]]
@@ -73,6 +82,13 @@ err_priority = {
warning = 2,
info = 3,
}
+min_verbosity='0'
+max_verbosity='3'
+def_verbosity='2'
+
+exit_ok = 0
+--exit_error = 1 -- apparently hard-coded in Lua
+exit_usage = 2
known_debugs = {
version = {},
@@ -80,9 +96,6 @@ known_debugs = {
config = {'files'},
view = {},
texdocs = {},
- filesea = {},
- lsrsea = {},
- kpse = {'texdocs', 'filesea', 'lsrsea'},
score = {},
}
diff --git a/Master/texmf/scripts/texdoc/functions.tlu b/Master/texmf/scripts/texdoc/functions.tlu
index cff6e2aaeec..e93debafffc 100644
--- a/Master/texmf/scripts/texdoc/functions.tlu
+++ b/Master/texmf/scripts/texdoc/functions.tlu
@@ -9,7 +9,7 @@ local L = {}
load_env(L, {
'export_symbols',
'string', 'io', 'os',
- 'pairs', 'ipairs',
+ 'pairs', 'ipairs', 'tonumber',
'C',
'config',
})
@@ -29,7 +29,7 @@ end
-- generic error display function (see the error_priority constant)
function err_print (lvl, msg)
-- be careful: maybe config.verbosity_level is not set yet
- local verbosity_level = config.verbosity_level or 2
+ local verbosity_level = config.verbosity_level or tonumber(C.def_verbosity)
if C.err_priority[lvl] <= verbosity_level then
io.stderr:write ("texdoc "..lvl..": "..msg.."\n")
end
diff --git a/Master/texmf/scripts/texdoc/main.tlu b/Master/texmf/scripts/texdoc/main.tlu
index c5ff50d2ded..cb105eabda3 100644
--- a/Master/texmf/scripts/texdoc/main.tlu
+++ b/Master/texmf/scripts/texdoc/main.tlu
@@ -22,7 +22,7 @@ setup_config_and_alias(arg)
-- make sure we actually have argument(s)
if not arg[1] then
print(C.usage_msg)
- os.exit(2)
+ os.exit(C.exit_usage)
end
-- main loop
diff --git a/Master/texmf/scripts/texdoc/search.tlu b/Master/texmf/scripts/texdoc/search.tlu
index a962eedf7c1..2679d01d1d2 100644
--- a/Master/texmf/scripts/texdoc/search.tlu
+++ b/Master/texmf/scripts/texdoc/search.tlu
@@ -209,7 +209,6 @@ end
-- scan a tree without ls-R file
function scan_tree (patlist, code, base, cwd, recurse)
- deb_print('filesea', "Entering directory: "..cwd)
for file in lfs.dir(base..'/'..cwd) do
if file ~= '.' and file ~= '..' then
local f = (cwd == '') and file or cwd..'/'..file
@@ -221,7 +220,6 @@ function scan_tree (patlist, code, base, cwd, recurse)
end
end
end
- deb_print('filesea', "Leaving directory: "..cwd)
end
-- scan a ls-R file
@@ -245,9 +243,7 @@ function scan_lsr(patlist, code, cwd, shift)
isdoc = true
current_dir = string.sub (dir_line, l+1)
is_dir[current_dir] = true
- deb_print('lsrsea', 'Scanning directory: '..current_dir)
elseif isdoc then
- deb_print('lsrsea', "Finished scanning: "..shift)
break -- we're exiting the ./doc (or shift) dir, so it's over
end
elseif isdoc then
diff --git a/Master/texmf/scripts/texdoc/texdoc.tlu b/Master/texmf/scripts/texdoc/texdoc.tlu
index 28470c597e7..69090deee2f 100755
--- a/Master/texmf/scripts/texdoc/texdoc.tlu
+++ b/Master/texmf/scripts/texdoc/texdoc.tlu
@@ -72,4 +72,4 @@ texdoc_load('view')
texdoc_load('main')
-- the end
-os.exit(0)
+os.exit(C.exit_ok)
diff --git a/Master/texmf/scripts/texdoc/view.tlu b/Master/texmf/scripts/texdoc/view.tlu
index b2f8d68a139..544c6673539 100644
--- a/Master/texmf/scripts/texdoc/view.tlu
+++ b/Master/texmf/scripts/texdoc/view.tlu
@@ -85,7 +85,15 @@ function try_viewing (view_command, viewer_replacement)
else
view_command = view_command..' '..viewer_replacement
end
- deb_print('view', 'View comand: '..view_command)
+ -- try to catch problems with missing DISPLAY on Unix
+ if os.type == 'unix' and not (os.name == 'macosx')
+ and os.getenv('DISPLAY') == nil then
+ err_print('warning',
+ "DISPLAY is not set. Things may go wrong with you viewer.")
+ err_print('warning',
+ "Try --list if you want results to be listed, not displayed.")
+ end
+ err_print('info', 'View comand: '..view_command)
if not os.execute(view_command) then
err_print('error', "Failed to execute '"..view_command.."'")
return false