diff options
| author | kobarity | 2022-05-21 15:23:21 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2022-05-21 15:23:21 +0200 |
| commit | a8acb9516e75b9b13ee988b6cbc2e6bbe1aa531c (patch) | |
| tree | 49b603528a77d9971cd00e999713bf2468406c0e /lisp/progmodes/python.el | |
| parent | 22ae842b346621095223213621f2244a5a59d3b8 (diff) | |
| download | emacs-a8acb9516e75b9b13ee988b6cbc2e6bbe1aa531c.tar.gz emacs-a8acb9516e75b9b13ee988b6cbc2e6bbe1aa531c.zip | |
Fix recently introduced Python font lock breakage of chained assignments
* lisp/progmodes/python.el (python-font-lock-assignment-matcher):
Fix fontification of chained assignments (bug#54992).
Diffstat (limited to 'lisp/progmodes/python.el')
| -rw-r--r-- | lisp/progmodes/python.el | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index ca744b1cfde..0761aaebdcc 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -606,12 +606,15 @@ builtins.") | |||
| 606 | Search for next occurrence if REGEXP matched within a `paren' | 606 | Search for next occurrence if REGEXP matched within a `paren' |
| 607 | context (to avoid, e.g., default values for arguments or passing | 607 | context (to avoid, e.g., default values for arguments or passing |
| 608 | arguments by name being treated as assignments) or is followed by | 608 | arguments by name being treated as assignments) or is followed by |
| 609 | an '=' sign (to avoid '==' being treated as an assignment." | 609 | an '=' sign (to avoid '==' being treated as an assignment. Set |
| 610 | point to the position one character before the end of the | ||
| 611 | occurrence found so that subsequent searches can detect the '=' | ||
| 612 | sign in chained assignment." | ||
| 610 | (lambda (limit) | 613 | (lambda (limit) |
| 611 | (cl-loop while (re-search-forward regexp limit t) | 614 | (cl-loop while (re-search-forward regexp limit t) |
| 612 | unless (or (python-syntax-context 'paren) | 615 | unless (or (python-syntax-context 'paren) |
| 613 | (equal (char-after) ?=)) | 616 | (equal (char-after) ?=)) |
| 614 | return t))) | 617 | return (progn (backward-char) t)))) |
| 615 | 618 | ||
| 616 | (defvar python-font-lock-keywords-maximum-decoration | 619 | (defvar python-font-lock-keywords-maximum-decoration |
| 617 | `((python--font-lock-f-strings) | 620 | `((python--font-lock-f-strings) |
| @@ -706,7 +709,7 @@ an '=' sign (to avoid '==' being treated as an assignment." | |||
| 706 | ;; [a] = 5 | 709 | ;; [a] = 5 |
| 707 | ;; [*a] = 5, 6 | 710 | ;; [*a] = 5, 6 |
| 708 | (,(python-font-lock-assignment-matcher | 711 | (,(python-font-lock-assignment-matcher |
| 709 | (python-rx (or line-start ?\;) (* space) | 712 | (python-rx (or line-start ?\; ?=) (* space) |
| 710 | (or "[" "(") (* space) | 713 | (or "[" "(") (* space) |
| 711 | grouped-assignment-target (* space) | 714 | grouped-assignment-target (* space) |
| 712 | (or ")" "]") (* space) | 715 | (or ")" "]") (* space) |