From: Ryan Yeske <rcyeske@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: window-scroll-functions called too often
Date: Thu, 07 Sep 2006 17:19:11 -0700 [thread overview]
Message-ID: <87bqprdxc0.fsf@cut.bc.hsia.telus.net> (raw)
In-Reply-To: <E1GKI4u-0008UJ-2h@fencepost.gnu.org> (message from Richard Stallman on Mon, 04 Sep 2006 13:17:44 -0400)
I suggest you copy the method used by comint.
It works.
Here is patch for a simplified version of the comint method. It just
scrolls to keep the point at the bottom of the window on user input
and on incoming text.
2006-09-07 Ryan Yeske <rcyeske@gmail.com>
* rcirc.el (rcirc-scroll-show-maximum-output): Rename from
rcirc-show-maximum-output.
(rcirc-mode): Remove window-scroll-function hook.
(rcirc-scroll-to-bottom): Remove function.
(rcirc-print): Recenter so point stays at the bottom of the window
if point was already there.
*** rcirc.el 05 Sep 2006 12:14:49 -0700 1.26
--- rcirc.el 07 Sep 2006 17:01:51 -0700
***************
*** 142,148 ****
(integer :tag "Number of lines"))
:group 'rcirc)
! (defcustom rcirc-show-maximum-output t
"*If non-nil, scroll buffer to keep the point at the bottom of
the window."
:type 'boolean
--- 142,148 ----
(integer :tag "Number of lines"))
:group 'rcirc)
! (defcustom rcirc-scroll-show-maximum-output t
"*If non-nil, scroll buffer to keep the point at the bottom of
the window."
:type 'boolean
***************
*** 762,769 ****
(add-hook 'change-major-mode-hook 'rcirc-change-major-mode-hook nil t)
(add-hook 'kill-buffer-hook 'rcirc-kill-buffer-hook nil t)
- (add-hook 'window-scroll-functions 'rcirc-scroll-to-bottom nil t)
-
;; add to buffer list, and update buffer abbrevs
(when target ; skip server buffer
(let ((buffer (current-buffer)))
--- 762,767 ----
***************
*** 1166,1179 ****
(defvar rcirc-last-sender nil)
(make-variable-buffer-local 'rcirc-last-sender)
- (defun rcirc-scroll-to-bottom (window display-start)
- "Scroll window to show maximum output if `rcirc-show-maximum-output' is
- non-nil."
- (when rcirc-show-maximum-output
- (with-selected-window window
- (when (>= (window-point) rcirc-prompt-end-marker)
- (recenter -1)))))
-
(defun rcirc-print (process sender response target text &optional activity)
"Print TEXT in the buffer associated with TARGET.
Format based on SENDER and RESPONSE. If ACTIVITY is non-nil,
--- 1164,1169 ----
***************
*** 1252,1268 ****
;; set the window point for buffers show in windows
(walk-windows (lambda (w)
! (unless (eq (selected-window) w)
! (when (and (eq (current-buffer)
! (window-buffer w))
! (>= (window-point w)
! rcirc-prompt-end-marker))
! (set-window-point w (point-max)))))
nil t)
;; restore the point
(goto-char (if moving rcirc-prompt-end-marker old-point))
;; flush undo (can we do something smarter here?)
(buffer-disable-undo)
(buffer-enable-undo))
--- 1242,1275 ----
;; set the window point for buffers show in windows
(walk-windows (lambda (w)
! (when (and (not (eq (selected-window) w))
! (eq (current-buffer)
! (window-buffer w))
! (>= (window-point w)
! rcirc-prompt-end-marker))
! (set-window-point w (point-max))))
nil t)
;; restore the point
(goto-char (if moving rcirc-prompt-end-marker old-point))
+ ;; keep window on bottom line if it was already there
+ (when rcirc-scroll-show-maximum-output
+ (walk-windows (lambda (w)
+ (when (eq (window-buffer w) (current-buffer))
+ (with-current-buffer (window-buffer w)
+ (when (eq major-mode 'rcirc-mode)
+ (with-selected-window w
+ (when (<= (- (window-height)
+ (- (line-number-at-pos
+ (window-point))
+ (line-number-at-pos
+ (window-start)))
+ 1)
+ 0)
+ (recenter -1)))))))
+ nil t))
+
;; flush undo (can we do something smarter here?)
(buffer-disable-undo)
(buffer-enable-undo))
next prev parent reply other threads:[~2006-09-08 0:19 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <871wqzqxxp.fsf@cut.bc.hsia.telus.net>
2006-09-03 15:17 ` window-scroll-functions called too often Richard Stallman
2006-09-03 19:41 ` Ryan Yeske
2006-09-04 17:17 ` Richard Stallman
2006-09-05 1:34 ` Miles Bader
2006-09-08 0:19 ` Ryan Yeske [this message]
2006-09-08 15:11 ` Richard Stallman
2006-09-09 18:46 ` Ryan Yeske
2006-09-10 13:04 ` Richard Stallman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87bqprdxc0.fsf@cut.bc.hsia.telus.net \
--to=rcyeske@gmail.com \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.