branch: externals/beframe
commit 6f8b1fb832dc520e8b7a991d329ed48cb71ee667
Author: Protesilaos Stavrou <i...@protesilaos.com>
Commit: Protesilaos Stavrou <i...@protesilaos.com>

    Make beframe-global-buffers also accept a major mode symbol
---
 README.org | 18 ++++++++----------
 beframe.el | 33 +++++++++++++++++++++------------
 2 files changed, 29 insertions(+), 22 deletions(-)

diff --git a/README.org b/README.org
index 67a9f6859b..3248b02b65 100644
--- a/README.org
+++ b/README.org
@@ -82,16 +82,14 @@ filters the list.
 
 #+vindex: beframe-global-buffers
 The user option ~beframe-global-buffers~ contains a list of regular
-expressions that are matched against buffers names. The matching
-buffers are never beframed and are available in all frames. The
-default value contains the buffers =*scratch*=, =*Messages*=, and
-=*Backtrace*= (more preciselly, it matches the regular expressions
-=\\*scratch\\*=, =\\*Messages\\*= =\\*Backtrace\\*=). If the value is
-~nil~, no buffer enjoys such special treatment: they all follow the
-beframing scheme of remaining associated with the frame that opened
-them. [ The ~beframe-global-buffers~ is revised as part of
-{{{development-version}}} to take a list of regular expressions
-instead of literal strings. ]
+expressions or major mode symbols that are matched against buffers.
+The matching buffers are never beframed and are available in all
+frames. The default value contains the buffers =*scratch*=,
+=*Messages*=, and =*Backtrace*= (more preciselly, it matches the
+regular expressions =\\*scratch\\*=, =\\*Messages\\*=
+=\\*Backtrace\\*=). If the value is ~nil~, no buffer enjoys such
+special treatment: they all follow the beframing scheme of remaining
+associated with the frame that opened them.
 
 #+vindex: beframe-create-frame-scratch-buffer
 The user option ~beframe-create-frame-scratch-buffer~ allows
diff --git a/beframe.el b/beframe.el
index 3826f99c55..b0d56a7da6 100644
--- a/beframe.el
+++ b/beframe.el
@@ -40,26 +40,31 @@
   "Isolate buffers per frame."
   :group 'frames)
 
-(defcustom beframe-global-buffers '("\\*scratch\\*" "\\*Messages\\*" 
"\\*Backtrace\\*")
-  "List of regular expressions to match buffer names.
-The matching buffers are always shown in the `beframe-buffer-menu' or
-buffer selection prompts when `beframe-mode' is enabled.  They do
-not need to be open inside the current frame and to thus become
-associated with it (the way other buffers are normally beframed).
+(defcustom beframe-global-buffers
+  '("\\*scratch\\*" "\\*Messages\\*" "\\*Backtrace\\*")
+  "List of regular expressions or major-mode symbols to match global buffers.
+
+Global buffers are those which are not associated only with the frame
+that displayed them: they are available to all frames through
+`beframe-buffer-menu' or standard buffer selection prompts when
+`beframe-mode' is enabled.
 
 When the value is nil, no buffer get this special treatment: they
 all follow the beframing scheme of remaining associated with the
 frame that opened them.
 
 Also see commands such as `beframe-assume-frame-buffers' and
-`beframe-unassume-frame-buffers' to add/remove buffers from a
-frame's buffer list ad-hoc.  The full list of commands:
+`beframe-unassume-frame-buffers' (and their variants) to add/remove
+buffers from a frame's buffer list ad-hoc.  The full list of commands:
 
 \\{beframe-prefix-map}"
   :group 'beframe
   :package-version '(beframe . "1.1.0")
-  :type '(choice (repeat :tag "List of regular expressions to match buffer 
names" string)
-                 (const :tag "No global buffers" nil)))
+  :type '(choice
+          (repeat (choice
+                   (string :tag "Regular expression to match buffer names")
+                   (symbol :tag "Symbol to match a buffer's major mode" :value 
"")))
+          (const :tag "No global buffers" nil)))
 
 (defcustom beframe-create-frame-scratch-buffer t
   "Create a frame-specific scratch buffer for new frames.
@@ -143,10 +148,14 @@ minus all the internal buffers."
 (defun beframe--global-buffers ()
   "Return list of `beframe-global-buffers' buffer objects."
   (mapcan
-   (lambda (regexp)
+   (lambda (regexp-or-symbol)
      (seq-filter
       (lambda (buffer)
-        (when (string-match-p regexp (buffer-name buffer))
+        (when (or (and (stringp regexp-or-symbol)
+                       (string-match-p regexp-or-symbol (buffer-name buffer)))
+                  (and (symbolp regexp-or-symbol)
+                       (with-current-buffer buffer
+                         (derived-mode-p regexp-or-symbol))))
           buffer))
       (beframe--public-buffers)))
    beframe-global-buffers))

Reply via email to