aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/init-elpa.el
diff options
context:
space:
mode:
authorJesús <heckyel@hyperbola.info>2018-07-29 20:12:28 -0500
committerJesús <heckyel@hyperbola.info>2018-07-29 20:12:28 -0500
commitd172fb6e48fe4e342f0d94eade1b108bed91cc00 (patch)
tree032559458aeda1cf45e9fc0f6561d742237b5b03 /lisp/init-elpa.el
downloademacs-personal-d172fb6e48fe4e342f0d94eade1b108bed91cc00.tar.lz
emacs-personal-d172fb6e48fe4e342f0d94eade1b108bed91cc00.tar.xz
emacs-personal-d172fb6e48fe4e342f0d94eade1b108bed91cc00.zip
Initial commit
Diffstat (limited to 'lisp/init-elpa.el')
-rw-r--r--lisp/init-elpa.el48
1 files changed, 48 insertions, 0 deletions
diff --git a/lisp/init-elpa.el b/lisp/init-elpa.el
new file mode 100644
index 0000000..1a889b8
--- /dev/null
+++ b/lisp/init-elpa.el
@@ -0,0 +1,48 @@
+;;; Find and load the correct package.el
+;; When switching between Emacs 23 and 24, we always use the bundled package.el in Emacs 24
+(let ((package-el-site-lisp-dir
+ (expand-file-name "site-lisp/package" user-emacs-directory)))
+ (when (and (file-directory-p package-el-site-lisp-dir)
+ (> emacs-major-version 23))
+ (message "Removing local package.el from load-path to avoid shadowing bundled version")
+ (setq load-path (remove package-el-site-lisp-dir load-path))))
+
+(require 'package)
+
+;; Repositories
+;; ================
+(setq package-archives
+ '(("melpa" . "https://melpa.org/packages/")
+ ;;("melpa-stable" . "https://stable.melpa.org/packages/")
+ ("gnu" . "https://elpa.gnu.org/packages/")
+ ("org" . "https://orgmode.org/elpa/")))
+
+(setq package-archive-priorities
+ '(("melpa" . 4)
+ ("melpa-stable" . 0)
+ ("gnu" . 1)
+ ("org" . 3)))
+;; =================
+
+;;; Find packages if not installed
+;; ================================
+;;; On-demand installation of packages
+(defun require-package (package &optional min-version no-refresh)
+ "Install given PACKAGE, optionally requiring MIN-VERSION.
+If NO-REFRESH is non-nil, the available package lists will not be
+re-downloaded in order to locate PACKAGE."
+ (if (package-installed-p package min-version)
+ t
+ (if (or (assoc package package-archive-contents) no-refresh)
+ (if (boundp 'package-selected-packages)
+ ;; Record this as a package the user installed explicitly
+ (package-install package nil)
+ (package-install package))
+ (progn
+ (package-refresh-contents)
+ (require-package package min-version t)))))
+;; ================================
+
+(package-initialize)
+
+(provide 'init-elpa)