all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#56757: 29.0.50; Python f-string font-lock logic is incomplete
@ 2022-07-25  9:06 Dima Kogan
  2022-07-30 14:58 ` bug#56757: " Laurence Warne
  2022-07-30 15:51 ` bug#56757: 29.0.50; " Laurence Warne
  0 siblings, 2 replies; 6+ messages in thread
From: Dima Kogan @ 2022-07-25  9:06 UTC (permalink / raw)
  To: 56757

Hi. Currently python-mode has syntax highlighting to display the part of
the string being interpolated (the {...} stuff) differently from the
rest of the string. The emacs python-mode has logic to detect f-strings
to turn this highlighting on/off properly. It looks like this logic is
incomplete, however: it doesn't handle ''' and """ and r strings. (It
doesn't handle b strings either, but fb'asdf' is not legal Python, so
that's fine).

This is legal Python, and {x} is expanded to '5' in each case when the
program is executed.

  x = 5
  ss = (f'''aaa {x} bbb''',
        fr'''aaa {x} bbb''',
        rf'''aaa {x} bbb''',
        f"""aaa {x} bbb""",
        fr"""aaa {x} bbb""",
        rf"""aaa {x} bbb""",
        f'aaa {x} bbb',        # this is highlighted properly
        fr'aaa {x} bbb',
        rf'aaa {x} bbb',
        f"aaa {x} bbb",        # this is highlighted properly
        fr"aaa {x} bbb",
        rf"aaa {x} bbb",)
  for s in ss:
        print(s)

However the {x} is highlighted as code only on the lines marked above.
The other lines should have this highlighting also.

Thanks!





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

end of thread, other threads:[~2022-09-06 10:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-25  9:06 bug#56757: 29.0.50; Python f-string font-lock logic is incomplete Dima Kogan
2022-07-30 14:58 ` bug#56757: " Laurence Warne
2022-07-30 15:51 ` bug#56757: 29.0.50; " Laurence Warne
2022-09-05 19:13   ` Lars Ingebrigtsen
2022-09-06 10:08     ` Laurence Warne
2022-09-06 10:28       ` Lars Ingebrigtsen

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.