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#62951: 29.0.90; c-ts-mode: Incorrect fontification due to FOR_EACH_TAIL_SAFE Date: Wed, 26 Apr 2023 15:19:01 -0700 Message-ID: <90E66143-A3E2-4B76-AC0A-01DC5E841AFE@gmail.com> References: <82E7ADEC-25BC-475B-8EE0-839FE78FF2F4@gmail.com> <83fs8s2xnk.fsf@gnu.org> <2BDA88D0-A870-4FE3-BAF8-350FBAA943BF@gmail.com> <384f8110-eba6-8fb3-ef4e-56fa0721d85d@gutov.dev> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.500.231\)) 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="24074"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , 62951@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Apr 27 00:20:26 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 1prnUv-000618-1q for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 27 Apr 2023 00:20:25 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1prnUb-0007Nz-4h; Wed, 26 Apr 2023 18:20:05 -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 1prnUZ-0007No-8l for bug-gnu-emacs@gnu.org; Wed, 26 Apr 2023 18:20: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 1prnUZ-0005DE-0f for bug-gnu-emacs@gnu.org; Wed, 26 Apr 2023 18:20:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1prnUY-0002yr-EG for bug-gnu-emacs@gnu.org; Wed, 26 Apr 2023 18:20:02 -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, 26 Apr 2023 22:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62951 X-GNU-PR-Package: emacs Original-Received: via spool by 62951-submit@debbugs.gnu.org id=B62951.168254756511406 (code B ref 62951); Wed, 26 Apr 2023 22:20:02 +0000 Original-Received: (at 62951) by debbugs.gnu.org; 26 Apr 2023 22:19:25 +0000 Original-Received: from localhost ([127.0.0.1]:57131 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1prnTw-0002xu-Pw for submit@debbugs.gnu.org; Wed, 26 Apr 2023 18:19:25 -0400 Original-Received: from mail-pf1-f178.google.com ([209.85.210.178]:62720) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1prnTs-0002xe-Nl for 62951@debbugs.gnu.org; Wed, 26 Apr 2023 18:19:22 -0400 Original-Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-64115eef620so604190b3a.1 for <62951@debbugs.gnu.org>; Wed, 26 Apr 2023 15:19:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682547554; x=1685139554; 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=UUhnrostUiptwuANAsGoG3iyjnCNJmkcDnWfcld/7f0=; b=J+ZhFR27B16lRXhF9vxcv+2Xb/aB1ZP14wYBnvzFZkfXfaxGlDaSOT1NH+HytkBmLu 5zqp7YtiFq56Moopnmk99Y+adXusVWTVtfOnd5HqDJIZdG3lVDy9iI1STua9m/DphszX /I9UonB0+Mj5wvHtAnmihgGDuOOLRa5A44IqcFxnXtSdInwP8DbFpjwgXN8REBxBiDcu foqhRu74BZneTA5UKx4Oq1UQcZga7C8nLGYP3id97P3rxEfomRaJrGgxwKv2AV9WOWHN rD8mw1FvHbQSm20lxIgZ4Scf+9KDCdSDQlKuIv3pqicmsEvd28CpxrK+yJSAxTcq/B6D Vckw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682547554; x=1685139554; 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=UUhnrostUiptwuANAsGoG3iyjnCNJmkcDnWfcld/7f0=; b=LTru3HiMbMxEUcy+S0DpN/62ZUs0A/t/fRAdUa0AFgIi7Wzg7wskvp+lsSNI2ScHb8 yLRgLj0dQCF+ngfE0dt/kIjrVRwrz0+kKhVbMIBmD/3ihvrFt2EOqjNKZi1g+C8rmChE SDx4LY5IgzunnVl6Xa7Ysh82vKQr+tbcAfKgndWt71e28RPlRi/Lx63dpBCtVnCQD3lA YhQVLxzeuQ5yaKbvciN4EMWdXbLsg9nYWyr1tZnpoSPjlWR5EcTzASVKhtP4Utj/8G+2 ytQUGIOzfBiVpNeEmRsTC7NL+cQoQyO5hif/1v0J7qpEYWTc5J31+NQVTAJxWrq3eDMG scmA== X-Gm-Message-State: AC+VfDyHwC+F0e62jJkIxLuNsgzje59lcixQwURto7XlNqXTym2BFEWg feKiA8e5GBQW1wqO3BTg8dc= X-Google-Smtp-Source: ACHHUZ5L9Xs4opJdEDRNRtihbklrNzaLrw7FZomkRoLwjEE9a1oFTorHAy4moxTz3QHrYwZMpf4IJg== X-Received: by 2002:a17:903:1c8:b0:1a1:cb18:7f99 with SMTP id e8-20020a17090301c800b001a1cb187f99mr4977240plh.30.1682547554279; Wed, 26 Apr 2023 15:19:14 -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 k9-20020a170902694900b0019c32968271sm10339719plt.11.2023.04.26.15.19.13 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Apr 2023 15:19:13 -0700 (PDT) In-Reply-To: <384f8110-eba6-8fb3-ef4e-56fa0721d85d@gutov.dev> X-Mailer: Apple Mail (2.3731.500.231) 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:260689 Archived-At: > On Apr 23, 2023, at 2:04 PM, Dmitry Gutov wrote: >=20 > On 23/04/2023 03:28, Yuan Fu wrote: >> What do you think of extending the parser to support these macros = instead? (So we fork tree-sitter-c.) If we can fix the parser, we = don=E2=80=99t need to retrofit hacks onto font-lock, indent, etc, = separately, and it truly fixes the problem. The downside is compiling = from grammar source to grammar.c needs rust and node tools. But I guess = depending on the grammar maintained by tree-sitter=E2=80=99s author = isn=E2=80=99t too much different from depending on the grammar = maintained by another individual (ie, me)? >=20 > We had also talked at some point about replacing the actual text that = the parser sees with something else. >=20 > If this can be done in a straightforward way (with tracking the = subsequent correspondence of "real" text back to the buffer for syntax = highlighting), that might be the perfect solution: we'd have a defcustom = which would hold a list of macros used in the current codebase in the = form of templates, and we'd set a bunch of them in emacs/.dir-locals.el. >=20 > I'm not sure how difficult this is to implement and maintain, but it's = probably going to be less work to maintain than a fork of the grammar. Sounds to me a bit difficult to write. Eg, translating between = tree-sitter position and buffer position efficiently isn=E2=80=99t too = easy. Now plus narrowing, and what if the narrowing boundary is in the = middle of a replace region? My idea right now is to use the range feature in tree-sitter. Since the = =E2=80=9Cbody=E2=80=9D of FOR_EACH_TAIL is valid C, I can either set the = ranges for the parser so it ignores FOR_EACH_TAIL, or I can add another = parser that only parses the body of FOR_EACH_TAIL. Yuan=