aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorJoel Rosdahl2018-12-27 16:52:07 +0100
committerEli Zaretskii2019-01-05 11:02:02 +0200
commita3c79d44ccb4f6503d0a8b02230ff7a41db64ff8 (patch)
tree9ce59ca12af69c9daa60a8374b66c60f8a0710a7 /lisp
parentf6eacc468b8539be482260fa569e7b5ece07f4a2 (diff)
downloademacs-a3c79d44ccb4f6503d0a8b02230ff7a41db64ff8.tar.gz
emacs-a3c79d44ccb4f6503d0a8b02230ff7a41db64ff8.zip
Fix electric indent bug in python-mode after dedenting colon
* list/progmodes/python.el (python-indent-post-self-insert-function): Use markers instead of positions when reindenting statement(s) after inserting electric colon to avoid reindenting too many statements (bug#22663). * test/lisp/progmodes/python-tests.el (python-indent-electric-colon-2): Improve test case to also verify the fix of bug#22663. Copyright-paperwork-exempt: yes
Diffstat (limited to 'lisp')
-rw-r--r--lisp/progmodes/python.el19
1 files changed, 10 insertions, 9 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index ea34e1d9ab5..71b2a94c071 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -1334,16 +1334,17 @@ the line will be re-indented automatically if needed."
1334 (not (equal ?: (char-before (1- (point))))) 1334 (not (equal ?: (char-before (1- (point)))))
1335 (not (python-syntax-comment-or-string-p))) 1335 (not (python-syntax-comment-or-string-p)))
1336 ;; Just re-indent dedenters 1336 ;; Just re-indent dedenters
1337 (let ((dedenter-pos (python-info-dedenter-statement-p)) 1337 (let ((dedenter-pos (python-info-dedenter-statement-p)))
1338 (current-pos (point)))
1339 (when dedenter-pos 1338 (when dedenter-pos
1340 (save-excursion 1339 (let ((start (copy-marker dedenter-pos))
1341 (goto-char dedenter-pos) 1340 (end (point-marker)))
1342 (python-indent-line) 1341 (save-excursion
1343 (unless (= (line-number-at-pos dedenter-pos) 1342 (goto-char start)
1344 (line-number-at-pos current-pos)) 1343 (python-indent-line)
1345 ;; Reindent region if this is a multiline statement 1344 (unless (= (line-number-at-pos start)
1346 (python-indent-region dedenter-pos current-pos))))))))) 1345 (line-number-at-pos end))
1346 ;; Reindent region if this is a multiline statement
1347 (python-indent-region start end))))))))))
1347 1348
1348 1349
1349;;; Mark 1350;;; Mark