4

I would like company mode to lead automatically for some buffers like AucTex for example but not on other buffers like Org-mode

global-company-mode 

Enables comapny mode everywhere and I only want to set it locally

user22187
  • 41
  • 2

2 Answers2

4

If you want to use company-mode in a few major modes, use a hook.

;; turn on company mode for all modes derived from prog-mode, and cmake-mode
(add-hook 'prog-mode-hook 'company-mode)
(add-hook 'cmake-mode-hook 'company-mode)

If you want to disable company-mode in a few major modes, use a hook.

;; enable company-mode everywhere except text-mode and cmake-mode
(add-hook 'after-init-hook 'global-company-mode)
(add-hook 'text-mode-hook (company-mode -1))
(add-hook 'cmake-mode-hook (company-mode -1))

Check your major mode's documentation for the exact name of its hook.

nega
  • 3,091
  • 15
  • 21
2

company comes with a variable called company-global-modes. The docstring says:

Modes for which company-mode mode is turned on by global-company-mode. If nil, means no modes. If t, then all major modes have it turned on. If a list, it should be a list of major-mode symbol names for which company-mode should be automatically turned on. The sense of the list is negated if it begins with not. For example:
(c-mode c++-mode)
means that company-mode is turned on for buffers in C and C++ modes only.
(not message-mode)
means that company-mode is always turned on except in message-mode buffers.

Customize this variable acc. to your needs. Or in your init file, write something like this:

(setq company-global-modes '(not org-mode))
Arash Esbati
  • 1,795
  • 1
  • 8
  • 13