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

Previous Next

Package: emacs;

Reported by: Dmitry Gutov <dgutov <at> yandex.ru>

Date: Fri, 13 Jul 2012 04:31:01 UTC

Severity: minor

Found in version 24.1.50

To reply to this bug, email your comments to 11929 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#11929; Package emacs. (Fri, 13 Jul 2012 04:31:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Dmitry Gutov <dgutov <at> yandex.ru>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 13 Jul 2012 04:31:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.1.50; Globalized minor mode turn-on function is called twice for
	each opened file
Date: Fri, 13 Jul 2012 08:24:52 +0400
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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11929; Package emacs. (Sat, 17 Aug 2019 22:00:02 GMT) Full text and rfc822 format available.

Message #8 received at 11929 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: 11929 <at> debbugs.gnu.org
Subject: Re: bug#11929: 24.1.50; Globalized minor mode turn-on function is
 called twice for each opened file
Date: Sat, 17 Aug 2019 14:59:14 -0700
Dmitry Gutov <dgutov <at> yandex.ru> 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




Severity set to 'minor' from 'normal' Request was from Stefan Kangas <stefankangas <at> gmail.com> to control <at> debbugs.gnu.org. (Wed, 10 Jan 2024 11:37:02 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 154 days ago.

Previous Next


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