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-modemode 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-modesymbol names for whichcompany-modeshould be automatically turned on. The sense of the list is negated if it begins withnot. For example:
(c-mode c++-mode)
means thatcompany-modeis turned on for buffers in C and C++ modes only.
(not message-mode)
means thatcompany-modeis always turned on except inmessage-modebuffers.
Customize this variable acc. to your needs. Or in your init file, write something like this:
(setq company-global-modes '(not org-mode))