summaryrefslogtreecommitdiff
path: root/lisp/progmodes/python.el
diff options
context:
space:
mode:
authorkobarity <kobarity@gmail.com>2023-03-25 22:59:05 +0900
committerDmitry Gutov <dgutov@yandex.ru>2023-03-26 05:03:07 +0300
commit8f42db010d15efa21fb9007e61daedbe1e2dfa53 (patch)
tree66a42da235a2becacc7ebd3572c240b592fb0f94 /lisp/progmodes/python.el
parentc4d490490dc24c76fbead7941518ad503672d216 (diff)
downloademacs-8f42db010d15efa21fb9007e61daedbe1e2dfa53.tar.gz
Improve indenting "case" in Python
* lisp/progmodes/python.el (python-info-dedenter-statement-p): Do not consider the first "case" in the block as dedenter. * test/lisp/progmodes/python-tests.el (python-info-dedenter-opening-block-positions-7) (python-info-dedenter-statement-p-6): New tests. (Bug#62092)
Diffstat (limited to 'lisp/progmodes/python.el')
-rw-r--r--lisp/progmodes/python.el9
1 files changed, 8 insertions, 1 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 2fe88323c35..bbabce80b4d 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -5854,7 +5854,14 @@ statement."
(save-excursion
(python-nav-beginning-of-statement)
(when (and (not (python-syntax-context-type))
- (looking-at (python-rx dedenter)))
+ (looking-at (python-rx dedenter))
+ ;; Exclude the first "case" in the block.
+ (not (and (string= (match-string-no-properties 0)
+ "case")
+ (save-excursion
+ (back-to-indentation)
+ (python-util-forward-comment -1)
+ (equal (char-before) ?:)))))
(point))))
(defun python-info-line-ends-backslash-p (&optional line-number)