all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Randy Taylor <dev@rjt.dev>
To: Jimmy Wong <wyuenho@gmail.com>
Cc: Eli Zaretskii <eliz@gnu.org>, 63086@debbugs.gnu.org, casouri@gmail.com
Subject: bug#63086: 29.0.90; go-ts-mode treesit-query-error during jit-lock
Date: Wed, 26 Apr 2023 15:40:36 +0000	[thread overview]
Message-ID: <zwkMtw65my9e_GyUU3NOy_HtsBmUmgW7jOJPngK5y0sZuiJ1iHb2RZ1fLrGgW2axXukBvqCdAisRAcyQYl0qXaK7sKG2KqgUYc7ev0QI1jI=@rjt.dev> (raw)
In-Reply-To: <Vjzy5iDJGINNO-EgyCd6gogKt02Q9kVGVhmJqKHt5D8YeW7_lxg25bCFpPc4j7JghFahHMf8chQ3ynEYTL1a895VUm5qE3Yz_W9ur593DRY=@rjt.dev>


[-- Attachment #1.1: Type: text/plain, Size: 2389 bytes --]

On Wednesday, April 26th, 2023 at 10:05, Randy Taylor <dev@rjt.dev> wrote:

> On Wednesday, April 26th, 2023 at 09:44, Jimmy Wong <wyuenho@gmail.com> wrote:
>
>> There hasn’t been any new releases since then, should emacs rely on devel packages?
>> On 26 Apr 2023 at 2:37 PM +0100, Eli Zaretskii <eliz@gnu.org>, wrote:
>>
>>>> Date: Wed, 26 Apr 2023 14:26:09 +0100
>>>> From: Jimmy Wong <wyuenho@gmail.com>
>>>> Cc: Yuan Fu <casouri@gmail.com>, Eli Zaretskii <eliz@gnu.org>,
>>>> 63086@debbugs.gnu.org
>>>>
>>>> I’m using tree-sitter-go 0.19.1 from Macports.
>>>
>>> That version was released 2 years ago. Maybe go-ts-mode.el relies on
>>>
>>> some newer functionality, or on some bug that was fixed since then?
>
> tree-sitter-go and a bunch of other grammars have dropped the ball of versioning, I think (some don't even try to version properly...). Since then there have plenty of changes, but it's stayed at the same version with no new tags. Anything packaging based on the tags of those repositories is going to be wildly out of date.
>
> You can try using `M-x treesit-install-language-grammar` to install the go grammar, which will get the latest and greatest.
>
>>
>
> If I had to guess what triggers the error, it's probably the (iota) match which seems to have been added Jan 5, 2022. You can try removing that from go-ts-mode and seeing if it fixes the issue for you (although maybe that will fix the current problem but reveal a bunch more...all of which will be easily resolved by using a more up to date grammar). I'll try to get that old version installed myself and see.
>
> I think java-ts-mode and some others have a helper that checks which queries are supported by testing them, I can make a patch for that if that's the direction we want to go.

I can reproduce this with the latest tagged tree-sitter-go version (v0.19.1 released on on Mar 3, 2021). I've attached a patch fixing it (i.e. go-ts-mode now runs and highlights), if we decide to support those older versions. Hopefully I didn't commit any elisp sins.

Please give it a try if you can, Jimmy. I still recommend that you upgrade to the latest tree-sitter-go (i.e. from the tip of the develop branch) yourself because v0.19.1 has other problems (some valid code can be highlighted as error if using the highest treesit-font-lock-level). And I would recommend that for all of the tree-sitter grammars.

>

[-- Attachment #1.2: Type: text/html, Size: 4682 bytes --]

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-go-ts-mode-Use-iota-query-only-if-supported-Bug-6308.patch --]
[-- Type: text/x-patch; name=0001-go-ts-mode-Use-iota-query-only-if-supported-Bug-6308.patch, Size: 1748 bytes --]

From 90d6ff24b5a9281bbc736c5445008ea5492fcffd Mon Sep 17 00:00:00 2001
From: Randy Taylor <dev@rjt.dev>
Date: Wed, 26 Apr 2023 11:15:45 -0400
Subject: [PATCH] go-ts-mode: Use iota query only if supported (Bug#63086)

iota query support was added on January 5, 2022.  To support older
versions of the tree-sitter-go grammar (like the latest tagged version,
v0.19.1, which was released on March 3, 2021), check if the query is
supported before trying to use it.

* lisp/progmodes/go-ts-mode.el (go-ts-mode--iota-query-supported-p): New
function.
(go-ts-mode--font-lock-settings): Use it.
---
 lisp/progmodes/go-ts-mode.el | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/lisp/progmodes/go-ts-mode.el b/lisp/progmodes/go-ts-mode.el
index 77c97ffac11..7d515263932 100644
--- a/lisp/progmodes/go-ts-mode.el
+++ b/lisp/progmodes/go-ts-mode.el
@@ -105,6 +105,12 @@ go-ts-mode--operators
     ">>" "%=" ">>=" "--" "!"  "..."  "&^" "&^=" "~")
   "Go operators for tree-sitter font-locking.")
 
+(defun go-ts-mode--iota-query-supported-p ()
+  "Returns t if the iota query is supported by the current version of
+the tree-sitter-go grammar."
+  (ignore-errors
+    (treesit-query-capture 'go '((iota) @font-lock-constant-face))))
+
 (defvar go-ts-mode--font-lock-settings
   (treesit-font-lock-rules
    :language 'go
@@ -117,7 +123,9 @@ go-ts-mode--font-lock-settings
 
    :language 'go
    :feature 'constant
-   '([(false) (iota) (nil) (true)] @font-lock-constant-face
+   `([(false) (nil) (true)] @font-lock-constant-face
+     ,@(when (go-ts-mode--iota-query-supported-p)
+         '((iota) @font-lock-constant-face))
      (const_declaration
       (const_spec name: (identifier) @font-lock-constant-face)))
 
-- 
2.40.1


  reply	other threads:[~2023-04-26 15:40 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-26 10:00 bug#63086: 29.0.90; go-ts-mode treesit-query-error during jit-lock Jimmy Yuen Ho Wong
2023-04-26 10:36 ` Eli Zaretskii
2023-04-26 11:07   ` Jimmy Wong
2023-04-26 12:38     ` Randy Taylor
2023-04-26 13:26       ` Jimmy Wong
2023-04-26 13:38         ` Eli Zaretskii
2023-04-26 13:44           ` Jimmy Wong
2023-04-26 14:05             ` Randy Taylor
2023-04-26 15:40               ` Randy Taylor [this message]
2023-04-27  6:36                 ` Jimmy Wong
2023-04-28  0:16               ` Dmitry Gutov
2023-04-28  1:35                 ` Randy Taylor
2023-04-28 10:05                   ` Dmitry Gutov
2023-05-02  0:29                     ` Randy Taylor
2023-05-03 21:58                       ` Dmitry Gutov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='zwkMtw65my9e_GyUU3NOy_HtsBmUmgW7jOJPngK5y0sZuiJ1iHb2RZ1fLrGgW2axXukBvqCdAisRAcyQYl0qXaK7sKG2KqgUYc7ev0QI1jI=@rjt.dev' \
    --to=dev@rjt.dev \
    --cc=63086@debbugs.gnu.org \
    --cc=casouri@gmail.com \
    --cc=eliz@gnu.org \
    --cc=wyuenho@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.