GNU bug report logs - #69983
Use category for display-buffer-alist

Previous Next

Package: emacs;

Reported by: Juri Linkov <juri <at> linkov.net>

Date: Sun, 24 Mar 2024 17:22:01 UTC

Severity: normal

Fixed in version 30.0.50

Done: Juri Linkov <juri <at> linkov.net>

Bug is archived. No further changes may be made.

Full log


Message #20 received at 69983 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: martin rudalics <rudalics <at> gmx.at>
Cc: 69983 <at> debbugs.gnu.org
Subject: Re: bug#69983: Use category for display-buffer-alist
Date: Thu, 28 Mar 2024 09:47:37 +0200
[Message part 1 (text/plain, inline)]
>> Would this imply a change in 'buffer-match-p'?
>
> Indeed, here it a simple change in 'buffer-match-p'
> that will support this case:

Ok, here is a complete patch with documentation:

[buffer-match-category.patch (text/x-diff, inline)]
diff --git a/doc/lispref/windows.texi b/doc/lispref/windows.texi
index eef05d94fdb..54e563eeb58 100644
--- a/doc/lispref/windows.texi
+++ b/doc/lispref/windows.texi
@@ -2638,6 +2638,23 @@ Choosing Window
 @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.
+
+When the caller of @code{display-buffer} passes a category as a symbol
+in its @var{action} argument, then @code{display-buffer-alist} can use it
+to match a whole category of buffers with different buffer 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
 @end defopt
 
 @defopt display-buffer-base-action
diff --git a/lisp/subr.el b/lisp/subr.el
index 90dbfc75d52..9319acefbf1 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -7476,6 +7474,8 @@ buffer-match-p
   * `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 if the caller of `display-buffer'
+    provided `(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.
@@ -7504,6 +7504,8 @@ buffer-match-p
                               (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)

This bug report was last modified 1 year and 82 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.