unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Wilhelm Kirschbaum <wkirschbaum@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 60453@debbugs.gnu.org
Subject: bug#60453: 29.0.60; treesit-range-rules throw an error without tree-sitter
Date: Sat, 31 Dec 2022 18:50:31 +0200	[thread overview]
Message-ID: <87r0wf7bm4.fsf@gmail.com> (raw)
In-Reply-To: <83lemn4jh8.fsf@gnu.org>


Eli Zaretskii <eliz@gnu.org> writes:

>> From: Wilhelm Kirschbaum <wkirschbaum@gmail.com>
>> 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.






  reply	other threads:[~2022-12-31 16:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-31 14:53 bug#60453: 29.0.60; treesit-range-rules throw an error without tree-sitter Wilhelm Kirschbaum
2022-12-31 16:37 ` Eli Zaretskii
2022-12-31 16:50   ` Wilhelm Kirschbaum [this message]
2022-12-31 17:05     ` Eli Zaretskii
2022-12-31 17:08       ` Wilhelm Kirschbaum
2023-01-02  0:19 ` Yuan Fu
2023-01-17  9:41 ` Yuan Fu

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=87r0wf7bm4.fsf@gmail.com \
    --to=wkirschbaum@gmail.com \
    --cc=60453@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).