From: Dmitry Gutov Date: Sun, 13 Jan 2019 21:16:19 +0000 (+0300) Subject: Make 'project-files' the "canonical" generic of the two X-Git-Tag: emacs-27.0.90~3796 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=d8da0916fff16a3ef26cc1f929c262466e143268;p=emacs.git 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'. --- diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index 844744bf953..afb390468b6 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."