unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dgutov@yandex.ru>
To: Eli Zaretskii <eliz@gnu.org>, 23224@debbugs.gnu.org
Subject: bug#23224: 25.0.92; Can xref-find-references work without a "project"?
Date: Wed, 6 Apr 2016 03:18:09 +0300	[thread overview]
Message-ID: <e73a9694-63a2-3acf-b53a-c1d90fc9a8e1@yandex.ru> (raw)
In-Reply-To: <83oa9om65f.fsf@gnu.org>

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"






  parent reply	other threads:[~2016-04-06  0:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-05 15:23 bug#23224: 25.0.92; Can xref-find-references work without a "project"? Eli Zaretskii
2016-04-05 17:22 ` John Wiegley
2016-04-06  0:18 ` Dmitry Gutov [this message]
2016-04-06 17:08   ` Eli Zaretskii
2016-04-06 23:08     ` Dmitry Gutov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e73a9694-63a2-3acf-b53a-c1d90fc9a8e1@yandex.ru \
    --to=dgutov@yandex.ru \
    --cc=23224@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).