aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/python.el
diff options
context:
space:
mode:
authorStefan Kangas2024-10-04 23:31:09 +0200
committerStefan Kangas2024-10-04 23:39:22 +0200
commitee6e737fdf7a1bea3abec383a1bf0ae69ac8ca77 (patch)
tree489cb433eced1d2579050ee597ef8f84271ecfce /lisp/progmodes/python.el
parente9727982cf62d0848056a9f3e42e8e719a609c8d (diff)
downloademacs-ee6e737fdf7a1bea3abec383a1bf0ae69ac8ca77.tar.gz
emacs-ee6e737fdf7a1bea3abec383a1bf0ae69ac8ca77.zip
python: Better support := in electric-layout-mode
* lisp/progmodes/python.el (python-base-mode): Use heuristic to better support the Python walrus operator := in electric-layout-rules.
Diffstat (limited to 'lisp/progmodes/python.el')
-rw-r--r--lisp/progmodes/python.el5
1 files changed, 5 insertions, 0 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 56c80c8264b..7576bae9f95 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -7090,6 +7090,11 @@ implementations: `python-mode' and `python-ts-mode'."
7090 `((?: . ,(lambda () 7090 `((?: . ,(lambda ()
7091 (and (zerop (car (syntax-ppss))) 7091 (and (zerop (car (syntax-ppss)))
7092 (python-info-statement-starts-block-p) 7092 (python-info-statement-starts-block-p)
7093 ;; Heuristic: assume walrus operator :=
7094 ;; when colon is preceded by space.
7095 (save-excursion
7096 (goto-char (- (point) 2))
7097 (looking-at (rx (not space) ":")))
7093 'after))))) 7098 'after)))))
7094 7099
7095 ;; Add """ ... """ pairing to electric-pair-mode. 7100 ;; Add """ ... """ pairing to electric-pair-mode.