GNU bug report logs - #5301
23.1; unload-feature remove defadvice

Previous Next

Package: emacs;

Reported by: Kevin Ryde <user42 <at> zip.com.au>

Date: Sun, 3 Jan 2010 23:29:01 UTC

Severity: wishlist

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Kevin Ryde <user42 <at> zip.com.au>
To: bug-gnu-emacs <at> gnu.org
Subject: 23.1; unload-feature remove defadvice
Date: Mon, 04 Jan 2010 10:27:54 +1100
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=''





This bug report was last modified 15 years and 151 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.