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: Eli Zaretskii
Subject: Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms
Date: Sun, 08 Dec 2024 09:20:06 +0200

> From: Yuan Fu <casouri@gmail.com>
> Date: Sat, 7 Dec 2024 22:39:21 -0800
> Cc: Eli Zaretskii <eliz@gnu.org>,
>  emacs-devel@gnu.org
> 
> > On Dec 7, 2024, at 5:47 AM, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
> > 
> >>> Does that mean declare-function forms only affect the file it’s in?
> >>> Because if treesit.el has declare-function forms for all the treesit.c
> >>> functions, and c-ts-mode.el requires treesit.el, why do we need to have
> >>> declare-function forms in c-ts-mode.el?
> >> Seems like that.  Stefan, am I missing something here?
> > 
> > Yes, `declare-function` *should* follow the same principles as `(defvar
> > FOO)`, meaning that they are compiler directives not functions to
> > execute.  They affect warnings only in the current lexical scope, and
> > requiring a file full of `(defvar FOO)` and `declare-function` will have
> > no effect at all.
> > 
> > [ Side note regarding this *should*: it currently doesn't work quite as
> >  well as `defvar` because its effect is always file-wide, whereas it
> >  should be limited to the current scope.  ]
> 
> Defining a macro that contains the declare-function forms, and calling it in 
> eval-when-compile forms seem to work (see patch), WDYT? The name 
> (treesit-declare-c-functions) could be better, any ideas?

Looks a bit ugly, but maybe this is the best we can do.

Andrea, WDYT?



reply via email to

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