unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Yuan Fu <casouri@gmail.com>
To: Dmitry Gutov <dmitry@gutov.dev>
Cc: Andrea Corallo <acorallo@gnu.org>, Eli Zaretskii <eliz@gnu.org>,
	emacs-devel@gnu.org
Subject: Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms
Date: Wed, 11 Dec 2024 22:05:56 -0800	[thread overview]
Message-ID: <F44EA030-17EF-481D-8284-DEC6B4A7A01E@gmail.com> (raw)
In-Reply-To: <bb27916a-ab05-43e9-b772-3974761cff39@gutov.dev>



> On Dec 11, 2024, at 4:23 PM, Dmitry Gutov <dmitry@gutov.dev> wrote:
> 
> On 12/12/2024 01:38, Andrea Corallo wrote:
>> The suggestion of having the C functions defined to nops when
>> HAVE_TREE_SITTER is not defined is cleaner in principle, but I think
>> there are two downsides:
>> - We don't tipically do it this way, so it would be an exception
> 
> We also don't typically require a caller to have a 'declare-function' for every function they use from a package that they (require ...) already.
> 
>> - Also we should do it for all the functions in treesit.c, otherwise we
>>   don't solve the original problem of introducing warnings by mistake on
>>   non treesit builds.
> 
> Sure. All non-static ones anyway.

I tried to define all the C functions and it’s not easy to do: doing it in C seems pretty tedious, we’d need DEFUN form and defsubr for each function (is there a easier way?). If done in lisp, we need to do it in a separate file and _load_ it before compiling treesit.el and any other package that uses tree-sitter. I’m not familiar with Emacs’s build process so I don’t know how and where to add such a file and make Emacs load it on startup.

Can someone enlighten me on how to define these functions in either C or lisp?

I think defining them as no-op for Emacs w/o tree-sitter is a good move, because otherwise if some user compiles an Emacs w/o tree-sitter and compiles a bunch of packages, and one of the package happens to be based on tree-sitter, they’ll see a bunch of warnings unless the package author added declare-function forms or the proposed macro. It’s better to have tree-sitter functions always defined and save everybody some hassle.

Yuan


  reply	other threads:[~2024-12-12  6:05 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-03  6:31 Use (eval-when-compile 'treesit) to save us from writing declare-function forms Yuan Fu
2024-12-03  8:30 ` Andrea Corallo
2024-12-04 18:21   ` Yuan Fu
2024-12-03 13:12 ` Eli Zaretskii
2024-12-04 18:19   ` Yuan Fu
2024-12-04 18:57     ` Eli Zaretskii
2024-12-05  6:25       ` Yuan Fu
2024-12-05  7:07         ` Eli Zaretskii
2024-12-07  1:12           ` Yuan Fu
2024-12-07  7:51             ` Eli Zaretskii
2024-12-07 13:47               ` Stefan Monnier
2024-12-08  6:39                 ` Yuan Fu
2024-12-08  7:20                   ` Eli Zaretskii
2024-12-11 23:28                     ` Andrea Corallo
2024-12-08 15:27                   ` Stefan Monnier
2024-12-09  1:37                     ` Yuan Fu
2024-12-09  2:40                       ` Stefan Monnier
2024-12-11  1:57                         ` Dmitry Gutov
2024-12-08 16:01     ` Dmitry Gutov
2024-12-11 23:38       ` Andrea Corallo
2024-12-12  0:23         ` Dmitry Gutov
2024-12-12  6:05           ` Yuan Fu [this message]
2024-12-12  6:43             ` Eli Zaretskii
2024-12-13  5:01               ` Yuan Fu
2024-12-12  6:19           ` Eli Zaretskii
2024-12-12  6:13         ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=F44EA030-17EF-481D-8284-DEC6B4A7A01E@gmail.com \
    --to=casouri@gmail.com \
    --cc=acorallo@gnu.org \
    --cc=dmitry@gutov.dev \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).