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?

5
  • Have a look on this excellent reference on "mastering emacs": masteringemacs.org/article/mastering-key-bindings-emacs Commented Jun 13, 2016 at 12:16
  • Yes, bind a key to a command that uses insert-char to insert that character. Commented Jun 13, 2016 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. Commented Jun 13, 2016 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... Commented Jun 13, 2016 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). Commented Jun 13, 2016 at 20:39

1 Answer 1

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 
1
  • 2
    Why not simply (insert "ê"), without having to look the char up? Commented Oct 14, 2016 at 14:53

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.