all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Keith David Bershatsky <esq@lawlist.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 22404@debbugs.gnu.org
Subject: bug#22404: 25.1.50; Forcing `window-scroll-functions` to run.
Date: Wed, 20 Jan 2016 18:32:40 -0800	[thread overview]
Message-ID: <m2io2nk6gn.wl%esq@lawlist.com> (raw)
In-Reply-To: <m260yqdsp7.wl%esq@lawlist.com>

[-- Attachment #1: Type: text/plain, Size: 3054 bytes --]

`set-window-start` (without the third option) would indeed trigger the WSF because it contains a key ingredient:  `w->force_start = true`.

Because the second argument (i.e., POS) cannot be known from the PCH when point has moved beyond the visible window, `set-window-start` is not a viable substitute for this feature request.

The attached patch is an example of an implementation of this feature request.  I created a new function called `force-wsf`, whose sole purpose is to trigger the WSF to run during redisplay -- after the PCH has already finished.  As noted in a previous e-mail, `run-window-scroll-functions` doesn't accomplish what `force-wsf` can achieve because the former runs the function attached to the WSF immediately -- instead of waiting until later on during redisplay when the correct values of `window-start` and `window-end` are ascertainable.

This is my first attempt at writing something like this, and I'm not sure exactly if everything is correct.  It does, however, appear to achieve the desired affect -- i.e., run the WSF at least once every command loop (even if no scrolling occurs) so we can always know the correct values for `window-start` and `window-end`.  It is no longer necessary to guess with `elisp` from the PCH regarding whether WSF will run.

I would, however, still like to come up with a test at the C-source code level that tells me whether the WSF will run more than one time -- because I only care about the last call on the WSF when the final values for `window-start` and `window-end` become available.

The usage for the new function `force-wsf` is as follows:

    (defun pch-fn ()
      (force-wsf (selected-window)))
    
    (add-hook 'post-command-hook 'pch-fn nil 'local)
    
    (defun wsf-fn (win start)
      (message "point: %s | win: %s | start: %s | end: %s" 
        ;; A better test at the C-source code level appears to be needed to ascertain whether
        ;; the WSF will run more than one time -- because we want the value for `window-start`
        ;; and `window-end win t` based on the LAST time WSF runs during the command loop.
        (if (pos-visible-in-window-p nil nil nil)
          "visible"
          "NOT visible")
        win start (window-end win t)))
    
    (add-hook 'window-scroll-functions 'wsf-fn nil 'local)

The new function in window.c looks like this:

    DEFUN ("force-wsf", Fforce_wsf, Sforce_wsf, 0, 1, 0,
           doc: /* Set force_start so that redisplay_window will run the
    window-scroll-functions.  */)
      (Lisp_Object window)
    {
      register struct window *w = decode_live_window (window);
        w->optional_new_start = true;
        return;
    }

And, the there is one additional line that may also be required further on down in window.d:

  defsubr (&Sforce_wsf);

Thanks,

Keith

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

At Wed, 20 Jan 2016 15:34:41 +0200,
Eli Zaretskii wrote:
> 
> > . . . you need to call set-window-start with its 3rd
> argument omitted or nil.  Does that solve your problem?


[-- Attachment #2: patch.diff --]
[-- Type: application/diff, Size: 1092 bytes --]

  parent reply	other threads:[~2016-01-21  2:32 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-19  5:49 bug#22404: 25.1.50; Forcing `window-scroll-functions` to run Keith David Bershatsky
2016-01-19 17:50 ` Eli Zaretskii
2016-01-19 18:49 ` Keith David Bershatsky
2016-01-19 19:39   ` Eli Zaretskii
2016-01-19 18:53 ` John Wiegley
2016-01-19 19:26 ` Keith David Bershatsky
2016-01-19 20:35 ` Keith David Bershatsky
2016-01-20 13:34   ` Eli Zaretskii
2016-01-19 23:07 ` Keith David Bershatsky
2016-01-21  2:32 ` Keith David Bershatsky [this message]
2016-01-21 17:41   ` Eli Zaretskii
2016-01-21 19:54 ` Keith David Bershatsky
2016-01-21 20:28   ` Eli Zaretskii
2016-01-29 12:00     ` Michael Heerdegen
2016-01-29 14:37       ` Eli Zaretskii
2016-01-29 14:57         ` Michael Heerdegen
2016-01-29 15:33           ` Eli Zaretskii
2016-01-21 21:11 ` Keith David Bershatsky
2016-01-29  2:14   ` John Wiegley
2016-01-29  3:08 ` Keith David Bershatsky
2016-01-29  8:42   ` Eli Zaretskii
2016-01-29 15:54 ` Keith David Bershatsky
2016-02-01  3:50 ` Keith David Bershatsky
2016-02-01 19:54   ` Eli Zaretskii
2016-02-01 13:18 ` Keith David Bershatsky
2016-02-02 16:34   ` Eli Zaretskii
2016-02-02  5:58 ` Keith David Bershatsky
2016-02-02 18:16 ` Keith David Bershatsky
2016-02-02 18:43   ` Eli Zaretskii
2016-02-02 20:00 ` Keith David Bershatsky
2016-02-02 21:05 ` Keith David Bershatsky
2016-02-08  8:51 ` Keith David Bershatsky
2016-02-08 17:17   ` Eli Zaretskii
2016-02-09 16:00 ` Keith David Bershatsky
2016-02-09 17:48   ` Eli Zaretskii
2016-02-12  0:14 ` Keith David Bershatsky
2016-02-12  8:18   ` Eli Zaretskii
2016-02-16  3:39     ` Keith David Bershatsky
2016-02-12  8:25   ` Why do idle timers trigger redisplay? Eli Zaretskii
2016-02-22  6:05 ` bug#22404: 25.1.50; Forcing `window-scroll-functions` to run Keith David Bershatsky
2016-03-11 16:21 ` Keith David Bershatsky

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=m2io2nk6gn.wl%esq@lawlist.com \
    --to=esq@lawlist.com \
    --cc=22404@debbugs.gnu.org \
    --cc=eliz@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.