Skip to content
This repository

Python Development Emacs Environment

branch: master
Octocat-spinner-32 completion Missing window-configuration-p, lp:1248633, fixed November 06, 2013
Octocat-spinner-32 devel py-execute-.. -fast forms reconsidered April 01, 2014
Octocat-spinner-32 doc Docu updated April 04, 2014
Octocat-spinner-32 extensions Menu: move "TAB related" into "Indent" March 07, 2014
Octocat-spinner-32 obsolete Rope bindings moved from pdee-bindings.el into pdee-init.el December 11, 2011
Octocat-spinner-32 python-libs Starting to develop unittesting November 22, 2011
Octocat-spinner-32 scripts Further editing on package.py April 10, 2011
Octocat-spinner-32 snippets Some yasnippets for Django templates (html-mode). August 02, 2011
Octocat-spinner-32 test `py-fast-send-string', tests and fixes April 08, 2014
Octocat-spinner-32 .gitignore Bogus whitespace left in docstring after wrapping, lp:1178455, fixed May 13, 2013
Octocat-spinner-32 CONTRIBUTORS Added Bastian to the CONTRIBUTORS list June 15, 2011
Octocat-spinner-32 COPYING added license June 18, 2010
Octocat-spinner-32 CREDITS py-fill-paragraph fails, lp:1291493, again March 18, 2014
Octocat-spinner-32 ChangeLog Updated readme and changelog with the new feature July 29, 2011
Octocat-spinner-32 Diskussions.md Titles changed November 24, 2011
Octocat-spinner-32 EXTENSIONS keep just one PDEE main directory August 15, 2012
Octocat-spinner-32 Glossar.md Glossar add sources November 18, 2011
Octocat-spinner-32 Home.md Receive visitors with something relevant #2 November 09, 2011
Octocat-spinner-32 INSTALL keep just one PDEE main directory August 15, 2012
Octocat-spinner-32 INSTALL-INFO-FILES info-lookup-symbol, lp:1281950 February 19, 2014
Octocat-spinner-32 IPYTHON keep just one PDEE main directory August 15, 2012
Octocat-spinner-32 NEWS Boolean `py-enforce-output-buffer-p' dropped April 01, 2014
Octocat-spinner-32 Pymacs.md Pymacs.md added November 23, 2011
Octocat-spinner-32 README Docu updated April 04, 2014
Octocat-spinner-32 README-AUTOPAIR.org keep just one PDEE main directory August 15, 2012
Octocat-spinner-32 README.DEVEL.org inconvenient splitting behavior, lp:1018996, again December 30, 2012
Octocat-spinner-32 ToDo.md Updated deliver project management resp. workspace tools: (markdown) November 18, 2011
Octocat-spinner-32 ToDo.org large output makes Emacs freeze, lp:1253907 March 17, 2014
Octocat-spinner-32 ar-comment-lor.el `py-end-of-statement': reduce number of recursive calls to expect October 30, 2013
Octocat-spinner-32 auto-complete-pycomplete.el keep just one PDEE main directory August 15, 2012
Octocat-spinner-32 beg-end.el keep just one PDEE main directory August 15, 2012
Octocat-spinner-32 byte-compile-directory.sh inconvinient-py-shell-switch-buffers-on-execute, lp:1073986 November 02, 2012
Octocat-spinner-32 company-pycomplete.el keep just one PDEE main directory August 15, 2012
Octocat-spinner-32 index.docbook keep just one PDEE main directory August 15, 2012
Octocat-spinner-32 makeElpa renamed: Makefile -> makeElpa December 06, 2011
Octocat-spinner-32 misc-utils.el keep just one PDEE main directory August 15, 2012
Octocat-spinner-32 pdee-completion.el Don't add hooks that operate on non-existent variables December 09, 2011
Octocat-spinner-32 pdee-editing.el fixes issue #29 February 20, 2013
Octocat-spinner-32 pdee-init.el wrong-indentation-after-return-or-pass-keyword, lp:1087499, test added December 08, 2012
Octocat-spinner-32 pdee-pkg.el Add package metadata files for ELPA packkage format and Marmalade add… November 26, 2011
Octocat-spinner-32 pycomplete+.el keep just one PDEE main directory August 15, 2012
Octocat-spinner-32 pyflakespep8.py keep just one PDEE main directory August 15, 2012
Octocat-spinner-32 pymacs.el python-components-up-down.el added September 24, 2012
Octocat-spinner-32 python-abbrev-propose.el dedicated forms fixed August 13, 2013
Octocat-spinner-32 python-components-auto-fill.el fixes issue #29 February 20, 2013
Octocat-spinner-32 python-components-beginning-forms.el beginning-of-line copy forms, menu added March 06, 2014
Octocat-spinner-32 python-components-bol-forms.el More useful doc-strings WRT beginning-of-line forms March 06, 2014
Octocat-spinner-32 python-components-comment.el `minor-block' commands added September 19, 2013
Octocat-spinner-32 python-components-completion.el internal used `python-font-lock-keywords' renamed `py-font-lock-keywo… November 23, 2012
Octocat-spinner-32 python-components-completion_flymake.el remove obsolete, risky forms June 29, 2013
Octocat-spinner-32 python-components-copy.el `py-statement' no longer aliased to `py-copy-statement' November 12, 2013
Octocat-spinner-32 python-components-dedicated-shells.el keep just one PDEE main directory August 15, 2012
Octocat-spinner-32 python-components-delete.el inferior-python-mode-map fixed October 08, 2013
Octocat-spinner-32 python-components-edit.el Some more face-tests, some cleanup March 21, 2014
Octocat-spinner-32 python-components-electric.el deletes too much, lp:1300270 March 31, 2014
Octocat-spinner-32 python-components-exec-forms.el large output makes Emacs freeze, lp:1253907 March 17, 2014
Octocat-spinner-32 python-components-execute-file.el dedicated forms fixed August 13, 2013
Octocat-spinner-32 python-components-execute.el `py-fast-send-string', tests and fixes April 08, 2014
Octocat-spinner-32 python-components-extensions.el ipython-complete, use py-ipython-completions September 24, 2013
Octocat-spinner-32 python-components-fast-forms.el `py-fast-send-string', tests and fixes April 08, 2014
Octocat-spinner-32 python-components-forms-code.el `py-statement' no longer aliased to `py-copy-statement' November 12, 2013
Octocat-spinner-32 python-components-forms.el `py-mark-base' fixed November 13, 2013
Octocat-spinner-32 python-components-help.el Report state of python-mode variables , lp:1295002 March 27, 2014
Octocat-spinner-32 python-components-hide-show.el paren-typo breaking devel/python-mode-utils.el April 01, 2014
Octocat-spinner-32 python-components-imenu.el PyIndex fixed February 11, 2014
Octocat-spinner-32 python-components-intern.el py-mark-def hangs, lp:1294478 March 19, 2014
Octocat-spinner-32 python-components-macros.el PEP8 alternatives how to close a list implemented, lp:1197521 September 12, 2013
Octocat-spinner-32 python-components-mode.el `py-fast-send-string', tests and fixes April 08, 2014
Octocat-spinner-32 python-components-move.el py-mark-def hangs, lp:1294478 March 19, 2014
Octocat-spinner-32 python-components-named-shells.el large output makes Emacs freeze, lp:1253907 March 17, 2014
Octocat-spinner-32 python-components-nomacros.el dedicated forms fixed August 13, 2013
Octocat-spinner-32 python-components-paragraph.el Setting docstring style simplified March 27, 2014
Octocat-spinner-32 python-components-pdb.el Debugger menu extended February 06, 2014
Octocat-spinner-32 python-components-re-forms.el `py-up' fixed March 31, 2014
Octocat-spinner-32 python-components-send.el `py-fast-send-string', tests and fixes April 08, 2014
Octocat-spinner-32 python-components-shell-complete.el Wrong type argument inserted-chars, lp:1293172 March 18, 2014
Octocat-spinner-32 python-components-shift-forms.el `minor-block' commands added September 19, 2013
Octocat-spinner-32 python-components-skeletons.el `py-beginning-of-block-or-clause' fixed June 03, 2013
Octocat-spinner-32 python-components-switches.el Setting docstring style simplified March 27, 2014
Octocat-spinner-32 python-components-unified-completion.el keep just one PDEE main directory August 15, 2012
Octocat-spinner-32 python-components-up-down.el `py-down-base', go to the end of buffer if no match November 24, 2013
Octocat-spinner-32 python-components-virtualenv.el TAB-completion in IPyhton-shell fixed September 12, 2013
Octocat-spinner-32 python-dedicated-shells.el keep just one PDEE main directory August 15, 2012
Octocat-spinner-32 python-extended-executes.el large output makes Emacs freeze, lp:1253907 March 17, 2014
Octocat-spinner-32 python-mode-fixed-examples.py keep just one PDEE main directory August 15, 2012
Octocat-spinner-32 python-mode-send.el keep just one PDEE main directory August 15, 2012
Octocat-spinner-32 python-mode-utils.el keep just one PDEE main directory August 15, 2012
Octocat-spinner-32 python-named-shells.el keep just one PDEE main directory August 15, 2012
Octocat-spinner-32 python-shell-complete.el keep just one PDEE main directory August 15, 2012
Octocat-spinner-32 python-shell-install-example-buffer.el keep just one PDEE main directory August 15, 2012
Octocat-spinner-32 setup.py `py-shell-manage-windows', lp:1273902 February 02, 2014
Octocat-spinner-32 sh-beg-end.el keep just one PDEE main directory August 15, 2012
Octocat-spinner-32 thing-at-point-utils.el keep just one PDEE main directory August 15, 2012
Octocat-spinner-32 thingatpt-highlight.el ert tests prefix normalized `py-ert-' March 03, 2014
Octocat-spinner-32 thingatpt-python-expressions.el keep just one PDEE main directory August 15, 2012
Octocat-spinner-32 thingatpt-utils-base.el keep just one PDEE main directory August 15, 2012
README
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)

;;;;;;;;;

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

`py-shell-name' might be an installed executable as
shell command `type' would display, but also a
PATH/TO/(I)PYTHON, of a virtualenv for example

To change the Python default shell see also INSTALL

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-'

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

M-x SHELL

With prefix C-u user is prompted to specify a PATH-TO-LOCAL-SHELL
Also evaluating

(py-shell nil DEDICATED PATH-TO-LOCAL-SHELL)

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))

;;;;;;;;;


Python code might be processed by an

- interactive Python shell (DEFAULT)
- non-interactive Python (`py-fast-process-p', if large output)

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

;;;;;;;;;
To use auto-complete, just prepend the following lines:

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

or for company:

  (autoload 'company-mode "company" nil t)

;;;;;;;;;

Beside common moves like `defun', `statement', block 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

;;;;;;;;;

- 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-output-buffer'
  
;;;;;;;;;

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. Also when
starting a session, first completion might fail, while
succeeding afterwards. Any bug reports, which might
help truck down the issue, are highly appreciated.

;;;;;;;;;

Troubleshooting

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.