[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
master 4ca13d9 1/3: project-switch-to-buffer: Don't filter based on default-directory
Sun, 5 Jul 2020 17:51:41 -0400 (EDT)
Author: Dmitry Gutov <email@example.com>
Commit: Dmitry Gutov <firstname.lastname@example.org>
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
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
@@ -800,10 +800,10 @@ Arguments the same as in `compile'."
(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."
- (let* ((root (project-root (project-current t)))
+ (let* ((pr (project-current t))
(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."
;; 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)
"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))
+ (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
+ (push buf bufs)))