aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabián Ezequiel Gallina2014-11-15 19:02:52 -0300
committerFabián Ezequiel Gallina2014-11-15 19:02:52 -0300
commit92f58578cc939e0d955437fcbc87cda80c2ba05c (patch)
treecfa7284f877f5bf05e98f6f607a38ce36ccd044e
parentb6cd03a825f7b8bdd0a741f68f20f81fb541ee5b (diff)
downloademacs-92f58578cc939e0d955437fcbc87cda80c2ba05c.tar.gz
emacs-92f58578cc939e0d955437fcbc87cda80c2ba05c.zip
Fixes: debbugs:18432
* lisp/progmodes/python.el (python-indent-calculate-levels): Fix indentation behavior multiline dedenter statement. * test/automated/python-tests.el (python-indent-dedenters-8): New test for Bug#18432.
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/progmodes/python.el6
-rw-r--r--test/ChangeLog5
-rw-r--r--test/automated/python-tests.el15
4 files changed, 30 insertions, 1 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index fe06ac671b7..d13a62a9b2d 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,10 @@
12014-11-15 Fabián Ezequiel Gallina <fgallina@gnu.org> 12014-11-15 Fabián Ezequiel Gallina <fgallina@gnu.org>
2 2
3 * progmodes/python.el (python-indent-calculate-levels): Fix
4 indentation behavior multiline dedenter statement. (Bug#18432)
5
62014-11-15 Fabián Ezequiel Gallina <fgallina@gnu.org>
7
3 * progmodes/python.el (python-indent-region): Use 8 * progmodes/python.el (python-indent-region): Use
4 python-indent-line and skip special cases. (Bug#18843) 9 python-indent-line and skip special cases. (Bug#18843)
5 10
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 5f8d7a29fa6..89b2f1fd081 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -955,7 +955,11 @@ START is the buffer position where the sexp starts."
955 955
956(defun python-indent-calculate-levels () 956(defun python-indent-calculate-levels ()
957 "Calculate `python-indent-levels' and reset `python-indent-current-level'." 957 "Calculate `python-indent-levels' and reset `python-indent-current-level'."
958 (if (not (python-info-dedenter-statement-p)) 958 (if (or (python-info-continuation-line-p)
959 (not (python-info-dedenter-statement-p)))
960 ;; XXX: This asks for a refactor. Even if point is on a
961 ;; dedenter statement, it could be multiline and in that case
962 ;; the continuation lines should be indented with normal rules.
959 (let* ((indentation (python-indent-calculate-indentation)) 963 (let* ((indentation (python-indent-calculate-indentation))
960 (remainder (% indentation python-indent-offset)) 964 (remainder (% indentation python-indent-offset))
961 (steps (/ (- indentation remainder) python-indent-offset))) 965 (steps (/ (- indentation remainder) python-indent-offset)))
diff --git a/test/ChangeLog b/test/ChangeLog
index 971a4f8f400..4f7f068e796 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,5 +1,10 @@
12014-11-15 Fabián Ezequiel Gallina <fgallina@gnu.org> 12014-11-15 Fabián Ezequiel Gallina <fgallina@gnu.org>
2 2
3 * automated/python-tests.el (python-indent-dedenters-8): New test
4 for Bug#18432.
5
62014-11-15 Fabián Ezequiel Gallina <fgallina@gnu.org>
7
3 * automated/python-tests.el (python-indent-region-1) 8 * automated/python-tests.el (python-indent-region-1)
4 (python-indent-region-2, python-indent-region-3) 9 (python-indent-region-2, python-indent-region-3)
5 (python-indent-region-4, python-indent-region-5): New tests. 10 (python-indent-region-4, python-indent-region-5): New tests.
diff --git a/test/automated/python-tests.el b/test/automated/python-tests.el
index 8c657c38b64..f368f995cae 100644
--- a/test/automated/python-tests.el
+++ b/test/automated/python-tests.el
@@ -711,6 +711,21 @@ if a:
711 (should (= (python-indent-calculate-indentation) 0)) 711 (should (= (python-indent-calculate-indentation) 0))
712 (should (equal (python-indent-calculate-levels) '(0))))) 712 (should (equal (python-indent-calculate-levels) '(0)))))
713 713
714(ert-deftest python-indent-dedenters-8 ()
715 "Test indentation for Bug#18432."
716 (python-tests-with-temp-buffer
717 "
718if (a == 1 or
719 a == 2):
720 pass
721elif (a == 3 or
722a == 4):
723"
724 (python-tests-look-at "a == 4):\n")
725 (should (eq (car (python-indent-context)) 'inside-paren))
726 (should (= (python-indent-calculate-indentation) 6))
727 (should (equal (python-indent-calculate-levels) '(0 4 6)))))
728
714(ert-deftest python-indent-electric-colon-1 () 729(ert-deftest python-indent-electric-colon-1 ()
715 "Test indentation case from Bug#18228." 730 "Test indentation case from Bug#18228."
716 (python-tests-with-temp-buffer 731 (python-tests-with-temp-buffer