summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Gutov <dgutov@yandex.ru>2022-11-24 04:33:01 +0200
committerDmitry Gutov <dgutov@yandex.ru>2022-11-24 04:33:14 +0200
commitb37604c263e4813dc2a8b80e4e9131a3961c4f3e (patch)
tree6caf2ca798dc2c56426763c266420cbf87a33b5f
parentf8b410f4a16053d38aca1e4f8ac4bf426709f4ef (diff)
downloademacs-b37604c263e4813dc2a8b80e4e9131a3961c4f3e.tar.gz
project-switch-project: Use a different fix for bug#58784
* lisp/progmodes/project.el (project-current-inhibit-prompt): Rename to 'project-current-directory-override', and make it a string value. (project-current): Refer to it. (project-switch-project): Bind it. Drop the temp buffer (bug#58784).
-rw-r--r--lisp/progmodes/project.el21
1 files changed, 13 insertions, 8 deletions
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index c7b2c386ccd..0e08dae154b 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -175,8 +175,14 @@ function; the only practical limitation is to use values that
`cl-defmethod' can dispatch on, like a cons cell, or a list, or a
CL struct.")
-(defvar project-current-inhibit-prompt nil
- "Non-nil to skip prompting the user in `project-current'.")
+(define-obsolete-variable-alias
+ 'project-current-inhibit-prompt
+ 'project-current-directory-override
+ "29.1")
+
+(defvar project-current-directory-override nil
+ "Value to use instead of `default-directory' when detecting the project.
+When it is non-nil, `project-current' will always skip prompting too.")
;;;###autoload
(defun project-current (&optional maybe-prompt directory)
@@ -195,11 +201,12 @@ ignored (per `project-ignores').
See the doc string of `project-find-functions' for the general form
of the project instance object."
- (unless directory (setq directory default-directory))
+ (unless directory (setq directory (or project-current-directory-override
+ default-directory)))
(let ((pr (project--find-in-directory directory)))
(cond
(pr)
- ((unless project-current-inhibit-prompt
+ ((unless project-current-directory-override
maybe-prompt)
(setq directory (project-prompt-project-dir)
pr (project--find-in-directory directory))))
@@ -1698,10 +1705,8 @@ to directory DIR."
(let ((command (if (symbolp project-switch-commands)
project-switch-commands
(project--switch-project-command))))
- (with-temp-buffer
- (let ((default-directory dir)
- (project-current-inhibit-prompt t))
- (call-interactively command)))))
+ (let ((project-current-directory-override dir))
+ (call-interactively command))))
(provide 'project)
;;; project.el ends here