From: Keith David Bershatsky <esq@lawlist.com>
To: "John Wiegley" <johnw@gnu.org>
Cc: 22404@debbugs.gnu.org
Subject: bug#22404: 25.1.50; Forcing `window-scroll-functions` to run.
Date: Thu, 28 Jan 2016 19:08:22 -0800 [thread overview]
Message-ID: <m237thf5g9.wl%esq@lawlist.com> (raw)
In-Reply-To: <m260yqdsp7.wl%esq@lawlist.com>
Thanks, John, for taking another look at #22404.
Let's say for example that someone has a function named `foo` which uses `window-start` and `window-end`, and the user wants that function to run every command loop. Everyone will immediately think of the `post-command-hook` because the buffer or position may have been modified by `this-command` (whatever that may be). The way Emacs is presently designed, people are needlessly calling `foo` multiple times when scrolling occurs because the `post-command-hook` can't provide correct numbers. Most people probably don't care because `foo` is trivial in terms of the time it takes to run -- so if it runs 3 times per command loop, no problem. I personally think calling `foo` 3 times per command loop, when it only needed to run once, is a poor design.
There is no 100% guaranteed test from the `post-command-hook` to know whether the `window-scroll-functions` hook will run, and if so, whether it will run 2 times (instead of just one).
Here is an excerpt from `window.h` that tells us what `optional_new_start` is currently used for:
/* True means we have explicitly changed the value of start,
but that the next redisplay is not obliged to use the new value.
This is used in Fdelete_other_windows to force a call to
Vwindow_scroll_functions; also by Frecenter with argument. */
bool_bf optional_new_start : 1;
It is also used for `set-window-buffer`; so perhaps that should be added to the doc-string.
By setting `optional_new_start` to `true`, we force the `window_scroll_functions` hook to run every command loop (during redisplay). If that happens, then the `post-command-hook` is no longer needed to run `foo`. So we have just reduced `foo` being called 2 to 3 times, to 1 to 2 times instead. I have been studying `xdisp.c` and have concluded that it is extremely difficult to know whether the `window-scroll-functions` hook will run 1 or 2 times, because that hook can modify the buffer and there are some other hooks that may modify the buffer too -- thus requiring a second call to the WSF.
So, the moral of the story is whether it is a good thing to call `foo` 2 to 3 times per command loop, instead of 1 to 2 times per command loop. And, it boils down to whether `foo` is costly. It is costly for me because I use `vertical-motion`. It may be costly to other users for a different reason.
Another idea would be to create a new animal that permits users to THROW_ANY_SWITCH from `elisp`. It doesn't have to be `optional_new_start` specifically. If users have an `elisp` mechanism to THROW_ANY_SWITCH, they can throw it from anywhere -- `pre-command-hook`, `post-command-hook`, etc. [By switch, I mean the bool_bf items in `window.h`.]
Keith
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
At Thu, 28 Jan 2016 18:14:43 -0800,
John Wiegley wrote:
>
> >>>>> Keith David Bershatsky <esq@lawlist.com> writes:
>
> >> What do you need from window-scroll-functions? Only the correct values of
> >> window-start and window-end? Or something else?
>
> > Correct, I just need the 100% accurate `window-start` and
> > `window-end`. :) :)
>
> Keith, your use case here does strike me as a bit exotic. I'm not saying it's
> not a bug, but I'm wondering if your suggested solution is really the best
> path to the final result you're reaching for. The cost of `vertical-motion',
> for example, seems to be a driving force behind your request.
next prev parent reply other threads:[~2016-01-29 3:08 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
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 [this message]
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=m237thf5g9.wl%esq@lawlist.com \
--to=esq@lawlist.com \
--cc=22404@debbugs.gnu.org \
--cc=johnw@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.