[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master a8acb9516e: Fix recently introduced Python font lock breakage of
From: |
Lars Ingebrigtsen |
Subject: |
master a8acb9516e: Fix recently introduced Python font lock breakage of chained assignments |
Date: |
Sat, 21 May 2022 09:24:02 -0400 (EDT) |
branch: master
commit a8acb9516e75b9b13ee988b6cbc2e6bbe1aa531c
Author: kobarity <kobarity@gmail.com>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
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).
---
lisp/progmodes/python.el | 9 ++++++---
test/lisp/progmodes/python-tests.el | 7 +++++++
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index ca744b1cfd..0761aaebdc 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -606,12 +606,15 @@ builtins.")
Search for next occurrence if REGEXP matched within a `paren'
context (to avoid, e.g., default values for arguments or passing
arguments by name being treated as assignments) or is followed by
-an '=' sign (to avoid '==' being treated as an assignment."
+an '=' sign (to avoid '==' being treated as an assignment. Set
+point to the position one character before the end of the
+occurrence found so that subsequent searches can detect the '='
+sign in chained assignment."
(lambda (limit)
(cl-loop while (re-search-forward regexp limit t)
unless (or (python-syntax-context 'paren)
(equal (char-after) ?=))
- return t)))
+ return (progn (backward-char) t))))
(defvar python-font-lock-keywords-maximum-decoration
`((python--font-lock-f-strings)
@@ -706,7 +709,7 @@ an '=' sign (to avoid '==' being treated as an assignment."
;; [a] = 5
;; [*a] = 5, 6
(,(python-font-lock-assignment-matcher
- (python-rx (or line-start ?\;) (* space)
+ (python-rx (or line-start ?\; ?=) (* space)
(or "[" "(") (* space)
grouped-assignment-target (* space)
(or ")" "]") (* space)
diff --git a/test/lisp/progmodes/python-tests.el
b/test/lisp/progmodes/python-tests.el
index 98b55a5f8b..ee7b66610a 100644
--- a/test/lisp/progmodes/python-tests.el
+++ b/test/lisp/progmodes/python-tests.el
@@ -342,6 +342,13 @@ aliqua."
(16 . font-lock-variable-name-face) (17))))
(ert-deftest python-font-lock-assignment-statement-17 ()
+ (python-tests-assert-faces
+ "(a) = (b) = 1"
+ `((1)
+ (2 . font-lock-variable-name-face) (3)
+ (8 . font-lock-variable-name-face) (9))))
+
+(ert-deftest python-font-lock-assignment-statement-18 ()
(python-tests-assert-faces
"CustomInt = int
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master a8acb9516e: Fix recently introduced Python font lock breakage of chained assignments,
Lars Ingebrigtsen <=