From 31a42446860e90261f3b45c5a93579850cdf0904 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sat, 6 Jan 2018 17:02:57 -0500 Subject: [PATCH] Rethink what Doom loads at startup and manually Better to simply load what we need, when we need it, rather than set up autoloads for every litte thing. --- core/autoload/packages.el | 1 + core/core-lib.el | 19 ++++++++++--------- core/core.el | 1 - modules/lang/go/autoload.el | 1 + modules/lang/javascript/autoload.el | 1 + modules/lang/php/autoload.el | 1 + modules/lang/php/config.el | 1 + 7 files changed, 15 insertions(+), 10 deletions(-) diff --git a/core/autoload/packages.el b/core/autoload/packages.el index 1eb4ec417..c335a4f3c 100644 --- a/core/autoload/packages.el +++ b/core/autoload/packages.el @@ -133,6 +133,7 @@ containing (PACKAGE-SYMBOL OLD-VERSION-LIST NEW-VERSION-LIST). If INCLUDE-FROZEN-P is non-nil, check frozen packages as well. Used by `doom//packages-update'." + (require 'async) (let (quelpa-pkgs elpa-pkgs) ;; Separate quelpa from elpa packages (dolist (pkg (doom-get-packages t)) diff --git a/core/core-lib.el b/core/core-lib.el index 61f1ea589..6ea99c594 100644 --- a/core/core-lib.el +++ b/core/core-lib.el @@ -1,14 +1,15 @@ ;;; core-lib.el -*- lexical-binding: t; -*- -(require 'subr-x) -(load "async-autoloads" nil t) -(dolist (sym '(json-read json-read-file json-read-from-string json-encode)) - (autoload sym "json")) -(eval-and-compile - (when (version< emacs-version "26") - (with-no-warnings - (defalias 'if-let* #'if-let) - (defalias 'when-let* #'when-let)))) +(let ((load-path doom--site-load-path)) + (require 'subr-x) + (require 'cl-lib) + (require 'map) + (eval-when-compile (require 'use-package))) + +(when (version< emacs-version "26") + (with-no-warnings + (defalias 'if-let* #'if-let) + (defalias 'when-let* #'when-let))) ;; diff --git a/core/core.el b/core/core.el index c61b84233..61d222d76 100644 --- a/core/core.el +++ b/core/core.el @@ -155,7 +155,6 @@ ability to invoke the debugger in debug mode." gc-cons-percentage 0.6 file-name-handler-alist nil)) - (require 'cl-lib) (load (concat doom-core-dir "core-packages") nil t) (setq load-path (eval-when-compile (doom-initialize t) (doom-initialize-load-path t)) diff --git a/modules/lang/go/autoload.el b/modules/lang/go/autoload.el index 18a3e1ca6..5532e757c 100644 --- a/modules/lang/go/autoload.el +++ b/modules/lang/go/autoload.el @@ -8,6 +8,7 @@ "The last test run.") (defun +go--run-tests (args) + (require 'async) (save-selected-window (async-shell-command (concat "go test " args)))) diff --git a/modules/lang/javascript/autoload.el b/modules/lang/javascript/autoload.el index 3df1ecd03..cfc42d65c 100644 --- a/modules/lang/javascript/autoload.el +++ b/modules/lang/javascript/autoload.el @@ -11,6 +11,7 @@ ignore the cache." (gethash project-root +javascript-npm-conf)) (let ((package-file (expand-file-name "package.json" project-root))) (when-let* ((json (and (file-exists-p package-file) + (require 'json) (json-read-file package-file)))) (puthash project-root json +javascript-npm-conf)))))) diff --git a/modules/lang/php/autoload.el b/modules/lang/php/autoload.el index fc2fd8ca9..53ce77a57 100644 --- a/modules/lang/php/autoload.el +++ b/modules/lang/php/autoload.el @@ -10,5 +10,6 @@ ignore the cache." (or (and (not refresh-p) (gethash project-root +php-composer-conf)) (let ((package-file (expand-file-name "composer.json" project-root))) (when-let* ((data (and (file-exists-p package-file) + (require 'json) (json-read-file package-file)))) (puthash project-root data +php-composer-conf)))))) diff --git a/modules/lang/php/config.el b/modules/lang/php/config.el index 3dfc1aa4e..86d6ba3e2 100644 --- a/modules/lang/php/config.el +++ b/modules/lang/php/config.el @@ -58,6 +58,7 @@ ;; Make expensive php-extras generation async (unless (file-exists-p (concat php-extras-eldoc-functions-file ".el")) (message "Generating PHP eldoc files...") + (require 'async) (async-start `(lambda () ,(async-inject-variables "\\`\\(load-path\\|php-extras-eldoc-functions-file\\)$") (require 'php-extras-gen-eldoc)