]> git.eshelyaron.com Git - emacs.git/commitdiff
(Info-last-menu-item): Fix gross logic errors.
authorRichard M. Stallman <rms@gnu.org>
Tue, 9 Aug 1994 01:41:08 +0000 (01:41 +0000)
committerRichard M. Stallman <rms@gnu.org>
Tue, 9 Aug 1994 01:41:08 +0000 (01:41 +0000)
(Info-last-preorder): After going thru menu item, go to end.
(Info-scroll-up): Set window-start if it's out of range.
Once menu start is on or above screen, start using menu items.
(Info-scroll-down): Set window-start if it's out of range.
If there's a menu item, always use menu.

lisp/info.el

index 7464e22c76535e53a7235adb708157b7be5a77b1..a9feb3b2281bedad0fa735fbe842c7c6498fbd66 100644 (file)
@@ -1073,10 +1073,14 @@ N is the digit argument used to invoke this command."
   (interactive)
   (save-excursion
     (forward-line 1)
-    (search-backward "\n* menu:" nil t)
-    (or (search-backward "\n* " nil t)
-       (error "No previous items in menu"))
-    (Info-goto-node (Info-extract-menu-node-name))))
+    (let ((beg (save-excursion
+                (and (search-backward "\n* menu:" nil t)
+                     (point)))))
+      (or (and beg (search-backward "\n* " beg t))
+         (error "No previous items in menu")))
+    (Info-goto-node (save-excursion
+                     (goto-char (match-end 0))
+                     (Info-extract-menu-node-name)))))
 
 (defmacro Info-no-error (&rest body)
   (list 'condition-case nil (cons 'progn (append body '(t))) '(error nil)))
@@ -1103,23 +1107,42 @@ N is the digit argument used to invoke this command."
 (defun Info-last-preorder ()
   "Go to the last node, popping up a level if there is none."
   (interactive)
-  (cond ((Info-no-error (Info-last-menu-item)) )
+  (cond ((Info-no-error
+         (Info-last-menu-item)
+         ;; If we go down a menu item, go to the end of the node
+         ;; so we can scroll back through it.
+         (goto-char (point-max))))
        ((Info-no-error (Info-up))              (forward-line -1))
        (t                                      (error "No previous nodes"))))
 
 (defun Info-scroll-up ()
   "Read the next screen.  If end of buffer is visible, go to next entry."
   (interactive)
-  (if (pos-visible-in-window-p (point-max))
-      (Info-next-preorder)
-    (scroll-up)))
+  (if (or (< (window-start) (point-min))
+         (> (window-start) (point-max)))
+      (set-window-start (selected-window) (point)))
+  (let ((virtual-end (save-excursion
+                      (goto-char (point-min))
+                      (if (search-forward "\n* Menu:" nil t)
+                          (point)
+                        (point-max)))))
+    (if (or (< virtual-end (window-start))
+           (pos-visible-in-window-p virtual-end))
+       (Info-next-preorder)
+      (scroll-up))))
 
 (defun Info-scroll-down ()
   "Read the previous screen.  If start of buffer is visible, go to last entry."
   (interactive)
-  (if (pos-visible-in-window-p (point-min))
-      (Info-last-preorder)
-    (scroll-down)))
+  (if (or (< (window-start) (point-min))
+         (> (window-start) (point-max)))
+      (set-window-start (selected-window) (point)))
+  (let ((virtual-end (save-excursion
+                      (goto-char (point-min))
+                      (search-forward "\n* Menu:" nil t))))
+    (if (or virtual-end (pos-visible-in-window-p (point-min)))
+       (Info-last-preorder)
+      (scroll-down))))
 
 (defun Info-next-reference ()
   "Move cursor to the next cross-reference or menu item in the node."