From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Andrea Corallo Newsgroups: gmane.emacs.devel Subject: Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms Date: Wed, 11 Dec 2024 18:28:55 -0500 Message-ID: References: <2C0B7D3A-6131-4427-BF04-9211981B57DD@gmail.com> <867c8g3o6v.fsf@gnu.org> <0D278D91-4D67-4E0E-869F-6AF0A46678F7@gmail.com> <86h67jz36z.fsf@gnu.org> <502D58B8-9432-4A8F-B50D-ECA392B7E7C5@gmail.com> <86ser2y5e1.fsf@gnu.org> <86ser0j5hw.fsf@gnu.org> <292D0D0F-AB88-49AB-86DD-A9B736DB00F7@gmail.com> <8634iyhc9l.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9690"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Yuan Fu , monnier@iro.umontreal.ca, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Dec 12 00:30:15 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1tLW9n-0002KV-CZ for ged-emacs-devel@m.gmane-mx.org; Thu, 12 Dec 2024 00:30:15 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tLW97-0007Wf-NZ; Wed, 11 Dec 2024 18:29:33 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tLW93-0007W0-Au for emacs-devel@gnu.org; Wed, 11 Dec 2024 18:29:29 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tLW91-0006Ng-SS; Wed, 11 Dec 2024 18:29:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=f4rlLA6uRJZqUVYRz+ZbpPQDSckxnOPDPqOCtzpapzk=; b=VIp7SuNhfOLPYjswCBgu W3S7yyDmrWw6tuv7avkxz7FAeHtf7AsopBPrazXCQ/uAeeAEKytM0YLCJUtnl0swRtjyyJUxTVpc9 InT5L53YDnXd9WUqAv4kXACz+EhaXq+wHs6TG2hOj4mFfFLsroNpGa+I506GAXPuu3ec1OqS9dddJ tIc5A+7ajRJBAs+xWnopphuc1DLKhvOfN0zB5UyUs3dK+25r59tq+jIcaccnktUX/FP+dDAAfzCFH 0u3iZpI6SPashdB4yVjQI4Obbl/bKNfe6uQse41PGFd1IzaaKb92XQO1XNPz0KTXZXloJn0iT3J8u bp69F/tVDZ1vIA==; Original-Received: from acorallo by fencepost.gnu.org with local (Exim 4.90_1) (envelope-from ) id 1tLW8V-0008Sx-DP; Wed, 11 Dec 2024 18:29:25 -0500 In-Reply-To: <8634iyhc9l.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 08 Dec 2024 09:20:06 +0200") X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:326386 Archived-At: Eli Zaretskii writes: >> From: Yuan Fu >> Date: Sat, 7 Dec 2024 22:39:21 -0800 >> Cc: Eli Zaretskii , >> emacs-devel@gnu.org >>=20 >> > On Dec 7, 2024, at 5:47=E2=80=AFAM, Stefan Monnier wrote: >> >=20 >> >>> Does that mean declare-function forms only affect the file it=E2=80= =99s 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 h= ave >> >>> declare-function forms in c-ts-mode.el? >> >> Seems like that. Stefan, am I missing something here? >> >=20 >> > 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 ha= ve >> > no effect at all. >> >=20 >> > [ 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. ] >>=20 >> 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