unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: martin rudalics <rudalics@gmx.at>
To: dalanicolai <dalanicolai@gmail.com>
Cc: Michael Heerdegen <michael_heerdegen@web.de>,
	54438@debbugs.gnu.org, Stefan Monnier <monnier@iro.umontreal.ca>
Subject: bug#54438: 27.2; inconsistent-behavior-global-vs-local-hook
Date: Fri, 18 Mar 2022 10:58:23 +0100	[thread overview]
Message-ID: <8e029893-2d25-8302-7e30-c75abef3ec3e@gmx.at> (raw)
In-Reply-To: <CACJP=3=VtJGMt6L-C00Nxmebv61519D6j-ofuW0WHZMjBuSMTA@mail.gmail.com>

 > About the 'restoring mechanism'; the global hook seems not to restore the
 > window selected before running the hook.

Right.  You can easily test that yourself by calling
'run-window-configuration-change-hook' directly.

 > So the 'restoring mechanism' works like you explained for the local hook
 > but not for the global hook
 > (where after calling 'test', the pop-up buffer will be selected).

Right.  Because for running the global hook, Emacs does not enter the
(costly) window selection rigmarole.  But I think that even for the
global hook you might be able to run into troubles when the current
buffer and that of the selected window differ.  A case for the expert
only though.

 > Also, I would expect that a hook just calls the hook function, and it would
 > not 'restore the window
 >   selected before the hook'. I would say the restoring is undesired behavior.

The idea is probably that a function on that hook should be allowed to
inadvertently select some other window and have the hook runner fix
that.  Maybe Stefan can tell us more.

In either case you can avoid these problems by running whatever you have
in mind on 'window-state-change-hook' with the following caveat:

    • Window change functions should not create or delete windows or
      change the buffer, size or selection status of any window because
      there is no guarantee that the information about such a change will
      be propagated to other window change functions.  If at all, any
      such change should be executed only by the last function listed by
      the default value of ‘window-state-change-hook’.

martin

  parent reply	other threads:[~2022-03-18  9:58 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-17 17:52 bug#54438: 27.2; inconsistent-behavior-global-vs-local-hook dalanicolai
2022-03-18  0:42 ` Michael Heerdegen
2022-03-18  8:37   ` martin rudalics
2022-03-18  9:11     ` dalanicolai
2022-03-18  9:12       ` dalanicolai
2022-03-18  9:58       ` martin rudalics [this message]
2022-03-18 12:14         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-03-18 17:03           ` dalanicolai
2022-03-18  8:36 ` martin rudalics

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=8e029893-2d25-8302-7e30-c75abef3ec3e@gmx.at \
    --to=rudalics@gmx.at \
    --cc=54438@debbugs.gnu.org \
    --cc=dalanicolai@gmail.com \
    --cc=michael_heerdegen@web.de \
    --cc=monnier@iro.umontreal.ca \
    /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).