emacs-diffs
[Top][All Lists]
Advanced

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

master 1a3bad431d 3/3: Update project-kill-buffer-conditions to match bu


From: Philip Kaludercic
Subject: master 1a3bad431d 3/3: Update project-kill-buffer-conditions to match buffer-match-p
Date: Fri, 15 Apr 2022 04:07:27 -0400 (EDT)

branch: master
commit 1a3bad431d841e52a61e5f1f09b4ebe7fbbd70da
Author: Philip Kaludercic <philipk@posteo.net>
Commit: Philip Kaludercic <philipk@posteo.net>

    Update project-kill-buffer-conditions to match buffer-match-p
    
    * project.el (project-kill-buffer-conditions): Document the
    deprecation of the use of derived-mode
    (project--buffer-check): Have `major-mode' behave like `derived-mode'
    did previously, and issue a warning of `derived-mode' is used.
---
 lisp/progmodes/project.el | 40 ++++++++++++++++++++++++----------------
 1 file changed, 24 insertions(+), 16 deletions(-)

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index daaf86f327..ac6aa0ced2 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -1201,18 +1201,22 @@ displayed."
   (display-buffer-other-frame buffer-or-name))
 
 (defcustom project-kill-buffer-conditions
-  '(buffer-file-name    ; All file-visiting buffers are included.
+  `(buffer-file-name    ; All file-visiting buffers are included.
     ;; Most of the temp buffers in the background:
-    (major-mode . fundamental-mode)
+    ,(lambda (buf)
+       (not (eq (buffer-local-value 'major-mode buf)
+                'fundamental-mode)))
     ;; non-text buffer such as xref, occur, vc, log, ...
-    (and (derived-mode . special-mode)
-         (not (major-mode . help-mode)))
-    (derived-mode . compilation-mode)
-    (derived-mode . dired-mode)
-    (derived-mode . diff-mode)
-    (derived-mode . comint-mode)
-    (derived-mode . eshell-mode)
-    (derived-mode . change-log-mode))
+    (and (major-mode . special-mode)
+         ,(lambda (buf)
+            (not (eq (buffer-local-value 'major-mode buf)
+                     'help-mode))))
+    (major-mode . compilation-mode)
+    (major-mode . dired-mode)
+    (major-mode . diff-mode)
+    (major-mode . comint-mode)
+    (major-mode . eshell-mode)
+    (major-mode . change-log-mode))
   "List of conditions to kill buffers related to a project.
 This list is used by `project-kill-buffers'.
 Each condition is either:
@@ -1222,10 +1226,11 @@ Each condition is either:
 - a cons-cell, where the car describes how to interpret the cdr.
   The car can be one of the following:
   * `major-mode': the buffer is killed if the buffer's major
-    mode is eq to the cons-cell's cdr
-  * `derived-mode': the buffer is killed if the buffer's major
     mode is derived from the major mode denoted by the cons-cell's
-    cdr
+    cdr.
+  * `derived-mode': the buffer is killed if the buffer's major
+    mode is eq to the cons-cell's cdr (this is deprecated and will
+    result in a warning if used).
   * `not': the cdr is interpreted as a negation of a condition.
   * `and': the cdr is a list of recursive conditions, that all have
     to be met.
@@ -1285,10 +1290,13 @@ form of CONDITIONS."
               (string-match-p c (buffer-name buf)))
              ((symbolp c)
               (funcall c buf))
-             ((eq (car-safe c) 'major-mode)
-              (eq (buffer-local-value 'major-mode buf)
-                  (cdr c)))
              ((eq (car-safe c) 'derived-mode)
+              (warn "The use of `derived-mode' in \
+`project--buffer-check' is deprecated.")
+              (provided-mode-derived-p
+               (buffer-local-value 'major-mode buf)
+               (cdr c)))
+             ((eq (car-safe c) 'major-mode)
               (provided-mode-derived-p
                (buffer-local-value 'major-mode buf)
                (cdr c)))



reply via email to

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