diff options
| author | Sean Whitton | 2025-05-01 20:55:56 +0800 |
|---|---|---|
| committer | Sean Whitton | 2025-05-01 20:56:36 +0800 |
| commit | 343f0c44f35c41b93c66f67da0ddeceb98bbdb93 (patch) | |
| tree | c6956895b0e97c3d99877ee0f9cf9eae7c27457f | |
| parent | 7ae86074231159647d9bcb579dc5ea5a569acf0d (diff) | |
| download | emacs-343f0c44f35c41b93c66f67da0ddeceb98bbdb93.tar.gz emacs-343f0c44f35c41b93c66f67da0ddeceb98bbdb93.zip | |
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.
| -rw-r--r-- | doc/lispref/windows.texi | 8 | ||||
| -rw-r--r-- | etc/NEWS | 5 | ||||
| -rw-r--r-- | lisp/subr.el | 9 | ||||
| -rw-r--r-- | lisp/window.el | 5 |
4 files changed, 27 insertions, 0 deletions
diff --git a/doc/lispref/windows.texi b/doc/lispref/windows.texi index 3a8dffd1af1..82b670fd634 100644 --- a/doc/lispref/windows.texi +++ b/doc/lispref/windows.texi | |||
| @@ -3914,6 +3914,14 @@ List, @code{buffer-match-p}}. Thus, if a Lisp program uses a particular | |||
| 3914 | @var{symbol} as the category when calling @code{display-buffer}, users | 3914 | @var{symbol} as the category when calling @code{display-buffer}, users |
| 3915 | can customize how these buffers will be displayed by including such an | 3915 | can customize how these buffers will be displayed by including such an |
| 3916 | entry in @code{display-buffer-alist}. | 3916 | entry in @code{display-buffer-alist}. |
| 3917 | |||
| 3918 | @vindex this-command@r{, a buffer display action alist entry} | ||
| 3919 | @item this-command | ||
| 3920 | The value is a symbol naming a command or a list of such symbols. It | ||
| 3921 | means the condition when that command, or any of those commands, are now | ||
| 3922 | being executed. You can use this in the condition part of | ||
| 3923 | @code{display-buffer-alist} entries to match buffers displayed during | ||
| 3924 | the execution of particular commands. | ||
| 3917 | @end table | 3925 | @end table |
| 3918 | 3926 | ||
| 3919 | By convention, the entries @code{window-height}, @code{window-width} | 3927 | By convention, the entries @code{window-height}, @code{window-width} |
| @@ -312,6 +312,11 @@ When bound to non-nil, 'window-state-get' will normalize 'uniquify' | |||
| 312 | managed buffer names by removing 'uniquify' prefixes and suffixes. This | 312 | managed buffer names by removing 'uniquify' prefixes and suffixes. This |
| 313 | helps to restore window buffers across Emacs sessions. | 313 | helps to restore window buffers across Emacs sessions. |
| 314 | 314 | ||
| 315 | +++ | ||
| 316 | *** New action alist entry 'this-command' for 'display-buffer'. | ||
| 317 | You can use this in 'display-buffer-alist' to match buffers displayed | ||
| 318 | during the execution of particular commands. | ||
| 319 | |||
| 315 | ** Frames | 320 | ** Frames |
| 316 | 321 | ||
| 317 | +++ | 322 | +++ |
diff --git a/lisp/subr.el b/lisp/subr.el index a5c850ebe5e..975f28e0a17 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -7629,6 +7629,11 @@ CONDITION is either: | |||
| 7629 | the buffer matches if the caller of `display-buffer' provides | 7629 | the buffer matches if the caller of `display-buffer' provides |
| 7630 | `(category . SYMBOL)' in its ACTION argument, and SYMBOL is `eq' | 7630 | `(category . SYMBOL)' in its ACTION argument, and SYMBOL is `eq' |
| 7631 | to the cons-cell's cdr. | 7631 | to the cons-cell's cdr. |
| 7632 | * `this-command': the buffer matches if the command now being executed | ||
| 7633 | is `eq' to or a `memq' of the cons-cell's cdr. | ||
| 7634 | (This case is not useful when calling `buffer-match-p' directly, but | ||
| 7635 | is needed to support the `this-command' buffer display action alist | ||
| 7636 | entry. See `display-buffer'.) | ||
| 7632 | * `not': the cadr is interpreted as a negation of a condition. | 7637 | * `not': the cadr is interpreted as a negation of a condition. |
| 7633 | * `and': the cdr is a list of recursive conditions, that all have | 7638 | * `and': the cdr is a list of recursive conditions, that all have |
| 7634 | to be met. | 7639 | to be met. |
| @@ -7659,6 +7664,10 @@ CONDITION is either: | |||
| 7659 | (if args nil '(nil))))))) | 7664 | (if args nil '(nil))))))) |
| 7660 | (`(category . ,category) | 7665 | (`(category . ,category) |
| 7661 | (eq (alist-get 'category (cdar args)) category)) | 7666 | (eq (alist-get 'category (cdar args)) category)) |
| 7667 | (`(this-command . ,command-or-commands) | ||
| 7668 | (if (listp command-or-commands) | ||
| 7669 | (memq this-command command-or-commands) | ||
| 7670 | (eq this-command command-or-commands))) | ||
| 7662 | (`(major-mode . ,mode) | 7671 | (`(major-mode . ,mode) |
| 7663 | (eq | 7672 | (eq |
| 7664 | (buffer-local-value 'major-mode buffer) | 7673 | (buffer-local-value 'major-mode buffer) |
diff --git a/lisp/window.el b/lisp/window.el index e0e626e9500..afa9a156e46 100644 --- a/lisp/window.el +++ b/lisp/window.el | |||
| @@ -8236,6 +8236,11 @@ Action alist entries are: | |||
| 8236 | `(category . symbol)' in its action argument, then you can match | 8236 | `(category . symbol)' in its action argument, then you can match |
| 8237 | the displayed buffer by using the same category in the condition | 8237 | the displayed buffer by using the same category in the condition |
| 8238 | part of `display-buffer-alist' entries. | 8238 | part of `display-buffer-alist' entries. |
| 8239 | `this-command' -- A symbol naming the command now being executed, or a | ||
| 8240 | list of such symbols to mean the condition when any of those commands | ||
| 8241 | are now being executed. | ||
| 8242 | You can use this in the condition part of `display-buffer-alist' | ||
| 8243 | entries to match buffers displayed by particular commands. | ||
| 8239 | 8244 | ||
| 8240 | The entries `window-height', `window-width', `window-size' and | 8245 | The entries `window-height', `window-width', `window-size' and |
| 8241 | `preserve-size' are applied only when the window used for | 8246 | `preserve-size' are applied only when the window used for |