From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.bugs Subject: bug#67262: python-ts-mode cannot identify triple-quoted-strings Date: Sat, 16 Dec 2023 15:36:49 -0800 Message-ID: <2C8AF27C-596F-4F7B-879C-9EB7497C45D1@gmail.com> 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> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.700.6\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_924D19E7-C6C7-4820-9304-9AB73A97A80D" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7917"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , 67262@debbugs.gnu.org, JD Smith To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Dec 17 00:38:13 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 1rEeEX-0001na-GC for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 17 Dec 2023 00:38:13 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rEeEN-0001QO-J8; Sat, 16 Dec 2023 18:38:03 -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 1rEeEL-0001QF-9p for bug-gnu-emacs@gnu.org; Sat, 16 Dec 2023 18:38:01 -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 1rEeEL-0001wc-1a for bug-gnu-emacs@gnu.org; Sat, 16 Dec 2023 18:38:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rEeEL-0002fF-Sv for bug-gnu-emacs@gnu.org; Sat, 16 Dec 2023 18:38:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Yuan Fu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 16 Dec 2023 23:38: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.170276983310170 (code B ref 67262); Sat, 16 Dec 2023 23:38:01 +0000 Original-Received: (at 67262) by debbugs.gnu.org; 16 Dec 2023 23:37:13 +0000 Original-Received: from localhost ([127.0.0.1]:56339 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rEeDY-0002dy-Lx for submit@debbugs.gnu.org; Sat, 16 Dec 2023 18:37:12 -0500 Original-Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]:54757) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rEeDU-0002de-80 for 67262@debbugs.gnu.org; Sat, 16 Dec 2023 18:37:11 -0500 Original-Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-6ce72730548so1796733b3a.1 for <67262@debbugs.gnu.org>; Sat, 16 Dec 2023 15:37:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702769821; x=1703374621; darn=debbugs.gnu.org; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=cIkcffT0+koBbHbWB/J6IFJB3k6ZDVax+K/tWK6ZQeU=; b=BP7nOa/M9YC+99XeERjlKWCjE5r6ZMxmCNAOl3DCkUmPn9pcc5C6PXhhgWQngSRcjk o+fZ4qxZk9/QsKGWaCxg/kKsq1RnU/ps7aCvI8sx2i6GCV7iBI/ES8Cbm5XXbf+R2dCY UQ2jPC6PHqh4tNm6H4Ufz119z3r0gLEI9K3WTfv5S+Ik8oVMuD2XE4IbUaIJpIkhjvF0 uXXVM0wVSDoHV5F3Qq9usEGhHakxAHyQ8adLGnhWZmJwqbQ7zh1S0yRDpVeAV0ARBcIN lrGNkUXqc4EmgQFd3yYhBDpl1Gp0UM8kLLOtfyJU9eppMl0lt6Pv1RfV3FeGSRX6II1Y MwtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702769821; x=1703374621; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=cIkcffT0+koBbHbWB/J6IFJB3k6ZDVax+K/tWK6ZQeU=; b=GQPFKMPfzWlRUMl3E3fjkFwVDDxmzTgJdK48RL2IWEW/CtFkRp9VKqeuaPXHxXTuV5 XHkChwqmteB2Eg7C6t07sxug617l5uYe8lkMgMvBJIFG3181G/G/kJSRonWglk+TDNkG xjNkU7kE71vpfJmDn5J2sn/fUlFq5MTSY3tFi2tFCB3W4EQ+b06OxmJCIQbH2/sWYHvQ XUODSO6OzZHvpl/gE27EnNfP2ZJm6pJEYDCZ2WwXg5fDGdE5yxfbe1V4p1suSnEsIQZO Tb8sfi3drSUhempZ2BL+K/9muOxd6oX5O3iKNL8s/UDw+C63OULUaQKdVQUanU9FAIku c8gw== X-Gm-Message-State: AOJu0YxF12C+Zv4S4CgZGDm1h62YqOLBI8HxpfG6P+TWPHwWFgGswraH VUg9OKVu56JpY9FfX9qS+1g= X-Google-Smtp-Source: AGHT+IEcuR37yQVk/5sWoBmkVlNMyIkKD9PEABwWBHNyHS9Vo2eNAloHhWqQrl7eW0sZt+A+BqfVvA== X-Received: by 2002:a05:6a20:158b:b0:190:61a1:3be2 with SMTP id h11-20020a056a20158b00b0019061a13be2mr18886787pzj.97.1702769821277; Sat, 16 Dec 2023 15:37:01 -0800 (PST) Original-Received: from smtpclient.apple (172-117-161-177.res.spectrum.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id c12-20020a62e80c000000b006ce7e497302sm15458968pfi.21.2023.12.16.15.37.00 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 16 Dec 2023 15:37:00 -0800 (PST) In-Reply-To: <6b009ad5-2a09-f4e5-8ebe-8a7744692473@gutov.dev> X-Mailer: Apple Mail (2.3731.700.6) 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:276393 Archived-At: --Apple-Mail=_924D19E7-C6C7-4820-9304-9AB73A97A80D Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Dec 16, 2023, at 5:37 AM, Dmitry Gutov wrote: >=20 > On 16/12/2023 14:47, Eli Zaretskii wrote: >> How should we make progress with this bug? I'd like to fix it before >> Emacs 29.2 is released. >=20 > We're currently working on the general issue in bug#66732. How do you think of this patch? This extends the patch in bug#66732, and = adds correct text property to the quotes (I think). It doesn=E2=80=99t handle the case of =E2=80=9C=E2=80=9D=E2=80=9D=E2=80=9D= =E2=80=9D=E2=80=9D (no content inside the quotes), but I think that=E2=80=99= s fine? --Apple-Mail=_924D19E7-C6C7-4820-9304-9AB73A97A80D Content-Disposition: attachment; filename=python-triple-quote.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="python-triple-quote.patch" Content-Transfer-Encoding: quoted-printable =46rom=20b4fffdeb808f372463dca9b78814d9f6432fe13c=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20Yuan=20Fu=20=0ADate:=20Sat,=20= 16=20Dec=202023=2015:35:23=20-0800=0ASubject:=20[PATCH]=20wip=0A=0A---=0A= =20lisp/progmodes/python.el=20|=2019=20+++++++++++++++++++=0A=20= lisp/treesit.el=20=20=20=20=20=20=20=20=20=20|=2028=20= +++++++++++++++++++++++++++-=0A=202=20files=20changed,=2046=20= insertions(+),=201=20deletion(-)=0A=0Adiff=20--git=20= a/lisp/progmodes/python.el=20b/lisp/progmodes/python.el=0Aindex=20= 7c5c20608bd..201b3da13f3=20100644=0A---=20a/lisp/progmodes/python.el=0A= +++=20b/lisp/progmodes/python.el=0A@@=20-1228,6=20+1228,21=20@@=20= python--treesit-fontify-variable=0A=20=20=20=20=20=20(treesit-node-start=20= node)=20(treesit-node-end=20node)=0A=20=20=20=20=20=20= 'font-lock-variable-use-face=20override=20start=20end)))=0A=20=0A+(defun=20= python--treesit-triple-quote-notifier=20(ranges=20parser)=0A+=20=20= "Propertize=20triple-quote=20strings=20in=20RANGES=20for=20PARSER."=0A+=20= =20(save-excursion=0A+=20=20=20=20(dolist=20(range=20ranges)=0A+=20=20=20= =20=20=20(goto-char=20(car=20range))=0A+=20=20=20=20=20=20(while=20= (search-forward=20"\"\"\""=20(cdr=20range)=20t)=0A+=20=20=20=20=20=20=20=20= (let=20((node=20(treesit-node-at=20(point)=20parser)))=0A+=20=20=20=20=20= =20=20=20=20=20(when=20(equal=20(treesit-node-type=20node)=20= "string_content")=0A+=20=20=20=20=20=20=20=20=20=20=20=20(let=20((start=20= (treesit-node-start=20node))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20(end=20(treesit-node-end=20node)))=0A+=20=20=20=20=20=20=20=20= =20=20=20=20=20=20(put-text-property=20(1-=20start)=20start=0A+=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20'syntax-table=20(string-to-syntax=20"|=20"))=0A+=20=20=20=20=20= =20=20=20=20=20=20=20=20=20(put-text-property=20end=20(min=20(1+=20end)=20= (point-max))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20'syntax-table=20= (string-to-syntax=20"|=20")))))))))=0A+=0A=20=0C=0A=20;;;=20Indentation=0A= =20=0A@@=20-6729,6=20+6744,10=20@@=20python-ts-mode=0A=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20#'python--treesit-defun-name)=0A=20=20=20=20= =20(treesit-major-mode-setup)=0A=20=0A+=20=20=20=20= (treesit-parser-add-notifier=0A+=20=20=20=20=20(car=20= (treesit-parser-list))=0A+=20=20=20=20=20= #'python--treesit-triple-quote-notifier)=0A+=0A=20=20=20=20=20= (python-skeleton-add-menu-items)=0A=20=0A=20=20=20=20=20(when=20= python-indent-guess-indent-offset=0Adiff=20--git=20a/lisp/treesit.el=20= b/lisp/treesit.el=0Aindex=208a07f5023a9..638faf6c535=20100644=0A---=20= a/lisp/treesit.el=0A+++=20b/lisp/treesit.el=0A@@=20-1088,6=20+1088,28=20= @@=20treesit--font-lock-notifier=0A=20=20=20=20=20=20=20= (with-silent-modifications=0A=20=20=20=20=20=20=20=20=20= (put-text-property=20(car=20range)=20(cdr=20range)=20'fontified=20= nil)))))=0A=20=0A+(defun=20treesit--pre-redisplay=20(&rest=20_)=0A+=20=20= "Force=20redisplay=20and=20consequently=20run=20all=20notifiers.=0A+=0A= +One=20of=20the=20notifiers=20is=20`treesit--font-lock-notifier',=20= which=20will=0A+mark=20the=20region=20whose=20syntax=20has=20changed=20= to=20\"need=20to=20refontify\".=0A+=0A+For=20example,=20when=20the=20= user=20types=20the=20final=20slash=20of=20a=20C=20block=0A+comment=20/*=20= xxx=20*/,=20not=20only=20do=20we=20need=20to=20fontify=20the=20slash,=20= but=0A+also=20the=20whole=20block=20comment,=20which=20previously=20= wasn't=20fontified=0A+as=20comment=20due=20to=20incomplete=20parse=20= tree."=0A+=20=20(treesit-update-ranges)=0A+=20=20(dolist=20(parser=20= (treesit-parser-list=20nil=20nil=20t))=0A+=20=20=20=20= (treesit-parser-root-node=20parser)))=0A+=0A+(defun=20= treesit--pre-syntax-ppss=20(&rest=20_)=0A+=20=20"Force=20redisplay=20and=20= consequently=20run=20all=20notifiers.=0A+=0A+Similar=20to=20font-lock,=20= we=20want=20to=20update=20the=20syntax=20text=20property=0A+before=20= `syntax-ppss'=20starts=20working=20on=20the=20text."=0A+=20=20= (treesit--pre-redisplay)=0A+=20=20nil)=0A+=0A=20;;;=20Indent=0A=20=0A=20= (define-error=20'treesit-indent-error=0A@@=20-2392,7=20+2414,11=20@@=20= treesit-major-mode-setup=0A=20=20=20=20=20= (treesit-font-lock-recompute-features)=0A=20=20=20=20=20(dolist=20= (parser=20(treesit-parser-list))=0A=20=20=20=20=20=20=20= (treesit-parser-add-notifier=0A-=20=20=20=20=20=20=20parser=20= #'treesit--font-lock-notifier)))=0A+=20=20=20=20=20=20=20parser=20= #'treesit--font-lock-notifier))=0A+=20=20=20=20(add-hook=20= 'pre-redisplay-functions=20#'treesit--pre-redisplay=200=20t))=0A+=20=20= ;;=20Syntax=0A+=20=20(add-hook=20= 'syntax-propertize-extend-region-functions=0A+=20=20=20=20=20=20=20=20=20= =20=20=20#'treesit--pre-syntax-ppss=200=20t)=0A=20=20=20;;=20Indent.=0A=20= =20=20(when=20treesit-simple-indent-rules=0A=20=20=20=20=20(setq-local=20= treesit-simple-indent-rules=0A--=20=0A2.41.0=0A=0A= --Apple-Mail=_924D19E7-C6C7-4820-9304-9AB73A97A80D--