GNU bug report logs - #57004
[PATCH] Fontify Escape Sequences in Python String and Byte Literals

Previous Next

Package: emacs;

Reported by: Laurence Warne <laurencewarne <at> gmail.com>

Date: Fri, 5 Aug 2022 13:08:01 UTC

Severity: normal

Tags: patch

Fixed in version 29.1

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

Bug is archived. No further changes may be made.

Full log


Message #13 received at 57004 <at> debbugs.gnu.org (full text, mbox):

From: Laurence Warne <laurencewarne <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 57004 <at> debbugs.gnu.org
Subject: Re: bug#57004: [PATCH] Fontify Escape Sequences in Python String and
 Byte Literals
Date: Tue, 9 Aug 2022 09:42:57 +0100
[Message part 1 (text/plain, inline)]
Great, thanks.  I saw a few bugs playing around a bit more:

1) Consecutive escape codes not fontified:
b'\x12\x23'  # Here only "\x12" would be fontified
2) Multi-line bytes literals fontified as string literals:
b'''\x12 \777 \1\23 \u1234'''  # Here '\u1234" would be (incorrectly)
fontified
3) Octal escape codes may be one to three characters instead of always
three (
https://docs.python.org/3/reference/lexical_analysis.html#escape-sequences):
"\1 \12 \123"  # Here only "\123" would be fontified

I've attached a patch which fixes the above and adds a new test.  The new
test (tests different combinations of multi-line literals) makes up the
majority of the diff.

Thanks, Laurence

On Sat, Aug 6, 2022 at 2:02 PM Lars Ingebrigtsen <larsi <at> gnus.org> wrote:

> Laurence Warne <laurencewarne <at> gmail.com> writes:
>
> > Hi, this patch implements escape code syntax highlighting within string
> an bytes
> > literals for python-mode (described at
> >
> https://docs.python.org/3/reference/lexical_analysis.html#string-and-bytes-literals
> )
> > similar to how they are highlighted by https://pygments.org.
>
> Thanks; pushed to Emacs 29.
>
>
[Message part 2 (text/html, inline)]
[0001-Fix-python-escape-code-fontification-for-multi-line-.patch (text/x-patch, attachment)]

This bug report was last modified 2 years and 285 days ago.

Previous Next


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