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#67061: [PATCH] Improve syntax highlighting for python-ts-mode Date: Sun, 10 Dec 2023 23:10:44 -0800 Message-ID: <7b17c99d-6e4b-43b3-af93-993901a3a4ea@gmail.com> 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> <0c6e2e14-b494-a8cb-3893-ffb39577baf9@gutov.dev> 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="38352"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla Thunderbird Cc: "67061@debbugs.gnu.org" <67061@debbugs.gnu.org> To: Dmitry Gutov , Denis Zubarev , Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Dec 11 08:12:09 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 1rCaSW-0009rT-E2 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 11 Dec 2023 08:12:08 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rCaSG-0006zH-F1; Mon, 11 Dec 2023 02:11:52 -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 1rCaSD-0006yo-4A for bug-gnu-emacs@gnu.org; Mon, 11 Dec 2023 02:11:49 -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 1rCaSC-0004hu-1o for bug-gnu-emacs@gnu.org; Mon, 11 Dec 2023 02:11:48 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rCaSQ-0005zy-B1 for bug-gnu-emacs@gnu.org; Mon, 11 Dec 2023 02:12:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Yuan Fu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 11 Dec 2023 07:12:02 +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.170227867222974 (code B ref 67061); Mon, 11 Dec 2023 07:12:02 +0000 Original-Received: (at 67061) by debbugs.gnu.org; 11 Dec 2023 07:11:12 +0000 Original-Received: from localhost ([127.0.0.1]:52319 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rCaRc-0005yT-71 for submit@debbugs.gnu.org; Mon, 11 Dec 2023 02:11:12 -0500 Original-Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]:48457) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rCaRW-0005xt-TL for 67061@debbugs.gnu.org; Mon, 11 Dec 2023 02:11:10 -0500 Original-Received: by mail-pg1-x52d.google.com with SMTP id 41be03b00d2f7-5c690c3d113so3465845a12.1 for <67061@debbugs.gnu.org>; Sun, 10 Dec 2023 23:10:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702278646; x=1702883446; darn=debbugs.gnu.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=rQT8Api6FqNHq/6i/MEvbVEKz0hXMnC52LJiA7AREM4=; b=Po9tvKdJdgikFOXLHOXJ3mhl5nnKPFeUmtggaX4xhXLBLrZdy8iENxIBk3F7KGypdN hySzc+LOjReeRt+aewDSi8UgZwXOT2j9llq/uJE76+UIYZ/II40SDy2834DtnKab70Ff 9C4e1bWJAU9CILZaYhSzrCfaS54f1i3Ng0t6fU28SijiM+lFER3xdjbY8Guw2JuSBlPP qBXhuAlIQ15cUDHdthBQ8NWz/KyvY1UESaF+zDXNxkkKmumjdqXqU5DsqocKl5zMSpVb MFqt0KFW3u59Lad+f1IukBJwxF5HO/vZP4pAF1Unep1nI+zHUD91Vyej9+aQWsvHJazS 8pOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702278646; x=1702883446; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=rQT8Api6FqNHq/6i/MEvbVEKz0hXMnC52LJiA7AREM4=; b=N4ESpYigYHZ/JzQDxkKds6trTBVkY3s5A0xAzBGjbK1+2wpxDvetoZ8+GwZP5o4p2x sJCd/jdPfR9+xvS6oHIl0tSwyJwBIv6Dit6I8279fre5+XVTg+bo2WLU3lpy6lN8YPYr QxQSDBbQ5wvTYMv9wDySuxl9ndvJUKKgCkeGbMCBTYHo/Wnl1AJ2Sx9KPTRTaBP5E+KF 5axNN1tn4hLeRBBiIepYrE+qEq80Hrk6DWjppbOL9wNFIP0mxmKPFCFeniBIs86mwJ2N SN6WVMz7ZqyYsed5ZAhpiJY41fh3M5YxL/6WoBxNegw+6ok/K7QvF8mPeRMKPOosLywb bjfw== X-Gm-Message-State: AOJu0Yw/y/aVh13bByn+g5n0aMCmQNBatRiECV6MxSyzsN5aNGd4X4rw vjCcmtMK9XxDWEL0DOqER92p+gOI+Wnsn+qb X-Google-Smtp-Source: AGHT+IHRZy8SzTYQQLMeBn/QVcFw2JYeH2/DMMV4BdhYEentX+DiRK5DNQiyWbDsOTLdVWxTuOEQKw== X-Received: by 2002:a05:6a21:18d:b0:189:bde9:9cb0 with SMTP id le13-20020a056a21018d00b00189bde99cb0mr6069611pzb.27.1702278646195; Sun, 10 Dec 2023 23:10:46 -0800 (PST) Original-Received: from [192.168.1.7] (172-117-161-177.res.spectrum.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id si7-20020a17090b528700b00286e9f15f21sm6204942pjb.12.2023.12.10.23.10.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 10 Dec 2023 23:10:45 -0800 (PST) Content-Language: en-US In-Reply-To: <0c6e2e14-b494-a8cb-3893-ffb39577baf9@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:275967 Archived-At: On 12/10/23 4:00 PM, Dmitry Gutov wrote: > 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. Personally I regard the "assignment" feature to mean "any assignment", rather than definition. But that's just me. For my personal taste, I would make *= always highlight its LHS. >> 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. IMHO, for the assignment feature, we should stick to the narrow definition of assignments, ie, anything that looks like "a = b". Things like "for var in range(3)" could be highlighted by variable feature, I think. And for var[i] = 1, I don't know either. I think I decided to not fontify it back then, but it wasn't based on any strong reasoning. >> 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. > If you can consolidate everything into a single patch, and pair it with a summary, that'll be a great aid to me. Also, in case you don't know yet, we follow certain format for commit messages, you can check it out in the CONTRIBUTE file, "Commit messages" section. Yuan