From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: kobarity Newsgroups: gmane.emacs.bugs Subject: bug#68445: [PATCH] Problem with python--treesit-syntax-propertize Date: Tue, 23 Jan 2024 00:44:16 +0900 Message-ID: References: <5135ab69-3704-459f-b6c7-b8ea738e8d31@gutov.dev> Mime-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2698"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?Q?Goj=C5=8D?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/30.0.50 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) Cc: Yuan Fu , 68445@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jan 22 16:45:14 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rRwU6-0000TS-O9 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 22 Jan 2024 16:45:14 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rRwTs-0000ZZ-To; Mon, 22 Jan 2024 10:45:00 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rRwTr-0000XT-6S for bug-gnu-emacs@gnu.org; Mon, 22 Jan 2024 10:44:59 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rRwTq-0000z5-6b for bug-gnu-emacs@gnu.org; Mon, 22 Jan 2024 10:44:58 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rRwTu-0007aP-15 for bug-gnu-emacs@gnu.org; Mon, 22 Jan 2024 10:45:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: kobarity Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 22 Jan 2024 15:45:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68445 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 68445-submit@debbugs.gnu.org id=B68445.170593827029084 (code B ref 68445); Mon, 22 Jan 2024 15:45:01 +0000 Original-Received: (at 68445) by debbugs.gnu.org; 22 Jan 2024 15:44:30 +0000 Original-Received: from localhost ([127.0.0.1]:41575 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rRwTN-0007Z1-Df for submit@debbugs.gnu.org; Mon, 22 Jan 2024 10:44:29 -0500 Original-Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]:60603) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rRwTI-0007Yh-LN for 68445@debbugs.gnu.org; Mon, 22 Jan 2024 10:44:28 -0500 Original-Received: by mail-pj1-x1034.google.com with SMTP id 98e67ed59e1d1-28e8c930c01so1296692a91.0 for <68445@debbugs.gnu.org>; Mon, 22 Jan 2024 07:44:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705938254; x=1706543054; darn=debbugs.gnu.org; h=mime-version:user-agent:references:in-reply-to:subject:cc:to:from :message-id:date:from:to:cc:subject:date:message-id:reply-to; bh=39sBZwQYwFCSKHsvhLc5nUjd6lao5D+twW1QsF1vB5g=; b=az40mzQfPQwn8Nna+3089QeDkU45W1DT9x7l+hsaoTcL4lqdo+1KsaSgB0CGV+7NbR hDtoIbYpAJNbUF2DbiDkS7ifu05U9FCquLSzhHoqXmaRbydiFOZB/dlm06MAB72Qsf1/ PaNLXA5IXUnMlZx+oGZHEh1atVewlSBWQSFTklBwEYV5HNXsLf/gfN1g7pPWn/B4NUpk MZaR8ReJ9HZIY6kMjXLU5GuJ77ufAVsnIP6kulhlXE22sSJ1UQDWg/3I1LDhkLKcqtGZ ErjjNsWYaYlA+5+LVvYy0FB4oNyRBBfjvESqw5TichETo+yHtxVfRy9ec6Ob6+hmNEbe 5HvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705938254; x=1706543054; h=mime-version:user-agent:references:in-reply-to:subject:cc:to:from :message-id:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=39sBZwQYwFCSKHsvhLc5nUjd6lao5D+twW1QsF1vB5g=; b=VTxIQOSGXlP/UXkyaZ2Ej7Tm0LVMtxW3HH7YSjYCafIGeDf5eEnzGrlisz+98BfBui m5DxmavUtBfuFrLJAbFsuDx7PYgpuX+AsEHPtix7PFL3WHpYkJ4nGxZ4BOrxa43cX21C W4PRVRnsKimDyA6/vrbuqc0Q452Tqut2F+TbI9Q2LMiUZyuUo0lfWzzARz7f79Szg4qi nEqPgKPAzXgwPFerm5Hypt1HNilJSrAlEYfzGpKZy1B3epndiPvPvxspUbvV18LLcm8X 0b1gzauduFEHgH8sG/6vt6TbhvQ1JOprH+uvlnc3DOGZPDmIHVCVr/3fS2A8R148Kxd6 1nLQ== X-Gm-Message-State: AOJu0YznaoRheCC4yX4gZVtWe1O8Y9gg01dIdKYmym4AgrbnpziNlL/A 0J0jzHA2XOmyqPZKdXHfmz+tTjbvUUHUxJR9saDdM/Kj+RJwCab3 X-Google-Smtp-Source: AGHT+IHU6qG6Ta6yHtZgWa+tBQeNgDAJ7pKkuMswGfp9RywRL6Rwx6xFJxh+O+QJztPcNwjyfwWkMA== X-Received: by 2002:a17:90a:df02:b0:28e:8e7b:1edf with SMTP id gp2-20020a17090adf0200b0028e8e7b1edfmr1464744pjb.75.1705938254589; Mon, 22 Jan 2024 07:44:14 -0800 (PST) Original-Received: from localhost (58x12x133x161.ap58.ftth.ucom.ne.jp. [58.12.133.161]) by smtp.gmail.com with ESMTPSA id d14-20020a17090b004e00b0029020be4298sm9712815pjt.0.2024.01.22.07.44.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 07:44:14 -0800 (PST) In-Reply-To: <5135ab69-3704-459f-b6c7-b8ea738e8d31@gutov.dev> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:278708 Archived-At: 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 gmail.com, dmitry@.gutov.dev, bug-gnu-emacs 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