diff options
-rwxr-xr-x | Master/texmf/scripts/texlive/texdoc.tlu | 86 |
1 files changed, 54 insertions, 32 deletions
diff --git a/Master/texmf/scripts/texlive/texdoc.tlu b/Master/texmf/scripts/texlive/texdoc.tlu index 871717c1c10..38c0dd30132 100755 --- a/Master/texmf/scripts/texlive/texdoc.tlu +++ b/Master/texmf/scripts/texlive/texdoc.tlu @@ -308,6 +308,27 @@ function setup_config () end end +-- for default viewer on general Unix, we use a list +-- and check in the path in order to find a suitable program + +-- check if "name" is the name of a file in the path +-- Warning: to be used only on Unix (hard-coded separators) +function is_in_path(name) + local path_list = string.explode(os.getenv("PATH"), ':') + for _, path in ipairs(path_list) do + if lfs.isfile(path..'/'..name) then return true end + end + return false +end + +-- return the first element of "list" whos name is found in path, or nil +function first_in_path(list) + for _, cmd in ipairs(list) do + if is_in_path(cmd[1]) then return cmd[2] end + end + return nil +end + -- some fall-back default values if (os.type == "windows") then -- probably Windows (or OS/2) @@ -342,10 +363,39 @@ else -- since we don't support msdos, if os.type is not windows, it's unix } else set_config_list { - viewer_dvi = '(xdvi %s) &', - viewer_html = '(see %s) &', - viewer_pdf = '(xpdf %s) &', + viewer_dvi = first_in_path { + {'see', '(see %s) &'}, + {'evince', '(evince %s) &'}, + {'okular', '(okular %s) &'}, + {'kdvi', '(kdvi %s) &'}, + {'xdvi', '(xdvi %s) &'} + }, + viewer_html = first_in_path { + {'see', '(see %s) &'}, + {'firefox', '(firefox %s) &'}, + {'mozilla', '(mozilla %s) &'}, + {'konqueror', '(konqueror %s) &'}, + {'epiphany', '(epiphany %s) &'}, + {'opera', '(opera %s) &'}, + {'w3m', '(w3m %s) &'}, + {'links', '(links %s) &'}, + {'lynx', '(lynx %s) &'} + }, + viewer_pdf = first_in_path { + {'see', '(see %s) &'}, + {'evince', '(evince %s) &'}, + {'okular', '(okular %s) &'}, + {'kpdf', '(kpdf %s) &'}, + {'xpdf', '(xpdf %s) &'} + }, viewer_ps = '(gv %s) &', + viewer_ps = first_in_path { + {'see', '(see %s) &'}, + {'evince', '(evince %s) &'}, + {'okular', '(okular %s) &'}, + {'kghostview', '(kghostview %s) &'}, + {'gv', '(gv %s) &'} + }, viewer_txt = '(less %s)', viewer_tex = '(less %s)' } @@ -355,7 +405,7 @@ end set_config_list { zipformats = {'','gz','bz2'}, formats = {'dvi','pdf','ps','txt','html'}, - extlist = { + extlist = { '','.dvi', '.dvi.gz', '.dvi.bz2', '.pdf', '.pdf.gz', '.pdf.bz2', '.ps', '.ps.gz', '.ps.bz2', '.txt', '.txt.gz', '.txt.bz2', '.html' } @@ -368,14 +418,6 @@ if not config.extlist[1] == '' then insert(config.extlist,1,'') end ---[[ -print "-- Begin config" -for key, value in pairs(config) do - print(string.format('config.%-11s ==> "%s"', key, value)) -end -print "-- End config" -]] - -- [[ functions for viewing ]] -- uncompress if needed @@ -469,26 +511,6 @@ end -- for docname in arg -- cleanup_tmpdir() --- [[ to be used latter (mpg) ]] - --- check if "name" is the name of a file in the path --- Warning: to be used only on Unix (hard-coded separators and useless on win) -function is_in_path(name) - local path_list = string.explode(os.getenv("PATH"), ':') - for i, path in ipairs(path_list) do - if lfs.isfile(path..'/'..name) then return true end - end - return false -end - --- return the first element of "list" found in the path, nil otherwise -function first_in_path(list) - for i, name in ipairs(list) do - if is_in_path(name) then return name end - end - return nil -end - -- Local Variables: -- lua-indent-level: 4 -- tab-width: 4 |