all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Kevin Rodgers <ihs_4664@yahoo.com>
Subject: Re: tool to display library dependencies?
Date: Thu, 30 Dec 2004 11:59:59 -0700	[thread overview]
Message-ID: <33j1htF42vp6oU1@individual.net> (raw)
In-Reply-To: <mailman.10066.1104423032.27204.help-gnu-emacs@gnu.org>

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.
`----

So:

(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)))

Now (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")

-- 
Kevin Rodgers

       reply	other threads:[~2004-12-30 18:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.10066.1104423032.27204.help-gnu-emacs@gnu.org>
2004-12-30 18:59 ` Kevin Rodgers [this message]
2004-12-30 19:49   ` tool to display library dependencies? Drew Adams
     [not found] <mailman.10104.1104437134.27204.help-gnu-emacs@gnu.org>
2004-12-30 20:54 ` Kevin Rodgers
2004-12-30 15:58 Drew Adams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=33j1htF42vp6oU1@individual.net \
    --to=ihs_4664@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.