From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms Date: Fri, 13 Dec 2024 16:54:01 -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> <1771C735-A03F-4FE5-8FCE-22F9647F4C36@gmail.com> <1af97645-16bc-47d6-bcba-2dbe2a1fa583@gutov.dev> 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="24495"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Yuan Fu , Eli Zaretskii , emacs-devel@gnu.org To: Dmitry Gutov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Dec 13 22:54:56 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 1tMDcd-0006AM-Bm for ged-emacs-devel@m.gmane-mx.org; Fri, 13 Dec 2024 22:54:55 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tMDc3-0004J5-OC; Fri, 13 Dec 2024 16:54:19 -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 1tMDc2-0004IV-3G for emacs-devel@gnu.org; Fri, 13 Dec 2024 16:54:18 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tMDbu-0008OR-Of; Fri, 13 Dec 2024 16:54:17 -0500 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id AB44D10004A; Fri, 13 Dec 2024 16:54:04 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1734126842; bh=DEtH0yGU4ZNoZ+UghcxBqpm9HM0+UkS6JJbcikQYeNI=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=BJfOroW6WcRxVl7sghJJLZ2twoYSsr9WAvfF1StrvrmvacPaDJySFjYv9HjbLHrgY nmeqmhGUtJGNMU7ItgafLNqm7LW5orfkp0FT/N6u86ViIcC+t5u15vseTpsc8g/H0F dg5iV1PN+N9JTiEEkRBAcPsHOn8fgRKeHHD4CnL9xrF6rnfREwTVpQuQJIsiCK71Lv P/zWVncDkmIefKbGw8K0iiz22kkkNc6lQXH8l7qIpe4IuR8/+cmFXQhfTmqAereOp0 S1atbphOb/AlCaKWiISy9ji1AATYvMHBLtqBDijXIh62zJ1U3WM85BVyTTem6V8D2r LorvxvgeWfCfA== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id B6626100042; Fri, 13 Dec 2024 16:54:02 -0500 (EST) Original-Received: from alfajor (104-195-225-43.cpe.teksavvy.com [104.195.225.43]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 7D9631203B6; Fri, 13 Dec 2024 16:54:02 -0500 (EST) In-Reply-To: <1af97645-16bc-47d6-bcba-2dbe2a1fa583@gutov.dev> (Dmitry Gutov's message of "Wed, 11 Dec 2024 03:57:42 +0200") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_PASS=-0.001, T_SPF_HELO_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action 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:326459 Archived-At: >>> I thought eval-when-compile is more of a =E2=80=9Cinclude if compiling= =E2=80=9D macro, should=E2=80=99ve checked =F0=9F=99=82 >>> >>> We can also go with Dmitry=E2=80=99s idea, and just define all the func= tions in >>> treesit.el if Emacs is not built with tree-sitter. We can detect that w= ith >>> treesit-available-p. >> I haven't really thought about it, so I don't have a strong opinion. >> AFAICT your proposal should work fine even if you remove the >> `eval-when-compile` wrappers to which I objected. =F0=9F=99=82 > > It seems to me that, having taken than route, we would recommend every > > (require 'treesit) > > to be accompanied by > > (treesit-declare-c-functions) > > ...or the familiar declare-function list, of course. > > And the same would also be true for transitive dependencies (so, both > c-ts-common and c-ts-mode, even though otherwise the latter could drop t= he > (require 'treesit) form). Yup. The only cleanish way to avoid having to do that (short of a major improvement to the byte-compiler's handling of tracking when functions are defined) is to arrange it to all those function are always defined (and presumably signal errors when treesit is not actually available). Stefan