GNU bug report logs - #60453
29.0.60; treesit-range-rules throw an error without tree-sitter

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Wilhelm Kirschbaum <wkirschbaum@HIDDEN>; dated Sat, 31 Dec 2022 15:01:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 60453 <at> debbugs.gnu.org:


Received: (at 60453) by debbugs.gnu.org; 17 Jan 2023 09:41:58 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jan 17 04:41:58 2023
Received: from localhost ([127.0.0.1]:35805 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pHiTd-0000tY-MG
	for submit <at> debbugs.gnu.org; Tue, 17 Jan 2023 04:41:58 -0500
Received: from mail-pg1-f181.google.com ([209.85.215.181]:35787)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <casouri@HIDDEN>) id 1pHiTb-0000tF-4w
 for 60453 <at> debbugs.gnu.org; Tue, 17 Jan 2023 04:41:55 -0500
Received: by mail-pg1-f181.google.com with SMTP id f3so21518153pgc.2
 for <60453 <at> debbugs.gnu.org>; Tue, 17 Jan 2023 01:41:55 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=to:cc:date:message-id:subject:mime-version
 :content-transfer-encoding:from:from:to:cc:subject:date:message-id
 :reply-to; bh=rdASjmu65jH1d3TML0+reWxU4rGwgjZYscLn4/GVYqg=;
 b=PbCFKeC2DsiO0uKVnihyIQJ0rPJUop27/KhLddnMD35dWw3qZ7fazdpWOE28LiB/ZE
 aJhrMuF798eZ2aKYfJq1pFd2PNkla0dzQ4+AnnHC+tywLXVK4Wn1yaJ/3sFesaUQ22CL
 2y2063Gg+VJVLLYvljKeNXgQxbVV+4/sdQi3t6yyreu04H0LJc0+1FsqC+hTI/QKVvPE
 DWt/YKj84hPK1Kxm5eDR1SE9mGBTTqxFCAYDwbbjglATMHGLKHJeRG+ox4iaR+KYKeBt
 sd6JxEmSvHfIHs+1dRxOCchQklHzr5PY2nbpDwxTs9PtSXqfA3idp5tW+cdqPXCMlgoq
 M9oQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=to:cc:date:message-id:subject:mime-version
 :content-transfer-encoding:from:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=rdASjmu65jH1d3TML0+reWxU4rGwgjZYscLn4/GVYqg=;
 b=sNHj5tyShpBi1yZMoXdjoaxYX6Lwbasprrwy0ZOTGvtmy9QKf1b8f34dmHWUGEWd0b
 eX2vKkvTPedHe06vqHdUS7YgsXme2MEwhS5LwzmdsPDYgbJXnjZKVpID6FwB2gvIZaAJ
 kDz8GuKVbxM7hdXB8UiN+d1ieq9ER9y4vhA7dEY2cVSYMtWJFnFduwC/fQbXF7iS6R7x
 bWxETeOhXxYIkMjx7fPJ8UA3vvvB922yuC96hmzD3TxFtaSSY6SkDGm3+u4vzzTG0LK2
 2SzE1KpXdkNy8b8cKipvAapcriAJLNxM5zcZYY+X/yiw+x1hRZLemRl162YisJmG4gV+
 1JlQ==
X-Gm-Message-State: AFqh2koXV1wqy7kU6nUUwzUzK7l5kE7wJNOUMZXizEKTjnIkjuPY4jc1
 NYK1BY0ToCPTwMzCdZnTERU=
X-Google-Smtp-Source: AMrXdXskiAUjpcj12riynidXPkL5iwpSuliCQJO9q3T4R68HdaXN7n+g5VvCnVF2fYxPSar3BGndGw==
X-Received: by 2002:aa7:8544:0:b0:58d:d0de:fc11 with SMTP id
 y4-20020aa78544000000b0058dd0defc11mr693565pfn.31.1673948509613; 
 Tue, 17 Jan 2023 01:41:49 -0800 (PST)
Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com.
 [172.117.161.177]) by smtp.gmail.com with ESMTPSA id
 i1-20020a056a00004100b00581a156b920sm7404451pfk.132.2023.01.17.01.41.48
 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128);
 Tue, 17 Jan 2023 01:41:49 -0800 (PST)
From: Yuan Fu <casouri@HIDDEN>
Content-Type: text/plain;
	charset=utf-8
Content-Transfer-Encoding: quoted-printable
Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\))
Subject: Re: bug#60453: 29.0.60; treesit-range-rules throw an error without 
 tree-sitter
Message-Id: <45844FFA-6D03-4B0E-9170-C62BDDE73438@HIDDEN>
Date: Tue, 17 Jan 2023 01:41:48 -0800
To: Wilhelm <wkirschbaum@HIDDEN>
X-Mailer: Apple Mail (2.3696.120.41.1.1)
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 60453
Cc: Eli Zaretskii <eliz@HIDDEN>, 60453 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


Yuan Fu <casouri@HIDDEN> writes:

> Wilhelm Kirschbaum <wkirschbaum@HIDDEN> writes:
>
>> Eli Zaretskii <eliz@HIDDEN> writes:
>>
>>>> From: Wilhelm Kirschbaum <wkirschbaum@HIDDEN>
>>>> Cc: 60453 <at> debbugs.gnu.org
>>>> Date: Sat, 31 Dec 2022 18:50:31 +0200
>>>> Eli Zaretskii <eliz@HIDDEN> writes:
>>>>  >> From: Wilhelm Kirschbaum <wkirschbaum@HIDDEN>
>>>> >> Date: Sat, 31 Dec 2022 16:53:08 +0200
>>>> >>  >>  >> With the following code without tree-sitter library:
>>>> >>  >> (defvar elixir-ts-mode--treesit-range-rules
>>>> >>   (treesit-range-rules
>>>> >>    :embed 'heex
>>>> >>    :host 'elixir
>>>> >>    '((sigil (sigil_name) @name (:match "^[H]$" @name)  >>
>>>> (quoted_content)
>>>> >>   @heex))))
>>>> >>  >> upon loading the mode I get the following error:
>>>> >>  >> treesit-range-rules: Symbol=E2=80=99s function definition is =
void:
>>>> >> treesit-query-compile
>>>> >>  >> This can easily be mitigated with (when  >>
>>>> (treesit-available-p)...)
>>>> >> but think it should function similar to how  >>
>>>> (treesit-font-lock-rules
>>>> >> work.
>>>> >
>>>> > Why does it make sense to protect treesit.el's code with
>>>> > treesit-available-p?  You aren't supposed to use treesit.el  >
>>>> functions
>>>> > when the tree-sitter library is not available.  IOW, Lisp  >
>>>> programs
>>>> > that want to use treesit-range-rules and other functions from
>>>> > treesit.el should make the treesit-available-p test _before_  >
>>>> that.
>>>> Okay, that makes sense.  I just saw this comment on
>>>> ;; treesit.el#618
>>>> (defun treesit-font-lock-rules (&rest query-specs)
>>>>   ...
>>>>   ;; Other tree-sitter function don't tend to be called unless
>>>>   ;; tree-sitter is enabled, which means tree-sitter must be
>>>> compiled.
>>>>   ;; But this function is usually call in `defvar' which runs
>>>>   ;; regardless whether tree-sitter is enabled.  So we need   this
>>>>   ;; guard.
>>>>   (when (treesit-available-p)
>>>> As treesit-range-rules also gets called with defvar and it is a
>>>> consistency issue.  I think the reason why this has not popped up
>>>> before is that no other modes I have seen uses treesit-range-rules
>>>> yet and think it will probably catch people off guard in the
>>>> future.
>>>
>>> It's up to Yuan: if he thinks this is a good idea, he should feel
>>> free
>>> to add that test.  But it's slippery slope, IMNSHO: we will very
>>> soon
>>> find ourselves adding such tests to every treesit.el function, just
>>> because some code somewhere calls that function without a prior
>>> test.
>>> IOW, IMO a single case of such callers is not enough to add a test.
>>> But that's me.
>>
>> Okay, I will add the checks before defvar anyways to keep things
>> consistent on my side.  It does make more sense to me just to not =
have
>> the
>> guards in the first place as it creates false expectation they will =
be
>> everywhere.
>
> I wonder if we should remove that guard in treesit-font-lock-rules... =
It
> looked like a good idea at the time, but now I can see it creating
> confusion going forward.

I think it=E2=80=99s too late to change treesit-font-lock-rules, maybe =
we should
add the guard to treesit-range-rules, just to be consistent? We can make
it an convention to add guards to all treesit-xxx-rules functions.

Yuan




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#60453; Package emacs. Full text available.

Message received at 60453 <at> debbugs.gnu.org:


Received: (at 60453) by debbugs.gnu.org; 2 Jan 2023 00:20:06 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Jan 01 19:20:06 2023
Received: from localhost ([127.0.0.1]:42021 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pC8Yg-0006XA-56
	for submit <at> debbugs.gnu.org; Sun, 01 Jan 2023 19:20:06 -0500
Received: from mail-pj1-f51.google.com ([209.85.216.51]:55046)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <casouri@HIDDEN>) id 1pC8Ye-0006WT-54
 for 60453 <at> debbugs.gnu.org; Sun, 01 Jan 2023 19:20:04 -0500
Received: by mail-pj1-f51.google.com with SMTP id o2so23024420pjh.4
 for <60453 <at> debbugs.gnu.org>; Sun, 01 Jan 2023 16:20:04 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=to:cc:date:message-id:subject:mime-version
 :content-transfer-encoding:from:from:to:cc:subject:date:message-id
 :reply-to; bh=LTvUSmykm12xlo8yxZ5oTTV1JoXH16TmBuNC/vufrmc=;
 b=L827zgT8Z6Gd4GvClWg7QLRK8jo36ceQ5LPUCBnLOrwz+BGzf2B8qK1GrNqpsDJ+JI
 xMh7SJpOzFzmeowFkOeppyvHyfhKJW/EJ2eOYZJ7Abvwm6iAY2k02OM8R2ru08g4kE2a
 7KBLbzovkSGNXeQqM/G4lsS4Dbhf8mlHPqYdDocEpqSLoiw4FC8umA3MdjU+xPLaxQSI
 tAC3vX6t2oxM3sxTvgrQ68gAbmusw+STYxKC+nUHsp/3eU8ODQdG5KG7icbEQZxKqF6X
 HfKei+lbc3ln8ITWWL5RuO7PVFssf40Fw5Q/RmHVyfICI2un2ZDQl0muUs4xq/bIKRv5
 KUiQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=to:cc:date:message-id:subject:mime-version
 :content-transfer-encoding:from:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=LTvUSmykm12xlo8yxZ5oTTV1JoXH16TmBuNC/vufrmc=;
 b=7O9Yiub6ivx/RtnzVpi11B77vr5rfo5a7M+Z7fUnhMguO2BsvXdT7n4n6bFux+rFR/
 Hptoo8b6o6DeQ9UImq+hCCo1eIaXqYtyS5VWLRPuzRMZNtsCyUgmw80cxNnYgUuJXTyt
 RDCq/L4b1bJ00SGnwR3LOzsnaK22w043v/F1pO7BCDKfKRAis4BZerQVlTWn+HpSh3ev
 X6IX6VYkrAACsMtnjay5Ifow+L73gqxmmVVCulhjlj+v6lmD6dZbhBwt3sufiRg4kxx2
 LsnTo2HlL3++3mE5SWfps3d/7Xa6kZAm1NGlnPPyFngYeCIHg3TDXiE+97oB89u2H49w
 3+eA==
X-Gm-Message-State: AFqh2krClvVYwjODDXMw6kTJGXGrRyBbWLomoXaDXBaa79lTO7VT3LY6
 v4RXYjoz9fUbyD0UcYvQ78g=
X-Google-Smtp-Source: AMrXdXuKbkbMFJOfhgW9YMiekVNwtDBgEix0n7hzDjk24VOLRSCekYxRsTVvVaVS5+qoO7D/f4xJEA==
X-Received: by 2002:a17:902:8ec7:b0:192:4f85:b91d with SMTP id
 x7-20020a1709028ec700b001924f85b91dmr46134927plo.46.1672618798420; 
 Sun, 01 Jan 2023 16:19:58 -0800 (PST)
Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com.
 [172.117.161.177]) by smtp.gmail.com with ESMTPSA id
 p2-20020a170902c70200b001898aa48d17sm9315652plp.185.2023.01.01.16.19.57
 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128);
 Sun, 01 Jan 2023 16:19:58 -0800 (PST)
From: Yuan Fu <casouri@HIDDEN>
Content-Type: text/plain;
	charset=utf-8
Content-Transfer-Encoding: quoted-printable
Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\))
Subject: Re: bug#60453: 29.0.60; treesit-range-rules throw an error without 
 tree-sitter
Message-Id: <45DCDC27-F7FF-4CEB-A667-2407CAB10321@HIDDEN>
Date: Sun, 1 Jan 2023 16:19:56 -0800
To: Wilhelm <wkirschbaum@HIDDEN>
X-Mailer: Apple Mail (2.3696.120.41.1.1)
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 60453
Cc: Eli Zaretskii <eliz@HIDDEN>, 60453 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


Wilhelm Kirschbaum <wkirschbaum@HIDDEN> writes:

> Eli Zaretskii <eliz@HIDDEN> writes:
>
>>> From: Wilhelm Kirschbaum <wkirschbaum@HIDDEN>
>>> Cc: 60453 <at> debbugs.gnu.org
>>> Date: Sat, 31 Dec 2022 18:50:31 +0200
>>> Eli Zaretskii <eliz@HIDDEN> writes:
>>>  >> From: Wilhelm Kirschbaum <wkirschbaum@HIDDEN>
>>> >> Date: Sat, 31 Dec 2022 16:53:08 +0200
>>> >>  >>  >> With the following code without tree-sitter library:
>>> >>  >> (defvar elixir-ts-mode--treesit-range-rules
>>> >>   (treesit-range-rules
>>> >>    :embed 'heex
>>> >>    :host 'elixir
>>> >>    '((sigil (sigil_name) @name (:match "^[H]$" @name)  >>
>>> (quoted_content)
>>> >>   @heex))))
>>> >>  >> upon loading the mode I get the following error:
>>> >>  >> treesit-range-rules: Symbol=E2=80=99s function definition is =
void:
>>> >> treesit-query-compile
>>> >>  >> This can easily be mitigated with (when  >>
>>> (treesit-available-p)...)
>>> >> but think it should function similar to how  >>
>>> (treesit-font-lock-rules
>>> >> work.
>>> >
>>> > Why does it make sense to protect treesit.el's code with
>>> > treesit-available-p?  You aren't supposed to use treesit.el  >
>>> functions
>>> > when the tree-sitter library is not available.  IOW, Lisp  >
>>> programs
>>> > that want to use treesit-range-rules and other functions from
>>> > treesit.el should make the treesit-available-p test _before_  >
>>> that.
>>> Okay, that makes sense.  I just saw this comment on
>>> ;; treesit.el#618
>>> (defun treesit-font-lock-rules (&rest query-specs)
>>>   ...
>>>   ;; Other tree-sitter function don't tend to be called unless
>>>   ;; tree-sitter is enabled, which means tree-sitter must be
>>> compiled.
>>>   ;; But this function is usually call in `defvar' which runs
>>>   ;; regardless whether tree-sitter is enabled.  So we need   this
>>>   ;; guard.
>>>   (when (treesit-available-p)
>>> As treesit-range-rules also gets called with defvar and it is a
>>> consistency issue.  I think the reason why this has not popped up
>>> before is that no other modes I have seen uses treesit-range-rules
>>> yet and think it will probably catch people off guard in the
>>> future.
>>
>> It's up to Yuan: if he thinks this is a good idea, he should feel
>> free
>> to add that test.  But it's slippery slope, IMNSHO: we will very
>> soon
>> find ourselves adding such tests to every treesit.el function, just
>> because some code somewhere calls that function without a prior
>> test.
>> IOW, IMO a single case of such callers is not enough to add a test.
>> But that's me.
>
> Okay, I will add the checks before defvar anyways to keep things
> consistent on my side.  It does make more sense to me just to not have
> the
> guards in the first place as it creates false expectation they will be
> everywhere.

I wonder if we should remove that guard in treesit-font-lock-rules... It
looked like a good idea at the time, but now I can see it creating
confusion going forward.

Yuan




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#60453; Package emacs. Full text available.

Message received at 60453 <at> debbugs.gnu.org:


Received: (at 60453) by debbugs.gnu.org; 31 Dec 2022 17:27:47 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Dec 31 12:27:47 2022
Received: from localhost ([127.0.0.1]:39750 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pBfe6-0000Ew-KX
	for submit <at> debbugs.gnu.org; Sat, 31 Dec 2022 12:27:46 -0500
Received: from mail-wm1-f49.google.com ([209.85.128.49]:54067)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <wkirschbaum@HIDDEN>) id 1pBfe4-0000Ei-IV
 for 60453 <at> debbugs.gnu.org; Sat, 31 Dec 2022 12:27:45 -0500
Received: by mail-wm1-f49.google.com with SMTP id ja17so17545697wmb.3
 for <60453 <at> debbugs.gnu.org>; Sat, 31 Dec 2022 09:27:44 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=content-transfer-encoding:mime-version:message-id:in-reply-to:date
 :subject:cc:to:from:user-agent:references:from:to:cc:subject:date
 :message-id:reply-to;
 bh=zjQwGg3Y+2hIK/RHI/OzehgknmUKHOZGrGBul5gOYaM=;
 b=L6qbTf9yThfeLHA68kvSQn1cwDu7xDwvSmq+b7enaUnLPA89aHGEgfhQlszYP7vuP5
 msDMSzigAa7Qa5/oYFjQgh6X5JB8ThXOIoxcZuReSxwmsLMq+X0c7dXv8xEEd0bHEaBN
 cBUSQSjbV/S2KJ6Jrcin29s0H4jzIAdSt1aR0qlcYRUj9jWhM5CS834S/LLj51xPb2tm
 buF9nrAU8yMd1WDxmiNFvsxf+TooQyh54uZWMelTxi06iqNRr6ll4x563TQg+ExGLMDT
 up4lSihscftzVw0hM4hT8SsgNF1M9re3I+6aeMFChb73lkDy3CMqGa4asl9GforWYbXr
 baLQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=content-transfer-encoding:mime-version:message-id:in-reply-to:date
 :subject:cc:to:from:user-agent:references:x-gm-message-state:from:to
 :cc:subject:date:message-id:reply-to;
 bh=zjQwGg3Y+2hIK/RHI/OzehgknmUKHOZGrGBul5gOYaM=;
 b=keydFNaRZtbYKwsb5QcGvnr0BJ2cd62KmC5k/GGqCDMT+vUkv4Js3yaCZ5LKafA5j4
 P/ZHUjC1r7clfydOIKHR9Lczx/aCXaB/38Ef44G0nAXmfryEIdvlJj4DmqtJHPI67zUV
 ULgFaev3Y7SBy0HJtjfzLb2GLpbf/N78iFhZ2/BCFq/9AB8ziLqfwatVL650zwy+uoxh
 HI4d/tUh7AmcMMb4WeF8GLlAeHOULrz4uCpIjVZydPxxcg719F9DyLPeXl9qgiJo2/y6
 8WZcvUeI95HooOY9CiCIpeGPcKp7fATdgPPXxD9kElm63aoHyGVxed0TNwqY5WV/bTbr
 zSnA==
X-Gm-Message-State: AFqh2kp5eVG4wGJlwvVT7D6iPngRkNxOwOswIQoDDcz1xBYgunI1q9Ze
 BgooFmEfii8830Ny+ID1dDlD1DdWrV8=
X-Google-Smtp-Source: AMrXdXun7QH4/aaH+SJFRtCWMyythnAKkjy3MOO5wvJH2FLmJKxzE54Dlk2D5ygdC3HTQcen8JRo8A==
X-Received: by 2002:a05:600c:601e:b0:3c6:e61e:ae71 with SMTP id
 az30-20020a05600c601e00b003c6e61eae71mr30967104wmb.1.1672507658369; 
 Sat, 31 Dec 2022 09:27:38 -0800 (PST)
Received: from melissa.local ([2c0f:ef18:1431:0:b09:9616:db04:c248])
 by smtp.gmail.com with ESMTPSA id
 t184-20020a1c46c1000000b003b4a699ce8esm36912179wma.6.2022.12.31.09.27.36
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 31 Dec 2022 09:27:37 -0800 (PST)
References: <87wn67sjnw.fsf@HIDDEN> <83lemn4jh8.fsf@HIDDEN>
 <87r0wf7bm4.fsf@HIDDEN> <83ilhr4i7a.fsf@HIDDEN>
User-agent: mu4e 1.9.3; emacs 29.0.60
From: Wilhelm Kirschbaum <wkirschbaum@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#60453: 29.0.60; treesit-range-rules throw an error without
 tree-sitter
Date: Sat, 31 Dec 2022 19:08:19 +0200
In-reply-to: <83ilhr4i7a.fsf@HIDDEN>
Message-ID: <87mt737abd.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 60453
Cc: 60453 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


Eli Zaretskii <eliz@HIDDEN> writes:

>> From: Wilhelm Kirschbaum <wkirschbaum@HIDDEN>
>> Cc: 60453 <at> debbugs.gnu.org
>> Date: Sat, 31 Dec 2022 18:50:31 +0200
>>=20
>>=20
>> Eli Zaretskii <eliz@HIDDEN> writes:
>>=20
>> >> From: Wilhelm Kirschbaum <wkirschbaum@HIDDEN>
>> >> Date: Sat, 31 Dec 2022 16:53:08 +0200
>> >>=20
>> >>=20
>> >> With the following code without tree-sitter library:
>> >>=20
>> >> (defvar elixir-ts-mode--treesit-range-rules
>> >>   (treesit-range-rules
>> >>    :embed 'heex
>> >>    :host 'elixir
>> >>    '((sigil (sigil_name) @name (:match "^[H]$" @name)=20
>> >>    (quoted_content)
>> >>   @heex))))
>> >>=20
>> >> upon loading the mode I get the following error:
>> >>=20
>> >> treesit-range-rules: Symbol=E2=80=99s function definition is void:
>> >> treesit-query-compile
>> >>=20
>> >> This can easily be mitigated with (when=20
>> >> (treesit-available-p)...)
>> >> but think it should function similar to how=20
>> >> (treesit-font-lock-rules
>> >> work.
>> >
>> > Why does it make sense to protect treesit.el's code with
>> > treesit-available-p?  You aren't supposed to use treesit.el=20
>> > functions
>> > when the tree-sitter library is not available.  IOW, Lisp=20
>> > programs
>> > that want to use treesit-range-rules and other functions from
>> > treesit.el should make the treesit-available-p test _before_=20
>> > that.
>>=20
>> Okay, that makes sense.  I just saw this comment on
>>=20
>> ;; treesit.el#618
>> (defun treesit-font-lock-rules (&rest query-specs)
>>   ...
>>   ;; Other tree-sitter function don't tend to be called unless
>>   ;; tree-sitter is enabled, which means tree-sitter must be=20
>>   compiled.
>>   ;; But this function is usually call in `defvar' which runs
>>   ;; regardless whether tree-sitter is enabled.  So we need=20
>>   this
>>   ;; guard.
>>   (when (treesit-available-p)
>>=20
>> As treesit-range-rules also gets called with defvar and it is a
>> consistency issue.  I think the reason why this has not popped=20
>> up
>> before is that no other modes I have seen uses=20
>> treesit-range-rules
>> yet and think it will probably catch people off guard in the=20
>> future.
>
> It's up to Yuan: if he thinks this is a good idea, he should=20
> feel free
> to add that test.  But it's slippery slope, IMNSHO: we will very=20
> soon
> find ourselves adding such tests to every treesit.el function,=20
> just
> because some code somewhere calls that function without a prior=20
> test.
> IOW, IMO a single case of such callers is not enough to add a=20
> test.
> But that's me.

Okay, I will add the checks before defvar anyways to keep things
consistent on my side.  It does make more sense to me just to not=20
have the
guards in the first place as it creates false expectation they=20
will be
everywhere.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#60453; Package emacs. Full text available.

Message received at 60453 <at> debbugs.gnu.org:


Received: (at 60453) by debbugs.gnu.org; 31 Dec 2022 17:05:36 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Dec 31 12:05:36 2022
Received: from localhost ([127.0.0.1]:39740 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pBfIe-0008A8-56
	for submit <at> debbugs.gnu.org; Sat, 31 Dec 2022 12:05:36 -0500
Received: from eggs.gnu.org ([209.51.188.92]:41078)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1pBfIc-00089s-38
 for 60453 <at> debbugs.gnu.org; Sat, 31 Dec 2022 12:05:34 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1pBfIW-0003zu-Mm; Sat, 31 Dec 2022 12:05:28 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From:
 Date; bh=EqLZdkQa6kk4DPiaBPk6QWiOKjzeAJ8C5/n0nRYbEkI=; b=j84VvzbeeI0BSwi8QeHi
 OITmADJTiM9EnwHP22SQkGBiHAH/PgSKE8doQ+v8YdaGbBTMazIU9LzWDnXzee2zf/2EGlhnrGINl
 /p1FTyUqCkoYco+2iNYF1tSmwWLgaNjBM6pXgigCPNB0YlHBuqjcWBUipxWZkfNTWFjrs034iIviK
 7xsaGxy+F7mUWqUyUxbJR6OiaPPQIZt0AAxs16BXpn2nRnPtvhyOvDy0/sw2nh8qIZgBTKtMuLBo0
 iik07DAfQuIcv2r+ipw2vVloaVL2Mtdtc8QtI3/nksSBnQKs07F38QNkNJKmW/9EzE39Sx0NfQAjm
 Qegf01k5m60jSA==;
Received: from [87.69.77.57] (helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1pBfIV-0001LU-Gw; Sat, 31 Dec 2022 12:05:28 -0500
Date: Sat, 31 Dec 2022 19:05:29 +0200
Message-Id: <83ilhr4i7a.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Wilhelm Kirschbaum <wkirschbaum@HIDDEN>
In-Reply-To: <87r0wf7bm4.fsf@HIDDEN> (message from Wilhelm Kirschbaum on
 Sat, 31 Dec 2022 18:50:31 +0200)
Subject: Re: bug#60453: 29.0.60; treesit-range-rules throw an error without
 tree-sitter
References: <87wn67sjnw.fsf@HIDDEN> <83lemn4jh8.fsf@HIDDEN>
 <87r0wf7bm4.fsf@HIDDEN>
MIME-version: 1.0
Content-type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 60453
Cc: 60453 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Wilhelm Kirschbaum <wkirschbaum@HIDDEN>
> Cc: 60453 <at> debbugs.gnu.org
> Date: Sat, 31 Dec 2022 18:50:31 +0200
> 
> 
> Eli Zaretskii <eliz@HIDDEN> writes:
> 
> >> From: Wilhelm Kirschbaum <wkirschbaum@HIDDEN>
> >> Date: Sat, 31 Dec 2022 16:53:08 +0200
> >> 
> >> 
> >> With the following code without tree-sitter library:
> >> 
> >> (defvar elixir-ts-mode--treesit-range-rules
> >>   (treesit-range-rules
> >>    :embed 'heex
> >>    :host 'elixir
> >>    '((sigil (sigil_name) @name (:match "^[H]$" @name) 
> >>    (quoted_content)
> >>   @heex))))
> >> 
> >> upon loading the mode I get the following error:
> >> 
> >> treesit-range-rules: Symbol’s function definition is void:
> >> treesit-query-compile
> >> 
> >> This can easily be mitigated with (when 
> >> (treesit-available-p)...)
> >> but think it should function similar to how 
> >> (treesit-font-lock-rules
> >> work.
> >
> > Why does it make sense to protect treesit.el's code with
> > treesit-available-p?  You aren't supposed to use treesit.el 
> > functions
> > when the tree-sitter library is not available.  IOW, Lisp 
> > programs
> > that want to use treesit-range-rules and other functions from
> > treesit.el should make the treesit-available-p test _before_ 
> > that.
> 
> Okay, that makes sense.  I just saw this comment on
> 
> ;; treesit.el#618
> (defun treesit-font-lock-rules (&rest query-specs)
>   ...
>   ;; Other tree-sitter function don't tend to be called unless
>   ;; tree-sitter is enabled, which means tree-sitter must be 
>   compiled.
>   ;; But this function is usually call in `defvar' which runs
>   ;; regardless whether tree-sitter is enabled.  So we need this
>   ;; guard.
>   (when (treesit-available-p)
> 
> As treesit-range-rules also gets called with defvar and it is a
> consistency issue.  I think the reason why this has not popped up
> before is that no other modes I have seen uses treesit-range-rules
> yet and think it will probably catch people off guard in the future.

It's up to Yuan: if he thinks this is a good idea, he should feel free
to add that test.  But it's slippery slope, IMNSHO: we will very soon
find ourselves adding such tests to every treesit.el function, just
because some code somewhere calls that function without a prior test.
IOW, IMO a single case of such callers is not enough to add a test.
But that's me.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#60453; Package emacs. Full text available.

Message received at 60453 <at> debbugs.gnu.org:


Received: (at 60453) by debbugs.gnu.org; 31 Dec 2022 16:59:44 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Dec 31 11:59:44 2022
Received: from localhost ([127.0.0.1]:39724 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pBfCx-0007yX-RL
	for submit <at> debbugs.gnu.org; Sat, 31 Dec 2022 11:59:44 -0500
Received: from mail-wm1-f50.google.com ([209.85.128.50]:54051)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <wkirschbaum@HIDDEN>) id 1pBfCw-0007yJ-6M
 for 60453 <at> debbugs.gnu.org; Sat, 31 Dec 2022 11:59:42 -0500
Received: by mail-wm1-f50.google.com with SMTP id ja17so17513429wmb.3
 for <60453 <at> debbugs.gnu.org>; Sat, 31 Dec 2022 08:59:42 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=content-transfer-encoding:mime-version:message-id:in-reply-to:date
 :subject:cc:to:from:user-agent:references:from:to:cc:subject:date
 :message-id:reply-to;
 bh=4zKCKEGCKArbsZuD1RbWoDd55huAOzG3cs2fY/dxpRA=;
 b=cEiRf2sIJMyhBbGKp7NzmZ5+DgpiKqO6Ym+M2eBx7pGF3IvWiNM3ot2PoMF9gl6I/J
 bnMCtU6RrigRk+0U/mEt6E2JpZ0IyXr1WPHlOH/rSqc6PIlgoaK8Rwx0OyJucy1El9U2
 KGJGvrM+A5qi8UytPru7Sm7zKE8VTC2QyiNLS2pDhWsBUyllj4G6+cqNcv8Ryqbtw4p2
 n1j8N4ZXaccXbGSp0E6B3uuw58XuFUbH1+99Z2+S8z8nRDKORkQArtoMTwhSTnqq0w5Q
 dv/ouTxWqe/FgLwElOML5koXV1we26+pr3+OFIeAhTi8zU29KAfKhnY+MtYGhj+iae71
 Ajgg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=content-transfer-encoding:mime-version:message-id:in-reply-to:date
 :subject:cc:to:from:user-agent:references:x-gm-message-state:from:to
 :cc:subject:date:message-id:reply-to;
 bh=4zKCKEGCKArbsZuD1RbWoDd55huAOzG3cs2fY/dxpRA=;
 b=XUPlLjxHC1ar1kiN3jTvCcz2vbw+S8QBnzOXvstWFudO81ciLEDapNtk0oI8bN4Ygu
 3leaVEfoTbugZZ3hEwu/qhOIx79HDrkbUsI86PBIrPWyo4RaTtEh9MLLHyVvSZQRIRRu
 nIbMxkYoHQwXK8Pzkj53T5a7cRFc8c4Y6WEKex6M3JEkGHbcER9B+472zPh/+5dzew9h
 Uz/4kKpMEi1S1CDXyAwv6IAsI7HtJEzIT2sqq0NLr8S1XPSE/GlGD+ts879v4xl4+0pB
 YmPU7eS5+ElXnbcI3eFTv0J8wD/UrrDUpwX7SM7s09to6f5AyBUwFL/vULi5J3cA04xs
 msXA==
X-Gm-Message-State: AFqh2krJ+enTSAP34LVhgMo3PCzw0rS3sTtQ3uF+ePp0ydXkITgE9PCE
 ULnTwYfLl2Aa2DGCTXs/iQRD+EmfLhQ=
X-Google-Smtp-Source: AMrXdXveKuBoZKjHI3CkNad7IpPaDZfCQgH6aASEaEf+qifSb7VoqforMONiZyzzPRNHLk+5e+gTBQ==
X-Received: by 2002:a05:600c:a13:b0:3d0:2485:c046 with SMTP id
 z19-20020a05600c0a1300b003d02485c046mr25014850wmp.27.1672505975838; 
 Sat, 31 Dec 2022 08:59:35 -0800 (PST)
Received: from melissa.local ([2c0f:ef18:1431:0:b09:9616:db04:c248])
 by smtp.gmail.com with ESMTPSA id
 l42-20020a05600c1d2a00b003cfbbd54178sm54676407wms.2.2022.12.31.08.59.34
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 31 Dec 2022 08:59:35 -0800 (PST)
References: <87wn67sjnw.fsf@HIDDEN> <83lemn4jh8.fsf@HIDDEN>
User-agent: mu4e 1.9.3; emacs 29.0.60
From: Wilhelm Kirschbaum <wkirschbaum@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#60453: 29.0.60; treesit-range-rules throw an error without
 tree-sitter
Date: Sat, 31 Dec 2022 18:50:31 +0200
In-reply-to: <83lemn4jh8.fsf@HIDDEN>
Message-ID: <87r0wf7bm4.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 60453
Cc: 60453 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


Eli Zaretskii <eliz@HIDDEN> writes:

>> From: Wilhelm Kirschbaum <wkirschbaum@HIDDEN>
>> Date: Sat, 31 Dec 2022 16:53:08 +0200
>>=20
>>=20
>> With the following code without tree-sitter library:
>>=20
>> (defvar elixir-ts-mode--treesit-range-rules
>>   (treesit-range-rules
>>    :embed 'heex
>>    :host 'elixir
>>    '((sigil (sigil_name) @name (:match "^[H]$" @name)=20
>>    (quoted_content)
>>   @heex))))
>>=20
>> upon loading the mode I get the following error:
>>=20
>> treesit-range-rules: Symbol=E2=80=99s function definition is void:
>> treesit-query-compile
>>=20
>> This can easily be mitigated with (when=20
>> (treesit-available-p)...)
>> but think it should function similar to how=20
>> (treesit-font-lock-rules
>> work.
>
> Why does it make sense to protect treesit.el's code with
> treesit-available-p?  You aren't supposed to use treesit.el=20
> functions
> when the tree-sitter library is not available.  IOW, Lisp=20
> programs
> that want to use treesit-range-rules and other functions from
> treesit.el should make the treesit-available-p test _before_=20
> that.

Okay, that makes sense.  I just saw this comment on

;; treesit.el#618
(defun treesit-font-lock-rules (&rest query-specs)
  ...
  ;; Other tree-sitter function don't tend to be called unless
  ;; tree-sitter is enabled, which means tree-sitter must be=20
  compiled.
  ;; But this function is usually call in `defvar' which runs
  ;; regardless whether tree-sitter is enabled.  So we need this
  ;; guard.
  (when (treesit-available-p)

As treesit-range-rules also gets called with defvar and it is a=20
consistency
issue.  I think the reason why this has not popped up before is=20
that no
other modes I have seen uses treesit-range-rules yet and think it=20
will
probably catch people off guard in the future.





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#60453; Package emacs. Full text available.

Message received at 60453 <at> debbugs.gnu.org:


Received: (at 60453) by debbugs.gnu.org; 31 Dec 2022 16:38:01 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Dec 31 11:38:00 2022
Received: from localhost ([127.0.0.1]:39702 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pBerw-0007P9-KR
	for submit <at> debbugs.gnu.org; Sat, 31 Dec 2022 11:38:00 -0500
Received: from eggs.gnu.org ([209.51.188.92]:46440)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1pBerv-0007Ox-5K
 for 60453 <at> debbugs.gnu.org; Sat, 31 Dec 2022 11:37:59 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1pBerp-0007vJ-Uv; Sat, 31 Dec 2022 11:37:53 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From:
 Date; bh=38D7n6Wwdy21a0CPOhqYXAC1GhgmT0TI7QXqHAekASI=; b=khOwwTbQMBlDfqGZ4ngr
 9Tu3+nKrHv69UDwU61p5Jm0JsnToSZc9ZfgbHMyQCvs5o0IwPO3w61uzX3kYD2MnD93UJXX8FpygA
 LsU7M7OEfP85bZu+SQBka7b9d0yvNj5Ikya7mtpflgl6PjQ63GEpq7fhz+ORBNyDdDb5aNQynCM0Z
 pVT6N/yD9oObIQK8ulzG2boCxmlLPjDt2TKUG1M97hy+E/SL754CcIqlQ8cJQ9z00CuZyMTmFmNWK
 owPtfI0yi9exxkO4Koe6TtftaRSc4czJwbUzWJ6NIXXRf/J4LUmGwF6HEKbl6X1354OSxmW0opWlc
 3UzW2gmIEHMd8Q==;
Received: from [87.69.77.57] (helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1pBerp-0001be-9b; Sat, 31 Dec 2022 11:37:53 -0500
Date: Sat, 31 Dec 2022 18:37:55 +0200
Message-Id: <83lemn4jh8.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Wilhelm Kirschbaum <wkirschbaum@HIDDEN>
In-Reply-To: <87wn67sjnw.fsf@HIDDEN> (message from Wilhelm Kirschbaum on
 Sat, 31 Dec 2022 16:53:08 +0200)
Subject: Re: bug#60453: 29.0.60;
 treesit-range-rules throw an error without tree-sitter
References: <87wn67sjnw.fsf@HIDDEN>
MIME-version: 1.0
Content-type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 60453
Cc: 60453 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Wilhelm Kirschbaum <wkirschbaum@HIDDEN>
> Date: Sat, 31 Dec 2022 16:53:08 +0200
> 
> 
> With the following code without tree-sitter library:
> 
> (defvar elixir-ts-mode--treesit-range-rules
>   (treesit-range-rules
>    :embed 'heex
>    :host 'elixir
>    '((sigil (sigil_name) @name (:match "^[H]$" @name) 
>    (quoted_content)
>   @heex))))
> 
> upon loading the mode I get the following error:
> 
> treesit-range-rules: Symbol’s function definition is void:
> treesit-query-compile
> 
> This can easily be mitigated with (when (treesit-available-p)...)
> but think it should function similar to how (treesit-font-lock-rules
> work.

Why does it make sense to protect treesit.el's code with
treesit-available-p?  You aren't supposed to use treesit.el functions
when the tree-sitter library is not available.  IOW, Lisp programs
that want to use treesit-range-rules and other functions from
treesit.el should make the treesit-available-p test _before_ that.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#60453; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 31 Dec 2022 15:00:15 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Dec 31 10:00:15 2022
Received: from localhost ([127.0.0.1]:39607 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pBdLL-0004vJ-6w
	for submit <at> debbugs.gnu.org; Sat, 31 Dec 2022 10:00:15 -0500
Received: from lists.gnu.org ([209.51.188.17]:47546)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <wkirschbaum@HIDDEN>) id 1pBdLJ-0004vA-I4
 for submit <at> debbugs.gnu.org; Sat, 31 Dec 2022 10:00:13 -0500
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 <wkirschbaum@HIDDEN>)
 id 1pBdLI-0000SE-TG
 for bug-gnu-emacs@HIDDEN; Sat, 31 Dec 2022 10:00:13 -0500
Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <wkirschbaum@HIDDEN>)
 id 1pBdLG-0004yz-QK
 for bug-gnu-emacs@HIDDEN; Sat, 31 Dec 2022 10:00:12 -0500
Received: by mail-wr1-x429.google.com with SMTP id z10so22537239wrh.10
 for <bug-gnu-emacs@HIDDEN>; Sat, 31 Dec 2022 07:00:10 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=content-transfer-encoding:mime-version:message-id:date:subject:to
 :from:user-agent:from:to:cc:subject:date:message-id:reply-to;
 bh=DxEXYg1Hfjl29fZNPWw/x9V56EUZa1LposNporZOJ90=;
 b=U+EXDEdK3kXeOzedEUa9w07yyeyl/J+nICK3a+ZqnIgfge1gadf7V9qfyLq8Wm+5/F
 8TtsutI6ROurU8d+xYP0DpclVNLQWgPkG2Hw2Qwe9HSci5YvIwNdxv0uHbRpbWkCSRNp
 VDt3kTudSYQkPuLFPZd+Hs0MjLMhu8dkUD8TJaf4pvH0eFX3dGKzHK85eR7JUhvTSEi4
 golUclokuAuap7f0xUh2E0xmYeSkXxu7nVRvG0Fm4VKPNU4awSHTwAejp+AyemVu88rB
 y8R4tpDh5iOhU1oOQtKokqz6YQBsSx+h1OYxoLiissmiMM5Q7zKIqtSREVCGlZsWuPIg
 S1rA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=content-transfer-encoding:mime-version:message-id:date:subject:to
 :from:user-agent:x-gm-message-state:from:to:cc:subject:date
 :message-id:reply-to;
 bh=DxEXYg1Hfjl29fZNPWw/x9V56EUZa1LposNporZOJ90=;
 b=ry44x7ugwjshmqc2SEP+J1G8GNSoRMIXqeUyDdykSkF1xNzo9Yb2Up6MyOknCg0v2r
 nKq1KSlsJAvT6bZh8TKJU2V1MfRaKlycw3CsSOpG7vF7RkFZFD01dNw0isw96pB9e+UX
 O8vnUe5DmSOC+VAmWYxO05RWdq+kJSrfLrxxB19Whs0mvma2P6kYQcsQMWTGBWC6yykm
 Z5qD8z1wBPXqMKkhHo3N1Qd6iB09fJBSIGfBK7lqCrW8pwFQj4EgwS8wt1C6VIAZa1uT
 8tcXNM9F2KGWBMBYNIT7EHxcGs/BCnpOG1jnusEjlAlHqr0Boh44JTkXbjhh1Nf8fTmF
 Z+oQ==
X-Gm-Message-State: AFqh2kpOLJlDyGG16FBqnXbte4LjWyz1y3I+icYwtrT/fT4/KzTMtvBv
 18jNsYCPeGwtoewcFbZIIY9wEN4zwC8=
X-Google-Smtp-Source: AMrXdXtO+DwHRe6yIvtD5vQHDVmr5VyyEzdbtPayEVVZzfS6PvHgJ/Udz/xS2nF7080xxCvjh8sXlg==
X-Received: by 2002:a05:6000:49:b0:242:6777:c7e2 with SMTP id
 k9-20020a056000004900b002426777c7e2mr20411945wrx.31.1672498808760; 
 Sat, 31 Dec 2022 07:00:08 -0800 (PST)
Received: from melissa.local ([2c0f:ef18:1431:0:b09:9616:db04:c248])
 by smtp.gmail.com with ESMTPSA id
 i1-20020adfb641000000b002425787c5easm23587886wre.96.2022.12.31.07.00.07
 for <bug-gnu-emacs@HIDDEN>
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 31 Dec 2022 07:00:08 -0800 (PST)
User-agent: mu4e 1.9.3; emacs 29.0.60
From: Wilhelm Kirschbaum <wkirschbaum@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 29.0.60; treesit-range-rules throw an error without tree-sitter
Date: Sat, 31 Dec 2022 16:53:08 +0200
Message-ID: <87wn67sjnw.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: quoted-printable
Received-SPF: pass client-ip=2a00:1450:4864:20::429;
 envelope-from=wkirschbaum@HIDDEN; helo=mail-wr1-x429.google.com
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,
 RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.3 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)


With the following code without tree-sitter library:

(defvar elixir-ts-mode--treesit-range-rules
  (treesit-range-rules
   :embed 'heex
   :host 'elixir
   '((sigil (sigil_name) @name (:match "^[H]$" @name)=20
   (quoted_content)
  @heex))))

upon loading the mode I get the following error:

treesit-range-rules: Symbol=E2=80=99s function definition is void:
treesit-query-compile

This can easily be mitigated with (when (treesit-available-p)...)=20
but
think it should function similar to how (treesit-font-lock-rules=20
work.

Wilhelm




Acknowledgement sent to Wilhelm Kirschbaum <wkirschbaum@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#60453; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Tue, 17 Jan 2023 09:45:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.