unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Gilles <gilles.usenet@gmail.com>
To: 54161@debbugs.gnu.org
Subject: bug#54161: 27.2; `define-minor-mode' with alist of key bindings
Date: Fri, 25 Feb 2022 22:41:05 +0100	[thread overview]
Message-ID: <CAHf9+CvXQXvt5e0Hu64xZOu0USb5LhsnzLZyvQ44FHJ1KLhUKw@mail.gmail.com> (raw)
In-Reply-To: <SJ0PR10MB5488E28AC3E53A0C5D919131F33E9@SJ0PR10MB5488.namprd10.prod.outlook.com>

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





  reply	other threads:[~2022-02-25 21:41 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-25 17:48 bug#54161: 27.2; `define-minor-mode' with alist of key bindings Drew Adams
2022-02-25 21:41 ` Gilles [this message]
2022-02-26  3:20   ` bug#54161: [External] : " Drew Adams
2022-02-28  9:46   ` Lars Ingebrigtsen
2022-03-01  1:21   ` Michael Heerdegen
2022-03-01 15:41     ` Lars Ingebrigtsen
2022-03-01 18:16       ` bug#54161: [External] : " Drew Adams
2022-03-01 22:18         ` Michael Heerdegen
2022-03-01 22:52           ` Lars Ingebrigtsen
2022-03-01 23:56             ` Michael Heerdegen
2022-03-02  0:04               ` Michael Heerdegen
2022-03-01 18:11     ` Drew Adams
2022-02-25 22:33 ` Drew Adams
2022-02-25 22:43   ` Drew Adams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAHf9+CvXQXvt5e0Hu64xZOu0USb5LhsnzLZyvQ44FHJ1KLhUKw@mail.gmail.com \
    --to=gilles.usenet@gmail.com \
    --cc=54161@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).