summaryrefslogtreecommitdiff
path: root/lisp/progmodes/project.el
diff options
context:
space:
mode:
authorDmitry Gutov <dgutov@yandex.ru>2016-04-07 02:02:13 +0300
committerDmitry Gutov <dgutov@yandex.ru>2016-04-07 02:02:26 +0300
commit20686f7a6430ef37f17b3866f14e7dc3095c1524 (patch)
tree00420635465970c05438c3470f516048ad777a6b /lisp/progmodes/project.el
parent0d7aad1b30de7e9deb8b3c7011d9b679e538371c (diff)
downloademacs-20686f7a6430ef37f17b3866f14e7dc3095c1524.tar.gz
Add a `transient' project type
* lisp/progmodes/project.el (project-roots): Implement for the `transient' project type (bug#23224). (project-current): Instead of signaling an error, return a transient project instance rooted in the chosen directory.
Diffstat (limited to 'lisp/progmodes/project.el')
-rw-r--r--lisp/progmodes/project.el10
1 files changed, 8 insertions, 2 deletions
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 1251bca2491..9c8a88c80fc 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -101,7 +101,9 @@ that it is not applicable, or a project instance.")
(defun project-current (&optional maybe-prompt dir)
"Return the project instance in DIR or `default-directory'.
When no project found in DIR, and MAYBE-PROMPT is non-nil, ask
-the user for a different directory to look in."
+the user for a different directory to look in. If that directory
+is not a part of a detectable project either, return a
+`transient' project instance rooted in it."
(unless dir (setq dir default-directory))
(let ((pr (project--find-in-directory dir)))
(cond
@@ -110,7 +112,8 @@ the user for a different directory to look in."
(setq dir (read-directory-name "Choose the project directory: " dir nil t)
pr (project--find-in-directory dir))
(unless pr
- (user-error "No project found in `%s'" dir))))
+ (message "Using '%s' as a transient project root" dir)
+ (setq pr (cons 'transient dir)))))
pr))
(defun project--find-in-directory (dir)
@@ -182,6 +185,9 @@ to find the list of ignores for each directory."
(t
(complete-with-action action all-files string pred))))))
+(cl-defmethod project-roots ((project (head transient)))
+ (list (cdr project)))
+
(defgroup project-vc nil
"Project implementation using the VC package."
:version "25.1"