From: Konstantin Kharlamov Date: Tue, 21 Jan 2025 15:34:54 +0000 (+0300) Subject: python-mode: add 'exit' and 'quit' to the list of block-enders X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=f88bfa5bacb6edba7ebceafbb264169a01cd5157;p=emacs.git 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()', 'os.exit()', 'os._exit()', 'sys.exit()' and 'quit()', decrease the indentation level. * /lisp/progmodes/python.el (python-rx): Add 'exit()', 'os.exit()', 'os._exit()', 'sys.exit()', 'quit' to the list of block-enders. (Bug#75729) (cherry picked from commit 0514619b2c944ae17fbf649496595c5e866ff785) --- diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 6f0435efd47..3a1d64d8251 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -434,10 +434,17 @@ This variant of `rx' supports common Python named REGEXPS." (dedenter (seq symbol-start (or "elif" "else" "except" "finally" "case") symbol-end)) - (block-ender (seq symbol-start - (or - "break" "continue" "pass" "raise" "return") - symbol-end)) + (block-ender (seq + symbol-start + (or + (seq (or + "break" "continue" "pass" "raise" "return") + symbol-end) + (seq + (or + (seq (? (or (seq "os." (? ?_)) "sys.")) "exit") + "quit") + (* space) "(")))) (decorator (seq line-start (* space) ?@ (any letter ?_) (* (any word ?_)))) (defun (seq symbol-start