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#61913: java-ts-mode query error for string highlight, due to recent commit in tree-sitter-java. Date: Mon, 06 Mar 2023 15:03:46 +0100 Message-ID: <2822162.Lt9SDvczpP@3-191.divsi.unimi.it> References: <23F92D53-993F-43D6-8A22-00F7AAE10505@gmail.com> <83lekb8cba.fsf@gnu.org> <874jqyo1b2.fsf@thornhill.no> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart4524094.ejJDZkT8p0" Content-Transfer-Encoding: 7Bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13967"; mail-complaints-to="usenet@ciao.gmane.io" Cc: casouri@gmail.com, 61913@debbugs.gnu.org To: Eli Zaretskii , Theodor Thornhill Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Mar 06 15:04:18 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 1pZBRq-0003Qa-Ci for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 06 Mar 2023 15:04:18 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZBRc-0003uI-Gt; Mon, 06 Mar 2023 09:04:04 -0500 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 1pZBRb-0003u2-21 for bug-gnu-emacs@gnu.org; Mon, 06 Mar 2023 09:04:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pZBRa-0006sb-Il for bug-gnu-emacs@gnu.org; Mon, 06 Mar 2023 09:04:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pZBRZ-0006vx-V0 for bug-gnu-emacs@gnu.org; Mon, 06 Mar 2023 09:04:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Vincenzo Pupillo Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 06 Mar 2023 14:04:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61913 X-GNU-PR-Package: emacs Original-Received: via spool by 61913-submit@debbugs.gnu.org id=B61913.167811143626643 (code B ref 61913); Mon, 06 Mar 2023 14:04:01 +0000 Original-Received: (at 61913) by debbugs.gnu.org; 6 Mar 2023 14:03:56 +0000 Original-Received: from localhost ([127.0.0.1]:41728 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pZBRU-0006vd-Ba for submit@debbugs.gnu.org; Mon, 06 Mar 2023 09:03:56 -0500 Original-Received: from mail-ed1-f41.google.com ([209.85.208.41]:37536) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pZBRS-0006vQ-DH for 61913@debbugs.gnu.org; Mon, 06 Mar 2023 09:03:54 -0500 Original-Received: by mail-ed1-f41.google.com with SMTP id j11so19451703edq.4 for <61913@debbugs.gnu.org>; Mon, 06 Mar 2023 06:03:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678111428; 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=RsYuj4KrkCFDodmRqLT+hzVLy8s5n1mbYiYuYhII8rk=; b=IMx6xiFsDvvNP078dNPoOOQ6bOO0tvjiZs1dfF8hn4dOR0IJtc5HoHdEadDaVjZZXY 2vN5OdR6pOzsASX9XyQQrbblqxyGa40NfB39rSfC9q2pRKFH4DpP4IXnqBtNe1zOPMWS bg5mRvnac8MCX96GQAmHS8K5LCheDq1KXVHyeJ3Pwyq2E7Fk7/WwBb8s2Hv7xTH1LSPI wx2dOdW9FkIZKFxowKdxMgySARBAVvfpEYeJeOSGiCd4wWEZC1YlNMYARd57A4eA9kqZ y9zy6+MB7XaOKBpg53AWfKFXtjsPNDbQyph8dugxnRt2EOq5x5Yn1m/G13z1OzBpuQGE rYAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678111428; 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=RsYuj4KrkCFDodmRqLT+hzVLy8s5n1mbYiYuYhII8rk=; b=nq4fYDxV9074QHxNFYN3vlb5K3MF28ltZuycX+Gc0uyx3+UZ+VqO7D+OBRbDi5CXTl hFBf49x06Nsh+C3FjV4EaGKhbnTUCIbTJLaaCmBn8/QKq0wGeLHS6qTOaybb/Hnefiko RclekmDHWubSnLkjRNuHppqDSN2jJviw4oG+2Ep2hYHrbmb/TYZECxnhp6s7SKWjY4uR hbkHXbaGP3aKDdwcMDidvZRruNl8aalmRfNfP7JnHk6RzrWsgBgnG0yuQluJCX3BNML5 HW5wa6lYQ8FOjd3T+ZGF9tewhjTIEm2cpOolP2xieUHkel1IxWdBOG2Cv0jZgC6J/qbH REYg== X-Gm-Message-State: AO0yUKXzVF6OlZ697oKRWuO/OCGt0iWdSau3GqsTModXP7gCEWUZNKgE U1oPVi7wfgVlXPFmZzVzwag= X-Google-Smtp-Source: AK7set9WQy9bG+tIraHP1kI1bSkWszXwjQ79tADAx28l3lnGvAolgYp26eMGRi3a0nUcXWqHGerbiA== X-Received: by 2002:a17:906:fca8:b0:8ae:707:e129 with SMTP id qw8-20020a170906fca800b008ae0707e129mr10629514ejb.19.1678111428060; Mon, 06 Mar 2023 06:03:48 -0800 (PST) Original-Received: from 3-191.divsi.unimi.it (3-191.divsi.unimi.it. [159.149.3.191]) by smtp.gmail.com with ESMTPSA id vf22-20020a170907239600b008ee64893786sm4669188ejb.99.2023.03.06.06.03.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Mar 2023 06:03:47 -0800 (PST) In-Reply-To: <874jqyo1b2.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:257396 Archived-At: This is a multi-part message in MIME format. --nextPart4524094.ejJDZkT8p0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="ISO-8859-1" Is this patch okay? Please feel free to make any changes you see fit. Thank you. Vincenzo In data luned=EC 6 marzo 2023 07:12:49 CET, Theodor Thornhill ha scritto: > Eli Zaretskii writes: >=20 > >> From: Vincenzo Pupillo > >> Date: Sun, 5 Mar 2023 14:50:39 +0100 > >> Cc: Eli Zaretskii , 61913@debbugs.gnu.org > >>=20 > >> nvim-treesiter seems to use a "lockfile" in which they put the version= of the language parser to be installed > >> (https://github.com/nvim-treesitter/nvim-treesitter/blob/master/lockfi= le.json) to allow some stability I suppose. > > > > Those seem to be Git SHA hashes, but how can Emacs verify that the > > particular grammar shared library is of that revision or later? We > > can only tell users to verify that, which is not very reliable, and > > requires users to clone the repository. >=20 > We could keep a header in the *-ts-mode.el file maybe? Something like: >=20 >=20 > ;;; Grammar version: 95e84b5493e8d21060f1a905d2e5e3c5590bae45 >=20 >=20 > Anyway, I think until we have such a system in place, we should strive > to adhere to the most recent version of the grammar. The diff is ok, > Vicenzo. Would you like to add a proper patch or should I just do it? > I mean with a commit message and format like in CONTRIBUTE? >=20 > Theo >=20 --nextPart4524094.ejJDZkT8p0 Content-Disposition: attachment; filename="0001-java-ts-mode-detect-if-text_block-is-supported.patch" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="unicode-2-0-utf-8"; name="0001-java-ts-mode-detect-if-text_block-is-supported.patch" >From 72f32b71d82b925e5b4aa5d6bebc707aaca992af Mon Sep 17 00:00:00 2001 From: Vincenzo Pupillo Date: Mon, 6 Mar 2023 12:24:34 +0100 Subject: [PATCH] java-ts-mode: detect if text_block is supported. A recent commit in tree-sitter-java (issue #141) removed support for the text_block node type from the grammar. To support the old released version and the new one, a helper function was added on which the string syntax highlighting now depends. (bug#61913) * lisp/progmodes/java-ts-mode.el (java-ts-mode--string-highlight-helper): New helper function that return the right query string (java-ts-mode--font-lock-settings): Use it --- lisp/progmodes/java-ts-mode.el | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lisp/progmodes/java-ts-mode.el b/lisp/progmodes/java-ts-mode.el index 1115eadde7..66fec3b0f1 100644 --- a/lisp/progmodes/java-ts-mode.el +++ b/lisp/progmodes/java-ts-mode.el @@ -145,6 +145,16 @@ java-ts-mode--operators "|=" "~" ">>" ">>>" "<<" "::" "?" "&=") "Java operators for tree-sitter font-locking.") +(defun java-ts-mode--string-highlight-helper () +"Returns, for strings, a query based on what is supported by +the available version of Tree-sitter for java." + (condition-case nil + (progn (treesit-query-capture 'java '((text_block) @font-lock-string-face)) + `((string_literal) @font-lock-string-face + (text_block) @font-lock-string-face)) + (error + `((string_literal) @font-lock-string-face)))) + (defvar java-ts-mode--font-lock-settings (treesit-font-lock-rules :language 'java @@ -182,8 +192,7 @@ java-ts-mode--font-lock-settings :language 'java :override t :feature 'string - `((string_literal) @font-lock-string-face - (text_block) @font-lock-string-face) + (java-ts-mode--string-highlight-helper) :language 'java :override t :feature 'literal -- 2.39.2 --nextPart4524094.ejJDZkT8p0--