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#74277: 29.4; rust-ts-mode doesn't highlight some function calls Date: Sat, 23 Nov 2024 21:18:58 -0800 Message-ID: References: <86bjyookld.fsf@gnu.org> <87r077kl0n.fsf@gmail.com> <87ed3522aj.fsf@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3776.700.51\)) 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="36644"; mail-complaints-to="usenet@ciao.gmane.io" Cc: acidbong@tilde.club, Trevor Arjeski , 74277@debbugs.gnu.org, Eli Zaretskii To: Randy Taylor Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Nov 24 06:21:22 2024 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 1tF53h-0009OQ-Cu for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 24 Nov 2024 06:21:21 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tF53S-0003Tu-Vs; Sun, 24 Nov 2024 00:21:07 -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 1tF53Q-0003Th-A0 for bug-gnu-emacs@gnu.org; Sun, 24 Nov 2024 00:21:04 -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 1tF53P-00031I-55 for bug-gnu-emacs@gnu.org; Sun, 24 Nov 2024 00:21:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=References:Date:In-Reply-To:From:Mime-Version:To:Subject; bh=edu6LV6Y5NsfPfH6reGGyvQtLmmUyLhqOAw+kdbMtCY=; b=ng/r+PHUwpivw4TfXDHiwlannAYrePzlecPfaZXpZo3iZxOJKUHNparBYkLN1z0e7n7yXtcRIQIb/AbHjjxsUUT0qcshU733i0baW0aMW7foGm17YK0OfoHvLkE7x6mUqEwlWdDAI06q5es2ZFhzl06Zy71dUh6VSooIXatbC3oM8R2yHJ45nfRUNMHZsqS4If0xg/vB+7zbGVGQF2oQZB3m1uDUQcm2k0rHUEsm6QZLUVKcNNCyiIIvG9EJCjqxWwc266l9RnOfFiqmAFxFM6O8x9r4/uoRGeleTWCyKM1pi9ukZGOfm6cI/sSAeKg77jGbXskw67f/HNkCYJxSlA==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tF53O-0004zo-MA for bug-gnu-emacs@gnu.org; Sun, 24 Nov 2024 00:21: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: Sun, 24 Nov 2024 05:21:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74277 X-GNU-PR-Package: emacs Original-Received: via spool by 74277-submit@debbugs.gnu.org id=B74277.173242561419109 (code B ref 74277); Sun, 24 Nov 2024 05:21:02 +0000 Original-Received: (at 74277) by debbugs.gnu.org; 24 Nov 2024 05:20:14 +0000 Original-Received: from localhost ([127.0.0.1]:60338 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tF52b-0004y8-QF for submit@debbugs.gnu.org; Sun, 24 Nov 2024 00:20:14 -0500 Original-Received: from mail-pl1-f170.google.com ([209.85.214.170]:43045) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tF52Z-0004xv-KL for 74277@debbugs.gnu.org; Sun, 24 Nov 2024 00:20:12 -0500 Original-Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-21260209c68so33269995ad.0 for <74277@debbugs.gnu.org>; Sat, 23 Nov 2024 21:20:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732425550; x=1733030350; darn=debbugs.gnu.org; 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=edu6LV6Y5NsfPfH6reGGyvQtLmmUyLhqOAw+kdbMtCY=; b=cPR8b4STacT2K3lGDROYm+zQ1RESLUeSVLYx1xToeZ8pW8wXwXcClRtUpi4bdufIWI dcwjYTscPcpN4lZV2JP95m/mhLPKuJE+2Hvhet4TVftwmyajvLNek7doRxAswVbpiIhM EpxM8V2dFL8UV1JnFK8P3NfpprEM3QL64fd43QkXGp6Vfd8LCiVoRXnwyo0WSSjkirmI kaxN5VPuvTyyjdHycBHTQguHaxGYSi+kxpvuJ7dtueNiHJlkk3WtLYHfYpAISZE9L4o4 JRlVFtcRQqinIBp98k5AzdiDfWzpNOVkGIG9FEbh9uFJGCAFa2htkjOh+m54ZzUchid5 EAYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732425550; x=1733030350; 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=edu6LV6Y5NsfPfH6reGGyvQtLmmUyLhqOAw+kdbMtCY=; b=JzBe8sh6SFdJbaEZqt4vpAeg2v6N7O2+wXqr4RNChZNLrSEYL9pJ75JNjanJUcZysj 9FQsqFehqw0+wYoojuAGBulQrqTFVkJ1xQdrDIS45cgeLXEqT5nhhdCH+XycxoYNdKwm bwmzfKPVxD3c9XdZA9OUbYVrEExd2TmRridc1ywgezi0hU9xG/hTw/lCvdxXmgCUBpp2 jjf/3cyik9r8iW5DadZ5h8tzXoEm+GtPtlLxBrHa9DE2QQNDkW0H2rmuFNmFhb1k21yY 70yeL7BC3NpI2LabC3JX152F/fPOgRhrt7e8qrlxS2B2z2Qsp1mMGQiVLHH8tWqCOXxo gYMQ== X-Forwarded-Encrypted: i=1; AJvYcCW9irRU4drc/avZwnmy8ODgh/KKtCv0ywRQEuHWrT2GzIN+NE7qxgEgeCf50KhFO97XRiOKoA==@debbugs.gnu.org X-Gm-Message-State: AOJu0YyosGm3Tw9733ujtmd5vQ8R4qidQiY7eb5l/hxROZW56/sY8EbM 7PmfQ+x8KnCbhQM8xOwoTVXEEgKDGhDuuT8mnoLYHFzPZJRF7w3H X-Gm-Gg: ASbGncv8ZnQRgGm4udpLlIqrQ5ApGqUbmw7+0IKxa9zGMHgnv5rL6LxZqlS09HJREFJ Ly1K7vHnYqtvjtiGQEGNWEuTudFEsyWkhkeeveCvc2vU7STIUXpORPpUjrTm6myac7csjvGfgOJ s8Fou5e3PYCPeeDPL9N9tVYHXl56/xmZfuRjX2kdtbMN/8Ei4j6H3LSAbS++Lgahq2/9Zaq3Qz8 zE+Y12HRqQyTllT/vNduujS8xs2RwddWUe1LWwgLDBfJ3wEhH+xneirKBYKa25+fJeXiq2D2g== X-Google-Smtp-Source: AGHT+IHCCpVo2JWXWVcSw7oDZe958JFsyUXMWHDEW2xrLkdiox0i5Qhqor1/y7DGOLfhhOeeKHMoFA== X-Received: by 2002:a17:902:e849:b0:20b:a9b2:b558 with SMTP id d9443c01a7336-21283d20371mr189644585ad.28.1732425550414; Sat, 23 Nov 2024 21:19:10 -0800 (PST) Original-Received: from smtpclient.apple ([2601:646:8f81:6120:9db4:d34c:247c:f36b]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2129dbff380sm40998755ad.114.2024.11.23.21.19.09 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 23 Nov 2024 21:19:09 -0800 (PST) In-Reply-To: X-Mailer: Apple Mail (2.3776.700.51) 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:295884 Archived-At: > On Nov 21, 2024, at 7:30=E2=80=AFPM, Randy Taylor wrote: >=20 > On Wednesday, November 20th, 2024 at 13:22, Trevor Arjeski = wrote: >>=20 >> Trevor Arjeski tmarjeski@gmail.com writes: >>=20 >>=20 >> I decided to hack around with this a little bit and found that adding >> the following lines partially works: >>=20 >>=20 >> I'm sure there is an issue with solving it this way, I just need = someone >> else more experienced to confirm. It is finicky where it turns the >> highlighting on and off when you make some code changes, for example >> adding and removing the semi-colon after the macro invocation. >=20 > Yuan would be the best to answer that. Using injection (what Emacs calls local parser, same thing) here is = fine, I think. As Randy said, tree-sitter doesn=E2=80=99t have a good = answer for macros. If nvim uses this workaround (create an injection for = the macro and parses it like normal rust code), then it should be fine = for us to follow suit. >=20 > Personally, I envisioned a custom highlight helper function like > rust-ts-mode--fontify-pattern or rust-ts-mode--fontify-scope which > seems like the simplest solution that should cover this use case, but > I'm not actually aware of all the sorts of craziness one could get up > to in a macro invocation so that might not be enough and maybe = injections > are the way to go. Rust macros are not as crazy as C/C++, but definitely goes beyond normal = rust code, for example, the select! macro: #[tokio::main] async fn main() { tokio::select! { _ =3D do_stuff_async() =3D> { println!("do_stuff_async() completed first") } _ =3D more_async_work() =3D> { println!("more_async_work() completed first") } }; } Does what you envisioned work for something like this? To be fair, I = don=E2=80=99t think the injection solution works well for this either. Yuan