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, 11 Mar 2023 11:08:32 +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:
> I type the colon after 'case 2', see it indented correctly, but also a
> message in the echo area:
> 
>   Closes case 1:
> 
> I type the next case with colon and see:
> 
>   Closes case 2:
> 
> and so on. They don't do much harm, but they still seem semantically
> incorrect.

Thank you for testing my patch.  I don't think this is a incorrect
message.  Let's discuss with the following code:

#+begin_src python
match a:
    case 1:
        print("a = 1")
        match b:
            case 2:
                print("b = 2")
                case 3
#+end_src

When I type ":" at the last line after "case 3", it will be indented
as follows:

#+begin_src python
match a:
    case 1:
        print("a = 1")
        match b:
            case 2:
                print("b = 2")
            case 3:
#+end_src

The message "Closes case 2:" is shown.  It means that the "case 3:"
corresponds to the "case 2:" in the inner "match" statement, not the
"case 1:" in the outer "match" statement.

When I type TAB twice, the line will be indented as follows:

#+begin_src python
match a:
    case 1:
        print("a = 1")
        match b:
            case 2:
                print("b = 2")
    case 3:
#+end_src

The message "Closes case 1:" is shown.  It is shown to help
distinguishing nested blocks, although it will not be useful if the
case statements are same.

This is the same behavior as "if" blocks, etc.  The term "Closes" may
not be the most appropriate for "case," but I don't think it is wrong.





reply via email to

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