0

I am having an issue with bind-key where the following command works

(bind-key* "s-c q"  #'quick-calc)

but

(bind-keys* ("s-c q" . #'quick-calc))

does not. Instead I get the error

command-execute: Wrong type argument: commandp, #'quick-calc

when I press s-c q.

I want to use bind-keys* to bind multiple keys (without prefix). What am I doing wrong?

Tohiko
  • 1,589
  • 1
  • 10
  • 22
  • FWIW, both of them work for me: I don't get an error. What does `C-h f quick-calc` say? – NickD Oct 08 '21 at 11:50
  • That's really weird. `quick-calc` is just an example. I am seeing the same issue with any functions. – Tohiko Oct 08 '21 at 11:51
  • 1
    Sorry, I do see the problem. Try without the quoting. It's a macro, so it does not evaluate its arguments (I think): `(bind-keys* ("s-c q" . quick-calc))` – NickD Oct 08 '21 at 11:56
  • 3
    @NickD Yes. The doc of `bind-keys` says: "The rest of the arguments are conses of keybinding string and a function symbol (unquoted)." **Note the "unquoted".** – Tobias Oct 08 '21 at 11:59
  • Ah yes, that works! I think it's weird that these functions are different since `bind-key` is also a macro. – Tohiko Oct 08 '21 at 12:00
  • @Tobias: thanks for pointing that out. – NickD Oct 08 '21 at 12:09
  • 1
    Yes, the "API" is somewhat strange in that regard. The macro `bind-keys` uses `(bind-key ,(car form) ,fun nil ,filter)` with `fun` equal to `(list 'function (cdr form))` and `form` being the cons with the car being the key binding string and the cdr being the unquoted symbol of the bound command. **Note the `'function`.** On the other side `bind-key` uses `(define-key (or ,keymap global-map) ,keyvar ,command)` directly. **Note the direct use of `,command`.** – Tobias Oct 08 '21 at 12:23

0 Answers0