emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Info-history-forward


From: Juri Linkov
Subject: Info-history-forward
Date: Tue, 28 Dec 2004 04:28:45 +0200
User-agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux)

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/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]