I'm using spacemacs and setting a binding with spacemacs/set-leader-keys
. The documentation for this states that it uses define-key
:
spacemacs/set-leader-keys is a Lisp function in ‘core-keybindings.el’.
(spacemacs/set-leader-keys KEY DEF &rest BINDINGS)
Add KEY and DEF as key bindings under ‘dotspacemacs-leader-key’ and ‘dotspacemacs-emacs-leader-key’. KEY should be a string suitable for passing to ‘kbd’, and it should not include the leaders. DEF is most likely a quoted command. See ‘define-key’ for more information about the possible choices for DEF. This function simply uses ‘define-key’ to add the bindings.
For convenience, this function will accept additional KEY DEF pairs. For example,
(spacemacs/set-leader-keys "a" ’command1 "C-c" ’command2 "bb" ’command3)
spacemacs/set-leader-keys
sets the name of the binding in the minibuffer to whatever function it's bound to. Right now I have:
(spacemacs/set-leader-keys "ic" (kbd "o { RET } <escape> O"))
so the binding name is the literal keystrokes. I'd like to be able to put the kbd statement in a function so the function name can be used:
(defun insert-code-block ()
(kbd "o { RET } <escape> O"))
(spacemacs/set-leader-keys "ic" #'insert-code-block)
When doing so I get this error:
command-execute: Wrong type argument: commandp, insert-code-block
How do I make this work?
If you need to know the point of this binding, the binding adds a "code block". So if I type:
void this()
and issue the mnemonic SPC i c
, I get a code block with the cursor (|
) properly positioned:
void this()
{
|
}