bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#11929: 24.1.50; Globalized minor mode turn-on function is called twi


From: Lars Ingebrigtsen
Subject: 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
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Dmitry Gutov <dgutov@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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]