texlive[45693] Master/texmf-dist/scripts/texdoc/view.tlu: RET in view

commits+karl at tug.org commits+karl at tug.org
Sun Nov 5 00:33:05 CET 2017


Revision: 45693
          http://tug.org/svn/texlive?view=revision&revision=45693
Author:   karl
Date:     2017-11-05 00:33:04 +0100 (Sun, 05 Nov 2017)
Log Message:
-----------
RET in view mode views first document, texdoc r18

Revision Links:
--------------
    http://tug.org/svn/texlive?view=revision&revision=18

Modified Paths:
--------------
    trunk/Master/texmf-dist/scripts/texdoc/view.tlu

Modified: trunk/Master/texmf-dist/scripts/texdoc/view.tlu
===================================================================
--- trunk/Master/texmf-dist/scripts/texdoc/view.tlu	2017-11-04 22:25:58 UTC (rev 45692)
+++ trunk/Master/texmf-dist/scripts/texdoc/view.tlu	2017-11-04 23:33:04 UTC (rev 45693)
@@ -156,8 +156,9 @@
             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 @@
         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



More information about the tex-live-commits mailing list