0

I want to create a new key binding that puts out a single letter with a key combination. For example: M-E inserts an "ê" character. Is this possible?

  • Have a look on this excellent reference on "mastering emacs": masteringemacs.org/article/mastering-key-bindings-emacs – turbopape Jun 13 '16 at 12:16
  • Yes, bind a key to a command that uses insert-char to insert that character. – Drew Jun 13 '16 at 13:17
  • 1
    FYI, at least as tested on emacs 25 pretest version, C-x 8 ^ e inserts ê. Similarly using A, E, I, O, U, a, i, o, u after C-x 8 ^ would work as you would guess. – Kaushal Modi Jun 13 '16 at 14:16
  • I try to insert this command inside my .emacs file: '(global-set-key (kbd "M-x e") "ê")' but there is an error... – sblindo Jun 13 '16 at 14:56
  • @sblindo M-x is already bound to a command so it can't be a prefix for a keybinding (as the error msg says). – JeanPierre Jun 13 '16 at 20:39
1

Try this:

(global-set-key (kbd "M-e") '(lambda () (interactive) (insert-char 234)))

How to get 234? Place your cursor on the letter ê and press C-x =. Modeline will show you the codes:

Char: ê (234, #o352, #xea, file ...) point=3 of 27 (7%) column=0
  • 2
    Why not simply (insert "ê"), without having to look the char up? – T. Verron Oct 14 '16 at 14:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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