Skip to content

Use string query for comment font-lock (#match? compat) - #14

Closed
bbatsov wants to merge 1 commit into
mainfrom
fix/match-predicate-compat
Closed

Use string query for comment font-lock (#match? compat)#14
bbatsov wants to merge 1 commit into
mainfrom
fix/match-predicate-compat

Conversation

@bbatsov

@bbatsov bbatsov commented Apr 25, 2026

Copy link
Copy Markdown
Owner

Emacs 30.2 treesit.c translates the sexp :match form to #match (without ?). Whether that works depends on the tree-sitter C library linked with Emacs — statically linked builds (e.g., macOS) tend to accept both, but dynamically linked builds (e.g., some Linux distros) may require #match? and reject #match.

This switches the comment font-lock rule to a string query so #match? bypasses treesit-query-expand and reaches tree-sitter verbatim.

@david2038 — could you try this branch and let us know if it fixes the issue on your build?

Ref #13

Emacs 30.2 and earlier translate the sexp :match form to #match
(without ?). Whether this works depends on the tree-sitter C library
version linked with Emacs -- some accept both forms, some require
#match? exclusively. Using a string query bypasses treesit-query-expand
so #match? reaches tree-sitter verbatim.

Ref #13
@bbatsov

bbatsov commented Apr 25, 2026

Copy link
Copy Markdown
Owner Author

Closing this — the CI shows Emacs 29.4 and 30.1 reject #match? with "Currently Emacs only supports `equal', `match', and `pred' predicates". So the string query approach makes things worse on those versions.

The situation is:

  • Emacs 29.4/30.1/30.2 translate :match#match and their built-in tree-sitter accepts it
  • The reporter's build has a newer system tree-sitter that rejects #match and wants #match?

The sexp :match form is the only portable option — it lets each Emacs translate to what its tree-sitter expects. The conflict is between the reporter's Emacs C code and their system's tree-sitter library, not something we can fix.

@bbatsov bbatsov closed this Apr 25, 2026
@bbatsov bbatsov mentioned this pull request Apr 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant