changeset 8489:c6088e3005cf

(Info-last-menu-item): Fix gross logic errors. (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.
author Richard M. Stallman <rms@gnu.org>
date Tue, 09 Aug 1994 01:41:08 +0000
parents ddd8e250a65d
children 7db23bef024e
files lisp/info.el
diffstat 1 files changed, 34 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/info.el	Mon Aug 08 23:23:33 1994 +0000
+++ b/lisp/info.el	Tue Aug 09 01:41:08 1994 +0000
@@ -1073,10 +1073,14 @@
   (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 @@
 (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."