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: Sun, 17 Dec 2023 15:46:29 +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> <83le9umhzh.fsf@gnu.org> <6b009ad5-2a09-f4e5-8ebe-8a7744692473@gutov.dev> <2C8AF27C-596F-4F7B-879C-9EB7497C45D1@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15278"; 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: Eli Zaretskii , 67262@debbugs.gnu.org, JD Smith To: Yuan Fu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Dec 17 14:47:14 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 1rErU7-0003fS-Ob for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 17 Dec 2023 14:47:13 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rErU2-00040B-Cx; Sun, 17 Dec 2023 08:47:06 -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 1rErU0-0003zn-Ff for bug-gnu-emacs@gnu.org; Sun, 17 Dec 2023 08:47:04 -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 1rErTx-00076I-1K for bug-gnu-emacs@gnu.org; Sun, 17 Dec 2023 08:47:04 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rErTx-0006Nd-Sp for bug-gnu-emacs@gnu.org; Sun, 17 Dec 2023 08:47:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 17 Dec 2023 13:47:01 +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.170282080224495 (code B ref 67262); Sun, 17 Dec 2023 13:47:01 +0000 Original-Received: (at 67262) by debbugs.gnu.org; 17 Dec 2023 13:46:42 +0000 Original-Received: from localhost ([127.0.0.1]:56774 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rErTe-0006N0-4g for submit@debbugs.gnu.org; Sun, 17 Dec 2023 08:46:42 -0500 Original-Received: from out1-smtp.messagingengine.com ([66.111.4.25]:33845) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rErTc-0006Mn-S9 for 67262@debbugs.gnu.org; Sun, 17 Dec 2023 08:46:41 -0500 Original-Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 5BC845C0110; Sun, 17 Dec 2023 08:46:34 -0500 (EST) Original-Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Sun, 17 Dec 2023 08:46:34 -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=1702820794; x=1702907194; bh=wwgxtHDH4VKMnAOb0FyDOIaE82uGM74kRmAv/n0xCmo=; b= oeHp4KJ/wEKkGH7nJxOEqUmapeM6JfHp4zM2Bicrs0KWLWet44OUxeaRO5EplSYM a+VvvEKuccraBVIn1WyNRMc0zDTKfJ1S6r4VaTPOvHSyZWuAarDEn+7Us3TKpqHp IRsOMztizSpmzKA43oU9u3rBliSRUaph3Lh7DhX4df6lcCYR+PUrgdoZ53zVCcOs Akl/gQZWQQZ9X158Y42PLa/wW36W21shgjYKWwaxGSff2k6j0G888dYyIRRo838o +bkBtHN9J74qVeg2T/kVGOr+4CcunBmgjRgloifmt+p1ZdrxGtKHudD+3mDj2peN +UyK0hhY7mTNLaFl8DP47A== 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=fm2; t=1702820794; x= 1702907194; bh=wwgxtHDH4VKMnAOb0FyDOIaE82uGM74kRmAv/n0xCmo=; b=o h/l0jNUkN1ImeYZgKtoFcUJeeQ4yV7l9P9vtBw/t4KmdBH2Ohuuw9flVniWZNVWX SSDCL+XuxkQhb4wuq7nHsW7xOyhGaXD14XA34KRY5YIAGHWYh9fqTeKeAfCr0Wbf 2FxlyvDYHjIybKv6LUN142BjCqCFzroCGeF/kQgl65T9rfSTaviCZ31jHIgYorWU ypJZCODmGjSsgjjiCo2TbTqaM+MP9LkGlvsDTmYk4WOLkxaOmwtLZEUkaan/yAk2 9kyNr8pjXvW4kbkJ1GY03FrC12XN0k91c7WF4SkTGUFPSZMCWKRGcEmtvx4+4mmw J8mUuTCkXhuj5MHcGTyJA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvddtiedgheegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvvehfhfgjtgfgsehtkeertddtfeejnecuhfhrohhmpeffmhhi thhrhicuifhuthhovhcuoegumhhithhrhiesghhuthhovhdruggvvheqnecuggftrfgrth htvghrnhephfffheeljeffgeffueeghfekkedtfffgheejvdegjeettdduheeufffggfef jeehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepug hmihhtrhihsehguhhtohhvrdguvghv X-ME-Proxy: Feedback-ID: i0e71465a:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 17 Dec 2023 08:46:32 -0500 (EST) Content-Language: en-US In-Reply-To: <2C8AF27C-596F-4F7B-879C-9EB7497C45D1@gmail.com> 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:276423 Archived-At: On 17/12/2023 01:36, Yuan Fu wrote: > How do you think of this patch? This extends the patch in bug#66732, and adds correct text property to the quotes (I think). I do believe the common pattern should be followed here: a syntax-propertize-function and a call to syntax-ppss-flush-cache to invalidate when appropriate. See my patch in this bug for reference. The reasons are performance (deferring work) and keeping state management logic in one place. With your patch in particular, try this: 1. Type """foo -- no text properties. 2. Add """. Check the 3rd and 4th quote characters with 'C-u C-x ='. Both should have the (15) 'syntax-table' text property applied. 4. Backspace. Syntax highlighting changes -- the string is not highlighted now (that's good, I guess). But both 3rd and 4th quote chars retain the text property. (python-info-triple-quoted-string-p) still returns the same value, and, more importantly, (syntax-ppss) does too. 5. Backspace 2 more times (the text in the buffer is now '"""foo'). The 4th quote is gone now, but the 3rd still has the text property. (nth 3 (syntax-ppss)) still returns t, and (python-info-triple-quoted-string-p) still returns the same value. On steps 1 and 5 the buffer contents are the same, but the syntax-table properties are different. > It doesn’t handle the case of “””””” (no content inside the quotes), but I think that’s fine? It might be important for some callers of (python-info-triple-quoted-string-p). But it should be pretty easy to fix, now or later.