aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/python.el
diff options
context:
space:
mode:
authorkobarity2024-12-11 23:21:04 +0900
committerStefan Monnier2024-12-13 18:33:41 -0500
commit71cd290c20dbbd8b14f09818b3c1b58623aea350 (patch)
tree25aaadfef60b1b4175e77020189ce6e272c7e7aa /lisp/progmodes/python.el
parentdde5d0a41e2a700f2eb17e93a5e5586195c5780d (diff)
downloademacs-71cd290c20dbbd8b14f09818b3c1b58623aea350.tar.gz
emacs-71cd290c20dbbd8b14f09818b3c1b58623aea350.zip
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)
Diffstat (limited to 'lisp/progmodes/python.el')
-rw-r--r--lisp/progmodes/python.el4
1 files changed, 3 insertions, 1 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 4a1cfc6c072..5729b12573f 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -623,7 +623,9 @@ the {...} holes that appear within f-strings."
623 (forward-char 1) ;Just skip over {{ 623 (forward-char 1) ;Just skip over {{
624 (let ((beg (match-beginning 0)) 624 (let ((beg (match-beginning 0))
625 (end (condition-case nil 625 (end (condition-case nil
626 (progn (up-list 1) (min send (point))) 626 (let ((parse-sexp-ignore-comments))
627 (up-list 1)
628 (min send (point)))
627 (scan-error send)))) 629 (scan-error send))))
628 (goto-char end) 630 (goto-char end)
629 (put-text-property beg end 'face nil)))) 631 (put-text-property beg end 'face nil))))