From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms Date: Wed, 04 Dec 2024 20:57:24 +0200 Message-ID: <86h67jz36z.fsf@gnu.org> References: <2C0B7D3A-6131-4427-BF04-9211981B57DD@gmail.com> <867c8g3o6v.fsf@gnu.org> <0D278D91-4D67-4E0E-869F-6AF0A46678F7@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12722"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Yuan Fu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Dec 04 19:58:14 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 1tIuZi-0003AU-80 for ged-emacs-devel@m.gmane-mx.org; Wed, 04 Dec 2024 19:58:14 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tIuYz-0007uj-9H; Wed, 04 Dec 2024 13:57:29 -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 1tIuYy-0007ua-5c for emacs-devel@gnu.org; Wed, 04 Dec 2024 13:57:28 -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 1tIuYx-0004Mo-TK; Wed, 04 Dec 2024 13:57: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:References:Subject:In-Reply-To:To:From: Date; bh=lr4WSruujDXXiNuWfwK7MZJoxAC+WYw8gKKq0y7fagI=; b=SHnWG31O0NbZauRuoeUi 1nYYqjfg7nTYPdlmR/Rlr4EX1Ta9WILHP7GHSpEpnmFOcoAlE7hEeFuhTFWthBLSZK6WHly7w2y4e /mp9+qwWfsOVpKd8AlEh3ugzoqcy/ShABLOwqOFCc2GXZ0k8VGyWDofuxUw81Gu2KchAa4dxR8OM5 LfkvEP++VhP1pkIYqLhHhAIZdE7x/+Rs/5oSFCf5CvZmZZxnDTXsV0HPJ+iKUwNyTK6Jjzen1a52t 3h3cgSHFCWt57FcBFDYPCSJY94W6N+ywYzhykGduJmyjGMWXO2is1Mt/hVcCV8Ymrogju1dUSMTWz TXJNwfwFOTNM4g==; In-Reply-To: <0D278D91-4D67-4E0E-869F-6AF0A46678F7@gmail.com> (message from Yuan Fu on Wed, 4 Dec 2024 10:19:42 -0800) 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:326049 Archived-At: > From: Yuan Fu > Date: Wed, 4 Dec 2024 10:19:42 -0800 > Cc: emacs-devel@gnu.org > > > > > On Dec 3, 2024, at 5:12 AM, Eli Zaretskii wrote: > > > > I don't understand" c-ts-mode.el already does > > > > (require 'treesit) > > > > So what would eval-when-compile add to that? > > When Emacs is built without tree-sitter, none of the treesit.c functions are available (except for treesit-ready-p). Now if this Emacs compiles c-ts-mode.el, it’ll signal undefined function error for all those functions. So we add declare-function forms for all the treesit.c functions used in c-ts-mode.el, and have to update the declare-function forms whenever we use some new treesit.c functions. > > If we use eval-when-compile, we don’t need to write declare-function forms in c-ts-mode.el anymore, because treesit.el has declare-function forms for all treesit.c functions. That's what I don't understand: how will eval-when-compile which loads treesit.el be different from (require 'treesit) we already have in c-ts-mode? Don't they both load treesit.el?