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
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.
company
comes with a variable called company-global-modes
. The docstring says:
Modes for which
company-mode
mode is turned on byglobal-company-mode
. Ifnil
, means no modes. Ift
, then all major modes have it turned on. If a list, it should be a list ofmajor-mode
symbol names for whichcompany-mode
should be automatically turned on. The sense of the list is negated if it begins withnot
. For example:
(c-mode c++-mode)
means thatcompany-mode
is turned on for buffers in C and C++ modes only.
(not message-mode)
means thatcompany-mode
is always turned on except inmessage-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))