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#63840: 29.0.91; c-ts-mode fails to fontify common C extension Date: Tue, 27 Jun 2023 18:46:24 -0700 Message-ID: References: <87fs7anjwq.fsf.ref@yahoo.com> <87fs7anjwq.fsf@yahoo.com> <835y86auxi.fsf@gnu.org> <692BAB16-A7DD-4080-871A-FB541329CCFC@gmail.com> <873532jq2a.fsf@yahoo.com> <83zg51tgjd.fsf@gnu.org> <868C5538-F021-4EF8-9730-0828FC9BD801@gmail.com> <834jn7uddh.fsf@gnu.org> <6871B1D5-9B52-47C0-BB6F-5C41655CD33B@gmail.com> <835y7j8lpk.fsf@gnu.org> <4CB53EB5-CFBE-40F4-A303-353B3D891FA5@gmail.com> <83ilb9w4g7.fsf@gnu.org> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.600.7\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10476"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Po Lu , 63840@debbugs.gnu.org, Theodor Thornhill To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jun 28 03:47:28 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 1qEKHI-0002Tp-Kt for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 28 Jun 2023 03:47:28 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qEKGx-0001VN-3o; Tue, 27 Jun 2023 21:47:07 -0400 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 1qEKGs-0001U2-Oo for bug-gnu-emacs@gnu.org; Tue, 27 Jun 2023 21:47:05 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qEKGs-0000DM-Fu for bug-gnu-emacs@gnu.org; Tue, 27 Jun 2023 21:47:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qEKGr-0002P0-U5 for bug-gnu-emacs@gnu.org; Tue, 27 Jun 2023 21:47:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Yuan Fu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 28 Jun 2023 01:47:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63840 X-GNU-PR-Package: emacs Original-Received: via spool by 63840-submit@debbugs.gnu.org id=B63840.16879168059208 (code B ref 63840); Wed, 28 Jun 2023 01:47:01 +0000 Original-Received: (at 63840) by debbugs.gnu.org; 28 Jun 2023 01:46:45 +0000 Original-Received: from localhost ([127.0.0.1]:49756 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qEKGa-0002OS-S9 for submit@debbugs.gnu.org; Tue, 27 Jun 2023 21:46:45 -0400 Original-Received: from mail-pf1-f169.google.com ([209.85.210.169]:47412) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qEKGY-0002OE-UM for 63840@debbugs.gnu.org; Tue, 27 Jun 2023 21:46:44 -0400 Original-Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-6682909acadso2834458b3a.3 for <63840@debbugs.gnu.org>; Tue, 27 Jun 2023 18:46:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687916797; x=1690508797; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Q+TyyDg5S41eROleEuWu3h9ytLwVRLzgAFrBjK79nqs=; b=dSzVuaO8iQcD1QFc2T5u80uQjRV629tf+/ocEexrXAKFGRExdtj5NCthjGPq6WWyX1 jJLOsF+0SB6CWSkh9NMJ+6Q4hQgIzMhYRQplE5vlL056HW7c4T5CH9LNglNPQQDyMeWq eOqw2jbnmYfCzs7cx/050bLTJRJPcXVVfr8LKcfcQS7Rrv0eYITVhFpLw0TgoQrnk1nB X05yYiFgwce0q1j4ukSIBSQ7iaWwq3F+XKecnHV0JEpbJncXHb7jerQ+aYSBI9rogAqM N1p/LtGYLVDawIZzCb2pVzUyipYP98bvvUqQ8RsdtJYKlHVirC/OcYAmipfuATtdueee aL3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687916797; x=1690508797; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Q+TyyDg5S41eROleEuWu3h9ytLwVRLzgAFrBjK79nqs=; b=krWfdpFxewdAH4VApXFCz7V/t2tgnpcRzpAwJpXUkeE+wG7IhtGb5vF41BhvY0n1aW w5DvqEHVzFOf4qOOAIOorr6m9pGmRW+qn5KIu7OYgrye8r5ArR9Az8lcjJk8WEIdC5Yh JwJnCnYh6I3xRpDbnt4nlP7oVKaZIbm86FjduXyAriNrQrQhGZ8nHOpAKHjVDMotad8u WIa0A/DZdIS4mDanE+qcRa500/H/WN32x2FYn3kT6xbG3sr9zepytCk2aBIXE15a6tqf vrZScgsdInu3QLs3GR4yUdg5f8Qn19F42Nbeqhf1/g+VcItrbSb4U2EBCGMWxCJ+CAHT s1nA== X-Gm-Message-State: AC+VfDzwqa/AbKFAKLotkyWD6e+C5DBnPyycMVK9jwgaxzbxgv7CidTb 6yir4GPuMYvp4OxYjDmtflU= X-Google-Smtp-Source: ACHHUZ6vthpEOTMS5PZ9s5gq+RgiZebqgqdrVoMuCq9TS4imWKfLjtuyUPggt5nuUKli88qpW1faow== X-Received: by 2002:a05:6a20:a103:b0:127:8784:8e5b with SMTP id q3-20020a056a20a10300b0012787848e5bmr5678659pzk.31.1687916796681; Tue, 27 Jun 2023 18:46:36 -0700 (PDT) Original-Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id m18-20020a170902db1200b001ac8e0ea157sm6553581plx.144.2023.06.27.18.46.35 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Jun 2023 18:46:36 -0700 (PDT) In-Reply-To: <83ilb9w4g7.fsf@gnu.org> X-Mailer: Apple Mail (2.3731.600.7) 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:264189 Archived-At: > On Jun 27, 2023, at 4:05 AM, Eli Zaretskii wrote: >=20 >> From: Yuan Fu >> Date: Mon, 26 Jun 2023 22:54:16 -0700 >> Cc: Theodor Thornhill , >> Po Lu , >> 63840@debbugs.gnu.org >>=20 >>=20 >>=20 >>> On Jun 19, 2023, at 9:23 AM, Eli Zaretskii wrote: >>>=20 >>>> From: Yuan Fu >>>> Date: Sun, 18 Jun 2023 23:43:51 -0700 >>>> Cc: Theodor Thornhill , >>>> Po Lu , >>>> 63840@debbugs.gnu.org >>>>=20 >>>>> On Jun 15, 2023, at 11:31 PM, Eli Zaretskii wrote: >>>>>=20 >>>>>> From: Yuan Fu >>>>>> Date: Thu, 15 Jun 2023 22:05:33 -0700 >>>>>> Cc: Theodor Thornhill , >>>>>> Po Lu , >>>>>> 63840@debbugs.gnu.org >>>>>>=20 >>>>>>> Ping! Any progress with this? >>>>>>=20 >>>>>> The best option is to ask tree-sitter-c to recognize $. I see a = PR for it but the author closed it shortly after posting, not sure what = was going on[1]. >>>>>=20 >>>>> Any hope of re-opening it, or at least asking why it was closed >>>>> without fixing? >>>>=20 >>>> I asked on GitHub. >>>>=20 >>>>>=20 >>>>>> Fixing it ourselves involves checking every identifier during = fontification. Is that something we want to do? >>>>>=20 >>>>> How would that work? Can you describe how could this be = implemented? >>>>> It is hard to decide whether it's something we want to do without >>>>> knowing the implications. >>>>=20 >>>> I was going to write a demo implementation, but that actually would = change quite some lines. So let me just describe it for now. In = c-ts-mode--font-lock-settings, I would replace all the different types = of faces used for all the identifiers to a function. (If you search for = identifier in c-ts-mode--font-lock-settings, there are quite a few of = them.) This function would obviously receive the beg and end of the = identifier tree-sitter detects, and it would check if there are $ right = before or after the given range, if there is, it would extend the range = fontified. >>>>=20 >>>> For example, for a code like abc$de, tree-sitter might consider abc = as an identifier, and $ de to be error. The function I mentioned would = look at abc=E2=80=99s beg and end, and see that c is immediately = followed by a $, so it would extend the fontification range to include = abc$de. >>>=20 >>> Thanks. This sounds like a lot of hair, so let's first see how the >>> developers of the tree-sitter-c grammar respond. >>=20 >> Cool. (Not surprisingly) I didn=E2=80=99t get any reply on GitHub as = for now. It would be nice if tree-sitter-c (and other grammars) can have = a separate maintainer other than tree-sitter=E2=80=99s author. He seems = to be heavily overloaded right now (tree-sitter, a dozen grammars, Zed = editor). >=20 > Would it be possible for you or someone else of the interested Emacs > users to submit a patch for the grammar library to support $, either > as an option or as an extension? IOW, is it hard to modify the > TS grammar definitions for such relatively simple and straightforward > extensions? There is a PR for it on GitHub (under which I left a comment). Judging = from the PR, it=E2=80=99s simple to add support for $. Yuan=