I am using Emacs 28.2. Here is my code:
;;; foo.el
(define-minor-mode foo-mode
"Foo mode"
:lighter " Foo"
(message "foo-mode %s in buffer %s" foo-mode (buffer-name)))
(defun foo-mode-on ()
(foo-mode 1))
(define-globalized-minor-mode global-foo-mode foo-mode foo-mode-on)
This works like I want.
emacs -q -l foo.el
Then I run these things:
C-x b *scratch*
M-x global-foo-mode
C-x b foo
C-x b bar
C-x b baz
I find that all buffers foo
, bar
and baz
have Foo mode enabled. But https://www.gnu.org/software/emacs/manual/html_node/elisp/Defining-Minor-Modes.html has got this to tell
Globally enabling the mode also affects buffers subsequently created by visiting files, and buffers that use a major mode other than Fundamental mode; but it does not detect the creation of a new buffer in Fundamental mode.
But in my case, it did work for fundamental mode buffers too. Why did it work when the documentation says it should not have worked? Or the documentation does not say that and I am misunderstanding something?