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.
This commit is contained in:
parent
b6cd03a825
commit
92f58578cc
4 changed files with 30 additions and 1 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2014-11-15 Fabián Ezequiel Gallina <fgallina@gnu.org>
|
||||||
|
|
||||||
|
* progmodes/python.el (python-indent-calculate-levels): Fix
|
||||||
|
indentation behavior multiline dedenter statement. (Bug#18432)
|
||||||
|
|
||||||
2014-11-15 Fabián Ezequiel Gallina <fgallina@gnu.org>
|
2014-11-15 Fabián Ezequiel Gallina <fgallina@gnu.org>
|
||||||
|
|
||||||
* progmodes/python.el (python-indent-region): Use
|
* progmodes/python.el (python-indent-region): Use
|
||||||
|
|
|
@ -955,7 +955,11 @@ START is the buffer position where the sexp starts."
|
||||||
|
|
||||||
(defun python-indent-calculate-levels ()
|
(defun python-indent-calculate-levels ()
|
||||||
"Calculate `python-indent-levels' and reset `python-indent-current-level'."
|
"Calculate `python-indent-levels' and reset `python-indent-current-level'."
|
||||||
(if (not (python-info-dedenter-statement-p))
|
(if (or (python-info-continuation-line-p)
|
||||||
|
(not (python-info-dedenter-statement-p)))
|
||||||
|
;; XXX: This asks for a refactor. Even if point is on a
|
||||||
|
;; dedenter statement, it could be multiline and in that case
|
||||||
|
;; the continuation lines should be indented with normal rules.
|
||||||
(let* ((indentation (python-indent-calculate-indentation))
|
(let* ((indentation (python-indent-calculate-indentation))
|
||||||
(remainder (% indentation python-indent-offset))
|
(remainder (% indentation python-indent-offset))
|
||||||
(steps (/ (- indentation remainder) python-indent-offset)))
|
(steps (/ (- indentation remainder) python-indent-offset)))
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
2014-11-15 Fabián Ezequiel Gallina <fgallina@gnu.org>
|
||||||
|
|
||||||
|
* automated/python-tests.el (python-indent-dedenters-8): New test
|
||||||
|
for Bug#18432.
|
||||||
|
|
||||||
2014-11-15 Fabián Ezequiel Gallina <fgallina@gnu.org>
|
2014-11-15 Fabián Ezequiel Gallina <fgallina@gnu.org>
|
||||||
|
|
||||||
* automated/python-tests.el (python-indent-region-1)
|
* automated/python-tests.el (python-indent-region-1)
|
||||||
|
|
|
@ -711,6 +711,21 @@ if a:
|
||||||
(should (= (python-indent-calculate-indentation) 0))
|
(should (= (python-indent-calculate-indentation) 0))
|
||||||
(should (equal (python-indent-calculate-levels) '(0)))))
|
(should (equal (python-indent-calculate-levels) '(0)))))
|
||||||
|
|
||||||
|
(ert-deftest python-indent-dedenters-8 ()
|
||||||
|
"Test indentation for Bug#18432."
|
||||||
|
(python-tests-with-temp-buffer
|
||||||
|
"
|
||||||
|
if (a == 1 or
|
||||||
|
a == 2):
|
||||||
|
pass
|
||||||
|
elif (a == 3 or
|
||||||
|
a == 4):
|
||||||
|
"
|
||||||
|
(python-tests-look-at "a == 4):\n")
|
||||||
|
(should (eq (car (python-indent-context)) 'inside-paren))
|
||||||
|
(should (= (python-indent-calculate-indentation) 6))
|
||||||
|
(should (equal (python-indent-calculate-levels) '(0 4 6)))))
|
||||||
|
|
||||||
(ert-deftest python-indent-electric-colon-1 ()
|
(ert-deftest python-indent-electric-colon-1 ()
|
||||||
"Test indentation case from Bug#18228."
|
"Test indentation case from Bug#18228."
|
||||||
(python-tests-with-temp-buffer
|
(python-tests-with-temp-buffer
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue