bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#62092: 30.0.50; "case" does not work as dedenter in Python


From: kobarity
Subject: bug#62092: 30.0.50; "case" does not work as dedenter in Python
Date: Sat, 25 Mar 2023 23:13:06 +0900
User-agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (Gojō) APEL-LB/10.8 EasyPG/1.0.0 Emacs/30.0.50 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO)

Dmitry Gutov wrote:
> Pushed your change to emacs-29, and closing. Thanks!

Thank you for applying the patch.  However, I overlooked one problem.

#+begin_src python
match a:
    case 1:
        match b:
            case 2
#+end_src

When I type ":" at the last line after "case 2", the message "Closes
case 1:" is shown.  This is wrong because it cannot be the "case"
block of the outer "match" block (match a:).  I'm sorry if you were
mentioning this case.

Similar message can be shown with "elif":

#+begin_src python
for c in (1, 2):
    if a == 1:
        for d in (3, 4):
            elif b == 1:
#+end_src

However, this is not a correct Python code because "elif" cannot be
the first sentence in a block.

Dedenters other than "case" can never be the first sentence of a
block, whereas "case" can be the first sentence of a block.

So I think it is appropriate that the first "case" in the block should
not be considered a dedenter.  Attached is a patch to add a condition
in `python-info-dedenter-statement-p'.

Attachment: 0001-Improve-indenting-case-in-Python.patch
Description: Binary data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]