Refactor doom-initialize
This commit is contained in:
parent
6a3e879501
commit
5363d1192d
1 changed files with 19 additions and 20 deletions
|
@ -78,41 +78,40 @@ if you have byte-compiled your configuration (as intended).")
|
||||||
|
|
||||||
(defun doom-initialize (&optional force-p)
|
(defun doom-initialize (&optional force-p)
|
||||||
"Initialize installed packages (using package.el) and ensure the core packages
|
"Initialize installed packages (using package.el) and ensure the core packages
|
||||||
are installed. If you byte compile core/core.el, calls to `package.el' are
|
are installed. If you byte compile core/core.el, this function will be avoided
|
||||||
avoided to speed up startup."
|
to speed up startup."
|
||||||
;; This is called early during Emacs initialization, so we can only use native
|
;; This is called early during Emacs initialization, so we can only use native
|
||||||
;; emacs functions.
|
;; emacs functions.
|
||||||
(unless (or doom-init-p force-p)
|
(unless (or doom-init-p force-p)
|
||||||
(setq load-path doom--base-load-path
|
(setq load-path doom--base-load-path
|
||||||
package-activated-list nil)
|
package-activated-list nil)
|
||||||
|
|
||||||
|
;; Ensure cache folder exists
|
||||||
|
(mapc (lambda (dir)
|
||||||
|
(unless (file-directory-p dir)
|
||||||
|
(make-directory dir t)))
|
||||||
|
(list doom-cache-dir package-user-dir))
|
||||||
|
|
||||||
(package-initialize t)
|
(package-initialize t)
|
||||||
|
|
||||||
;; Sure, `package-initialize' fills the load-path, but when NO-ACTIVATE is
|
;; Sure, `package-initialize' fills the load-path, but when NO-ACTIVATE is
|
||||||
;; non-nil, it will error out on missing packages. UNACCEPTAABBLLLE!
|
;; non-nil, it will error out on missing packages. UNACCEPTAABBLLLE!
|
||||||
(setq load-path (append load-path (directory-files package-user-dir t "^[a-zA-Z0-9]" t)))
|
(setq load-path (append load-path (directory-files package-user-dir t "^[a-zA-Z0-9]" t)))
|
||||||
|
|
||||||
;; Ensure cache folder exists
|
|
||||||
(unless (file-exists-p doom-cache-dir)
|
|
||||||
(make-directory doom-cache-dir t))
|
|
||||||
|
|
||||||
;; Ensure core packages are installed
|
;; Ensure core packages are installed
|
||||||
(unless (and (file-exists-p doom-packages-dir)
|
(let ((core-packages (cl-remove-if 'package-installed-p doom-protected-packages)))
|
||||||
(require 'use-package nil t)
|
(when core-packages
|
||||||
(require 'quelpa nil t))
|
|
||||||
(package-refresh-contents)
|
(package-refresh-contents)
|
||||||
(condition-case ex
|
(dolist (pkg core-packages)
|
||||||
(mapc (lambda (pkg)
|
(let ((inhibit-message t))
|
||||||
(package-install pkg)
|
(package-install pkg))
|
||||||
(unless (package-installed-p pkg)
|
(if (package-installed-p pkg)
|
||||||
(error "Couldn't install %s" pkg)))
|
(message "Installed %s" pkg)
|
||||||
doom-protected-packages)
|
(error "Couldn't install %s" pkg)))))
|
||||||
(error
|
|
||||||
(delete-directory doom-packages-dir t)
|
|
||||||
(error "There was an error initializing DOOM. Try running it again"))))
|
|
||||||
|
|
||||||
(require 'quelpa)
|
(require 'quelpa)
|
||||||
(require 'use-package)
|
(require 'use-package)
|
||||||
;; Remove package management keywords, I'll deal with the myself
|
;; Remove package management keywords, I'll deal with that myself
|
||||||
(mapc (lambda (keyword) (setq use-package-keywords (delq keyword use-package-keywords)))
|
(mapc (lambda (keyword) (setq use-package-keywords (delq keyword use-package-keywords)))
|
||||||
'(:ensure :pin))
|
'(:ensure :pin))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue