diff options
author | Manuel Pégourié-Gonnard <mpg@elzevir.fr> | 2008-07-15 18:08:28 +0000 |
---|---|---|
committer | Manuel Pégourié-Gonnard <mpg@elzevir.fr> | 2008-07-15 18:08:28 +0000 |
commit | 58838b7d1d5b93973ec7ca255e738ab3946a2450 (patch) | |
tree | e4ee7ace073877cb76b001579fa3b2d634fb63e7 /Master | |
parent | 32f267d464b33c8412cc19d712367700b5b822ac (diff) |
rm viewer_tex since tex is not in ext_list. Add a fallback viewer, with appropriate warning/errors. reorder ext_list in the zipped case
git-svn-id: svn://tug.org/texlive/trunk@9582 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rwxr-xr-x | Master/texmf/scripts/texlive/texdoc.tlu | 56 |
1 files changed, 30 insertions, 26 deletions
diff --git a/Master/texmf/scripts/texlive/texdoc.tlu b/Master/texmf/scripts/texlive/texdoc.tlu index c01943599a1..4f1877d7fa3 100755 --- a/Master/texmf/scripts/texlive/texdoc.tlu +++ b/Master/texmf/scripts/texlive/texdoc.tlu @@ -247,7 +247,6 @@ set_config_list { viewer_ps = os.getenv ("PSVIEWER"), viewer_dvi = os.getenv ("DVIVIEWER"), viewer_html = os.getenv ("BROWSER"), - viewer_tex = os.getenv ("PAGER"), viewer_txt = os.getenv ("PAGER") } @@ -346,7 +345,7 @@ if (os.type == "windows") then viewer_pdf = '(start /wait %s) &', viewer_ps = '(start /wait %s) &', viewer_txt = '(start /wait %s) &', - viewer_tex = '(start /wait %s) &' + viewer_fallback='(start /wait %s) &' } else -- since we don't support msdos, if os.type is not windows, it's unix if (os.name == 'macosx') then @@ -356,7 +355,7 @@ else -- since we don't support msdos, if os.type is not windows, it's unix viewer_pdf = '(open %s)', viewer_ps = '(open %s)', viewer_txt = '(less %s)', - viewer_tex = '(less %s)' + viewer_fallback='(open %s)' } else set_config_list { @@ -397,8 +396,8 @@ else -- since we don't support msdos, if os.type is not windows, it's unix {'less', '(less %s)'}, {'more', '(more %s)'} }, - viewer_tex = first_in_path { - {'most', '(most %s)'}, + viewer_fallback = first_in_path { + {'see', '(see %s) &'}, {'less', '(less %s)'}, {'more', '(more %s)'} } @@ -409,8 +408,8 @@ end -- now a particular case for config.ext_list and zip-relted stuff if support_zipped then set_config_element('ext_list', - '.pdf, .pdf.gz, .pdf.bz2, .dvi, .dvi.gz, .dvi.bz2,'.. - '.ps, .ps.gz, .ps.bz2, .txt, .txt.gz, .txt.bz2, .html') + '.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 ', @@ -453,31 +452,36 @@ function prepare_viewing (ext) .. filename .. ';' .. config.rm_dir .. tmpdir end else - if ext == '' then - -- fallback if complete filename has been specified + if ext == '' then -- fallback if complete filename has been specified ext = string.match(filename,'.*(%..*)$') - if not ext then - -- still no extension for filenames like README - ext = 'txt' - end end viewer_replacement = filename viewext = string.match(ext,'%.(.*)$') - if not viewext or not config['viewer_'..viewext] then - -- complete filename specified, unknown extension, use "txt" - viewext = 'txt' - end + if not viewext then + print ("texdoc warning: cannot determine file type for\n".. + filename..", using fallback viewer.") + viewext = 'fallback' + else + if not config['viewer_'..viewext] then + print ("texdoc warning: no "..viewext.." viewer found, ".. + "using fallback viewer.\nYou can select you preffered".. + "with the viewer_"..viewext.." variable in texdoc.cnf.") + viewext = 'fallback' + if not config['viewer_'..viewext] then + print ("texdoc error: fallback viewer not found. ".. + "Skipping file "..filename..".") + end -- no fallback + end -- viewer for ext + end -- no ext end -- zipped or not + return config['viewer_'..viewext] end -- view a file, if possible -function try_viewing () - if config['viewer_'..viewext] == nil then - print ("Sorry, no "..viewext.." viewer found. You can choose one\n".. - "with the viewer_"..viewext" variable in texdoc.cnf.\n".. - "Please report the problem so we can add your viewer as a default.\n") +function try_viewing (view_command) + if not view_command then + view_result = false else - view_command = config['viewer_'..viewext] if string.match (view_command, place_holder) then view_command = string.gsub( view_command, place_holder, '"'..viewer_replacement..'"') @@ -489,7 +493,8 @@ function try_viewing () end view_result = os.execute(view_command) if not view_result then - print("Error executing \n" .. view_command) + print("texdoc error: the following command failed\n\t" + .. view_command) end end return view_result @@ -515,8 +520,7 @@ for docname in list_iter (arg) do if (mode == 'list') then print(filename) else -- mode is view, is unzipping needed? - prepare_viewing(ext) - local ok = try_viewing() + local ok = try_viewing(prepare_viewing(ext)) if ok then break end end -- list or view end -- found a filename with that extension or not? |