Subject: Re: bug#75729: [PATCH v3] python-mode: add `exit` to the list of block-enders

From: Konstantin Kharlamov <[email-masked]>
Date: Tue, 21 Jan 2025 22:00:16 +0300

On Tue, 2025-01-21 at 10:52 -0800, Stefan Kangas wrote:
> Konstantin Kharlamov <[email-masked]> writes:
> 
> > diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
> > index 16c296a8f86..2feb9f47e1a 100644
> > --- a/lisp/progmodes/python.el
> > +++ b/lisp/progmodes/python.el
> > @@ -442,7 +442,8 @@ python-rx
> >                                      symbol-end))
> >              (block-ender       (seq symbol-start
> >                                      (or
> > -                                     "break" "continue" "pass"
> > "raise" "return")
> > +                                     "break" "continue" "pass"
> > "raise" "return"
> > +                                     "exit")
> >                                      symbol-end))
> >              (decorator         (seq line-start (* space) ?@ (any
> > letter ?_)
> >                                      (* (any word ?_))))
> > --
> > 2.48.1
> 
> Could you describe what behaviour changes this will result in?
> 
> I recommend something brief about that to the commit message too.

Thank you, done! I put the following text to the commit message, please
see if it describes the change well enough:

> `exit()` and `quit()` end the current codeflow, there can't be any
> code past it, similarly to `return`, `continue`, etc. So when
> calculating indentation for the line next to `exit()` and `quit()`,
> decrease the indentation level.

Patch is attached.
From 5f8af0b700192d9bcbaf3b86e50422597572094f Mon Sep 17 00:00:00 2001
From: Konstantin Kharlamov <[email-masked]>
Date: Tue, 21 Jan 2025 18:34:54 +0300
Subject: [PATCH v3] python-mode: add `exit` and `quit` to the list of
 block-enders

`exit()` and `quit()` end the current codeflow, there can't be any
code past it, similarly to `return`, `continue`, etc. So when
calculating indentation for the line next to `exit()` and `quit()`,
decrease the indentation level.

* /lisp/progmodes/python.el (python-rx): Add `exit` and `quit` to the
list of block-enders.
---
 lisp/progmodes/python.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 16c296a8f86..9fd4533f257 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -442,7 +442,8 @@ python-rx
                                     symbol-end))
             (block-ender       (seq symbol-start
                                     (or
-                                     "break" "continue" "pass" "raise" "return")
+                                     "break" "continue" "pass" "raise" "return"
+                                     "exit" "quit")
                                     symbol-end))
             (decorator         (seq line-start (* space) ?@ (any letter ?_)
                                     (* (any word ?_))))
-- 
2.48.1