aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtur Malabarba2014-12-13 11:48:08 +0000
committerArtur Malabarba2014-12-13 12:31:20 +0000
commitafd801f9a7a5e025394d89dae798ac81bfc2d46d (patch)
tree4a881e81ee88b844ef9152beeb2c5c1d78f68bb3
parent7c9eb96534274cbbe297e771c6ae764f8cd1d9ed (diff)
downloademacs-afd801f9a7a5e025394d89dae798ac81bfc2d46d.tar.gz
emacs-afd801f9a7a5e025394d89dae798ac81bfc2d46d.zip
emacs-lisp/package.el (package--list-loaded-files): New function
List files in a given directory which correspond to already loaded files.
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/emacs-lisp/package.el32
2 files changed, 38 insertions, 0 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index f3d56c99241..bc34066d001 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
12014-12-13 Artur Malabarba <bruce.connor.am@gmail.com>
2
3 * emacs-lisp/package.el (package--list-loaded-files): New function
4 to list files in a given directory which correspond to already
5 loaded files.
6
12014-12-13 Eric S. Raymond <esr@snark.thyrsus.com> 72014-12-13 Eric S. Raymond <esr@snark.thyrsus.com>
2 8
3 * vc/vc-svn.el (vc-svn-diff): Fix bug #19312. 9 * vc/vc-svn.el (vc-svn-diff): Fix bug #19312.
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index 4e5c397e433..654ad3aa3a5 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -543,6 +543,38 @@ Return the max version (as a string) if the package is held at a lower version."
543 ;; Don't return nil. 543 ;; Don't return nil.
544 t)) 544 t))
545 545
546(defun package--list-loaded-files (dir)
547 "Recursively list all files in DIR which correspond to loaded features.
548Returns the `file-name-sans-extension' of each file, relative to
549DIR, sorted by most recently loaded last."
550 (let* ((history (mapcar (lambda (x) (file-name-sans-extension
551 (file-truename (car x))))
552 load-history))
553 (dir (file-truename dir))
554 ;; List all files that have already been loaded.
555 (list-of-conflicts
556 (remove
557 nil
558 (mapcar
559 (lambda (x) (let* ((file (file-relative-name x dir))
560 ;; Previously loaded file, if any.
561 (previous
562 (ignore-errors
563 (file-name-sans-extension
564 (file-truename (find-library-name file)))))
565 (pos (when previous (member previous history))))
566 ;; Return (RELATIVE-FILENAME . HISTORY-POSITION)
567 (when pos
568 (cons (file-name-sans-extension file) (length pos)))))
569 (directory-files-recursively dir "\\`[^\\.].*\\.el\\'")))))
570 ;; Turn the list of (FILENAME . POS) back into a list of features. Files in
571 ;; subdirectories are returned relative to DIR (so not actually features).
572 (let ((default-directory (file-name-as-directory dir)))
573 (mapcar (lambda (x) (file-truename (car x)))
574 (sort list-of-conflicts
575 ;; Sort the files by ascending HISTORY-POSITION.
576 (lambda (x y) (< (cdr x) (cdr y))))))))
577
546(defun package-built-in-p (package &optional min-version) 578(defun package-built-in-p (package &optional min-version)
547 "Return true if PACKAGE is built-in to Emacs. 579 "Return true if PACKAGE is built-in to Emacs.
548Optional arg MIN-VERSION, if non-nil, should be a version list 580Optional arg MIN-VERSION, if non-nil, should be a version list