emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[nongnu] elpa/projectile f5a2a3ab26 2/2: [Fix #1804] Make it possible to


From: ELPA Syncer
Subject: [nongnu] elpa/projectile f5a2a3ab26 2/2: [Fix #1804] Make it possible to ignore special project buffers
Date: Thu, 27 Oct 2022 11:59:40 -0400 (EDT)

branch: elpa/projectile
commit f5a2a3ab268b905c796de255e04790e6e69a61ab
Author: Miles Liu <miles@bung.cc>
Commit: Bozhidar Batsov <bozhidar@batsov.dev>

    [Fix #1804] Make it possible to ignore special project buffers
---
 CHANGELOG.md            |  1 +
 projectile.el           | 31 +++++++++++++++++++++++++++++++
 test/projectile-test.el | 14 ++++++++++++++
 3 files changed, 46 insertions(+)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 11d16b0ce9..086e48553c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,7 @@
 ### New features
 
 * [#1591](https://github.com/bbatsov/projectile/issues/1591): Add `project.el` 
integration that will make Projectile the default provider for project lookup.
+* [#1799](https://github.com/bbatsov/projectile/pull/1799): Make it possible 
to ignore special project buffers.
 
 ### Bug fixed
 
diff --git a/projectile.el b/projectile.el
index 8e8b34a2eb..9041cd9ad3 100644
--- a/projectile.el
+++ b/projectile.el
@@ -822,6 +822,27 @@ If the value is nil, there is no limit to the opend 
buffers count."
   :type 'integer
   :package-version '(projectile . "2.2.0"))
 
+(defcustom projectile-ignore-special-project-buffers t
+  "When t ignore special project buffers.
+
+See `projectile-ignored-project-buffers'."
+  :group 'projectile
+  :type 'boolean
+  :package-version '(projectile . "2.7.0"))
+
+(defcustom projectile-ignored-project-buffers
+  '(
+    "*scratch*"              ; Lisp Interaction Buffer
+    "*lsp-log*"              ; LSP Mode Troubleshooting Buffer
+    )
+  "A list of buffers considered that should never be killed or
+associated with any specific project.
+
+See `projectile-ignore-special-project-buffers'."
+  :group 'projectile
+  :type '(repeat string)
+  :package-version '(projectile . "2.7.0"))
+
 (defvar projectile-project-test-suffix nil
   "Use this variable to override the current project's test-suffix property.
 It takes precedence over the test-suffix for the project type when set.
@@ -1641,12 +1662,22 @@ If PROJECT is not specified the command acts on the 
current project."
                        default-directory)))
       (and (not (string-prefix-p " " (buffer-name buffer)))
            (not (projectile-ignored-buffer-p buffer))
+           (not (projectile-ignored-project-buffers-p buffer))
            directory
            (string-equal (file-remote-p directory)
                          (file-remote-p project-root))
            (not (string-match-p "^http\\(s\\)?://" directory))
            (string-prefix-p project-root (file-truename directory) (eq 
system-type 'windows-nt))))))
 
+(defun projectile-ignored-project-buffers-p (buffer)
+  "Check if BUFFER should never associated with any specific project"
+  (when projectile-ignore-special-project-buffers
+    (with-current-buffer buffer
+      (cl-some
+       (lambda (name)
+         (string-match-p name (buffer-name)))
+       projectile-ignored-project-buffers))))
+
 (defun projectile-ignored-buffer-p (buffer)
   "Check if BUFFER should be ignored.
 
diff --git a/test/projectile-test.el b/test/projectile-test.el
index 875b01ec52..cf445a10f3 100644
--- a/test/projectile-test.el
+++ b/test/projectile-test.el
@@ -1038,6 +1038,20 @@ Just delegates OPERATION and ARGS for all operations 
except for`shell-command`'.
 
           (expect (current-buffer) :to-be (get-file-buffer 
"project/file")))))))
 
+(describe "projectile-ignored-project-buffers-p"
+  (it "checks if buffer should never associated with any specific project"
+    (let ((projectile-ignore-special-project-buffers t)
+          (projectile-ignored-project-buffers '("*nrepl messages*" 
"*something*")))
+      (expect (projectile-ignored-project-buffers-p (get-buffer-create "*nrepl 
messages*")) :to-be-truthy)
+      (expect (projectile-ignored-project-buffers-p (get-buffer-create 
"*something*")) :to-be-truthy)
+      (expect (projectile-ignored-project-buffers-p (get-buffer-create 
"test")) :not :to-be-truthy)))
+  (it "check if buffer should not ignored when not enabled"
+    (let ((projectile-ignore-special-project-buffers nil)
+          (projectile-ignored-project-buffers '("*nrepl messages*" 
"*something*")))
+      (expect (projectile-ignored-project-buffers-p (get-buffer-create "*nrepl 
messages*")) :not :to-be-truthy)
+      (expect (projectile-ignored-project-buffers-p (get-buffer-create 
"*something*")) :not :to-be-truthy)
+      (expect (projectile-ignored-project-buffers-p (get-buffer-create 
"test")) :not :to-be-truthy))))
+
 (describe "projectile-ignored-buffer-p"
   (it "checks if buffer should be ignored"
     (let ((projectile-globally-ignored-buffers '("*nrepl messages*" 
"*something*")))



reply via email to

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