[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: tool to display library dependencies?
From: |
Drew Adams |
Subject: |
RE: tool to display library dependencies? |
Date: |
Thu, 30 Dec 2004 11:49:40 -0800 |
> Is there a tool somewhere that will look at one or more Emacs Lisp
> libraries and output a tree or list of its library dependencies?
> And it would be good if such a tool/command distinguished somehow
> between hard and soft (`(require nil t)') `require's.
C-h f file-requires
C-h f feature-file
This is great news. I wasn't aware of these functions (or of loadhist.el).
(require 'loadhist)
(defun file-dependencies (file)
"Return a list of the files `require'd by FILE.
If any of those files themselves `require' another, return it as a list
of it and its dependencies, and so on (recursively)."
(mapcar (lambda (feature)
(let* ((required-file (feature-file feature))
(required-file-dependencies
(file-dependencies required-file)))
(if required-file-dependencies
(cons required-file required-file-dependencies)
required-file)))
(file-requires file)))
(progn (require 'w3m) (file-dependencies "w3m"))
returns ("browse-url" "timezone" "w3m-hist" ("w3m-e21" "wid-edit"
("w3m-ccl" "ccl") "w3m-fsf" "w3m-favicon" "w3m-image")
"w3m-proc" "w3m-util")
Thanks, Kevin.
However, there is one hiccup still: there is no distinction between hard and
soft `require's. This in effect relies on all of the `require'd libraries
actually being loaded.
For example, I have a library foo.el that does this: (require 'mwheel nil
t). My library works in Emacs 21 (which has feature mwheel), but also in
Emacs 20 (which does not have feature mwheel) - the soft require succeeds in
Emacs 21 and fails (gracefully) in Emacs 20.
When I try (progn (require 'foo) (file-dependencies "foo")) in Emacs 20 I
get an error from the call to (feature-file mwheel): "mwheel is not a
currently loaded feature".
This is such a _useful_ feature, and it's so close to being generally
usable. I can try myself to hack it up to get around this, but perhaps you
have a suggestion or two (or a fix)?
Thanks,
Drew