diff options
| author | Jakub Ječmínek | 2024-01-19 16:38:21 +0100 |
|---|---|---|
| committer | Eli Zaretskii | 2024-01-27 12:05:48 +0200 |
| commit | 09cdf8a406c5b73e8924a7396c2aaabe74a1a638 (patch) | |
| tree | d90ed6d61f7a1af203e4fe096b1cfe75dafd931c /lisp/progmodes/python.el | |
| parent | f0c573d8069f7ee654a550ae3d148325c49900a3 (diff) | |
| download | emacs-09cdf8a406c5b73e8924a7396c2aaabe74a1a638.tar.gz emacs-09cdf8a406c5b73e8924a7396c2aaabe74a1a638.zip | |
Fix syntax highlighting after string literal concat in python-mode
* lisp/progmodes/python.el (python-syntax-stringify): Fix
incorrect font-lock after string literal concatenation.
(Bug#45897)
* test/lisp/progmodes/python-tests.el
(python-font-lock-string-literal-concatenation): New test.
Co-authored-by: kobarity <kobarity@gmail.com>
Copyright-paperwork-exempt: yes
Diffstat (limited to 'lisp/progmodes/python.el')
| -rw-r--r-- | lisp/progmodes/python.el | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 41f612c8b1c..9d840efb9da 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -909,6 +909,7 @@ is used to limit the scan." | |||
| 909 | "Put `syntax-table' property correctly on single/triple quotes." | 909 | "Put `syntax-table' property correctly on single/triple quotes." |
| 910 | (let* ((ppss (save-excursion (backward-char 3) (syntax-ppss))) | 910 | (let* ((ppss (save-excursion (backward-char 3) (syntax-ppss))) |
| 911 | (string-start (and (eq t (nth 3 ppss)) (nth 8 ppss))) | 911 | (string-start (and (eq t (nth 3 ppss)) (nth 8 ppss))) |
| 912 | (string-literal-concat (numberp (nth 3 ppss))) | ||
| 912 | (quote-starting-pos (- (point) 3)) | 913 | (quote-starting-pos (- (point) 3)) |
| 913 | (quote-ending-pos (point))) | 914 | (quote-ending-pos (point))) |
| 914 | (cond ((or (nth 4 ppss) ;Inside a comment | 915 | (cond ((or (nth 4 ppss) ;Inside a comment |
| @@ -921,6 +922,8 @@ is used to limit the scan." | |||
| 921 | ((nth 5 ppss) | 922 | ((nth 5 ppss) |
| 922 | ;; The first quote is escaped, so it's not part of a triple quote! | 923 | ;; The first quote is escaped, so it's not part of a triple quote! |
| 923 | (goto-char (1+ quote-starting-pos))) | 924 | (goto-char (1+ quote-starting-pos))) |
| 925 | ;; Handle string literal concatenation (bug#45897) | ||
| 926 | (string-literal-concat nil) | ||
| 924 | ((null string-start) | 927 | ((null string-start) |
| 925 | ;; This set of quotes delimit the start of a string. Put | 928 | ;; This set of quotes delimit the start of a string. Put |
| 926 | ;; string fence syntax on last quote. (bug#49518) | 929 | ;; string fence syntax on last quote. (bug#49518) |