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: Fri, 21 Apr 2023 13:37:08 -0700 Message-ID: <82E7ADEC-25BC-475B-8EE0-839FE78FF2F4@gmail.com> References: <83y1mn7rl7.fsf@gnu.org> 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="8387"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 62951@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Apr 21 22:38: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 1ppxWV-000215-Q4 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 21 Apr 2023 22:38:27 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ppxW9-0005FO-Qe; Fri, 21 Apr 2023 16:38: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 1ppxW7-0005Em-OR for bug-gnu-emacs@gnu.org; Fri, 21 Apr 2023 16:38: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 1ppxW7-0001sA-Gm for bug-gnu-emacs@gnu.org; Fri, 21 Apr 2023 16:38:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ppxW6-0004MU-4k for bug-gnu-emacs@gnu.org; Fri, 21 Apr 2023 16:38:02 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: <83y1mn7rl7.fsf@gnu.org> Resent-From: Yuan Fu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 21 Apr 2023 20:38: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.168210945016727 (code B ref 62951); Fri, 21 Apr 2023 20:38:02 +0000 Original-Received: (at 62951) by debbugs.gnu.org; 21 Apr 2023 20:37:30 +0000 Original-Received: from localhost ([127.0.0.1]:41248 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ppxVa-0004Lj-0E for submit@debbugs.gnu.org; Fri, 21 Apr 2023 16:37:30 -0400 Original-Received: from mail-pl1-f176.google.com ([209.85.214.176]:51534) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ppxVW-0004LQ-8V for 62951@debbugs.gnu.org; Fri, 21 Apr 2023 16:37:29 -0400 Original-Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-1a6c5acf6ccso21265875ad.3 for <62951@debbugs.gnu.org>; Fri, 21 Apr 2023 13:37:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682109440; x=1684701440; h=to:cc:date:message-id:subject:mime-version :content-transfer-encoding:from:from:to:cc:subject:date:message-id :reply-to; bh=D9WryCw91hUtex4VWdMeqkQiOipcgZPzYfYFuw9yZEg=; b=nJxS9f5L4VtM4IAoetPzh4V7cFSdNuBkz7ogOIDmdEd5VMrE3rRcxIYi3+jgI6MvZw qiQcwJIsqhZ+Fad+ZVkmAcQNU78iCwg6AfL/EKmxI63TBLllw5PfQ6tSytpxzFqltQ4N QsEA0MwE1Jezo94I+PkMglX325FUfGbkqnUBv3hvyzsZ34xM5+VddgTqbFP0K7Osw8xx ZiRRrf42GQv2O8POkpXywFTCwsyfYS9hr/sWROxP54t8msDB+HRkaSMaT7VKWesdoJZm gfkXRBaZyEYSy9rTHlTxx3c7bWhgi3mOPtMZZY5GSlNrYgvZ/0ZMss9x9MrIhHPH0V6W f0Fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682109440; x=1684701440; h=to:cc:date:message-id:subject:mime-version :content-transfer-encoding:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=D9WryCw91hUtex4VWdMeqkQiOipcgZPzYfYFuw9yZEg=; b=WtUUDno9toZGAYi3x6ETqUkRWQrzC+SAey6E+5cZiMrn7/I2M6LKKXx/FDJ88dl6CV 1vQi5HD1121cVMAffzWnIOaEF4fRpbhbdO0C1YQvQOMNCYyQIll5V/4MFGJBFFcbOLQL 3jmXvbhvuW8n6PrqxcqU7u/BdLAqubtCXJtUz99Fm75/BWNfiQ6EVm9yk5gY5XfTUa+8 n91KsSdQ9nDJx+V3JwMl29o0RkVIcZlx19INXKp3QJBwVwjE6FCIp6AXXI4w+EJRCy+w el8JlxFgGVVf5E51ORE7J+Z6SwHbTCNaIdU50uVLQVHT/a+Ag3qm4dAnpkkJJUSQGFpT IW0g== X-Gm-Message-State: AAQBX9e1FklUT4wo/v+thdxo/d3/DtJmrJs0V8gv2IUW3HlAjbFoQW7r WZ2UJvr2a0zklL1Shk0x9iM= X-Google-Smtp-Source: AKy350arbq03WRiP6SrCmF6ags0wyeQOo/6lD+QNkuYJjWqolC5CQzT+5uwf2n1uT96fL52c+LzNpw== X-Received: by 2002:a17:902:e892:b0:1a2:8c7e:f310 with SMTP id w18-20020a170902e89200b001a28c7ef310mr8376998plg.35.1682109440111; Fri, 21 Apr 2023 13:37:20 -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 b5-20020a170902a9c500b001a6f6638595sm3077647plr.92.2023.04.21.13.37.19 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Apr 2023 13:37:19 -0700 (PDT) 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:260414 Archived-At: Eli Zaretskii writes: > To reproduce: > > emacs -Q > C-x C-f src/fns.c RET > C-u 3365 M-g g > > Observe that "if" and "STRINGP" in the body of FOR_EACH_TAIL_SAFE are > fontified in font-lock-function-name-face. This is because the > FOR_EACH_TAIL_SAFE macro is misparsed by tree-sitter as a declaration. > > Can we teach c-ts-mode to recognize FOR_EACH_TAIL_SAFE and > FOR_EACH_TAIL for what they are, perhaps conditioned on > c-ts-mode-emacs-sources-support being non-nil? I=E2=80=99m aware of this issue, but the truth is there isn=E2=80=99t a = good solution to it. We need to recognize FOR_EACH_TAIL_SAFE (not hard) and fix arbitrary code after it (hard). In this case it=E2=80=99s a if statement, with = macro calls and AND operation in it=E2=80=99s condition, it=E2=80=99s already three = things we need to recognize and somehow handle. It can also be a for loop, a switch case, a function call, a while loop. If we want to fix FOR_EACH_TAIL we would need to handle every possible thing, at that point we might as well have wrote a parser :-) We can probably fix this very particular case, but it=E2=80=99s still = work and overhead, and doesn=E2=80=99t mean much. Yuan