diff options
| author | Juri Linkov | 2019-08-27 23:48:57 +0300 |
|---|---|---|
| committer | Juri Linkov | 2019-08-27 23:48:57 +0300 |
| commit | ba5d9795f87fb2660be5d54516c97e2d56344b03 (patch) | |
| tree | f06942d6e9ee1f92700eaefb04bc07979728a777 | |
| parent | ba1f7797fbf6c6b94f5236b621b6aeda9ada405c (diff) | |
| download | emacs-ba5d9795f87fb2660be5d54516c97e2d56344b03.tar.gz emacs-ba5d9795f87fb2660be5d54516c97e2d56344b03.zip | |
Browser-like Info-history button menu (bug#37184)
* 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.
| -rw-r--r-- | doc/misc/info.texi | 8 | ||||
| -rw-r--r-- | etc/NEWS | 5 | ||||
| -rw-r--r-- | lisp/info.el | 32 |
3 files changed, 45 insertions, 0 deletions
diff --git a/doc/misc/info.texi b/doc/misc/info.texi index cbdeaff50ce..077e83e3c90 100644 --- a/doc/misc/info.texi +++ b/doc/misc/info.texi | |||
| @@ -886,6 +886,14 @@ which the header says is the @samp{Previous} node (from this node, the | |||
| 886 | to revisit nodes in the history list in the forward direction, so that | 886 | to revisit nodes in the history list in the forward direction, so that |
| 887 | @kbd{r} will return you to the node you came from by typing @kbd{l}. | 887 | @kbd{r} will return you to the node you came from by typing @kbd{l}. |
| 888 | 888 | ||
| 889 | @cindex using tool-bar to navigate history | ||
| 890 | Clicking the mouse on the left arrow icon in the tool-bar while | ||
| 891 | holding down the @key{CTRL} key in Emacs opens a menu of previously | ||
| 892 | visited nodes: the same nodes that you can revisit by | ||
| 893 | @code{Info-history-back}. Selecting a node after clicking on the | ||
| 894 | right arrow icon revisits the same nodes as available by | ||
| 895 | @code{Info-history-forward}. | ||
| 896 | |||
| 889 | @kindex L @r{(Info mode)} | 897 | @kindex L @r{(Info mode)} |
| 890 | @findex Info-history | 898 | @findex Info-history |
| 891 | @cindex history list of visited nodes | 899 | @cindex history list of visited nodes |
| @@ -953,6 +953,11 @@ early init file. | |||
| 953 | 953 | ||
| 954 | ** Info | 954 | ** Info |
| 955 | 955 | ||
| 956 | +++ | ||
| 957 | *** Clicking on the left/right arrow icon in the Info tool-bar while | ||
| 958 | holding down the Ctrl key pops up a menu of previously visited Info nodes | ||
| 959 | where you can select a node to go back (like in browsers). | ||
| 960 | |||
| 956 | --- | 961 | --- |
| 957 | *** Info can now follow 'file://' protocol URLs. | 962 | *** Info can now follow 'file://' protocol URLs. |
| 958 | The 'file://' URLs in Info documents can now be followed by passing | 963 | The 'file://' URLs in Info documents can now be followed by passing |
diff --git a/lisp/info.el b/lisp/info.el index 17a2d63e6de..e22466af871 100644 --- a/lisp/info.el +++ b/lisp/info.el | |||
| @@ -4059,6 +4059,8 @@ If FORK is non-nil, it is passed to `Info-goto-node'." | |||
| 4059 | (define-key map [follow-link] 'mouse-face) | 4059 | (define-key map [follow-link] 'mouse-face) |
| 4060 | (define-key map [XF86Back] 'Info-history-back) | 4060 | (define-key map [XF86Back] 'Info-history-back) |
| 4061 | (define-key map [XF86Forward] 'Info-history-forward) | 4061 | (define-key map [XF86Forward] 'Info-history-forward) |
| 4062 | (define-key map [tool-bar C-Back\ in\ history] 'Info-history-back-menu) | ||
| 4063 | (define-key map [tool-bar C-Forward\ in\ history] 'Info-history-forward-menu) | ||
| 4062 | map) | 4064 | map) |
| 4063 | "Keymap containing Info commands.") | 4065 | "Keymap containing Info commands.") |
| 4064 | 4066 | ||
| @@ -4151,6 +4153,36 @@ If FORK is non-nil, it is passed to `Info-goto-node'." | |||
| 4151 | :vert-only t) | 4153 | :vert-only t) |
| 4152 | map)) | 4154 | map)) |
| 4153 | 4155 | ||
| 4156 | (defun Info-history-menu (e name history command) | ||
| 4157 | (let* ((i (length history)) | ||
| 4158 | (map (make-sparse-keymap name))) | ||
| 4159 | (mapc (lambda (history) | ||
| 4160 | (let ((file (nth 0 history)) | ||
| 4161 | (node (nth 1 history))) | ||
| 4162 | (when (stringp file) | ||
| 4163 | (setq file (file-name-sans-extension | ||
| 4164 | (file-name-nondirectory file)))) | ||
| 4165 | (define-key map (vector (intern (format "history-%i" i))) | ||
| 4166 | `(menu-item ,(format "(%s) %s" file node) | ||
| 4167 | (lambda () | ||
| 4168 | (interactive) | ||
| 4169 | (dotimes (_ ,i) (call-interactively ',command)))))) | ||
| 4170 | (setq i (1- i))) | ||
| 4171 | (reverse history)) | ||
| 4172 | (let* ((selection (x-popup-menu e map)) | ||
| 4173 | (binding (and selection (lookup-key map (vector (car selection)))))) | ||
| 4174 | (if binding (call-interactively binding))))) | ||
| 4175 | |||
| 4176 | (defun Info-history-back-menu (e) | ||
| 4177 | "Pop up the menu with a list of previously visited Info nodes." | ||
| 4178 | (interactive "e") | ||
| 4179 | (Info-history-menu e "Back in history" Info-history 'Info-history-back)) | ||
| 4180 | |||
| 4181 | (defun Info-history-forward-menu (e) | ||
| 4182 | "Pop up the menu with a list of Info nodes visited with ‘Info-history-back’." | ||
| 4183 | (interactive "e") | ||
| 4184 | (Info-history-menu e "Forward in history" Info-history-forward 'Info-history-forward)) | ||
| 4185 | |||
| 4154 | (defvar Info-menu-last-node nil) | 4186 | (defvar Info-menu-last-node nil) |
| 4155 | ;; Last node the menu was created for. | 4187 | ;; Last node the menu was created for. |
| 4156 | ;; Value is a list, (FILE-NAME NODE-NAME). | 4188 | ;; Value is a list, (FILE-NAME NODE-NAME). |