问题
I've been using Git submodules within my dotfiles repository to track each Emacs package that I use. With a package manager being built-in with Emacs 24, though, I'd like to switch to the more official and easier-to-use method.
My problem with switching: With my current Git submodule method, any clone of the dotfiles repository is guaranteed to contain all the referenced add-ons. Is there a built-in functionality within this package manager to allow synchronization of packages, so that any pull of the Git repo will contain the necessary packages (or have them all installable with a single command)?
If there's nothing like this built-in, is there a "post-package-install" hook that I can use to maintain a text-based list of packages (later readable with a custom command which installs the packages in the list)? Essentially I would like to keep my packages / package list under version control so that it is portable between computers.
回答1:
I tried el-get
by kindahero's suggestion, but this didn't work out too well for me.. it didn't load correctly — either by some bug in the code or by my lack of skill in Emacs Lisp (more likely the latter).
I stumbled upon the Emacs Prelude project, and found a very simple snippet of code while browsing through the source:
(require 'package)
(add-to-list 'package-archives
'("marmalade" . "http://marmalade-repo.org/packages/") t)
(package-initialize)
(when (not package-archive-contents)
(package-refresh-contents))
(defvar prelude-packages
'(auctex clojure-mode coffee-mode deft gist haml-mode
haskell-mode magit markdown-mode paredit projectile
sass-mode scss-mode yaml-mode yari yasnippet)
"A list of packages to ensure are installed at launch.")
(dolist (p prelude-packages)
(when (not (package-installed-p p))
(package-install p)))
I shamelessly stole this for my own purposes, and it has been working great. I deleted almost all of my submodules by switching to the package manager (with the Marmalade repo).
来源:https://stackoverflow.com/questions/7302771/dotfiles-repository-switching-from-per-package-git-submodules-to-elpa-while-mai