How to debug defadvice

How can you debug error using defadvice?

Finding solutions that I can find are recommendations not to use defadvice because of the complexity of debugging. Amen to this, but other peoples deadweights are everywhere, and I always encounter errors that I cannot even track.

+4
source share
2 answers

Another thing I could think of:

  • Temporarily rename defadvice to 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))) 
  • Examine (symbol-plist <<name of advice>>) , as soon as you need it, it will have a position in the file of the file that the macro used.
+8
source

One option is to force the body of the board to call a function to do its job, and then you can debug this function.

Note that you can evaluate (ad-deactivate 'function) to disable all the tips for the specified function (this will return the function to its unmanaged state). This can help if some tips cause serious problems while you are trying to track it.

+3
source

All Articles