From 35d0190b0b91c085c73bbe6c2b8e93ea8288b589 Mon Sep 17 00:00:00 2001 From: Lele Gaifax Date: Sun, 22 May 2022 10:44:31 +0200 Subject: 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). --- lisp/progmodes/python.el | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lisp/progmodes/python.el') 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." `(rx-let ((block-start (seq symbol-start (or "def" "class" "if" "elif" "else" "try" "except" "finally" "for" "while" "with" + ;; Python 3.10+ PEP634 + "match" "case" ;; Python 3.5+ PEP492 (and "async" (+ space) (or "def" "for" "with"))) -- cgit v1.2.1