Subject: bug#45341: [PATCH] Make python-mode fontify more assignment statements

From: "Basil L. Contovounesios" <[email-masked]>
Date: Sun, 20 Dec 2020 18:04:59 +0000

Dario Gjorgjevski <[email-masked]> writes:

> +(defun python-font-lock-assignment-matcher (regexp)
> +  "Font lock matcher for assignments based on REGEXP.
> +Return nil 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."
> +  (lambda (limit)
> +    (let ((res (re-search-forward regexp limit t)))
> +      (unless (or (python-syntax-context 'paren)
> +                  (equal (char-after (point)) ?=))

Nit: char-after already defaults to looking at point, but you could also
use following-char which always returns a natnum.

-- 
Basil