Normalise the file-list functions so they can be assessed for similarities

This commit is contained in:
Steve Purcell 2012-05-05 08:53:48 +01:00
parent bd6ce27c31
commit c9220870ed

View file

@ -468,31 +468,33 @@ of the same-named package which is to be kept."
(defun pb/source-file-list (files) (defun pb/source-file-list (files)
"Generate a flat source file listing from FILES." "Generate a flat source file listing from FILES."
(mapcan (lambda (fn) (if (consp fn) (mapcan (lambda (entry)
(pb/source-file-list (cdr fn)) (if (consp entry)
(list fn))) files)) (pb/source-file-list (cdr entry))
(list entry)))
files))
(defun pb/target-file-list (files) (defun pb/target-file-list (files)
"Generate a flat target file listing from FILES." "Generate a flat target file listing from FILES."
(loop for fn in files (mapcan (lambda (entry)
nconc (if (consp fn) (if (consp entry)
(loop for res in (pb/target-file-list (cdr fn)) (loop for res in (pb/target-file-list (cdr entry))
collect (concat (car fn) "/" res)) collect (concat (car entry) "/" res))
(list (file-name-nondirectory fn))))) (list (file-name-nondirectory entry))))
files))
(defun pb/expand-config-file-list (dir config) (defun pb/expand-config-file-list (dir config)
"In DIR, expand the :files for CONFIG and flatten the list." "In DIR, expand the :files for CONFIG and flatten the list."
(pb/expand-file-list dir (or (plist-get config :files) (list "*.el")))) (pb/expand-file-list dir (or (plist-get config :files) (list "*.el"))))
(defun pb/expand-file-list (dir wildcards) (defun pb/expand-file-list (dir files)
"In DIR, expand WILDCARDS, some of which may be shell-style wildcards." "In DIR, expand FILES, some of which may be shell-style wildcards."
(mapcan (lambda (entry)
(if (consp entry)
(list (cons (car entry) (pb/expand-file-list dir (cdr entry))))
(let ((default-directory dir)) (let ((default-directory dir))
(mapcan (lambda (wc) (file-expand-wildcards entry))))
(if (consp wc) files))
(list (cons (car wc) (pb/expand-file-list dir (cdr wc))))
(file-expand-wildcards wc)))
wildcards)))
(defun pb/expand-source-file-list (dir config) (defun pb/expand-source-file-list (dir config)
"Shorthand way to expand paths in DIR for files listed in CONFIG." "Shorthand way to expand paths in DIR for files listed in CONFIG."