all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: kobarity <kobarity@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: "Andreas Röhler" <andreas.roehler@easy-emacs.de>,
	"Lin Sun" <sunlin7.mail@gmail.com>,
	71093@debbugs.gnu.org
Subject: bug#71093: 30.0.50; python: multiple assignments not fontified
Date: Fri, 24 May 2024 21:17:39 +0900	[thread overview]
Message-ID: <eke74jan1k0s.wl-kobarity@gmail.com> (raw)
In-Reply-To: <86h6eo4qp2.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 590 bytes --]


Eli Zaretskii wrote:
> 
> > Date: Tue, 21 May 2024 12:47:57 +0200
> > From: Andreas Röhler <andreas.roehler@easy-emacs.de>
> > 
> > a = b = c = 5
> > 
> > b and c are not fontified
> 
> Can someone please look into fixing this?  python-ts-mode does TRT,
> btw.

Sorry, this bug was introduced by my commit
4915ca5dd4245a909c046e6691e8d4a1919890c8.  I canceled it in commit
6b2c8dc9050c5c0514fa404733ce1d4a37d00e39 due to a performance issue,
but the cancellation was incomplete.  Attached is the patch to fix
this in master with an ERT.  Is it better to fix in emacs-29?

[-- Attachment #2: 0001-Fix-Python-font-lock-of-chained-assignment-statement.patch --]
[-- Type: application/octet-stream, Size: 2137 bytes --]

From 0476507cc1fb77217fe051f6261c9a9a1d38243c Mon Sep 17 00:00:00 2001
From: kobarity <kobarity@gmail.com>
Date: Fri, 24 May 2024 21:00:59 +0900
Subject: [PATCH] Fix Python font lock of chained assignment statement

* lisp/progmodes/python.el
(python-font-lock-keywords-maximum-decoration): Allow chaining of single
assignment statements.
* test/lisp/progmodes/python-tests.el
(python-font-lock-assignment-statement-20): New test. (Bug#71093)
---
 lisp/progmodes/python.el            |  3 +--
 test/lisp/progmodes/python-tests.el | 10 ++++++++++
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 360936c9efd..fea52b2f7d6 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -800,8 +800,7 @@ python-font-lock-keywords-maximum-decoration
     ;;   c: Collection = {1, 2, 3}
     ;;   d: Mapping[int, str] = {1: 'bar', 2: 'baz'}
     (,(python-font-lock-assignment-matcher
-       (python-rx (or line-start ?\;) (* space)
-                  grouped-assignment-target (* space)
+       (python-rx grouped-assignment-target (* space)
                   (? ?: (* space) (group (+ not-simple-operator)) (* space))
                   (group assignment-operator)))
      (1 font-lock-variable-name-face)
diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el
index b19c5c31f16..de6a4316758 100644
--- a/test/lisp/progmodes/python-tests.el
+++ b/test/lisp/progmodes/python-tests.el
@@ -502,6 +502,16 @@ python-font-lock-assignment-statement-19
      (31 . font-lock-type-face) (40)
      (43 . font-lock-operator-face) (44))))
 
+(ert-deftest python-font-lock-assignment-statement-20 ()
+  (python-tests-assert-faces
+   "a = b = c = 1"
+   '((1 . font-lock-variable-name-face) (2)
+     (3 . font-lock-operator-face) (4)
+     (5 . font-lock-variable-name-face) (6)
+     (7 . font-lock-operator-face) (8)
+     (9 . font-lock-variable-name-face) (10)
+     (11 . font-lock-operator-face) (12))))
+
 (ert-deftest python-font-lock-operator-1 ()
   (python-tests-assert-faces
    "1 << 2 ** 3 == +4%-5|~6&7^8%9"
-- 
2.34.1


  reply	other threads:[~2024-05-24 12:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-21 10:47 bug#71093: 30.0.50; python: multiple assignments not fontified Andreas Röhler
2024-05-23 13:12 ` Eli Zaretskii
2024-05-24 12:17   ` kobarity [this message]
2024-05-24 12:46     ` Eli Zaretskii
2024-05-24 13:54       ` kobarity
2024-05-24 14:54         ` Eli Zaretskii
2024-05-26  1:10           ` kobarity
2024-05-26  8:21             ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=eke74jan1k0s.wl-kobarity@gmail.com \
    --to=kobarity@gmail.com \
    --cc=71093@debbugs.gnu.org \
    --cc=andreas.roehler@easy-emacs.de \
    --cc=eliz@gnu.org \
    --cc=sunlin7.mail@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.