|
From: | Wilhelm Kirschbaum |
Subject: | bug#60453: 29.0.60; treesit-range-rules throw an error without tree-sitter |
Date: | Sat, 31 Dec 2022 18:50:31 +0200 |
User-agent: | mu4e 1.9.3; emacs 29.0.60 |
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-compileThis can easily be mitigated with (when (treesit-available-p)...) but think it should function similar to how (treesit-font-lock-ruleswork.Why does it make sense to protect treesit.el's code withtreesit-available-p? You aren't supposed to use treesit.el functions when the tree-sitter library is not available. IOW, Lisp programsthat want to use treesit-range-rules and other functions fromtreesit.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.
[Prev in Thread] | Current Thread | [Next in Thread] |