python-mode.el Changelog

New in version 6.1.3

January 28th, 2014
  • PEP8 indent-alternatives when closing a list implemented
  • Boolean `py-close-at-start-column-p', default is nil
  • my_list = [ 1, 2, 3, 4, 5, 6, ]
  • result = some_function_that_takes_arguments( 'a', 'b', 'c', 'd', 'e', 'f', )
  • When non-nil, it will be lined up under the first character of the line that starts the multi-line construct, as in:
  • my_list = [ 1, 2, 3, 4, 5, 6,
  • result = some_function_that_takes_arguments( 'a', 'b', 'c', 'd', 'e', 'f',
  • Keys C-M-a, C-M-e usable for all top-level form, lp:1191078
  • Boolean `py-defun-use-top-level-p' If non-nil, beginning- end-of-defun forms will use `py-beginning-of-top-level', `py-end-of-top-level', mark-defun marks top-level form at point etc.
  • Keys C-M-a, C-M-e usable for all top-level form, lp:1191078
  • New commands: py-beginning-of-block-current-column "Reach the beginning of block which starts at current column "
  • py-beginning-of-top-level py-beginning-of-top-level py-end-of-top-level py-mark-top-level py-copy-top-level py-delete-top-level py-kill-top-level py-execute-top-level py-top-level-form-p py-comment-top-level py-beginning-of-top-level-p
  • `minor-block' commands added A minor block is started by a `for', `if', `try' or `with', while block covers also `def' or `class'
  • variable `py-keep-windows-configuration', default is nil Setting `py-keep-windows-configuration' to `t' will restore windows-configuration regardless of `py-switch-buffers-on-execute-p' and `py-split-windows-on-execute-p' settings. However, if an error occurs, it's displayed.
  • To suppres window-changes due to error-signaling also, set `py-keep-windows-configuration' onto 'force
  • boolean empty-line-closes-p, default is nil When non-nil, dedent after empty line following block If non-nil, a C-j from empty line would dedent.
  • if True: print("Part of the if-statement")
  • print("Not part of the if-statement")
  • boolean py-debug-p, default is nil When non-nil, keep resp. store information useful for debugging. Temporary files are not deleted. Other functions might implement some logging etc.
  • heuristic exit new var `py-max-specpdl-size', default is `max-specpdl-size' py-end-of-statement will error if number of `py-max-specpdl-size' loops is completed, thus avoiding a hang from a possibly eternal loop.
  • `py-statement' no longer refferred to `py-copy-statement' Same with block, def, expression etc. `py-statement' made own command, which returns statement, a string.
  • boolean `py-max-help-buffer-p', default is nil If "*Python-Help*"-buffer be the only visible.

New in version 6.1.2 (September 3rd, 2013)

  • simplified menu
  • `py-execute-...'-commands return result as string
  • Controlled by boolean `py-store-result-p', Default is nil
  • When non-nil, put resulting string of `py-execute-...' into kill-ring, so it might be yanked.
  • commands deleting all commented lines:
  • `py-delete-comments-in-def-or-class'
  • `py-delete-comments-in-class'
  • `py-delete-comments-in-block'
  • `py-delete-comments-in-region'
  • boolean `py-indent-paren-spanned-multilines-p, default is nil
  • If non-nil, indents elements of list a value of `py-indent-offset' to first element:
  • def foo():
  • if (foo &&
  • baz):
  • bar()
  • Default lines up with first element:
  • def foo():
  • if (foo &&
  • baz):
  • bar()
  • `py-output-buffer' made customizable
  • See boolean `py-enforce-output-buffer-p'
  • exceptions following executed regions made point to source
  • command `py-empty-out-list-backward'
  • Deletes all elements from list before point
  • With when cursor after
  • mystring[0:1]
  • -------------^
  • ==>
  • mystring[]
  • ---------^
  • In result cursor is insided emptied delimited form."
  • `py-minor-expression' reconsidered, numeric args dropped
  • grasps keyword-arguments
  • boolean `py-electric-kill-backward-p', default is nil.
  • If behind a delimited form of braces, brackets or parentheses,
  • `py-electric-backspace' runs `py-empty-out-list-backward'
  • py-flakes8-run, flakes8 API
  • customizable `py-backslashed-lines-indent-offset'
  • boolean `py-pylint-offer-current-p'
  • If current buffers file should be offered for check.
  • Otherwise `py-pylint-run' looks up filename from history
  • boolean `py-prompt-on-changed-p'
  • When called interactively, ask for save before a
  • changed buffer is sent to interpreter.
  • customizable `py-closing-list-space'
  • Number of chars, closing parentesis outdent from opening
  • customizable `py-uncomment-indents-p'
  • When non-nil, after uncomment indent lines.
  • boolean `py-load-skeletons-p'
  • If skeleton definitions should be loaded
  • boolean `py-if-name-main-permission-p'
  • Allows execution of code inside blocks started by
  • if __name__== '__main__'
  • boolean `py-highlight-error-source-p', default is nil
  • When py-execute-... commands raise an error, respective code in source-buffer will be highlighted.
  • `py-remove-overlays-at-point', command
  • Remove overlays as set when `py-highlight-error-source-p' is non-nil.
  • `py-which-def-or-class', command, now used `which-function-mode'
  • unused variable `py-backspace-function' removed
  • Bundled third-party-stuff removed as reported conflicting at emacs-mirror, lp:1153998
  • affects autopair.el, smart-operator.el
  • Kept menu switches resp. commands will issue a warning
  • dropped `py-paragraph-fill-docstring-p'; just `fill-paragraph' should DTRT
  • `py-set-pager-cat-p', default is nil
  • If non-nil, $PAGER is set to 'cat'
  • in directory doc customizable variables are listed:
  • variables-python-mode.org, variables-python-mode.rst

New in version 6.1.0 (December 5th, 2012)

  • py-up:
  • Go to beginning one level above of compound statement or definition at point.
  • py-down:
  • Go to beginning one level below of compound statement or definition at point.
  • Customizable output directory:
  • After checking for a remote shell, the following variables are consulted:
  • py-use-current-dir-when-execute-p, default t:
  • When `t', current directory is used by Python-shell for output of `py-execute-buffer' and related commands
  • py-fileless-buffer-use-default-directory-p, default t:
  • When `py-use-current-dir-when-execute-p' is non-nil and no buffer-file exists, value of `default directory' sets current working directory of Python output shell"
  • py-keep-shell-dir-when-execute-p, default nil:
  • Don't change Python shell's current working directory when sending code.
  • `py-execute-directory', default nil
  • If nothing was set so far, $VIRTUAL_ENV and $HOME are queried.
  • Set of commands calling Python3.3
  • fill docstrings according to style, commands:
  • py-fill-string-django
  • py-fill-string-onetwo
  • py-fill-string-pep-257
  • py-fill-string-pep-257-nn
  • py-fill-string-symmetric
  • Customizable variable `py-fill-docstring-style' provides default value
  • used by `py-fill-string', `py-fill-paragraph'
  • DJANGO:
  • \"\"\"
  • Process foo, return bar.
  • \"\"\"
  • \"\"\"
  • Process foo, return bar.
  • If processing fails throw ProcessingError.
  • \"\"\"
  • ONETWO:
  • \"\"\"Process foo, return bar.\"\"\"
  • \"\"\"
  • Process foo, return bar.
  • If processing fails throw ProcessingError.
  • \"\"\"
  • PEP-257:
  • \"\"\"Process foo, return bar.\"\"\"
  • \"\"\"Process foo, return bar.
  • If processing fails throw ProcessingError.
  • \"\"\"
  • PEP-257-NN:
  • \"\"\"Process foo, return bar.\"\"\"
  • \"\"\"Process foo, return bar.
  • If processing fails throw ProcessingError.
  • \"\"\"
  • SYMMETRIC:
  • \"\"\"Process foo, return bar.\"\"\"
  • \"\"\"
  • Process foo, return bar.
  • If processing fails throw ProcessingError.
  • \"\"\""
  • Built upon code seen at python.el, thanks Fabian
  • `py-down-statement', `py-up-statement'
  • toggle-py-split-windows-on-execute-p
  • py-split-windows-on-execute-p-off
  • py-split-windows-on-execute-p-on
  • toggle-py-switch-buffers-on-execute-p
  • py-switch-buffers-on-execute-p-on
  • py-switch-buffers-on-execute-p-off
  • `py-shell-switch-buffers-on-execute-p' renamed `py-switch-buffers-on-execute-p'

New in version 6.0.12 (September 28th, 2012)

  • 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
  • `py-partial-expression' reconsidered.
  • Beside common moves like `defun', `statement' 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-find-definition' also detects non-imported definition in current buffer
  • Choice between `py-imenu-create-index-new' and series 5.
  • py-imenu-create-index-function made easier.
  • Customizable variable `py-imenu-create-index-function' provided, see also
  • command in PyTools
  • New commands addressing BOL as start/end:
  • py-beginning-of-block-bol
  • py-end-of-block-bol
  • py-mark-block-bol
  • py-copy-block-bol
  • py-kill-block-bol
  • py-delete-block-bol
  • py-end-of-clause-bol
  • etc.
  • While commands "py-beginning..." resp. "py-end..." compute the context,
  • selecting the corresponding beginning or end,
  • new "py-up...", "py-down..." jump regexp-based to the
  • next element in buffer.
  • See also menu PyEdit

New in version 6.0.10 (June 29th, 2012)

  • Adresses some bugs and speed issues

New in version 6.0.9 (June 21st, 2012)

  • autopair-mode delivered Credits to Joao Tavora http://autopair.googlecode.com see README-AUTOPAIR.org for details
  • Syntax highlighting in Python-shell buffers enabled boolean `py-fontify-shell-buffer-p', default is nil
  • py-add-abbrev, new command Similar to `add-mode-abbrev', but uses `py-partial-expression' before point for expansion to store, not `word'. Also provides a proposal for new abbrevs.
  • Proposal for an abbrev is composed from the downcased initials of expansion - provided they are of char-class [:alpha:]
  • For example code below would be recognised as a `py-expression' composed by three py-partial-expressions.
  • OrderedDict.popitem(last=True)
  • Putting the curser at the EOL, M-3 M-x py-add-abbrev
  • would prompt "op" for an abbrev to store, as first `py-partial-expression' beginns with a "(", which is not taken as proposal.
  • py-edit-abbrevs Jumps to `python-mode-abbrev-table'
  • modeline enhanced when a path/to/my/favoured/Python is given with `py-shell-name' the Python-shell buffer before would display
  • *ND path/to/my/favoured/Python*
  • now:
  • *ptmfP Python*
  • boolean `py-modeline-display-full-path-p' boolean `py-modeline-acronym-display-home-p' If the modeline acronym should contain chars indicating the home-directory.
  • mode-line indicates "Py" by default customize `python-mode-modeline-display'
  • Pymacs intergration dropped from trunk conflicts with classic install being reported

New in version 6.0.7 (May 8th, 2012)

  • make every Python shell acces its own history-file:
  • .python3_history
  • .python_history
  • .ipython_history etc.
  • related to shell used:
  • `toggle-force-py-shell-name-p'
  • `force-py-shell-name-p-on'/off
  • making it easier to enforce default py-shell upon execution
  • `toggle-force-local-shell'
  • `py-force-local-shell-on'/off
  • If locally indicated Python shell should be taken and
  • enforced upon sessions execute commands, lp:988091
  • specific completion:
  • py-python2-shell-complete, py-python3-shell-complete,
  • py-python2-script-complete, py-python3-script-complete

New in version 6.0.5 (March 5th, 2012)

  • Menu reworked and extended
  • extended commands combine executing statement/block... with dedicated/switch... etc. This may remove some need of customization.
  • local environments support started
  • If calls to common `py-shell' should use local executable instead of default system Python set
  • `py-use-local-default' alongside with `py-shell-local-path'
  • py-toggle-shells' alias of more powerful `py-switch-shells'
  • Toggles between the interpreter customized in `py-shell-toggle-1' resp. `py-shell-toggle-2'. Was hard-coded CPython and Jython in earlier versions, now starts with Python2 and Python3 by default.
  • `py-shell-name' accepts PATH/TO/EXECUTABLE in addition to name of an installed default Python-Shell.
  • Permits installing commands like (defun python-XYZ-shell (&optional argprompt)
  • "Start an Python-XYZ interpreter ... "
  • (interactive)
  • (let ((py-shell-name "PATH/TO/PYTHON-XYZ"))
  • (py-shell argprompt)))
  • new commands `indent-tabs-mode', `toggle-indent-tabs-mode', `indent-tabs-mode-on', `indent-tabs-mode-off'
  • feature after a request at Stack Exchange asked Jul 13 '11 at 13:23 saying `tab-width' now follows `py-indent-offset'
  • new command `py-execute-region-default' forces the systems default Python interpreter to execute, ignores shebang
  • related functions redesigned, `async' argument dropped `py-execute-region' now reads:
  • (defun py-execute-region (start end &optional shell dedicated) "Send the region to a Python interpreter.
  • When called with \\[univeral-argument], execution through `default-value' of `py-shell-name' is forced.
  • When called with \\[univeral-argument] followed by a number different from 4 and 1, user is prompted to specify a shell. This might be the name of a system-wide shell or include the path to a virtual environment.
  • When called from a programm, it accepts a string specifying a shell which will be forced upon execute as argument. " [ ... ]
  • new `py-number-face', visible only when customized and `py-use-number-face-p' is `t', inherits default face With large files fontifying numbers may cause a delay
  • new boolean `py-verbose-p' if `t', reached indent level etc. is messaged
  • new commands py-execute-buffer-dedicated, py-execute-buffer-switch -dedicated
  • `toggle-py-smart-indentation' new command also `py-smart-indentation-on', -off

New in version 6.0.4 (January 1st, 2012)

  • Python shell starts with `python-mode' that's needed by completion for now boolean customizable `py-start-run-py-shell'
  • outline-(minor-)mode enabled providing regular expressions. Customize `py-outline-minor-mode-p' to switch it on with python-mode
  • Hook delivered to start hs-minor-mode from python-mode
  • Customize `py-hide-show-minor-mode-p'
  • Key setting example:
  • (global-set-key [(super s)] 'hs-hide-all)
  • (global-set-key [(super S)] 'hs-show-all)
  • Listing of available commands in org-mode and reST format in directory "doc"
  • Python shells and executing forms may be called as dedicated process. See commands available \w suffix "-dedicated".
  • completion fixed: M-TAB completes in Python buffer, TAB completes in Python shells
  • py-down-FORM-lc commands
  • Goto beginning of line following end of FORM.
  • \"-lc\" stands for \"left-corner\" - a complementary command travelling left, whilst `py-end-of-FORM' stops at right corner.
  • Implemented forms are "block", "clause", "def", "class", "statement".
  • py-down-FORM commands
  • like py-down-block introduced in version 6.0.3,
  • implemented also for "clause", "def", "class",
  • "statement".
  • Go to the beginning of next block below
  • current level.