Commit 782fbf2a authored by Chong Yidong's avatar Chong Yidong
Browse files

* lisp/follow.el: Rework, eliminating reliance on advice.

(set-process-filter, process-filter, sit-for): Advice deleted.
(follow-mode-off-hook): Obsolete hook removed.
(follow-avoid-tail-recenter-p, follow-process-filter-alist): Vars
deleted.
(follow-auto): Use a :set function.
(follow-mode): Rewritten.  Don't advise process filters.
(follow-switch-to-current-buffer-all, follow-scroll-up)
(follow-scroll-down): Assume follow-mode is bound.
(follow-comint-scroll-to-bottom)
(follow-align-compilation-windows): New functions.
(follow--window-sorter): New function.
(follow-all-followers): Use it to explicitly sort windows by their
positions; don't make assumptions about next-window order.
(follow-windows-start-end, follow-delete-other-windows-and-split)
(follow-calc-win-start): Doc fix.
(follow-windows-aligned-p, follow-select-if-visible): Don't call
vertical-motion unnecessarily.
(follow-adjust-window): New function.
(follow-post-command-hook): Use it.
(follow-call-set-process-filter, follow-call-process-filter)
(follow-intercept-process-output, follow-tidy-process-filter-alist)
(follow-stop-intercept-process-output, follow-generic-filter):
Functions deleted.
(follow-scroll-bar-toolkit-scroll, follow-scroll-bar-drag)
(follow-scroll-bar-scroll-up, follow-scroll-bar-scroll-down): New
functions, replacing advice on scroll-bar-* commands.

* lisp/comint.el (comint-adjust-point): New function.
(comint-postoutput-scroll-to-bottom): Use it.  Call
follow-comint-scroll-to-bottom for Follow mode buffers.
parent eb0ae1d1
...@@ -100,6 +100,13 @@ these commands now). ...@@ -100,6 +100,13 @@ these commands now).
** erc will look up server/channel names via auth-source and use the ** erc will look up server/channel names via auth-source and use the
channel keys found, if any. channel keys found, if any.
** Follow mode
*** The obsolete variable `follow-mode-off-hook' has been removed.
*** Follow mode no longer works by using advice.
The option `follow-intercept-processes' has been removed.
** The `server-auth-key' variable can be used to set a permanent ** The `server-auth-key' variable can be used to set a permanent
shared key for Emacs Server. shared key for Emacs Server.
......
2012-05-01 Chong Yidong <cyd@gnu.org>
* follow.el: Eliminate advice.
(set-process-filter, process-filter, sit-for): Advice deleted.
(follow-mode-off-hook): Obsolete hook removed.
(follow-avoid-tail-recenter-p, follow-process-filter-alist): Vars
deleted.
(follow-auto): Use a :set function.
(follow-mode): Rewritten. Don't advise process filters.
(follow-switch-to-current-buffer-all, follow-scroll-up)
(follow-scroll-down): Assume follow-mode is bound.
(follow-comint-scroll-to-bottom)
(follow-align-compilation-windows): New functions.
(follow--window-sorter): New function.
(follow-all-followers): Use it to explicitly sort windows by their
positions; don't make assumptions about next-window order.
(follow-windows-start-end, follow-delete-other-windows-and-split)
(follow-calc-win-start): Doc fix.
(follow-windows-aligned-p, follow-select-if-visible): Don't call
vertical-motion unnecessarily.
(follow-adjust-window): New function.
(follow-post-command-hook): Use it.
(follow-call-set-process-filter, follow-call-process-filter)
(follow-intercept-process-output, follow-tidy-process-filter-alist)
(follow-stop-intercept-process-output, follow-generic-filter):
Functions deleted.
(follow-scroll-bar-toolkit-scroll, follow-scroll-bar-drag)
(follow-scroll-bar-scroll-up, follow-scroll-bar-scroll-down): New
functions, replacing advice on scroll-bar-* commands.
* comint.el (comint-adjust-point): New function.
(comint-postoutput-scroll-to-bottom): Use it. Call
follow-comint-scroll-to-bottom for Follow mode buffers.
2012-05-01 Glenn Morris <rgm@gnu.org> 2012-05-01 Glenn Morris <rgm@gnu.org>
* term/AT386.el, term/apollo.el, term/bobcat.el, term/cygwin.el: * term/AT386.el, term/apollo.el, term/bobcat.el, term/cygwin.el:
......
...@@ -2101,43 +2101,51 @@ This function should be a pre-command hook." ...@@ -2101,43 +2101,51 @@ This function should be a pre-command hook."
(select-window selected)))) (select-window selected))))
nil t)))))) nil t))))))
(defvar follow-mode)
(declare-function follow-comint-scroll-to-bottom "follow" ())
(defun comint-postoutput-scroll-to-bottom (_string) (defun comint-postoutput-scroll-to-bottom (_string)
"Go to the end of buffer in some or all windows showing it. "Go to the end of buffer in some or all windows showing it.
Does not scroll if the current line is the last line in the buffer. Do not scroll if the current line is the last line in the buffer.
Depends on the value of `comint-move-point-for-output' and Depends on the value of `comint-move-point-for-output' and
`comint-scroll-show-maximum-output'. `comint-scroll-show-maximum-output'.
This function should be in the list `comint-output-filter-functions'." This function should be in the list `comint-output-filter-functions'."
(let* ((selected (selected-window)) (let* ((current (current-buffer))
(current (current-buffer)) (process (get-buffer-process current)))
(process (get-buffer-process current))
(scroll comint-move-point-for-output))
(unwind-protect (unwind-protect
(if process (cond
(walk-windows ((null process))
(lambda (window) ((bound-and-true-p follow-mode)
(when (eq (window-buffer window) current) (follow-comint-scroll-to-bottom))
(select-window window) (t
(if (and (< (point) (process-mark process)) (let ((selected (selected-window)))
(or (eq scroll t) (eq scroll 'all) (dolist (w (get-buffer-window-list current nil t))
;; Maybe user wants point to jump to end. (select-window w)
(and (eq scroll 'this) (eq selected window)) (unwind-protect
(and (eq scroll 'others) (not (eq selected window))) (progn
;; If point was at the end, keep it at end. (comint-adjust-point selected)
(and (marker-position comint-last-output-start) ;; Optionally scroll to the bottom of the window.
(>= (point) comint-last-output-start)))) (and comint-scroll-show-maximum-output
(goto-char (process-mark process))) (eobp)
;; Optionally scroll so that the text (recenter (- -1 scroll-margin))))
;; ends at the bottom of the window. (select-window selected))))))
(if (and comint-scroll-show-maximum-output
(= (point) (point-max)))
(save-excursion
(goto-char (point-max))
(recenter (- -1 scroll-margin))))
(select-window selected)))
nil t))
(set-buffer current)))) (set-buffer current))))
(defun comint-adjust-point (selected)
"Move point in the selected window based on Comint settings.
SELECTED is the window that was originally selected."
(let ((process (get-buffer-process (current-buffer))))
(and (< (point) (process-mark process))
(or (memq comint-move-point-for-output '(t all))
;; Maybe user wants point to jump to end.
(eq comint-move-point-for-output
(if (eq (selected-window) selected) 'this 'others))
;; If point was at the end, keep it at end.
(and (marker-position comint-last-output-start)
(>= (point) comint-last-output-start)))
(goto-char (process-mark process)))))
(defun comint-truncate-buffer (&optional _string) (defun comint-truncate-buffer (&optional _string)
"Truncate the buffer to `comint-buffer-maximum-size'. "Truncate the buffer to `comint-buffer-maximum-size'.
This function could be on `comint-output-filter-functions' or bound to a key." This function could be on `comint-output-filter-functions' or bound to a key."
......
This diff is collapsed.
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