[Top][All Lists]

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

Re: tool to display library dependencies?

From: Kevin Rodgers
Subject: Re: tool to display library dependencies?
Date: Thu, 30 Dec 2004 11:59:59 -0700
User-agent: Mozilla Thunderbird 0.9 (X11/20041105)

Drew Adams wrote:
> This has probably been asked before, but I couldn't find it.
> 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? An Emacs command that
> does this would be great.
> For example: Library A requires B, which requires C and D. I'd like to be
> able to determine all of the libraries that A ultimately requires - in this
> case B, C, and D. A dependency tree would be even better:
>  A-B-+-C
>      |
>      +-D
> I realize that it would be problematic to take autoloads into account, but
> just dealing with the explicit `require's would still be useful. 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 RET ]
| file-requires is a compiled Lisp function in `loadhist'.
| (file-requires FILE)
| Return the list of features required by FILE.

,----[ C-h f feature-file RET ]
| feature-file is a compiled Lisp function in `loadhist'.
| (feature-file FEATURE)
| Return the file name from which a given FEATURE was loaded.
| Actually, return the load argument, if any; this is sometimes the name of a | Lisp file without an extension. If the feature came from an `eval-buffer' on
| a buffer with no associated file, or an `eval-region', return nil.


(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))
                    (file-dependencies required-file)))
              (if required-file-dependencies
                  (cons required-file required-file-dependencies)
          (file-requires file)))

Now (progn (require 'w3m) (file-dependencies "w3m")) returns

Kevin Rodgers

reply via email to

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