spacemacs/contrib/lang/python
Jean-Christophe Petkovich 8b0c0a5c2e Add vim-like anaconda-nav-mode bindings
Anaconda nav mode currently starts in evil mode which masks most of its
bindings. This just adds anaconda-nav-mode to the list of emacs states,
and throws in j/k bindings that make sense to me.

Fix using spacemacs|evilify

Add leader key, and next and previous error.
2015-02-04 00:53:27 -05:00
..
extensions
img Add django logo in python layer README 2015-01-30 22:42:32 -05:00
config.el Sort and modify key bindings in python layer packages.el 2015-01-30 22:28:47 -05:00
extensions.el
funcs.el
packages.el Add vim-like anaconda-nav-mode bindings 2015-02-04 00:53:27 -05:00
README.md contrib(python): document Django keys 2015-02-01 22:55:06 -05:00

Python contribution layer for Spacemacs

logo_python logo_django

Table of Contents

Description

This layer adds support for the Python language.

Features:

Install

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

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

Key Bindings

Inferior REPL process

Start a Python or iPython 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

---------------------|------------------------------------------------------------ SPC m t a | launch all tests of the project SPC m t b | launch all tests of the current buffer (same as module) SPC m t m | launch all tests of the current module SPC m t s | launch all tests of the current suite SPC m t t | launch the current test (function)

 Debug           |                 Description

---------------------|------------------------------------------------------------ SPC m T a | launch all tests of the project in debug mode SPC m T b | launch all tests of the current buffer (module) in debug mode SPC m T m | launch all tests of the current module in debug mode SPC m T s | launch all tests of the current suite in debug mode SPC m T t | launch the current test (function) in debug mode

Other Python commands

Key Binding       |                 Description

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

Django

Django related key bindings uses pony-mode and are behind the prefix SPC m j.

Configuration options for pony-mode are documented at deadpansincerity.com

Manage Django with SPC m j m.

Fabric

Key Binding       |                 Description

----------------------|------------------------------------------------------------ mjaf | Run a fabric command mjad | Deploy project with fab deploy

Files

Key Binding       |                 Description

----------------------|------------------------------------------------------------ mjfs | Open the settings.py for this project mjfc | Interactively display a setting value in the minibuffer mjft | Jump to template at point mjfr | Jump to the view file that the URL resolves to (experimental)

Interactive

Key Binding       |                 Description

----------------------|------------------------------------------------------------ mjid | Run interpreter for this project's default database as an inferior process mjis | Open a Python shell with the current pony project's context loaded. If the project has the django_extras package installed, then use the excellent shell_plus command. Otherwise, fall back to manage.py shell

Server

Key Binding       |                 Description

----------------------|------------------------------------------------------------ mjrd | Stop the dev server mjro | Open a tab at the dev server mjrr | Restart the dev server (works better with django_extras/werkzeug) mjru | Start or open the dev server mjrt | Open a second server with a "throwaway" host/port

South/Syncdb

Key Binding       |                 Description

----------------------|------------------------------------------------------------ mjsc | Convert an existing app to south mjsh | Create migration for modification mjsi | Run the initial south migration for an app mjsm | Migrate an app mjss | Run syncdb on the current project

Test

Key Binding       |                 Description

----------------------|------------------------------------------------------------ mjtd | Move down the traceback one level mjte | Go to the file and line of the last stack trace in a test buffer mjto | Open the file in a traceback at the line specified mjtt | Run the test(s) given by command mjtu | Move up the traceback one level