spacemacs/contrib/lang/python
2014-11-26 18:29:53 -05:00
..
extensions Add nose and pylookup as regular directories 2014-11-14 23:12:47 -05:00
extensions.el Fix void variable spacemacs-config-layer 2014-11-25 20:51:15 -05:00
funcs.el separated python settings into a contrib 2014-11-14 22:41:45 -05:00
packages.el highlight TODO words in python mode 2014-11-26 18:29:53 -05:00
README.md Update python layer documentation 2014-11-26 17:54:23 -05:00

Python contribution layer for Spacemacs

Features

  • Auto-completion
  • Code Navigation
  • Virtual Environment
  • Documentation Lookup
  • Running Tests

Install

To use this contribution add it to your ~/.spacemacs

(defvar dotspacemacs-configuration-layers '(python)
  "List of contribution to load."
)

Because spacemacs is using anaconda-mode as emacs interface to jedi library, you may need to install jedi in order to use code completion. You may install jedi by running following command in your python environment:

$ pip install jedi

Key Bindings

Inferior REPL process

Start an (i)Python inferior REPL process with <SPC> m i. If ipython is available in system executable search paths, ipython will be used to launch python shell; otherwise, default python interpreter will be used. You may change your system executable search path by activating a virtual environment.

Send code to inferior process commands:

Key Binding   |                 Description

------------------|------------------------------------------------------------ <SPC> m b | send buffer and keep code buffer focused <SPC> m B | send buffer and switch to REPL in insert mode <SPC> m f | send function and keep code buffer focused <SPC> m F | send function and switch to REPL in insert mode <SPC> m r | send region and keep code buffer focused <SPC> m R | send region and switch to REPL in insert mode CTRL+j | next item in REPL history CTRL+k | previous item in REPL history

Testing in Python

Spacemacs uses nose as a test runner. An improved version of nose.el is shipped with Spacemacs, this version adds:

  • windows support
  • test suite support

The root of the project is detected with a .git directory or a setup.cfg file.

Test commands (start with m t or m T):

No Debug      |                 Description

------------------|------------------------------------------------------------ m t a | launch all tests of the project m t f | launch the current test under point m t m | launch all tests of the current module m t s | launch all tests of the current suite

 Debug        |                 Description

------------------|------------------------------------------------------------ m T a | launch all tests of the project in debug mode m T f | launch the current test under point in debug mode m T m | launch all tests of the current module in debug mode m T s | launch all tests of the current suite in debug mode

Other Python commands

Key Binding   |                 Description

------------------|------------------------------------------------------------ <SPC> m d | quick documentation using anaconda <SPC> m D | open documentation in firefox using pylookup <SPC> m g | go to definition using anaconda-mode-goto (C-o to jump back) <SPC> m p | toggle a breakpoint <SPC> m v | activate a virtual environment with pyvenv

Screenshots