Subject: Re: 27.2; `define-minor-mode' with alist of key bindings

From: Gilles <[email-masked]>
Date: Fri, 25 Feb 2022 22:41:05 +0100

Hi Drew,

I don't understand the documentation in the same way. I don't think
the documentation is wrong, but it could always use a few examples.

> > where each KEY-SEQUENCE and DEFINITION are arguments suitable for
> > passing to 'define-key'.
> I think that's the case in these examples, no?  Both (kbd "C-o") and
> "\C-o" are suitable args for `define-key'.

The Lisp object (kbd "C-o") (a two-element list) is not a suitable
argument for define-key. The Lisp *expression* (kbd "C-o") *returns* a
suitable argument for define-key.

(define-minor-mode titi-mode
  "TITI MODE" nil nil '(((kbd "C-o") . forward-char)))
(define-minor-mode tata-mode
  "TATA MODE" nil nil '(("\\C-o" . forward-char)))

I would in fact expect titi to result in an error, since a list whose
car is the symbol kbd is not a valid key. But this seems to work, as I
would expect it to:

(define-minor-mode tutu-mode
  "TUTU MODE" nil nil `((,(kbd "C-o") . forward-char)))

As for tata, it binds the four-character sequence {backslash, capital
C, dash, lowercase o}. To bind C-o, you need to pass the one-character
string "\C-o".

-- 
Gilles