]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix finding filelist for :tree fileset (Bug#976)
authorDrew Adams <drew.adams@oracle.com>
Tue, 24 Nov 2020 11:00:29 +0000 (08:00 -0300)
committerMauro Aranda <maurooaranda@gmail.com>
Tue, 24 Nov 2020 11:00:29 +0000 (08:00 -0300)
* 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.

lisp/filesets.el

index c7ec3f77f430d1f787bc113b6c05b913e26abc78..84196561fcdcf655a045fb2249135cd5c9b666c7 100644 (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."