From e8fb1ec1881ee2767b282d62a35f953a295ccbfa Mon Sep 17 00:00:00 2001 From: Andrew Judson Date: Tue, 7 Jul 2015 15:33:42 -0700 Subject: [PATCH] Added auto installation for packages in Emacs --- dotfiles/.emacs.d/init.el | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/dotfiles/.emacs.d/init.el b/dotfiles/.emacs.d/init.el index 296126e..67531ba 100644 --- a/dotfiles/.emacs.d/init.el +++ b/dotfiles/.emacs.d/init.el @@ -4,6 +4,43 @@ ("melpa" . "http://melpa.org/packages/"))) (package-initialize) +(setq my-packages + (set-difference + '(bracketed-paste + cider + clojure-mode + csv-mode + expand-region + flycheck + jedi + magit + multiterm + zenburn-theme + ) + '(melpa) + ) + ) + +(defun my-packages-installed-p () + (loop for p in my-packages + when (not (package-installed-p p)) do (return nil) + finally (return t))) + +(when (and ;;(not (getenv "http_proxy")) might not be necessary in most situations, can readd + (not (my-packages-installed-p))) + ;; check for new packages (package versions) + (message "%s" "Emacs is now refreshing its package database...") + (package-refresh-contents) + (message "%s" " done.") + ;; install the missing packages + (dolist (p my-packages) + (when (not (package-installed-p p)) + (condition-case nil + (package-install p) + (error (message "%s not installable" p)))))) +;; TODO: add autoinstallation of necessary Pip modules for Python modes + +;; (require 'multi-term) ;; copy paste into terminal easier (require 'bracketed-paste) @@ -15,6 +52,7 @@ (require 'magit) (require 'csv-mode) (require 'clojure-mode) +(require 'cider) (require 'flycheck) (add-hook 'after-init-hook #'global-flycheck-mode) ;;python related stuff