Subject: 31.0.50; Cannot bind <C-m> with keymap-global-set

From: Manuel Uberti <[email-masked]>
Date: Wed, 15 Jan 2025 17:03:07 +0100

Hi,

starting from `emacs -Q`, if I:

- M-x toggle-debug-on-error
- add the following to the *scratch* buffer:

(define-key input-decode-map [?\C-m] [C-m])
(define-prefix-command 'mu-ctrl-m-map)
(keymap-global-set (kbd "<C-m>") mu-ctrl-m-map)

- M-x eval-buffer

I see the following:

Debugger entered--Lisp error: (error "[C-m] is not a valid key
definition; see ‘key-valid-p’")
  signal(error ("[C-m] is not a valid key definition; see ‘key-valid-p’"))
  error("%S is not a valid key definition; see `key-valid-p'" [C-m])
  keymap--check([C-m])
  keymap-set((keymap #^[nil nil keymap #^^[3 0 set-mark-command
move-beginning-of-line backward-char mode-specific-command-prefix
delete-char move-end-of-line forward-char keyboard-quit help-command
indent-for-tab-command electric-newline-and-maybe-indent kill-line
recenter-top-bottom newline next-line open-line previous-line
quoted-insert isearch-backward isearch-forward transpose-chars
universal-argument scroll-up-command kill-region Control-X-prefix yank
suspend-frame ESC-prefix toggle-input-method abort-recursive-edit nil
undo self-insert-command self-insert-command self-insert-command
self-insert-command self-insert-command ...] #^^[1 0 #^^[2 0 #^^[3 0
set-mark-command move-beginning-of-line backward-char
mode-specific-command-prefix delete-char move-end-of-line forward-char
keyboard-quit help-command indent-for-tab-command
electric-newline-and-maybe-indent kill-line recenter-top-bottom newline
next-line open-line previous-line quoted-insert isearch-backward
isearch-forward transpose-chars universal-argument scroll-up-command
kill-region Control-X-prefix yank suspend-frame ESC-prefix
toggle-input-method abort-recursive-edit nil undo self-insert-command
self-insert-command self-insert-command self-insert-command
self-insert-command ...] self-insert-command self-insert-command
self-insert-command self-insert-command self-insert-command
self-insert-command self-insert-command self-insert-command
self-insert-command self-insert-command self-insert-command
self-insert-command self-insert-command self-insert-command
self-insert-command self-insert-command self-insert-command
self-insert-command self-insert-command self-insert-command
self-insert-command self-insert-command self-insert-command
self-insert-command self-insert-command self-insert-command
self-insert-command self-insert-command self-insert-command
self-insert-command self-insert-command] self-insert-command
self-insert-command self-insert-command self-insert-command
self-insert-command self-insert-command self-insert-command
self-insert-command self-insert-command self-insert-command
self-insert-command self-insert-command self-insert-command
self-insert-command self-insert-command] self-insert-command
self-insert-command self-insert-command self-insert-command
self-insert-command self-insert-command self-insert-command
self-insert-command self-insert-command self-insert-command
self-insert-command self-insert-command self-insert-command
self-insert-command self-insert-command self-insert-command
self-insert-command self-insert-command self-insert-command
self-insert-command self-insert-command self-insert-command
self-insert-command self-insert-command self-insert-command
self-insert-command self-insert-command self-insert-command
self-insert-command self-insert-command self-insert-command
self-insert-command self-insert-command ...] (C-m keymap) (f18 .
clipboard-yank) (f16 . clipboard-kill-ring-save) (f20 .
clipboard-kill-region) (C-wheel-up . mouse-wheel-text-scale)
(C-wheel-down . mouse-wheel-text-scale) (C-mouse-5 .
mouse-wheel-text-scale) (C-mouse-4 . mouse-wheel-text-scale)
(C-M-wheel-up . mouse-wheel-global-text-scale) (C-M-wheel-down .
mouse-wheel-global-text-scale) (C-M-mouse-5 .
mouse-wheel-global-text-scale) (C-M-mouse-4 .
mouse-wheel-global-text-scale) (M-wheel-right . mwheel-scroll)
(M-wheel-left . mwheel-scroll) (M-wheel-up . mwheel-scroll)
(M-wheel-down . mwheel-scroll) (M-mouse-7 . mwheel-scroll) (M-mouse-6 .
mwheel-scroll) (M-mouse-5 . mwheel-scroll) (M-mouse-4 . mwheel-scroll)
(S-wheel-right . mwheel-scroll) (S-wheel-left . mwheel-scroll)
(S-wheel-up . mwheel-scroll) (S-wheel-down . mwheel-scroll) (S-mouse-7 .
mwheel-scroll) (S-mouse-6 . mwheel-scroll) (S-mouse-5 . mwheel-scroll)
(S-mouse-4 . mwheel-scroll) (wheel-right . mwheel-scroll) (wheel-left .
mwheel-scroll) (wheel-up . mwheel-scroll) (wheel-down . mwheel-scroll)
(mouse-7 . mwheel-scroll) (mouse-6 . mwheel-scroll) (mouse-5 .
mwheel-scroll) (right-fringe keymap (wheel-right . mwheel-scroll)
(wheel-left . mwheel-scroll) (wheel-up . mwheel-scroll) (wheel-down .
mwheel-scroll) (mouse-7 . mwheel-scroll) (mouse-6 . mwheel-scroll)
(mouse-5 . mwheel-scroll) (mouse-4 . mwheel-scroll)) ...) [C-m] (keymap))
  keymap-global-set([C-m] (keymap))
  (progn (keymap-global-set (kbd "<C-m>") mu-ctrl-m-map))
  eval((progn (keymap-global-set (kbd "<C-m>") mu-ctrl-m-map)) t)
  elisp--eval-last-sexp(nil)
  #f(compiled-function () #<bytecode 0x84153ab75072>)()
  handler-bind-1(#f(compiled-function () #<bytecode 0x84153ab75072>)
(error) eval-expression--debug)
  eval-last-sexp(nil)
  funcall-interactively(eval-last-sexp nil)
  call-interactively(eval-last-sexp nil nil)
  command-execute(eval-last-sexp)

In GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, cairo version
 1.18.0) of 2025-01-15 built on baruch
Repository revision: 16c89c5ae5ec0c002c327793e783f0a943bacb0d
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12302006
System Description: Ubuntu 24.04.1 LTS

Configured using:
 'configure --with-x-toolkit=no 'CFLAGS=-O2 -pipe -march=native
 -fomit-frame-pointer''

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NOTIFY
INOTIFY OLDXMENU PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF
TREE_SITTER WEBP X11 XDBE XIM XINPUT2 XPM ZLIB

Important settings:
  value of $LC_MESSAGES: en_GB.UTF-8
  value of $LC_MONETARY: it_IT.UTF-8
  value of $LC_NUMERIC: it_IT.UTF-8
  value of $LC_TIME: it_IT.UTF-8
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: Debugger

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  minibuffer-regexp-mode: t
  buffer-read-only: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message mailcap yank-media puny dired
dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg rfc6068
epg-config gnus-util text-property-search time-date subr-x mm-decode
mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader
sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils
help-fns radix-tree cl-print byte-opt gv bytecomp byte-compile debug
backtrace help-mode find-func cl-loaddefs cl-lib cus-start cus-load rmc
iso-transl tooltip cconv eldoc paren electric uniquify ediff-hook
vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win
term/common-win x-dnd touch-screen tool-bar dnd fontset image regexp-opt
fringe tabulated-list replace newcomment text-mode lisp-mode prog-mode
register page tab-bar menu-bar rfn-eshadow isearch easymenu timer select
scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors
frame minibuffer nadvice seq simple cl-generic indonesian philippine
cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese composite emoji-zwj charscript
charprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure
cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp
files window text-properties overlay sha1 md5 base64 format env
code-pages mule custom widget keymap hashtable-print-readable backquote
threads dbusbind inotify lcms2 dynamic-setting system-font-setting
font-render-setting cairo xinput2 x multi-tty move-toolbar
make-network-process tty-child-frames emacs)

Memory information:
((conses 16 63332 11699) (symbols 48 7493 0) (strings 32 17261 2393)
 (string-bytes 1 426596) (vectors 16 11783)
 (vector-slots 8 125141 7217) (floats 8 33 13) (intervals 56 624 14)
 (buffers 992 12))

-- 
Manuel Uberti
https://manueluberti.eu