1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-05 22:20:24 -08:00

; Fix order in which 'package-dir-info' searches files

See https://mail.gnu.org/archive/html/emacs-devel/2025-11/msg00977.html.

* lisp/emacs-lisp/package.el (package-dir-info): Sort files by
length instead of by the default order.  This aligns the
intention, the implementation and the preceding comment.
This commit is contained in:
Philip Kaludercic 2025-11-26 19:30:48 +01:00
parent e10c4982dc
commit d74bcd7b2c
No known key found for this signature in database

View file

@ -1280,10 +1280,10 @@ The return result is a `package-desc'."
(let ((files (or (and (derived-mode-p 'dired-mode)
(dired-get-marked-files nil 'marked))
(directory-files default-directory t "\\.el\\'" t))))
;; We sort the file names in lexicographical order, to ensure
;; that we check shorter file names first (ie. those further
;; up in the directory structure).
(dolist (file (sort files))
;; We sort the file names by length, to ensure that we check
;; shorter file names first, as these are more likely to
;; contain the package metadata.
(dolist (file (sort files :key #'length))
;; The file may be a link to a nonexistent file; e.g., a
;; lock file.
(when (file-exists-p file)