3

I want to install the company mode, but searching in the M-x list-packages i find no company mode found, but a bunch of company backends for different languages. How should i install company? PS: This is my init.el file beginning:

(require 'package) 

(add-to-list 'package-archives
             '("melpa" . "https://melpa.org/packages/") t)
(add-to-list 'package-archives
             '("melpa-stable" . "https://stable.melpa.org/packages/") t)
;; elpy
(add-to-list 'package-archives
         '("elpy" . "http://jorgenschaefer.github.io/packages/") t)
(when (< emacs-major-version 24)
  ;; For important compatibility libraries like cl-lib
  (add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/")))

(package-initialize) 
8
  • company-mode should be part of GNU Emacs, i.e. there is no need to install it separately. What version of Emacs are you using (M-x emacs-version)? Jan 23, 2017 at 21:27
  • I have Emacs 24.4.1. So it suffices to add (add-hook 'after-init-hook 'global-company-mode) to the init.el file?
    – user12021
    Jan 23, 2017 at 21:43
  • 1
    Yes, that should work. Also consider using the sharp quote (#') for functions like global-company-mode. Jan 23, 2017 at 22:23
  • 1
    "company-mode should be part of GNU Emacs" No, it isn't.
    – Dmitry
    Jan 23, 2017 at 22:25
  • 1
    @TianxiangXiong Company is available from ELPA, which is the official package repository and is enabled by default. The license text is required as part of submitting to ELPA. It is still necessary to actually install the package to use it.
    – glucas
    Jan 24, 2017 at 2:00

2 Answers 2

3

The bit of configuration you provided does not actually evaluate, so I suspect your package list is not configured correctly. (Try it: copy your add-to-list code above in to a scratch buffer and then call M-x eval-buffer to see the error.)

Use C-h v package-archives to check the value. Or try the Customize interface, with: M-x customize-option package-archives.

Note that company is not part of the standard Emacs distribution and must be installed. However, it is available in the GNU ELPA repository, which should already be configured in the default package-archives. So you should be able to start Emacs without any custom configuration and use package-install to install it.

See: https://elpa.gnu.org/packages/company.html

2
  • 1
    I tried to install company with package-install, there are only company-backends as choice. I cannot see any company to install
    – user12021
    Jan 26, 2017 at 19:58
  • Did you try removing your package archives configuration or checking what the actual value is? As I noted one can start a clean installation of Emacs with no customization and install as described, so there must be a non-default configuration here that is causing problems.
    – glucas
    Jan 26, 2017 at 20:01
2

'package-archives is a list of dotted pairs. So your code should be:

(setq package-archives
      '(("elpy" . "http://jorgenschaefer.github.io/packages/")
        ("melpa" . "https://melpa.org/packages/")
        ("gnu" . "http://elpa.gnu.org/packages/")
        ("melpa-stable" . "https://stable.melpa.org/packages/")))

Your Answer

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