40 lines
1.3 KiB
EmacsLisp
40 lines
1.3 KiB
EmacsLisp
(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)
|