> On Dec 7, 2024, at 5:47 AM, Stefan Monnier 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? Yuan