[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master d8da091 1/3: Make 'project-files' the "canonical" g
From: |
Dmitry Gutov |
Subject: |
[Emacs-diffs] master d8da091 1/3: Make 'project-files' the "canonical" generic of the two |
Date: |
Thu, 17 Jan 2019 22:46:44 -0500 (EST) |
branch: master
commit d8da0916fff16a3ef26cc1f929c262466e143268
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>
Make 'project-files' the "canonical" generic of the two
* lisp/progmodes/project.el (project-files): Move the actual
command building and invocation here.
(project-file-completion-table): Delegate to 'project-files'.
---
lisp/progmodes/project.el | 48 +++++++++++++++++++++--------------------------
1 file changed, 21 insertions(+), 27 deletions(-)
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 844744b..afb3904 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -162,29 +162,14 @@ end it with `/'. DIR must be one of `project-roots' or
DIRS is a list of absolute directories; it should be some
subset of the project roots and external roots.
-The default implementation uses `find-program'. PROJECT is used
-to find the list of ignores for each directory."
- ;; FIXME: Uniquely abbreviate the roots?
- (require 'xref)
- (let ((all-files
- (cl-mapcan
- (lambda (dir)
- (let ((command
- (format "%s %s %s -type f -print0"
- find-program
- (shell-quote-argument
- (expand-file-name dir))
- (xref--find-ignores-arguments
- (project-ignores project dir)
- (expand-file-name dir)))))
- (split-string (shell-command-to-string command) "\0" t)))
- dirs)))
+The default implementation delegates to `project-files'."
+ (let ((all-files (project-files project dirs)))
(lambda (string pred action)
(cond
((eq action 'metadata)
- '(metadata . ((category . project-file))))
+ '(metadata . ((category . project-file))))
(t
- (complete-with-action action all-files string pred))))))
+ (complete-with-action action all-files string pred))))))
(cl-defmethod project-roots ((project (head transient)))
(list (cdr project)))
@@ -192,14 +177,23 @@ to find the list of ignores for each directory."
(cl-defgeneric project-files (project &optional dirs)
"Return a list of files in directories DIRS in PROJECT.
DIRS is a list of absolute directories; it should be some
-subset of the project roots and external roots."
- ;; This default implementation only works if project-file-completion-table
- ;; returns a "flat" completion table.
- ;; FIXME: Maybe we should do the reverse: implement the default
- ;; `project-file-completion-table' on top of `project-files'.
- (all-completions
- "" (project-file-completion-table
- project (or dirs (project-roots project)))))
+subset of the project roots and external roots.
+
+The default implementation uses `find-program'. PROJECT is used
+to find the list of ignores for each directory."
+ (require 'xref)
+ (cl-mapcan
+ (lambda (dir)
+ (let ((command
+ (format "%s %s %s -type f -print0"
+ find-program
+ (shell-quote-argument
+ (expand-file-name dir))
+ (xref--find-ignores-arguments
+ (project-ignores project dir)
+ (expand-file-name dir)))))
+ (split-string (shell-command-to-string command) "\0" t)))
+ (or dirs (project-roots project))))
(defgroup project-vc nil
"Project implementation using the VC package."