From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#23224: 25.0.92; Can xref-find-references work without a "project"? Date: Wed, 6 Apr 2016 03:18:09 +0300 Message-ID: References: <83oa9om65f.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1459901962 24928 80.91.229.3 (6 Apr 2016 00:19:22 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 6 Apr 2016 00:19:22 +0000 (UTC) To: Eli Zaretskii , 23224@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Apr 06 02:19:11 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1anbBe-0001Lp-At for geb-bug-gnu-emacs@m.gmane.org; Wed, 06 Apr 2016 02:19:10 +0200 Original-Received: from localhost ([::1]:39982 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1anbBc-0006ls-TA for geb-bug-gnu-emacs@m.gmane.org; Tue, 05 Apr 2016 20:19:08 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41275) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1anbBZ-0006lG-Fs for bug-gnu-emacs@gnu.org; Tue, 05 Apr 2016 20:19:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1anbBW-0001fG-9f for bug-gnu-emacs@gnu.org; Tue, 05 Apr 2016 20:19:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:38480) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1anbBW-0001eo-5o for bug-gnu-emacs@gnu.org; Tue, 05 Apr 2016 20:19:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1anbBV-0004iO-V4 for bug-gnu-emacs@gnu.org; Tue, 05 Apr 2016 20:19:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 06 Apr 2016 00:19:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23224 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 23224-submit@debbugs.gnu.org id=B23224.145990189818069 (code B ref 23224); Wed, 06 Apr 2016 00:19:01 +0000 Original-Received: (at 23224) by debbugs.gnu.org; 6 Apr 2016 00:18:18 +0000 Original-Received: from localhost ([127.0.0.1]:50817 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1anbAo-0004hN-Gs for submit@debbugs.gnu.org; Tue, 05 Apr 2016 20:18:18 -0400 Original-Received: from mail-wm0-f52.google.com ([74.125.82.52]:36247) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1anbAn-0004hB-2l for 23224@debbugs.gnu.org; Tue, 05 Apr 2016 20:18:17 -0400 Original-Received: by mail-wm0-f52.google.com with SMTP id v188so5528686wme.1 for <23224@debbugs.gnu.org>; Tue, 05 Apr 2016 17:18:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:subject:to:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=ggVf3IsbbFD2sTR9kEyGFvC88uFFxj+b/3/Pm/fdjaU=; b=qs0lbjE4VXgoIB0XrhvZfRmNL5McCk+xnt/8rRyot10NgggihI/UBGrrXlJscpaHsa J0N/D4X4f1p47ltj0u1oW98aEUbeect02hPxgEIapLWR0B36IpVeNHz+wAJajCevP00H 9rnHg9LESGN0Rp4Sr2vE83MvwNJGW+ZkyfTHOAh7j/2pV88ShEdlVbLoMxjUoR4ViOG+ 1dX+x8v9OXzaRgznbspK2P87b/MA41GrZ/MYpGtfyH/WLn75hiidj1wjFSaOKgtv2ui/ 00skmfGK9z59dLw9hRJtFoRw4xobUWDe1nH4x1qFWXGcNwMeucptYa9rGigAe2+sYiuN /Osw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:subject:to:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=ggVf3IsbbFD2sTR9kEyGFvC88uFFxj+b/3/Pm/fdjaU=; b=gVJAeUQIiPOuvltUy3Ndp/3uKFGp1rpPWhaBwHlTJ7C6d0Mxsq4IJzsOXdWzNHKN+O aBMWRPf+jT6rUdY3aqNJl1xG3mQuxuh02361DZjPyVwhE7x+VEk3TmtpfMcUvn9aPuJU YtDHKghFKDOYOYGIaD3PxlZPNUI6WQcXckZMyUSJU8IsLLMdTPVpr5X93gBWZkbGmZai PnP+r7YnexepVmeuzv5nLmarMeaKPwdgnjywcsApitLp0KXoX36CMt9njKNEQqHt7wri Pwnbd2iNdbyXSNlAd6PwPppWIxDvW8uWVXzcrVUn1xsajV3+3kr3WKG7XU/eKJ07aeWD dWzw== X-Gm-Message-State: AD7BkJJfVO7AqhIDYHU+8Y7KW0PNuG0nrOZ2HbKO43pzEu1FkOtMduApPuz1T+iS5hgvXQ== X-Received: by 10.28.109.87 with SMTP id i84mr2935505wmc.3.1459901891245; Tue, 05 Apr 2016 17:18:11 -0700 (PDT) Original-Received: from [192.168.1.2] ([185.105.175.24]) by smtp.googlemail.com with ESMTPSA id u3sm21879833wmg.15.2016.04.05.17.18.10 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 05 Apr 2016 17:18:10 -0700 (PDT) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.0 In-Reply-To: <83oa9om65f.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:116100 Archived-At: 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"