GNU bug report logs -
#23224
25.0.92; Can xref-find-references work without a "project"?
Previous Next
Reported by: Eli Zaretskii <eliz <at> gnu.org>
Date: Tue, 5 Apr 2016 15:24:01 UTC
Severity: normal
Found in version 25.0.92
Done: Dmitry Gutov <dgutov <at> yandex.ru>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
On 04/05/2016 06:23 PM, Eli Zaretskii wrote:
> I think we shouldn't fail the operation in this case, but instead use
> the directory specified by the user as the single project root.
Sure, fine by me.
> + (let* ((pr (project-current t nil 'noerror))
> + (roots (ignore-errors (project-roots pr)))
> + (eroots (ignore-errors (project-external-roots pr))))
> + ;; If we didn't find any project files in PR, default to PR
> + ;; itself as the project's single root.
> + (if (and (null roots) (null eroots))
> + (setq roots (list (expand-file-name pr))))
> + (append roots eroots))))
I'm going to assume you're teasing here. :)
See the counter-proposal below, it should provide a more universal
benefit along the same line of reasoning. Unless we come upon situations
where we *do* want to abort with an error after asking the user for a
project and not finding a "real" one.
If 'transient' doesn't sound great, alternative suggestions welcome.
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 1251bca..9c8a88c 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -101,7 +101,9 @@ project-find-functions
(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 @@ project-current
(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 @@ project--find-in-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"
This bug report was last modified 9 years and 100 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.