From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Emacs development discussions." Newsgroups: gmane.emacs.devel Subject: Re: pkg-autoloads.el vs. pkg-loaddefs.el Date: Fri, 14 Jun 2024 09:54:07 -0400 Message-ID: References: <87y1adrria.fsf@localhost> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34603"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) To: emacs-devel@gnu.org Cancel-Lock: sha1:IGLR7Qry1hD3Q5RNkKS7AWBBJ5E= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Jun 14 15:55:04 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 1sI7OR-0008rJ-0k for ged-emacs-devel@m.gmane-mx.org; Fri, 14 Jun 2024 15:55:03 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sI7Nm-0002wF-MW; Fri, 14 Jun 2024 09:54:22 -0400 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 1sI7Nj-0002uL-TE for emacs-devel@gnu.org; Fri, 14 Jun 2024 09:54:20 -0400 Original-Received: from ciao.gmane.io ([116.202.254.214]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sI7Nh-0006TS-In for emacs-devel@gnu.org; Fri, 14 Jun 2024 09:54:19 -0400 Original-Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1sI7Ne-0007nr-5n for emacs-devel@gnu.org; Fri, 14 Jun 2024 15:54:14 +0200 X-Injected-Via-Gmane: http://gmane.org/ Received-SPF: pass client-ip=116.202.254.214; envelope-from=ged-emacs-devel@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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:320073 Archived-At: > Further, `elpaa-batch-generate-autoloads' in ELPA/admin/elpa-admin.el > hard-codes pkg-autoloads.el. And I got a report that in some Emacs > packages distributed through ELPA (org-mode, tramp, hyperbole), both > pkg-autoloads and pkg-loaddefs are generated. [...] > Finally, all the libraries in Emacs core are using name-loaddefs.el. > > I feel confused about where to use which name. There is apparent > inconsistency in the above facts. Here's how I see it: `-autoloads.el` is supposed to contain what would have gone into `lisp/loaddefs.el` if the package were part of Emacs. I.e. it should contain the strict minimum necessary to expose the usual entry points to the package: enough that users of the package usually don't need to do things like add `require` or touch `auto-mode-alist` in their `.emacs`, but not so much that users who *don't* use the package pay an undue cost. ELPA packages can be installed without ever being used, just like packages bundled with Emacs, and contrary to `lisp/loaddefs.el`, `-autoloads.el` are loaded at startup so the larger they are, the slower Emacs starts up: it's really important to keep them minimal. `-loaddefs.el` is not "codified" in the same way, but in practice it contains those autoloads *internal* to a package, i.e. loaded only once we know the package is being used and typically used to avoid some undesirable toplevel `require`s inside the package's files (e.g. to avoid circular dependencies, or to load the different subparts of the package more lazily). It's fairly normal for such files to be significantly larger than the corresponding `-autoloads.el`. I hope someone can work on providing better support for `-loaddefs.el`: Lars (IIRC) has done some of the work for that in `loaddefs-gen.el`, but I think there's still some "glue" around that's needed to make it easy for a package developer to start using such a file (e.g. have `package-vc` and `elpa-admin.el` generate those files, documenting how to do it, ...). Stefan