* bug#49057: 28.0.50; windmove-display-in-direction ignores windmove-display-no-select
[not found] <20210616064248.mqqzlt7qyxwqrcfy.ref@Ergus>
@ 2021-06-16 6:42 ` Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-06-16 7:59 ` Juri Linkov
0 siblings, 1 reply; 9+ messages in thread
From: Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2021-06-16 6:42 UTC (permalink / raw)
To: 49057
Hi I just try to use the user option windmove-display-no-select and I
found that the new window is always selected and ignores
windmove-display-no-select.
To reproduce:
emacs -Q
M-: (setq windmove-display-no-select t)
M-x windmove-display-right
C-x b *scratch*
The new window will be selected independently of the value of
windmove-display-no-select.
Sometimes the new buffer is displayed in the current buffer ignoring
windmove-display-right (when *scratch* is already on the right for
example).
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#49057: 28.0.50; windmove-display-in-direction ignores windmove-display-no-select
2021-06-16 6:42 ` bug#49057: 28.0.50; windmove-display-in-direction ignores windmove-display-no-select Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2021-06-16 7:59 ` Juri Linkov
2021-06-16 12:16 ` Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 1 reply; 9+ messages in thread
From: Juri Linkov @ 2021-06-16 7:59 UTC (permalink / raw)
To: 49057; +Cc: Ergus
> M-: (setq windmove-display-no-select t)
> M-x windmove-display-right
> C-x b *scratch*
>
> The new window will be selected independently of the value of
> windmove-display-no-select.
>
> Sometimes the new buffer is displayed in the current buffer ignoring
> windmove-display-right (when *scratch* is already on the right for
> example).
Please also do:
M-: (setq switch-to-buffer-obey-display-actions t)
What we could do to improve this:
1. enable switch-to-buffer-obey-display-actions by default;
2. mention switch-to-buffer-obey-display-actions in more docstrings.
Currently the docstring of windmove-display-in-direction has this text:
"When `switch-to-buffer-obey-display-actions' is non-nil,
`switch-to-buffer' commands are also supported."
Maybe the same text should be copied to all commands that use
windmove-display-in-direction, i.e. to windmove-display-right,
etc.
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#49057: 28.0.50; windmove-display-in-direction ignores windmove-display-no-select
2021-06-16 7:59 ` Juri Linkov
@ 2021-06-16 12:16 ` Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-06-16 23:08 ` Juri Linkov
0 siblings, 1 reply; 9+ messages in thread
From: Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2021-06-16 12:16 UTC (permalink / raw)
To: Juri Linkov; +Cc: 49057
On Wed, Jun 16, 2021 at 10:59:50AM +0300, Juri Linkov wrote:
>> M-: (setq windmove-display-no-select t)
>> M-x windmove-display-right
>> C-x b *scratch*
>>
>> The new window will be selected independently of the value of
>> windmove-display-no-select.
>>
>> Sometimes the new buffer is displayed in the current buffer ignoring
>> windmove-display-right (when *scratch* is already on the right for
>> example).
>
>Please also do:
>
> M-: (setq switch-to-buffer-obey-display-actions t)
>
>What we could do to improve this:
>
>1. enable switch-to-buffer-obey-display-actions by default;
>
>2. mention switch-to-buffer-obey-display-actions in more docstrings.
>
>Currently the docstring of windmove-display-in-direction has this text:
>
> "When `switch-to-buffer-obey-display-actions' is non-nil,
> `switch-to-buffer' commands are also supported."
>
>Maybe the same text should be copied to all commands that use
>windmove-display-in-direction, i.e. to windmove-display-right,
>etc.
Sorry, I forgot to mention that line but it is enabled but I already
have that in my config. Even with that it is not working fine.
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#49057: 28.0.50; windmove-display-in-direction ignores windmove-display-no-select
2021-06-16 12:16 ` Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2021-06-16 23:08 ` Juri Linkov
2021-06-17 8:33 ` martin rudalics
0 siblings, 1 reply; 9+ messages in thread
From: Juri Linkov @ 2021-06-16 23:08 UTC (permalink / raw)
To: Ergus; +Cc: 49057
> Sorry, I forgot to mention that line but it is enabled but I already
> have that in my config. Even with that it is not working fine.
Thanks for clarification, then we have a problem because
pop-to-buffer insists on always selecting the new window
that was displayed:
;; Make sure the window is selected (Bug#8615), (Bug#6954)
(select-window window norecord))
Here is the workflow:
1. switch-to-buffer calls pop-to-buffer-same-window
2. pop-to-buffer-same-window calls pop-to-buffer
3. pop-to-buffer calls display-buffer
4. display-buffer calls display-buffer-override-next-command
that calls post-function from windmove-display-in-direction
that selects the old window
5. but later pop-to-buffer selects the new window,
thus overriding the specified selection of the old window.
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#49057: 28.0.50; windmove-display-in-direction ignores windmove-display-no-select
2021-06-16 23:08 ` Juri Linkov
@ 2021-06-17 8:33 ` martin rudalics
2021-06-17 19:54 ` Juri Linkov
0 siblings, 1 reply; 9+ messages in thread
From: martin rudalics @ 2021-06-17 8:33 UTC (permalink / raw)
To: Juri Linkov, Ergus; +Cc: 49057
> 1. switch-to-buffer calls pop-to-buffer-same-window
> 2. pop-to-buffer-same-window calls pop-to-buffer
> 3. pop-to-buffer calls display-buffer
> 4. display-buffer calls display-buffer-override-next-command
> that calls post-function from windmove-display-in-direction
> that selects the old window
>
> 5. but later pop-to-buffer selects the new window,
> thus overriding the specified selection of the old window.
Conceptually, `pop-to-buffer' has to
Display buffer specified by BUFFER-OR-NAME and select its window.
so I cannot see anything wrong here. Step 5 must be allowed to override
any selection made in step 4 and any expectation derived from having set
`windmove-display-no-select' to t is moot here.
[BTW, `windmove-display-in-direction' is not a command but its doc-string
talks about
If ‘windmove-display-no-select’ is non-nil, this command doesn’t
select the window with a displayed buffer, and the meaning of
the prefix argument is reversed.
This should be fixed.]
Now we all know that `display-buffer' may or may not select the chosen
window. We cannot disallow it when the window shall appear on a new
frame because most WMs will "select" the new frame. Even trying to
disallow it in such case might be a bad idea because this instance of
`display-buffer' might have been triggered by a `pop-to-buffer' like
function and we will confuse the hell out of the WM - do not select the
new frame as `display-buffer' says, do select it as `pop-to-buffer' or
`switch-to-buffer' say ...
So maybe we should relax that basic statement of `display-buffer'
This command makes BUFFER-OR-NAME appear in some window, without
selecting the window or making the buffer current.
because it is wrong anyway. Then we could add an additional action
alist entry, say 'select' with values like
- t (try to select)
- nil (avoid to select)
and maybe `never' or 'on-new-frame-only' to emphasize whether
`display-buffer' is allowed to select the window and make its buffer
current. This has the advantage of freeing `display-buffer' from the
responsibility to decide whether it may select the chosen window.
Then we could also try to use frame parameters like 'no-focus-on-map'
and 'no-accept-focus' right away and users do not have to specify them
explicitly via `pop-up-frame-parameters'.
martin
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#49057: 28.0.50; windmove-display-in-direction ignores windmove-display-no-select
2021-06-17 8:33 ` martin rudalics
@ 2021-06-17 19:54 ` Juri Linkov
2021-06-18 7:33 ` martin rudalics
0 siblings, 1 reply; 9+ messages in thread
From: Juri Linkov @ 2021-06-17 19:54 UTC (permalink / raw)
To: martin rudalics; +Cc: 49057, Ergus
tags 49057 fixed
thanks
> Conceptually, `pop-to-buffer' has to
>
> Display buffer specified by BUFFER-OR-NAME and select its window.
>
> so I cannot see anything wrong here. Step 5 must be allowed to override
> any selection made in step 4 and any expectation derived from having set
> `windmove-display-no-select' to t is moot here.
I completely agree. All code that calls `pop-to-buffer' expects that
`pop-to-buffer' will select the displayed window, so code could continue
working on the selected window after its call.
So the only safe solution is to select the needed window in post-command-hook,
when the current command is already finished. This is how this bug is fixed now.
> [BTW, `windmove-display-in-direction' is not a command but its doc-string
> talks about
>
> If ‘windmove-display-no-select’ is non-nil, this command doesn’t
> select the window with a displayed buffer, and the meaning of
> the prefix argument is reversed.
>
> This should be fixed.]
Now fixed as well.
> Now we all know that `display-buffer' may or may not select the chosen
> window. We cannot disallow it when the window shall appear on a new
> frame because most WMs will "select" the new frame. Even trying to
> disallow it in such case might be a bad idea because this instance of
> `display-buffer' might have been triggered by a `pop-to-buffer' like
> function and we will confuse the hell out of the WM - do not select the
> new frame as `display-buffer' says, do select it as `pop-to-buffer' or
> `switch-to-buffer' say ...
>
> So maybe we should relax that basic statement of `display-buffer'
>
> This command makes BUFFER-OR-NAME appear in some window, without
> selecting the window or making the buffer current.
>
> because it is wrong anyway. Then we could add an additional action
> alist entry, say 'select' with values like
>
> - t (try to select)
>
> - nil (avoid to select)
>
> and maybe `never' or 'on-new-frame-only' to emphasize whether
> `display-buffer' is allowed to select the window and make its buffer
> current. This has the advantage of freeing `display-buffer' from the
> responsibility to decide whether it may select the chosen window.
>
> Then we could also try to use frame parameters like 'no-focus-on-map'
> and 'no-accept-focus' right away and users do not have to specify them
> explicitly via `pop-up-frame-parameters'.
But wouldn't this be too confusing for users, when users will call
`pop-to-buffer' with the new alist entry 'select', and it still will select
the unintended window as `pop-to-buffer' currently does?
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#49057: 28.0.50; windmove-display-in-direction ignores windmove-display-no-select
2021-06-17 19:54 ` Juri Linkov
@ 2021-06-18 7:33 ` martin rudalics
2021-06-18 19:10 ` Juri Linkov
0 siblings, 1 reply; 9+ messages in thread
From: martin rudalics @ 2021-06-18 7:33 UTC (permalink / raw)
To: Juri Linkov; +Cc: 49057, Ergus
> But wouldn't this be too confusing for users, when users will call
> `pop-to-buffer' with the new alist entry 'select', and it still will select
> the unintended window as `pop-to-buffer' currently does?
`pop-to-buffer' has to select the window chosen by `display-buffer'
regardless of whether `display-buffer' selected it or not. Do we
violate this principle anywhere? The basic difference I'd propose is to
have `pop-to-buffer' bind
(display-buffer-overriding-action '(nil ((select . t))))
around the `display-buffer' call and so `display-buffer' will select the
chosen window regardless of any user customizations.
martin
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#49057: 28.0.50; windmove-display-in-direction ignores windmove-display-no-select
2021-06-18 7:33 ` martin rudalics
@ 2021-06-18 19:10 ` Juri Linkov
2021-06-20 9:21 ` martin rudalics
0 siblings, 1 reply; 9+ messages in thread
From: Juri Linkov @ 2021-06-18 19:10 UTC (permalink / raw)
To: martin rudalics; +Cc: 49057, Ergus
>> But wouldn't this be too confusing for users, when users will call
>> `pop-to-buffer' with the new alist entry 'select', and it still will select
>> the unintended window as `pop-to-buffer' currently does?
>
> `pop-to-buffer' has to select the window chosen by `display-buffer'
> regardless of whether `display-buffer' selected it or not. Do we
> violate this principle anywhere? The basic difference I'd propose is to
> have `pop-to-buffer' bind
>
> (display-buffer-overriding-action '(nil ((select . t))))
>
> around the `display-buffer' call and so `display-buffer' will select the
> chosen window regardless of any user customizations.
Then other commands should take care to not override
display-buffer-overriding-action.
Do you intend to rewrite commands that currently use
switch-to-buffer-other-window (such as Buffer-menu-other-window
and dired-find-file-other-window) to use `display-buffer'
with '(nil ((select . t)))? Probably not because
switch-to-buffer-other-window already uses pop-to-buffer.
Then maybe you want to rewrite commands that currently use
`display-buffer' with ACTION=t (such as
Buffer-menu-switch-other-window and dired-display-file)
to use `display-buffer' with '(nil ((select . nil))) instead?
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#49057: 28.0.50; windmove-display-in-direction ignores windmove-display-no-select
2021-06-18 19:10 ` Juri Linkov
@ 2021-06-20 9:21 ` martin rudalics
0 siblings, 0 replies; 9+ messages in thread
From: martin rudalics @ 2021-06-20 9:21 UTC (permalink / raw)
To: Juri Linkov; +Cc: 49057, Ergus
> Do you intend to rewrite commands that currently use
> switch-to-buffer-other-window (such as Buffer-menu-other-window
> and dired-find-file-other-window) to use `display-buffer'
> with '(nil ((select . t)))? Probably not because
> switch-to-buffer-other-window already uses pop-to-buffer.
>
> Then maybe you want to rewrite commands that currently use
> `display-buffer' with ACTION=t (such as
> Buffer-menu-switch-other-window and dired-display-file)
> to use `display-buffer' with '(nil ((select . nil))) instead?
These do not use `pop-to-buffer' so I'd leave them alone. Note that the
only value for 'select' I'd really care about is 'never' because it
means that `display-buffer' should try to refrain from focusing another
frame - provided the WM allows it. But I doubt that people really care.
martin
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2021-06-20 9:21 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20210616064248.mqqzlt7qyxwqrcfy.ref@Ergus>
2021-06-16 6:42 ` bug#49057: 28.0.50; windmove-display-in-direction ignores windmove-display-no-select Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-06-16 7:59 ` Juri Linkov
2021-06-16 12:16 ` Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-06-16 23:08 ` Juri Linkov
2021-06-17 8:33 ` martin rudalics
2021-06-17 19:54 ` Juri Linkov
2021-06-18 7:33 ` martin rudalics
2021-06-18 19:10 ` Juri Linkov
2021-06-20 9:21 ` martin rudalics
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.