I want a non-global minor mode to be enabled on the Emacs start up. I found it can be done with that code:
(define-globalized-minor-mode my-global-mode
the-mode
(lambda ()
(the-mode t))
)
(my-global-mode t)
But I don't get it. What do two last arguments of the define-globalized-minor-mode
do? the-mode
and a lambda
. More precisely why do I need both, isn't it tautology?
A globalized minor mode is a global minor mode that is created from an existing (non-global) minor mode. Nothing more.
The first arg to define-globalized-minor-mode
is the name (a symbol) of the global minor mode you want to create. The second arg is the existing (non-global) minor mode function (a symbol) that you want to use to create the global one.
The third arg is a function that turns the minor mode on. The minor mode function typically is a toggle command. Invoking it with no args does not turn the mode on.
And some minor modes have a defined (named) separate command to turn them on. E.g., turn-on-visual-line-mode
is a separate command from visual-line-mode
. It is equivalent to (lambda () visual-line-mode 1))
. So you could pass as the third arg either the symbol turn-on-visual-line-mode
or the equivalent lambda form.
That's really all there is to it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With