aboutsummaryrefslogtreecommitdiffstats
path: root/test/automated/python-tests.el
diff options
context:
space:
mode:
authorFabián Ezequiel Gallina2014-12-22 02:24:42 -0300
committerFabián Ezequiel Gallina2014-12-22 02:24:42 -0300
commit749813e9d4a844384e0450f6f7f88484b15e348a (patch)
tree11dacc975324be1c08bf16c4430183fbb624f53b /test/automated/python-tests.el
parent936d5e5bb63358da281188d9c8e9e21341df9444 (diff)
downloademacs-749813e9d4a844384e0450f6f7f88484b15e348a.tar.gz
emacs-749813e9d4a844384e0450f6f7f88484b15e348a.zip
python.el: Fix electric colon behavior
* lisp/progmodes/python.el (python-indent-post-self-insert-function): Make colon to re-indent only for dedenters, handling multiline-statements gracefully. * test/automated/python-tests.el (python-indent-electric-colon-2) (python-indent-electric-colon-3): New tests.
Diffstat (limited to 'test/automated/python-tests.el')
-rw-r--r--test/automated/python-tests.el33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/automated/python-tests.el b/test/automated/python-tests.el
index f84ded8cad2..d1713ac1851 100644
--- a/test/automated/python-tests.el
+++ b/test/automated/python-tests.el
@@ -740,6 +740,39 @@ def b()
740 (python-tests-self-insert ":") 740 (python-tests-self-insert ":")
741 (should (= (current-indentation) 0)))) 741 (should (= (current-indentation) 0))))
742 742
743(ert-deftest python-indent-electric-colon-2 ()
744 "Test indentation case for dedenter."
745 (python-tests-with-temp-buffer
746 "
747if do:
748 something()
749 else
750"
751 (python-tests-look-at "else")
752 (goto-char (line-end-position))
753 (python-tests-self-insert ":")
754 (should (= (current-indentation) 0))))
755
756(ert-deftest python-indent-electric-colon-3 ()
757 "Test indentation case for multi-line dedenter."
758 (python-tests-with-temp-buffer
759 "
760if do:
761 something()
762 elif (this
763 and
764 that)
765"
766 (python-tests-look-at "that)")
767 (goto-char (line-end-position))
768 (python-tests-self-insert ":")
769 (python-tests-look-at "elif" -1)
770 (should (= (current-indentation) 0))
771 (python-tests-look-at "and")
772 (should (= (current-indentation) 6))
773 (python-tests-look-at "that)")
774 (should (= (current-indentation) 6))))
775
743(ert-deftest python-indent-region-1 () 776(ert-deftest python-indent-region-1 ()
744 "Test indentation case from Bug#18843." 777 "Test indentation case from Bug#18843."
745 (let ((contents " 778 (let ((contents "