From: Stefan Kangas Date: Sat, 21 Sep 2024 02:41:46 +0000 (+0200) Subject: Support electric-layout-mode in python-base-mode X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=9b814a0268e794e6d900a9a16cb45c685b7af8c3;p=emacs.git 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) --- 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