all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: martin rudalics <rudalics@gmx.at>
Cc: 69983@debbugs.gnu.org
Subject: bug#69983: Use category for display-buffer-alist
Date: Thu, 28 Mar 2024 09:47:37 +0200	[thread overview]
Message-ID: <86cyrevniu.fsf@mail.linkov.net> (raw)
In-Reply-To: <86bk7040vo.fsf@mail.linkov.net> (Juri Linkov's message of "Wed,  27 Mar 2024 09:15:19 +0200")

[-- Attachment #1: Type: text/plain, Size: 188 bytes --]

>> 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:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: buffer-match-category.patch --]
[-- Type: text/x-diff, Size: 1967 bytes --]

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)

  reply	other threads:[~2024-03-28  7:47 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-24 17:19 bug#69983: Use category for display-buffer-alist Juri Linkov
2024-03-25  9:41 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-25 17:12   ` Juri Linkov
2024-03-26  9:55     ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-27  7:15       ` Juri Linkov
2024-03-28  7:47         ` Juri Linkov [this message]
2024-03-28  8:23           ` Eli Zaretskii
2024-03-28 17:46             ` Juri Linkov
2024-03-28  9:18           ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-28 17:50             ` Juri Linkov
2024-03-29  8:43               ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-29 16:30                 ` Juri Linkov
2024-03-30  9:36                   ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-30 18:22                     ` Juri Linkov
2024-04-02 16:52                       ` Juri Linkov
2024-04-04  6:16   ` Juri Linkov
2024-04-05 16:47     ` Juri Linkov
2024-04-06 18:42       ` Juri Linkov
2024-04-07  8:22         ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-09  6:30           ` Juri Linkov
2024-04-09  7:09             ` Eli Zaretskii
2024-04-09 16:34               ` Juri Linkov
2024-04-09 18:28                 ` Eli Zaretskii
2024-04-10  6:45                   ` Juri Linkov
2024-04-10  8:47                     ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-10 11:07                     ` Eli Zaretskii
2024-04-10 17:49                       ` Juri Linkov
2024-04-10 18:13                         ` Eli Zaretskii
2024-04-11  6:31                           ` Juri Linkov
2024-04-11  7:40                             ` Eli Zaretskii
2024-04-12  6:37                               ` Juri Linkov
2024-04-12  7:05                                 ` Eli Zaretskii
2024-04-12 16:50                                   ` Juri Linkov
2024-04-12 18:27                                     ` Eli Zaretskii
2024-04-13 18:49                                       ` Juri Linkov
2024-04-13 19:03                                         ` Eli Zaretskii
2024-04-14 16:04                                           ` Juri Linkov
2024-04-18 14:30                                             ` Eli Zaretskii
2024-04-18 17:16                                               ` Juri Linkov
2024-04-18 17:56                                                 ` Eli Zaretskii
2024-04-19  6:24                                                   ` Juri Linkov
2024-04-19  6:28                                                     ` Juri Linkov
2024-04-19  7:19                                                       ` Eli Zaretskii
2024-04-19 16:17                                                       ` Juri Linkov
2024-04-20 12:08                                                         ` Eli Zaretskii
2024-04-21  6:52                                                           ` Juri Linkov
2024-04-21  9:13                                                             ` Eli Zaretskii
2024-04-22  6:50                                                               ` Juri Linkov
2024-04-19  7:19                                                     ` Eli Zaretskii
2024-04-11  9:16                       ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-11 11:03                         ` Eli Zaretskii
2024-04-24 16:46     ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86cyrevniu.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=69983@debbugs.gnu.org \
    --cc=rudalics@gmx.at \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.