[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Making project-files the "canonical" generic

From: Stefan Monnier
Subject: Re: Making project-files the "canonical" generic
Date: Wed, 16 Jan 2019 11:38:28 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

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.


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 @@
+(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.
          (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)
        ((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)))
-   "" (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."

reply via email to

[Prev in Thread] Current Thread [Next in Thread]