[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
scratch/project-switching a4f22ab 1/2: Teach project-current to inhibit
From: |
Dmitry Gutov |
Subject: |
scratch/project-switching a4f22ab 1/2: Teach project-current to inhibit the prompt |
Date: |
Mon, 18 May 2020 18:28:17 -0400 (EDT) |
branch: scratch/project-switching
commit a4f22ab4abac304b4ec476714ca98c76a3427d56
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>
Teach project-current to inhibit the prompt
* lisp/progmodes/project.el:
(project-current-inhibit-prompt): New variable.
(project-current, project-switch-project): Use it.
---
lisp/progmodes/project.el | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 06e2730..cb254e8 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -96,6 +96,9 @@ Each functions on this hook is called in turn with one
argument (the directory) and should return either nil to mean
that it is not applicable, or a project instance.")
+(defvar project-current-inhibit-prompt nil
+ "Non-nil to skip prompting the user in `project-current'.")
+
;;;###autoload
(defun project-current (&optional maybe-prompt dir)
"Return the project instance in DIR or `default-directory'.
@@ -105,7 +108,8 @@ the user for a different project to look in."
(let ((pr (project--find-in-directory dir)))
(cond
(pr)
- (maybe-prompt
+ ((unless project-current-inhibit-prompt
+ maybe-prompt)
(setq dir (project-prompt-project-dir)
pr (project--find-in-directory dir))))
(if pr
@@ -764,7 +768,8 @@ and presented in a dispatch menu."
(setq choice (read-key-sequence (project--keymap-prompt))))
(if (equal choice (kbd "C-g"))
(message "Quit")
- (let ((default-directory dir))
+ (let ((default-directory dir)
+ (project-current-inhibit-prompt t))
(call-interactively
(nth 2 (assoc choice project-switch-commands)))))))