From 9b814a0268e794e6d900a9a16cb45c685b7af8c3 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Sat, 21 Sep 2024 04:41:46 +0200 Subject: [PATCH] Support electric-layout-mode in python-base-mode * lisp/progmodes/python.el (python-base-mode): Add support for 'electric-layout-mode'. (cherry picked from commit dfecd6037d5ebe5778c40ff7b38bfcbaa3ef779e) --- lisp/progmodes/python.el | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index a46ac806edd..76c9cbb77a7 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -7070,6 +7070,11 @@ implementations: `python-mode' and `python-ts-mode'." (setq-local electric-indent-inhibit t) (setq-local electric-indent-chars (cons ?: electric-indent-chars)) + (setq-local electric-layout-rules + `((?: . ,(lambda () + (and (zerop (car (syntax-ppss))) + (python-info-statement-starts-block-p) + 'after))))) ;; Add """ ... """ pairing to electric-pair-mode. (add-hook 'post-self-insert-hook -- 2.39.2