From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Re: Recursive Fload and eval-after-load forms. (See bug #43116.) Date: Tue, 1 Sep 2020 19:42:55 +0000 Message-ID: <20200901194255.GB12507@ACM> References: <20200831184526.GB4176@ACM> <20200831194238.GC4176@ACM> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19107"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org, Nonax To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Sep 01 21:43:36 2020 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 1kDCBr-0004tc-Ce for ged-emacs-devel@m.gmane-mx.org; Tue, 01 Sep 2020 21:43:35 +0200 Original-Received: from localhost ([::1]:49570 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kDCBq-00086K-FO for ged-emacs-devel@m.gmane-mx.org; Tue, 01 Sep 2020 15:43:34 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34398) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kDCBM-0007Tk-Df for emacs-devel@gnu.org; Tue, 01 Sep 2020 15:43:04 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:44741 helo=mail.muc.de) by eggs.gnu.org with smtp (Exim 4.90_1) (envelope-from ) id 1kDCBK-00086D-7K for emacs-devel@gnu.org; Tue, 01 Sep 2020 15:43:04 -0400 Original-Received: (qmail 28220 invoked by uid 3782); 1 Sep 2020 19:42:58 -0000 Original-Received: from acm.muc.de (p4fe15ade.dip0.t-ipconnect.de [79.225.90.222]) by localhost.muc.de (tmda-ofmipd) with ESMTP; Tue, 01 Sep 2020 21:42:57 +0200 Original-Received: (qmail 12881 invoked by uid 1000); 1 Sep 2020 19:42:55 -0000 Content-Disposition: inline In-Reply-To: X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de Received-SPF: pass client-ip=193.149.48.1; envelope-from=acm@muc.de; helo=mail.muc.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/01 15:42:58 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_MSPIKE_BL=0.001, RCVD_IN_MSPIKE_L3=0.001, 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.23 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" Xref: news.gmane.io gmane.emacs.devel:254476 Archived-At: Hello, Stefan. On Mon, Aug 31, 2020 at 23:18:35 -0400, Stefan Monnier wrote: > > Fload bails out with an error if the nesting of files it's loading has > > a file more than three times in the stack. > Indeed, we know that recursive loads do exist and don't always end up > inf-looping, so we only signal an infinite recursive load when it looks > *really* bad ;-) > > Maybe instead we could modify custom-menu-create such that it will only > > require its target file if that file isn't currently being loaded. > We could try that. Or we could make it return a dynamic menu whose > content is only computed when the menu is actually displayed. > > If it is currently being loaded, then we only include the customisable > > variables that have already been defined. This shouldn't be too much > > of a hardship, since custom variables tend to be defined near the > > start of a .el file, and the higher level functions which create the > > custom menu tend to be nearer the end of the file. > > What do you think? > According to `grep` it would be good enough for the 3 use cases we have > bundled with Emacs. Something like: diff --git a/lisp/custom.el b/lisp/custom.el index 885c486c5e..f8e154e7ae 100644 --- a/lisp/custom.el +++ b/lisp/custom.el @@ -649,7 +649,8 @@ custom-load-symbol (ignore-errors (require 'cus-start)) (dolist (load (get symbol 'custom-loads)) - (cond ((symbolp load) (ignore-errors (require load))) + (cond ((being-loaded-p load)) ; For bug #43116 + ((symbolp load) (ignore-errors (require load))) ;; This is subsumed by the test below, but it's much faster. ((assoc load load-history)) ;; This was just (assoc (locate-library load) load-history) , where `being-loaded-p' would be a new primitive in lread.c which would just scan the static variable Vloads_in_progress with Fmember. Of course, some doc strings would need amendments, too. > Stefan -- Alan Mackenzie (Nuremberg, Germany).