GNU bug report logs - #68445
[PATCH] Problem with python--treesit-syntax-propertize

Previous Next

Package: emacs;

Reported by: kobarity <kobarity <at> gmail.com>

Date: Sun, 14 Jan 2024 09:16:01 UTC

Severity: normal

Tags: patch

Done: Dmitry Gutov <dmitry <at> gutov.dev>

Bug is archived. No further changes may be made.

Full log


Message #14 received at 68445 <at> debbugs.gnu.org (full text, mbox):

From: kobarity <kobarity <at> gmail.com>
To: Dmitry Gutov <dmitry <at> gutov.dev>
Cc: Yuan Fu <casouri <at> gmail.com>, 68445 <at> debbugs.gnu.org
Subject: Re: [PATCH] Problem with python--treesit-syntax-propertize
Date: Tue, 23 Jan 2024 00:44:16 +0900
Hi,

Dmitry Gutov wrote:
> On 21/01/2024 16:47, kobarity wrote:
> > I am resending my mail, as I made a mistake in X-Debbugs-CC.
> Was it supposed to appear in the bug's thread? I don't see it anywhere.

My first mail was registered as Bug#68445, and my patch is there.

https://debbugs.gnu.org/cgi/bugreport.cgi?bug=68445

It says:

Report forwarded to casouri <at> gmail.com, dmitry@.gutov.dev, bug-gnu-emacs <at> gnu.org:

The extra period is my mistake and it may have caused the problem.
I'm sorry for the confusion.

> I think there is also another approach--handle two different types of
> nodes separately, instead of just string_content, so we don't have to
> start from the beginning of the literal. Like this:
> 
> diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
> index e2f614f52c2..4f8b0cb9473 100644
> --- a/lisp/progmodes/python.el
> +++ b/lisp/progmodes/python.el
> @@ -1361,13 +1361,15 @@ python--treesit-syntax-propertize
>      (while (re-search-forward (rx (or "\"\"\"" "'''")) end t)
>        (let ((node (treesit-node-at (point))))
>          ;; The triple quotes surround a non-empty string.
> -        (when (equal (treesit-node-type node) "string_content")
> -          (let ((start (treesit-node-start node))
> -                (end (treesit-node-end node)))
> -            (put-text-property (1- start) start
> -                               'syntax-table (string-to-syntax "|"))
> -            (put-text-property end (min (1+ end) (point-max))
> -                               'syntax-table (string-to-syntax "|"))))))))
> +        (cond
> +         ((equal (treesit-node-type node) "string_content")
> +          (put-text-property (1- (treesit-node-start node))
> +                             (treesit-node-start node)
> +                             'syntax-table (string-to-syntax "|")))
> +         ((and (equal (treesit-node-type node) "string_end")
> +               (= (treesit-node-start node) (- (point) 3)))
> +          (put-text-property (- (point) 3) (- (point) 2)
> +                             'syntax-table (string-to-syntax "|"))))))))
> 
>  
>  ;;; Indentation
> 

This approach seems better than my patch, but it does not seem to
address the following special case.

#+begin_src python
"""a""""""b"""
#+end_src




This bug report was last modified 1 year and 173 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.