emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] malabarba/package.el-reload-files-on-upgrade 5675b0a 4/4:


From: Artur Malabarba
Subject: [Emacs-diffs] malabarba/package.el-reload-files-on-upgrade 5675b0a 4/4: (package--list-loaded-files) Return a recursive list of files
Date: Thu, 11 Dec 2014 08:33:45 +0000

branch: malabarba/package.el-reload-files-on-upgrade
commit 5675b0a4600416e7ceb9e4cf38d521a373b974cb
Author: Artur Malabarba <address@hidden>
Commit: Artur Malabarba <address@hidden>

    (package--list-loaded-files) Return a recursive list of files
---
 lisp/emacs-lisp/package.el |   50 +++++++++++++++++++++++++------------------
 1 files changed, 29 insertions(+), 21 deletions(-)

diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index b34eacb..e44abe6 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -554,28 +554,36 @@ Return the max version (as a string) if the package is 
held at a lower version."
     t))
 
 (defun package--list-loaded-files (dir)
-  "List all files in DIR which correspond to loaded features.
-Returns the `file-name-base' of each file, sorted by most recently
-loaded last."
+  "Recursively list all files in DIR which correspond to loaded features.
+Returns the `file-name-sans-extension' of each file, relative to
+DIR, sorted by most recently loaded last."
   (let* ((history (mapcar (lambda (x) (file-name-sans-extension
-                                 (file-truename (car x))))
-                         load-history))
-        ;; List all files that have already been loaded.
-        (list-of-conflicts
-         (remove
-          nil
-          (mapcar (lambda (x) (let* ((file (file-name-sans-extension
-                                       (file-truename
-                                        (find-library-name (file-name-base 
x)))))
-                                (pos (when file (member file history))))
-                           ;; Return (FILENAME . HISTORY-POSITION)
-                           (when pos (cons file (length pos)))))
-           (directory-files "./" nil "^[^\\.].*\\.el\\'" 'nosort)))))
-    ;; Turn the list of (FILENAME . POS) back into a list of features.
-    (mapcar (lambda (x) (file-name-base (car x)))
-     (sort list-of-conflicts
-          ;; Sort the files by ascending HISTORY-POSITION.
-          (lambda (x y) (< (cdr x) (cdr y)))))))
+                                  (file-truename (car x))))
+                          load-history))
+         (dir (file-truename dir))
+         ;; List all files that have already been loaded.
+         (list-of-conflicts
+          (remove
+           nil
+           (mapcar
+            (lambda (x) (let* ((file (file-relative-name x dir))
+                          ;; Previously loaded file, if any.
+                          (previous
+                           (ignore-errors
+                             (file-name-sans-extension
+                              (file-truename (find-library-name file)))))
+                          (pos (when previous (member previous history))))
+                     ;; Return (RELATIVE-FILENAME . HISTORY-POSITION)
+                     (when pos
+                       (cons (file-name-sans-extension file) (length pos)))))
+            (directory-files-recursively dir "\\`[^\\.].*\\.el\\'")))))
+    ;; Turn the list of (FILENAME . POS) back into a list of features.  Files 
in
+    ;; subdirectories are returned relative to DIR (so not actually features).
+    (mapcar (lambda (x) (file-name-sans-extension
+                    (file-relative-name (file-truename (car x)) dir)))
+            (sort list-of-conflicts
+                  ;; Sort the files by ascending HISTORY-POSITION.
+                  (lambda (x y) (< (cdr x) (cdr y)))))))
 
 (defun package-built-in-p (package &optional min-version)
   "Return true if PACKAGE is built-in to Emacs.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]