From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Sebastien Vauban" Newsgroups: gmane.emacs.help Subject: Re: Show who is requiring Date: Fri, 07 Dec 2012 22:57:02 +0100 Organization: Sebastien Vauban Message-ID: <80zk1pv841.fsf@somewhere.org> References: <80d2zd87t0.fsf@somewhere.org> <804nkl7eqc.fsf@somewhere.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1354917616 17658 80.91.229.3 (7 Dec 2012 22:00:16 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 7 Dec 2012 22:00:16 +0000 (UTC) To: help-gnu-emacs-mXXj517/zsQ@public.gmane.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org-mXXj517/zsQ@public.gmane.org Fri Dec 07 23:00:30 2012 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Th5y7-0001Jx-TV for geh-help-gnu-emacs@m.gmane.org; Fri, 07 Dec 2012 23:00:28 +0100 Original-Received: from localhost ([::1]:39405 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Th5xu-00062n-EN for geh-help-gnu-emacs@m.gmane.org; Fri, 07 Dec 2012 17:00:14 -0500 Original-Path: usenet.stanford.edu!goblin1!goblin.stu.neva.ru!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 271 Injection-Info: mx04.eternal-september.org; posting-host="5da807328d6a3351ee2b595083918cf6"; logging-data="17172"; mail-complaints-to="abuse-VVbKFVtnif8H+i2N2EyTrmui9UKz+5OX@public.gmane.org"; posting-account="U2FsdGVkX18VocWawBaVrkENAOPv6IJZ" User-Agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.3.50 (windows-nt) X-Archive: encrypt Cancel-Lock: sha1:lvuNxmc65pR9zbokDICjSbGRhZU= sha1:H8LexfJPdjj6sQ2AGESYX5D/uN4= X-Url: Under construction... Original-Xref: usenet.stanford.edu gnu.emacs.help:195759 X-BeenThere: help-gnu-emacs-mXXj517/zsQ@public.gmane.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org-mXXj517/zsQ@public.gmane.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org-mXXj517/zsQ@public.gmane.org Xref: news.gmane.org gmane.emacs.help:88081 Archived-At: Hello Stefan and all, "Sebastien Vauban" wrote: > Stefan Monnier wrote: >>>>> I tried using (current-buffer) to get the name of the "source" package >>>>> (i.e., the one which makes the `require' request), but that's wrong. Any >>>>> idea how to get the name of the "caller" package? >>>> >>>> IIUC you want load-file-name. >>> >>> How does this report the names of files that require another package? >> >> IIUC he has put an advice on `require', so in this advice, `load-file-name' >> should contain the name of the code that's calling the `require'. > > From your description, that's exactly what I'm after. I'll test and report. For some unknown reason (I mean: to me), `load-file-name' is sometimes nil, like if the requires came out of nowhere: --8<---------------cut here---------------start------------->8--- Loading Minimal Emacs... .emacs-minimal -> help-fns... Done [3 times] Loading Minimal Emacs... Done org -> calendar... calendar -> cal-menu... cal-menu -> calendar... Done calendar -> cal-menu... Done org -> calendar... Done org -> find-func... Done org -> format-spec... Done org -> ob-emacs-lisp... ob-emacs-lisp -> ob... ob -> ob-eval... Done ob -> org-macs... Done ob -> org-compat... org-compat -> org-macs... Done ob -> org-compat... Done ob-emacs-lisp -> ob... Done org -> ob-emacs-lisp... Done org -> org-compat... Done org -> outline... Done org -> noutline... Done org -> time-date... Done org -> easymenu... Done org -> overlay... Done org -> org-macs... Done org -> org-entities... org-entities -> org-macs... Done org -> org-entities... Done org -> org-faces... org-faces -> org-macs... Done org-faces -> org-compat... Done org -> org-faces... Done org -> org-list... org-list -> org-macs... Done org-list -> org-compat... Done org -> org-list... Done org -> org-pcomplete... org-pcomplete -> org-macs... Done org-pcomplete -> org-compat... Done org-pcomplete -> pcomplete... pcomplete -> comint... comint -> ring... Done comint -> ansi-color... Done comint -> regexp-opt... Done pcomplete -> comint... Done org-pcomplete -> pcomplete... Done org -> org-pcomplete... Done org -> org-src... org-src -> org-macs... Done org-src -> org-compat... Done org-src -> ob-keys... ob-keys -> ob... Done org-src -> ob-keys... Done org-src -> ob-comint... ob-comint -> ob... Done ob-comint -> org-compat... Done ob-comint -> comint... Done org-src -> ob-comint... Done org -> org-src... Done org -> org-footnote... org-footnote -> org-macs... Done org-footnote -> org-compat... Done org -> org-footnote... Done org -> ob... Done org -> ob-table... ob-table -> ob... Done org -> ob-table... Done org -> ob-lob... ob-lob -> ob... Done ob-lob -> ob-table... Done org -> ob-lob... Done org -> ob-ref... ob-ref -> ob... Done org -> ob-ref... Done org -> ob-tangle... ob-tangle -> ob... Done ob-tangle -> org-src... Done org -> ob-tangle... Done org -> ob-comint... Done org -> ob-keys... Done org -> font-lock... Done org -> help-fns... Done [2 times] org -> bytecomp... bytecomp -> backquote... Done bytecomp -> macroexp... Done bytecomp -> cconv... Done org -> bytecomp... Done org -> warnings... Done byte-opt -> bytecomp... Done byte-opt -> macroexp... Done org -> help-fns... Done [3 times] nil? -> org-bbdb... org-bbdb -> org... Done nil? -> org-bbdb... Done nil? -> org-bibtex... org-bibtex -> org... Done org-bibtex -> bibtex... bibtex -> button... Done org-bibtex -> bibtex... Done org-bibtex -> org-compat... Done nil? -> org-bibtex... Done nil? -> org-docview... org-docview -> org... Done nil? -> org-docview... Done nil? -> org-gnus... org-gnus -> org... Done org-gnus -> gnus-util... gnus-util -> time-date... Done org-gnus -> gnus-util... Done nil? -> org-gnus... Done nil? -> org-info... org-info -> org... Done nil? -> org-info... Done nil? -> org-jsinfo... org-jsinfo -> org-exp... org-exp -> org... Done org-exp -> org-macs... Done org-exp -> org-agenda... org-agenda -> org... Done org-agenda -> org-macs... Done org-exp -> org-agenda... Done org-exp -> org-exp-blocks... org-exp-blocks -> find-func... Done org-exp-blocks -> org-compat... Done org-exp -> org-exp-blocks... Done org-exp -> ob-exp... ob-exp -> ob... Done ob-exp -> org-exp-blocks... Done org-exp -> ob-exp... Done org-exp -> org-src... Done org-jsinfo -> org-exp... Done org-jsinfo -> org-html... org-html -> org-exp... Done org-html -> format-spec... Done org-jsinfo -> org-html... Done nil? -> org-jsinfo... Done nil? -> org-irc... org-irc -> org... Done nil? -> org-irc... Done nil? -> org-mew... org-mew -> org... Done nil? -> org-mew... Done nil? -> org-mhe... org-mhe -> org... Done nil? -> org-mhe... Done nil? -> org-rmail... org-rmail -> org... Done nil? -> org-rmail... Done nil? -> org-vm... org-vm -> org... Done nil? -> org-vm... Done nil? -> org-w3m... org-w3m -> org... Done nil? -> org-w3m... Done nil? -> org-wl... org-wl -> org... Done nil? -> org-wl... Done OVERVIEW Loading vc-svn...done nil? -> vc-svn... Done --8<---------------cut here---------------end--------------->8--- The above trace is obtained with the following minimal Emacs file: --8<---------------cut here---------------start------------->8--- (message "Loading Minimal Emacs...") (defadvice require (around require-around) "Leave a trace of packages being loaded." (let* ((feature (ad-get-arg 0)) (require-depth (or (and (boundp 'require-depth) require-depth) 0)) (prefix (concat (make-string (* 2 require-depth) ? ) ""))) (cond ((featurep feature) (message "%s%s -> %s... Done" ;; already loaded prefix (if load-file-name (file-name-base load-file-name) "nil?") feature) (setq ad-return-value feature)) (t (let ((lvn/time-start)) (message "%s%s -> %s..." prefix (if load-file-name (file-name-base load-file-name) "nil?") feature) (setq lvn/time-start (float-time)) (let ((require-depth (1+ require-depth))) ad-do-it) (message "%s%s -> %s... Done" prefix (if load-file-name (file-name-base load-file-name) "nil?") feature)))))) (ad-activate 'require) (message "Loading Minimal Emacs... Done") --8<---------------cut here---------------end--------------->8--- launched with the command `emacs -q -l .emacs-minimal.el'. In the above session, I just opened a random `.org' file... Any idea on (how to get) who is requiring packages such as: - org-bbdb, - org-bibtex, - org-docview, - org-gnus, - org-info, - org-jsinfo, - org-irc, - org-mew, - org-mhe, - org-rmail, - org-vm, - org-w3m, - org-wl, and - vc-svn? Writing it down, I just realize that all the `org-*' packages here are the ones in `org-modules'. In fact, that's `org.el' who's requiring them: --8<---------------cut here---------------start------------->8--- (defun org-load-modules-maybe (&optional force) "Load all extensions listed in `org-modules'." (when (or force (not org-modules-loaded)) (mapc (lambda (ext) (condition-case nil (require ext) (error (message "Problems while trying to load feature `%s'" ext)))) org-modules) (setq org-modules-loaded t))) --8<---------------cut here---------------end--------------->8--- Why isn't `load-file-name' set to `org.el' in this case, then? No idea, neither, for `vc-svn'... Who required it? Who's hidden under the alias nil, here? Best regards, Seb -- Sebastien Vauban