bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#57004: [PATCH] Fontify Escape Sequences in Python String and Byte Li


From: Laurence Warne
Subject: bug#57004: [PATCH] Fontify Escape Sequences in Python String and Byte Literals
Date: Tue, 9 Aug 2022 09:42:57 +0100

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@gnus.org> wrote:
Laurence Warne <laurencewarne@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.

Attachment: 0001-Fix-python-escape-code-fontification-for-multi-line-.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]