emacs-diffs
[Top][All Lists]
Advanced

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

master 4ca13d9 1/3: project-switch-to-buffer: Don't filter based on defa


From: Dmitry Gutov
Subject: master 4ca13d9 1/3: project-switch-to-buffer: Don't filter based on default-directory
Date: Sun, 5 Jul 2020 17:51:41 -0400 (EDT)

branch: master
commit 4ca13d98c9eb81b9c5e89f77b4012c74a30ab5fd
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>

    project-switch-to-buffer: Don't filter based on default-directory
    
    * lisp/progmodes/project.el (project-switch-to-buffer):
    Don't filter based on default-directory
    (https://lists.gnu.org/archive/html/emacs-devel/2020-07/msg00075.html).
    (project-switch-to-buffer): Ditto.
---
 lisp/progmodes/project.el | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 0a15939..03f7c99 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -800,10 +800,10 @@ Arguments the same as in `compile'."
 ;;;###autoload
 (defun project-switch-to-buffer ()
   "Switch to another buffer that is related to the current project.
-A buffer is related to a project if its `default-directory'
-is inside the directory hierarchy of the project's root."
+A buffer is related to a project if `project-current' returns the
+same (equal) value when called in that buffer."
   (interactive)
-  (let* ((root (project-root (project-current t)))
+  (let* ((pr (project-current t))
          (current-buffer (current-buffer))
          (other-buffer (other-buffer current-buffer))
          (other-name (buffer-name other-buffer))
@@ -811,10 +811,9 @@ is inside the directory hierarchy of the project's root."
           (lambda (buffer)
             ;; BUFFER is an entry (BUF-NAME . BUF-OBJ) of Vbuffer_alist.
             (and (cdr buffer)
-                 (not (eq (cdr buffer) current-buffer))
-                 (when-let ((file (buffer-local-value 'default-directory
-                                                      (cdr buffer))))
-                   (file-in-directory-p file root))))))
+                 (equal pr
+                        (with-current-buffer (cdr buffer)
+                          (project-current)))))))
     (switch-to-buffer
      (read-buffer
       "Switch to buffer: "
@@ -836,13 +835,12 @@ any of the conditions will not be killed."
 
 (defun project--buffer-list (pr)
   "Return the list of all buffers in project PR."
-  (let ((root (project-root pr))
-        bufs)
+  (let (bufs)
     (dolist (buf (buffer-list))
-      (let ((filename (or (buffer-file-name buf)
-                          (buffer-local-value 'default-directory buf))))
-        (when (and filename (file-in-directory-p filename root))
-          (push buf bufs))))
+      (when (equal pr
+                   (with-current-buffer buf
+                     (project-current)))
+        (push buf bufs)))
     (nreverse bufs)))
 
 ;;;###autoload



reply via email to

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