]> git.donarmstrong.com Git - lib.git/commitdiff
load use-package even more quickly (hopefully)
authorDon Armstrong <don@donarmstrong.com>
Tue, 16 Jan 2018 21:20:18 +0000 (13:20 -0800)
committerDon Armstrong <don@donarmstrong.com>
Tue, 16 Jan 2018 21:20:18 +0000 (13:20 -0800)
emacs_el/configuration/don-configuration.org

index 1f38321e01235d5bf9c946786f479f603fd61f1c..5e63115dc830f1ce340e8657f624cc4bae3951c0 100644 (file)
 
 * Package management
 ** package repositories and package manager
-#+BEGIN_SRC emacs-lisp
-  (require 'package)
+Borrowed from https://github.com/nilcons/emacs-use-package-fast/ to
+load use-package even faster
+#+BEGIN_SRC emacs-lisp
+  (setq package-enable-at-startup nil)
+  (setq package--init-file-ensured t)
+  (eval-and-compile
+    (setq use-package-verbose (not (bound-and-true-p byte-compile-current-file))))
+  (mapc #'(lambda (add) (add-to-list 'load-path add))
+        (eval-when-compile
+          (package-initialize)
+          (unless (package-installed-p 'use-package)
+            (package-refresh-contents)
+            (package-install 'use-package))
+          (setq use-package-always-ensure t)
+          (let ((package-user-dir-real (file-truename package-user-dir)))
+            ;; The reverse is necessary, because outside we mapc
+            ;; add-to-list element-by-element, which reverses.
+            (nreverse (apply #'nconc
+                             ;; Only keep package.el provided loadpaths.
+                             (mapcar #'(lambda (path)
+                                         (if (string-prefix-p package-user-dir-real path)
+                                             (list path)
+                                           nil))
+                                     load-path))))))
+
   (setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/")
                            ("melpa" . "https://melpa.org/packages/")
                            ("org" . "http://orgmode.org/elpa/") ))
 ** [[https://github.com/jwiegley/use-package/][use-package]]
 #+BEGIN_SRC emacs-lisp
   (package-initialize)
-  (condition-case nil
-      (require 'use-package)
-    (progn (package-install 'use-package)
-           (require 'use-package)))
+  (eval-when-compile
+    (unless (package-installed-p 'use-package)
+      (package-refresh-contents)
+      (package-install 'use-package))
+    (require 'use-package))
 #+END_SRC
 ** Paradox
 #+BEGIN_SRC emacs-lisp