bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#5301: 23.1; unload-feature remove defadvice


From: Kevin Ryde
Subject: bug#5301: 23.1; unload-feature remove defadvice
Date: Mon, 04 Jan 2010 10:27:54 +1100
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.1 (gnu/linux)

As an idea, it'd be good if defadvice were among the `def' things
automatically unloaded by `unload-feature'.

A defadvice will nearly always use functions or whatever in the defining
package and if they've been unloaded it could leave the advised target
function badly broken.

I know it's possible for a foo-unload-function to undo its defadvices.
I've done that for some of my things, but it gets very repetitive and
makes me think defadvice could set that up itself.

I know advice is a slightly second class citizen, but if the necessary
unloading stuff were confined to advice.el then it needn't be a burden
if no advise is in use.

My best idea so far would be for defadvice to record something in
load-history like

    (defadvice . (TARGET CLASS AD-NAME))

if it could beg a tie-in to unload-feature at a good spot.  Something
indirect like a property setting on the `defadvice' symbol appearing in
the load-history might let other `def' macros jig up unloading for
themselves in a general way.

    ;; untested!
    (put 'defadvice 'load-history-unload-feature-function
         (lambda (elem)
           (when (apply 'ad-find-advice (cdr elem))
             (apply 'ad-remove-advice (cdr elem))
             (ad-activate (cadr elem)))))

May have to think about what happens if the package defining the `def'
macro is unloaded when things it has `def'fed still exist.  But if
`require's express dependencies correctly that might never arise.



In GNU Emacs 23.1.1 (i486-pc-linux-gnu, GTK+ Version 2.16.5)
 of 2009-09-14 on raven, modified by Debian
configured using `configure  '--build=i486-linux-gnu' '--host=i486-linux-gnu' 
'--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib' 
'--localstatedir=/var/lib' '--infodir=/usr/share/info' 
'--mandir=/usr/share/man' '--with-pop=yes' 
'--enable-locallisppath=/etc/emacs23:/etc/emacs:/usr/local/share/emacs/23.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/23.1/site-lisp:/usr/share/emacs/site-lisp:/usr/share/emacs/23.1/leim'
 '--with-x=yes' '--with-x-toolkit=gtk' '--with-toolkit-scroll-bars' 
'build_alias=i486-linux-gnu' 'host_alias=i486-linux-gnu' 'CFLAGS=-DDEBIAN -g 
-O2' 'LDFLAGS=-g' 'CPPFLAGS=''







reply via email to

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