GNU bug report logs -
#57004
[PATCH] Fontify Escape Sequences in Python String and Byte Literals
Previous Next
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.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 57004 in the body.
You can then email your comments to 57004 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#57004
; Package
emacs
.
(Fri, 05 Aug 2022 13:08:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Laurence Warne <laurencewarne <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Fri, 05 Aug 2022 13:08:01 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
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.
I've written a few tests (which should probably be expanded on (: ), an
example based on one of the test samples:
b'example 1: \n \\ \u1234 \U00010348 \N{Plus-Minus Sign}'
'example 2: \n \\ \u1234 \U00010348 \N{Plus-Minus Sign}'
e.g. in the above we see "\n", "\\" highlighted on the first line, but not
"\u1234", "\U00010348" "\N{Plus-Minus Sign}" since these items aren't valid
escape sequences in byte literals. The second line however is a string
literal, so all of the preceding items are highlighted.
Thanks, Laurence
[Message part 2 (text/html, inline)]
[0001-Fontify-python-escape-sequences-in-literals.patch (text/x-patch, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#57004
; Package
emacs
.
(Sat, 06 Aug 2022 13:03:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 57004 <at> debbugs.gnu.org (full text, mbox):
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.
bug marked as fixed in version 29.1, send any further explanations to
57004 <at> debbugs.gnu.org and Laurence Warne <laurencewarne <at> gmail.com>
Request was from
Lars Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Sat, 06 Aug 2022 13:03:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#57004
; Package
emacs
.
(Tue, 09 Aug 2022 08:44:02 GMT)
Full text and
rfc822 format available.
Message #13 received at 57004 <at> debbugs.gnu.org (full text, mbox):
[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)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#57004
; Package
emacs
.
(Tue, 09 Aug 2022 15:31:01 GMT)
Full text and
rfc822 format available.
Message #16 received at 57004 <at> debbugs.gnu.org (full text, mbox):
Laurence Warne <laurencewarne <at> gmail.com> writes:
> 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; pushed to Emacs 29.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Wed, 07 Sep 2022 11:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 2 years and 284 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.