bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#42386: Acknowledgement ([PATCH] Handle symbols in project-kill-buffe


From: Philip K.
Subject: bug#42386: Acknowledgement ([PATCH] Handle symbols in project-kill-buffers-ignores)
Date: Thu, 16 Jul 2020 10:47:43 +0200

Didn't properly test the last patch, sorry for that. The previous
version would try to call the major mode initialisation as a predicate.

-- 
        Philip K.

>From 01df630f6bfa8939b2df53f31882e3ef9fd7dfa1 Mon Sep 17 00:00:00 2001
From: Philip K <philip@warpmail.net>
Date: Thu, 16 Jul 2020 10:03:35 +0200
Subject: [PATCH] Handle symbols in project-kill-buffers-ignores

---
 lisp/progmodes/project.el | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 67ce3dc7d9..811c18cb56 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -847,10 +847,11 @@ project-kill-buffers-ignores
   '("\\*Help\\*")
   "Conditions for buffers `project-kill-buffers' should not kill.
 Each condition is either a regular expression matching a buffer
-name, or a predicate function that takes a buffer object as
-argument and returns non-nil if it matches.  Buffers that match
-any of the conditions will not be killed."
-  :type '(repeat (choice regexp function))
+name, a predicate function that takes a buffer object as argument
+and returns non-nil if it matches, or a symbol protecting buffers
+of certain major modes.  Buffers that match any of the conditions
+will not be killed."
+  :type '(repeat (choice regexp function symbol))
   :version "28.1"
   :package-version '(project . "0.5.0"))
 
@@ -877,7 +878,12 @@ project-kill-buffers
                (lambda (c)
                  (cond ((stringp c)
                         (string-match-p c (buffer-name buf)))
-                       ((functionp c)
+                       ((and (symbolp c)
+                             (provided-mode-derived-p
+                              (buffer-local-value 'major-mode buf)
+                              c)))
+                       ((and (not (symbolp c))
+                             (functionp c))
                         (funcall c buf))))
                project-kill-buffers-ignores)
         (push buf bufs)))
-- 
2.20.1


reply via email to

[Prev in Thread] Current Thread [Next in Thread]