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#67061: [PATCH] Improve syntax highlighting for python-ts-mode Date: Mon, 11 Dec 2023 02:00:57 +0200 Message-ID: <0c6e2e14-b494-a8cb-3893-ffb39577baf9@gutov.dev> References: <8734xdni6y.fsf@yandex.ru> <831qcwycbj.fsf@gnu.org> <83v8a3qh6m.fsf@gnu.org> <834jhadvkt.fsf@gnu.org> <7aee7e42-c07d-9131-18a9-4806f07d4267@gutov.dev> <83a5qw7izt.fsf@gnu.org> <172531702081590@mail.yandex.ru> <212931702208489@mail.yandex.ru> 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="29525"; 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: "casouri@gmail.com" , "67061@debbugs.gnu.org" <67061@debbugs.gnu.org> To: Denis Zubarev , Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Dec 11 01:02:05 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 1rCTkK-0007Rx-1m for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 11 Dec 2023 01:02:05 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rCTk5-0007lk-9T; Sun, 10 Dec 2023 19:01:49 -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 1rCTk3-0007ku-Sk for bug-gnu-emacs@gnu.org; Sun, 10 Dec 2023 19:01:47 -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 1rCTk3-00007p-K5 for bug-gnu-emacs@gnu.org; Sun, 10 Dec 2023 19:01:47 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rCTkH-0001xl-V5 for bug-gnu-emacs@gnu.org; Sun, 10 Dec 2023 19:02: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: Mon, 11 Dec 2023 00:02:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67061 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 67061-submit@debbugs.gnu.org id=B67061.17022528887504 (code B ref 67061); Mon, 11 Dec 2023 00:02:01 +0000 Original-Received: (at 67061) by debbugs.gnu.org; 11 Dec 2023 00:01:28 +0000 Original-Received: from localhost ([127.0.0.1]:52106 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rCTjk-0001wx-57 for submit@debbugs.gnu.org; Sun, 10 Dec 2023 19:01:28 -0500 Original-Received: from wout3-smtp.messagingengine.com ([64.147.123.19]:56333) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rCTjg-0001wh-LO for 67061@debbugs.gnu.org; Sun, 10 Dec 2023 19:01:27 -0500 Original-Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 00E2E3200AA3; Sun, 10 Dec 2023 19:01:03 -0500 (EST) Original-Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Sun, 10 Dec 2023 19:01:04 -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:sender:subject:subject:to:to; s=fm3; t= 1702252863; x=1702339263; bh=hOzzCWXU3mnHPkoH9xkw7pOlrTifC/FKDeW nmGbMis4=; b=dwp+GH7KcIrv/AArkLDcQGUXoezv8W+LCrpcDtdF3zWRWo1jM5z Eh4/IkPagCL1YkYl1pxlMpTuB2AW+TwH4w8rIxBC4N9gB+dDOc4uSBzcDdOKR1B8 eRZikdaczbMaDdtEz6v8qP4R09mGPJTIsu603xBfkriD+yEFlQG97/kPxe/Jvn6Z hYOe+aMOh4FdCGiKmJL5Trnc0shWzuv9TnVS2/mVCl3Ec7la7XDaccX7/OdcvRQO /ns5kpd23dobRagT2cCpcKkXOptkk5bH6XIwkT6sAw1MMxgqq/1X+SIHUQvVUDS2 E1Uxfy8flGWvCHKCottXJJeNxOZUUQza95g== 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:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1702252863; x=1702339263; bh=hOzzCWXU3mnHPkoH9xkw7pOlrTifC/FKDeW nmGbMis4=; b=qq8bxhqminxE6qEqZ4WEONqi8eG9yne299W6IeLnCk3/W+Mtzrs NHXr8479KiHuE9P3uq8RFzC9L/sXPaid2xNfV4pBD5bkjVcirNgFuiVfIFyvBsXW 8WtBj9QJUhkxOjNOxKvGkE6Nm6TEnI0I9Oza4IOwerrkqehNA+w/u0LPGLvIO8v+ g1e4BYXFPMxaRkCpWfiVgCLS0YxProM3hHzqVb27VRT6QsJYCMd2NEtE7bz7PHUn WUwTYX+1I8P0wor8sImljkrRWMVmT62yMZ4g19fVIrx4HUsHDowsNdVE5foiD+FV l0cMlkGKJdwNsUq2gcYm8pkm8/Z31ST6gng== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudeluddgudekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvvehfhfgjtgfgsehtkeertddtfeejnecuhfhrohhmpeffmhhi thhrhicuifhuthhovhcuoegumhhithhrhiesghhuthhovhdruggvvheqnecuggftrfgrth htvghrnhephfffheeljeffgeffueeghfekkedtfffgheejvdegjeettdduheeufffggfef jeehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepug hmihhtrhihsehguhhtohhvrdguvghv X-ME-Proxy: Feedback-ID: i0e71465a:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 10 Dec 2023 19:00:59 -0500 (EST) Content-Language: en-US In-Reply-To: <212931702208489@mail.yandex.ru> 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:275948 Archived-At: On 10/12/2023 14:04, Denis Zubarev wrote: > > Arguably, the last 2 lines are "variable references" rather than > definitions > `var := 3`  is assignment expressions. It allows variable assignments to > occur inside of larger expressions. For example `if (match := > pattern.search(data)) is not None:`. > It mostly used to define new variables and act on them if some condition > is met. Ah, thanks! This feature is newer than my working experience with Python. > My rationale for `var *= 3` was that it is shorthand for `var = var * 3` > and currently the `var` on the left hand side is fontified with > `font-lock-variable-name-face`. I think ideally, in cases when "var =" is not the first occurrence for the same var in a given scope, we wouldn't highlight it as "definition" either. Speaking of font-lock-variable-use-face, I think it would be most useful if it helped with noticing typos (meaning, it would only be used for references to variables that have been defined previously, according to the rules of the language). But for that we still need to implement the scope tracking. And before that, well, my personal preference is not to highlight the references at all, but opinions differ. > I wanted shorthand form to be consistent with the full form. > Your point makes sense too, I don't have strong opinion about this. > Also I'm not sure now about `var[ii] = 1`, since it is actually > accessing the list or dictionary element and > `font-lock-variable-use-face` may suit better here. Yep. To sum up, I would add highlighting to your examples `for var in range(3)` and `var := 3` but not others. > Question about new changes. > Should I push them to this patch and provide description of new changes, > or it would be better to wait for review and send them as new patch? I suggest sending an updated patch for review in this case, but you can also wait for Yuan's comments first. Also, please double-check that the tests pass. It might be something in the way I applied your latest patch, but in the example that you gave regarding the "type" feature, def func(v:dict[ list[ tuple[str] ], int | None] | None): , only the last "None" gets highlighted for me with font-lock-type-face. There are corresponding test failures too. Again, could be something on my side, but it would help to verify.