When setting up your .emacs to automatically add company-anaconda to your company-backends list, eval-after-load is your friend:
;;; Company, and Company backends. (add-hook 'after-init-hook 'global-company-mode) (eval-after-load 'company (progn '(add-to-list 'company-backends 'company-anaconda) ))
8 thoughts on “Emacs company-mode and company-anaconda”
You don’t need the progn in this simple example. You do need it when you want to evaluate multiple forms after the library is loaded, and, in that case, the progn form has itself to be quoted.
You don’t need the `progn` in this case. You only need it, or something that implicitly has it, when you want to evaluate multiple forms after `company` is loaded. And, in that case, the `progn` form has to be quoted. Also, to make this idiomatic elisp, don’t put newlines between closing parenthesis.s
You don’t need the (misleading) progn wrapper. But if you DID need it (because you wanted to perform multiple actions after loading), you would quote the progn, and not the expression(s) inside it.
@joaotavora and @Phil:
Thank you for the corrections! You’ve shamed me into deciding to dive into my Emacs Lisp books! 🙂 That’s my goal for today.
(I used the progn because I anticipate adding more company backends.)
Here’s version 2, using with-eval-after-load, which was added in Emacs Lisp version 24.4:
But then you don’t need the progn at all, since `with-eval-after-load` accepts &rest body
(with-eval-after-load FILE &rest BODY)
Execute BODY after FILE is loaded.
Arg! I can’t make any more errors in such a short code fragment, can I? 🙂
And this tiny code becomes just this: