Skip to content

Commit f752db6

Browse files
committed
elpaca--main-file: use regexp + directory-file search
Previous method of manually constructing a list of files was intended to be faster. The performance gain in negligible and using a regexp + directory-files based search is able to better find files in non-standard locations.
1 parent 36923ba commit f752db6

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

elpaca.el

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,18 +1160,12 @@ The keyword's value is expected to be one of the following:
11601160
(declared (plist-member recipe :main)))
11611161
(cadr declared)
11621162
(let* ((package (file-name-sans-extension (elpaca<-package e)))
1163-
(filename (concat package ".el"))
1164-
(regexp (concat "\\`" filename "//'")))
1165-
(or (cl-loop for name in (list (concat package "-pkg.el")
1166-
(concat "./lisp/" package "-pkg.el")
1167-
filename
1168-
(concat "./lisp/" filename)
1169-
(concat "./elisp/" filename))
1170-
when (file-exists-p name) return name)
1171-
(car (directory-files repo nil regexp))
1172-
(car (elpaca--directory-files-recursively repo regexp))
1173-
;; Best guess if there is no file matching the package name...
1174-
(car (directory-files repo nil "\\.el\\'" 'nosort))
1163+
(name (concat "\\(?:" package "\\(?:-pkg\\)?\\.el\\)\\'"))
1164+
(prefix "\\`[^.z-a]*")
1165+
(regexp (concat prefix name)))
1166+
(or (car (directory-files repo nil regexp))
1167+
(car (cl-remove-if-not (apply-partially #'string-match-p (concat "[/\\]" name))
1168+
(elpaca--directory-files-recursively repo regexp)))
11751169
(error "Unable to find main elisp file for %S" package)))))))
11761170

11771171
(defun elpaca--dependencies (e &optional recache)

0 commit comments

Comments
 (0)