1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-30 12:21:25 -08:00

New this-command buffer display action alist entry

* lisp/subr.el (buffer-match-p): New this-command cons cell
condition to implement new this-command buffer display action
alist entry (bug#78082).
* lisp/window.el (display-buffer):
* doc/lispref/windows.texi (Buffer Display Action Alists):
* etc/NEWS: Document the new buffer display action alist entry.
This commit is contained in:
Sean Whitton 2025-05-01 20:55:56 +08:00
parent 7ae8607423
commit 343f0c44f3
4 changed files with 27 additions and 0 deletions

View file

@ -3914,6 +3914,14 @@ List, @code{buffer-match-p}}. Thus, if a Lisp program uses a particular
@var{symbol} as the category when calling @code{display-buffer}, users
can customize how these buffers will be displayed by including such an
entry in @code{display-buffer-alist}.
@vindex this-command@r{, a buffer display action alist entry}
@item this-command
The value is a symbol naming a command or a list of such symbols. It
means the condition when that command, or any of those commands, are now
being executed. You can use this in the condition part of
@code{display-buffer-alist} entries to match buffers displayed during
the execution of particular commands.
@end table
By convention, the entries @code{window-height}, @code{window-width}

View file

@ -312,6 +312,11 @@ When bound to non-nil, 'window-state-get' will normalize 'uniquify'
managed buffer names by removing 'uniquify' prefixes and suffixes. This
helps to restore window buffers across Emacs sessions.
+++
*** New action alist entry 'this-command' for 'display-buffer'.
You can use this in 'display-buffer-alist' to match buffers displayed
during the execution of particular commands.
** Frames
+++

View file

@ -7629,6 +7629,11 @@ CONDITION is either:
the buffer matches if the caller of `display-buffer' provides
`(category . SYMBOL)' in its ACTION argument, and SYMBOL is `eq'
to the cons-cell's cdr.
* `this-command': the buffer matches if the command now being executed
is `eq' to or a `memq' of the cons-cell's cdr.
(This case is not useful when calling `buffer-match-p' directly, but
is needed to support the `this-command' buffer display action alist
entry. See `display-buffer'.)
* `not': the cadr is interpreted as a negation of a condition.
* `and': the cdr is a list of recursive conditions, that all have
to be met.
@ -7659,6 +7664,10 @@ CONDITION is either:
(if args nil '(nil)))))))
(`(category . ,category)
(eq (alist-get 'category (cdar args)) category))
(`(this-command . ,command-or-commands)
(if (listp command-or-commands)
(memq this-command command-or-commands)
(eq this-command command-or-commands)))
(`(major-mode . ,mode)
(eq
(buffer-local-value 'major-mode buffer)

View file

@ -8236,6 +8236,11 @@ Action alist entries are:
`(category . symbol)' in its action argument, then you can match
the displayed buffer by using the same category in the condition
part of `display-buffer-alist' entries.
`this-command' -- A symbol naming the command now being executed, or a
list of such symbols to mean the condition when any of those commands
are now being executed.
You can use this in the condition part of `display-buffer-alist'
entries to match buffers displayed by particular commands.
The entries `window-height', `window-width', `window-size' and
`preserve-size' are applied only when the window used for