]> git.eshelyaron.com Git - emacs.git/commitdiff
Teach project-current to inhibit the prompt
authorDmitry Gutov <dgutov@yandex.ru>
Mon, 18 May 2020 22:00:43 +0000 (01:00 +0300)
committerSimen Heggestøyl <simenheg@gmail.com>
Tue, 26 May 2020 15:41:45 +0000 (17:41 +0200)
* lisp/progmodes/project.el:
(project-current-inhibit-prompt): New variable.
(project-current, project-switch-project): Use it.

lisp/progmodes/project.el

index 956a4b8a345318d144af5a055ea87d0057dad99a..132d172a08e97f6f2289c8a651f0727703557f04 100644 (file)
@@ -101,6 +101,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'.
@@ -110,7 +113,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
@@ -829,7 +833,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)))))))