Question

I'm interested in standardizing the emacs configurations that a few of us use (~5 people).

Is there a way to install ELPA packages from lisp functions that can be included in a script if we know the set of packages we want? All I can find is how to call up list-packages and install individual packages graphically.

Was it helpful?

Solution

What you need is to use package-install function, like:

(mapc 'package-install install-list)

the install-list variable should contain a list of names of packages that you want to install.

OTHER TIPS

Another thing you can do it make your own package that depends on the other packages that you want installed. Then install that package.

Packages can be installed from file with:

M-x package-install-from-file

or you can make your own package archive with the package in, you can use elpakit to do that.

You can also do this from the command line:

emacs -e "(progn (package-initialize)(package-install 'packagename))"

to install from the operating system command line if you wish.

You may also want to take a look at cask. It allows you to declare the packages you want to install in file named Cask using a DSL described here. Then from the command line go to the directory and run cask. It will install all the packages declared in the Cask file.

In you init file you will need to add the following lines to use the packages installed by cask.

(require 'cask "~/.cask/cask.el")
(cask-initialize)

In addition you can get the list of already installed ELPA packages by

(defun eab/print-0 (body)
  "Insert value of body in current-buffer."
  (let ((print-length nil)
        (eval-expression-print-length nil))
    (prin1 `,body (current-buffer))))

(defun eab/package-installed ()
  "Get the list of ELPA installed packages."
  (mapcar (lambda (x) (car x)) package-alist))

(eab/print-0 (eab/package-installed))

and the same for el-get packages

(defun eab/el-get-installed ()
  "Get the list of el-get installed packages."
  (mapcar 'intern
      (el-get-list-package-names-with-status "installed")))

(eab/print-0 (eab/el-get-installed))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top