GNU bug report logs - #21507
25.0.50: (global-SOME-MINOR-MODE) not affecting fundamental mode buffers

Previous Next

Package: emacs;

Reported by: Kaushal Modi <kaushal.modi <at> gmail.com>

Date: Thu, 17 Sep 2015 16:17:02 UTC

Severity: minor

Found in version 25.0.50

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 21507 in the body.
You can then email your comments to 21507 AT debbugs.gnu.org in the normal way.

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#21507; Package emacs. (Thu, 17 Sep 2015 16:17:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Kaushal Modi <kaushal.modi <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 17 Sep 2015 16:17:02 GMT) Full text and rfc822 format available.

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

From: Kaushal Modi <kaushal.modi <at> gmail.com>
To: "bug-gnu-emacs <at> gnu.org" <bug-gnu-emacs <at> gnu.org>
Cc: Drew Adams <drew.adams <at> oracle.com>
Subject: 25.0.50: (global-SOME-MINOR-MODE) not affecting fundamental mode
 buffers
Date: Thu, 17 Sep 2015 12:15:46 -0400
[Message part 1 (text/plain, inline)]
Hi,

I recently was debugging an issue with my globalized minor mode and auto
generated Fundamental mode buffers created by different pacakages. I
brought up that problem over at emacs.SE:
http://emacs.stackexchange.com/q/16693/115

The below code summarizes what I learnt. The code can be eval'ed in an
emacs -Q session to recreate the issue I am seeing.

Please review the below code, eval and run it and proceed with my
explanation after the code.

;; my1-mode - init value nil - enabled using its global variant
(define-minor-mode my1-mode
  :init-value nil
  :lighter " my1")
(defun turn-on-my1-mode () (my1-mode 1))
(define-globalized-minor-mode global-my1-mode my1-mode turn-on-my1-mode)
(global-my1-mode)

;; my2-mode - init value nil - enabled using setq-default
(define-minor-mode my2-mode
  :init-value nil
  :lighter " my2")
(defun turn-on-my2-mode () (my2-mode 1))
(define-globalized-minor-mode global-my2-mode my2-mode turn-on-my2-mode)
(setq-default my2-mode t)

;; my3-mode - init value t (so enabled by default)
(define-minor-mode my3-mode
  :init-value t
  :lighter " my3")

;; Now call `get-buffer-create' that creates a buffer with Fundamental
major mode
(with-current-buffer (get-buffer-create "*temp*")
  (insert "Hello"))
(split-window-right)
(switch-to-buffer "*temp*")


---

My minor mode is of the type my1-mode above where the init value is nil but
I enable it in my config using (global-my1-mode).

The global enabling of my1-mode is seen everywhere, all the newly created
buffers except for the cases where a package would create some sort of temp
buffer using `get-buffer-create'. Such buffers would be in Fundamental mode
by default and I noticed that the (global-my1-mode) had no effect on those
buffers.

If I tweak my minor mode to be of my2-mode (change the init value to t)or
my3-mode (force the init value to t using setq-default) types above, then
my minor mode gets enabled globally in true sense (even in buffers created
using get-create-buffer).

In essence, setting the init value as t is not the same as enabling a
globalized minor mode.

Is this by design?



--
Kaushal Modi
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21507; Package emacs. (Mon, 28 Dec 2020 00:29:01 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Kaushal Modi <kaushal.modi <at> gmail.com>
Cc: 21507 <at> debbugs.gnu.org, Drew Adams <drew.adams <at> oracle.com>
Subject: Re: bug#21507: 25.0.50: (global-SOME-MINOR-MODE) not affecting
 fundamental mode buffers
Date: Mon, 28 Dec 2020 01:28:44 +0100
Kaushal Modi <kaushal.modi <at> gmail.com> writes:

> Please review the below code, eval and run it and proceed with my explanation
> after the code.

It had to be adjusted a bit:

;; my1-mode - init value nil - enabled using its global variant
(define-minor-mode my1-mode
  ""
  :init-value nil
  :lighter " my1")
(defun turn-on-my1-mode () (my1-mode 1))
(define-globalized-minor-mode global-my1-mode my1-mode turn-on-my1-mode)
(global-my1-mode)

;; my2-mode - init value nil - enabled using setq-default
(define-minor-mode my2-mode
  ""
  :init-value nil
  :lighter " my2")
(defun turn-on-my2-mode () (my2-mode 1))
(define-globalized-minor-mode global-my2-mode my2-mode turn-on-my2-mode)
(setq-default my2-mode t)

;; my3-mode - init value t (so enabled by default)
(define-minor-mode my3-mode
  ""
  :init-value t
  :lighter " my3")

> My minor mode is of the type my1-mode above where the init value is
> nil but I enable it in my config using (global-my1-mode).
>
> The global enabling of my1-mode is seen everywhere, all the newly
> created buffers except for the cases where a package would create some
> sort of temp buffer using `get-buffer-create'. Such buffers would be
> in Fundamental mode by default and I noticed that the
> (global-my1-mode) had no effect on those buffers.

I'm still seeing this behaviour in Emacs 28.

> If I tweak my minor mode to be of my2-mode (change the init value to
> t)or my3-mode (force the init value to t using setq-default) types
> above, then my minor mode gets enabled globally in true sense (even in
> buffers created using get-create-buffer).
>
> In essence, setting the init value as t is not the same as enabling a
> globalized minor mode.
>
> Is this by design? 

Anybody know?

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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21507; Package emacs. (Wed, 26 May 2021 22:34:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Kaushal Modi <kaushal.modi <at> gmail.com>
Cc: 21507 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>,
 Drew Adams <drew.adams <at> oracle.com>
Subject: Re: bug#21507: 25.0.50: (global-SOME-MINOR-MODE) not affecting
 fundamental mode buffers
Date: Thu, 27 May 2021 00:33:10 +0200
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

>> If I tweak my minor mode to be of my2-mode (change the init value to
>> t)or my3-mode (force the init value to t using setq-default) types
>> above, then my minor mode gets enabled globally in true sense (even in
>> buffers created using get-create-buffer).
>>
>> In essence, setting the init value as t is not the same as enabling a
>> globalized minor mode.
>>
>> Is this by design? 
>
> Anybody know?

Perhaps Stefan does; added to the CCs.

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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21507; Package emacs. (Wed, 26 May 2021 22:42:01 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 21507 <at> debbugs.gnu.org, Drew Adams <drew.adams <at> oracle.com>,
 Kaushal Modi <kaushal.modi <at> gmail.com>
Subject: Re: bug#21507: 25.0.50: (global-SOME-MINOR-MODE) not affecting
 fundamental mode buffers
Date: Wed, 26 May 2021 18:41:07 -0400
Lars Ingebrigtsen [2021-05-27 00:33:10] wrote:
> Lars Ingebrigtsen <larsi <at> gnus.org> writes:
>>> If I tweak my minor mode to be of my2-mode (change the init value to
>>> t)or my3-mode (force the init value to t using setq-default) types
>>> above, then my minor mode gets enabled globally in true sense (even in
>>> buffers created using get-create-buffer).
>>>
>>> In essence, setting the init value as t is not the same as enabling a
>>> globalized minor mode.
>>>
>>> Is this by design? 
>> Anybody know?
> Perhaps Stefan does; added to the CCs.

Maybe I misunderstand the question, but a minor mode is defined by
a function that can used to turn it ON/OFF and a variable that lets you
know where it's ON or OFF.

Setting the var directly rather than via the minor mode function just
breaks the abstraction and its behavior is thus "defined by
implementation" and subject to change.

Similarly `:init-value` is used to tell Emacs what is the initial state,
rather than to set this initial state.


        Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21507; Package emacs. (Thu, 27 May 2021 23:38:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 21507 <at> debbugs.gnu.org, Drew Adams <drew.adams <at> oracle.com>,
 Kaushal Modi <kaushal.modi <at> gmail.com>
Subject: Re: bug#21507: 25.0.50: (global-SOME-MINOR-MODE) not affecting
 fundamental mode buffers
Date: Fri, 28 May 2021 01:37:32 +0200
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

> Setting the var directly rather than via the minor mode function just
> breaks the abstraction and its behavior is thus "defined by
> implementation" and subject to change.

Yes, indeed.  So this is working as it should, and I'm closing this bug
report.

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




bug closed, send any further explanations to 21507 <at> debbugs.gnu.org and Kaushal Modi <kaushal.modi <at> gmail.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Thu, 27 May 2021 23:38:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 25 Jun 2021 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 298 days ago.

Previous Next


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