From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Wilhelm Kirschbaum Newsgroups: gmane.emacs.bugs Subject: bug#60453: 29.0.60; treesit-range-rules throw an error without tree-sitter Date: Sat, 31 Dec 2022 18:50:31 +0200 Message-ID: <87r0wf7bm4.fsf@gmail.com> References: <87wn67sjnw.fsf@gmail.com> <83lemn4jh8.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13733"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.9.3; emacs 29.0.60 Cc: 60453@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Dec 31 18:00:21 2022 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 1pBfDZ-0003Q4-5U for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 31 Dec 2022 18:00:21 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pBfDR-0007Fg-Jw; Sat, 31 Dec 2022 12:00:14 -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 1pBfDH-0007EG-Kn for bug-gnu-emacs@gnu.org; Sat, 31 Dec 2022 12:00: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 1pBfDH-0000Xx-9B for bug-gnu-emacs@gnu.org; Sat, 31 Dec 2022 12:00:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pBfDG-0007ze-Up for bug-gnu-emacs@gnu.org; Sat, 31 Dec 2022 12:00:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Wilhelm Kirschbaum Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 31 Dec 2022 17:00:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60453 X-GNU-PR-Package: emacs Original-Received: via spool by 60453-submit@debbugs.gnu.org id=B60453.167250598430665 (code B ref 60453); Sat, 31 Dec 2022 17:00:02 +0000 Original-Received: (at 60453) by debbugs.gnu.org; 31 Dec 2022 16:59:44 +0000 Original-Received: from localhost ([127.0.0.1]:39724 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pBfCx-0007yX-RL for submit@debbugs.gnu.org; Sat, 31 Dec 2022 11:59:44 -0500 Original-Received: from mail-wm1-f50.google.com ([209.85.128.50]:54051) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pBfCw-0007yJ-6M for 60453@debbugs.gnu.org; Sat, 31 Dec 2022 11:59:42 -0500 Original-Received: by mail-wm1-f50.google.com with SMTP id ja17so17513429wmb.3 for <60453@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) Original-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) In-reply-to: <83lemn4jh8.fsf@gnu.org> 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:252206 Archived-At: Eli Zaretskii writes: >> From: Wilhelm Kirschbaum >> 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.