60 lines
2.6 KiB
Org Mode
60 lines
2.6 KiB
Org Mode
:PROPERTIES:
|
|
:ID: 33d3052d-e679-415d-98fa-56e210555539
|
|
:END:
|
|
#+title: elpy
|
|
|
|
Elpy is an [[id:5f1df0e1-384f-4685-ae1e-fec2431b04e5][emacs]] [[id:b7c4f849-d1b1-4837-8634-82f6976a1473][package]] to bring powerful [[id:ba15b77e-e9a2-4a21-b63f-b9b350ec811a][python]] editing to Emacs. It combines and configures a number of other packages, both written in Emacs Lisp as well as Python. Elpy is fully documented at [[https://elpy.readthedocs.io/en/latest/index.html][Readthedocs]]
|
|
|
|
* Installation
|
|
Elpy is available on [[id:79bae242-a2b4-4753-9960-1f929c8c6300][melpa]], the most straightforward way to install it is to use use-package:
|
|
#+begin_src lisp
|
|
(use-package elpy
|
|
:ensure t
|
|
:init
|
|
(elpy-enable))
|
|
#+end_src
|
|
|
|
* Quickstart
|
|
Once installed, Elpy will automatically provide code completion, syntax error highlighting and code hinting (in the modeline) for python files. Elpy offers a lot of features, but the following keybindings should be enough to get started:
|
|
** ~C-c C-C~
|
|
evaluates the current python script (or region if something is selected) in an interactive python shell. The python shell is automatically displayed aside of your script.
|
|
** ~C-Ret~
|
|
evaluates the current statement (current line plus the following nested lines).
|
|
** ~C-c C-z~
|
|
switches between your script and the interactive shell.
|
|
** ~C-c C-d~
|
|
displays documentation for the thing under cursor. The documentation will pop in a different buffer, that can be closed with ~q~.
|
|
|
|
* Emacs implementation
|
|
#+begin_src lisp
|
|
(use-package elpy
|
|
:ensure t
|
|
:hook ((elpy-mode . flycheck-mode)
|
|
(elpy-mode . (lambda ()
|
|
(set (make-local-variable 'company-backends)
|
|
'((elpy-company-backend :with company-yasnippet))))))
|
|
:init
|
|
(elpy-enable)
|
|
:config
|
|
(setq elpy-modules (delq 'elpy-module-flymake elpy-modules))
|
|
(setq elpy-shell-echo-output nil)
|
|
(setq elpy-shell-echo-input nil)
|
|
(setq elpy-rpc-python-command "python3")
|
|
(setq elpy-rpc-timeout 2))
|
|
|
|
(when (require 'flycheck nil t)
|
|
(setq elpy-modules (delq 'elpy-module-flymake elpy-modules))
|
|
(define-key elpy-mode-map (kbd "C-c p") 'flycheck-previous-error)
|
|
(define-key elpy-mode-map (kbd "C-c n") 'flycheck-next-error)
|
|
(add-hook 'elpy-mode-hook 'flycheck-mode))
|
|
#+end_src
|
|
|
|
In addition to that there is an entry in thea visual fill function for elpy:
|
|
#+begin_src lisp
|
|
(use-package visual-fill-column
|
|
:hook ((org-mode . diz/org-mode-visual-fill)
|
|
(matlab-mode . diz/org-mode-visual-fill)
|
|
(elpy-mode . diz/pyth-mode-visual-fill) # <- This line
|
|
(python-mode . diz/pyth-mode-visual-fill))) # <- and this one
|
|
#+end_src
|