Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I stop elpy from overriding some of my keybindings?

Tags:

emacs

I just updated the emacs package elpy, and it's set the following keybindings:

<M-down>        elpy-nav-move-iblock-down
<M-left>        elpy-nav-move-iblock-left
<M-right>       elpy-nav-move-iblock-right
<M-up>          elpy-nav-move-iblock-up

I usually have these keys bound to windmove-<direction> and I think this is a real pain. Following this github issue, I tried:

(load "python")
(define-key elpy-mode-map [remap windmove-left] nil)
(define-key elpy-mode-map [remap windmove-right] nil)
(define-key elpy-mode-map [remap windmove-down] nil)
(define-key elpy-mode-map [remap windmove-up] nil)

in my .emacs, but no luck. How can I stop elpy-mode from overriding these keys?

like image 495
Patrick Collins Avatar asked Feb 13 '23 08:02

Patrick Collins


1 Answers

You can reset the offending mappings to nil in one fell swoop in the following way. UPDATE. As per lunaryorn's comment, the file parameter should be "elpy" rather than "python", which is now reflected in the answer.

(eval-after-load "elpy"
  '(cl-dolist (key '("M-<up>" "M-<down>" "M-<left>" "M-<right>"))
     (define-key elpy-mode-map (kbd key) nil)))

If you're not keen on the dolist, you could wrap four calls to define-key in a progn within the eval-after-load.

like image 189
Dan Avatar answered Mar 17 '23 01:03

Dan