GNU bug report logs -
#78082
31.0.50; Proposal for this-command display buffer action alist key
Previous Next
To reply to this bug, email your comments to 78082 AT debbugs.gnu.org.
There is no need to reopen the bug first.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
juri <at> linkov.net, bug-gnu-emacs <at> gnu.org
:
bug#78082
; Package
emacs
.
(Sun, 27 Apr 2025 08:48:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Sean Whitton <spwhitton <at> spwhitton.name>
:
New bug report received and forwarded. Copy sent to
juri <at> linkov.net, bug-gnu-emacs <at> gnu.org
.
(Sun, 27 Apr 2025 08:48:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
X-debbugs-cc: juri <at> linkov.net
I want windows generated by C-x v = to be displayed but not selected,
but windows generated by C-x v D to be both displayed and selected.
I have had advice in my init.el for a long time, using
save-selected-window, to achieve this. But I just learned about the
post-command-select-window display buffer action alist key, which would
be a better solution.
It's not quite applicable, however, due to how C-x v = and C-x v D both
use a buffer called *vc-diff*. Therefore, I can't distinguish them in
an entry in display-buffer-alist, I think?
I would like to propose a new display buffer action alist key called
this-command. Its value would be a command or list of commands.
The display-buffer-alist entry would apply only when the 'this-command'
variable matched the 'this-command' display buffer action alist entry.
I could then use
(("^\\*vc-diff\\*"
nil
(this-command . (vc-diff log-view-diff log-view-diff-changeset))
(post-command-select-window . t))
("^\\*vc-diff\\*"
nil
(this-command . vc-root-diff)
(post-command-select-window . nil)))
Juri, what do you think?
--
Sean Whitton
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78082
; Package
emacs
.
(Mon, 28 Apr 2025 15:23:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 78082 <at> debbugs.gnu.org (full text, mbox):
> I want windows generated by C-x v = to be displayed but not selected,
> but windows generated by C-x v D to be both displayed and selected.
>
> I have had advice in my init.el for a long time, using
> save-selected-window, to achieve this. But I just learned about the
> post-command-select-window display buffer action alist key, which would
> be a better solution.
>
> It's not quite applicable, however, due to how C-x v = and C-x v D both
> use a buffer called *vc-diff*. Therefore, I can't distinguish them in
> an entry in display-buffer-alist, I think?
>
> I would like to propose a new display buffer action alist key called
> this-command. Its value would be a command or list of commands.
> The display-buffer-alist entry would apply only when the 'this-command'
> variable matched the 'this-command' display buffer action alist entry.
> I could then use
>
> (("^\\*vc-diff\\*"
> nil
> (this-command . (vc-diff log-view-diff log-view-diff-changeset))
> (post-command-select-window . t))
> ("^\\*vc-diff\\*"
> nil
> (this-command . vc-root-diff)
> (post-command-select-window . nil)))
>
> Juri, what do you think?
Currently the official way to do this is to use a function predicate
in the condition part of the display-buffer-alist rule like this:
(add-to-list 'display-buffer-alist
`(,(lambda (buffer-name _action)
(and (memq this-command '( vc-diff log-view-diff
log-view-diff-changeset))
(string-match-p "^\\*vc-diff\\*" buffer-name)))
nil
(post-command-select-window . t)))
(add-to-list 'display-buffer-alist
`(,(lambda (buffer-name _action)
(and (eq this-command 'vc-root-diff)
(string-match-p "^\\*vc-diff\\*" buffer-name)))
nil
(post-command-select-window . nil)))
To simplify this, a special 'this-command' item could be supported as well,
but it should be in the condition part e.g.
(add-to-list 'display-buffer-alist
'((this-command . vc-root-diff)
nil
(post-command-select-window . nil)))
like there is a 'category' item:
(add-to-list 'display-buffer-alist
'((category . diff)
nil
(post-command-select-window . nil)))
But then the corresponding predicate for 'this-command'
should be added to 'buffer-match-p' when deemed necessary.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78082
; Package
emacs
.
(Tue, 29 Apr 2025 00:33:04 GMT)
Full text and
rfc822 format available.
Message #11 received at 78082 <at> debbugs.gnu.org (full text, mbox):
Hello,
On Mon 28 Apr 2025 at 06:09pm +03, Juri Linkov wrote:
>> I want windows generated by C-x v = to be displayed but not selected,
>> but windows generated by C-x v D to be both displayed and selected.
>>
>> I have had advice in my init.el for a long time, using
>> save-selected-window, to achieve this. But I just learned about the
>> post-command-select-window display buffer action alist key, which would
>> be a better solution.
>>
>> It's not quite applicable, however, due to how C-x v = and C-x v D both
>> use a buffer called *vc-diff*. Therefore, I can't distinguish them in
>> an entry in display-buffer-alist, I think?
>>
>> I would like to propose a new display buffer action alist key called
>> this-command. Its value would be a command or list of commands.
>> The display-buffer-alist entry would apply only when the 'this-command'
>> variable matched the 'this-command' display buffer action alist entry.
>> I could then use
>>
>> (("^\\*vc-diff\\*"
>> nil
>> (this-command . (vc-diff log-view-diff log-view-diff-changeset))
>> (post-command-select-window . t))
>> ("^\\*vc-diff\\*"
>> nil
>> (this-command . vc-root-diff)
>> (post-command-select-window . nil)))
>>
>> Juri, what do you think?
>
> Currently the official way to do this is to use a function predicate
> in the condition part of the display-buffer-alist rule like this:
>
> (add-to-list 'display-buffer-alist
> `(,(lambda (buffer-name _action)
> (and (memq this-command '( vc-diff log-view-diff
> log-view-diff-changeset))
> (string-match-p "^\\*vc-diff\\*" buffer-name)))
> nil
> (post-command-select-window . t)))
>
> (add-to-list 'display-buffer-alist
> `(,(lambda (buffer-name _action)
> (and (eq this-command 'vc-root-diff)
> (string-match-p "^\\*vc-diff\\*" buffer-name)))
> nil
> (post-command-select-window . nil)))
>
> To simplify this, a special 'this-command' item could be supported as well,
> but it should be in the condition part e.g.
>
> (add-to-list 'display-buffer-alist
> '((this-command . vc-root-diff)
> nil
> (post-command-select-window . nil)))
>
> like there is a 'category' item:
>
> (add-to-list 'display-buffer-alist
> '((category . diff)
> nil
> (post-command-select-window . nil)))
>
> But then the corresponding predicate for 'this-command'
> should be added to 'buffer-match-p' when deemed necessary.
After reading your message, I think this would be even more useful than
just for solving my case.
When people match on buffer names, they are usually just matching on all
the buffers produced by a given command or commands. So it might make
for more declarative, readable configuration if they can just use
this-command.
Thank you for the hints about the condition part and buffer-match-p.
I'll implement it.
--
Sean Whitton
Reply sent
to
Sean Whitton <spwhitton <at> spwhitton.name>
:
You have taken responsibility.
(Thu, 01 May 2025 13:00:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Sean Whitton <spwhitton <at> spwhitton.name>
:
bug acknowledged by developer.
(Thu, 01 May 2025 13:00:03 GMT)
Full text and
rfc822 format available.
Message #16 received at 78082-done <at> debbugs.gnu.org (full text, mbox):
Hello,
Implemented and installed this.
--
Sean Whitton
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78082
; Package
emacs
.
(Thu, 01 May 2025 17:46:02 GMT)
Full text and
rfc822 format available.
Message #19 received at 78082 <at> debbugs.gnu.org (full text, mbox):
> Implemented and installed this.
Thanks. I noticed one problem in the documentation:
'this-command' is not a buffer display action alist entry, but
a buffer display condition entry. I'm sorry that this confusion
was caused by the 'category' entry used for both condition and action:
a display-buffer call can provide the action entry 'category',
then the 'category' condition can match it in 'display-buffer-alist'.
So we need to move the description of 'this-command' from
(info "(elisp) Buffer Display Action Alists") to
to (info "(elisp) Buffer List") where it could follow
the 'category'.
Also 'this-command' could be mentioned in
(info "(elisp) Choosing Window") after 'category' as well.
'this-command' is correctly documented in the docstring of
'buffer-match-p', but should not be presented in the docstring
of 'display-buffer' (maybe only as an example?)
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78082
; Package
emacs
.
(Fri, 02 May 2025 04:51:01 GMT)
Full text and
rfc822 format available.
Message #22 received at 78082 <at> debbugs.gnu.org (full text, mbox):
Hello,
On Thu 01 May 2025 at 08:41pm +03, Juri Linkov wrote:
>> Implemented and installed this.
>
> Thanks. I noticed one problem in the documentation:
>
> 'this-command' is not a buffer display action alist entry, but
> a buffer display condition entry. I'm sorry that this confusion
> was caused by the 'category' entry used for both condition and action:
> a display-buffer call can provide the action entry 'category',
> then the 'category' condition can match it in 'display-buffer-alist'.
Ah, I see. Thanks.
> So we need to move the description of 'this-command' from
> (info "(elisp) Buffer Display Action Alists") to
> to (info "(elisp) Buffer List") where it could follow
> the 'category'.
Done.
> Also 'this-command' could be mentioned in
> (info "(elisp) Choosing Window") after 'category' as well.
Yes, added something there.
> 'this-command' is correctly documented in the docstring of
> 'buffer-match-p', but should not be presented in the docstring
> of 'display-buffer' (maybe only as an example?)
display-buffer's docstring doesn't have worked examples in it so adding
one for this doesn't seem right.
I think we have to rely on (info "(elisp) Choosing Window").
--
Sean Whitton
This bug report was last modified 1 day ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.