Refactor core-modules

- Update comments & docstrings
- Remove unnecessary compile-time evaluation (we're not using any of
  that config at compile time within that file anyway).
This commit is contained in:
Henrik Lissner 2020-05-27 16:11:59 -04:00
parent fa55a0889a
commit d4d8c48265
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -315,30 +315,30 @@ This value is cached. If REFRESH-P, then don't use the cached value."
;; ;;
;;; Use-package modifications ;;; Use-package modifications
(eval-and-compile
(autoload 'use-package "use-package-core" nil nil t)
(setq use-package-compute-statistics doom-debug-p
use-package-verbose doom-debug-p
use-package-minimum-reported-time (if doom-debug-p 0 0.1)
use-package-expand-minimally doom-interactive-p))
(defvar doom--deferred-packages-alist '(t)) (defvar doom--deferred-packages-alist '(t))
(with-eval-after-load 'use-package-core (autoload 'use-package "use-package-core" nil nil t)
;; Macros are already fontified, no need for this
(font-lock-remove-keywords 'emacs-lisp-mode use-package-font-lock-keywords)
;; A common mistake for new users is that they inadvertantly try to install (setq use-package-compute-statistics doom-debug-p
;; their packages with package.el, by copying over old `use-package' use-package-verbose doom-debug-p
;; declarations with an :ensure t property. Doom doesn't use package.el, so use-package-minimum-reported-time (if doom-debug-p 0 0.1)
;; this will throw an error that will confuse beginners. use-package-expand-minimally doom-interactive-p)
(setq use-package-ensure-function #'ignore)
;; ...On the other hand, if the user has loaded `package', then we should ;; A common mistake for new users is that they inadvertantly install their
;; assume they know what they're doing and restore the old behavior: ;; packages with package.el, by copying over old `use-package' declarations with
(add-transient-hook! 'package-initialize ;; an :ensure t property. Doom doesn't use package.el, so this will throw an
(when (eq use-package-ensure-function #'ignore) ;; error that will confuse beginners, so we disable `:ensure'.
(setq use-package-ensure-function #'use-package-ensure-elpa))) (setq use-package-ensure-function #'ignore)
;; ...On the other hand, if the user has loaded `package', then we should assume
;; they know what they're doing and restore the old behavior:
(add-transient-hook! 'package-initialize
(when (eq use-package-ensure-function #'ignore)
(setq use-package-ensure-function #'use-package-ensure-elpa)))
(with-eval-after-load 'use-package-core
;; `use-package' adds syntax highlighting for the `use-package' macro, but
;; Emacs 26+ already highlights macros, so it's redundant.
(font-lock-remove-keywords 'emacs-lisp-mode use-package-font-lock-keywords)
;; We define :minor and :magic-minor from the `auto-minor-mode' package here ;; We define :minor and :magic-minor from the `auto-minor-mode' package here
;; so we don't have to load `auto-minor-mode' so early. ;; so we don't have to load `auto-minor-mode' so early.
@ -531,7 +531,7 @@ If FLAG is provided, returns t if CATEGORY MODULE has FLAG enabled.
(featurep! :config default) (featurep! :config default)
Module FLAGs are set in your config's `doom!' block, typically in Module FLAGs are set in your config's `doom!' block, typically in
~/.emacs.d/init.el. Like so: ~/.doom.d/init.el. Like so:
:config (default +flag1 -flag2) :config (default +flag1 -flag2)
@ -540,11 +540,10 @@ CATEGORY and MODULE can be omitted When this macro is used from inside a module
(and (cond (flag (memq flag (doom-module-get category module :flags))) (and (cond (flag (memq flag (doom-module-get category module :flags)))
(module (doom-module-p category module)) (module (doom-module-p category module))
(doom--current-flags (memq category doom--current-flags)) (doom--current-flags (memq category doom--current-flags))
((let ((module (doom-module-from-path))) ((if-let (module (doom-module-from-path))
(unless module (memq category (doom-module-get (car module) (cdr module) :flags))
(error "(featurep! %s %s %s) couldn't figure out what module it was called from (in %s)" (error "(featurep! %s %s %s) couldn't figure out what module it was called from (in %s)"
category module flag (file!))) category module flag (file!)))))
(memq category (doom-module-get (car module) (cdr module) :flags)))))
t)) t))
(provide 'core-modules) (provide 'core-modules)