2

I'm trying to adjust bindings in input-decode-map (to distinguish C-m and RET in GUI mode). None of the advice given on Stack Overflow, gnu.emacs.help, Reddit, or Super User seems to work. I ended up with this:

(defun ~/setup-C-m (&rest args)
  (define-key input-decode-map [?\C-m] [C-m]))

(~/setup-C-m)
(add-hook 'tty-setup-hook #'~/setup-C-m)
(add-hook 'window-setup-hook #'~/setup-C-m)
(add-hook 'terminal-init-xterm-hook #'~/setup-C-m)
(add-hook 'after-make-frame-functions #'~/setup-C-m)

Even with all these, starting Emacs with emacsclient --alternate-editor="" --create-frame --frame-parameters="((fullscreen . maximized))" results in input-decode-map being set to this:

Value:
(keymap
 (27 keymap
     (C-backspace)
     (C-delete))
 (C-M-backspace)
 (C-M-delete)
 (M-backspace)
 (M-delete))

Which doesn't include the C-m binding. I've printed the value of input-decode-map when my setup-C-m function is called, and it's always an empty keymap.

How can I ensure that my setup-C-m function runs every time I create a frame and properly sets input-decode-map?

3
  • That's quite some bizarre prefix you've got here. The code in your example won't work because you haven't defined such a function.
    – wasamasa
    Aug 4, 2017 at 15:46
  • Yup, of course, sorry for the typo. The question stands, of course.
    – Clément
    Aug 5, 2017 at 13:08
  • I use ~/ as a prefix for all my personal functions.
    – Clément
    Aug 5, 2017 at 13:08

2 Answers 2

1

Your usage of after-make-frame-functions isn't working because you're ignoring the FRAME argument, and therefore not operating on the new frame at all.

Your function needs to do this:

(with-selected-frame FRAME
  ...)
0

(add-hook 'server-after-make-frame-hook #'~/setup-C-m) should do what you want (at least since 27.1).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.