GNU bug report logs -
#45897
27.1; python mode font-lock confused by string concatenation
Previous Next
Reported by: Tom Tromey <tom <at> tromey.com>
Date: Fri, 15 Jan 2021 18:05:02 UTC
Severity: normal
Found in version 27.1
Done: Eli Zaretskii <eliz <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
Tags: patch
I'm sending the patch once again with correct indentation and patch tag
(I'm still figuring out how the bug tracker works).
From 93d60a342c3d12b46d9fece443d63cdb4101a745 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jakub=20Je=C4=8Dm=C3=ADnek?= <jecminek.k <at> gmail.com>
Date: Fri, 19 Jan 2024 16:38:21 +0100
Subject: [PATCH] Fix syntax highlighting after string literal concatenation in
python-mode
* lisp/progmodes/python.el (python-syntax-stringify): Fix incorrect font-lock after string
literal concatenation.
---
lisp/progmodes/python.el | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index e2f614f52c2..ca014469952 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -908,7 +908,11 @@ is used to limit the scan."
(defun python-syntax-stringify ()
"Put `syntax-table' property correctly on single/triple quotes."
(let* ((ppss (save-excursion (backward-char 3) (syntax-ppss)))
+ (line-ppss (save-excursion (backward-char 3) (parse-partial-sexp
+ (line-beginning-position) (point))))
(string-start (and (eq t (nth 3 ppss)) (nth 8 ppss)))
+ (string-literal-concat (and (null string-start)
+ (and (not (null (nth 3 line-ppss))) (nth 8 line-ppss))))
(quote-starting-pos (- (point) 3))
(quote-ending-pos (point)))
(cond ((or (nth 4 ppss) ;Inside a comment
@@ -921,6 +925,8 @@ is used to limit the scan."
((nth 5 ppss)
;; The first quote is escaped, so it's not part of a triple quote!
(goto-char (1+ quote-starting-pos)))
+ ;; Handle string literal concatenation (bug#45897)
+ (string-literal-concat nil)
((null string-start)
;; This set of quotes delimit the start of a string. Put
;; string fence syntax on last quote. (bug#49518)
--
2.39.3 (Apple Git-145)
I'm more than happy to make further changes if need be.
Best,
Jakub Ječmínek
This bug report was last modified 1 year and 172 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.