emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: master 09b5f00613: ; Fix calls to treesit functions


From: Yuan Fu
Subject: Re: master 09b5f00613: ; Fix calls to treesit functions
Date: Sun, 18 Dec 2022 15:02:14 -0800


> On Dec 18, 2022, at 12:19 PM, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
> 
>> +(declare-function treesit-available-p "treesit.c")
>> (declare-function treesit-parser-list "treesit.c")
>> (declare-function treesit-node-type "treesit.c")
>> 
>> @@ -156,7 +157,8 @@ or follows point."
>>   (interactive "P")
>>   (save-excursion
>>     (let ((treesit-text-node
>> -           (and (treesit-parser-list)
>> +           (and (treesit-available-p)
>> +                (treesit-parser-list)
> 
> How 'bout always defining `treesit-parser-list` (and making it return
> `nil` if Emacs was compiled without Tree-sitter support)?
> 
> Most places that can make use of Tree-sitter probably would probably
> prefer not to have to worry about the subtle distinction between
> "Tree-sitter support is available but not for this major mode" and
> "Tree-sitter support is not available at all”.

That makes sense. Also, anyone using tree-sitter functions needs to declare 
functions in treesit.c in case Emacs didn’t build with tree-sitter. Should we 
streamline it with a macro like this? Would it work?

(defmacro treesit-declare-c-functions ()
  '(progn
     (declare-function treesit-node-child "treesit.c")
     ...))


(eval-when-compile
  (require 'treesit)
  (treesit-declare-c-functions))

Yuan





reply via email to

[Prev in Thread] Current Thread [Next in Thread]