From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Vincenzo Pupillo Newsgroups: gmane.emacs.bugs Subject: bug#64647: treesit-query-error due to a recent change to tree-sitter-javascript grammar definition Date: Sun, 16 Jul 2023 20:00:43 +0200 Message-ID: <1861187.tdWV9SEqCh@fedora> References: <2171209.irdbgypaU6@fedora> <83351obfqw.fsf@gnu.org> <87lefgdzea.fsf@thornhill.no> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7Bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20962"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 64647@debbugs.gnu.org, jostein@kjonigsen.net To: Eli Zaretskii , Theodor Thornhill Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jul 16 20:01:22 2023 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 1qL63e-0005G8-KB for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 16 Jul 2023 20:01:22 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qL63L-0008VH-NL; Sun, 16 Jul 2023 14:01:03 -0400 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 1qL63K-0008V4-UX for bug-gnu-emacs@gnu.org; Sun, 16 Jul 2023 14:01:02 -0400 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 1qL63K-0000FC-Mj for bug-gnu-emacs@gnu.org; Sun, 16 Jul 2023 14:01:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qL63K-0005f6-5R for bug-gnu-emacs@gnu.org; Sun, 16 Jul 2023 14:01:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Vincenzo Pupillo Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 16 Jul 2023 18:01:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64647 X-GNU-PR-Package: emacs Original-Received: via spool by 64647-submit@debbugs.gnu.org id=B64647.168953045421742 (code B ref 64647); Sun, 16 Jul 2023 18:01:02 +0000 Original-Received: (at 64647) by debbugs.gnu.org; 16 Jul 2023 18:00:54 +0000 Original-Received: from localhost ([127.0.0.1]:48512 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qL63B-0005eb-TB for submit@debbugs.gnu.org; Sun, 16 Jul 2023 14:00:54 -0400 Original-Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]:47574) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qL638-0005eO-R8 for 64647@debbugs.gnu.org; Sun, 16 Jul 2023 14:00:52 -0400 Original-Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-3fbc63c2e84so36296685e9.3 for <64647@debbugs.gnu.org>; Sun, 16 Jul 2023 11:00:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689530445; x=1692122445; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HfWb+GGRSUyjr5c8GSe/dLnVnq1/8QPhAVQ1FqkM7A4=; b=Mzb9QXBR7O07NGY4WAZAkVGk5IRT/aIywDr/QCBKKi1OxOXRPf24naMuei1p/Fjmjt Ctjx33UNwr30b23ogJQH94yciww1ZaFXEGWMapuFHPxLST+9cQv95HJiUh0EHDMCYgNO yyJxtUbG1XjshuRIAh59mJNkJKuN2IxCeZIJVPRqWKLdHETW/ZVDkuQIq1GigYiSjrGq JmFzsFxt7lZ9OuIABeNa9JylIeyFzJ/uuD+Or7JiBeq7peupZrkzvDyMovcHDxNhiWdp ClazmF0h58HUsKmAwC9FD9JlYM0/8b6lTV1HebURi4gu2tKD8wEJAFhQUs3ib9pN9eUj 17zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689530445; x=1692122445; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HfWb+GGRSUyjr5c8GSe/dLnVnq1/8QPhAVQ1FqkM7A4=; b=gcH17+pH+py0j2kia1RIwjA7eAQH1ZMwwsyzc5w40fcyMQUu5pesWklBhKTWE6San+ uh+ihW3x6YY+6yisGOoBQ5ELTyHMSmDrawZtNb6NkFX1Kk0/ej1GXlBUIv+9rh8qXCsA AfwUqtBDTMqXa6F68izw0/JOhCasg6PsRgTl9RsI5FY8QF9sBA4jk2UnFTgddWD0ThQO sChaJ81T6SkM9xpE56DNS5CgGaCb7Pf8ne8AQZ0lf6QeTf9kItMG1lviMbX1GKLXUPaI eSy8/7Ci1USmPUKGCagH6u1TcvpMKZpqg/I8vEmrHdRhi1llfBBYfIxZ/OyKLAnrcyRp TQ2Q== X-Gm-Message-State: ABy/qLaAqwsWaXVC+N8L3yr6g28yt4de+Y/tDUwKw9ZfWL61Z44HgGHB sPirTYYskT+ia96/f8P/qTwzcMWlQD+wqg== X-Google-Smtp-Source: APBJJlFK+dz3vu80+R1ci5elAIk7ue+GvmpjyP5P8IznNqWPdr6iMP7NXGiqKMw5W4VhYY37VPXaFA== X-Received: by 2002:a05:600c:210c:b0:3fb:dd9c:72d2 with SMTP id u12-20020a05600c210c00b003fbdd9c72d2mr9223672wml.31.1689530444890; Sun, 16 Jul 2023 11:00:44 -0700 (PDT) Original-Received: from fedora.localnet (2-230-139-124.ip202.fastwebnet.it. [2.230.139.124]) by smtp.gmail.com with ESMTPSA id w19-20020a1cf613000000b003fa96fe2bd9sm6032871wmc.22.2023.07.16.11.00.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Jul 2023 11:00:44 -0700 (PDT) In-Reply-To: <87lefgdzea.fsf@thornhill.no> 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:265356 Archived-At: In data domenica 16 luglio 2023 10:38:37 CEST, Theodor Thornhill ha scritto: > Eli Zaretskii writes: > >> Yeah, I think we can do that in this case. I'm just wondering whether > >> it's worth the effort or not. > > > > AFAIU, people tend to have old grammar libraries all the time. For > > example, we had a couple of bug reports for C or C++ which turned out > > to be due to grammar libraries that are not the latest HEAD of their > > respective repositories. Some people tend to use only official > > releases of those grammar libraries (for those which make releases; > > many don't). Also, you cannot upgrade the library while the Emacs > > session which uses it is running, so people who have long-running > > sessions and don't like to restart Emacs sometimes have no choice but > > to stay with an old library for some time. > > > > For these and other reasons, I think being less rigid in requiring the > > latest grammar libraries will benefit our users. > > Sure! > > >> Should we introduce some notion of > >> "deprecated" tree sitter functionalities? Otherwise I guess we'll have > >> to maintain a growing set of compat-code, which over time will incur a > >> performance cost, and it may be difficult to remember what code is > >> compat-code and what isn't. > > > > I'm not afraid of compatibility code, as long as it's manageable. We > > could retire some of that as time passes. But we are not yet at a > > point where this compatibility code presents any significant issue, so > > I'd rather we delayed the decision until we come to that bridge. > > > > 1> > I can rewrite both patches in the same way I had patched > > java-ts-mode. > > > >> > Basically, there are only two changes. I think it would be useful to > >> > have a > >> > function to check whether grammar features are supported or not. For > >> > example, a specialized version of treesit-query-validate that could > >> > also be used in interactive mode (to simplify the development). > >> > > >> > Do I rewrite the patches? > >> > >> I seem to have missed the java-ts-mode patch. Where is it? Do you have > >> such an implementation ready at hand? To me it sounds smart to have such > >> a function, and it sounds like it should be in treesit.el, but that > >> would probably be too late for emacs-29, I think? > > > > A function will probably go to master, but an ad-hoc compatibility fix > > that doesn't regress for older grammar libraries would be welcome on > > emacs-29 (assuming it is not very complicated). > > > > Thanks. > > Sure - unless Vincenzo wants to tackle it, I can look into creating a > function for master to check for available features. I am not familiar with the internal emacs treesitter binding. I would need some time to study it. However, I have seen that there are functions in the treesitter library that are not used by the current binding implementation. For example: ts_language_field_id_for_name could be useful to check whether a symbol is defined or not. In my patch for java-ts-mode I used treesit-query-capture to figure out whether a symbol was defined or not. Check out the java-ts-mode--string-highlight- helper function. > > Vincenzo, do you want to add compat-code to emacs-29 and your patches? Okay. I think I can do it this week. Do I create a new file, like treesitter- compat.el ? > I can take care of the in-core function in a separate bug, if that makes > sense :) > > Theo Vincenzo