From afa2ebdbcdfb509df8996f46f209860c7c28be67 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sat, 4 Nov 2017 23:33:04 +0000 Subject: RET in view mode views first document, texdoc r18 git-svn-id: svn://tug.org/texlive/trunk@45693 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/scripts/texdoc/view.tlu | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'Master/texmf-dist/scripts/texdoc') diff --git a/Master/texmf-dist/scripts/texdoc/view.tlu b/Master/texmf-dist/scripts/texdoc/view.tlu index 45e7c9df395..484cfe34344 100644 --- a/Master/texmf-dist/scripts/texdoc/view.tlu +++ b/Master/texmf-dist/scripts/texdoc/view.tlu @@ -156,8 +156,9 @@ function print_menu(name, doclist, showall) end end end - local i, doc + local i, doc, last_i for i, doc in ipairs (doclist) do + last_i = i -- save for test below if doc.quality == 'killed' then break end if doc.quality ~= 'good' and not showall then break end if config.machine_switch == true then @@ -174,16 +175,20 @@ function print_menu(name, doclist, showall) end end if config.interact_switch then - io.write ("Please enter the number of the file to view, ", - "anything else to skip: ") - local num = tonumber(io.read('*line')) - if num and doclist[num] then + io.write ("Enter number of file to view, ", + "RET to view 1, anything else to skip: ") + local num_str = io.read('*line') + -- That returns the empty string on an empty line, nil on EOF. + -- We only want to default to viewing 1 on an empty line. + -- Use Lua's faked ternary operator for fun and brevity: + num = (num_str == "" and 1 or tonumber(num_str)) + if num and doclist[num] and num < last_i then view_doc(doclist[num]) end end end ------------------------ deliver results base on mode ---------------------- +----------------------- deliver results based on mode --------------------- function deliver_results(name, doclist, many) -- ensure that results were found or apologize -- cgit v1.2.3