mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-22 21:07:36 +00:00
Add new argument INCLUDE-ALL to project-find-file
* lisp/progmodes/project.el (project-find-file): Add new argument INCLUDE-ALL. Have 'C-u' make it non-nil. (project-or-external-find-file): Ditto. (project-find-file-in): Add new argument INCLUDE-ALL. (https://lists.gnu.org/archive/html/emacs-devel/2021-10/msg00209.html)
This commit is contained in:
parent
97c4f84cbc
commit
14bfb31dba
2 changed files with 37 additions and 11 deletions
5
etc/NEWS
5
etc/NEWS
|
|
@ -123,6 +123,11 @@ also handle ANSI codes for faint, italic and blinking text, displaying
|
|||
it with new 'ansi-term-faint/italic/slow-blinking/fast-blinking'
|
||||
faces.
|
||||
|
||||
** Xref
|
||||
|
||||
*** 'project-find-file' and 'project-or-external-find-file' now accept
|
||||
a prefix argument which is interpreted to mean "include all files".
|
||||
|
||||
|
||||
* New Modes and Packages in Emacs 29.1
|
||||
|
||||
|
|
|
|||
|
|
@ -840,28 +840,36 @@ pattern to search for."
|
|||
project-regexp-history-variable)))
|
||||
|
||||
;;;###autoload
|
||||
(defun project-find-file ()
|
||||
(defun project-find-file (&optional include-all)
|
||||
"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)
|
||||
is available as part of \"future history\".
|
||||
|
||||
If INCLUDE-ALL is non-nil, or with prefix argument when called
|
||||
interactively, include all files under the project root, except
|
||||
for VCS directories listed in `vc-directory-exclusion-list'."
|
||||
(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 include-all)))
|
||||
|
||||
;;;###autoload
|
||||
(defun project-or-external-find-file ()
|
||||
(defun project-or-external-find-file (&optional include-all)
|
||||
"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)
|
||||
is available as part of \"future history\".
|
||||
|
||||
If INCLUDE-ALL is non-nil, or with prefix argument when called
|
||||
interactively, include all files under the project root, except
|
||||
for VCS directories listed in `vc-directory-exclusion-list'."
|
||||
(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 include-all)))
|
||||
|
||||
(defcustom project-read-file-name-function #'project--read-file-cpd-relative
|
||||
"Function to call to read a file name from a list.
|
||||
|
|
@ -914,12 +922,25 @@ by the user at will."
|
|||
predicate
|
||||
hist mb-default))
|
||||
|
||||
(defun project-find-file-in (suggested-filename dirs project)
|
||||
(defun project-find-file-in (suggested-filename dirs project &optional include-all)
|
||||
"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 INCLUDE-ALL is non-nil, or with prefix argument when called
|
||||
interactively, include all files from DIRS, except for VCS
|
||||
directories listed in `vc-directory-exclusion-list'."
|
||||
(let* ((vc-dirs-ignores (mapcar
|
||||
(lambda (dir)
|
||||
(concat dir "/"))
|
||||
vc-directory-exclusion-list))
|
||||
(all-files
|
||||
(if include-all
|
||||
(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
|
||||
|
|
|
|||
Loading…
Reference in a new issue