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: Yuan Fu
Subject: Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms
Date: Wed, 4 Dec 2024 10:19:42 -0800


> On Dec 3, 2024, at 5:12 AM, Eli Zaretskii <eliz@gnu.org> wrote:
> 
>> From: Yuan Fu <casouri@gmail.com>
>> Date: Mon, 2 Dec 2024 22:31:48 -0800
>> 
>> Some of my recent changes to c-ts-mode.el uses some more C treesit 
>> functions, and I (again) forgot to add their declare-function forms to 
>> c-ts-mode.el, and Andrea has to fix it for me. The main problem for me is 
>> that (I think) you don’t get warning for them unless you build a 
>> non-tree-sitter build of Emacs. So I’m prone to forgot about them. Also it’s 
>> a burden for anyone wanting to use tree-sitter functions.
>> 
>> treesit.el already has all the declare-function forms, how about we use 
>> (eval-when-compile 'treesit) in other files? I believe that should alleviate 
>> us from adding those declare-function forms in other files?
> 
> I don't understand" c-ts-mode.el already does
> 
>  (require 'treesit)
> 
> So what would eval-when-compile add to that?

When Emacs is built without tree-sitter, none of the treesit.c functions are 
available (except for treesit-ready-p). Now if this Emacs compiles 
c-ts-mode.el, it’ll signal undefined function error for all those functions. So 
we add declare-function forms for all the treesit.c functions used in 
c-ts-mode.el, and have to update the declare-function forms whenever we use 
some new treesit.c functions.

If we use eval-when-compile, we don’t need to write declare-function forms in 
c-ts-mode.el anymore, because treesit.el has declare-function forms for all 
treesit.c functions.

Yuan


reply via email to

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