summaryrefslogtreecommitdiff
path: root/lisp/progmodes/python.el
diff options
context:
space:
mode:
authorFabián Ezequiel Gallina <fgallina@gnu.org>2014-09-01 19:51:46 -0300
committerFabián Ezequiel Gallina <fgallina@gnu.org>2014-09-01 19:51:46 -0300
commit0e4c8f1856c46900f9530977e5ac9f83ca13bbfd (patch)
tree529ec7bc3cad3c868e1662d3e8ff6e83c29323ce /lisp/progmodes/python.el
parentad5c82a8cc3f78172dc872c7fe3c6e774f50fe15 (diff)
downloademacs-0e4c8f1856c46900f9530977e5ac9f83ca13bbfd.tar.gz
emacs-0e4c8f1856c46900f9530977e5ac9f83ca13bbfd.tar.bz2
emacs-0e4c8f1856c46900f9530977e5ac9f83ca13bbfd.zip
* lisp/progmodes/python.el (python-indent-post-self-insert-function):
Avoid electric colon at beginning-of-defun. * test/automated/python-tests.el: (python-indent-electric-colon-1): New test. (Bug#18228)
Diffstat (limited to 'lisp/progmodes/python.el')
-rw-r--r--lisp/progmodes/python.el8
1 files changed, 7 insertions, 1 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index a51cff8529e..740dfee5870 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -1155,9 +1155,15 @@ the line will be re-indented automatically if needed."
((and (eq ?: last-command-event)
(memq ?: electric-indent-chars)
(not current-prefix-arg)
+ ;; Trigger electric colon only at end of line
(eolp)
+ ;; Avoid re-indenting on extra colon
(not (equal ?: (char-before (1- (point)))))
- (not (python-syntax-comment-or-string-p)))
+ (not (python-syntax-comment-or-string-p))
+ ;; Never re-indent at beginning of defun
+ (not (save-excursion
+ (python-nav-beginning-of-statement)
+ (python-info-looking-at-beginning-of-defun))))
(python-indent-line)))))