aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/python.el
diff options
context:
space:
mode:
authorkobarity2022-05-16 15:40:17 +0200
committerLars Ingebrigtsen2022-05-16 15:40:17 +0200
commitc44908c0593a2c3aab6468144643ccd003084afa (patch)
tree43bd441f1a6086b999173139ec19c0b07ba7a72f /lisp/progmodes/python.el
parented71839c33f9dad1de4bdf6911dafbe4a571136b (diff)
downloademacs-c44908c0593a2c3aab6468144643ccd003084afa.tar.gz
emacs-c44908c0593a2c3aab6468144643ccd003084afa.zip
Fix Python highlighting of some assignment statements
* lisp/progmodes/python.el (python-rx): Limit not-simple-operator to a single line (bug#51362).
Diffstat (limited to 'lisp/progmodes/python.el')
-rw-r--r--lisp/progmodes/python.el18
1 files changed, 9 insertions, 9 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index cb4be10f5cc..ca744b1cfde 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -394,7 +394,7 @@ This variant of `rx' supports common Python named REGEXPS."
394 (open-paren (or "{" "[" "(")) 394 (open-paren (or "{" "[" "("))
395 (close-paren (or "}" "]" ")")) 395 (close-paren (or "}" "]" ")"))
396 (simple-operator (any ?+ ?- ?/ ?& ?^ ?~ ?| ?* ?< ?> ?= ?%)) 396 (simple-operator (any ?+ ?- ?/ ?& ?^ ?~ ?| ?* ?< ?> ?= ?%))
397 (not-simple-operator (not simple-operator)) 397 (not-simple-operator (not (or simple-operator ?\n)))
398 (operator (or "==" ">=" "is" "not" 398 (operator (or "==" ">=" "is" "not"
399 "**" "//" "<<" ">>" "<=" "!=" 399 "**" "//" "<<" ">>" "<=" "!="
400 "+" "-" "/" "&" "^" "~" "|" "*" "<" ">" 400 "+" "-" "/" "&" "^" "~" "|" "*" "<" ">"
@@ -603,15 +603,15 @@ builtins.")
603 603
604(defun python-font-lock-assignment-matcher (regexp) 604(defun python-font-lock-assignment-matcher (regexp)
605 "Font lock matcher for assignments based on REGEXP. 605 "Font lock matcher for assignments based on REGEXP.
606Return nil if REGEXP matched within a `paren' context (to avoid, 606Search for next occurrence if REGEXP matched within a `paren'
607e.g., default values for arguments or passing arguments by name 607context (to avoid, e.g., default values for arguments or passing
608being treated as assignments) or is followed by an '=' sign (to 608arguments by name being treated as assignments) or is followed by
609avoid '==' being treated as an assignment." 609an '=' sign (to avoid '==' being treated as an assignment."
610 (lambda (limit) 610 (lambda (limit)
611 (let ((res (re-search-forward regexp limit t))) 611 (cl-loop while (re-search-forward regexp limit t)
612 (unless (or (python-syntax-context 'paren) 612 unless (or (python-syntax-context 'paren)
613 (equal (char-after (point)) ?=)) 613 (equal (char-after) ?=))
614 res)))) 614 return t)))
615 615
616(defvar python-font-lock-keywords-maximum-decoration 616(defvar python-font-lock-keywords-maximum-decoration
617 `((python--font-lock-f-strings) 617 `((python--font-lock-f-strings)