mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-16 17:24:23 +00:00
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.
This commit is contained in:
parent
e9727982cf
commit
ee6e737fdf
1 changed files with 5 additions and 0 deletions
|
|
@ -7090,6 +7090,11 @@ implementations: `python-mode' and `python-ts-mode'."
|
|||
`((?: . ,(lambda ()
|
||||
(and (zerop (car (syntax-ppss)))
|
||||
(python-info-statement-starts-block-p)
|
||||
;; Heuristic: assume walrus operator :=
|
||||
;; when colon is preceded by space.
|
||||
(save-excursion
|
||||
(goto-char (- (point) 2))
|
||||
(looking-at (rx (not space) ":")))
|
||||
'after)))))
|
||||
|
||||
;; Add """ ... """ pairing to electric-pair-mode.
|
||||
|
|
|
|||
Loading…
Reference in a new issue