Changing meta key in Emacs Org mode

614 views Asked by At

In all other modes of Emacs I am quite used to using Alt-Left and Alt-Right to move the cursor one word left or right respectively. However in Org-mode, the Alt key is used to change the hierarchy of a headline. This has been a major source of annoyance. How can I have the Alt key work normally in org-mode and use Esc-Left and Esc-Right to do the changing of headline hierarchy?

1

There are 1 answers

0
Tim X On

The M-left/M-right behaviour is defined in the global keymap. Bindings in the global key map can be overridden by bindings in mode specific keymaps. This means that in order to get the global behaviour you need to remove the mode specific keymap setting.

If you open an org file and type C-h k, you will be prompted for a key sequence. Enter M-left or M-right and it will tell you what keymap that binding is defined in.

Once you know that, you can uses one of the various commands to clear that binding. For example, you can set the binding to nil (or I think the symbol 'ignore may work as well). i.e.

(define-key 'org-mode-map (kbd "<M-right>") nil)

should work. Note however, you probably need to put this in one of the org-mode hooks run after org mode is loaded as your command needs to run after org mode ahs run. Check the org manual for which hook would be most appropriate.