Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Python Development Emacs Environment
branch: master
Failed to load latest commit information.
completion Missing window-configuration-p, lp:1248633, fixed
devel Useless messaging removed from internal position forms
doc Docu updated
extensions Provide skeletons with directory extensions
obsolete Rope bindings moved from pdee-bindings.el into pdee-init.el
python-libs Starting to develop unittesting
scripts Further editing on
snippets/django Some yasnippets for Django templates (html-mode).
test TAB-completion in IPyton, lp:1425268
.gitignore `py-beginning-of-elif-block' and some other missing symbols
.travis.yml `py-beginning-of-statement' fixed
COPYING added license
CREDITS CREDITS updated, lp:1406357
ChangeLog Updated readme and changelog with the new feature
EXTENSIONS keep just one PDEE main directory
INSTALL keep just one PDEE main directory
INSTALL-INFO-FILES info-lookup-symbol, lp:1281950
IPYTHON keep just one PDEE main directory
NEWS New command `py-flycheck-mode' - toggle flycheck-mode `py-split-window-on-execute-p' renamed `py-split-window-on-execute' keep just one PDEE main directory added Compose python-mode.el from components-python-mode directory New command `py-flycheck-mode' - toggle flycheck-mode `py-end-of-statement-bol' provide interactive spec
ar-comment-lor.el `py-end-of-statement': reduce number of recursive calls to expect
auto-complete-pycomplete.el keep just one PDEE main directory
beg-end.el `py-beginning-of-for-block', lp:1367424 inconvinient-py-shell-switch-buffers-on-execute, lp:1073986
company-pycomplete.el keep just one PDEE main directory
index.docbook keep just one PDEE main directory
makeElpa renamed: Makefile -> makeElpa
misc-utils.el keep just one PDEE main directory
pdee-completion.el Don't add hooks that operate on non-existent variables
pdee-editing.el fixes issue #29
pdee-init.el wrong-coloring, lp:1315186
pdee-pkg.el Add package metadata files for ELPA packkage format and Marmalade add…
pycomplete+.el keep just one PDEE main directory keep just one PDEE main directory
pymacs.el python-components-up-down.el added
python-abbrev-propose.el Some commands not so useful made common functions, like
python-components-auto-fill.el fixes issue #29
python-components-beginning-forms.el `py-beginning-of-elif-block' and some other missing symbols
python-components-beginning-position-forms.el Useless messaging removed from internal position forms
python-components-bol-forms.el Some commands not so useful made common functions, like
python-components-booleans-beginning-forms.el `py-beginning-of-for-block', lp:1367424
python-components-booleans-end-forms.el `py-beginning-of-for-block', lp:1367424
python-components-bounds-forms.el `py-beginning-of-for-block', lp:1367424
python-components-comment.el `py-beginning-of-for-block', lp:1367424
python-components-completion_flymake.el remove obsolete, risky forms
python-components-copy-forms.el `py-beginning-of-for-block', lp:1367424
python-components-copy.el `py-statement' no longer aliased to `py-copy-statement'
python-components-dedicated-shells.el keep just one PDEE main directory
python-components-delete-forms.el `py-beginning-of-for-block', lp:1367424
python-components-delete.el inferior-python-mode-map fixed
python-components-edit.el Erroneous requiring, lp:1416633
python-components-electric.el Erroneous requiring, lp:1416633
python-components-end-forms.el `py-beginning-of-elif-block' and some other missing symbols
python-components-end-position-forms.el Useless messaging removed from internal position forms
python-components-exec-forms.el `py-beginning-of-for-block', lp:1367424
python-components-execute-file.el `py-beginning-of-for-block', lp:1367424
python-components-execute.el TAB-completion in IPyton, lp:1425268
python-components-extensions.el TAB-completion in IPyton, lp:1425268
python-components-fast-complete.el Missing symbols from python-components-fast-complete.el
python-components-fast-forms.el `py-beginning-of-for-block', lp:1367424
python-components-foot.el `py-beginning-of-for-block', lp:1367424
python-components-forms-code.el Missing symbols from python-components-forms-code.el
python-components-forms.el `py-beginning-of-for-block', lp:1367424
python-components-help.el TAB-completion in IPyton, lp:1425268
python-components-hide-show.el `py-beginning-of-for-block', lp:1367424
python-components-imenu.el Erroneous requiring, lp:1416633
python-components-intern.el TAB-completion in IPyton, lp:1425268
python-components-kill-forms.el `py-beginning-of-for-block', lp:1367424
python-components-mark-forms.el `py-beginning-of-for-block', lp:1367424
python-components-misc-forms.el `py-beginning-of-for-block', lp:1367424
python-components-mode.el `py-complete-ac-sources' docu augmented, lp:1403920
python-components-move.el `py-beginning-of-statement', docu, clean-up
python-components-named-shells.el `py-shell-name' no-op, lp:1349549
python-components-paragraph.el fill-paragraph causes wrong indent, lp:1397936
python-components-pdb.el py-shell-complete fixed
python-components-re-forms.el Some commands not so useful made common functions, like
python-components-send.el Erroneous requiring, lp:1416633
python-components-shell-complete.el TAB-completion in IPyton, lp:1425268
python-components-shift-forms.el Some commands not so useful made common functions, like
python-components-switches.el Compose python-mode.el from components-python-mode directory
python-components-unified-completion.el keep just one PDEE main directory
python-components-up-down.el `py-beginning-of-for-block', lp:1367424
python-components-virtualenv.el New test/py-ert-variablen-tests.el added
python-dedicated-shells.el keep just one PDEE main directory
python-edit-forms.el `py-beginning-of-for-block', lp:1367424
python-end-forms.el `py-beginning-of-for-block', lp:1367424
python-extended-executes.el test/py-ert-always-split-lp-1361531-tests.el added keep just one PDEE main directory
python-mode-send.el keep just one PDEE main directory
python-mode-utils.el keep just one PDEE main directory
python-named-shells.el keep just one PDEE main directory
python-shell-complete.el keep just one PDEE main directory
python-shell-install-example-buffer.el keep just one PDEE main directory Wrong indent inside closed arglist `py-shell-manage-windows', lp:1273902
sh-beg-end.el keep just one PDEE main directory
thing-at-point-utils.el keep just one PDEE main directory
thingatpt-highlight.el Compose python-mode.el from components-python-mode directory
thingatpt-python-expressions.el keep just one PDEE main directory
thingatpt-utils-base.el keep just one PDEE main directory


Put the following into your initialization file:

(setq py-install-directory “PATH/TO/PYTHON-MODE/”) (add-to-list ‘load-path py-install-directory) (require ‘python-mode)

Selecting a Python shell:

Customize default Python shell as `py-shell-name’

`py-shell-name’ might be an installed default executable as shell command `type’ would display, but also a PATH/TO/EXECUTABLE

If different flavours of Python are installed, customize py-python-command - python2 py-python3-command py-ipython-command

py-python-command-args py-python3-command-args py-ipython-command-args

You might run code by another installed (I)Python-version than default.

Normally this would happen if a shebang in buffer specifies it. Shebang precedes default py-shell-name.

In case you will run code by default-shell, ignoring shebang, set `py-force-py-shell-name-p’ to. This might be done also via menu Python/…/Switches

Another way to enforce a different shell is specifiyng a path –interactively C-u prompts for that– or using commands which end in version like `py-execute-statement-python3’ See menu Python/Interpreter/Other/Ignoring Defaults

Invoking an (I)Python interactive shell

Commands related to a specific shell start with it’s name as `ipython-complete’. Open an installed shell by


This calls py-shell with its default arguments


if DEDICATED is set to `t’, shell will get an unique name.

Install a local shell by evaluating

(defun MY-LOCAL-SHELL () (interactive) (py-shell nil DEDICATED PATH-TO-LOCAL-SHELL))

Invoking versioned Python shells in interactive mode:

M-x py-shell RET ==> ”Python” M-x python RET ==> ”Python” M-x ipython RET ==> ”IPython” M-x python3 RET ==> ”Python3

When Path/To/Executable is given C-u python RET ==> ”PTE Python

Prefix conventions

Most python-mode.el commands start with prefix `py-’

`M-x py- TAB’ displays a list of them in completion-buffer. See also commands list delivered in directory doc.

List virtualenv related `M-x virtualenv- TAB’ resp. Pymacs commands `M-x pymacs-’

Execution code

Python code might be processed by an

  • interactive Python shell (DEFAULT)
  • non-interactive Python (`py-fast-process-p’) The latter, while design for large output, seems more reliable - see also

Both processes might run in

  • session, i.e. start from possible previous state (DEFAULT)
  • dedicated, (`py-dedicated-process-p’) run in separate process

There is also

  • python-mode-v5-behavior


Access is provided to a couple of known checkers like Flake8, pep8, pylint Need to be installed for example calling “pip install pep8” from a shell command-line Get flycheck from

Displaying Output

`py-execute-…’-commands arrive in buffer created by `py-shell’. It’s name is composed WRT to Python version used, it’s path etc.

Result of commands ending “-fast” arrives in `py-fast-output-buffer’

Window management

Variables in question:

** py-keep-windows-configuration

Default is nil. When non-nil, it takes precedence over `py-split-window-on-execute’ and `py-switch-buffers-on-execute-p’ settings

Useful, if a pre-designed set of python-shells/buffers should be maintained

** py-split-window-on-execute

When non-nil split windows according to value set.

Default is ‘just-two: when code is send to interpreter, split screen into source-code buffer and current py-shell result. Other buffers will be hidden that way.

When set to `t’, python-mode tries to reuse existing windows and will split only if needed.

With ‘always, results will displayed in a new window.

** py-switch-buffers-on-execute-p

Put focus into the output buffer: this will display buffer in any case


At the end of a word TAB by default calls completion.

Auto-completion should be available via

(require ‘auto-complete-config) (ac-config-default)

or for company:

(autoload ‘company-mode “company” nil t)

There is also a Pymacs based auto-completion mode see

Either use Pymacs and `company-mode’ with `pycomplete.el’ etc. –load stuff from folder completion–

or switch `py-auto-completion-mode-p’ - which relies on `py-shell-complete’, i.e. calls the current Python process.

Extern tools like jedi-server/mode should work too.


Beside common moves like `defun’, `statement’, block called via py-end-of-…, py-beginning-… specific Python-mode edits are delivered:

`py-expression’ and `py-partial-expression’.

Statement below is considered composed of two `py-expression’

a = [‘spam’, ‘eggs’, 100, 1234]


Assigment operator and all inside comments is ignored.

`py-partial-expression’ would match six sections

a = [‘spam’, ‘eggs’, 100, 1234]

_____ _____ __ ___

When traversing code, `py-partial-expression’ climbs down and up all levels encountered, i.e. at opening `[’ `py-expression’ would return [‘spam’, ‘eggs’, 100, 1234], while one char behind at `” it yields `’spam’,’

  • py-sexp-function, When set, it’s value is called instead of `forward-sexp’, `backward-sexp Choices are py-partial-expression, py-expression, default nil


Customize boolean `py-set-fill-column-p’

If `t’, enables use Python specific `fill-column’ according to

`py-docstring-fill-column’, default is 72

and `py-comment-fill-column, default is 79

Comment- and docstring settings might be disabled by any non-integer value, which means: do not use a different value of `fill-column’ than emacs-wide

Python and IPython

Start IPython shell after loading python-mode via M-x ipython, not from plain shell.

Executing code through IPython should work as with regular Python, also getting completions from. However, with IPython, it feels a demi-second slower.


Start with Emacs -Q from the directory where python-mode.el lives. Open python-mode.el and evaluate it.

Open a file with ending “.py”.

M-x python RET

a regular Python-shell should appear

M-x IPython RET

an IPython-shell should be opened

Something went wrong with that request. Please try again.