[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#45341: [PATCH] Make python-mode fontify more assignment statements
From: |
Basil L. Contovounesios |
Subject: |
bug#45341: [PATCH] Make python-mode fontify more assignment statements |
Date: |
Sun, 20 Dec 2020 18:04:59 +0000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Dario Gjorgjevski <dario.gjorgjevski@gmail.com> 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