]> git.eshelyaron.com Git - emacs.git/commitdiff
Browser-like Info-history button menu (bug#37184)
authorJuri Linkov <juri@linkov.net>
Tue, 27 Aug 2019 20:48:57 +0000 (23:48 +0300)
committerJuri Linkov <juri@linkov.net>
Tue, 27 Aug 2019 20:48:57 +0000 (23:48 +0300)
* doc/misc/info.texi (Help-Int): Using tool-bar to navigate history.

* lisp/info.el (Info-history-menu): New function.
(Info-history-back-menu, Info-history-forward-menu): New commands.
(Info-mode-map): Bind Info-history-back-menu and
Info-history-forward-menu to tool-bar on C-key.

doc/misc/info.texi
etc/NEWS
lisp/info.el

index cbdeaff50ce50ae9f02b2a7947fadad38cd8e4d3..077e83e3c9032de478d025507d5c7190720f46c4 100644 (file)
@@ -886,6 +886,14 @@ which the header says is the @samp{Previous} node (from this node, the
 to revisit nodes in the history list in the forward direction, so that
 @kbd{r} will return you to the node you came from by typing @kbd{l}.
 
+@cindex using tool-bar to navigate history
+  Clicking the mouse on the left arrow icon in the tool-bar while
+holding down the @key{CTRL} key in Emacs opens a menu of previously
+visited nodes: the same nodes that you can revisit by
+@code{Info-history-back}.  Selecting a node after clicking on the
+right arrow icon revisits the same nodes as available by
+@code{Info-history-forward}.
+
 @kindex L @r{(Info mode)}
 @findex Info-history
 @cindex history list of visited nodes
index a03e2027a9467156964fad61c9b5a56d27cd71f5..4e231e2a64e65bde4f3d77e51aeff59322b4d718 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -953,6 +953,11 @@ early init file.
 
 ** Info
 
++++
+*** Clicking on the left/right arrow icon in the Info tool-bar while
+holding down the Ctrl key pops up a menu of previously visited Info nodes
+where you can select a node to go back (like in browsers).
+
 ---
 *** Info can now follow 'file://' protocol URLs.
 The 'file://' URLs in Info documents can now be followed by passing
index 17a2d63e6dec443a9ea704392c4d74b9042a6d1c..e22466af871f83eac1e92d788471282b80bb0db2 100644 (file)
@@ -4059,6 +4059,8 @@ If FORK is non-nil, it is passed to `Info-goto-node'."
     (define-key map [follow-link] 'mouse-face)
     (define-key map [XF86Back] 'Info-history-back)
     (define-key map [XF86Forward] 'Info-history-forward)
+    (define-key map [tool-bar C-Back\ in\ history] 'Info-history-back-menu)
+    (define-key map [tool-bar C-Forward\ in\ history] 'Info-history-forward-menu)
     map)
   "Keymap containing Info commands.")
 
@@ -4151,6 +4153,36 @@ If FORK is non-nil, it is passed to `Info-goto-node'."
                                   :vert-only t)
     map))
 
+(defun Info-history-menu (e name history command)
+  (let* ((i (length history))
+         (map (make-sparse-keymap name)))
+    (mapc (lambda (history)
+            (let ((file (nth 0 history))
+                  (node (nth 1 history)))
+              (when (stringp file)
+                (setq file (file-name-sans-extension
+                            (file-name-nondirectory file))))
+              (define-key map (vector (intern (format "history-%i" i)))
+                `(menu-item ,(format "(%s) %s" file node)
+                            (lambda ()
+                              (interactive)
+                              (dotimes (_ ,i) (call-interactively ',command))))))
+            (setq i (1- i)))
+          (reverse history))
+    (let* ((selection (x-popup-menu e map))
+           (binding (and selection (lookup-key map (vector (car selection))))))
+      (if binding (call-interactively binding)))))
+
+(defun Info-history-back-menu (e)
+  "Pop up the menu with a list of previously visited Info nodes."
+  (interactive "e")
+  (Info-history-menu e "Back in history" Info-history 'Info-history-back))
+
+(defun Info-history-forward-menu (e)
+  "Pop up the menu with a list of Info nodes visited with ‘Info-history-back’."
+  (interactive "e")
+  (Info-history-menu e "Forward in history" Info-history-forward 'Info-history-forward))
+
 (defvar Info-menu-last-node nil)
 ;; Last node the menu was created for.
 ;; Value is a list, (FILE-NAME NODE-NAME).