diff options
| author | kobarity | 2022-05-16 15:40:17 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2022-05-16 15:40:17 +0200 |
| commit | c44908c0593a2c3aab6468144643ccd003084afa (patch) | |
| tree | 43bd441f1a6086b999173139ec19c0b07ba7a72f /lisp/progmodes/python.el | |
| parent | ed71839c33f9dad1de4bdf6911dafbe4a571136b (diff) | |
| download | emacs-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.el | 18 |
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. |
| 606 | Return nil if REGEXP matched within a `paren' context (to avoid, | 606 | Search for next occurrence if REGEXP matched within a `paren' |
| 607 | e.g., default values for arguments or passing arguments by name | 607 | context (to avoid, e.g., default values for arguments or passing |
| 608 | being treated as assignments) or is followed by an '=' sign (to | 608 | arguments by name being treated as assignments) or is followed by |
| 609 | avoid '==' being treated as an assignment." | 609 | an '=' 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) |