aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/python.el
diff options
context:
space:
mode:
authorKonstantin Kharlamov2025-01-21 18:34:54 +0300
committerEli Zaretskii2025-01-25 12:51:27 +0200
commit0514619b2c944ae17fbf649496595c5e866ff785 (patch)
treee91cddb00e554e6a8c318f46ae1fa7ddb6382d7b /lisp/progmodes/python.el
parent192355e54af91ad6e7d1343071a749e1ced29400 (diff)
downloademacs-0514619b2c944ae17fbf649496595c5e866ff785.tar.gz
emacs-0514619b2c944ae17fbf649496595c5e866ff785.zip
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)
Diffstat (limited to 'lisp/progmodes/python.el')
-rw-r--r--lisp/progmodes/python.el15
1 files changed, 11 insertions, 4 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 16c296a8f86..c00de2d6a8d 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -440,10 +440,17 @@ This variant of `rx' supports common Python named REGEXPS."
440 (dedenter (seq symbol-start 440 (dedenter (seq symbol-start
441 (or "elif" "else" "except" "finally" "case") 441 (or "elif" "else" "except" "finally" "case")
442 symbol-end)) 442 symbol-end))
443 (block-ender (seq symbol-start 443 (block-ender (seq
444 (or 444 symbol-start
445 "break" "continue" "pass" "raise" "return") 445 (or
446 symbol-end)) 446 (seq (or
447 "break" "continue" "pass" "raise" "return")
448 symbol-end)
449 (seq
450 (or
451 (seq (? (or (seq "os." (? ?_)) "sys.")) "exit")
452 "quit")
453 (* space) "("))))
447 (decorator (seq line-start (* space) ?@ (any letter ?_) 454 (decorator (seq line-start (* space) ?@ (any letter ?_)
448 (* (any word ?_)))) 455 (* (any word ?_))))
449 (defun (seq symbol-start 456 (defun (seq symbol-start