0

When using the below and invoking the function via <leader>Bn I get an error of command-execute: Wrong type argument: commandp, (bm-my bm-next)

(defun bm-my (a)
  (interactive)
  (a)
  (bm-show-all)
  )

(spacemacs/set-leader-keys "Bn" '(bm-my bm-next))

What is the cause of the error? Essentially I'm trying to define a function that takes a function to be run, and then runs bm-show-all after it.

This mentions the function must be interactive (which mine is?) https://stackoverflow.com/questions/1250846/wrong-type-argument-commandp-error-when-binding-a-lambda-to-a-key


I've tried:

(defun bm-my (a)
  (interactive)
  (a)
  (bm-show-all)
  )

(spacemacs/set-leader-keys "Bn" (bm-my 'bm-next))

But that errors in the below when evaluating (with eval-buffer):

helm-M-x: Symbol’s function definition is void: a
  • 1
    2 issues. First, your command requires an argument, but you don't pass it one when you invoke it via the keybinding. Second, you need to use funcall to call the function in the body of the command, since you presumably mean to pass it a function symbol as the argument. – Dan Nov 16 '19 at 15:35
  • @Dan: Please consider posting that as an answer. (As you know, comments can be deleted at any time.) – Drew Nov 16 '19 at 15:52
  • Surely the argument is a, which I pass as bm-next to bm-my? I'll take a look at funcall now. – Chris Stryczynski Nov 16 '19 at 16:45
  • Perhaps the issue is elisp does not do "partial" functions - while I assume it does? – Chris Stryczynski Nov 16 '19 at 16:51
  • Ah, a third issue. You can only bind a key to an interactive function symbol, not a list of a function and argument. – Dan Nov 16 '19 at 18:30

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.