* doc/lispref/windows.texi (Choosing Window): Provide an example
of using '(category . comint)' in the condition of 'display-buffer-alist'
and in the action of 'display-buffer'.
(Buffer Display Action Alists): Add a new action alist entry 'category'.
* lisp/subr.el (buffer-match-p): Add a new condition 'category'.
* lisp/window.el (display-buffer): Document a new action alist entry
'category'.
(cherry picked from commit
9af533dc751e5220a545ca7e15456992cbbfab98)
@code{buffer-match-p} could fail to report a match if
@code{display-buffer} is called before the major mode of the buffer is
set.
+
+If the caller of @code{display-buffer} passes a category as a symbol
+in its @var{action} argument, then you can use the same category in
+@code{display-buffer-alist} to match buffers with different names,
+for example:
+
+@example
+@group
+(setopt
+ display-buffer-alist
+ (cons '((category . comint) (display-buffer-same-window))
+ display-buffer-alist))
+
+(display-buffer (get-buffer-create "*my-shell*")
+ '(nil (category . comint)))
+@end group
+@end example
+
+Regardless of the displayed buffer's name the caller defines a category
+as a symbol @code{comint}. Then @code{display-buffer-alist} matches
+this category for all buffers displayed with the same category.
+This avoids the need to construct a complex regular expression
+that matches a buffer name.
@end defopt
@defopt display-buffer-base-action
@code{pop-to-buffer} is deselected, and the window that was selected
before calling this function will remain selected regardless of which
windows were selected afterwards within this command.
+
+@vindex category@r{, a buffer display action alist entry}
+@item category
+If the caller of @code{display-buffer} passes an alist entry
+@code{(category . symbol)} in its @var{action} argument, then you can
+match the displayed buffer by using the same category in the condition
+part of @code{display-buffer-alist} entries.
@end table
By convention, the entries @code{window-height}, @code{window-width}
** Windows
++++
+*** New action alist entry 'category' for 'display-buffer'.
+If the caller of 'display-buffer' passes '(category . symbol)'
+in its 'action' argument, you can match the displayed buffer
+by adding '(category . symbol)' to the condition part of
+'display-buffer-alist' entries.
+
++++
*** New action alist entry 'post-command-select-window' for 'display-buffer'.
It specifies whether the window of the displayed buffer should be
selected or deselected at the end of executing the current command.
* `major-mode': the buffer matches if the buffer's major mode
is eq to the cons-cell's cdr. Prefer using `derived-mode'
instead when both can work.
+ * `category': the buffer matches a category as a symbol if
+ the caller of `display-buffer' provides `(category . symbol)'
+ in its action argument.
* `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.
(push condition buffer-match-p--past-warnings))
(apply condition buffer-or-name
(if args nil '(nil)))))))
+ (`(category . ,category)
+ (eq (alist-get 'category (cdar args)) category))
(`(major-mode . ,mode)
(eq
(buffer-local-value 'major-mode buffer)
window that was selected before calling this function will remain
selected regardless of which windows were selected afterwards within
this command.
+ `category' -- If the caller of `display-buffer' passes an alist entry
+ `(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.
The entries `window-height', `window-width', `window-size' and
`preserve-size' are applied only when the window used for