GNU bug report logs - #79687
31.0.50; Latest tree-sitter library mandates predicates to end with ? or !

Previous Next

Package: emacs;

Reported by: Yuan Fu <casouri <at> gmail.com>

Date: Fri, 24 Oct 2025 02:18:02 UTC

Severity: normal

Found in version 31.0.50

Done: Yuan Fu <casouri <at> gmail.com>

To reply to this bug, email your comments to 79687 AT debbugs.gnu.org.
There is no need to reopen the bug first.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to mailto:eliz <at> gnu.org, bug-gnu-emacs <at> gnu.org:
bug#79687; Package emacs. (Fri, 24 Oct 2025 02:18:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Yuan Fu <casouri <at> gmail.com>:
New bug report received and forwarded. Copy sent to mailto:eliz <at> gnu.org, bug-gnu-emacs <at> gnu.org. (Fri, 24 Oct 2025 02:18:04 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Yuan Fu <casouri <at> gmail.com>
To: Bug Report Emacs <bug-gnu-emacs <at> gnu.org>
Subject: 31.0.50; Latest tree-sitter library mandates predicates to end with ?
 or !
Date: Thu, 23 Oct 2025 19:17:18 -0700
X-Debbugs-CC: juri <at> linkov.net <mailto:juri <at> linkov.net>
X-Debbugs-CC: eliz <at> gnu.org <mailto:eliz <at> gnu.org>

So the change to language version function isn’t the only problem with the latest tree-sitter updates. Now tree-sitter signals a syntax error if the predicate in a query (the #match, #equal, etc) don’t end with a “?” or “!”. This is new since I check the old documentation from 2021 and it didn’t have that mandate. It must be added since then and I missed it.

This isn’t a good new for us because when I added the predicates for Emacs, I want to make it as idiomatic as possible, so the predicates in Emacs are a bit different from the ones everybody else uses. Instead of #match? and #eq?, I used #match and #equal. So they are illegal now. Also, the #match predicate in Emacs has the regexp as the first argument, rather than the second, which is opposite from what others do. Here, “others” include the tree-sitter CLI tool (which has a number of built-in predicates for its operations, like produce syntax highlighting) and other editors like nvim. They have each define their own predicates but the common ones like #match?, #eq?, #set! are the same. (Technically #set! is a “directive”.)

So it’s best for us to just follow the convention now and use the same predicate as others.

Our problem is how to convert to use the blessed syntax with least amount of damage to existing code. Right now my plan is to transparently convert #match to #match?, and #equal to #eq?. For #match, we have to swap the arguments too but that’s not hard. This transparent conversion can only be done to sexp queries. If someone uses a query in the string form, we can’t convert the predicates automatically. But that shouldn’t be much of a problem since I don’t expect anybody to use the string form except for maybe 0.1% of the cases.

Another problem is the confusion this conversion might cause. I’ll add deprecation notice for the current #match and #equal predicates. But there’ll be a period where both #match and #match? are supported, and have opposite arguments. I can’t think of a good way around it though.

WDYT? Unless someone can come up with a better plan, that’s what I’ll do. Add #match? and #eq? predicate, convert old ones to them transparently, and add deprecate warning for the old predicates.

Yuan



Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79687; Package emacs. (Sun, 02 Nov 2025 22:53:01 GMT) Full text and rfc822 format available.

Message #8 received at 79687 <at> debbugs.gnu.org (full text, mbox):

From: Yuan Fu <casouri <at> gmail.com>
To: 79687 <at> debbugs.gnu.org
Subject: #79687 31.0.50; Latest tree-sitter library mandates predicates to end
 with ? or !
Date: Sun, 2 Nov 2025 14:51:56 -0800
Actually, I got a better idea. I can make the #match/#match? predicate work with both order so it works with (regexp, node) and (node, regexp), problem solved :)

Yuan



Reply sent to Yuan Fu <casouri <at> gmail.com>:
You have taken responsibility. (Mon, 03 Nov 2025 01:22:02 GMT) Full text and rfc822 format available.

Notification sent to Yuan Fu <casouri <at> gmail.com>:
bug acknowledged by developer. (Mon, 03 Nov 2025 01:22:03 GMT) Full text and rfc822 format available.

Message #13 received at 79687-done <at> debbugs.gnu.org (full text, mbox):

From: Yuan Fu <casouri <at> gmail.com>
To: 79687-done <at> debbugs.gnu.org
Subject: Re: bug#79687: #79687 31.0.50; Latest tree-sitter library mandates
 predicates to end with ? or !
Date: Sun, 2 Nov 2025 17:20:59 -0800

> On Nov 2, 2025, at 2:51 PM, Yuan Fu <casouri <at> gmail.com> wrote:
> 
> Actually, I got a better idea. I can make the #match/#match? predicate work with both order so it works with (regexp, node) and (node, regexp), problem solved :)

Now done.

Yuan



This bug report was last modified 3 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.