GNU bug report logs - #11929
24.1.50; Globalized minor mode turn-on function is called twice for each opened file

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Dmitry Gutov <dgutov@HIDDEN>; dated Fri, 13 Jul 2012 04:31:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 11929 <at> debbugs.gnu.org:


Received: (at 11929) by debbugs.gnu.org; 17 Aug 2019 21:59:25 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Aug 17 17:59:25 2019
Received: from localhost ([127.0.0.1]:56977 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1hz6jM-000535-VS
	for submit <at> debbugs.gnu.org; Sat, 17 Aug 2019 17:59:25 -0400
Received: from quimby.gnus.org ([80.91.231.51]:56008)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <larsi@HIDDEN>) id 1hz6jJ-00052t-OD
 for 11929 <at> debbugs.gnu.org; Sat, 17 Aug 2019 17:59:23 -0400
Received: from [50.225.213.182] (helo=sandy)
 by quimby.gnus.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.89) (envelope-from <larsi@HIDDEN>)
 id 1hz6jF-0004LF-TC; Sat, 17 Aug 2019 23:59:20 +0200
From: Lars Ingebrigtsen <larsi@HIDDEN>
To: Dmitry Gutov <dgutov@HIDDEN>
Subject: Re: bug#11929: 24.1.50; Globalized minor mode turn-on function is
 called twice for each opened file
References: <4FFFA314.5030509@HIDDEN>
Date: Sat, 17 Aug 2019 14:59:14 -0700
In-Reply-To: <4FFFA314.5030509@HIDDEN> (Dmitry Gutov's message of "Fri, 13
 Jul 2012 08:24:52 +0400")
Message-ID: <87blwnlah9.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 @@CONTACT_ADDRESS@@ for details.
 Content preview: Dmitry Gutov <dgutov@HIDDEN> writes: > 1. Define the minor
 mode: > > (define-minor-mode foo-mode "" :lighter "") > > (defun
 turn-on-foo-mode
 () > (message "buffer %s major mode %s" (buffer-name) major-mode) > (foo-mode
 1)) > > (define-gl [...] 
 Content analysis details:   (-2.9 points, 5.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -1.0 ALL_TRUSTED            Passed through trusted hosts only via SMTP
 -1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%
 [score: 0.0000]
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 11929
Cc: 11929 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Dmitry Gutov <dgutov@HIDDEN> writes:

> 1. Define the minor mode:
>
> (define-minor-mode foo-mode "" :lighter "")
>
> (defun turn-on-foo-mode ()
>   (message "buffer %s major mode %s" (buffer-name) major-mode)
>   (foo-mode 1))
>
> (define-globalized-minor-mode global-foo-mode foo-mode turn-on-foo-mode)
>
> 2. Turn on the global mode.
>
> 3. Open any file, look at the *Messages* buffer.
> It will contain something like this:
>
> buffer init.el major mode fundamental-mode
> buffer init.el major mode emacs-lisp-mode
>
> If the buffer is going to be immediately switched to another mode,
> there's no point in calling the turn-on function in the default mode.
> I think this behavior is buggy.

If I understand you correctly, you don't think that buffers should first
be opened in `fundamental-mode', and then the "real" major mode, because
this means that globalised minor modes get switched on twice?

I agree that this seems like surprising behaviour, but I think it's been
this way since forever, so perhaps it should just be documented?  I'm
not sure where, though...  in the `define-globalized-minor-mode' doc
string, perhaps?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#11929; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 13 Jul 2012 04:30:33 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Jul 13 00:30:33 2012
Received: from localhost ([127.0.0.1]:38003 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1SpXWT-0008QV-1F
	for submit <at> debbugs.gnu.org; Fri, 13 Jul 2012 00:30:33 -0400
Received: from eggs.gnu.org ([208.118.235.92]:44417)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <dgutov@HIDDEN>) id 1SpXWR-0008QN-2c
	for submit <at> debbugs.gnu.org; Fri, 13 Jul 2012 00:30:31 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <dgutov@HIDDEN>) id 1SpXR0-0001wn-P2
	for submit <at> debbugs.gnu.org; Fri, 13 Jul 2012 00:24:55 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,
	RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.2
Received: from lists.gnu.org ([208.118.235.17]:48669)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <dgutov@HIDDEN>) id 1SpXR0-0001we-LZ
	for submit <at> debbugs.gnu.org; Fri, 13 Jul 2012 00:24:54 -0400
Received: from eggs.gnu.org ([208.118.235.92]:54027)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <dgutov@HIDDEN>) id 1SpXQz-0003I9-LZ
	for bug-gnu-emacs@HIDDEN; Fri, 13 Jul 2012 00:24:54 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <dgutov@HIDDEN>) id 1SpXQy-0001wJ-El
	for bug-gnu-emacs@HIDDEN; Fri, 13 Jul 2012 00:24:53 -0400
Received: from forward2.mail.yandex.net ([77.88.46.7]:40180)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <dgutov@HIDDEN>) id 1SpXQy-0001wD-2A
	for bug-gnu-emacs@HIDDEN; Fri, 13 Jul 2012 00:24:52 -0400
Received: from smtp2.mail.yandex.net (smtp2.mail.yandex.net [77.88.46.102])
	by forward2.mail.yandex.net (Yandex) with ESMTP id 8F9DD12A3E8F
	for <bug-gnu-emacs@HIDDEN>; Fri, 13 Jul 2012 08:24:50 +0400 (MSK)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail;
	t=1342153490; bh=yP8QMO/MCMR+LRGwNVAcDNp5A7Ost0WKd/84apNgvBU=;
	h=Message-ID:Date:From:MIME-Version:To:Subject:Content-Type:
	Content-Transfer-Encoding;
	b=QmUK0pqSTq7YQdG0C37ZMoytGRW0mhopPL9M3LMVbWWfFnmT3fT2Cdnfl5YPlTdEm
	uEWb+OV25qOXi4IKlic3qFppS3H93szuSqbh0L60Xe6n73kujofSH6AWsEG0W1OW9B
	wzH0qoBEkgol5NIwYsefck9Xp0+dwVzu89yE8Djc=
Received: from smtp2.mail.yandex.net (localhost [127.0.0.1])
	by smtp2.mail.yandex.net (Yandex) with ESMTP id 7D117E2031C
	for <bug-gnu-emacs@HIDDEN>; Fri, 13 Jul 2012 08:24:50 +0400 (MSK)
Received: from 98-87.nwlink.spb.ru (98-87.nwlink.spb.ru [178.252.98.87])
	by smtp2.mail.yandex.net (nwsmtp/Yandex) with ESMTP id
	OnY4kZwL-OoYeOOrX; Fri, 13 Jul 2012 08:24:50 +0400
X-Yandex-Rcpt-Suid: bug-gnu-emacs@HIDDEN
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail;
	t=1342153490; bh=yP8QMO/MCMR+LRGwNVAcDNp5A7Ost0WKd/84apNgvBU=;
	h=Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:
	Content-Type:Content-Transfer-Encoding;
	b=lfD3YIePGZRqVjPQu4nV9uIdqkQftin2P+a1Pr61cbr7oNtAMrvwFaxHIomZcioEP
	7qy8JfrZ79S6bSCmRN1v8zmNIYPinBT2scd04A09HU8arSb2iFJkyLGDTPHKTozcTk
	WbFryPVgQJdCAjIZ3d3lZTdqO0n+BoHOkyjKSoSY=
Message-ID: <4FFFA314.5030509@HIDDEN>
Date: Fri, 13 Jul 2012 08:24:52 +0400
From: Dmitry Gutov <dgutov@HIDDEN>
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64;
	rv:13.0) Gecko/20120614 Thunderbird/13.0.1
MIME-Version: 1.0
To: bug-gnu-emacs@HIDDEN
Subject: 24.1.50; Globalized minor mode turn-on function is called twice for
	each opened file
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3)
X-Received-From: 208.118.235.17
X-Spam-Score: -6.2 (------)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.13
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -6.2 (------)

I raised the topic on help-gnu-emacs previously, but hadn't received an
answer: 
http://lists.gnu.org/archive/html/help-gnu-emacs/2012-07/msg00174.html

How to reproduce.

1. Define the minor mode:

(define-minor-mode foo-mode "" :lighter "")

(defun turn-on-foo-mode ()
   (message "buffer %s major mode %s" (buffer-name) major-mode)
   (foo-mode 1))

(define-globalized-minor-mode global-foo-mode foo-mode turn-on-foo-mode)

2. Turn on the global mode.

3. Open any file, look at the *Messages* buffer.
It will contain something like this:

buffer init.el major mode fundamental-mode
buffer init.el major mode emacs-lisp-mode

If the buffer is going to be immediately switched to another mode,
there's no point in calling the turn-on function in the default mode.
I think this behavior is buggy.

--Dmitry

In GNU Emacs 24.1.50.1 (i386-mingw-nt6.1.7601)
  of 2012-07-11 on SOL
Windowing system distributor `Microsoft Corp.', version 6.1.7601
Configured using:
  `configure --with-gcc (3.4) --cflags -IH:/Apps/System/gnuwin32/include'

Important settings:
   value of $EMACSDATA: C:/Users/gutov/vc/emacs-master/etc
   value of $EMACSDOC: C:/Users/gutov/vc/emacs-master/etc
   value of $EMACSLOADPATH: 
C:/Users/gutov/vc/emacs-master/site-lisp;C:/Users/gutov/vc/emacs-master/../site-lisp;C:/Users/gutov/vc/emacs-master/lisp;C:/Users/gutov/vc/emacs-master/leim
   value of $EMACSPATH: C:/Users/gutov/vc/emacs-master/bin
   value of $LANG: RU
   locale-coding-system: cp1251
   default enable-multibyte-characters: t




Acknowledgement sent to Dmitry Gutov <dgutov@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#11929; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 25 Nov 2019 12:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.