aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/python.el
diff options
context:
space:
mode:
authorLele Gaifax2022-05-22 10:44:31 +0200
committerLars Ingebrigtsen2022-05-22 13:22:59 +0200
commit35d0190b0b91c085c73bbe6c2b8e93ea8288b589 (patch)
tree38ba5e3c42cf4508c4167cbf96ecb8dbbd92a2b2 /lisp/progmodes/python.el
parentae8b1b8fd476b8c6240c1337c0c51763d4879ac9 (diff)
downloademacs-35d0190b0b91c085c73bbe6c2b8e93ea8288b589.tar.gz
emacs-35d0190b0b91c085c73bbe6c2b8e93ea8288b589.zip
Properly indent Python PEP634 match/case blocks
Python 3.10 introduced the "structural pattern matching" syntax, and commit 139042eb8629e6fd49b2c3002a8fc4d1aabd174d told font-lock about the new keywords. This adds them also as block-start statements, to enable proper indentation of such blocks. * lisp/progmodes/python.el (python-rx): Add "match" and "case" as block-start keywords. * test/lisp/progmodes/python-tests.el (python-indent-after-match-block, python-indent-after-case-block): New tests to verify indentation of "match" and "case" blocks (bug#55572).
Diffstat (limited to 'lisp/progmodes/python.el')
-rw-r--r--lisp/progmodes/python.el2
1 files changed, 2 insertions, 0 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 0761aaebdcc..94297d4ea5b 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -362,6 +362,8 @@ This variant of `rx' supports common Python named REGEXPS."
362 `(rx-let ((block-start (seq symbol-start 362 `(rx-let ((block-start (seq symbol-start
363 (or "def" "class" "if" "elif" "else" "try" 363 (or "def" "class" "if" "elif" "else" "try"
364 "except" "finally" "for" "while" "with" 364 "except" "finally" "for" "while" "with"
365 ;; Python 3.10+ PEP634
366 "match" "case"
365 ;; Python 3.5+ PEP492 367 ;; Python 3.5+ PEP492
366 (and "async" (+ space) 368 (and "async" (+ space)
367 (or "def" "for" "with"))) 369 (or "def" "for" "with")))