unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: window-scroll-functions called too often
       [not found] <871wqzqxxp.fsf@cut.bc.hsia.telus.net>
@ 2006-09-03 15:17 ` Richard Stallman
  2006-09-03 19:41   ` Ryan Yeske
  2006-09-09 18:46   ` Ryan Yeske
  0 siblings, 2 replies; 8+ messages in thread
From: Richard Stallman @ 2006-09-03 15:17 UTC (permalink / raw)
  Cc: emacs-devel

It seems unreasonable to put a hook on window-scroll-functions which
scrolls the window differently.  The intended use of that hook is to
to whatever is necessary to support the scrolling that the user wants
to do, not override it.  So I am not really surprised that this does
not work.

What problem are you trying to solve?


You wrote:

    (defun foo-scroll (window display-start)
      (message "foo-scroll %S %S" window (current-time))
      (when (and window (window-live-p window))
	(with-selected-window window
	  (when (>= (window-point) (mark))
	    (save-excursion
	      (recenter -1))))))

    (add-hook 'window-scroll-functions 'foo-scroll nil t)

    ;;; 1 - hit C-SPC to set the mark on this line somewhere
    ;;
    ;;; 2 - hit C-l here to force a call to `foo-scroll'
    ;;
    ;;; 3 - C-n, C-p, C-a will all result in `foo-scroll' being called now
    ;;
    ;;; 4 - C-p until you are above line 1 and back down and notice C-a
    ;;;   doesnt trigger `foo-scroll', even when you move below line 1
    ;;;   again

    In rcirc, I am using a scroll-function, like the one above, and it is
    being called on every keypress once recenter has been called once.  Is
    this an emacs bug?  If not, how do I suppress those subsequent calls
    cleanly?

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: window-scroll-functions called too often
  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-09 18:46   ` Ryan Yeske
  1 sibling, 1 reply; 8+ messages in thread
From: Ryan Yeske @ 2006-09-03 19:41 UTC (permalink / raw)
  Cc: emacs-devel

Richard Stallman <rms@gnu.org> writes:

> It seems unreasonable to put a hook on window-scroll-functions which
> scrolls the window differently.  The intended use of that hook is to
> to whatever is necessary to support the scrolling that the user wants
> to do, not override it.  So I am not really surprised that this does
> not work.
>
> What problem are you trying to solve?

A simple way to keep the point at the bottom of the window in rcirc
buffers when messages come in, on user input, when splitting windows,
and when resizing the minibuffer.  Using window-scroll-functions is
the only way I've been able to have it work the way I like (and how I
think users expect).

In `rcirc-mode' I have:
(add-hook 'window-scroll-functions 'rcirc-scroll-to-bottom nil t)

And the function:

(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)))))

The above is adapted from similar code in erc-goodies.el.

Ryan

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: window-scroll-functions called too often
  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
  0 siblings, 2 replies; 8+ messages in thread
From: Richard Stallman @ 2006-09-04 17:17 UTC (permalink / raw)
  Cc: emacs-devel

    A simple way to keep the point at the bottom of the window in rcirc
    buffers when messages come in, on user input, when splitting windows,
    and when resizing the minibuffer.

I suggest you copy the method used by comint.
It works.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: window-scroll-functions called too often
  2006-09-04 17:17     ` Richard Stallman
@ 2006-09-05  1:34       ` Miles Bader
  2006-09-08  0:19       ` Ryan Yeske
  1 sibling, 0 replies; 8+ messages in thread
From: Miles Bader @ 2006-09-05  1:34 UTC (permalink / raw)
  Cc: Ryan Yeske, emacs-devel

Richard Stallman <rms@gnu.org> writes:
>     A simple way to keep the point at the bottom of the window in rcirc
>     buffers when messages come in, on user input, when splitting windows,
>     and when resizing the minibuffer.
>
> I suggest you copy the method used by comint.
> It works.

But please make it optional; I absolutely hate that behavior.

Thanks,

-Miles

-- 
"An atheist doesn't have to be someone who thinks he has a proof that there
can't be a god.  He only has to be someone who believes that the evidence
on the God question is at a similar level to the evidence on the werewolf
question."  [John McCarthy]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: window-scroll-functions called too often
  2006-09-04 17:17     ` Richard Stallman
  2006-09-05  1:34       ` Miles Bader
@ 2006-09-08  0:19       ` Ryan Yeske
  2006-09-08 15:11         ` Richard Stallman
  1 sibling, 1 reply; 8+ messages in thread
From: Ryan Yeske @ 2006-09-08  0:19 UTC (permalink / raw)
  Cc: emacs-devel

   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))

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: window-scroll-functions called too often
  2006-09-08  0:19       ` Ryan Yeske
@ 2006-09-08 15:11         ` Richard Stallman
  0 siblings, 0 replies; 8+ messages in thread
From: Richard Stallman @ 2006-09-08 15:11 UTC (permalink / raw)
  Cc: emacs-devel

If nobody shows a problem with your change in a few days, please
install it.  Thanks.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: window-scroll-functions called too often
  2006-09-03 15:17 ` window-scroll-functions called too often Richard Stallman
  2006-09-03 19:41   ` Ryan Yeske
@ 2006-09-09 18:46   ` Ryan Yeske
  2006-09-10 13:04     ` Richard Stallman
  1 sibling, 1 reply; 8+ messages in thread
From: Ryan Yeske @ 2006-09-09 18:46 UTC (permalink / raw)
  Cc: emacs-devel

Richard Stallman <rms@gnu.org> writes:

> It seems unreasonable to put a hook on window-scroll-functions which
> scrolls the window differently.  The intended use of that hook is to
> to whatever is necessary to support the scrolling that the user
> wants to do, not override it.  So I am not really surprised that
> this does not work.

I think the `window-scroll-functions' documentation should explicitly
mention that the intention is not to override the.  I originally
thought that this would be the very place to hook in my own scroll
code.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: window-scroll-functions called too often
  2006-09-09 18:46   ` Ryan Yeske
@ 2006-09-10 13:04     ` Richard Stallman
  0 siblings, 0 replies; 8+ messages in thread
From: Richard Stallman @ 2006-09-10 13:04 UTC (permalink / raw)
  Cc: emacs-devel

    I think the `window-scroll-functions' documentation should explicitly
    mention that the intention is not to override the.  I originally
    thought that this would be the very place to hook in my own scroll
    code.

I put this in the Lisp Manual.  Thanks.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2006-09-10 13:04 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [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
2006-09-08 15:11         ` Richard Stallman
2006-09-09 18:46   ` Ryan Yeske
2006-09-10 13:04     ` Richard Stallman

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).