[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] [emacs] 01/01: Fixes: debbugs:18432
From: |
Fabián Ezequiel Gallina |
Subject: |
[Emacs-diffs] [emacs] 01/01: Fixes: debbugs:18432 |
Date: |
Sat, 15 Nov 2014 22:03:03 +0000 |
fgallina pushed a commit to branch emacs-24
in repository emacs.
commit 92f58578cc939e0d955437fcbc87cda80c2ba05c
Author: Fabián Ezequiel Gallina <address@hidden>
Date: Sat Nov 15 19:02:52 2014 -0300
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.
---
lisp/ChangeLog | 5 +++++
lisp/progmodes/python.el | 6 +++++-
test/ChangeLog | 5 +++++
test/automated/python-tests.el | 15 +++++++++++++++
4 files changed, 30 insertions(+), 1 deletions(-)
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index fe06ac6..d13a62a 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,10 @@
2014-11-15 Fabián Ezequiel Gallina <address@hidden>
+ * progmodes/python.el (python-indent-calculate-levels): Fix
+ indentation behavior multiline dedenter statement. (Bug#18432)
+
+2014-11-15 Fabián Ezequiel Gallina <address@hidden>
+
* progmodes/python.el (python-indent-region): Use
python-indent-line and skip special cases. (Bug#18843)
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 5f8d7a2..89b2f1f 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -955,7 +955,11 @@ START is the buffer position where the sexp starts."
(defun python-indent-calculate-levels ()
"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))
(remainder (% indentation python-indent-offset))
(steps (/ (- indentation remainder) python-indent-offset)))
diff --git a/test/ChangeLog b/test/ChangeLog
index 971a4f8..4f7f068 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,5 +1,10 @@
2014-11-15 Fabián Ezequiel Gallina <address@hidden>
+ * automated/python-tests.el (python-indent-dedenters-8): New test
+ for Bug#18432.
+
+2014-11-15 Fabián Ezequiel Gallina <address@hidden>
+
* automated/python-tests.el (python-indent-region-1)
(python-indent-region-2, python-indent-region-3)
(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 8c657c3..f368f99 100644
--- a/test/automated/python-tests.el
+++ b/test/automated/python-tests.el
@@ -711,6 +711,21 @@ if a:
(should (= (python-indent-calculate-indentation) 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 ()
"Test indentation case from Bug#18228."
(python-tests-with-temp-buffer