Python 4 Emacs

See Emacs wiki

Elpy

  • conda install jedi rope flake8 autopep8 yapf black
  • M-x list-package, install elpy
  • pyvenv already part of elpy
  • Some info here

Git

Markdown

Keybindings cheatsheet

Mode Keybinding Description
anaconda C-M-i auto-complete
anaconda M-. find definition
anaconda M-= show assignement
anaconda M-r show all lines containing focus
anaconda M-? show doc
elpy C-c C-c send buffer/region to ipython
elpy C-RET send line to Ipython
elpy C-c C-z switch to ipython/buffer
elpy C-c C-d open doc
elpy C-c C-K Kill shells
flycheck C-c ! l list all error
flycheck C-c ! n next error
flycheck C-c ! p prev error
flycheck C-c ! s select checker

Relevant .emacs snippet

(setenv "WORKON_HOME" "/home/sylchev/anaconda3/envs")
(pyvenv-mode 1)
(add-hook 'python-mode-hook 'anaconda-mode)
(add-hook 'python-mode-hook 'anaconda-eldoc-mode)
(add-hook 'python-mode-hook 'elpy-mode)
;; (setq python-shell-interpreter "jupyter"
;;       python-shell-interpreter-args "console --simple-prompt"
;;       python-shell-prompt-detect-failure-warning nil)
;; (add-to-list 'python-shell-completion-native-disabled-interpreters
;;              "jupyter")
 (setq python-shell-interpreter "ipython"
       python-shell-interpreter-args "--simple-prompt -i")
(elpy-enable)
(when (load "flycheck" t t)
  (setq elpy-modules (delq 'elpy-module-flymake elpy-modules))
  (add-hook 'elpy-mode-hook 'flycheck-mode))