0

I'm using iTerm2, and I would like to remap some of the meta keys. In my .emacs I have

(global-set-key (kbd "M-g") 'goto-line)

And in my iTerm2 settings I have both "option" keys set to send +Esc. I can use any of the default key bindings like normal, but M-g, (or others I've remapped) still send the default command. I've tried changing iTerm2 to send meta, but it instead injects non-printable ascii characters.

What's the best workaround to get these key bindings to work under iTerm2? Is there a clearer solution than to have my .emacs check if I'm using a Mac, and if so then use (kdb "Esc-g")?

4
  • 1
    Is this really an Emacs problem? It sounds more like an iTerm2 problem. What happens when you try (from a shell) cat and type C-e M-e M-g.
    – PythonNut
    Feb 27, 2015 at 17:11
  • Nothing shows up. To clarify, I'm not saying "this is a problem with emacs", but rather "emacs is getting bad input from another program".
    – David
    Feb 27, 2015 at 17:23
  • I use iTerm2 and have the left option set to +Esc and am able to define new key combos including the one you're trying to use. When you say that it sends the "default command" after remapping what do you mean? If you hit M-g M-g (or M-g g) does it invoke goto-line (I think this is emacs default)? Feb 27, 2015 at 23:27
  • Insofar as this is about emacs in a terminal, have a look at Problems with keybindings when using terminal.
    – Dan
    Feb 28, 2015 at 17:37

1 Answer 1

0

Forgot to check *Warnings*. A totally unrelated change in my .emacs was causing it to not load correctly, meaning the bindings were never set.

Your Answer

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

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