[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 4f3dae2b0d5: project--read-project-buffer: Fixup default-director
From: |
Dmitry Gutov |
Subject: |
master 4f3dae2b0d5: project--read-project-buffer: Fixup default-directory if needed |
Date: |
Fri, 21 Apr 2023 19:27:49 -0400 (EDT) |
branch: master
commit 4f3dae2b0d5fc43e5e2effa6d36544b6de2a43d8
Author: Dmitry Gutov <dmitry@gutov.dev>
Commit: Dmitry Gutov <dmitry@gutov.dev>
project--read-project-buffer: Fixup default-directory if needed
* lisp/progmodes/project.el (project--read-project-buffer):
Make sure that when the read buffer is new, its default-directory
belongs to the project (bug#62974).
---
lisp/progmodes/project.el | 24 +++++++++++++++++-------
1 file changed, 17 insertions(+), 7 deletions(-)
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 04c67710d71..7c51778d5d4 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -1327,13 +1327,23 @@ general form of conditions."
(and (memq (cdr buffer) buffers)
(not
(project--buffer-check
- (cdr buffer) project-ignore-buffer-conditions))))))
- (read-buffer
- "Switch to buffer: "
- (when (funcall predicate (cons other-name other-buffer))
- other-name)
- nil
- predicate)))
+ (cdr buffer) project-ignore-buffer-conditions)))))
+ (buffer (read-buffer
+ "Switch to buffer: "
+ (when (funcall predicate (cons other-name other-buffer))
+ other-name)
+ nil
+ predicate)))
+ ;; XXX: This check hardcodes the default buffer-belonging relation
+ ;; which `project-buffers' is allowed to override. Straighten
+ ;; this up sometime later. Or not. Since we can add a method
+ ;; `project-contains-buffer-p', but a separate method to create a
+ ;; new project buffer seems too much.
+ (if (or (get-buffer buffer)
+ (file-in-directory-p default-directory (project-root pr)))
+ buffer
+ (let ((default-directory (project-root pr)))
+ (get-buffer-create buffer)))))
;;;###autoload
(defun project-switch-to-buffer (buffer-or-name)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 4f3dae2b0d5: project--read-project-buffer: Fixup default-directory if needed,
Dmitry Gutov <=