Recently I have discovered tabnine, a really good completion backend. I wanted to use it in emacs. So I went through the installation procedure and now I have it. But when I M-x company-diag, it shows me that I am using company-yasnippet in major mode python. I want to use tabnine instead. How do I do that?

Emacs 27.1 (x86_64-pc-linux-gnu) of 2020-08-28 on juergen
Company 0.9.13

company-backends: ((company-anaconda)
 company-capf company-yasnippet company-tabnine)

Used backend: company-yasnippet
Major mode: python-mode

This is company-diag.

1 Answer 1


A few things.

  1. company decides its backend based on the variable company-backends. If you want a specific auto-completion backend, you must specify it in your init.el file.

In general, you can read documentation on variables by using M-x apropos-variable.

  1. To add a backend to company, call (add-to-list 'company-backends '(<backend name>))

For example, to add Elisp completion, there is a backend called company-elisp that comes with company.

To use this, you run (add-to-list 'company-backend '(company-elisp)).

This will add company-elisp to the list of backends that company decides to use.

  1. Company runs through its list of backends in company-backends and performs a test to see if it should run a given backend for your current mode.

The first to pass the test is used. All others are ignored.

Now, looking at company-anaconda, it recommends:

(eval-after-load "company"
  '(add-to-list 'company-backends 'company-anaconda))

or, if you want both company-anaconda and company-capf together:

(eval-after-load "company"
 '(add-to-list 'company-backends '(company-anaconda :with company-capf)))

Finally, you must add: (add-hook 'python-mode-hook 'anaconda-mode)

Looking at the source code for company-anaconda reveals that you must enable anaconda-mode for company to choose the company-anaconda backend.

  • I like your idea, which helps me to solve a problem in emacs-lisp-mode (when writing comments in this mode, the company always pop up.)
    – yanpengl
    Commented Nov 23, 2022 at 15:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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