feat: distinguish [C-m] key from RET

Now, uses can rebind ctrl+m by targeting [C-m] (or "<C-m>", same thing),
and it won't rebind RET. This will only work in GUI Emacs, however, and
there is no kkp support for this one.

Ref: 96d7e50f3e
This commit is contained in:
Henrik Lissner 2024-09-07 14:49:18 -04:00
parent 4fc11b696e
commit de1ffbca11
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -68,6 +68,17 @@ and Emacs states, and for non-evil users.")
(key-binding (vconcat (cl-subseq keys 0 -1) [C-i]) nil t)))
[C-i] [?\C-i])))
;; HACK: Same as C-i, but C-m is a little harder. There is no workaround for
;; this for the terminal.
(define-key input-decode-map
[?\C-m] (cmd! (if (when-let ((keys (this-single-command-raw-keys)))
(and (display-graphic-p)
(not (cl-position 'return keys))
(not (cl-position 'kp-return keys))
;; Fall back if no <C-m> keybind can be found.
(key-binding (vconcat (cl-subseq keys 0 -1) [C-m]) nil t)))
[C-m] [?\C-m])))
;;
;;; Universal, non-nuclear escape