emacs-devel
[Top][All Lists]
Advanced

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

Re: Use (eval-when-compile 'treesit) to save us from writing declare-fun


From: Stefan Monnier
Subject: Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms
Date: Fri, 13 Dec 2024 16:54:01 -0500
User-agent: Gnus/5.13 (Gnus v5.13)

>>> I thought eval-when-compile is more of a “include if compiling” macro, 
>>> should’ve checked 🙂
>>>
>>> We can also go with Dmitry’s idea, and just define all the functions in
>>> treesit.el if Emacs is not built with tree-sitter. We can detect that with
>>> treesit-available-p.
>> I haven't really thought about it, so I don't have a strong opinion.
>> AFAICT your proposal should work fine even if you remove the
>> `eval-when-compile` wrappers to which I objected.  🙂
>
> It seems to me that, having taken than route, we would recommend every
>
>   (require 'treesit)
>
> to be accompanied by
>
>   (treesit-declare-c-functions)
>
> ...or the familiar declare-function list, of course.
>
> And the same would also be true for transitive dependencies (so, both
>  c-ts-common and c-ts-mode, even though otherwise the latter could drop the
> (require 'treesit) form).

Yup.  The only cleanish way to avoid having to do that (short of
a major improvement to the byte-compiler's handling of tracking when
functions are defined) is to arrange it to all those function are always
defined (and presumably signal errors when treesit is not actually
available).


        Stefan




reply via email to

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