unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: martin rudalics via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Juri Linkov <juri@linkov.net>
Cc: 67993@debbugs.gnu.org
Subject: bug#67993: Selecting buffer automatically
Date: Mon, 8 Jan 2024 09:55:58 +0100	[thread overview]
Message-ID: <1ea06837-0d7e-46ba-849c-a4bf42929c40@gmx.at> (raw)
In-Reply-To: <86cyudjdmb.fsf@mail.linkov.net>

 >> In 'display-buffer' first save the selected window as
 >> old-selected-window, display the buffer and in your code select
 >> old-selected-window instead of (old-selected-window).
 >
 > Unfortunately, this is not so easy to do.  'old-selected-window'
 > should be reinitialized before the next command is executed.

Why?  As I imagine it, it would be let-bound in 'display-buffer'.

 > So by definition 'old-selected-window' should contain
 > the window that was selected before the current command
 > was executed.  I have no idea how to do this without hooks.

Hmmm... I have problems to see what the "current command" is.  One and
the same command may contain multiple invocations of 'display-buffer'.
I thought you wanted a 'select-window' entry to be handled separately by
each of them.  Otherwise, IIUC the entry provided by the last invocation
would prevail any entries provided by previous invocations.  How would
you explain that to a user?

If you want 'old-selected-window' to denote "some" state before the
"current command", the function 'old-selected-window' might be a better
choice than a variable you bind in 'display-buffer' (but note that
redisplay may occur in the middle of executing a command).

But if you want to interpret "current command" more strictly, you need a
separate variable, say 'pre-command-selected-window' that you always set
in 'pre-command-hook' and consult (and maybe reset) in
'post-command-hook'.

 > 'pop-to-buffer' can't be changed because (select-window . t)
 > should be handled only at the end of the current command.

Are your sure that you do not somewhat arbitrarily restrict the scope of
this feature?  What if (select-window . t) were to be handled in a call
from within a timer?  Would you ignore it?

 > So this also need to run 'select-frame' in post-command-hook.

'select-frame-set-input-focus' maybe.  Or, what's worse, undo the
consequences of a preceding 'select-frame-set-input-focus' call
triggered by 'pop-to-buffer'.  That's why any such 'select-window' call
(or its avoidance) you propose would be better handled within
'display-buffer' and not later in a 'post-command-hook'.

martin





  reply	other threads:[~2024-01-08  8:55 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-23 17:51 bug#67993: Selecting buffer automatically Juri Linkov
2024-01-04 17:12 ` Juri Linkov
2024-01-05  9:23   ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-06 17:40     ` Juri Linkov
2024-01-07 14:56       ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-07 16:51         ` Juri Linkov
2024-01-08  8:55           ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2024-01-09 17:20             ` Juri Linkov
2024-01-10  8:37               ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-10 17:12                 ` Juri Linkov
2024-01-11  9:15                   ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-12  7:46                     ` Juri Linkov
2024-01-13 10:39                       ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-14 18:48                         ` Juri Linkov
2024-01-15 10:23                           ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-15 17:56                             ` Juri Linkov
2024-01-16 10:18                               ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-16 16:54                                 ` Juri Linkov

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=1ea06837-0d7e-46ba-849c-a4bf42929c40@gmx.at \
    --to=bug-gnu-emacs@gnu.org \
    --cc=67993@debbugs.gnu.org \
    --cc=juri@linkov.net \
    --cc=rudalics@gmx.at \
    /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).