unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#64215: Python raw format strings highlighted as regular strings
@ 2023-06-21 20:07 Joseph Garvin
  2023-06-22  6:01 ` Eli Zaretskii
  0 siblings, 1 reply; 2+ messages in thread
From: Joseph Garvin @ 2023-06-21 20:07 UTC (permalink / raw)
  To: 64215

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

Start emacs with `emacs -Q`, press C-x C-f and type in a filename that
ends in .py like "foo.py". Then type in:

x = 3
rf"hello {x} world"

The whole string will be colored as a string literal. r means "raw" which
means no escape sequences and f means this is a format string where we can
interpolate variables like x. Delete the leading 'r' and the highlighting
will change so that {x} is not highlighted, since it's code. However, raw
and format strings are not mutually exclusive and it should be considered
code in both cases. If you run the snippet above in the interpreter you
will get "hello 3 world".

In GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo
version 1.16.0, Xaw3d scroll bars)
 of 2021-05-14 built on eruv
Repository revision: efc24f1e0bb127481bcc9c3054c57c4cd3c99aa9
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12013000
System Description: Ubuntu 20.04.6 LTS

[-- Attachment #2: Type: text/html, Size: 1110 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* bug#64215: Python raw format strings highlighted as regular strings
  2023-06-21 20:07 bug#64215: Python raw format strings highlighted as regular strings Joseph Garvin
@ 2023-06-22  6:01 ` Eli Zaretskii
  0 siblings, 0 replies; 2+ messages in thread
From: Eli Zaretskii @ 2023-06-22  6:01 UTC (permalink / raw)
  To: Joseph Garvin; +Cc: 64215-done

> From: Joseph Garvin <joseph.h.garvin@gmail.com>
> Date: Wed, 21 Jun 2023 15:07:19 -0500
> 
> Start emacs with `emacs -Q`, press C-x C-f and type in a filename that
> ends in .py like "foo.py". Then type in:
> 
> x = 3
> rf"hello {x} world"
> 
> The whole string will be colored as a string literal. r means "raw" which means no escape sequences
> and f means this is a format string where we can interpolate variables like x. Delete the leading 'r' and
> the highlighting will change so that {x} is not highlighted, since it's code. However, raw and format
> strings are not mutually exclusive and it should be considered code in both cases. If you run the
> snippet above in the interpreter you will get "hello 3 world".
> 
> In GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw3d scroll
> bars)
>  of 2021-05-14 built on eruv

Thanks.

You are using a pretest version of Emacs 28.1.  I can reproduce the
problem in Emacs 28, but not in what will soon become Emacs 29.  So I
think we already fixed this problem, and I'm therefore closing this
bug.





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-06-22  6:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-21 20:07 bug#64215: Python raw format strings highlighted as regular strings Joseph Garvin
2023-06-22  6:01 ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).