From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#67262: python-ts-mode cannot identify triple-quoted-strings Date: Tue, 12 Dec 2023 23:55:43 +0200 Message-ID: References: <66A741A1-38B8-40C9-BE84-AF99F74A079F@gmail.com> <838r6vm3dj.fsf@gnu.org> <9bfc5e6f-3612-115f-a59d-35ad629bdf9e@gutov.dev> <83v89qcfsb.fsf@gnu.org> <9B8C904A-3729-44AF-82F7-3BEA849F46D0@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28031"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Cc: 67262@debbugs.gnu.org To: Yuan Fu , JD Smith , Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Dec 12 22:57:02 2023 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 1rDAkP-00072O-3H for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 12 Dec 2023 22:57:01 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rDAkE-0005Kj-Tk; Tue, 12 Dec 2023 16:56:50 -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 1rDAkC-0005KI-0j for bug-gnu-emacs@gnu.org; Tue, 12 Dec 2023 16:56:48 -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 1rDAkB-0006Y5-BU for bug-gnu-emacs@gnu.org; Tue, 12 Dec 2023 16:56:47 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rDAkQ-0002AL-G4 for bug-gnu-emacs@gnu.org; Tue, 12 Dec 2023 16:57:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 12 Dec 2023 21:57:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67262 X-GNU-PR-Package: emacs Original-Received: via spool by 67262-submit@debbugs.gnu.org id=B67262.17024181738260 (code B ref 67262); Tue, 12 Dec 2023 21:57:02 +0000 Original-Received: (at 67262) by debbugs.gnu.org; 12 Dec 2023 21:56:13 +0000 Original-Received: from localhost ([127.0.0.1]:57847 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rDAjc-000299-GJ for submit@debbugs.gnu.org; Tue, 12 Dec 2023 16:56:12 -0500 Original-Received: from wout3-smtp.messagingengine.com ([64.147.123.19]:47709) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rDAja-00028x-KC for 67262@debbugs.gnu.org; Tue, 12 Dec 2023 16:56:11 -0500 Original-Received: from compute7.internal (compute7.nyi.internal [10.202.2.48]) by mailout.west.internal (Postfix) with ESMTP id D0D353200AA7; Tue, 12 Dec 2023 16:55:48 -0500 (EST) Original-Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Tue, 12 Dec 2023 16:55:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1702418148; x=1702504548; bh=g5hQJD84+yV+rDVZNbUs4FP1ex/wD+xrOi0oGD9aA2s=; b= jivUMJnMaehS+8Mq64PcjhVJKc7dhqH5yOKGzAqueTf2Xfmeo+vpjJC1jQqS/kPf jHVs8e+0CQ+hHgV/GYUnZ8KiXvyX5BS+DdzC09DutAvOhyvzqf61RzfnyVYcXcKo XbB1HYVIDwDdUimoinPW/pKzDFPofLDaowdcgQJBTlz0wDpuxLaovo60c1Bjt2g8 x4odcTcek3DgDhhnHPrRsj1QStyOOypD9p9spMlp1vymmuqbV8UScn/8dIQRXD/H y2ZJu+rq60x9ZOAzTXkWbnjmwck5kLNJrOeBYsF9jrH6VMmXPZNZWLz+nz2Io3c6 UZBIMGg/AXRaWLOJMfQMUg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1702418148; x= 1702504548; bh=g5hQJD84+yV+rDVZNbUs4FP1ex/wD+xrOi0oGD9aA2s=; b=S OC71ucM8pDGyw2O0Nr5J+CXUPkX6KKf3kug1Fh2LU9aWoDyWPMTF+HLjtf8g7qD5 +s2GX4eanjil/CCKHk9Zyw901KyckgoOBbBuR9LCZa028U4JFvbcN8HYcWxE45I2 bNzkRlRLrJl4aeZVYvYm8b+G2Po5j9U7yolDJseQrLvhsdTu5M/HBEh1V9+SgCXB S0j3KNDQ0nkGUef4Fx38/j5Vx7RaclXJQC3trqM0/RyrsrTr/a0l4IFzSo/GfFj+ Zxbzy7AF5oOFEFe7F6gAzD+45+N4oDVIZ6YjPAsSfvpcHscQmnOqhmqR28soH+VB o1dSoYg3cpkK5g6upBMgQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudelgedgudehvdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefkffggfgfuvfevfhfhjggtgfesthejredttdefjeenucfhrhhomhepffhm ihhtrhihucfiuhhtohhvuceoughmihhtrhihsehguhhtohhvrdguvghvqeenucggtffrrg htthgvrhhnpeeigfetveehveevffehledtueekieeikeeufeegudfgfeeghfdulefgfeev ledvveenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe gumhhithhrhiesghhuthhovhdruggvvh X-ME-Proxy: Feedback-ID: i0e71465a:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 12 Dec 2023 16:55:46 -0500 (EST) Content-Language: en-US In-Reply-To: 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:276093 Archived-At: On 12/12/2023 10:32, Yuan Fu wrote: >> syntax-ppss-flush-cache is called by edits (and by the re-parse). It >> seems like it will be odd to have execution the other way around >> and/or add some hook into it which would call the re-parse and extend >> the region to be invalidated. >> >> syntax-propertize could have another hook added, yes. Or an advice. >> >> But it seems better to reuse some of the existing hooks, such as >> syntax-propertize-extend-region-functions. It treesit.c provided a way >> to fetch the newly-invalidated region, the treesit-major-mode-setup >> could add a new function to syntax-propertize-extend-region-functions >> which would invoke that feature. But even now it can instantiate the >> parse, which would call treesit-force-reparse internally, and then >> collect the info from the callbacks. > syntax-propertize-extend-region-functions looks perfect. We just need to > force a reparse in it and the notifier will do the rest. >> >> And yet another way - is to extend the region to be propertized from >> inside the major mode's syntax-propertize-function, invalidating some >> earlier entries too. The main problem with that, I think, is that >> every ts mode will have to repeat that trick. And that authors would >> have to know to do that. How to make that easier and more obvious, is >> a question. >> >> Finally, if I'm right that bug#66732 has a similar cause, then a >> shared solution that can be reused by syntax and font-lock (or >> preferably just fix both in the same place) would be ideal. >> >>> I'm not quite sure about how do we cause this re-parse. The >>> straightforward approach would be calling treesit-force-reparse[1] in >>> syntax-propertize/syntax-ppss-flush-cache. But ideally I'd like to >>> keep tree-sitter transparent for syntax.el. Maybe we can add a hook >>> in syntax-propertize/syntax-ppss-flush-cache. >>> >>> [1] This function doesn't exist yet, but it's easy to define in lisp. >> >> treesit-parser-root-node calls it anyway and does little else, so we >> could get by with just using it. >> > Yep. For the casual observer: I posted a solution using the above method in comments to bug#66732 yesterday.