From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.help Subject: RE: tool to display library dependencies? Date: Thu, 30 Dec 2004 11:49:40 -0800 Message-ID: References: <33j1htF42vp6oU1@individual.net> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1104436479 9688 80.91.229.6 (30 Dec 2004 19:54:39 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 30 Dec 2004 19:54:39 +0000 (UTC) Cc: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Dec 30 20:54:22 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1Ck6NK-0003Kv-00 for ; Thu, 30 Dec 2004 20:54:22 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1Ck6YG-0003GT-Uf for geh-help-gnu-emacs@m.gmane.org; Thu, 30 Dec 2004 15:05:40 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1Ck6Xy-0003Fb-Rj for help-gnu-emacs@gnu.org; Thu, 30 Dec 2004 15:05:23 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1Ck6Xy-0003Eq-1V for help-gnu-emacs@gnu.org; Thu, 30 Dec 2004 15:05:22 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1Ck6Xw-0003Ek-Da for help-gnu-emacs@gnu.org; Thu, 30 Dec 2004 15:05:21 -0500 Original-Received: from [148.87.2.204] (helo=inet-mail4.oracle.com) by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168) (Exim 4.34) id 1Ck6Iu-000180-PK for help-gnu-emacs@gnu.org; Thu, 30 Dec 2004 14:49:49 -0500 Original-Received: from inet-mail4.oracle.com (localhost [127.0.0.1]) by inet-mail4.oracle.com (Switch-3.1.4/Switch-3.1.0) with ESMTP id iBUJnkDP029698; Thu, 30 Dec 2004 11:49:46 -0800 (PST) Original-Received: from rgmsgw301.us.oracle.com (rgmsgw301.us.oracle.com [138.1.191.50]) by inet-mail4.oracle.com (Switch-3.1.4/Switch-3.1.0) with ESMTP id iBUJnhtH029675; Thu, 30 Dec 2004 11:49:44 -0800 (PST) Original-Received: from rgmsgw301.us.oracle.com (localhost [127.0.0.1]) by rgmsgw301.us.oracle.com (Switch-3.1.4/Switch-3.1.0) with ESMTP id iBUJnhYo010571; Thu, 30 Dec 2004 12:49:43 -0700 Original-Received: from dradamslap (dhcp-amer-csvpn-gw1-141-144-67-143.vpn.oracle.com [141.144.67.143]) by rgmsgw301.us.oracle.com (Switch-3.1.4/Switch-3.1.0) with SMTP id iBUJnglK010556 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO); Thu, 30 Dec 2004 12:49:43 -0700 Original-To: "Kevin Rodgers" X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.6604 (9.0.2911.0) In-reply-to: <33j1htF42vp6oU1@individual.net> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 Importance: Normal X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:23064 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:23064 > 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