Reputation: 522
How can you go about debugging an error with a defadvice involved?
Searching for solutions all I can find is recommendations not to use defadvice because of the debugging difficulties. Amen to that, but other peoples defadvices are everywhere and I'm always running into bugs I can't even begin to track down.
Upvotes: 4
Views: 295
Reputation: 73314
One option is to make the advice body call a function to do its work, and then you can debug the function instead.
Note that you can evaluate (ad-deactivate 'function)
to deactivate all advice for the specified function
(this will revert the function to its unadvised state). This might help if some advice is causing you serious problems while you are trying to track it down.
Upvotes: 3
Reputation:
One more thing I could think of:
Temporary rename defadvice
into defadvice-old
.
Write this new version of defadvice
:
(defmacro defadvice (function args &rest body)
`(progn
(put ',(cadr args) 'source-position
(cons byte-compile-current-file byte-compile-read-position))
(defadvice-old ,function ,args ,@body)))
(symbol-plist <<name of advice>>)
once you need it, it would have the position in the file of the file that used the macro.Upvotes: 8