GNU bug report logs - #78714
30.1; failure binding keys to certain unicode characters

Previous Next

Package: emacs;

Reported by: John Holman <john.g.holman <at> gmail.com>

Date: Sat, 7 Jun 2025 11:48:01 UTC

Severity: normal

Tags: fixed

Found in version 30.1

Fixed in version 30.2

Done: Robert Pluim <rpluim <at> gmail.com>

Full log


Message #32 received at 78714 <at> debbugs.gnu.org (full text, mbox):

From: John Holman <john.g.holman <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 78714 <at> debbugs.gnu.org, Robert Pluim <rpluim <at> gmail.com>,
 schwab <at> linux-m68k.org
Subject: Re: bug#78714: 30.1;
 failure binding keys to certain unicode characters
Date: Mon, 9 Jun 2025 22:12:40 +0100
[Message part 1 (text/plain, inline)]
Hi Robert

I just tried using key-description, for example

(define-minor-mode math-typing-mode
  "A minor mode for typing maths characters"
  :init-value nil
  :lighter " Math"
  (let ((map (make-sparse-keymap)))
    (if math-typing-mode
     (progn

        (define-key map (kbd "C-3") (key-description "\u00B3"))

        (use-local-map map))
      (use-local-map nil))))

but this produces the same result as

(define-key map (kbd "C-3") "\u00B3")

while

(define-key map (kbd "C-3") [?\u00B3]) or my original lambda works (inserts
the unicode character when you press C-3)

Probably I misunderstand what you are suggesting though?



On Mon, 9 Jun 2025 at 15:40, Eli Zaretskii <eliz <at> gnu.org> wrote:

> > Cc: 78714 <at> debbugs.gnu.org, Andreas Schwab <schwab <at> linux-m68k.org>
> > From: Robert Pluim <rpluim <at> gmail.com>
> > Date: Mon, 09 Jun 2025 13:48:31 +0200
> >
> > >>>>> On Mon, 9 Jun 2025 11:05:40 +0100, John Holman <
> john.g.holman <at> gmail.com> said:
> >
> >     John> Many thanks Andreas - that's certainly more concise than using
> a lambda.
> >     John> I do think this is a trap for users who may expect that a key
> definition
> >     John> that a single character string simply specifies the character
> to be
> >     John> inserted when that key is pressed rather than a macro.
> Treating a string
> >     John> with a single character as a character to insert rather than a
> >     John> one-character macro might avoid that, or if that is awkward to
> implement or
> >     John> otherwise undesirable an explicit warning in the documentation
> might help.
> >     John> The documentation for define-key does say that a string is
> treated as a
> >     John> keyboard macro, but the significance of that is easy to miss.
> >
> > (info "(emacs) Init Rebinding") describes how to do this. The
> > docstring for `keymap-global-set' also mentions `key-description',
> > which avoids the need to manually write in vector notation, which I
> > guess we could add to `keymap-set' as well.
>
> Feel free to add that.
>
[Message part 2 (text/html, inline)]

This bug report was last modified 5 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.