unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Keith David Bershatsky <esq@lawlist.com>
Cc: 19684@debbugs.gnu.org
Subject: bug#19684: 25.0.50; `this-command` is set to `nil` before `window-scroll-functions` hook	runs.
Date: Sun, 25 Jan 2015 17:33:20 +0200	[thread overview]
Message-ID: <8361buswn3.fsf@gnu.org> (raw)
In-Reply-To: <m2ppa3xr6z.wl%esq@lawlist.com>

> Date: Sat, 24 Jan 2015 23:19:48 -0800
> From: Keith David Bershatsky <esq@lawlist.com>
> 
> To the extent that a user wishes to use the value of `this-command` within a 
> function attached to the `window-scroll-functions` hook, a workaround is needed 
> because the default value is `nil`.  In other words, something at the C source 
> code level is setting the value to `nil` before the `window-scroll-functions` 
> hook runs.

That "something" is the command loop itself: it resets 'this-command'
when the command finishes and returns to the loop.

Recall that in Emacs, execution of commands running the Lisp
interpreter is separated from redisplay: the latter runs when Emacs is
idle and is waiting for input.  Since most of the calls to
window-scroll-functions are made by the display engine, the command
already returned to the command loop by that time.

> Calling `redisplay` somehow prevents `this-command` from being reset
> to `nil`

I hope it is now clear why this happens: in this scenario redisplay is
entered before the command finishes, so 'this-command' was still not
reset.

> The most reliable test I have discovered to pinpoint when the 
> `window-scroll-functions` hook will activate is by having the following code 
> within a function attached to the `post-command-hook`:  
> (pos-visible-in-window-p (point) (get-buffer-window (current-buffer) 
> (selected-frame))).  If the result is `t`, then the `window-scroll-functions` 
> hook will be activating.

You are well-advised not to depend on such implementation details.

> Although this bug report has been submitted with Emacs Trunk from October 1, 
> 2014; the behavior is the same with Emacs Trunk built on January 1, 2015.

Emacs always behaved like that.  And it's not a bug.





  parent reply	other threads:[~2015-01-25 15:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-25  7:19 bug#19684: 25.0.50; `this-command` is set to `nil` before `window-scroll-functions` hook runs Keith David Bershatsky
2015-01-25 10:38 ` martin rudalics
2015-01-25 15:33 ` Eli Zaretskii [this message]
2015-01-25 16:14 ` Stefan Monnier
2015-01-25 17:42 ` Keith David Bershatsky
2019-10-01 20:16 ` Stefan Kangas

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8361buswn3.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=19684@debbugs.gnu.org \
    --cc=esq@lawlist.com \
    /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 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).