I'm on macOS 10.12.5 and Emacs 25.2.1. For some reason M-right is interpreted as M-f. ESC-right is correctly interpreted as ESC-right. I can't see anything in the macOS keyboard shortcuts list that might be capturing M-right/left. How might I figure out what's going on here?

I ended up switching to mitsuarhu's Emacs osx port instead, which doesn't have this problem. I noticed that terminal Emacs in iterm2 also doesn't have this problem. I guess terminal.app is capturing M-right and turning it in to M-f for some reason.

  • 1
    There is no such thing in Emacs as <esc>-right. To find out what function is bound to what keys, press 'C-h k [keys], and modify your question. It is common configuration under OSX that both Esc and Alt keys acts as meta. Both these keys plus 'f' are usually mapped to function forward-word.
    – Heikki
    Jul 5, 2017 at 6:21
  • Meant to say that what function a key combination is mapped to depends on the major mode of the buffer. Typically all combinations of [esc|alt] and [f|right] are mapped functions like forward-word or right-word.
    – Heikki
    Jul 5, 2017 at 6:32
  • 2
    Hm, not sure I understand "there is no such thing in emacs as <esc>-right" I'm just describing the keys I'm pressing. I have the default configuration which I believe maps both esc and alt to meta. I'm using org mode. pressing the escape key follow by right on a heading will correctly demote it. And 'c-h k escape right' tells me that it runs 'org-metaright'. Whereas alt-right runs the command forward-word, despite alt being my meta key as well. Jul 5, 2017 at 18:30
  • Start Emacs with -Q and see if the problem still occurs. If it doesn't then it's a problem with your Emacs config.
    – stevoooo
    Jul 5, 2017 at 19:43
  • You should change your title and question to state that you are asking why esc-right and meta-right work differently in org mode headers.
    – Heikki
    Jul 5, 2017 at 21:22

3 Answers 3


I think it is due to the fact shown in the following picture.

enter image description here

Terminal app in MacOS capture the behaviour of the keyboard.

In the menu Terminal>Preferences go to Profiles tab and select the default profile or the profile it's been used then Select the keyboard tab.

Here the list show how the input is modified, sending special characters to the terminal.

In this case M-right is bounded to \033f.

To fix the issue remove the interested row.

The same solution could apply for other combination of keys in the list.

  • 1
    Please elaborate - explain the fact shown and how it answers the question.
    – Drew
    Jan 23, 2019 at 14:45
  • I think this should be selected as the answer. @ericsoderstrom runs emacs inside a terminal window, and Terminal > Preferences > keyboard shows that M-right is interpreted as M-f, while there is no entry for ESC-right. On the other hand, running emacs from OSX port (or emascformacosx, as I have been doing), runs emacs in a gui frame, not inside a terminal window. @Elia proposes a solution which seems reasonable to me, but if there are use cases of Terminal.app's keyboard remapping, then I would be interested in learning about them.
    – Antoine
    Jan 26, 2021 at 13:22

You have hit something quite interesting here that came clear when you added that you see the behaviour in org mode headers. Although surprising, your emacs works as it should.

According to emacs faq, "Emacs converts M-a internally into ESC a anyway (depending on the value of meta-prefix-char)." The value of meta-prefix-char is by default 27 (esc).

However, when the cursor is in org mode header, meta and escape are indeed doing different things:

  • ESC right (translated from escape right) runs the command forward-word (found in global-map), which is an interactive built-in function in ‘C source code’.

  • M-right runs the command org-metaright (found in org-mode-map), which is an interactive compiled Lisp function in ‘org.el’.

Based on these observations, the conversion of meta to esc happens at C source code level, and if any Emacs major modes written in lisp redifine the meta + key(s) mapping, it leaves the global escape mapping intact. That's is not clearly stated anywhere I looked and quite good to know!


I had similar issue with macOS Catalina (10.15.7) & Emacs from https://emacsformacosx.com/

In org-mode:

  • ESC <left> was backward-word
  • ESC <right> was org-metaright while I wanted it to be forward-word.

I was able to fix this with the following (inspired by How to override a keybinding in Emacs org-mode):

(with-eval-after-load "org"
  (define-key org-mode-map (kbd "ESC <right>") nil))

With that, ESC-right is forward-word also in org-mode.

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.