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.bugs Subject: bug#43116: 27.1; with-eval-after-load executes BODY multiple times for fortran Date: 31 Aug 2020 11:34:28 -0000 Organization: muc.de e.V. Message-ID: <20200831113428.96126.qmail@mail.muc.de> References: <6a275221-6158-8b3e-648b-ceb0116a71b6@posteo.net> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31267"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: tin/2.4.4-20191224 ("Millburn") (FreeBSD/11.3-RELEASE-p9 (amd64)) Cc: acm@muc.de, 43116@debbugs.gnu.org To: Nonax Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Aug 31 13:35:10 2020 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 1kCi5e-00082g-92 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 31 Aug 2020 13:35:10 +0200 Original-Received: from localhost ([::1]:54036 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kCi5d-0001kB-7V for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 31 Aug 2020 07:35:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54226) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kCi5W-0001iY-76 for bug-gnu-emacs@gnu.org; Mon, 31 Aug 2020 07:35:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:40182) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kCi5V-00045S-UM for bug-gnu-emacs@gnu.org; Mon, 31 Aug 2020 07:35:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kCi5V-0003vc-Nx for bug-gnu-emacs@gnu.org; Mon, 31 Aug 2020 07:35:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 31 Aug 2020 11:35:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43116 X-GNU-PR-Package: emacs Original-Received: via spool by 43116-submit@debbugs.gnu.org id=B43116.159887367915069 (code B ref 43116); Mon, 31 Aug 2020 11:35:01 +0000 Original-Received: (at 43116) by debbugs.gnu.org; 31 Aug 2020 11:34:39 +0000 Original-Received: from localhost ([127.0.0.1]:51728 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kCi59-0003uz-7k for submit@debbugs.gnu.org; Mon, 31 Aug 2020 07:34:39 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:27604 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1kCi54-0003ui-PB for 43116@debbugs.gnu.org; Mon, 31 Aug 2020 07:34:37 -0400 Original-Received: (qmail 96127 invoked by uid 3782); 31 Aug 2020 11:34:28 -0000 In-Reply-To: X-Newsgroups: gnu.emacs.bug 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" Xref: news.gmane.io gmane.emacs.bugs:186760 Archived-At: Hello, Nonax. In article you wrote: > Hello, > The following command will reproduce the bug: emacs -Q -l mwe.el f.f > f.f does not have to exist, it just serves to open a buffer and enable > fortran-mode. The file mwe.el contains the following: > (with-eval-after-load 'fortran > (if (boundp 'fortran-canary) > (message "..is cursed.") > (message "FORTRAN..")) > (defvar fortran-canary t)) > ;;; end of mwe.el > The following message will appear in the *Message* buffer: > FORTRAN.. > ..is cursed. > suggesting BODY has been executed twice. This problem seems to persist > across multiple versions of Emacs. It seems to only apply to fortran > specifically, however. I could not reproduce it with other features. > Kind regards, > N. > In GNU Emacs 27.1 (build 1, x86_64-redhat-linux-gnu, GTK+ Version > 3.24.21, cairo version 1.16.0) > of 2020-08-20 built on buildvm-x86-24.iad2.fedoraproject.org > Windowing system distributor 'Fedora Project', version 11.0.12008000 > System Description: Fedora 32 (Workstation Edition) [ .... ] Diagnosis: 1. At a fairly low level, (load "fortran") gets called. 2. In fortran.el L658 in (defvar fortran-mode-map ....) there's a form ,(custom-menu-create 'fortran). This gets evaluated during the load. 3. custom-menu-create's call stack (pertinent part) looks like: (do-after-load-evaluation "path/to/fortran.elc") (require 'fortran) <========================================= (custom-load-symbol 'fortran) (custom-menu-create 'fortran) 4. The above do-after-load-evaluation eventually calls the fortran eval-after-load function that outputs "FORTRAN..". 5. At a later stage of the load, do-after-load-evaluation gets called by load normally. This calls the eval-after-load function again, which outputs "..is cursed.". In a nutshell, the problem is the recursive (require 'fortran) called from within (load "fortran"). I don't yet have any idea on how to fix this bug. -- Alan Mackenzie (Nuremberg, Germany).