GNU bug report logs - #67529
29.1; Python: syntax category of code in f-strings marked as string

Previous Next

Package: emacs;

Reported by: Daniel Fleischer <danflscr <at> gmail.com>

Date: Wed, 29 Nov 2023 16:27:01 UTC

Severity: normal

Found in version 29.1

Full log


View this message in rfc822 format

From: Daniel Fleischer <danflscr <at> gmail.com>
To: 67529 <at> debbugs.gnu.org
Subject: bug#67529: 29.1; Python: syntax category of code in f-strings marked as string
Date: Wed, 29 Nov 2023 18:10:23 +0200
Hi, in python f-strings can have python code inside them:

f"Two plus two is {2+2}"
f"The value of a is {a}"
f"The first item in arr is {arr[0]}"

The function `python--font-lock-f-strings` correctly fontify 
what's inside the
{} as code.  

However syntax analysis show the content inside {} as string; run
`(syntax-ppss-context (syntax-ppss (point)))` to see. 

This has semantic implications, for example the package 
`smart-scan` can jump
between occurrences of a symbol but it won't identify the symbol 
in a
string/comment. Maybe there are other packages which use this 
syntax
information. 

Daniel




This bug report was last modified 1 year and 199 days ago.

Previous Next


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