Dotfiles repository: Switching from per-package Git submodules to ELPA while maintaining portability

孤者浪人 提交于 2019-12-10 10:37:58

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!