unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Info-history-forward
@ 2004-12-28  2:28 Juri Linkov
  2004-12-28 16:29 ` Info-history-forward Drew Adams
  0 siblings, 1 reply; 20+ messages in thread
From: Juri Linkov @ 2004-12-28  2:28 UTC (permalink / raw)


I'd like to provide an enhancement that people have requested for
a long time.

Info has the `l' command which moves one step back through the history.
But there is no symmetric command to move forward.  Here is a simple
implementation.  It works like `Forward' button in web browsers.

There is a free key binding "r" in Info-mode-map suitable for
`Info-history-forward'.  It has several mnemonics like "return",
or even "right" whereas opposite "l" would mean "left" representing
imaginable direction of moving through the Info history.

Index: lisp/info.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/info.el,v
retrieving revision 1.413
diff -u -r1.413 info.el
--- lisp/info.el	13 Dec 2004 19:31:32 -0000	1.413
+++ lisp/info.el	28 Dec 2004 02:17:19 -0000
@@ -47,6 +47,10 @@
   "Stack of info nodes user has visited.
 Each element of list is a list (FILENAME NODENAME BUFFERPOS).")
 
+(defvar Info-history-forward nil
+  "Stack of info nodes user has visited with `Info-last' command.
+Each element of list is a list (FILENAME NODENAME BUFFERPOS).")
+
 (defvar Info-history-list nil
   "List of all info nodes user has visited.
 Each element of list is a list (FILENAME NODENAME).")
@@ -1295,7 +1308,8 @@
 	;; Add a new unique history item to full history list
 	(let ((new-history (list Info-current-file Info-current-node)))
 	  (setq Info-history-list
-		(cons new-history (delete new-history Info-history-list))))
+		(cons new-history (delete new-history Info-history-list)))
+	  (setq Info-history-forward nil))
 	(if (not (eq Info-fontify-maximum-menu-size nil))
             (Info-fontify-node))
 	(Info-display-images-node)
@@ -1736,13 +1751,31 @@
   (interactive)
   (or Info-history
       (error "This is the first Info node you looked at"))
-  (let (filename nodename opoint)
+  (let ((history-forward
+	 (cons (list Info-current-file Info-current-node (point))
+	       Info-history-forward))
+	filename nodename opoint)
     (setq filename (car (car Info-history)))
     (setq nodename (car (cdr (car Info-history))))
     (setq opoint (car (cdr (cdr (car Info-history)))))
     (setq Info-history (cdr Info-history))
     (Info-find-node filename nodename)
     (setq Info-history (cdr Info-history))
+    (setq Info-history-forward history-forward)
+    (goto-char opoint)))
+
+(defun Info-history-forward ()
+  "Go forward in the history of visited nodes."
+  (interactive)
+  (or Info-history-forward
+      (error "This is the last Info node you looked at"))
+  (let ((history-forward (cdr Info-history-forward))
+	filename nodename opoint)
+    (setq filename (car (car Info-history-forward)))
+    (setq nodename (car (cdr (car Info-history-forward))))
+    (setq opoint (car (cdr (cdr (car Info-history-forward)))))
+    (Info-find-node filename nodename)
+    (setq Info-history-forward history-forward)
     (goto-char opoint)))
 
 ;;;###autoload
@@ -2900,6 +2933,7 @@
   (define-key Info-mode-map "n" 'Info-next)
   (define-key Info-mode-map "p" 'Info-prev)
   (define-key Info-mode-map "q" 'Info-exit)
+  (define-key Info-mode-map "r" 'Info-history-forward)
   (define-key Info-mode-map "s" 'Info-search)
   (define-key Info-mode-map "S" 'Info-search-case-sensitively)
   ;; For consistency with Rmail.
@@ -2951,8 +2985,10 @@
     :help "Search for another occurrence of regular expression"]
    ["Go to Node..." Info-goto-node
     :help "Go to a named node"]
-   ["Last" Info-last :active Info-history
+   ["Back history (last)" Info-last :active Info-history
     :help "Go to the last node you were at"]
+   ["Forward history" Info-history-forward :active Info-history-forward
+    :help "Go to the previous node left with Info-last"]
    ["History" Info-history :active Info-history-list
     :help "Go to menu of visited nodes"]
    ["Table of Contents" Info-toc
@@ -3101,6 +3137,7 @@
 \\[Info-directory]	Go to the Info directory node.
 \\[Info-follow-reference]	Follow a cross reference.  Reads name of reference.
 \\[Info-last]	Move to the last node you were at.
+\\[Info-history-forward]	Move to the previous node left with Info-last.
 \\[Info-history]	Go to menu of visited nodes.
 \\[Info-toc]	Go to table of contents of the current Info file.
 \\[Info-top-node]	Go to the Top node of this file.
@@ -3157,6 +3194,7 @@
   (make-local-variable 'Info-tag-table-buffer)
   (setq Info-tag-table-buffer nil)
   (make-local-variable 'Info-history)
+  (make-local-variable 'Info-history-forward)
   (make-local-variable 'Info-index-alternatives)
   (setq header-line-format
 	(if Info-use-header-line

-- 
Juri Linkov
http://www.jurta.org/emacs/

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2005-01-05 13:02 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-12-28  2:28 Info-history-forward Juri Linkov
2004-12-28 16:29 ` Info-history-forward Drew Adams
2004-12-29  0:31   ` Info-history-forward Miles Bader
2004-12-29  1:11     ` Info-history-forward Drew Adams
2004-12-29  2:11   ` Info-history-forward Juri Linkov
2004-12-29  4:39     ` Info-history-forward Eli Zaretskii
2004-12-29  6:33       ` Info-history-forward Juri Linkov
2004-12-29 13:06         ` Info-history-forward Robert J. Chassell
2004-12-30  4:57           ` Info-history-forward Eli Zaretskii
2004-12-30 20:58             ` Info-history-forward Richard Stallman
2005-01-04  9:09               ` Info-history-forward Juri Linkov
2005-01-04 12:17                 ` Info-history-forward Chong Yidong
2005-01-05  5:41                   ` Info-history-forward Juri Linkov
2005-01-05 10:37                     ` Info-history-forward Chong Yidong
2005-01-05 13:02                       ` Info-history-forward Juri Linkov
2005-01-05  3:30                 ` Info-history-forward Richard Stallman
2004-12-30  4:37         ` Info-history-forward Eli Zaretskii
2004-12-30  7:29           ` Info-history-forward Juri Linkov
2004-12-30  8:16             ` Info-history-forward Jan D.
2004-12-30 18:58               ` Info-history-forward Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).