1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-29 07:58:28 +00:00

Fix finding filelist for :tree fileset (Bug#976)

* lisp/filesets.el (filesets-files-under): New function, used to get
all files for a :tree fileset.
(filesets-get-filelist): Use it.  Look for the directory and the
pattern in the right place inside entry.
This commit is contained in:
Drew Adams 2020-11-24 08:00:29 -03:00 committed by Mauro Aranda
parent 89a24e4d05
commit 5cc570215a

View File

@ -1718,9 +1718,12 @@ Assume MODE (see `filesets-entry-mode'), if provided."
(filesets-entry-get-master entry)))))
(cons entry (filesets-ingroup-cache-get entry))))
(:tree
(let ((dir (nth 0 entry))
(patt (nth 1 entry)))
(filesets-directory-files dir patt ':files t)))
(let* ((dirpatt (filesets-entry-get-tree entry))
(dir (nth 0 dirpatt))
(patt (nth 1 dirpatt))
(depth (or (filesets-entry-get-tree-max-level entry)
filesets-tree-max-level)))
(filesets-files-under 0 depth entry dir patt)))
(:pattern
(let ((dirpatt (filesets-entry-get-pattern entry)))
(if dirpatt
@ -1734,6 +1737,34 @@ Assume MODE (see `filesets-entry-mode'), if provided."
(lambda (file)
(not (filesets-filetype-property file event))))))
(defun filesets-files-under (level depth entry dir patt &optional relativep)
"Files under DIR that match PATT.
LEVEL is the current level under DIR.
DEPTH is the maximal tree scanning depth for ENTRY.
ENTRY is a fileset.
DIR is a directory.
PATT is a regexp that included file names must match.
RELATIVEP non-nil means use relative file names."
(and (or (= depth 0) (< level depth))
(let* ((dir (file-name-as-directory dir))
(files-here (filesets-directory-files
dir patt nil (not relativep)
(filesets-entry-get-filter-dirs-flag entry)))
(subdirs (filesets-filter-dir-names files-here))
(files
(filesets-filter-dir-names
(apply #'append
files-here
(mapcar
(lambda (subdir)
(let* ((subdir (file-name-as-directory subdir))
(full-subdir (concat dir subdir)))
(filesets-files-under (+ level 1) depth entry
full-subdir patt)))
subdirs))
t)))
files)))
(defun filesets-open (&optional mode name lookup-name)
"Open the fileset called NAME.
Use LOOKUP-NAME for searching additional data if provided."