summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuri Linkov <juri@linkov.net>2019-07-08 01:35:35 +0300
committerJuri Linkov <juri@linkov.net>2019-07-08 01:35:35 +0300
commit8d09cb21f8ad4c3d3197dadfcc38fe925da558d0 (patch)
treee4d3f94710b15e77aa7f35920fb2ebcc75523847
parent3bffc09d17cf7edf46e3834edd84520a493d2239 (diff)
downloademacs-8d09cb21f8ad4c3d3197dadfcc38fe925da558d0.tar.gz
Handle scroll-error-top-bottom in follow.el and view.el (bug#21893)
* lisp/follow.el (follow-scroll-up-arg, follow-scroll-up-window): Use scroll-up-command instead of scroll-up. (follow-scroll-down-arg, follow-scroll-down-window): Use scroll-down-command instead of scroll-down. (follow-scroll-up, follow-scroll-down): Handle scroll-error-top-bottom. * lisp/view.el (view-scroll-lines): Use scroll-down-command instead of scroll-down and scroll-up-command instead of scroll-up. (view-really-at-end): Handle scroll-error-top-bottom.
-rw-r--r--lisp/follow.el22
-rw-r--r--lisp/view.el7
2 files changed, 18 insertions, 11 deletions
diff --git a/lisp/follow.el b/lisp/follow.el
index acc2b26c550..faac87986bb 100644
--- a/lisp/follow.el
+++ b/lisp/follow.el
@@ -557,7 +557,7 @@ This is an internal function for `follow-scroll-up' and
(let ((opoint (point)) (owin (selected-window)))
(while
;; If we are too near EOB, try scrolling the previous window.
- (condition-case nil (progn (scroll-up arg) nil)
+ (condition-case nil (progn (scroll-up-command arg) nil)
(end-of-buffer
(condition-case nil (progn (follow-previous-window) t)
(error
@@ -576,7 +576,7 @@ If ARG is nil, scroll the size of the current window.
This is an internal function for `follow-scroll-down' and
`follow-scroll-down-window'."
(let ((opoint (point)))
- (scroll-down arg)
+ (scroll-down-command arg)
(unless (and scroll-preserve-screen-position
(get this-command 'scroll-command))
(goto-char opoint))
@@ -596,7 +596,7 @@ Negative ARG means scroll downward.
Works like `scroll-up' when not in Follow mode."
(interactive "P")
(cond ((not follow-mode)
- (scroll-up arg))
+ (scroll-up-command arg))
((eq arg '-)
(follow-scroll-down-window))
(t (follow-scroll-up-arg arg))))
@@ -616,7 +616,7 @@ Negative ARG means scroll upward.
Works like `scroll-down' when not in Follow mode."
(interactive "P")
(cond ((not follow-mode)
- (scroll-down arg))
+ (scroll-down-command arg))
((eq arg '-)
(follow-scroll-up-window))
(t (follow-scroll-down-arg arg))))
@@ -635,13 +635,16 @@ Negative ARG means scroll downward.
Works like `scroll-up' when not in Follow mode."
(interactive "P")
(cond ((not follow-mode)
- (scroll-up arg))
+ (scroll-up-command arg))
(arg (follow-scroll-up-arg arg))
(t
(let* ((windows (follow-all-followers))
(end (window-end (car (reverse windows)))))
(if (eq end (point-max))
- (signal 'end-of-buffer nil)
+ (if (or (null scroll-error-top-bottom)
+ (eobp))
+ (signal 'end-of-buffer nil)
+ (goto-char (point-max)))
(select-window (car windows))
;; `window-end' might return nil.
(if end
@@ -663,14 +666,17 @@ Negative ARG means scroll upward.
Works like `scroll-down' when not in Follow mode."
(interactive "P")
(cond ((not follow-mode)
- (scroll-down arg))
+ (scroll-down-command arg))
(arg (follow-scroll-down-arg arg))
(t
(let* ((windows (follow-all-followers))
(win (car (reverse windows)))
(start (window-start (car windows))))
(if (eq start (point-min))
- (signal 'beginning-of-buffer nil)
+ (if (or (null scroll-error-top-bottom)
+ (bobp))
+ (signal 'beginning-of-buffer nil)
+ (goto-char (point-min)))
(select-window win)
(goto-char start)
(vertical-motion (- (- (window-height win)
diff --git a/lisp/view.el b/lisp/view.el
index a765be02c1e..e4489b391a9 100644
--- a/lisp/view.el
+++ b/lisp/view.el
@@ -743,18 +743,19 @@ invocations return to earlier marks."
(setq backward (not backward) lines (- lines)))
(when (and maxdefault lines (> lines (view-window-size)))
(setq lines nil))
- (cond (backward (scroll-down lines))
+ (cond (backward (scroll-down-command lines))
((view-really-at-end)
(if view-scroll-auto-exit
(View-quit)
(ding)
(view-end-message)))
- (t (scroll-up lines)
+ (t (scroll-up-command lines)
(if (view-really-at-end) (view-end-message)))))
(defun view-really-at-end ()
;; Return true if buffer end visible. Maybe revert buffer and test.
- (and (pos-visible-in-window-p (point-max))
+ (and (or (null scroll-error-top-bottom) (eobp))
+ (pos-visible-in-window-p (point-max))
(let ((buf (current-buffer))
(bufname (buffer-name))
(file (buffer-file-name)))