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

From: Konstantin Kharlamov <[email-masked]>
Date: Tue, 21 Jan 2025 18:55:20 +0300

On Tue, 2025-01-21 at 10:47 -0500, Ship Mints wrote:
> Do you want to consider more of the terminal calls? os.exit()
> os._exit() sys.exit() quit() (though quit raises SystemExit which
> could be locally caught; I think it's equivalent to raise
> SystemExit?).
> 
> On Tue, Jan 21, 2025 at 10:43 AM Konstantin Kharlamov
> <[email-masked]> wrote:
> > `exit()` ends current codeflow, there can't be any code past it. So
> > account `exit` similarly to `return`, `continue`, etc.

Good point, thank you! I changed the patch to account for `quit` as
well.

If this is acceptable, I'd prefer to be light on the changes here and
only account for exit and quit for now because it's very simple to
support 😊

Also fixed the commit message per Eli's comment.
From bae2bc74fc6b20e482916ebd7f95e300d93aa06e Mon Sep 17 00:00:00 2001
From: Konstantin Kharlamov <[email-masked]>
Date: Tue, 21 Jan 2025 18:34:54 +0300
Subject: [PATCH] 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. So account `exit` similarly to `return`, `continue`, etc.

* /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