3

I had a look over the weekend, and I cannot see an easy way to check whether a function is advised.

I must be missing something.

HELP! :)

  • 6
    M-x describe-function aka C-h f – lawlist Jan 8 '18 at 17:47
  • 3
    advice-add/advice-remove updates function's documentation accordingly, thus C-h f works. From Lisp, take a look at advice-mapc and advice-member-p. – xuchunyang Jan 8 '18 at 18:15
  • I edited your question. 1. If you are not asking about one of the two aspects (interactive, from Lisp) then please delete that part. 2. It's not clear which advice system you are asking about, new (e.g. advice-add) or the old (e.g., defadvice). – Drew Jan 8 '18 at 19:16
6

As lawlist correctly points out in a comment, the Emacs Help system, invoked via C-hfNAMERET (M-xdescribe-functionRETNAMERET) in this case, is a quick way to interactively check whether there is any advice currently active on the function named NAME. This is doubly convenient because the name of the advising function is hyperlinked as a button, allowing you to jump to and back from its definition.

To programmatically determine whether the function definition of a particular symbol (e.g. fn) contains any advice[1], you can write:

(advice--p (advice--symbol-function 'fn))

Note, however, that the double hyphens indicate this is an internal API and thus subject to breaking change.

[1]: This assumes the new nadvice.el system in Emacs 24; see (elisp) Porting old advice.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.