From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.devel Subject: Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms Date: Wed, 11 Dec 2024 22:05:56 -0800 Message-ID: References: <2C0B7D3A-6131-4427-BF04-9211981B57DD@gmail.com> <867c8g3o6v.fsf@gnu.org> <0D278D91-4D67-4E0E-869F-6AF0A46678F7@gmail.com> <791c31a1-84ab-4cab-921b-cc8977e980d9@gutov.dev> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3776.700.51\)) 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="28711"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Andrea Corallo , Eli Zaretskii , emacs-devel@gnu.org To: Dmitry Gutov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Dec 12 07:06:59 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 1tLcLh-0007Ii-PH for ged-emacs-devel@m.gmane-mx.org; Thu, 12 Dec 2024 07:06:57 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tLcL1-0007Jw-FN; Thu, 12 Dec 2024 01:06:15 -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 1tLcKz-0007Ja-J8 for emacs-devel@gnu.org; Thu, 12 Dec 2024 01:06:13 -0500 Original-Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tLcKw-0003fi-Py; Thu, 12 Dec 2024 01:06:12 -0500 Original-Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-725ef0397aeso213822b3a.2; Wed, 11 Dec 2024 22:06:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733983568; x=1734588368; darn=gnu.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=MZdwzpuL9gi2jxGhvW8LfbzxGsSsZWfJZQ+fc5S75UU=; b=OGVs9fRS9kl9w82atFPX8ZnI+xZF+uzKtNozBNkPT564xbo148bAIkb53mujiELIzx 4IjBknTLuQWjQ/LhWiGJezvPMx103GSttLrj7kp4P+dK9P6sdYYQpPgSOYD/JzuoFUNs HZz8kQnzsom9oA6QywASsThrtmuqyxnWuwI3CNmgARjjD9qEHVImMT6m6fHRHIDE0K+7 BvwbzhuVldkBr96qZ1tnL06JETrsuYMy/hcPvFeRuNHl5qXWlF0Tgui4R7mDm2i2qIPo +ncRd5TDI2sHgAY/SZIC5RLdncarlzmvnmlvvEfZiMJMfdh7i2wWt2+Db4WumIrNG4Me lxjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733983568; x=1734588368; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MZdwzpuL9gi2jxGhvW8LfbzxGsSsZWfJZQ+fc5S75UU=; b=X83fEED3vPu16MdMqE/eplp6D6ABbJ3jpzlXT9YUX9kzCWoGb/EaKGqp2pLyZKtI4b EKFfdKRXyNOgpC5a+vigSvmhK2STWiXNJYsLyvdZ+QAqh9NM7plR+C91+CLW/+hxx9RX WY+k9HK1UkhKrRPnAHSvCxt0cJDyhC5PMyl1fJ1LtEoFmSpyGVZm0tCyCCdTU9789wYr 0dExN9fYRClJMVn45iXiM6mrX3DfaqN+91JPNVJ4g/C9Ki5YpJEv+Pmq5zHhFVaNvxQI Jc/7g1YL0nf8BSFLafN3rv7wufF3rqZlfHlujcyzghGpUkH1FZUry9AjRaToWv7wMLfW 6n/Q== X-Forwarded-Encrypted: i=1; AJvYcCUIbaEQkE86Ct28o+1daf5ivYq0+ua551MFBpmgwWycw4gyUcbd4m0rGuACJaEGIdW4WJQ8+HuQGEf8hrM=@gnu.org, AJvYcCXS+MyQv4dklwOg1qNIHF+Qsa/k94QIhW+8CX+lgAGLiuirP0CuyvyhPz23H/5+q3/1zvV2@gnu.org X-Gm-Message-State: AOJu0YyGDXTQNXPhxR03Esi0WpTKVB92+lsQYIGv/hCijIW0/pWqG17T +14UsLh133gvyh2YcuHGeWLJ3kV3kdvYhhqOEggSfP9qK5RWYZK33okmUQ== X-Gm-Gg: ASbGnctHZycZCDigHJtVPJGKWFYHl0cvVblCaH5u+EKvF3Uzskl1ZksaTviqpAog6dk gHpyImQCRPgEZ09R1zk+fXiJ7n7kTmSSUrwgEJe7/fdM1dIKaCvHr8vQX0geIpMznQUtwpfc0ym jITVUr8wshZmYQJp3iMlsvGwzbk4h90i+QPPlKnAKxRI//4ejo1kl4PdcYV+9IM2n4eh6LerH1P HKejwN0mizhfwoCa6ko8YGMFnACWKUR77Yjbc/GCqWgeKLh/pZXzJPOPrVwNz8c/MQ7hZb1N4m3 e480 X-Google-Smtp-Source: AGHT+IH7/5sFZh1j7hTS4VMOEtiJ6AchZxbvlt21iXoJZ8c3fMN2KsS7TVrPPXQ7jBGgqiLt9db2rQ== X-Received: by 2002:a05:6a00:3e0b:b0:728:e2cc:bfd6 with SMTP id d2e1a72fcca58-728faab06admr3227426b3a.18.1733983568267; Wed, 11 Dec 2024 22:06:08 -0800 (PST) Original-Received: from smtpclient.apple ([2601:646:8f81:6120:e40f:e83b:f0f0:1e5e]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-725eb9b6efdsm6687442b3a.34.2024.12.11.22.06.07 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Dec 2024 22:06:07 -0800 (PST) In-Reply-To: X-Mailer: Apple Mail (2.3776.700.51) Received-SPF: pass client-ip=2607:f8b0:4864:20::42c; envelope-from=casouri@gmail.com; helo=mail-pf1-x42c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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:326400 Archived-At: > On Dec 11, 2024, at 4:23=E2=80=AFPM, Dmitry Gutov = wrote: >=20 > 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 >=20 > 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. >=20 >> - 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. >=20 > Sure. All non-static ones anyway. I tried to define all the C functions and it=E2=80=99s not easy to do: = doing it in C seems pretty tedious, we=E2=80=99d 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=E2=80=99m not = familiar with Emacs=E2=80=99s build process so I don=E2=80=99t 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=E2=80=99ll see a bunch of warnings unless the = package author added declare-function forms or the proposed macro. = It=E2=80=99s better to have tree-sitter functions always defined and = save everybody some hassle. Yuan=