all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Jakub Ječmínek" <jecminek.k@gmail.com>
To: 45897@debbugs.gnu.org
Subject: bug#45897: [PATCH] 27.1; python mode font-lock confused by string concatenation
Date: Fri, 19 Jan 2024 18:25:57 +0100	[thread overview]
Message-ID: <m2bk9h9qvu.fsf_-_@gmail.com> (raw)
In-Reply-To: <m2il3pxqfn.fsf@gmail.com> ("Jakub Ječmínek"'s message of "Fri, 19 Jan 2024 17:01:48 +0100")

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@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





  reply	other threads:[~2024-01-19 17:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-15 18:03 bug#45897: 27.1; python mode font-lock confused by string concatenation Tom Tromey
2024-01-19 16:01 ` Jakub Ječmínek
2024-01-19 17:25   ` Jakub Ječmínek [this message]
2024-01-20 10:09     ` bug#45897: [PATCH] " Eli Zaretskii
2024-01-20 15:41       ` kobarity
2024-01-20 23:33 ` Jakub Ječmínek
2024-01-21  7:39   ` kobarity
2024-01-27 10:06     ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2bk9h9qvu.fsf_-_@gmail.com \
    --to=jecminek.k@gmail.com \
    --cc=45897@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.