[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: |
Andrea Corallo |
Subject: |
Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms |
Date: |
Wed, 11 Dec 2024 18:28:55 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
Eli Zaretskii <eliz@gnu.org> writes:
>> 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?
If it works having the 'treesit-declare-c-functions' without the
'eval-when-compile' around would be IMO okay.
Andrea
- Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms, (continued)
- Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms, Eli Zaretskii, 2024/12/03
- Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms, Yuan Fu, 2024/12/04
- Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms, Eli Zaretskii, 2024/12/04
- Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms, Yuan Fu, 2024/12/05
- Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms, Eli Zaretskii, 2024/12/05
- Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms, Yuan Fu, 2024/12/06
- Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms, Eli Zaretskii, 2024/12/07
- Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms, Stefan Monnier, 2024/12/07
- Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms, Yuan Fu, 2024/12/08
- Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms, Eli Zaretskii, 2024/12/08
- Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms,
Andrea Corallo <=
- Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms, Stefan Monnier, 2024/12/08
- Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms, Yuan Fu, 2024/12/08
- Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms, Stefan Monnier, 2024/12/08
- Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms, Dmitry Gutov, 2024/12/10
- Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms, Dmitry Gutov, 2024/12/08
- Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms, Andrea Corallo, 2024/12/11
- Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms, Dmitry Gutov, 2024/12/11
- Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms, Yuan Fu, 2024/12/12
- Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms, Eli Zaretskii, 2024/12/12
- Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms, Yuan Fu, 2024/12/13