Commit 0a56332b authored by Richard M. Stallman's avatar Richard M. Stallman
Browse files

(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.
parent a06d7943
...@@ -1073,10 +1073,14 @@ N is the digit argument used to invoke this command." ...@@ -1073,10 +1073,14 @@ N is the digit argument used to invoke this command."
(interactive) (interactive)
(save-excursion (save-excursion
(forward-line 1) (forward-line 1)
(search-backward "\n* menu:" nil t) (let ((beg (save-excursion
(or (search-backward "\n* " nil t) (and (search-backward "\n* menu:" nil t)
(error "No previous items in menu")) (point)))))
(Info-goto-node (Info-extract-menu-node-name)))) (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) (defmacro Info-no-error (&rest body)
(list 'condition-case nil (cons 'progn (append body '(t))) '(error nil))) (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." ...@@ -1103,23 +1107,42 @@ N is the digit argument used to invoke this command."
(defun Info-last-preorder () (defun Info-last-preorder ()
"Go to the last node, popping up a level if there is none." "Go to the last node, popping up a level if there is none."
(interactive) (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)) ((Info-no-error (Info-up)) (forward-line -1))
(t (error "No previous nodes")))) (t (error "No previous nodes"))))
(defun Info-scroll-up () (defun Info-scroll-up ()
"Read the next screen. If end of buffer is visible, go to next entry." "Read the next screen. If end of buffer is visible, go to next entry."
(interactive) (interactive)
(if (pos-visible-in-window-p (point-max)) (if (or (< (window-start) (point-min))
(Info-next-preorder) (> (window-start) (point-max)))
(scroll-up))) (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 () (defun Info-scroll-down ()
"Read the previous screen. If start of buffer is visible, go to last entry." "Read the previous screen. If start of buffer is visible, go to last entry."
(interactive) (interactive)
(if (pos-visible-in-window-p (point-min)) (if (or (< (window-start) (point-min))
(Info-last-preorder) (> (window-start) (point-max)))
(scroll-down))) (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 () (defun Info-next-reference ()
"Move cursor to the next cross-reference or menu item in the node." "Move cursor to the next cross-reference or menu item in the node."
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment