diff options
| author | Stefan Kangas | 2024-12-16 21:48:45 +0100 |
|---|---|---|
| committer | Stefan Kangas | 2024-12-16 21:48:45 +0100 |
| commit | 02a1e3052b665b8d7d8ea122a6ecb6878c6cece0 (patch) | |
| tree | d11c93b020431ba6bd98d68cd493de31f11cf1bb | |
| parent | 5c1889c964c99fa3cb0cd91b7703d59bd9fcb495 (diff) | |
| download | emacs-02a1e3052b665b8d7d8ea122a6ecb6878c6cece0.tar.gz emacs-02a1e3052b665b8d7d8ea122a6ecb6878c6cece0.zip | |
Improve heuristic for Python walrus operator
* lisp/progmodes/python.el (python-base-mode): Improve heuristic for
Python walrus operator in 'electric-layout-mode'.
| -rw-r--r-- | lisp/progmodes/python.el | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 493eab5e611..2f8d506fc60 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -7073,11 +7073,10 @@ implementations: `python-mode' and `python-ts-mode'." | |||
| 7073 | `((?: . ,(lambda () | 7073 | `((?: . ,(lambda () |
| 7074 | (and (zerop (car (syntax-ppss))) | 7074 | (and (zerop (car (syntax-ppss))) |
| 7075 | (python-info-statement-starts-block-p) | 7075 | (python-info-statement-starts-block-p) |
| 7076 | ;; Heuristic: assume walrus operator := | 7076 | ;; Heuristic for walrus operator := |
| 7077 | ;; when colon is preceded by space. | ||
| 7078 | (save-excursion | 7077 | (save-excursion |
| 7079 | (goto-char (- (point) 2)) | 7078 | (goto-char (- (point) 2)) |
| 7080 | (looking-at (rx (not space) ":"))) | 7079 | (looking-at (rx (not space) ":" eol))) |
| 7081 | 'after))))) | 7080 | 'after))))) |
| 7082 | 7081 | ||
| 7083 | ;; Add """ ... """ pairing to electric-pair-mode. | 7082 | ;; Add """ ... """ pairing to electric-pair-mode. |