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.bugs Subject: bug#72453: 29.4; "use-package" macro does not load all expected related files Date: Sun, 04 Aug 2024 07:44:43 +0300 Message-ID: <86v80gucas.fsf@gnu.org> References: <87plqp9slr.fsf@priss.frightenedpiglet.com> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29951"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 72453@debbugs.gnu.org To: Derek Upham , John Wiegley Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Aug 04 06:45:59 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1saT82-0007fc-34 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 04 Aug 2024 06:45:58 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1saT7t-0005AD-Q7; Sun, 04 Aug 2024 00:45:49 -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 1saT7l-00059G-IC for bug-gnu-emacs@gnu.org; Sun, 04 Aug 2024 00:45:45 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1saT7l-0007QQ-3v for bug-gnu-emacs@gnu.org; Sun, 04 Aug 2024 00:45:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=References:In-Reply-To:From:Date:To:Subject; bh=MD248noy35PjviydI/xTRVvqO3KTipbqEqbV/POKPyE=; b=ko/MCBd0e5Y/dVQ2r1mhY9YSkU8aLkmEFrauaXSimXFMy8eM8q268Y8lYbZXAW5fRaCFzVL3w1ZLKYli4w94KzBKQpm1zrVfb9XxAblavZ+kUsWnu3dFwQcxSWPQ4j53qugXHXvfv+7AiFVaPa/j1ozWakIZ1hG6HUIKx4a1pEZe5jQU89cGYgBmU6ZEeetMJenwctQOCncrNO07799Zth9DYscc3SLxTeSEDLxfYnHNuvHR7H4+ElDliro19S+NHFlytG1yNNGwDYnz27YIom5JSj5k8/JFKzuQTGINC1K1WtX3+3uNjJwFlLwTVF2BhPCun9uBpDul8r+B986rAg==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1saT85-0003nc-Jn for bug-gnu-emacs@gnu.org; Sun, 04 Aug 2024 00:46:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 04 Aug 2024 04:46:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 72453 X-GNU-PR-Package: emacs Original-Received: via spool by 72453-submit@debbugs.gnu.org id=B72453.172274671714464 (code B ref 72453); Sun, 04 Aug 2024 04:46:01 +0000 Original-Received: (at 72453) by debbugs.gnu.org; 4 Aug 2024 04:45:17 +0000 Original-Received: from localhost ([127.0.0.1]:55246 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1saT7M-0003lE-Es for submit@debbugs.gnu.org; Sun, 04 Aug 2024 00:45:16 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:36418) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1saT7L-0003kn-Gb for 72453@debbugs.gnu.org; Sun, 04 Aug 2024 00:45:16 -0400 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 1saT6u-0007A8-1v; Sun, 04 Aug 2024 00:44:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=MD248noy35PjviydI/xTRVvqO3KTipbqEqbV/POKPyE=; b=lbO2bTtUf1g9 kra5HYzRt07ppVV11pij+SSPHv1NiaDshfT0HNfbDU8d24GXOgjXsFzADNvibnAlimBGaGvCz9REC sf11FiF/kCHHRbU5AjcnYUamCkDqsg/A64k/W6MTmCfI69wCuuM6FpH9cWdEMnjr+CpKJT7Ch2y76 Cz+Ny8xlzAbGW5j83xCHdRgue/hZeF2gdclzUHEOqgt2RuGQvfN7kwYfy7v3C2EIkopzyNq7hHW15 8IOZvDWKx++IXFkN95zuUTigDBrZ4RFiL7LjKmWg4vwMDtuaSzN+OnYXq7abFNk6aZwjDoaKkNfZc ciq+/Ia9soO95olgoZKAKA==; In-Reply-To: <87plqp9slr.fsf@priss.frightenedpiglet.com> (bug-gnu-emacs@gnu.org) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:289703 Archived-At: > Date: Sat, 03 Aug 2024 14:58:08 -0700 > From: Derek Upham via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > > This problem exists for the current emacs-30 branch HEAD. > > The following "init.el" file contents provide a test case: > > (defun use-package-ensure-trace (name args state) > (warn "use-package-ensure-trace %s %s %s" name args state) > t) > > ;; (require 'use-package) > > (setq use-package-ensure-function 'use-package-ensure-trace) > (setq use-package-always-ensure t) > > (use-package faces) > (use-package ansi-color) > (use-package files :ensure t) > (use-package rx) > (use-package avoid) > > Place it in a scratch directory "use-package-ensure-test" and invoke > Emacs with, for example: > > emacs --init-directory use-package-ensure-test Is this step necessary, i.e. does this problem has anything to do with the non-default --init-directory setting? > The init file sets use-package-always-ensure to true, and we expect > trace warnings to show up for each use-package invocation. In fact, we > only see them for the third and beyond. > > Warning (emacs): use-package-ensure-trace files (t) nil > Warning (emacs): use-package-ensure-trace rx (t) nil > Warning (emacs): use-package-ensure-trace avoid (t) nil > > Uncomment the "require" line in the init file and we see all of the > traces that we expect: > > Warning (emacs): use-package-ensure-trace faces (t) nil > Warning (emacs): use-package-ensure-trace ansi-color (t) nil > Warning (emacs): use-package-ensure-trace files (t) nil > Warning (emacs): use-package-ensure-trace rx (t) nil > Warning (emacs): use-package-ensure-trace avoid (t) nil > > The root cause is the structure of the "use-package/use-package*.el" > libraries. The "use-package" macro exists in "use-package-core.el", and > has an autoload. When Emacs evalutes a use-package form, Emacs loads > "use-package-core.el" only. It does not load any of the other > "use-package*.el" components. That means that Emacs doesn't evaluate > any of the `add-to-list' forms at the bottom of "use-package-ensure.el". > As a result, the use-package-defaults mechanism doesn't start out with > the expected :ensure or :pin behaviors. > > But the first time we refer to an :ensure property explicitly, that is > enough to trigger the autoload of "use-package-handler/:ensure", which > loads the file and sets up the defaults. All later invocations run the > :ensure checks as expected. > > Moving the "use-package" macro into the top-level "use-package" file > should fix the problem. The "use-package" file explicitly loads the > other files, which sets up all of the defaults. John, any comments or suggestions?