0

I want to add advice to `describe-function'. However, when I try to do so, I get an error due to wrong number of arguments. Function:

(defun describe-function-advice (function)                                                                                                                                                                         
  (interactive)                                                                                                                                                                                                    
    (setq-local help-buffer-type "describe-function")                                                                                                                                                                
    (setq-local help-buffer-arg function))

(advice-add 'describe-function :after #'describe-function-advice)

Error:

Debugger entered--Lisp error: (wrong-number-of-arguments (1 . 1) 0)
  #f(compiled-function (function) "Display the full documentation of 
    FUNCTION (a symbol).\nWhen called from lisp, FUNCTION may also be
    a function object." (interactive #f(compiled-function ()    
    #<bytecode 0x12b6b$
 apply(#f(compiled-function (function) "Display the full documentation 
   of FUNCTION (a symbol).\nWhen called from lisp, FUNCTION may also 
   be a function object." (interactive #f(compiled-function () 
   #<bytecode 0$
 describe-function()
 funcall-interactively(describe-function)
 #<subr call-interactively>(describe-function nil nil)
 apply(#<subr call-interactively> describe-function (nil nil))
 call-interactively@ido-cr+-record-current-command(
    #<subr call-interactively> describe-function nil nil)
 apply(call-interactively@ido-cr+-record-current-command 
    #<subr call-interactively> (describe-function nil nil))
 call-interactively(describe-function nil nil)
 command-execute(describe-function)

For the given problem, I can probably use `help-fns-describe-function-functions', but I would still like to understand how to use advice-add with interactive functions.

1

Untested, but your (interactive) form doesn't tell Emacs how to obtain the FUNCTION argument, so that's presumably your problem.

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.