0

I want to be able to enable and disable global-company-mode by calling elisp functions in my init file.

Could I use (global-company-mode 1) to enable and (global-company-mode -1) to disable

Does this mean that I can do (global-company-mode 1) and (global-company-mode -1) without using the hook way (add-hook 'after-init-hook 'global-company-mode).

8
  • Yes, you can avoid the hook. Aug 2 at 14:35
  • global-company-mode is just a normal elisp function, am I right?
    – Ephram
    Aug 2 at 14:39
  • Yes, you should be able to invoke (global-company-mode 1) from Elisp. Aug 2 at 14:46
  • You would generally NOT invoke a global minor mode from a hook. A global minor mode is designed to turn on the corresponding minor mode globally. There is no point doing that from a hook: hooks are designed to enable minor modes (and other things) selectively, e.g. by turning it on for all buffers of a particular major mode.
    – NickD
    Aug 2 at 15:09
  • company-mode should be revisited because the documentation of company states that to have company-mode in all buffers, the following must be added to your init file: (add-hook 'after-init-hook 'global-company-mode).
    – Ephram
    Aug 2 at 15:47

0

Your Answer

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

Browse other questions tagged or ask your own question.