bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#22404: 25.1.50; Forcing `window-scroll-functions` to run.


From: Keith David Bershatsky
Subject: bug#22404: 25.1.50; Forcing `window-scroll-functions` to run.
Date: Tue, 19 Jan 2016 11:26:59 -0800

I too, John, got really excited when I saw `run-window-scroll-functions`.  
Unfortunately, it doesn't return the correct window-start and window-end 
because it runs too soon.  It's not really a trigger that forces the WSF to run 
at its normal stages during redisplay.  If you run the following test in a 
lengthy buffer in a vertical split window pane with a *Messages* buffer in the 
other pane, then use the down arrow key to force window scrolling as the cursor 
moves, you'll see the numbers from the PCH are wrong and the numbers from WSF 
are correct.  The other problem with `run-window-scroll-functions` for this 
usage is that the WSF still runs when it is supposed to run, but there is an 
extra call to just the function attached to the WSF hook -- in other words, 
there might be as many as three (3) times the WSF function runs -- once with 
the wrong results off of the PCH, and once with the initial results from the 
WSF, and one final time when the WSF does its last call.  That last call on the 
WSF is the one I'm seeking.  Sometimes WSF only runs once when scrolling if 
point is fully visible.

(setq scroll-conservatively 101)

(defvar pch-test-var nil)

(defun pch-fn ()
  (let ((pch-test-var t))
  (run-window-scroll-functions (selected-window))))

(add-hook 'post-command-hook 'pch-fn nil 'local)

(defun wsf-fn (win start)
  (message "hook: %s | win: %s | start: %s | end: %s"
    (if pch-test-var "PCH" "WSF") win start (window-end win t)))

(add-hook 'window-scroll-functions 'wsf-fn nil 'local)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

At Tue, 19 Jan 2016 10:53:32 -0800,
John Wiegley wrote:
> 
> >>>>> Keith David Bershatsky <esq@lawlist.com> writes:
> 
> > `run-window-scroll-functions` runs immediately and is not a viable
> > substitute for this feature request.
> 
> Keith, why is the fact that it runs immediately a problem? The very name of
> this function answers your feature request, but you don't explain why it is
> insufficient, other than this comment.
> 
> How would run-window-scroll-functions need to be changed, since that is the
> advertised way to... run the window-scroll-functions?
> 
> -- 
> John Wiegley





reply via email to

[Prev in Thread] Current Thread [Next in Thread]