* Failing to advice `require'
@ 2012-08-20 15:30 Sebastien Vauban
2012-08-21 0:12 ` Barry Margolin
0 siblings, 1 reply; 5+ messages in thread
From: Sebastien Vauban @ 2012-08-20 15:30 UTC (permalink / raw)
To: help-gnu-emacs-mXXj517/zsQ
Hello,
I tried to advice the require function, in order to get:
- performance information (load time)
- call graph of `require'
with the following code:
--8<---------------cut here---------------start------------->8---
(defvar my/require-depth 0)
(defadvice require (around require-around activate)
"Leave a trace of packages being loaded."
(let ((feature (ad-get-arg 0))
(filename (ad-get-arg 1))
(noerror (ad-get-arg 2))
(prefix (concat (make-string (* 2 my/require-depth) ? ) "+-> ")))
(setq my/require-depth (1+ my/require-depth))
(cond ((featurep feature)
(message "(info) %sRequiring `%s'... already loaded"
prefix feature)
)
(t
(let ((my/time-start))
(message "(info) %sRequiring `%s'..." prefix feature)
(setq my/time-start (float-time))
ad-do-it
(message "(info) %sRequiring `%s'... %s (loaded in %.2f s)"
prefix feature
(locate-library (symbol-name feature))
(- (float-time) my/time-start))
)))
(setq my/require-depth (1- my/require-depth))))
--8<---------------cut here---------------end--------------->8---
It works quite well, except for the following case:
--8<---------------cut here---------------start------------->8---
;; Requiring `auth-source'...
;; (info) +-> Requiring `password-cache'... d:/home/sva/Downloads/emacs/site-lisp/gnus/lisp/password-cache.elc (loaded in 0.11 s)
;; (info) +-> Requiring `mm-util'... already loaded
;; (info) +-> Requiring `gnus-util'... already loaded
;; (info) +-> Requiring `eieio'... already loaded [2 times]
;; byte-code: eieio not found in `load-path' or gnus-fallback-lib/ directory.
--8<---------------cut here---------------end--------------->8---
Guess what? `eieio' is in my default load path, in my GNU Emacs 24.1.1
(i386-mingw-nt5.1.2600) of 2012-06-02 on MARVIN on Windows XP.
Do you have any idea why it's failing?
Best regards,
Seb
--
Sebastien Vauban
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Failing to advice `require'
2012-08-20 15:30 Failing to advice `require' Sebastien Vauban
@ 2012-08-21 0:12 ` Barry Margolin
2012-08-21 7:24 ` Sebastien Vauban
0 siblings, 1 reply; 5+ messages in thread
From: Barry Margolin @ 2012-08-21 0:12 UTC (permalink / raw)
To: help-gnu-emacs
In article <80r4r18ttc.fsf@somewhere.org>,
"Sebastien Vauban" <wxhgmqzgwmuf@spammotel.com> wrote:
> Hello,
>
> I tried to advice the require function, in order to get:
>
> - performance information (load time)
> - call graph of `require'
>
> with the following code:
>
> --8<---------------cut here---------------start------------->8---
> (defvar my/require-depth 0)
>
> (defadvice require (around require-around activate)
> "Leave a trace of packages being loaded."
> (let ((feature (ad-get-arg 0))
> (filename (ad-get-arg 1))
> (noerror (ad-get-arg 2))
You never use filename or noerror, why do you bother binding them?
> (prefix (concat (make-string (* 2 my/require-depth) ? ) "+-> ")))
> (setq my/require-depth (1+ my/require-depth))
You should bind my/require-depth in your 'let'. Then you don't need to
restore it at the end, it will happen automatically (including if
there's an error that aborts out).
> (cond ((featurep feature)
> (message "(info) %sRequiring `%s'... already loaded"
> prefix feature)
> )
> (t
> (let ((my/time-start))
> (message "(info) %sRequiring `%s'..." prefix feature)
> (setq my/time-start (float-time))
> ad-do-it
> (message "(info) %sRequiring `%s'... %s (loaded in %.2f s)"
> prefix feature
> (locate-library (symbol-name feature))
> (- (float-time) my/time-start))
> )))
> (setq my/require-depth (1- my/require-depth))))
> --8<---------------cut here---------------end--------------->8---
>
> It works quite well, except for the following case:
>
> --8<---------------cut here---------------start------------->8---
> ;; Requiring `auth-source'...
> ;; (info) +-> Requiring `password-cache'...
> d:/home/sva/Downloads/emacs/site-lisp/gnus/lisp/password-cache.elc (loaded in
> 0.11 s)
> ;; (info) +-> Requiring `mm-util'... already loaded
> ;; (info) +-> Requiring `gnus-util'... already loaded
> ;; (info) +-> Requiring `eieio'... already loaded [2 times]
> ;; byte-code: eieio not found in `load-path' or gnus-fallback-lib/ directory.
> --8<---------------cut here---------------end--------------->8---
>
> Guess what? `eieio' is in my default load path, in my GNU Emacs 24.1.1
> (i386-mingw-nt5.1.2600) of 2012-06-02 on MARVIN on Windows XP.
>
> Do you have any idea why it's failing?
The real require returns the feature name, or nil if the package is not
found and noerror is set, yours returns various other things. You need
to ensure that you return the correct thing; 'prog1' is useful for this:
(prog1 ad-do-it
(message ...))
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Failing to advice `require'
2012-08-21 0:12 ` Barry Margolin
@ 2012-08-21 7:24 ` Sebastien Vauban
2012-08-21 9:19 ` Sylvain Rousseau
2012-08-21 14:01 ` Barry Margolin
0 siblings, 2 replies; 5+ messages in thread
From: Sebastien Vauban @ 2012-08-21 7:24 UTC (permalink / raw)
To: help-gnu-emacs-mXXj517/zsQ
Hi Barry,
Thanks for helping me...
Barry Margolin wrote:
> In article <80r4r18ttc.fsf-oHC15RC7JGTNLxjTenLetw@public.gmane.org>,
> "Sebastien Vauban" <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org> wrote:
>>
>> I tried to advice the require function, in order to get:
>>
>> - performance information (load time)
>> - call graph of `require'
>>
>> with the following code:
>>
>> (defvar my/require-depth 0)
>>
>> (defadvice require (around require-around activate)
>> "Leave a trace of packages being loaded."
>> (let ((feature (ad-get-arg 0))
>> (filename (ad-get-arg 1))
>> (noerror (ad-get-arg 2))
>
> You never use filename or noerror, why do you bother binding them?
Right.
>> (prefix (concat (make-string (* 2 my/require-depth) ? ) "+-> ")))
>> (setq my/require-depth (1+ my/require-depth))
>
> You should bind my/require-depth in your 'let'. Then you don't need to
> restore it at the end, it will happen automatically (including if
> there's an error that aborts out).
Not sure to understand, here, because I still want a global variable holding
the depth of the require calls. I'm not playing with a local variable, but
setting back and forth the value of the global var. Do I miss something?
>> (cond ((featurep feature)
>> (message "(info) %sRequiring `%s'... already loaded"
>> prefix feature)
>> )
>> (t
>> (let ((my/time-start))
>> (message "(info) %sRequiring `%s'..." prefix feature)
>> (setq my/time-start (float-time))
>> ad-do-it
>> (message "(info) %sRequiring `%s'... %s (loaded in %.2f s)"
>> prefix feature
>> (locate-library (symbol-name feature))
>> (- (float-time) my/time-start))
>> )))
>> (setq my/require-depth (1- my/require-depth))))
>>
>> It works quite well, except for the following case:
>>
>> ;; (info) +-> Requiring `eieio'... already loaded [2 times]
>> ;; byte-code: eieio not found in `load-path' or gnus-fallback-lib/ directory.
>>
>> Guess what? `eieio' is in my default load path, in my GNU Emacs 24.1.1
>> (i386-mingw-nt5.1.2600) of 2012-06-02 on MARVIN on Windows XP.
>>
>> Do you have any idea why it's failing?
>
> The real require returns the feature name, or nil if the package is not
> found and noerror is set, yours returns various other things. You need to
> ensure that you return the correct thing;
I did not think at that, yes...
> 'prog1' is useful for this:
>
> (prog1 ad-do-it
> (message ...))
Hence my new version of the code:
--8<---------------cut here---------------start------------->8---
(defadvice require (around require-around activate)
"Leave a trace of packages being loaded."
(let ((feature (ad-get-arg 0))
(prefix (concat (make-string (* 2 my/require-depth) ? ) "+-> ")))
(setq my/require-depth (1+ my/require-depth))
(cond ((featurep feature)
(message "(info) %sRequiring `%s'... already loaded"
prefix feature)
)
(t
(let ((my/time-start))
(message "(info) %sRequiring `%s'..." prefix feature)
(setq my/time-start (float-time))
(prog1
ad-do-it
(message "(info) %sRequiring `%s'... %s (loaded in %.2f s)"
prefix feature
(locate-library (symbol-name feature))
(- (float-time) my/time-start)))
)))
(setq my/require-depth (1- my/require-depth))))
--8<---------------cut here---------------end--------------->8---
Is the above what you suggested me to do?
However, with the above, I still have the same problem (here a little bit more
trace):
--8<---------------cut here---------------start------------->8---
(info) +-> Requiring `dired'...
(info) +-> Requiring `dired+'...
(info) +-> Requiring `easymenu'... already loaded
(info) +-> Requiring `dired'... already loaded
(info) +-> Requiring `dired-aux'...
(info) +-> Requiring `dired'... already loaded
(info) +-> Requiring `dired-aux'... c:/Program Files/emacs-24.1/lisp/dired-aux.elc (loaded in 0.33 s)
(info) +-> Requiring `ediff-util'... already loaded
(info) +-> Requiring `dired-x'...
(info) +-> Requiring `dired'... already loaded
(info) +-> Requiring `easymenu'... already loaded
(info) +-> Requiring `dired-x'... c:/Program Files/emacs-24.1/lisp/dired-x.elc (loaded in 0.61 s)
(info) +-> Requiring `misc-fns'... nil (loaded in 0.31 s)
(info) +-> Requiring `w32-browser'... nil (loaded in 0.28 s)
(info) +-> Requiring `dired+'... already loaded
(info) +-> Requiring `bookmark+'...
(info) +-> Requiring `bookmark'...
(info) +-> Requiring `pp'... c:/Program Files/emacs-24.1/lisp/emacs-lisp/pp.elc (loaded in 0.30 s)
(info) +-> Requiring `bookmark'... c:/Program Files/emacs-24.1/lisp/bookmark.elc (loaded in 0.63 s)
(info) Loading library `d:/home/sva/Downloads/emacs/site-lisp/bookmark+-mac.el'...
(info) Loading d:/home/sva/Downloads/emacs/site-lisp/bookmark+-mac.el...
Loading d:/home/sva/Downloads/emacs/site-lisp/bookmark+-mac.el (source)...
(info) +-> Requiring `bookmark'... already loaded
Loading d:/home/sva/Downloads/emacs/site-lisp/bookmark+-mac.el (source)...done
(info) +-> Requiring `bookmark+-lit'...
(info) +-> Requiring `cl'... already loaded
(info) +-> Requiring `bookmark'... already loaded
(info) +-> Requiring `pp+'... nil (loaded in 0.34 s)
(info) +-> Requiring `bookmark+-lit'... d:/home/sva/Downloads/emacs/site-lisp/bookmark+-lit.el (loaded in 0.67 s)
(info) +-> Requiring `bookmark+-bmu'...
(info) +-> Requiring `cl'... already loaded
(info) +-> Requiring `easymenu'... already loaded
(info) +-> Requiring `bookmark'... already loaded
(info) Loading library `d:/home/sva/Downloads/emacs/site-lisp/bookmark+-mac.el'...
(info) Loading d:/home/sva/Downloads/emacs/site-lisp/bookmark+-mac.el...
Loading d:/home/sva/Downloads/emacs/site-lisp/bookmark+-mac.el (source)...
(info) +-> Requiring `bookmark'... already loaded
Loading d:/home/sva/Downloads/emacs/site-lisp/bookmark+-mac.el (source)...done
(info) +-> Requiring `help-mode'... already loaded
(info) +-> Requiring `bookmark+-bmu'... d:/home/sva/Downloads/emacs/site-lisp/bookmark+-bmu.el (loaded in 1.08 s)
(info) +-> Requiring `bookmark+-1'...
(info) +-> Requiring `gnus'...
(info) +-> Requiring `wid-edit'... already loaded
(info) +-> Requiring `mm-util'...
(info) +-> Requiring `mail-prsvr'... d:/home/sva/Downloads/emacs/site-lisp/gnus/lisp/mail-prsvr.elc (loaded in 0.11 s)
(info) +-> Requiring `timer'... already loaded
(info) +-> Requiring `mm-util'... d:/home/sva/Downloads/emacs/site-lisp/gnus/lisp/mm-util.elc (loaded in 0.42 s)
(info) +-> Requiring `nnheader'...
(info) +-> Requiring `mail-utils'... c:/Program Files/emacs-24.1/lisp/mail/mail-utils.elc (loaded in 0.36 s)
(info) +-> Requiring `mm-util'... already loaded
(info) +-> Requiring `gnus-util'...
(info) +-> Requiring `time-date'... already loaded
(info) +-> Requiring `gnus-util'... d:/home/sva/Downloads/emacs/site-lisp/gnus/lisp/gnus-util.elc (loaded in 0.17 s)
(info) +-> Requiring `nnheader'... d:/home/sva/Downloads/emacs/site-lisp/gnus/lisp/nnheader.elc (loaded in 0.67 s)
(info) +-> Requiring `gnus-compat'...
(info) +-> Requiring `help-fns'... already loaded
(info) +-> Requiring `url'...
(info) +-> Requiring `mailcap'... d:/home/sva/Downloads/emacs/site-lisp/gnus/lisp/mailcap.elc (loaded in 0.11 s)
(info) +-> Requiring `url-vars'...
(info) +-> Requiring `mm-util'... already loaded
(info) +-> Requiring `url-vars'... c:/Program Files/emacs-24.1/lisp/url/url-vars.elc (loaded in 0.27 s)
(info) +-> Requiring `url-cookie'...
(info) +-> Requiring `url-util'...
(info) +-> Requiring `url-parse'...
(info) +-> Requiring `url-vars'... already loaded
(info) +-> Requiring `auth-source'...
(info) +-> Requiring `password-cache'... d:/home/sva/Downloads/emacs/site-lisp/gnus/lisp/password-cache.elc (loaded in 0.13 s)
(info) +-> Requiring `mm-util'... already loaded
(info) +-> Requiring `gnus-util'... already loaded
(info) +-> Requiring `eieio'... already loaded [2 times]
byte-code: eieio not found in `load-path' or gnus-fallback-lib/ directory.
--8<---------------cut here---------------end--------------->8---
Though, if I locate-lib "eieio", I get:
"d:/home/sva/Downloads/emacs/site-lisp/gnus/lisp/gnus-fallback-lib/eieio/eieio.el"
and load-path's value is:
(d:/home/sva/Downloads/emacs/site-lisp/auctex-11.86/lisp/auctex d:/home/sva/src/org-mode/testing d:/home/sva/src/org-mode/contrib/lisp d:/home/sva/src/org-mode/lisp d:/home/sva/emacs/site-lisp/yasnippet d:/home/sva/emacs/site-lisp/mode-abbrevs d:/home/sva/emacs/site-lisp/Pictures d:/home/sva/emacs/site-lisp/ d:/home/sva/Downloads/emacs/site-lisp/yasnippet/snippets/text-mode d:/home/sva/Downloads/emacs/site-lisp/yasnippet/snippets/sql-mode d:/home/sva/Downloads/emacs/site-lisp/yasnippet/snippets/snippet-mode d:/home/sva/Downloads/emacs/site-lisp/yasnippet/snippets/scala-mode d:/home/sva/Downloads/emacs/site-lisp/yasnippet/snippets/ruby-mode/general d:/home/sva/Downloads/emacs/site-lisp/yasnippet/snippets/ruby-mode/definitions d:/home/sva/Downloads/emacs/site-lisp/yasnippet/snippets/ruby-mode/control structure d:/home/sva/Downloads/emacs/site-lisp/yasnippet/snippets/ruby-mode/collections d:/home/sva/Downloads/emacs/site-lisp/yasnippet/snippets/ruby-mode d:/home/sva/Downloads/emacs/site-lisp/yasnippet/snippets/rst-mode d:/home/sva/Downloads/emacs/site-lisp/yasnippet/snippets/root/c++-mode d:/home/sva/Downloads/emacs/site-lisp/yasnippet/snippets/root d:/home/sva/Downloads/emacs/site-lisp/yasnippet/snippets/python-mode d:/home/sva/Downloads/emacs/site-lisp/yasnippet/snippets/perl-mode d:/home/sva/Downloads/emacs/site-lisp/yasnippet/snippets/objc-mode d:/home/sva/Downloads/emacs/site-lisp/yasnippet/snippets/nxml-mode/meta d:/home/sva/Downloads/emacs/site-lisp/yasnippet/snippets/nxml-mode/header d:/home/sva/Downloads/emacs/site-lisp/yasnippet/snippets/nxml-mode d:/home/sva/Downloads/emacs/site-lisp/yasnippet/snippets/markdown-mode d:/home/sva/Downloads/emacs/site-lisp/yasnippet/snippets/latex-mode d:/home/sva/Downloads/emacs/site-lisp/yasnippet/snippets/html-mode/table d:/home/sva/Downloads/emacs/site-lisp/yasnippet/snippets/html-mode/meta d:/home/sva/Downloads/emacs/site-lisp/yasnippet/snippets/html-mode/list d:/home/sva/Downloads/emacs/site-lisp/yasnippet/snippets/html-mode/header d:/home/sva/Downloads/emacs/site-lisp/yasnippet/snippets/html-mode d:/home/sva/Downloads/emacs/site-lisp/yasnippet/snippets/f90-mode d:/home/sva/Downloads/emacs/site-lisp/yasnippet/snippets/erlang-mode d:/home/sva/Downloads/emacs/site-lisp/yasnippet/snippets/emacs-lisp-mode d:/home/sva/Downloads/emacs/site-lisp/yasnippet/snippets/css-mode d:/home/sva/Downloads/emacs/site-lisp/yasnippet/snippets/csharp-mode d:/home/sva/Downloads/emacs/site-lisp/yasnippet/snippets/cperl-mode d:/home/sva/Downloads/emacs/site-lisp/yasnippet/snippets/cc-mode d:/home/sva/Downloads/emacs/site-lisp/yasnippet/snippets/c-mode d:/home/sva/Downloads/emacs/site-lisp/yasnippet/snippets d:/home/sva/Downloads/emacs/site-lisp/yasnippet/extras/imported/ruby-mode d:/home/sva/Downloads/emacs/site-lisp/yasnippet/extras/imported/rails-mode d:/home/sva/Downloads/emacs/site-lisp/yasnippet/extras/imported/objc-mode/Support d:/home/sva/Downloads/emacs/site-lisp/yasnippet/extras/imported/objc-mode d:/home/sva/Downloads/emacs/site-lisp/yasnippet/extras/imported/html-mode d:/home/sva/Downloads/emacs/site-lisp/yasnippet/extras/imported d:/home/sva/Downloads/emacs/site-lisp/yasnippet/extras/bundles/ruby-tmbundle d:/home/sva/Downloads/emacs/site-lisp/yasnippet/extras/bundles/rails-tmbundle d:/home/sva/Downloads/emacs/site-lisp/yasnippet/extras/bundles/html-tmbundle d:/home/sva/Downloads/emacs/site-lisp/yasnippet/extras/bundles d:/home/sva/Downloads/emacs/site-lisp/yasnippet/extras d:/home/sva/Downloads/emacs/site-lisp/yasnippet/doc/images d:/home/sva/Downloads/emacs/site-lisp/yasnippet/doc d:/home/sva/Downloads/emacs/site-lisp/yasnippet d:/home/sva/Downloads/emacs/site-lisp/yas-jit.el d:/home/sva/Downloads/emacs/site-lisp/redshank/_darcs/pristine.hashed d:/home/sva/Downloads/emacs/site-lisp/redshank/_darcs/prefs d:/home/sva/Downloads/emacs/site-lisp/redshank/_darcs/patches d:/home/sva/Downloads/emacs/site-lisp/redshank/_darcs/inventories d:/home/sva/Downloads/emacs/site-lisp/redshank/_darcs d:/home/sva/Downloads/emacs/site-lisp/redshank d:/home/sva/Downloads/emacs/site-lisp/helm/doc d:/home/sva/Downloads/emacs/site-lisp/helm d:/home/sva/Downloads/emacs/site-lisp/gnus/www/git.gnus.org d:/home/sva/Downloads/emacs/site-lisp/gnus/www d:/home/sva/Downloads/emacs/site-lisp/gnus/texi/xface d:/home/sva/Downloads/emacs/site-lisp/gnus/texi/smilies d:/home/sva/Downloads/emacs/site-lisp/gnus/texi/screen d:/home/sva/Downloads/emacs/site-lisp/gnus/texi/ps d:/home/sva/Downloads/emacs/site-lisp/gnus/texi/picons d:/home/sva/Downloads/emacs/site-lisp/gnus/texi/misc d:/home/sva/Downloads/emacs/site-lisp/gnus/texi/herds d:/home/sva/Downloads/emacs/site-lisp/gnus/texi/etc d:/home/sva/Downloads/emacs/site-lisp/gnus/texi d:/home/sva/Downloads/emacs/site-lisp/gnus/lisp/tests d:/home/sva/Downloads/emacs/site-lisp/gnus/lisp/gnus-fallback-lib/eieio d:/home/sva/Downloads/emacs/site-lisp/gnus/lisp/gnus-fallback-lib d:/home/sva/Downloads/emacs/site-lisp/gnus/lisp d:/home/sva/Downloads/emacs/site-lisp/gnus/etc/images/smilies/medium d:/home/sva/Downloads/emacs/site-lisp/gnus/etc/images/smilies/grayscale d:/home/sva/Downloads/emacs/site-lisp/gnus/etc/images/smilies d:/home/sva/Downloads/emacs/site-lisp/gnus/etc/images/mail d:/home/sva/Downloads/emacs/site-lisp/gnus/etc/images/gnus d:/home/sva/Downloads/emacs/site-lisp/gnus/etc/images d:/home/sva/Downloads/emacs/site-lisp/gnus/etc/gnus d:/home/sva/Downloads/emacs/site-lisp/gnus/etc d:/home/sva/Downloads/emacs/site-lisp/gnus/contrib d:/home/sva/Downloads/emacs/site-lisp/gnus d:/home/sva/Downloads/emacs/site-lisp/gnuplot-mode.0.6.0/auto d:/home/sva/Downloads/emacs/site-lisp/gnuplot-mode.0.6.0/Win9x d:/home/sva/Downloads/emacs/site-lisp/gnuplot-mode.0.6.0 d:/home/sva/Downloads/emacs/site-lisp/fuzzy-el d:/home/sva/Downloads/emacs/site-lisp/ess-12.04/lisp/tmp d:/home/sva/Downloads/emacs/site-lisp/ess-12.04/lisp d:/home/sva/Downloads/emacs/site-lisp/ess-12.04/fontlock-test d:/home/sva/Downloads/emacs/site-lisp/ess-12.04/etc/other/S-spread d:/home/sva/Downloads/emacs/site-lisp/ess-12.04/etc/other d:/home/sva/Downloads/emacs/site-lisp/ess-12.04/etc/icons d:/home/sva/Downloads/emacs/site-lisp/ess-12.04/etc d:/home/sva/Downloads/emacs/site-lisp/ess-12.04/doc/refcard d:/home/sva/Downloads/emacs/site-lisp/ess-12.04/doc/info d:/home/sva/Downloads/emacs/site-lisp/ess-12.04/doc/images/icons d:/home/sva/Downloads/emacs/site-lisp/ess-12.04/doc/images d:/home/sva/Downloads/emacs/site-lisp/ess-12.04/doc/html d:/home/sva/Downloads/emacs/site-lisp/ess-12.04/doc d:/home/sva/Downloads/emacs/site-lisp/ess-12.04/debian/source d:/home/sva/Downloads/emacs/site-lisp/ess-12.04/debian d:/home/sva/Downloads/emacs/site-lisp/ess-12.04/LDA d:/home/sva/Downloads/emacs/site-lisp/ess-12.04 d:/home/sva/Downloads/emacs/site-lisp/emacs-w3m/shimbun/CVS d:/home/sva/Downloads/emacs/site-lisp/emacs-w3m/shimbun d:/home/sva/Downloads/emacs/site-lisp/emacs-w3m/patches/CVS d:/home/sva/Downloads/emacs/site-lisp/emacs-w3m/patches d:/home/sva/Downloads/emacs/site-lisp/emacs-w3m/icons30/CVS d:/home/sva/Downloads/emacs/site-lisp/emacs-w3m/icons30 d:/home/sva/Downloads/emacs/site-lisp/emacs-w3m/icons/CVS d:/home/sva/Downloads/emacs/site-lisp/emacs-w3m/icons d:/home/sva/Downloads/emacs/site-lisp/emacs-w3m/doc/CVS d:/home/sva/Downloads/emacs/site-lisp/emacs-w3m/doc d:/home/sva/Downloads/emacs/site-lisp/emacs-w3m/attic/CVS d:/home/sva/Downloads/emacs/site-lisp/emacs-w3m/attic d:/home/sva/Downloads/emacs/site-lisp/emacs-w3m/CVS d:/home/sva/Downloads/emacs/site-lisp/emacs-w3m d:/home/sva/Downloads/emacs/site-lisp/emacs-calfw d:/home/sva/Downloads/emacs/site-lisp/emacs-bookmark-extension/contrib d:/home/sva/Downloads/emacs/site-lisp/emacs-bookmark-extension d:/home/sva/Downloads/emacs/site-lisp/ecb-2.40/info-help d:/home/sva/Downloads/emacs/site-lisp/ecb-2.40/html-help d:/home/sva/Downloads/emacs/site-lisp/ecb-2.40/ecb-images/sources/height-14_to_21 d:/home/sva/Downloads/emacs/site-lisp/ecb-2.40/ecb-images/sources d:/home/sva/Downloads/emacs/site-lisp/ecb-2.40/ecb-images/methods/height-21 d:/home/sva/Downloads/emacs/site-lisp/ecb-2.40/ecb-images/methods/height-20 d:/home/sva/Downloads/emacs/site-lisp/ecb-2.40/ecb-images/methods/height-19 d:/home/sva/Downloads/emacs/site-lisp/ecb-2.40/ecb-images/methods/height-18 d:/home/sva/Downloads/emacs/site-lisp/ecb-2.40/ecb-images/methods/height-17 d:/home/sva/Downloads/emacs/site-lisp/ecb-2.40/ecb-images/methods/height-16 d:/home/sva/Downloads/emacs/site-lisp/ecb-2.40/ecb-images/methods/height-15 d:/home/sva/Downloads/emacs/site-lisp/ecb-2.40/ecb-images/methods/height-14_to_21 d:/home/sva/Downloads/emacs/site-lisp/ecb-2.40/ecb-images/methods d:/home/sva/Downloads/emacs/site-lisp/ecb-2.40/ecb-images/directories/height-21 d:/home/sva/Downloads/emacs/site-lisp/ecb-2.40/ecb-images/directories/height-20 d:/home/sva/Downloads/emacs/site-lisp/ecb-2.40/ecb-images/directories/height-19 d:/home/sva/Downloads/emacs/site-lisp/ecb-2.40/ecb-images/directories/height-18 d:/home/sva/Downloads/emacs/site-lisp/ecb-2.40/ecb-images/directories/height-17 d:/home/sva/Downloads/emacs/site-lisp/ecb-2.40/ecb-images/directories/height-16 d:/home/sva/Downloads/emacs/site-lisp/ecb-2.40/ecb-images/directories/height-15 d:/home/sva/Downloads/emacs/site-lisp/ecb-2.40/ecb-images/directories/height-14 d:/home/sva/Downloads/emacs/site-lisp/ecb-2.40/ecb-images/directories/height-10 d:/home/sva/Downloads/emacs/site-lisp/ecb-2.40/ecb-images/directories d:/home/sva/Downloads/emacs/site-lisp/ecb-2.40/ecb-images/default/height-21 d:/home/sva/Downloads/emacs/site-lisp/ecb-2.40/ecb-images/default/height-20 d:/home/sva/Downloads/emacs/site-lisp/ecb-2.40/ecb-images/default/height-19 d:/home/sva/Downloads/emacs/site-lisp/ecb-2.40/ecb-images/default/height-18 d:/home/sva/Downloads/emacs/site-lisp/ecb-2.40/ecb-images/default/height-17 d:/home/sva/Downloads/emacs/site-lisp/ecb-2.40/ecb-images/default/height-16 d:/home/sva/Downloads/emacs/site-lisp/ecb-2.40/ecb-images/default/height-15 d:/home/sva/Downloads/emacs/site-lisp/ecb-2.40/ecb-images/default/height-14 d:/home/sva/Downloads/emacs/site-lisp/ecb-2.40/ecb-images/default/height-10 d:/home/sva/Downloads/emacs/site-lisp/ecb-2.40/ecb-images/default d:/home/sva/Downloads/emacs/site-lisp/ecb-2.40/ecb-images d:/home/sva/Downloads/emacs/site-lisp/ecb-2.40 d:/home/sva/Downloads/emacs/site-lisp/dictionary-1.8.7/deb d:/home/sva/Downloads/emacs/site-lisp/dictionary-1.8.7 d:/home/sva/Downloads/emacs/site-lisp/dictem-0.81 d:/home/sva/Downloads/emacs/site-lisp/deft d:/home/sva/Downloads/emacs/site-lisp/color-theme-leuven d:/home/sva/Downloads/emacs/site-lisp/color-theme-6.6.0/themes d:/home/sva/Downloads/emacs/site-lisp/color-theme-6.6.0 d:/home/sva/Downloads/emacs/site-lisp/circe-cvs/scripts/CVS d:/home/sva/Downloads/emacs/site-lisp/circe-cvs/scripts d:/home/sva/Downloads/emacs/site-lisp/circe-cvs/CVS d:/home/sva/Downloads/emacs/site-lisp/circe-cvs d:/home/sva/Downloads/emacs/site-lisp/bbdb/tex d:/home/sva/Downloads/emacs/site-lisp/bbdb/lisp d:/home/sva/Downloads/emacs/site-lisp/bbdb/doc d:/home/sva/Downloads/emacs/site-lisp/bbdb d:/home/sva/Downloads/emacs/site-lisp/babel d:/home/sva/Downloads/emacs/site-lisp/auto-complete-1.3.1/etc d:/home/sva/Downloads/emacs/site-lisp/auto-complete-1.3.1/doc d:/home/sva/Downloads/emacs/site-lisp/auto-complete-1.3.1/dict d:/home/sva/Downloads/emacs/site-lisp/auto-complete-1.3.1 d:/home/sva/Downloads/emacs/site-lisp/auctex-11.86/var d:/home/sva/Downloads/emacs/site-lisp/auctex-11.86/share/info d:/home/sva/Downloads/emacs/site-lisp/auctex-11.86/share/doc/auctex d:/home/sva/Downloads/emacs/site-lisp/auctex-11.86/share/doc d:/home/sva/Downloads/emacs/site-lisp/auctex-11.86/share d:/home/sva/Downloads/emacs/site-lisp/auctex-11.86/preview/tex/latex/preview d:/home/sva/Downloads/emacs/site-lisp/auctex-11.86/preview/tex/latex d:/home/sva/Downloads/emacs/site-lisp/auctex-11.86/preview/tex d:/home/sva/Downloads/emacs/site-lisp/auctex-11.86/preview/doc/latex/styles d:/home/sva/Downloads/emacs/site-lisp/auctex-11.86/preview/doc/latex d:/home/sva/Downloads/emacs/site-lisp/auctex-11.86/preview/doc d:/home/sva/Downloads/emacs/site-lisp/auctex-11.86/preview d:/home/sva/Downloads/emacs/site-lisp/auctex-11.86/lisp d:/home/sva/Downloads/emacs/site-lisp/auctex-11.86 d:/home/sva/Downloads/emacs/site-lisp/asp-mode d:/home/sva/Downloads/emacs/site-lisp/1345100_files d:/home/sva/Downloads/emacs/site-lisp/ ~/Public/GitHub/emacs-leuven c:/Program Files/emacs-24.1/site-lisp C:/Program Files/emacs-24.1/../site-lisp C:/Program Files/emacs-24.1/lisp c:/Program Files/emacs-24.1/lisp/vc c:/Program Files/emacs-24.1/lisp/url c:/Program Files/emacs-24.1/lisp/textmodes c:/Program Files/emacs-24.1/lisp/progmodes c:/Program Files/emacs-24.1/lisp/play c:/Program Files/emacs-24.1/lisp/org c:/Program Files/emacs-24.1/lisp/nxml c:/Program Files/emacs-24.1/lisp/net c:/Program Files/emacs-24.1/lisp/mh-e c:/Program Files/emacs-24.1/lisp/mail c:/Program Files/emacs-24.1/lisp/language c:/Program Files/emacs-24.1/lisp/international c:/Program Files/emacs-24.1/lisp/gnus c:/Program Files/emacs-24.1/lisp/eshell c:/Program Files/emacs-24.1/lisp/erc c:/Program Files/emacs-24.1/lisp/emulation c:/Program Files/emacs-24.1/lisp/emacs-lisp c:/Program Files/emacs-24.1/lisp/cedet c:/Program Files/emacs-24.1/lisp/calendar c:/Program Files/emacs-24.1/lisp/calc c:/Program Files/emacs-24.1/lisp/obsolete C:/Program Files/emacs-24.1/leim)
Any new idea on this?
Best regards,
Seb
PS- I know my load-path is a big longish, but it's the result of recursively
add all subdirs to the load-path variable.
--
Sebastien Vauban
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Failing to advice `require'
2012-08-21 7:24 ` Sebastien Vauban
@ 2012-08-21 9:19 ` Sylvain Rousseau
2012-08-21 14:01 ` Barry Margolin
1 sibling, 0 replies; 5+ messages in thread
From: Sylvain Rousseau @ 2012-08-21 9:19 UTC (permalink / raw)
To: Sebastien Vauban; +Cc: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 1329 bytes --]
The adviced require still not has the right signature, in the case ad-do-it
is not called, you have to set the return value yourself!
(setq ad-return-value feature)
in your case.
You can also get rid of the defvar but it's a little far fetched. Here is
what I come up with:
(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 "(info) %sRequiring `%s'... already loaded"
prefix feature)
(setq ad-return-value feature))
(t
(let ((my/time-start))
(message "(info) %sRequiring `%s'..." prefix feature)
(setq my/time-start (float-time))
(let ((require-depth (1+ require-depth)))
ad-do-it)
(message "(info) %sRequiring `%s'... %s (loaded in %.2f s)"
prefix feature
(locate-library (symbol-name feature))
(- (float-time) my/time-start)))))))
(ad-activate 'require)
Anyway, very useful advice! Let me know if it works with this version.
[-- Attachment #2: Type: text/html, Size: 1525 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Failing to advice `require'
2012-08-21 7:24 ` Sebastien Vauban
2012-08-21 9:19 ` Sylvain Rousseau
@ 2012-08-21 14:01 ` Barry Margolin
1 sibling, 0 replies; 5+ messages in thread
From: Barry Margolin @ 2012-08-21 14:01 UTC (permalink / raw)
To: help-gnu-emacs
In article <80zk5ou2r0.fsf@somewhere.org>,
"Sebastien Vauban" <wxhgmqzgwmuf@spammotel.com> wrote:
> Hi Barry,
>
> Thanks for helping me...
>
> Barry Margolin wrote:
> > In article <80r4r18ttc.fsf@somewhere.org>,
> > "Sebastien Vauban" <wxhgmqzgwmuf@spammotel.com> wrote:
> >>
> >> I tried to advice the require function, in order to get:
> >>
> >> - performance information (load time)
> >> - call graph of `require'
> >>
> >> with the following code:
> >>
> >> (defvar my/require-depth 0)
> >>
> >> (defadvice require (around require-around activate)
> >> "Leave a trace of packages being loaded."
> >> (let ((feature (ad-get-arg 0))
> >> (filename (ad-get-arg 1))
> >> (noerror (ad-get-arg 2))
> >
> > You never use filename or noerror, why do you bother binding them?
>
> Right.
>
> >> (prefix (concat (make-string (* 2 my/require-depth) ? ) "+->
> >> ")))
> >> (setq my/require-depth (1+ my/require-depth))
> >
> > You should bind my/require-depth in your 'let'. Then you don't need to
> > restore it at the end, it will happen automatically (including if
> > there's an error that aborts out).
>
> Not sure to understand, here, because I still want a global variable holding
> the depth of the require calls. I'm not playing with a local variable, but
> setting back and forth the value of the global var. Do I miss something?
You can use 'let' to temporarily bind a global variable. This is a
feature of dynamic scoping.
>
> >> (cond ((featurep feature)
> >> (message "(info) %sRequiring `%s'... already loaded"
> >> prefix feature)
> >> )
> >> (t
> >> (let ((my/time-start))
> >> (message "(info) %sRequiring `%s'..." prefix feature)
> >> (setq my/time-start (float-time))
> >> ad-do-it
> >> (message "(info) %sRequiring `%s'... %s (loaded in %.2f s)"
> >> prefix feature
> >> (locate-library (symbol-name feature))
> >> (- (float-time) my/time-start))
> >> )))
> >> (setq my/require-depth (1- my/require-depth))))
> >>
> >> It works quite well, except for the following case:
> >>
> >> ;; (info) +-> Requiring `eieio'... already loaded [2 times]
> >> ;; byte-code: eieio not found in `load-path' or gnus-fallback-lib/
> >> directory.
> >>
> >> Guess what? `eieio' is in my default load path, in my GNU Emacs 24.1.1
> >> (i386-mingw-nt5.1.2600) of 2012-06-02 on MARVIN on Windows XP.
> >>
> >> Do you have any idea why it's failing?
> >
> > The real require returns the feature name, or nil if the package is not
> > found and noerror is set, yours returns various other things. You need to
> > ensure that you return the correct thing;
>
> I did not think at that, yes...
>
> > 'prog1' is useful for this:
> >
> > (prog1 ad-do-it
> > (message ...))
>
> Hence my new version of the code:
>
> --8<---------------cut here---------------start------------->8---
> (defadvice require (around require-around activate)
> "Leave a trace of packages being loaded."
> (let ((feature (ad-get-arg 0))
> (prefix (concat (make-string (* 2 my/require-depth) ? ) "+->
> ")))
> (setq my/require-depth (1+ my/require-depth))
> (cond ((featurep feature)
> (message "(info) %sRequiring `%s'... already loaded"
> prefix feature)
> )
> (t
> (let ((my/time-start))
> (message "(info) %sRequiring `%s'..." prefix feature)
> (setq my/time-start (float-time))
> (prog1
> ad-do-it
> (message "(info) %sRequiring `%s'... %s (loaded in
> %.2f s)"
> prefix feature
> (locate-library (symbol-name feature))
> (- (float-time) my/time-start)))
> )))
> (setq my/require-depth (1- my/require-depth))))
> --8<---------------cut here---------------end--------------->8---
>
> Is the above what you suggested me to do?
You're still not returning the feature name in the case where the
feature is already loaded.
>
> However, with the above, I still have the same problem (here a little bit
> more
> trace):
I don't really know if the above issue is related to the error you're
getting. Maybe you should enable debugging.
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-08-21 14:01 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-20 15:30 Failing to advice `require' Sebastien Vauban
2012-08-21 0:12 ` Barry Margolin
2012-08-21 7:24 ` Sebastien Vauban
2012-08-21 9:19 ` Sylvain Rousseau
2012-08-21 14:01 ` Barry Margolin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).