GNU bug report logs - #45341
[PATCH] Make python-mode fontify more assignment statements

Previous Next

Package: emacs;

Reported by: Dario Gjorgjevski <dario.gjorgjevski <at> gmail.com>

Date: Sun, 20 Dec 2020 16:26:01 UTC

Severity: normal

Tags: fixed, patch

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: "Basil L. Contovounesios" <contovob <at> tcd.ie>
To: Dario Gjorgjevski <dario.gjorgjevski <at> gmail.com>
Cc: 45341 <at> debbugs.gnu.org
Subject: bug#45341: [PATCH] Make python-mode fontify more assignment statements
Date: Sun, 20 Dec 2020 18:04:59 +0000
Dario Gjorgjevski <dario.gjorgjevski <at> 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




This bug report was last modified 4 years and 238 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.