From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ryan Yeske Newsgroups: gmane.emacs.devel Subject: Re: window-scroll-functions called too often Date: Thu, 07 Sep 2006 17:19:11 -0700 Message-ID: <87bqprdxc0.fsf@cut.bc.hsia.telus.net> References: <871wqzqxxp.fsf@cut.bc.hsia.telus.net> <87r6ysyby6.fsf@cut.bc.hsia.telus.net> NNTP-Posting-Host: main.gmane.org X-Trace: sea.gmane.org 1157674773 28798 80.91.229.2 (8 Sep 2006 00:19:33 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 8 Sep 2006 00:19:33 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Sep 08 02:19:32 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GLU5i-0007F0-F5 for ged-emacs-devel@m.gmane.org; Fri, 08 Sep 2006 02:19:30 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GLU5h-000059-DU for ged-emacs-devel@m.gmane.org; Thu, 07 Sep 2006 20:19:29 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GLU5U-0008WS-Lj for emacs-devel@gnu.org; Thu, 07 Sep 2006 20:19:16 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GLU5T-0008W6-4R for emacs-devel@gnu.org; Thu, 07 Sep 2006 20:19:16 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GLU5T-0008W3-1u for emacs-devel@gnu.org; Thu, 07 Sep 2006 20:19:15 -0400 Original-Received: from [204.209.205.55] (helo=defout.telus.net) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GLU5v-0000q5-SO; Thu, 07 Sep 2006 20:19:44 -0400 Original-Received: from priv-edmwaa06.telusplanet.net ([207.6.239.189]) by priv-edmwes23.telusplanet.net (InterMail vM.7.05.01.01 201-2174-106-103-20060222) with ESMTP id <20060908001912.HLHV28524.priv-edmwes23.telusplanet.net@priv-edmwaa06.telusplanet.net>; Thu, 7 Sep 2006 18:19:12 -0600 Original-Received: from cut.bc.hsia.telus.net (d207-6-239-189.bchsia.telus.net [207.6.239.189]) by priv-edmwaa06.telusplanet.net (BorderWare MXtreme Infinity Mail Firewall) with ESMTP id DD9AH1DGQ3; Thu, 7 Sep 2006 18:19:12 -0600 (MDT) Original-To: rms@gnu.org In-reply-to: (message from Richard Stallman on Mon, 04 Sep 2006 13:17:44 -0400) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:59535 Archived-At: 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 * 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))