diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index 3eaa789b3e..65ae43ff4c 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -835,28 +835,28 @@ project--read-regexp project-regexp-history-variable))) ;;;###autoload -(defun project-find-file () +(defun project-find-file (&optional no-ignores) "Visit a file (with completion) in the current project. The filename at point (determined by `thing-at-point'), if any, is available as part of \"future history\"." - (interactive) + (interactive "P") (let* ((pr (project-current t)) (dirs (list (project-root pr)))) - (project-find-file-in (thing-at-point 'filename) dirs pr))) + (project-find-file-in (thing-at-point 'filename) dirs pr no-ignores))) ;;;###autoload -(defun project-or-external-find-file () +(defun project-or-external-find-file (&optional no-ignores) "Visit a file (with completion) in the current project or external roots. The filename at point (determined by `thing-at-point'), if any, is available as part of \"future history\"." - (interactive) + (interactive "P") (let* ((pr (project-current t)) (dirs (cons (project-root pr) (project-external-roots pr)))) - (project-find-file-in (thing-at-point 'filename) dirs pr))) + (project-find-file-in (thing-at-point 'filename) dirs pr no-ignores))) (defcustom project-read-file-name-function #'project--read-file-cpd-relative "Function to call to read a file name from a list. @@ -909,12 +909,24 @@ project--read-file-absolute predicate hist mb-default)) -(defun project-find-file-in (suggested-filename dirs project) +(defun project-find-file-in (suggested-filename dirs project &optional no-ignores) "Complete a file name in DIRS in PROJECT and visit the result. SUGGESTED-FILENAME is a relative file name, or part of it, which -is used as part of \"future history\"." - (let* ((all-files (project-files project dirs)) +is used as part of \"future history\". + +If NO-IGNORES is specified, include all files from DIRS, except +for VCS metadata directories enumerated in `vc-directory-exclusion-list'." + (let* ((vc-dirs-ignores (mapcar + (lambda (dir) + (concat dir "/")) + vc-directory-exclusion-list)) + (all-files + (if no-ignores + (mapcan + (lambda (dir) (project--files-in-directory dir vc-dirs-ignores)) + dirs) + (project-files project dirs))) (completion-ignore-case read-file-name-completion-ignore-case) (file (funcall project-read-file-name-function "Find file" all-files nil nil