From d223c1a3fc30e88dd6d87c5feaab15c62b37825b Mon Sep 17 00:00:00 2001 From: Manuel Pégourié-Gonnard Date: Tue, 15 Jul 2008 23:02:15 +0000 Subject: New -t option setting ext_list on the command-line. Now ext_list without leading dot. Also removed oboselte todo comment about -s options. git-svn-id: svn://tug.org/texlive/trunk@9587 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf/scripts/texlive/texdoc.tlu | 35 ++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 12 deletions(-) (limited to 'Master/texmf') diff --git a/Master/texmf/scripts/texlive/texdoc.tlu b/Master/texmf/scripts/texlive/texdoc.tlu index ee8c6696f53..d3cf9bbcdad 100755 --- a/Master/texmf/scripts/texlive/texdoc.tlu +++ b/Master/texmf/scripts/texlive/texdoc.tlu @@ -28,11 +28,12 @@ Usage: texdoc -h, --help | -v, --version | [option] name(s) -v|--verbose Show the command being used to display the documentation. -a|--alias Use the alias table. -A|--noalias Don't use the alias table. + -t|--type Search only for files of given type (extension). -l|--list List matching files, do not start a viewer. -s|--search Search for name as a pattern.]] notfound_msg = [[ Sorry, no documentation found for PKGNAME. -Please try texdoc -s PKGNAME or even texdoc -S PKGNAME +Please try texdoc -s PKGNAME and make sure the package is installed, or search the TeX Catalogue at http://ctan.org/search.html#byDescription.]] place_holder = '%%s' -- used for viewer commands @@ -69,6 +70,14 @@ function list_iter (t) end end +-- add a dot to ext except if it's empty +function dotted(ext) + if (ext == '') then + return ext + else + return '.'..ext + end +end -- [[ functions for the search option ]] no_lsr_doctrees = {} @@ -90,9 +99,6 @@ function get_lsr_files () end -- for path local i = 0 local n = table.getn(lsr_files) - -- TODO: We completely ignore trees without ls-R files. Since I - -- don't know how to get the output of "find" without resorting to - -- temporary files, anyway, I don't care. return function () i = i +1 if i <= n then return lsr_files[i] end @@ -375,8 +381,8 @@ function setup_config_from_defaults() -- now a particular case for config.ext_list and zip-related stuff if support_zipped then set_config_element('ext_list', - '.pdf,.pdf.gz,.pdf.bz2, html,html.gz,html.bz2, .txt,.txt.gz,.txt.bz2,'.. - '.dvi,.dvi.gz,.dvi.bz2, .ps,.ps.gz,.ps.bz2') + 'pdf,pdf.gz,pdf.bz2, html,html.gz,html.bz2, txt,txt.gz,txt.bz2,'.. + 'dvi,dvi.gz,dvi.bz2, ps,ps.gz,ps.bz2') set_config_list { unzip_gz = 'gzip -d -c ', unzip_bz2 = 'bzip -d -c ', @@ -384,7 +390,7 @@ function setup_config_from_defaults() rm_dir = 'rmdir' } else - set_config_element('ext_list', '.pdf, .html, .txt, .dvi, .ps') + set_config_element('ext_list', 'pdf, html, txt, dvi, ps') end end @@ -395,10 +401,10 @@ end -- command line is unsupported for compressed files by the way) function prepare_viewing (ext) if support_zipped then - zipext = string.match(ext,'%..*%.(.*)') + zipext = string.match(ext,'^.*%.(.*)') if zipext then unzip_command = config['unzip_'..zipext] - viewext = string.match(ext,'%.(.*)%..*$') + viewext = string.match(ext,'^(.*)%..*$') basename_pattern = '.*/(.*%.' .. viewext .. ')' basename = string.match(filename,basename_pattern) tmpdir = os.tmpdir("/tmp/texdoc.XXXXXX") @@ -414,10 +420,10 @@ function prepare_viewing (ext) end else if ext == '' then -- fallback if complete filename has been specified - ext = string.match(filename,'.*(%..*)$') + ext = string.match(filename,'.*%.(.*)$') end viewer_replacement = filename - viewext = string.match(ext,'%.(.*)$') + viewext = ext if not viewext then print ("texdoc warning: cannot determine file type for\n".. filename..", using fallback viewer.") @@ -481,6 +487,7 @@ end -- config options are: -- mode ('view'* or 'list' or 'search') -- enable_alias ('true'* or 'false' (string, not boolean)) +-- ext_list via the -t option verbose = false while table.maxn(arg) > 0 and string.match(arg[1],'^%-') do curr_arg = table.remove(arg,1) @@ -500,6 +507,10 @@ while table.maxn(arg) > 0 and string.match(arg[1],'^%-') do set_config_element('enable_alias', 'false') elseif (curr_arg == '-a') or (curr_arg == '--noalias') then set_config_element('enable_alias', 'true') + elseif string.match(curr_arg, '^-t') then + set_config_element('ext_list', string.gsub(curr_arg, '^-t=?', '')) + elseif string.match(curr_arg, '^--type') then + set_config_element('ext_list', string.gsub(curr_arg, '^--type=?', '')) end end -- defaults using the config table (ext_list comes later) @@ -542,7 +553,7 @@ for docname in list_iter (arg) do pattern_search(docname) elseif (config.mode == 'view') or (config.mode == 'list') then for ext in list_iter(config.ext_list) do - filename = kpse.find_file(docname .. ext, + filename = kpse.find_file(docname .. dotted(ext), "TeX system documentation") if filename then docfound = true -- cgit v1.2.3