* bug#64922: treesit-query-error due to a recent change to tree-sitter-cmake grammar definition
@ 2023-07-28 20:59 Vincenzo Pupillo
2023-07-29 7:51 ` Eli Zaretskii
0 siblings, 1 reply; 7+ messages in thread
From: Vincenzo Pupillo @ 2023-07-28 20:59 UTC (permalink / raw)
To: 64922
[-- Attachment #1: Type: text/plain, Size: 1097 bytes --]
Hi, a recent commit (commit fe9b5e022950d53cb23959b76c240e1da27ff0a5) changed
the definition of the cmake grammar, now there is a new node argument_list used
to wrap nodes of type argument.
This causes the following error:
Error during redisplay: (jit-lock-function 1) signaled (treesit-query-error
"Structure error at" 19 "((foreach_command ((argument) @font-lock-constant-
face (#match \"\\\\(?:^\\\\(?:I\\\\(?:N\\\\|TEMS\\\\)\\\\|LISTS\\\\|RANGE\\\\|
ZIP_LISTS\\\\)$\\\\)\" @font-lock-constant-face)))) ((if_command ((argument)
@font-lock-constant-face (#match \"\\\\(?:^\\\\(?:AND\\\\|COMMAND\\\\|DEFINED\
\\\|E\\\\(?:QUAL\\\\|XISTS\\\\)\\\\|GREATER\\\\(?:_EQUAL\\\\)?\\\\|LESS\\\\
(?:_EQUAL\\\\)?\\\\|MATCHES\\\\|NOT\\\\|OR\\\\|PATH_EQUAL\\\\|STR\\\\(?:EQUAL\
\\\|GREATER\\\\(?:_EQUAL\\\\)?\\\\|LESS\\\\(?:_EQUAL\\\\)?\\\\)\\\\|VERSION_\\
\\(?:EQUAL\\\\|GREATER\\\\(?:_EQUAL\\\\)?\\\\|LESS\\\\(?:_EQUAL\\\\)?\\\\)\\\
\)$\\\\)\" @font-lock-constant-face))))" "Debug the query with `treesit-query-
validate'")
The attached patch supports both the old and the new grammar.
Thanks.
Vincenzo
[-- Attachment #2: 0001-Updated-CMake-support-due-to-changes-in-tree-sitter-.patch --]
[-- Type: text/x-patch, Size: 4043 bytes --]
From 33a53c86b38624dcfe88aca24f6f1f94ab339463 Mon Sep 17 00:00:00 2001
From: Vincenzo Pupillo <v.pupillo@gmail.com>
Date: Fri, 28 Jul 2023 22:37:02 +0200
Subject: [PATCH] Updated CMake support due to changes in tree-sitter-cmake
A recent change in tree-sitter-cmake grammar support for CMake (commit
fe9b5e0), now put arguments are wrapped in a new argument_list node.
To support the old and new version of the grammar, a new function was
added on which string syntax highlighting now depends.
* lisp/progmodes/cmake-ts-mode.el: (cmake-ts-mode--font-lock-compatibility-fe9b5e0):
indent helper function for handle different tree-sitter-cmake
version
* lisp/progmodes/cmake-ts-mode.el: (cmake-ts-mode--font-lock-settings): use the new
function to handle the new argument_list node.
---
lisp/progmodes/cmake-ts-mode.el | 54 ++++++++++++++++++++++++---------
1 file changed, 39 insertions(+), 15 deletions(-)
diff --git a/lisp/progmodes/cmake-ts-mode.el b/lisp/progmodes/cmake-ts-mode.el
index 9d35d8077bd..9fcd8a7a2ab 100644
--- a/lisp/progmodes/cmake-ts-mode.el
+++ b/lisp/progmodes/cmake-ts-mode.el
@@ -31,6 +31,7 @@
(eval-when-compile (require 'rx))
(declare-function treesit-parser-create "treesit.c")
+(declare-function treesit-query-capture "treesit.c")
(declare-function treesit-induce-sparse-tree "treesit.c")
(declare-function treesit-node-child "treesit.c")
(declare-function treesit-node-start "treesit.c")
@@ -87,6 +88,42 @@
"VERSION_GREATER_EQUAL" "VERSION_LESS" "VERSION_LESS_EQUAL")
"CMake if conditions for tree-sitter font-locking.")
+(defun cmake-ts-mode--font-lock-compatibility-fe9b5e0 ()
+ "Indent rules helper, to handle different releases of tree-sitter-cmake.
+Check if a node type is available, then return the right indent rules."
+ ;; handle commit fe9b5e0
+ (condition-case nil
+ (progn (treesit-query-capture 'cmake '((argument_list) @capture))
+ `(((foreach_command
+ ((argument_list) @font-lock-constant-face
+ (:match ,(rx-to-string
+ `(seq bol
+ (or ,@cmake-ts-mode--foreach-options)
+ eol))
+ @font-lock-constant-face))))
+ ((if_command
+ ((argument_list) @font-lock-constant-face
+ (:match ,(rx-to-string
+ `(seq bol
+ (or ,@cmake-ts-mode--if-conditions)
+ eol))
+ @font-lock-constant-face))))))
+ (error
+ `(((foreach_command
+ ((argument) @font-lock-constant-face
+ (:match ,(rx-to-string
+ `(seq bol
+ (or ,@cmake-ts-mode--foreach-options)
+ eol))
+ @font-lock-constant-face))))
+ ((if_command
+ ((argument) @font-lock-constant-face
+ (:match ,(rx-to-string
+ `(seq bol
+ (or ,@cmake-ts-mode--if-conditions)
+ eol))
+ @font-lock-constant-face))))))))
+
(defvar cmake-ts-mode--font-lock-settings
(treesit-font-lock-rules
:language 'cmake
@@ -95,21 +132,8 @@
:language 'cmake
:feature 'builtin
- `(((foreach_command
- ((argument) @font-lock-constant-face
- (:match ,(rx-to-string
- `(seq bol
- (or ,@cmake-ts-mode--foreach-options)
- eol))
- @font-lock-constant-face))))
- ((if_command
- ((argument) @font-lock-constant-face
- (:match ,(rx-to-string
- `(seq bol
- (or ,@cmake-ts-mode--if-conditions)
- eol))
- @font-lock-constant-face)))))
-
+ (cmake-ts-mode--font-lock-compatibility-fe9b5e0)
+
:language 'cmake
:feature 'comment
'([(bracket_comment) (line_comment)] @font-lock-comment-face)
--
2.41.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* bug#64922: treesit-query-error due to a recent change to tree-sitter-cmake grammar definition
2023-07-28 20:59 bug#64922: treesit-query-error due to a recent change to tree-sitter-cmake grammar definition Vincenzo Pupillo
@ 2023-07-29 7:51 ` Eli Zaretskii
2023-07-29 9:13 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2023-07-29 7:51 UTC (permalink / raw)
To: Vincenzo Pupillo, Theodor Thornhill, Yuan Fu; +Cc: 64922
> From: Vincenzo Pupillo <v.pupillo@gmail.com>
> Date: Fri, 28 Jul 2023 22:59:27 +0200
>
> Hi, a recent commit (commit fe9b5e022950d53cb23959b76c240e1da27ff0a5) changed
> the definition of the cmake grammar, now there is a new node argument_list used
> to wrap nodes of type argument.
> This causes the following error:
> Error during redisplay: (jit-lock-function 1) signaled (treesit-query-error
> "Structure error at" 19 "((foreach_command ((argument) @font-lock-constant-
> face (#match \"\\\\(?:^\\\\(?:I\\\\(?:N\\\\|TEMS\\\\)\\\\|LISTS\\\\|RANGE\\\\|
> ZIP_LISTS\\\\)$\\\\)\" @font-lock-constant-face)))) ((if_command ((argument)
> @font-lock-constant-face (#match \"\\\\(?:^\\\\(?:AND\\\\|COMMAND\\\\|DEFINED\
> \\\|E\\\\(?:QUAL\\\\|XISTS\\\\)\\\\|GREATER\\\\(?:_EQUAL\\\\)?\\\\|LESS\\\\
> (?:_EQUAL\\\\)?\\\\|MATCHES\\\\|NOT\\\\|OR\\\\|PATH_EQUAL\\\\|STR\\\\(?:EQUAL\
> \\\|GREATER\\\\(?:_EQUAL\\\\)?\\\\|LESS\\\\(?:_EQUAL\\\\)?\\\\)\\\\|VERSION_\\
> \\(?:EQUAL\\\\|GREATER\\\\(?:_EQUAL\\\\)?\\\\|LESS\\\\(?:_EQUAL\\\\)?\\\\)\\\
> \)$\\\\)\" @font-lock-constant-face))))" "Debug the query with `treesit-query-
> validate'")
>
> The attached patch supports both the old and the new grammar.
Thanks.
Theo, yuan: any comments to the patch? If okay, I'd like to install
this on the release branch ASAP.
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#64922: treesit-query-error due to a recent change to tree-sitter-cmake grammar definition
2023-07-29 7:51 ` Eli Zaretskii
@ 2023-07-29 9:13 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-29 10:42 ` Eli Zaretskii
0 siblings, 1 reply; 7+ messages in thread
From: Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-07-29 9:13 UTC (permalink / raw)
To: Eli Zaretskii, Vincenzo Pupillo, Yuan Fu; +Cc: 64922
On 29 July 2023 09:51:19 CEST, Eli Zaretskii <eliz@gnu.org> wrote:
>> From: Vincenzo Pupillo <v.pupillo@gmail.com>
>> Date: Fri, 28 Jul 2023 22:59:27 +0200
>>
>> Hi, a recent commit (commit fe9b5e022950d53cb23959b76c240e1da27ff0a5) changed
>> the definition of the cmake grammar, now there is a new node argument_list used
>> to wrap nodes of type argument.
>> This causes the following error:
>> Error during redisplay: (jit-lock-function 1) signaled (treesit-query-error
>> "Structure error at" 19 "((foreach_command ((argument) @font-lock-constant-
>> face (#match \"\\\\(?:^\\\\(?:I\\\\(?:N\\\\|TEMS\\\\)\\\\|LISTS\\\\|RANGE\\\\|
>> ZIP_LISTS\\\\)$\\\\)\" @font-lock-constant-face)))) ((if_command ((argument)
>> @font-lock-constant-face (#match \"\\\\(?:^\\\\(?:AND\\\\|COMMAND\\\\|DEFINED\
>> \\\|E\\\\(?:QUAL\\\\|XISTS\\\\)\\\\|GREATER\\\\(?:_EQUAL\\\\)?\\\\|LESS\\\\
>> (?:_EQUAL\\\\)?\\\\|MATCHES\\\\|NOT\\\\|OR\\\\|PATH_EQUAL\\\\|STR\\\\(?:EQUAL\
>> \\\|GREATER\\\\(?:_EQUAL\\\\)?\\\\|LESS\\\\(?:_EQUAL\\\\)?\\\\)\\\\|VERSION_\\
>> \\(?:EQUAL\\\\|GREATER\\\\(?:_EQUAL\\\\)?\\\\|LESS\\\\(?:_EQUAL\\\\)?\\\\)\\\
>> \)$\\\\)\" @font-lock-constant-face))))" "Debug the query with `treesit-query-
>> validate'")
>>
>> The attached patch supports both the old and the new grammar.
>
>Thanks.
>
>Theo, yuan: any comments to the patch? If okay, I'd like to install
>this on the release branch ASAP.
I'm not able to look at it until tonight, which is in 8-9 hours. If that's not asap enough, I trust your judgement more than mine anyways ;-)
If that's not too late I'll take a look then and install if ok.
Theo
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#64922: treesit-query-error due to a recent change to tree-sitter-cmake grammar definition
2023-07-29 9:13 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-07-29 10:42 ` Eli Zaretskii
2023-07-29 12:22 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2023-07-29 10:42 UTC (permalink / raw)
To: Theodor Thornhill; +Cc: casouri, v.pupillo, 64922
> Date: Sat, 29 Jul 2023 11:13:10 +0200
> From: Theodor Thornhill <theo@thornhill.no>
> CC: 64922@debbugs.gnu.org
>
> On 29 July 2023 09:51:19 CEST, Eli Zaretskii <eliz@gnu.org> wrote:
> >
> >Theo, yuan: any comments to the patch? If okay, I'd like to install
> >this on the release branch ASAP.
>
> I'm not able to look at it until tonight, which is in 8-9 hours.
I guess it's okay, as I'll need to postpone the decision about
releasing Emacs 29.1 till tomorrow anyway.
Thanks.
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#64922: treesit-query-error due to a recent change to tree-sitter-cmake grammar definition
2023-07-29 10:42 ` Eli Zaretskii
@ 2023-07-29 12:22 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-29 19:19 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 1 reply; 7+ messages in thread
From: Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-07-29 12:22 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: casouri, v.pupillo, 64922
On 29 July 2023 12:42:31 CEST, Eli Zaretskii <eliz@gnu.org> wrote:
>> Date: Sat, 29 Jul 2023 11:13:10 +0200
>> From: Theodor Thornhill <theo@thornhill.no>
>> CC: 64922@debbugs.gnu.org
>>
>> On 29 July 2023 09:51:19 CEST, Eli Zaretskii <eliz@gnu.org> wrote:
>> >
>> >Theo, yuan: any comments to the patch? If okay, I'd like to install
>> >this on the release branch ASAP.
>>
>> I'm not able to look at it until tonight, which is in 8-9 hours.
>
>I guess it's okay, as I'll need to postpone the decision about
>releasing Emacs 29.1 till tomorrow anyway.
>
>Thanks.
Ok thanks, I'll be swift
Theo
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#64922: treesit-query-error due to a recent change to tree-sitter-cmake grammar definition
2023-07-29 12:22 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-07-29 19:19 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-29 19:24 ` Eli Zaretskii
0 siblings, 1 reply; 7+ messages in thread
From: Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-07-29 19:19 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: casouri, v.pupillo, 64922
Theodor Thornhill <theo@thornhill.no> writes:
> On 29 July 2023 12:42:31 CEST, Eli Zaretskii <eliz@gnu.org> wrote:
>>> Date: Sat, 29 Jul 2023 11:13:10 +0200
>>> From: Theodor Thornhill <theo@thornhill.no>
>>> CC: 64922@debbugs.gnu.org
>>>
>>> On 29 July 2023 09:51:19 CEST, Eli Zaretskii <eliz@gnu.org> wrote:
>>> >
>>> >Theo, yuan: any comments to the patch? If okay, I'd like to install
>>> >this on the release branch ASAP.
>>>
>>> I'm not able to look at it until tonight, which is in 8-9 hours.
>>
>>I guess it's okay, as I'll need to postpone the decision about
>>releasing Emacs 29.1 till tomorrow anyway.
>>
>>Thanks.
>
> Ok thanks, I'll be swift
>
> Theo
Installed.
@Vincenzo - thanks for the patch! For the next one, please make sure the
commit message conforms with the directions in CONTRIBUTE, in particular
line length :)
Theo
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-07-29 19:24 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-28 20:59 bug#64922: treesit-query-error due to a recent change to tree-sitter-cmake grammar definition Vincenzo Pupillo
2023-07-29 7:51 ` Eli Zaretskii
2023-07-29 9:13 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-29 10:42 ` Eli Zaretskii
2023-07-29 12:22 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-29 19:19 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-29 19:24 ` Eli Zaretskii
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.