Why are some global minor modes applicable before package initialize while some are not? e.g. In init file global-linum-mode works but projectile-global-mode doesn't. Why?

Also, why is there no global-helm-mode?

  • 1
    linum-mode is built-in to the standard version of Emacs. Perhaps the others you added to your installation using the package manager?
    – lawlist
    May 25 '16 at 3:37
  • 1
    The Emacs guidelines doesn't allow an arbitrary package to use the global- prefix, as in global-xxx-mode, so xxx-global-mode should be the way to go. On a side note, there are worse examples: electrict-indent-local-mode toggles the normal mode and electric-indent-mode the global -- it hurts me that no one noticed this weird naming when this package was included in Emacs. May 25 '16 at 7:55
  • @lawlist I installed company using the package manager, but it provides you a global-company-mode that you can enable in init.el file. May 25 '16 at 19:00

Your main question isn't really about global modes at all.

global-linum-mode is (auto) loaded in Emacs by default, and so is available to all Emacs users at all times.

projectile-global-mode is in a third-party package you've installed via the package manager, and therefore unavailable until your ELPA packages have been initialized.

Regarding your second question (and please don't post multiple questions together), "why is there no global-helm-mode?" the answer is surely "because no such mode has been written". I suspect you are under a misapprehension that buffer-local minor modes are automatically accompanied by global variants? This is not the case.

Minor modes can be separated into:

  • buffer-local minor modes
  • global minor modes
  • globalized minor modes

(The last type defines a global mode which controls a (pre-defined) buffer-local mode.)

All three types are defined independently. If they're not defined, they don't exist.

  • Thanks for the very descriptive answer. Appreciate it. I am just starting out, so have some basic questions. Just one point about the example I chose for a global minor mode; some other 3rd party minor modes like company also have a global-company-mode, which doesn't require package to be initialized. It is convenient. I can just throw in one line in the init.el file for initializing company globally. I see your point about separation of minor modes. May 25 '16 at 7:05
  • What do you mean by requiring the package to be initialized? I mean, what additional code do you need with projectile that you think is unnecessary for other (not built-in) packages?
    – glucas
    May 25 '16 at 11:52
  • lambdapilgrim: Something else is going on, if packages aren't enabled. If the installation is purely via the package manager, and packages aren't initialised, then Emacs won't have any idea what that function is. Your config might well be circumventing the package manager, though, perhaps adding the path to the load-path and loading the library directly (or defining an autoload). There are lots of options.
    – phils
    May 25 '16 at 22:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.