]> git.eshelyaron.com Git - emacs.git/commitdiff
New this-command buffer display action alist entry
authorSean Whitton <spwhitton@spwhitton.name>
Thu, 1 May 2025 12:55:56 +0000 (20:55 +0800)
committerEshel Yaron <me@eshelyaron.com>
Sat, 10 May 2025 06:53:36 +0000 (08:53 +0200)
* 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.

(cherry picked from commit 343f0c44f35c41b93c66f67da0ddeceb98bbdb93)

doc/lispref/windows.texi
lisp/subr.el
lisp/window.el

index 417c323be6bcef554e0c881509f0d12ce0db2864..96b97d0cffbdfc62a040aa4d5c3d79a7b8061cbf 100644 (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}
index 47e020d4337e426255b8b5db575a0cc4a103d582..94c337559e5e330565f2198d3bb7a827a2b8a402 100644 (file)
@@ -7086,6 +7086,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.
@@ -7116,6 +7121,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)
index 052547de7df79b9c5ff86c1f280b2c1966f77464..746133005be1ba7a7cb4d49442d3a154f74e3a81 100644 (file)
@@ -8184,6 +8184,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