When a function documentation page tells me that a function has advice, is there any way to find out where that piece of advice is defined? This is advice that was created using the defadvice facility. I was eventually able to find it by grepping defadvice the-func-name in all lisp folders, but is there a more direct way to locate a given defadvice statement?

  • When you use C-h f the-func-name, doesn't the *Help* output give you a link to the advice? If you follow that link, does it tell you where that advice is defined? Unfortunately, sometimes the *Help* is less helpful than it used to be, and it won't show you the file name but will just say, for example, "ad-Advice-THE-ADVICE-NAME is a compiled Lisp function.". – Drew Apr 22 '16 at 19:08
  • I actually have a function that is advised twice. One with add-advice and one with defadvice. The *Help* output for the first piece of advice does have a link to the file, but the second one (the one using defadvice) just says that it "is a compiled Lisp function," like you mentioned. – nispio Apr 22 '16 at 19:16
  • Yeah, unfortunately, around Emacs 23, I think, Emacs stopped showing the relevant file name in many cases (in general, not just for advice). Somehow, IIRC, they thought that it was an improvement overall. – Drew Apr 22 '16 at 19:33
  • I don't recall Emacs ever providing links to the definitions of defadvice statements (although I possibly didn't make use of advice prior to Emacs 23). If it's your own code, write useful docstrings for it to make it easy to find. Otherwise I've always resorted to rgrep to find them. – phils Apr 23 '16 at 6:33
  • This is also a duplicate of a SO question: How can I locate the defadvice for an advised function in Emacs? – phils Apr 23 '16 at 6:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.