From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Making project-files the "canonical" generic Date: Wed, 16 Jan 2019 11:38:28 -0500 Message-ID: References: <20180922154639.23195.66360@vcs0.savannah.gnu.org> <20180922154640.9D58220310@vcs0.savannah.gnu.org> <54108dbc-9d12-06ff-3f1d-151118e9b234@yandex.ru> <4e729d1e-bb31-455f-fd44-e99ae5a6b9fa@yandex.ru> <86zhs5r9lr.fsf_-_@stephe-leake.org> <08de4d90-d678-0524-9356-f9a3515bf0c4@yandex.ru> <86a7k2rabi.fsf@stephe-leake.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1547656605 31510 195.159.176.226 (16 Jan 2019 16:36:45 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 16 Jan 2019 16:36:45 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jan 16 17:36:41 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gjoBE-00083i-96 for ged-emacs-devel@m.gmane.org; Wed, 16 Jan 2019 17:36:40 +0100 Original-Received: from localhost ([127.0.0.1]:42199 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gjoDL-0000Ce-4m for ged-emacs-devel@m.gmane.org; Wed, 16 Jan 2019 11:38:51 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:33895) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gjoDA-0000CB-Q3 for emacs-devel@gnu.org; Wed, 16 Jan 2019 11:38:41 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gjoD9-0007C1-VK for emacs-devel@gnu.org; Wed, 16 Jan 2019 11:38:40 -0500 Original-Received: from [195.159.176.226] (port=37570 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gjoD9-0007AP-MU for emacs-devel@gnu.org; Wed, 16 Jan 2019 11:38:39 -0500 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1gjoAy-0007hC-0o for emacs-devel@gnu.org; Wed, 16 Jan 2019 17:36:24 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 53 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:a77h5XWtJ7hbI2eijfPcEimSvn4= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 195.159.176.226 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:232398 Archived-At: BTW, we could also make both "canonical", i.e. allow any project system to provide either of them, and have the default implementation of both delegate to the other. Stefan diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index 844744bf95..f971c85a7c 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -157,6 +157,8 @@ vc-directory-exclusion-list) grep-find-ignored-files)) +(defvar project--from-files nil) + (cl-defgeneric project-file-completion-table (project dirs) "Return a completion table for files in directories DIRS in PROJECT. DIRS is a list of absolute directories; it should be some @@ -167,6 +167,8 @@ ;; FIXME: Uniquely abbreviate the roots? (require 'xref) (let ((all-files + (if (not project--from-files) + (project-files project dirs) ;; Delegate to project--files. (cl-mapcan (lambda (dir) (let ((command @@ -178,7 +180,7 @@ (project-ignores project dir) (expand-file-name dir))))) (split-string (shell-command-to-string command) "\0" t))) - dirs))) + dirs)))) (lambda (string pred action) (cond ((eq action 'metadata) @@ -197,9 +197,10 @@ ;; returns a "flat" completion table. ;; FIXME: Maybe we should do the reverse: implement the default ;; `project-file-completion-table' on top of `project-files'. + (unless dirs (setq dirs (project-roots project))) (all-completions - "" (project-file-completion-table - project (or dirs (project-roots project))))) + "" (let ((project--from-files t)) + (project-file-completion-table project dirs)))) (defgroup project-vc nil "Project implementation using the VC package."