Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the arguments for define-globalized-minor-mode in Emacs

Tags:

emacs

elisp

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?

like image 890
Gherman Avatar asked Nov 10 '22 13:11

Gherman


1 Answers

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-modeor the equivalent lambda form.

That's really all there is to it.

like image 149
Drew Avatar answered Nov 15 '22 11:11

Drew