Subject: bug#17348: closed (Re: bug#17348: 24.3.50; Cannot advice-add the same function :before and :after)

From: [email-masked] (GNU bug Tracking System)
Date: Sat, 10 May 2014 20:10:03 +0000

Your bug report

#17348: 24.3.50; Cannot advice-add the same function :before and :after

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
17348: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=17348
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#17348: 24.3.50; Cannot advice-add the same function :before and :after
From: Stefan Monnier <[email-masked]>
To: Nicolas Richard <[email-masked]>
Cc: [email-masked]
Date: Sat, 10 May 2014 16:09:21 -0400
List-Id: <debbugs-submit.debbugs.gnu.org>

I installed a patch in `emacs-24' which will let you add the same
function multiple times, as long as you specify different `name'
properties for each one.

>> In the actual situation that lead me to adding the same function twice,
>> it was a tracing function, like (message "time: %s ; value of
>> foovariable: %s" (current-time) foovariable) and I assumed that I would
>> be able to remove them both with one (advice-remove ...) -- I guess that
>> isn't too complicated.
> Removing them both would not be desirable in general.

With the new code, you can remove each one individually by specifying
its `name', or you can remove them all by specifying the function itself.

        Stefan

Subject: 24.3.50; Cannot advice-add the same function :before and :after
From: Nicolas Richard <[email-masked]>
To: [email-masked]
Date: Sat, 26 Apr 2014 13:16:00 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Evalling:
(progn
  (defun yfcheck () (message "Check"))
  (defun yftest () (message "Test"))
  (advice-add 'yftest :before #'yfcheck)
  (advice-add 'yftest :after #'yfcheck)
  (yftest)
  nil)

gives (in the *Messages* buffer)
Test
Check

I'd have expected:
Check
Test
Check

-- 
Nico.