Switching To ELPA

| 分类 Emacs  | 标签 emacs  elpa 

I used to use submodule of git to pull emacs modules, and today, I decided to switch to ELPA. The main reason is: I don't want to keep track of changes of those modules.

It is really easy and convenient to use elpa, adding following lines into ~/.emacs:

 1: (defvar yc/packages
 2:   (list 'ac-helm 'edit-server 'flycheck 'magit 'yasnippet 'js3-mode 'autopair 'cmake-mode)
 3:   "List of needed packages.")
 4: 
 5: (defun yc/install-packages ()
 6:   "Install all packages."
 7:   (interactive)
 8:   (package-refresh-contents)
 9:   (mapc
10:    (lambda (p)
11:      (unless (package-installed-p p)
12:        (message "Installing %s" (symbol-name p))
13:        (package-install p)))
14:    yc/packages)
15:   (message "All packages installed..."))
16: 
17: (defun yc/all-packages-available-p ()
18:   "Check if all modules are available or not."
19:   (interactive)
20:   (let ((r t))
21:     (dolist (p yc/packages)
22:       (setq r (and r (package-installed-p p))))
23:     r))
24: 
25: (unless (yc/all-packages-available-p)
26:   (message "Trying to install missing modules...")
27:   (yc/install-packages))

Whenever emacs starts, it will check if all needed packages are installed. And it will try to install them if necessary.

This makes it is easier to port my emacs configurations into different machines.


上一篇     下一篇