1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-06 06:20:55 -08:00

Fix font-lock of Python f-strings

* lisp/progmodes/python.el (python--font-lock-f-strings): Bind
'parse-sexp-ignore-comments' to nil so that we can look for
closing braces even if a hash is used in the format specifier.
* test/lisp/progmodes/python-tests.el
(python-font-lock-f-string-1): New test.  (Bug#74738)
This commit is contained in:
kobarity 2024-12-11 23:21:04 +09:00 committed by Stefan Monnier
parent dde5d0a41e
commit 71cd290c20
2 changed files with 11 additions and 1 deletions

View file

@ -623,7 +623,9 @@ the {...} holes that appear within f-strings."
(forward-char 1) ;Just skip over {{
(let ((beg (match-beginning 0))
(end (condition-case nil
(progn (up-list 1) (min send (point)))
(let ((parse-sexp-ignore-comments))
(up-list 1)
(min send (point)))
(scan-error send))))
(goto-char end)
(put-text-property beg end 'face nil))))