From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#63840: 29.0.91; c-ts-mode fails to fontify common C extension Date: Mon, 19 Jun 2023 19:23:51 +0300 Message-ID: <835y7j8lpk.fsf@gnu.org> 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> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33770"; mail-complaints-to="usenet@ciao.gmane.io" Cc: luangruo@yahoo.com, 63840@debbugs.gnu.org, theo@thornhill.no To: Yuan Fu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jun 19 18:24:18 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 1qBHft-0008dh-PJ for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 19 Jun 2023 18:24:17 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qBHfk-0007iS-2H; Mon, 19 Jun 2023 12:24:08 -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 1qBHff-0007i9-2G for bug-gnu-emacs@gnu.org; Mon, 19 Jun 2023 12:24:03 -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 1qBHfe-0004a8-Ph for bug-gnu-emacs@gnu.org; Mon, 19 Jun 2023 12:24:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qBHfe-0004RL-Kq for bug-gnu-emacs@gnu.org; Mon, 19 Jun 2023 12:24:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 19 Jun 2023 16:24:02 +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.168719183517045 (code B ref 63840); Mon, 19 Jun 2023 16:24:02 +0000 Original-Received: (at 63840) by debbugs.gnu.org; 19 Jun 2023 16:23:55 +0000 Original-Received: from localhost ([127.0.0.1]:57115 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qBHfX-0004Qp-9m for submit@debbugs.gnu.org; Mon, 19 Jun 2023 12:23:55 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:49980) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qBHfU-0004Qc-Ra for 63840@debbugs.gnu.org; Mon, 19 Jun 2023 12:23:53 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qBHfP-0004U6-Bq; Mon, 19 Jun 2023 12:23:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=cWMr10W/RsjvVG7zq8Az/LjlxpoJ+0Zfhy2OHESERDc=; b=PiitrajIbyy+8IZp+P9F N/5epJcKAi26qrgThRc60VEfTTJenD4zZW3YYFfso3puktktc856pVpSdQVWEk71m5LWlTDBwCWiW 7bNtbro3iXA3bo3wFyGSy2eHEDZI+N2sYgYo1PRofr6DErBah/7nCLwdNZcWGLhq1JTviaR2vfopc +nJrx2JfGtjsH1dp1Nma1KBth4Wq/zoOMTapY8K3OfhIPchVOUpk0S901WBGUnXnqLRcxjJGD9YM8 s/8TshVBQ7xHgIfBb8X2TM0ohRD/eJypinpQvOiaNkA5B9oIkZTq//1NTpsYUtSnB123ri/vFhRny /asDwmhQaqPRhQ==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qBHfO-0002eu-Mp; Mon, 19 Jun 2023 12:23:47 -0400 In-Reply-To: <6871B1D5-9B52-47C0-BB6F-5C41655CD33B@gmail.com> (message from Yuan Fu on Sun, 18 Jun 2023 23:43:51 -0700) 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:263693 Archived-At: > From: Yuan Fu > Date: Sun, 18 Jun 2023 23:43:51 -0700 > Cc: Theodor Thornhill , > Po Lu , > 63840@debbugs.gnu.org > > > On Jun 15, 2023, at 11:31 PM, Eli Zaretskii wrote: > > > >> From: Yuan Fu > >> Date: Thu, 15 Jun 2023 22:05:33 -0700 > >> Cc: Theodor Thornhill , > >> Po Lu , > >> 63840@debbugs.gnu.org > >> > >>> Ping! Any progress with this? > >> > >> 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]. > > > > Any hope of re-opening it, or at least asking why it was closed > > without fixing? > > I asked on GitHub. > > > > >> Fixing it ourselves involves checking every identifier during fontification. Is that something we want to do? > > > > 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. > > 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. > > 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’s beg and end, and see that c is immediately followed by a $, so it would extend the fontification range to include abc$de. Thanks. This sounds like a lot of hair, so let's first see how the developers of the tree-sitter-c grammar respond.