The configuration that I have for python mode implies loading both elpy.el and python.el. The things is that I found the python.el keybindings more natural than the elpy.el ones. And most of the python.el keybindings are shadowed by elpy.el.

I have tried adding a redefinition of the key map to the .emacs file, but it is not working.

This is my "raw" configuration for python

;; --------------------------------------

(setq python-shell-interpreter "/home/anaconda3/bin/ipython"
      python-shell-interpreter-args "-i --simple-prompt")

;; use flycheck not flymake with elpy
(when (require 'flycheck nil t)
  (setq elpy-modules (delq 'elpy-module-flymake elpy-modules))
  (add-hook 'elpy-mode-hook 'flycheck-mode))

;; enable autopep8 formatting on save
(require 'py-autopep8)
(add-hook 'elpy-mode-hook 'py-autopep8-enable-on-save)

;; jedi config

(autoload 'jedi:setup "jedi" nil t)
(add-hook 'python-mode-hook 'jedi:setup)
(setq jedi:complete-on-dot t)            
(add-hook 'after-init-hook 'global-company-mode)

And this is the redefinition I have added:

(I have added an "e" after every "C-c")

(defvar elpy-mode-map
  (let ((map (make-sparse-keymap)))
(define-key map (kbd "C-c e C-r") elpy-refactor-map)
(define-key map (kbd "C-c e C-c") 'elpy-shell-send-region-or-buffer)
(define-key map (kbd "C-c e C-p") 'elpy-flymake-previous-error)

  "Key map for the Emacs Lisp Python Environment.")

It did not work.

How can I change the definition of those bindings without actually modifying the elpy.el file

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.