From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: michael@cadilhac.name (=?iso-8859-1?Q?Micha=EBl?= Cadilhac) Newsgroups: gmane.emacs.devel Subject: ad-remove-advice bug. Date: Wed, 07 Mar 2007 15:36:53 +0100 Organization: Epita/LRDE Message-ID: <878xe9t916.fsf@lrde.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1445047668==" X-Trace: sea.gmane.org 1173278323 32274 80.91.229.12 (7 Mar 2007 14:38:43 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 7 Mar 2007 14:38:43 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Mar 07 15:38:33 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1HOxHg-0003D2-Hf for ged-emacs-devel@m.gmane.org; Wed, 07 Mar 2007 15:38:29 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HOxHm-0000Er-CT for ged-emacs-devel@m.gmane.org; Wed, 07 Mar 2007 09:38:34 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HOxGL-0008Fm-Ez for emacs-devel@gnu.org; Wed, 07 Mar 2007 09:37:05 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HOxGJ-0008F0-O7 for emacs-devel@gnu.org; Wed, 07 Mar 2007 09:37:05 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HOxGJ-0008Ew-JH for emacs-devel@gnu.org; Wed, 07 Mar 2007 09:37:03 -0500 Original-Received: from smtp3-g19.free.fr ([212.27.42.29]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1HOxGC-0003pw-8H for emacs-devel@gnu.org; Wed, 07 Mar 2007 09:36:56 -0500 Original-Received: from localhost (ivr94-6-82-230-255-91.fbx.proxad.net [82.230.255.91]) by smtp3-g19.free.fr (Postfix) with ESMTP id E904282C5 for ; Wed, 7 Mar 2007 15:36:54 +0100 (CET) X-Website: http://michael.cadilhac.name Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAElBMVEVWPh+Tai+5r5YKBAEU CQQzGAtiq7gjAAACR0lEQVQ4jW2UzW7lIAyFzVW8BzTZX5DmCZLuU2H2pMXv/ypzbK7aSh2kRCRf /HNsE0q7Sg+RQ7JFKaqtrRNAl5AIIKe6D5DBqgbmUAe5hBI1wIRFAHjeM0RKtZi7XVVEpb0BSNfA IddChChT5DildSLWOWhY5IEItMnncZgFcUAc/5jjwCMsDosRNdfKPDTFEdVBW8C+RebDb4N5Orio RhM1+11IJyx0ng2+LryFHBMPDQDYHrY6IfGuU3ouiXTQNE8LIJDKOWpNxERTFrggQwRPd7USUsTW fJ0XbR3bdj5KgBYy4SACpxDeUYEUAzLmtJ1iIrD2gczPq8Qomjhsh/RjGIgKIO8p7NITjwlx7WID nsnQe5NeuTvoBpi8LX6vLLOh5icjOHqBypgnuSp7M+RE1agbQKHQr5E2z1WObhYW4gMqeGQL7joM jCf2DxSk5ApADSYHfFF4igNfJZL1z0GKP0FN02s4XiDXr7V5P94W6I9v8MfBOQDmfwAaVYt+x8Da v4DJvX8BAdin3Knm5yMZYAO4ABDkDniZLLfi4P40gP1F0TPGZOu0CGwA1lcowxwlGy6A9705mD0V jHCxwVZT/hYdRJVUGZNlx6l7ScQBTluof6Wj6bsPYlvpwoTvXFD9gHPn2TZPF3ntI2ecxVrW5MrV XiCie5EeNa7BlWu/HNSkprDUva163PHxAv5jyGV7gVzyAghSKOTnat85UIYFICXbD2NV9rRiv0BS tKQsg6OHH4A15F1WW+UHKHHa32h6aPnAm3/pUcWp+WYnTQAAAABJRU5ErkJggg== User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.95 (gnu/linux) X-detected-kernel: Linux 2.4-2.6 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:67503 Archived-At: --===============1445047668== Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Hi! Here's a bug with advices. Test case : $ emacs -Q M-: (defadvice forward-line (before foo activate)) M-x describe-function RET forward-line RET prints: | | This subr is advised. | | Before-advice `foo'. `-------------------------- Now, use M-x ad-remove-advice RET RET RET RET (the default each time) There's two annoying things : 1. M-x describe-function RET forward-line RET says : | This subr is advised. `-------------------------- although there's no more advice, 2. M-x ad-remove-advice default values are impossible. I propose this (maybe too heavy, only parts may suffice) change: --=-=-= Content-Type: text/x-patch; charset=iso-8859-1 Content-Disposition: inline; filename=advice.patch Content-Transfer-Encoding: quoted-printable Index: lisp/emacs-lisp/advice.el =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /sources/emacs/emacs/lisp/emacs-lisp/advice.el,v retrieving revision 1.49 diff -B -w -c -r1.49 advice.el *** lisp/emacs-lisp/advice.el 21 Jan 2007 02:44:24 -0000 1.49 =2D-- lisp/emacs-lisp/advice.el 7 Mar 2007 14:03:11 -0000 *************** *** 2022,2030 **** (defmacro ad-copy-advice-info (function) `(ad-copy-tree (get ,function 'ad-advice-info))) =20=20 ! (defmacro ad-is-advised (function) "Return non-nil if FUNCTION has any advice info associated with it. ! This does not mean that the advice is also active." (list 'ad-get-advice-info function)) =20=20 (defun ad-initialize-advice-info (function) =2D-- 2022,2040 ---- (defmacro ad-copy-advice-info (function) `(ad-copy-tree (get ,function 'ad-advice-info))) =20=20 ! (defun ad-is-advised (function) ! "Return non-nil if FUNCTION has any advice code associated with it. ! This does not mean that the advice is also active, but that one of the ! advice classes of FUNCTION is not empty." ! (catch 'not-empty ! (ad-dolist (class ad-advice-classes nil) ! (when (ad-get-advice-info-field function class) ! (throw 'not-empty t))))) !=20 ! (defmacro ad-has-advice-info (function) "Return non-nil if FUNCTION has any advice info associated with it. ! This does not mean that the advice has any function, but that advice ! machinery is installed for this function." (list 'ad-get-advice-info function)) =20=20 (defun ad-initialize-advice-info (function) *************** *** 2039,2045 **** =20=20 (defun ad-set-advice-info-field (function field value) "Destructively modify VALUE of the advice info FIELD of FUNCTION." ! (and (ad-is-advised function) (cond ((assq field (ad-get-advice-info function)) ;; A field with that name is already present: (rplacd (assq field (ad-get-advice-info function)) value)) =2D-- 2049,2055 ---- =20=20 (defun ad-set-advice-info-field (function field value) "Destructively modify VALUE of the advice info FIELD of FUNCTION." ! (and (ad-has-advice-info function) (cond ((assq field (ad-get-advice-info function)) ;; A field with that name is already present: (rplacd (assq field (ad-get-advice-info function)) value)) *************** *** 2411,2419 **** =2D-- 2421,2433 ---- (if (ad-is-advised function) (let ((advice-to-remove (ad-find-advice function class name))) (if advice-to-remove + (progn (ad-set-advice-info-field function class (delq advice-to-remove (ad-get-advice-info-field function class))) + ;; If the function now has no advice, remove the machinery. + (unless (ad-is-advised function) + (ad-unadvise function))) (error "ad-remove-advice: `%s' has no %s advice `%s'" function class name))) (error "ad-remove-advice: `%s' is not advised" function))) *************** *** 2431,2437 **** If the FUNCTION was not advised already, then its advice info will be initialized. Redefining a piece of advice whose name is part of the cach= e-id will clear the cache." ! (cond ((not (ad-is-advised function)) (ad-initialize-advice-info function) (ad-set-advice-info-field function 'origname (ad-make-origname function)))) =2D-- 2445,2451 ---- If the FUNCTION was not advised already, then its advice info will be initialized. Redefining a piece of advice whose name is part of the cach= e-id will clear the cache." ! (cond ((not (ad-has-advice-info function)) (ad-initialize-advice-info function) (ad-set-advice-info-field function 'origname (ad-make-origname function)))) *************** *** 3636,3642 **** a call to `ad-activate'." (interactive (list (ad-read-advised-function "Deactivate advice of" 'ad-is-active))) ! (if (not (ad-is-advised function)) (error "ad-deactivate: `%s' is not advised" function) (cond ((ad-is-active function) (ad-handle-definition function) =2D-- 3650,3656 ---- a call to `ad-activate'." (interactive (list (ad-read-advised-function "Deactivate advice of" 'ad-is-active))) ! (if (not (ad-has-advice-info function)) (error "ad-deactivate: `%s' is not advised" function) (cond ((ad-is-active function) (ad-handle-definition function) *************** *** 3662,3668 **** If FUNCTION was not advised this will be a noop." (interactive (list (ad-read-advised-function "Unadvise function"))) ! (cond ((ad-is-advised function) (if (ad-is-active function) (ad-deactivate function)) (ad-clear-orig-definition function) =2D-- 3676,3682 ---- If FUNCTION was not advised this will be a noop." (interactive (list (ad-read-advised-function "Unadvise function"))) ! (cond ((ad-has-advice-info function) (if (ad-is-active function) (ad-deactivate function)) (ad-clear-orig-definition function) Index: lisp/ChangeLog =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /sources/emacs/emacs/lisp/ChangeLog,v retrieving revision 1.10783 diff -C0 -r1.10783 ChangeLog *** lisp/ChangeLog 7 Mar 2007 12:50:23 -0000 1.10783 =2D-- lisp/ChangeLog 7 Mar 2007 14:03:28 -0000 *************** *** 0 **** =2D-- 1,13 ---- + 2007-03-07 Micha=EBl Cadilhac +=20 + * emacs-lisp/advice.el (ad-is-advised): Check not only that + function's advice info is not empty, but that an advice class of + the function has an element. + (ad-has-advise-info): New. Only check that function's advice info + is not empty. + (ad-set-advice-info-field, ad-deactivate, ad-unadvise) + (ad-add-advice): Use `ad-has-advise-info' instead of + `ad-is-advised': only advice machinery has to exist at this point. + (ad-remove-advice): If there's no more advice for the function, + remove advice machinery. +=20 --=-=-= Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable TIA! =2D-=20 | Micha=EBl `Micha' Cadilhac | Je veut dire que la loi francaise= | | http://michael.cadilhac.name | est overwritable par le = | | JID/MSN: | reglement interieur il me semble. = | `---- michael.cadilhac@gmail.com | -- ElBarto - = --' --=-=-=-- --==-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (GNU/Linux) iD8DBQFF7s4GUJhDmOfFA3URAvxvAKCGQcJ2QDbphfrZ9K+xgZKujzuutgCg39fh oq4N/TDW560V2OCLv94gc6k= =+uSH -----END PGP SIGNATURE----- --==-=-=-- --===============1445047668== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel --===============1445047668==--