Restoring Keybindings changed by a Major Mode
The Markdown major mode in Emacs binds
On a Mac keyboard, the key combinations above correspond to “Option” + right/left arrow. A more “natural” binding of these keys, in my opinion, is forward and backward word respectively, the behavior these two keys have in other Emacs modes.
I solved the problem by adding the following code to my
(eval-after-load "markdown-mode" '(progn (define-key markdown-mode-map (kbd "M-<right>") nil) (define-key markdown-mode-map (kbd "M-<left>") nil) ))
Setting the keybinding to
nil, in fact, removes it from the mode and
restores the original behavior.
I found the solution after reading How to override/change mode keybindings in elisp?, which shows how to solve the same issue for a Dired-X binding.
I made it into a post since I had to search a bit before finding the solution which I like the most.