aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman2005-01-02 23:43:51 +0000
committerRichard M. Stallman2005-01-02 23:43:51 +0000
commit27af61fe6c2bb7e9e16ae864eb76dd3be2f6587e (patch)
tree712b78522f429dc67874faf805945dbd52f43a6e
parent3625f6b741ad3f0a728224295f9112fa8211605b (diff)
downloademacs-27af61fe6c2bb7e9e16ae864eb76dd3be2f6587e.tar.gz
emacs-27af61fe6c2bb7e9e16ae864eb76dd3be2f6587e.zip
(file-loadhist-lookup): New function.
(file-provides, file-requires): Use it.
-rw-r--r--lisp/loadhist.el21
1 files changed, 19 insertions, 2 deletions
diff --git a/lisp/loadhist.el b/lisp/loadhist.el
index 8cbe1d80cd3..76ef87ee845 100644
--- a/lisp/loadhist.el
+++ b/lisp/loadhist.el
@@ -51,9 +51,26 @@ a buffer with no associated file, or an `eval-region', return nil."
51 (error "%S is not a currently loaded feature" feature) 51 (error "%S is not a currently loaded feature" feature)
52 (car (feature-symbols feature)))) 52 (car (feature-symbols feature))))
53 53
54(defun file-loadhist-lookup (file)
55 "Return the `load-history' element for FILE."
56 ;; First look for FILE as given.
57 (let ((symbols (assoc file load-history)))
58 ;; Try converting a library name to an absolute file name.
59 (and (null symbols)
60 (let ((absname (find-library-name file)))
61 (if (not (equal absname file))
62 (setq symbols (cdr (assoc absname load-history))))))
63 ;; Try converting an absolute file name to a library name.
64 (and (null symbols) (string-match "[.]el\\'" file)
65 (let ((libname (file-name-nondirectory file)))
66 (string-match "[.]el\\'" libname)
67 (setq libname (substring libname 0 (match-beginning 0)))
68 (setq symbols (cdr (assoc libname load-history)))))
69 symbols))
70
54(defun file-provides (file) 71(defun file-provides (file)
55 "Return the list of features provided by FILE." 72 "Return the list of features provided by FILE."
56 (let ((symbols (cdr (assoc file load-history))) 73 (let ((symbols (file-loadhist-lookup file))
57 provides) 74 provides)
58 (mapc (lambda (x) 75 (mapc (lambda (x)
59 (if (and (consp x) (eq (car x) 'provide)) 76 (if (and (consp x) (eq (car x) 'provide))
@@ -63,7 +80,7 @@ a buffer with no associated file, or an `eval-region', return nil."
63 80
64(defun file-requires (file) 81(defun file-requires (file)
65 "Return the list of features required by FILE." 82 "Return the list of features required by FILE."
66 (let ((symbols (cdr (assoc file load-history))) 83 (let ((symbols (file-loadhist-lookup file))
67 requires) 84 requires)
68 (mapc (lambda (x) 85 (mapc (lambda (x)
69 (if (and (consp x) (eq (car x) 'require)) 86 (if (and (consp x) (eq (car x) 'require))