emacskey-bindingsminor-mode

Override minor mode keybinding in emacs


I am using paredit (a lisp minor mode) in emacs. Paredit binds C-<left> and <C-right> to barf and slurp sexp which I don't like.

I am trying to set back the keybindings to left-word and right-word

If I evaluate in a buffer (that uses paredit mode) the following code I successfully overwrite the bindings:

 (define-key paredit-mode-map (kbd "<C-left>") 'left-word)
 (define-key paredit-mode-map (kbd "<C-right>") 'right-word))

However, when I try to eval-after-load the same thing in init.el it has no effect.

 (eval-after-load "paredit-mode"
    '(progn
       (define-key paredit-mode-map (kbd "<C-left>") 'left-word)
       (define-key paredit-mode-map (kbd "<C-right>") 'right-word)))

I have added the above code at the end of my init.el but it doesn't seem to make any difference.

Any ideas as to what am I doing wrong would be greatly appreciated.


Solution

  • Try (eval-after-load "paredit"...) instead of (eval-after-load "paredit-mode"...).

    The first argument to eval-after-load, FILE is a file name or a feature name. paredit-mode is the name of a command (and a mode), not a file or feature name. The file is paredit.el.