2018-06-11 23:18:15 +02:00
|
|
|
;;; core-modules.el --- module & package management system -*- lexical-binding: t; -*-
|
|
|
|
|
|
|
|
(defvar doom-init-modules-p nil
|
|
|
|
"Non-nil if `doom-initialize-modules' has run.")
|
|
|
|
|
|
|
|
(defvar doom-modules ()
|
|
|
|
"A hash table of enabled modules. Set by `doom-initialize-modules'.")
|
|
|
|
|
|
|
|
(defvar doom-modules-dirs
|
2018-06-23 22:22:42 +02:00
|
|
|
(list (expand-file-name "modules/" doom-private-dir)
|
|
|
|
doom-modules-dir)
|
2018-06-11 23:18:15 +02:00
|
|
|
"A list of module root directories. Order determines priority.")
|
|
|
|
|
2018-06-15 13:10:00 +02:00
|
|
|
(defconst doom-obsolete-modules
|
2019-02-22 00:20:29 -05:00
|
|
|
'((:feature (version-control (:emacs vc) (:ui vc-gutter))
|
|
|
|
(spellcheck (:tools flyspell))
|
2019-04-21 19:59:44 -04:00
|
|
|
(syntax-checker (:tools flycheck))
|
|
|
|
(evil (:editor evil))
|
|
|
|
(snippets (:editor snippets))
|
|
|
|
(file-templates (:editor file-templates))
|
|
|
|
(workspaces (:ui workspaces))
|
|
|
|
(eval (:tools eval))
|
|
|
|
(lookup (:tools lookup))
|
|
|
|
(debugger (:tools debugger)))
|
2019-05-18 23:41:18 -04:00
|
|
|
(:tools (rotate-text (:editor rotate-text))
|
2019-05-19 00:03:15 -04:00
|
|
|
(vterm (:term vterm))
|
|
|
|
(password-store (:tools pass)))
|
2019-02-18 00:01:58 -05:00
|
|
|
(:emacs (electric-indent (:emacs electric))
|
2019-05-18 23:41:18 -04:00
|
|
|
(hideshow (:editor fold))
|
|
|
|
(eshell (:term eshell))
|
|
|
|
(term (:term term)))
|
2019-04-21 19:59:44 -04:00
|
|
|
(:ui (doom-modeline (:ui modeline))
|
|
|
|
(fci (:ui fill-column))
|
2019-08-10 14:14:51 -04:00
|
|
|
(evil-goggles (:ui ophints))
|
|
|
|
(tabbar (:ui tabs)))
|
2019-05-05 14:11:59 -04:00
|
|
|
(:app (email (:email mu4e))
|
|
|
|
(notmuch (:email notmuch))))
|
2019-04-21 19:59:44 -04:00
|
|
|
"A tree alist that maps deprecated modules to their replacement(s).
|
2018-06-15 13:05:40 +02:00
|
|
|
|
2019-04-21 19:59:44 -04:00
|
|
|
Each entry is a three-level tree. For example:
|
2018-06-15 13:05:40 +02:00
|
|
|
|
2019-04-21 19:59:44 -04:00
|
|
|
(:feature (version-control (:emacs vc) (:ui vc-gutter))
|
|
|
|
(spellcheck (:tools flyspell))
|
|
|
|
(syntax-checker (:tools flycheck)))
|
|
|
|
|
|
|
|
This marks :feature version-control, :feature spellcheck and :feature
|
|
|
|
syntax-checker modules obsolete. e.g. If :feature version-control is found in
|
|
|
|
your `doom!' block, a warning is emitted before replacing it with :emacs vc and
|
|
|
|
:ui vc-gutter.")
|
2018-06-15 13:05:40 +02:00
|
|
|
|
2019-09-03 00:36:42 -04:00
|
|
|
(defvar doom-inhibit-module-warnings doom-interactive-mode
|
2019-07-21 15:39:45 +02:00
|
|
|
"If non-nil, don't emit deprecated or missing module warnings at startup.")
|
2018-06-11 23:18:15 +02:00
|
|
|
|
2019-03-07 19:39:45 -05:00
|
|
|
;;; Custom hooks
|
|
|
|
(defvar doom-before-init-modules-hook nil
|
|
|
|
"A list of hooks to run before Doom's modules' config.el files are loaded, but
|
|
|
|
after their init.el files are loaded.")
|
|
|
|
|
|
|
|
(defvar doom-init-modules-hook nil
|
|
|
|
"A list of hooks to run after Doom's modules' config.el files have loaded, but
|
|
|
|
before the user's private module.")
|
|
|
|
|
|
|
|
(defvaralias 'doom-after-init-modules-hook 'after-init-hook)
|
|
|
|
|
2019-07-21 15:39:45 +02:00
|
|
|
(defvar doom--current-module nil)
|
|
|
|
(defvar doom--current-flags nil)
|
2019-03-07 19:39:45 -05:00
|
|
|
|
|
|
|
|
|
|
|
;;
|
|
|
|
;;; Bootstrap API
|
2018-06-11 23:18:15 +02:00
|
|
|
|
|
|
|
(defun doom-initialize-modules (&optional force-p)
|
|
|
|
"Loads the init.el in `doom-private-dir' and sets up hooks for a healthy
|
|
|
|
session of Dooming. Will noop if used more than once, unless FORCE-P is
|
|
|
|
non-nil."
|
2019-07-21 15:39:45 +02:00
|
|
|
(when (or force-p (not doom-init-modules-p))
|
|
|
|
(setq doom-init-modules-p t
|
|
|
|
doom-modules nil)
|
|
|
|
(when (load! "init" doom-private-dir t)
|
|
|
|
(when doom-modules
|
|
|
|
(maphash (lambda (key plist)
|
|
|
|
(let ((doom--current-module key)
|
|
|
|
(doom--current-flags (plist-get plist :flags)))
|
|
|
|
(load! "init" (plist-get plist :path) t)))
|
|
|
|
doom-modules))
|
|
|
|
(run-hook-wrapped 'doom-before-init-modules-hook #'doom-try-run-hook)
|
2019-09-03 00:36:42 -04:00
|
|
|
(when doom-interactive-mode
|
2019-07-21 15:39:45 +02:00
|
|
|
(when doom-modules
|
|
|
|
(maphash (lambda (key plist)
|
|
|
|
(let ((doom--current-module key)
|
|
|
|
(doom--current-flags (plist-get plist :flags)))
|
|
|
|
(load! "config" (plist-get plist :path) t)))
|
|
|
|
doom-modules))
|
|
|
|
(run-hook-wrapped 'doom-init-modules-hook #'doom-try-run-hook)
|
|
|
|
(load! "config" doom-private-dir t)))))
|
2018-06-11 23:18:15 +02:00
|
|
|
|
|
|
|
|
|
|
|
;;
|
2019-03-07 23:21:58 -05:00
|
|
|
;;; Module API
|
2018-06-11 23:18:15 +02:00
|
|
|
|
2019-07-07 14:07:11 +02:00
|
|
|
(defun doom-module-p (category module &optional flag)
|
2018-06-11 23:18:15 +02:00
|
|
|
"Returns t if CATEGORY MODULE is enabled (ie. present in `doom-modules')."
|
2018-06-24 19:54:50 +02:00
|
|
|
(declare (pure t) (side-effect-free t))
|
2019-07-21 15:39:45 +02:00
|
|
|
(let ((plist (gethash (cons category module) doom-modules)))
|
|
|
|
(and plist
|
|
|
|
(or (null flag)
|
|
|
|
(memq flag (plist-get plist :flags)))
|
|
|
|
t)))
|
2018-06-11 23:18:15 +02:00
|
|
|
|
|
|
|
(defun doom-module-get (category module &optional property)
|
|
|
|
"Returns the plist for CATEGORY MODULE. Gets PROPERTY, specifically, if set."
|
2018-06-24 19:54:50 +02:00
|
|
|
(declare (pure t) (side-effect-free t))
|
2019-06-25 21:38:16 +02:00
|
|
|
(when-let (plist (gethash (cons category module) doom-modules))
|
2018-06-11 23:18:15 +02:00
|
|
|
(if property
|
|
|
|
(plist-get plist property)
|
|
|
|
plist)))
|
|
|
|
|
2018-09-25 23:52:20 -04:00
|
|
|
(defun doom-module-put (category module &rest plist)
|
2018-06-11 23:18:15 +02:00
|
|
|
"Set a PROPERTY for CATEGORY MODULE to VALUE. PLIST should be additional pairs
|
2018-09-25 23:52:20 -04:00
|
|
|
of PROPERTY and VALUEs.
|
|
|
|
|
|
|
|
\(fn CATEGORY MODULE PROPERTY VALUE &rest [PROPERTY VALUE [...]])"
|
2019-07-21 15:39:45 +02:00
|
|
|
(if-let (old-plist (doom-module-get category module))
|
2018-09-25 23:52:20 -04:00
|
|
|
(progn
|
|
|
|
(when plist
|
|
|
|
(when (cl-oddp (length plist))
|
|
|
|
(signal 'wrong-number-of-arguments (list (length plist))))
|
|
|
|
(while plist
|
|
|
|
(plist-put old-plist (pop plist) (pop plist))))
|
|
|
|
(puthash (cons category module) old-plist doom-modules))
|
2018-06-11 23:18:15 +02:00
|
|
|
(puthash (cons category module) plist doom-modules)))
|
|
|
|
|
|
|
|
(defun doom-module-set (category module &rest plist)
|
|
|
|
"Enables a module by adding it to `doom-modules'.
|
|
|
|
|
|
|
|
CATEGORY is a keyword, module is a symbol, PLIST is a plist that accepts the
|
|
|
|
following properties:
|
|
|
|
|
|
|
|
:flags [SYMBOL LIST] list of enabled category flags
|
|
|
|
:path [STRING] path to category root directory
|
|
|
|
|
|
|
|
Example:
|
|
|
|
(doom-module-set :lang 'haskell :flags '(+intero))"
|
2018-06-19 20:55:44 +02:00
|
|
|
(puthash (cons category module)
|
|
|
|
plist
|
|
|
|
doom-modules))
|
2018-06-11 23:18:15 +02:00
|
|
|
|
|
|
|
(defun doom-module-path (category module &optional file)
|
|
|
|
"Like `expand-file-name', but expands FILE relative to CATEGORY (keywordp) and
|
|
|
|
MODULE (symbol).
|
|
|
|
|
|
|
|
If the category isn't enabled this will always return nil. For finding disabled
|
|
|
|
modules use `doom-module-locate-path'."
|
2019-07-21 15:39:45 +02:00
|
|
|
(let ((path (doom-module-get category module :path)))
|
|
|
|
(if file
|
|
|
|
(let (file-name-handler-alist)
|
|
|
|
(expand-file-name file path))
|
2018-06-11 23:18:15 +02:00
|
|
|
path)))
|
|
|
|
|
|
|
|
(defun doom-module-locate-path (category &optional module file)
|
|
|
|
"Searches `doom-modules-dirs' to find the path to a module.
|
|
|
|
|
|
|
|
CATEGORY is a keyword (e.g. :lang) and MODULE is a symbol (e.g. 'python). FILE
|
|
|
|
is a string that will be appended to the resulting path. If no path exists, this
|
|
|
|
returns nil, otherwise an absolute path.
|
|
|
|
|
|
|
|
This doesn't require modules to be enabled. For enabled modules us
|
|
|
|
`doom-module-path'."
|
|
|
|
(when (keywordp category)
|
2018-09-25 23:52:20 -04:00
|
|
|
(setq category (doom-keyword-name category)))
|
2018-06-11 23:18:15 +02:00
|
|
|
(when (and module (symbolp module))
|
|
|
|
(setq module (symbol-name module)))
|
2018-06-24 19:54:50 +02:00
|
|
|
(cl-loop with file-name-handler-alist = nil
|
|
|
|
for default-directory in doom-modules-dirs
|
2018-06-11 23:18:15 +02:00
|
|
|
for path = (concat category "/" module "/" file)
|
|
|
|
if (file-exists-p path)
|
|
|
|
return (expand-file-name path)))
|
|
|
|
|
2019-07-21 15:39:45 +02:00
|
|
|
(defun doom-module-from-path (&optional path enabled-only)
|
|
|
|
"Returns a cons cell (CATEGORY . MODULE) derived from PATH (a file path).
|
|
|
|
If ENABLED-ONLY, return nil if the containing module isn't enabled."
|
2019-07-22 19:04:03 +02:00
|
|
|
(if (null path)
|
|
|
|
(if doom--current-module
|
|
|
|
(if enabled-only
|
|
|
|
(and (doom-module-p (car doom--current-module)
|
|
|
|
(cdr doom--current-module))
|
|
|
|
doom--current-module)
|
|
|
|
doom--current-module)
|
2019-11-23 14:52:38 -05:00
|
|
|
(ignore-errors
|
|
|
|
(doom-module-from-path (file!))))
|
2019-07-22 19:04:03 +02:00
|
|
|
(let* ((file-name-handler-alist nil)
|
|
|
|
(path (file-truename (or path (file!)))))
|
|
|
|
(save-match-data
|
|
|
|
(cond ((string-match "/modules/\\([^/]+\\)/\\([^/]+\\)\\(?:/.*\\)?$" path)
|
|
|
|
(when-let* ((category (doom-keyword-intern (match-string 1 path)))
|
|
|
|
(module (intern (match-string 2 path))))
|
|
|
|
(and (or (null enabled-only)
|
|
|
|
(doom-module-p category module))
|
|
|
|
(cons category module))))
|
|
|
|
((file-in-directory-p path doom-core-dir)
|
|
|
|
(cons :core (intern (file-name-base path))))
|
|
|
|
((file-in-directory-p path doom-private-dir)
|
|
|
|
(cons :private (intern (file-name-base path)))))))))
|
2019-07-21 15:39:45 +02:00
|
|
|
|
|
|
|
(defun doom-module-load-path (&optional module-dirs)
|
|
|
|
"Return a list of file paths to activated modules.
|
|
|
|
|
|
|
|
The list is in no particular order and its file paths are absolute. If
|
|
|
|
MODULE-DIRS is non-nil, include all modules (even disabled ones) available in
|
2019-08-21 00:10:24 -04:00
|
|
|
those directories. The first returned path is always `doom-private-dir'."
|
2018-06-24 19:54:50 +02:00
|
|
|
(declare (pure t) (side-effect-free t))
|
2019-07-21 15:39:45 +02:00
|
|
|
(append (list doom-private-dir)
|
|
|
|
(if module-dirs
|
|
|
|
(doom-files-in (if (listp module-dirs)
|
|
|
|
module-dirs
|
|
|
|
doom-modules-dirs)
|
2018-06-12 15:03:45 +02:00
|
|
|
:type 'dirs
|
|
|
|
:mindepth 1
|
2019-07-21 15:39:45 +02:00
|
|
|
:depth 1)
|
2018-06-12 15:03:45 +02:00
|
|
|
(cl-loop for plist being the hash-values of (doom-modules)
|
|
|
|
collect (plist-get plist :path)))
|
2019-07-21 15:39:45 +02:00
|
|
|
nil))
|
2018-06-11 23:18:15 +02:00
|
|
|
|
|
|
|
(defun doom-modules (&optional refresh-p)
|
2019-07-21 15:39:45 +02:00
|
|
|
"Minimally initialize `doom-modules' (a hash table) and return it.
|
|
|
|
This value is cached. If REFRESH-P, then don't use the cached value."
|
2018-06-11 23:18:15 +02:00
|
|
|
(or (unless refresh-p doom-modules)
|
2019-09-03 00:36:42 -04:00
|
|
|
(let (doom-interactive-mode
|
2018-09-25 23:52:20 -04:00
|
|
|
doom-modules
|
2018-06-11 23:18:15 +02:00
|
|
|
doom-init-modules-p)
|
2018-08-08 21:45:07 +02:00
|
|
|
(load! "init" doom-private-dir t)
|
2018-09-25 23:52:20 -04:00
|
|
|
(or doom-modules
|
|
|
|
(make-hash-table :test 'equal
|
|
|
|
:size 20
|
|
|
|
:rehash-threshold 1.0)))))
|
2018-06-11 23:18:15 +02:00
|
|
|
|
|
|
|
|
|
|
|
;;
|
2019-03-07 23:21:58 -05:00
|
|
|
;;; Use-package modifications
|
2018-06-11 23:18:15 +02:00
|
|
|
|
2019-05-13 00:49:00 -04:00
|
|
|
(eval-and-compile
|
|
|
|
(autoload 'use-package "use-package-core" nil nil t)
|
2018-06-11 23:18:15 +02:00
|
|
|
|
2019-05-13 00:49:00 -04:00
|
|
|
(setq use-package-compute-statistics doom-debug-mode
|
|
|
|
use-package-verbose doom-debug-mode
|
|
|
|
use-package-minimum-reported-time (if doom-debug-mode 0 0.1)
|
2019-09-03 00:36:42 -04:00
|
|
|
use-package-expand-minimally doom-interactive-mode))
|
2018-06-20 12:48:59 +02:00
|
|
|
|
2018-06-23 16:48:58 +02:00
|
|
|
(defvar doom--deferred-packages-alist '(t))
|
2019-05-01 19:12:52 -04:00
|
|
|
|
|
|
|
(with-eval-after-load 'use-package-core
|
|
|
|
;; Macros are already fontified, no need for this
|
|
|
|
(font-lock-remove-keywords 'emacs-lisp-mode use-package-font-lock-keywords)
|
|
|
|
|
2019-09-20 23:55:50 -04:00
|
|
|
;; 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.
|
2019-07-21 14:49:09 +02:00
|
|
|
(dolist (keyword '(:minor :magic-minor))
|
|
|
|
(setq use-package-keywords
|
|
|
|
(use-package-list-insert keyword use-package-keywords :commands)))
|
|
|
|
|
|
|
|
(defalias 'use-package-normalize/:minor #'use-package-normalize-mode)
|
|
|
|
(defun use-package-handler/:minor (name _ arg rest state)
|
|
|
|
(use-package-handle-mode name 'auto-minor-mode-alist arg rest state))
|
|
|
|
|
|
|
|
(defalias 'use-package-normalize/:magic-minor #'use-package-normalize-mode)
|
|
|
|
(defun use-package-handler/:magic-minor (name _ arg rest state)
|
|
|
|
(use-package-handle-mode name 'auto-minor-mode-magic-alist arg rest state))
|
2018-06-11 23:18:15 +02:00
|
|
|
|
2019-09-20 23:55:50 -04:00
|
|
|
;; Adds two keywords to `use-package' to expand its lazy-loading capabilities:
|
|
|
|
;;
|
|
|
|
;; :after-call SYMBOL|LIST
|
|
|
|
;; :defer-incrementally SYMBOL|LIST|t
|
|
|
|
;;
|
|
|
|
;; Check out `use-package!'s documentation for more about these two.
|
|
|
|
(dolist (keyword '(:defer-incrementally :after-call))
|
|
|
|
(push keyword use-package-deferring-keywords)
|
|
|
|
(setq use-package-keywords
|
|
|
|
(use-package-list-insert keyword use-package-keywords :after)))
|
|
|
|
|
2019-05-21 00:34:32 -04:00
|
|
|
(defalias 'use-package-normalize/:defer-incrementally #'use-package-normalize-symlist)
|
2018-09-20 10:41:19 -04:00
|
|
|
(defun use-package-handler/:defer-incrementally (name _keyword targets rest state)
|
|
|
|
(use-package-concat
|
|
|
|
`((doom-load-packages-incrementally
|
2018-09-21 22:43:52 -04:00
|
|
|
',(if (equal targets '(t))
|
|
|
|
(list name)
|
2018-12-23 00:25:51 -05:00
|
|
|
(append targets (list name)))))
|
2018-09-20 10:41:19 -04:00
|
|
|
(use-package-process-keywords name rest state)))
|
|
|
|
|
2019-05-21 00:34:32 -04:00
|
|
|
(defalias 'use-package-normalize/:after-call #'use-package-normalize-symlist)
|
2018-06-14 11:53:52 +02:00
|
|
|
(defun use-package-handler/:after-call (name _keyword hooks rest state)
|
2018-06-23 19:29:29 +02:00
|
|
|
(if (plist-get state :demand)
|
|
|
|
(use-package-process-keywords name rest state)
|
2019-07-18 15:27:20 +02:00
|
|
|
(let ((fn (make-symbol (format "doom--after-call-%s-h" name))))
|
2018-06-11 23:18:15 +02:00
|
|
|
(use-package-concat
|
|
|
|
`((fset ',fn
|
|
|
|
(lambda (&rest _)
|
2019-03-04 18:38:25 -05:00
|
|
|
(doom-log "Loading deferred package %s from %s" ',name ',fn)
|
2019-03-22 14:11:59 -04:00
|
|
|
(condition-case e
|
2019-08-26 20:36:39 -04:00
|
|
|
;; If `default-directory' is a directory that doesn't
|
|
|
|
;; exist or is unreadable, Emacs throws up file-missing
|
|
|
|
;; errors, so we set it to a directory we know exists and
|
|
|
|
;; is readable.
|
|
|
|
(let ((default-directory doom-emacs-dir))
|
|
|
|
(require ',name))
|
2018-06-19 20:54:09 +02:00
|
|
|
((debug error)
|
|
|
|
(message "Failed to load deferred package %s: %s" ',name e)))
|
2019-06-25 21:38:16 +02:00
|
|
|
(when-let (deferral-list (assq ',name doom--deferred-packages-alist))
|
2019-03-22 14:11:59 -04:00
|
|
|
(dolist (hook (cdr deferral-list))
|
2019-04-30 15:12:07 -04:00
|
|
|
(advice-remove hook #',fn)
|
|
|
|
(remove-hook hook #',fn))
|
2019-05-21 00:34:32 -04:00
|
|
|
(delq! deferral-list doom--deferred-packages-alist)
|
|
|
|
(unintern ',fn nil)))))
|
2018-06-23 16:48:58 +02:00
|
|
|
(let (forms)
|
|
|
|
(dolist (hook hooks forms)
|
2019-04-30 15:12:07 -04:00
|
|
|
(push (if (string-match-p "-\\(?:functions\\|hook\\)$" (symbol-name hook))
|
|
|
|
`(add-hook ',hook #',fn)
|
|
|
|
`(advice-add #',hook :before #',fn))
|
2018-06-23 16:48:58 +02:00
|
|
|
forms)))
|
|
|
|
`((unless (assq ',name doom--deferred-packages-alist)
|
|
|
|
(push '(,name) doom--deferred-packages-alist))
|
|
|
|
(nconc (assq ',name doom--deferred-packages-alist)
|
|
|
|
'(,@hooks)))
|
2018-06-11 23:18:15 +02:00
|
|
|
(use-package-process-keywords name rest state))))))
|
|
|
|
|
|
|
|
|
|
|
|
;;
|
2019-03-07 23:21:58 -05:00
|
|
|
;;; Module config macros
|
2018-06-11 23:18:15 +02:00
|
|
|
|
2019-07-26 12:05:13 +02:00
|
|
|
(put :if 'lisp-indent-function 2)
|
|
|
|
(put :when 'lisp-indent-function 'defun)
|
|
|
|
(put :unless 'lisp-indent-function 'defun)
|
|
|
|
|
2018-06-11 23:18:15 +02:00
|
|
|
(defmacro doom! (&rest modules)
|
|
|
|
"Bootstraps DOOM Emacs and its modules.
|
|
|
|
|
|
|
|
The bootstrap process involves making sure the essential directories exist, core
|
|
|
|
packages are installed, `doom-autoload-file' is loaded, `doom-packages-file'
|
|
|
|
cache exists (and is loaded) and, finally, loads your private init.el (which
|
|
|
|
should contain your `doom!' block).
|
|
|
|
|
|
|
|
If the cache exists, much of this function isn't run, which substantially
|
|
|
|
reduces startup time.
|
|
|
|
|
|
|
|
The overall load order of Doom is as follows:
|
|
|
|
|
|
|
|
~/.emacs.d/init.el
|
|
|
|
~/.emacs.d/core/core.el
|
2018-12-05 22:11:14 -05:00
|
|
|
$DOOMDIR/init.el
|
|
|
|
{$DOOMDIR,~/.emacs.d}/modules/*/*/init.el
|
2019-03-04 20:35:47 -05:00
|
|
|
`doom-before-init-modules-hook'
|
2018-12-05 22:11:14 -05:00
|
|
|
{$DOOMDIR,~/.emacs.d}/modules/*/*/config.el
|
2019-03-04 20:35:47 -05:00
|
|
|
`doom-init-modules-hook'
|
2018-12-05 22:11:14 -05:00
|
|
|
$DOOMDIR/config.el
|
2019-03-07 19:39:45 -05:00
|
|
|
`doom-after-init-modules-hook'
|
2018-06-11 23:18:15 +02:00
|
|
|
`after-init-hook'
|
|
|
|
`emacs-startup-hook'
|
2019-03-04 20:35:47 -05:00
|
|
|
`window-setup-hook'
|
2018-06-11 23:18:15 +02:00
|
|
|
|
|
|
|
Module load order is determined by your `doom!' block. See `doom-modules-dirs'
|
|
|
|
for a list of all recognized module trees. Order defines precedence (from most
|
|
|
|
to least)."
|
2019-10-07 16:10:33 -04:00
|
|
|
`(let ((modules ',modules))
|
|
|
|
(unless (keywordp (car modules))
|
|
|
|
(setq modules (eval modules t)))
|
|
|
|
(unless doom-modules
|
|
|
|
(setq doom-modules
|
|
|
|
(make-hash-table :test 'equal
|
|
|
|
:size (if modules (length modules) 150)
|
|
|
|
:rehash-threshold 1.0)))
|
|
|
|
(let ((inhibit-message doom-inhibit-module-warnings)
|
|
|
|
obsolete category m)
|
|
|
|
(while modules
|
|
|
|
(setq m (pop modules))
|
|
|
|
(cond ((keywordp m)
|
|
|
|
(setq category m
|
|
|
|
obsolete (assq m doom-obsolete-modules)))
|
|
|
|
((not category)
|
|
|
|
(error "No module category specified for %s" m))
|
|
|
|
((and (listp m) (keywordp (car m)))
|
|
|
|
(pcase (car m)
|
|
|
|
(:cond
|
|
|
|
(cl-loop for (cond . mods) in (cdr m)
|
|
|
|
if (eval cond t)
|
|
|
|
return (prependq! modules mods)))
|
|
|
|
(:if (if (eval (cadr m) t)
|
|
|
|
(push (caddr m) modules)
|
|
|
|
(prependq! modules (cdddr m))))
|
|
|
|
(fn (if (or (eval (cadr m) t)
|
|
|
|
(eq fn :unless))
|
|
|
|
(prependq! modules (cddr m))))))
|
|
|
|
((catch 'doom-modules
|
|
|
|
(let* ((module (if (listp m) (car m) m))
|
|
|
|
(flags (if (listp m) (cdr m))))
|
|
|
|
(when-let (new (assq module obsolete))
|
|
|
|
(let ((newkeys (cdr new)))
|
|
|
|
(if (null newkeys)
|
|
|
|
(message "WARNING %s module was removed" key)
|
|
|
|
(if (cdr newkeys)
|
|
|
|
(message "WARNING %s module was removed and split into the %s modules"
|
|
|
|
(list category module) (mapconcat #'prin1-to-string newkeys ", "))
|
|
|
|
(message "WARNING %s module was moved to %s"
|
|
|
|
(list category module) (car newkeys)))
|
|
|
|
(push category modules)
|
|
|
|
(dolist (key newkeys)
|
|
|
|
(push (if flags
|
|
|
|
(nconc (cdr key) flags)
|
|
|
|
(cdr key))
|
|
|
|
modules)
|
|
|
|
(push (car key) modules))
|
|
|
|
(throw 'doom-modules t))))
|
|
|
|
(if-let (path (doom-module-locate-path category module))
|
|
|
|
(doom-module-set category module :flags flags :path path)
|
|
|
|
(message "WARNING Couldn't find the %s %s module" category module)))))))
|
|
|
|
(unless doom-interactive-mode
|
|
|
|
(setq doom-inhibit-module-warnings t))
|
|
|
|
doom-modules)))
|
2018-06-11 23:18:15 +02:00
|
|
|
|
2018-06-16 00:36:27 +02:00
|
|
|
(defvar doom-disabled-packages)
|
2019-07-23 12:44:03 +02:00
|
|
|
(defmacro use-package! (name &rest plist)
|
2019-05-01 19:12:52 -04:00
|
|
|
"Declares and configures a package.
|
2019-03-09 15:06:45 -05:00
|
|
|
|
2019-05-01 19:12:52 -04:00
|
|
|
This is a thin wrapper around `use-package', and is ignored if the NAME package
|
|
|
|
is disabled by the user (with `package!').
|
2019-03-09 15:06:45 -05:00
|
|
|
|
2019-05-01 19:12:52 -04:00
|
|
|
See `use-package' to see what properties can be provided. Doom adds support for
|
|
|
|
two extra properties:
|
2019-03-09 15:06:45 -05:00
|
|
|
|
|
|
|
:after-call SYMBOL|LIST
|
|
|
|
Takes a symbol or list of symbols representing functions or hook variables.
|
|
|
|
The first time any of these functions or hooks are executed, the package is
|
2019-10-03 14:51:08 -04:00
|
|
|
loaded.
|
2019-03-09 15:06:45 -05:00
|
|
|
|
|
|
|
:defer-incrementally SYMBOL|LIST|t
|
|
|
|
Takes a symbol or list of symbols representing packages that will be loaded
|
|
|
|
incrementally at startup before this one. This is helpful for large packages
|
|
|
|
like magit or org, which load a lot of dependencies on first load. This lets
|
|
|
|
you load them piece-meal during idle periods, so that when you finally do need
|
2019-10-03 14:51:08 -04:00
|
|
|
the package, it'll load quicker.
|
2019-03-09 15:06:45 -05:00
|
|
|
|
|
|
|
NAME is implicitly added if this property is present and non-nil. No need to
|
2019-10-03 14:51:08 -04:00
|
|
|
specify it. A value of `t' implies NAME."
|
2019-07-24 16:53:33 +02:00
|
|
|
(declare (indent 1))
|
2019-02-22 01:48:59 -05:00
|
|
|
(unless (or (memq name doom-disabled-packages)
|
2019-05-01 19:12:52 -04:00
|
|
|
;; At compile-time, use-package will forcibly load packages to
|
|
|
|
;; prevent compile-time errors. However, if a Doom user has
|
|
|
|
;; disabled packages you get file-missing package errors, so it's
|
|
|
|
;; necessary to check for packages at compile time:
|
2019-02-22 01:48:59 -05:00
|
|
|
(and (bound-and-true-p byte-compile-current-file)
|
|
|
|
(not (locate-library (symbol-name name)))))
|
2019-03-06 00:26:33 -05:00
|
|
|
`(use-package ,name ,@plist)))
|
2018-06-11 23:18:15 +02:00
|
|
|
|
2019-07-23 12:44:03 +02:00
|
|
|
(defmacro use-package-hook! (package when &rest body)
|
|
|
|
"Reconfigures a package's `use-package!' block.
|
2018-06-11 23:18:15 +02:00
|
|
|
|
2019-10-01 17:41:25 -04:00
|
|
|
This macro must be used *before* PACKAGE's `use-package!' block. Often, this
|
|
|
|
means using it from your DOOMDIR/init.el.
|
2018-06-11 23:18:15 +02:00
|
|
|
|
|
|
|
Under the hood, this uses use-package's `use-package-inject-hooks'.
|
|
|
|
|
|
|
|
PACKAGE is a symbol; the package's name.
|
|
|
|
WHEN should be one of the following:
|
|
|
|
:pre-init :post-init :pre-config :post-config
|
|
|
|
|
2019-10-01 17:41:25 -04:00
|
|
|
WARNINGS:
|
|
|
|
- The use of this macro is more often than not a code smell. Use it as last
|
|
|
|
resort. There is almost always a better alternative.
|
|
|
|
- If you are using this solely for :post-config, stop! `after!' is much better.
|
|
|
|
- If :pre-init or :pre-config hooks return nil, the original `use-package!''s
|
|
|
|
:init/:config block (respectively) is overwritten, so remember to have them
|
|
|
|
return non-nil (or exploit that to overwrite Doom's config)."
|
2018-06-11 23:18:15 +02:00
|
|
|
(declare (indent defun))
|
|
|
|
(unless (memq when '(:pre-init :post-init :pre-config :post-config))
|
2019-07-23 12:44:03 +02:00
|
|
|
(error "'%s' isn't a valid hook for use-package-hook!" when))
|
2018-06-11 23:18:15 +02:00
|
|
|
`(progn
|
|
|
|
(setq use-package-inject-hooks t)
|
2019-07-26 19:57:13 +02:00
|
|
|
(add-hook ',(intern (format "use-package--%s--%s-hook"
|
|
|
|
package
|
|
|
|
(substring (symbol-name when) 1)))
|
|
|
|
(lambda () ,@body)
|
|
|
|
'append)))
|
2018-06-11 23:18:15 +02:00
|
|
|
|
2019-04-21 19:35:27 -04:00
|
|
|
(defmacro require! (category module &rest flags)
|
|
|
|
"Loads the CATEGORY MODULE module with FLAGS.
|
|
|
|
|
|
|
|
CATEGORY is a keyword, MODULE is a symbol and FLAGS are symbols.
|
|
|
|
|
|
|
|
(require! :lang php +lsp)
|
|
|
|
|
|
|
|
This is for testing and internal use. This is not the correct way to enable a
|
|
|
|
module."
|
2019-09-03 00:41:03 -04:00
|
|
|
`(let ((doom-modules (or ,doom-modules (doom-modules)))
|
2019-04-21 19:35:27 -04:00
|
|
|
(module-path (doom-module-locate-path ,category ',module)))
|
2018-09-25 23:52:20 -04:00
|
|
|
(doom-module-set
|
|
|
|
,category ',module
|
2019-04-24 18:07:17 -04:00
|
|
|
(let ((plist (doom-module-get ,category ',module)))
|
|
|
|
,(when flags
|
|
|
|
`(plist-put plist :flags `,flags))
|
|
|
|
(unless (plist-member plist :path)
|
|
|
|
(plist-put plist :path ,(doom-module-locate-path category module)))
|
|
|
|
plist))
|
2018-06-23 22:23:35 +02:00
|
|
|
(if (directory-name-p module-path)
|
|
|
|
(condition-case-unless-debug ex
|
2019-04-21 19:35:27 -04:00
|
|
|
(let ((doom--current-module ',(cons category module))
|
|
|
|
(doom--current-flags ',flags))
|
2018-06-23 22:23:35 +02:00
|
|
|
(load! "init" module-path :noerror)
|
:boom: revise advice naming convention (1/2)
This is first of three big naming convention updates that have been a
long time coming. With 2.1 on the horizon, all the breaking updates will
batched together in preparation for the long haul.
In this commit, we do away with the asterix to communicate that a
function is an advice function, and we replace it with the '-a' suffix.
e.g.
doom*shut-up -> doom-shut-up-a
doom*recenter -> doom-recenter-a
+evil*static-reindent -> +evil--static-reindent-a
The rationale behind this change is:
1. Elisp's own formatting/indenting tools would occasionally struggle
with | and * (particularly pp and cl-prettyprint). They have no
problem with / and :, fortunately.
2. External syntax highlighters (like pygmentize, discord markdown or
github markdown) struggle with it, sometimes refusing to highlight
code beyond these symbols.
3. * and | are less expressive than - and -- in communicating the
intended visibility, versatility and stability of a function.
4. It complicated the regexps we must use to search for them.
5. They were arbitrary and over-complicated to begin with, decided
on haphazardly way back when Doom was simply "my private config".
Anyhow, like how predicate functions have the -p suffix, we'll adopt the
-a suffix for advice functions, -h for hook functions and -fn for
variable functions.
Other noteable changes:
- Replaces advice-{add,remove}! macro with new def-advice!
macro. The old pair weren't as useful. The new def-advice! saves on a
lot of space.
- Removed "stage" assertions to make sure you were using the right
macros in the right place. Turned out to not be necessary, we'll
employ better checks later.
2019-07-18 15:42:52 +02:00
|
|
|
(load! "config" module-path :noerror))
|
2018-06-23 22:23:35 +02:00
|
|
|
('error
|
|
|
|
(lwarn 'doom-modules :error
|
|
|
|
"%s in '%s %s' -> %s"
|
|
|
|
(car ex) ,category ',module
|
|
|
|
(error-message-string ex))))
|
|
|
|
(warn 'doom-modules :warning "Couldn't find module '%s %s'"
|
|
|
|
,category ',module))))
|
2018-06-11 23:18:15 +02:00
|
|
|
|
2018-07-30 23:53:05 +02:00
|
|
|
(defmacro featurep! (category &optional module flag)
|
2019-04-20 02:17:51 -04:00
|
|
|
"Returns t if CATEGORY MODULE is enabled.
|
|
|
|
|
|
|
|
If FLAG is provided, returns t if CATEGORY MODULE has FLAG enabled.
|
2018-06-11 23:18:15 +02:00
|
|
|
|
|
|
|
(featurep! :config default)
|
|
|
|
|
|
|
|
Module FLAGs are set in your config's `doom!' block, typically in
|
|
|
|
~/.emacs.d/init.el. Like so:
|
|
|
|
|
|
|
|
:config (default +flag1 -flag2)
|
|
|
|
|
2019-04-20 02:17:51 -04:00
|
|
|
CATEGORY and MODULE can be omitted When this macro is used from inside a module
|
|
|
|
(except your DOOMDIR, which is a special moduel). e.g. (featurep! +flag)"
|
2018-07-30 23:53:05 +02:00
|
|
|
(and (cond (flag (memq flag (doom-module-get category module :flags)))
|
|
|
|
(module (doom-module-p category module))
|
|
|
|
(doom--current-flags (memq category doom--current-flags))
|
2019-07-22 19:04:03 +02:00
|
|
|
((let ((module (doom-module-from-path)))
|
|
|
|
(unless module
|
2019-10-26 02:13:40 -04:00
|
|
|
(error "(featurep! %s %s %s) couldn't figure out what module it was called from (in %s)"
|
|
|
|
category module flag (file!)))
|
2019-07-22 19:04:03 +02:00
|
|
|
(memq category (doom-module-get (car module) (cdr module) :flags)))))
|
2018-07-29 02:46:18 +02:00
|
|
|
t))
|
2018-06-11 23:18:15 +02:00
|
|
|
|
2019-07-22 18:57:17 +02:00
|
|
|
(defmacro after! (package &rest body)
|
|
|
|
"Evaluate BODY after PACKAGE have loaded.
|
2019-05-01 19:12:52 -04:00
|
|
|
|
2019-07-22 18:57:17 +02:00
|
|
|
PACKAGE is a symbol or list of them. These are package names, not modes,
|
Refactor after! macro
The trouble with with-eval-after-load is it arranges for the body to be
byte-compiled, whereas eval-after-load does not. I won't go into how
they do that here, but it causes us some trouble:
Macro calls in with-eval-after-load are eagerly (immediately) expanded
at startup, whether or not the package or macro is available and
regardless of its execution path.
This sucks for Doom because, when expanded, autoloaded macros will be
loaded, along with whatever baggage they've got with them, and this
happens long before they're actually used. We also can't guarantee those
macros are available at startup, which will cause void-function errors
when the interpreter later treats them like an ordinary function call.
So, the simple fix is to pass a quoted body form to eval-after-load
instead of the closure that with-eval-after-load will wrap it in. This
means the body won't get byte-compiled if we compile our config, but in
exchange, macros stay lazy-loaded until they're finally needed!
Wonderful.
2019-07-22 14:43:58 +02:00
|
|
|
functions or variables. It can be:
|
2019-05-01 19:12:52 -04:00
|
|
|
|
|
|
|
- An unquoted package symbol (the name of a package)
|
|
|
|
(after! helm BODY...)
|
|
|
|
- An unquoted list of package symbols (i.e. BODY is evaluated once both magit
|
|
|
|
and git-gutter have loaded)
|
|
|
|
(after! (magit git-gutter) BODY...)
|
Refactor after! macro
The trouble with with-eval-after-load is it arranges for the body to be
byte-compiled, whereas eval-after-load does not. I won't go into how
they do that here, but it causes us some trouble:
Macro calls in with-eval-after-load are eagerly (immediately) expanded
at startup, whether or not the package or macro is available and
regardless of its execution path.
This sucks for Doom because, when expanded, autoloaded macros will be
loaded, along with whatever baggage they've got with them, and this
happens long before they're actually used. We also can't guarantee those
macros are available at startup, which will cause void-function errors
when the interpreter later treats them like an ordinary function call.
So, the simple fix is to pass a quoted body form to eval-after-load
instead of the closure that with-eval-after-load will wrap it in. This
means the body won't get byte-compiled if we compile our config, but in
exchange, macros stay lazy-loaded until they're finally needed!
Wonderful.
2019-07-22 14:43:58 +02:00
|
|
|
- An unquoted, nested list of compound package lists, using any combination of
|
|
|
|
:or/:any and :and/:all
|
2019-05-01 19:12:52 -04:00
|
|
|
(after! (:or package-a package-b ...) BODY...)
|
|
|
|
(after! (:and package-a package-b ...) BODY...)
|
|
|
|
(after! (:and package-a (:or package-b package-c) ...) BODY...)
|
Refactor after! macro
The trouble with with-eval-after-load is it arranges for the body to be
byte-compiled, whereas eval-after-load does not. I won't go into how
they do that here, but it causes us some trouble:
Macro calls in with-eval-after-load are eagerly (immediately) expanded
at startup, whether or not the package or macro is available and
regardless of its execution path.
This sucks for Doom because, when expanded, autoloaded macros will be
loaded, along with whatever baggage they've got with them, and this
happens long before they're actually used. We also can't guarantee those
macros are available at startup, which will cause void-function errors
when the interpreter later treats them like an ordinary function call.
So, the simple fix is to pass a quoted body form to eval-after-load
instead of the closure that with-eval-after-load will wrap it in. This
means the body won't get byte-compiled if we compile our config, but in
exchange, macros stay lazy-loaded until they're finally needed!
Wonderful.
2019-07-22 14:43:58 +02:00
|
|
|
Without :or/:any/:and/:all, :and/:all are implied.
|
2019-05-01 19:12:52 -04:00
|
|
|
|
Refactor after! macro
The trouble with with-eval-after-load is it arranges for the body to be
byte-compiled, whereas eval-after-load does not. I won't go into how
they do that here, but it causes us some trouble:
Macro calls in with-eval-after-load are eagerly (immediately) expanded
at startup, whether or not the package or macro is available and
regardless of its execution path.
This sucks for Doom because, when expanded, autoloaded macros will be
loaded, along with whatever baggage they've got with them, and this
happens long before they're actually used. We also can't guarantee those
macros are available at startup, which will cause void-function errors
when the interpreter later treats them like an ordinary function call.
So, the simple fix is to pass a quoted body form to eval-after-load
instead of the closure that with-eval-after-load will wrap it in. This
means the body won't get byte-compiled if we compile our config, but in
exchange, macros stay lazy-loaded until they're finally needed!
Wonderful.
2019-07-22 14:43:58 +02:00
|
|
|
This is a wrapper around `eval-after-load' that:
|
|
|
|
|
|
|
|
1. Suppresses warnings for disabled packages at compile-time
|
2019-07-22 18:57:17 +02:00
|
|
|
2. No-ops for package that are disabled by the user (via `package!')
|
|
|
|
3. Supports compound package statements (see below)
|
Refactor after! macro
The trouble with with-eval-after-load is it arranges for the body to be
byte-compiled, whereas eval-after-load does not. I won't go into how
they do that here, but it causes us some trouble:
Macro calls in with-eval-after-load are eagerly (immediately) expanded
at startup, whether or not the package or macro is available and
regardless of its execution path.
This sucks for Doom because, when expanded, autoloaded macros will be
loaded, along with whatever baggage they've got with them, and this
happens long before they're actually used. We also can't guarantee those
macros are available at startup, which will cause void-function errors
when the interpreter later treats them like an ordinary function call.
So, the simple fix is to pass a quoted body form to eval-after-load
instead of the closure that with-eval-after-load will wrap it in. This
means the body won't get byte-compiled if we compile our config, but in
exchange, macros stay lazy-loaded until they're finally needed!
Wonderful.
2019-07-22 14:43:58 +02:00
|
|
|
4. Prevents eager expansion pulling in autoloaded macros all at once"
|
2019-05-01 19:12:52 -04:00
|
|
|
(declare (indent defun) (debug t))
|
2019-07-22 18:57:17 +02:00
|
|
|
(if (symbolp package)
|
|
|
|
(unless (memq package (bound-and-true-p doom-disabled-packages))
|
Refactor after! macro
The trouble with with-eval-after-load is it arranges for the body to be
byte-compiled, whereas eval-after-load does not. I won't go into how
they do that here, but it causes us some trouble:
Macro calls in with-eval-after-load are eagerly (immediately) expanded
at startup, whether or not the package or macro is available and
regardless of its execution path.
This sucks for Doom because, when expanded, autoloaded macros will be
loaded, along with whatever baggage they've got with them, and this
happens long before they're actually used. We also can't guarantee those
macros are available at startup, which will cause void-function errors
when the interpreter later treats them like an ordinary function call.
So, the simple fix is to pass a quoted body form to eval-after-load
instead of the closure that with-eval-after-load will wrap it in. This
means the body won't get byte-compiled if we compile our config, but in
exchange, macros stay lazy-loaded until they're finally needed!
Wonderful.
2019-07-22 14:43:58 +02:00
|
|
|
(list (if (or (not (bound-and-true-p byte-compile-current-file))
|
2019-07-22 18:57:17 +02:00
|
|
|
(require package nil 'noerror))
|
Refactor after! macro
The trouble with with-eval-after-load is it arranges for the body to be
byte-compiled, whereas eval-after-load does not. I won't go into how
they do that here, but it causes us some trouble:
Macro calls in with-eval-after-load are eagerly (immediately) expanded
at startup, whether or not the package or macro is available and
regardless of its execution path.
This sucks for Doom because, when expanded, autoloaded macros will be
loaded, along with whatever baggage they've got with them, and this
happens long before they're actually used. We also can't guarantee those
macros are available at startup, which will cause void-function errors
when the interpreter later treats them like an ordinary function call.
So, the simple fix is to pass a quoted body form to eval-after-load
instead of the closure that with-eval-after-load will wrap it in. This
means the body won't get byte-compiled if we compile our config, but in
exchange, macros stay lazy-loaded until they're finally needed!
Wonderful.
2019-07-22 14:43:58 +02:00
|
|
|
#'progn
|
|
|
|
#'with-no-warnings)
|
|
|
|
(let ((body (macroexp-progn body)))
|
2019-07-22 18:57:17 +02:00
|
|
|
`(if (featurep ',package)
|
Refactor after! macro
The trouble with with-eval-after-load is it arranges for the body to be
byte-compiled, whereas eval-after-load does not. I won't go into how
they do that here, but it causes us some trouble:
Macro calls in with-eval-after-load are eagerly (immediately) expanded
at startup, whether or not the package or macro is available and
regardless of its execution path.
This sucks for Doom because, when expanded, autoloaded macros will be
loaded, along with whatever baggage they've got with them, and this
happens long before they're actually used. We also can't guarantee those
macros are available at startup, which will cause void-function errors
when the interpreter later treats them like an ordinary function call.
So, the simple fix is to pass a quoted body form to eval-after-load
instead of the closure that with-eval-after-load will wrap it in. This
means the body won't get byte-compiled if we compile our config, but in
exchange, macros stay lazy-loaded until they're finally needed!
Wonderful.
2019-07-22 14:43:58 +02:00
|
|
|
,body
|
|
|
|
;; We intentionally avoid `with-eval-after-load' to prevent
|
|
|
|
;; eager macro expansion from pulling (or failing to pull) in
|
|
|
|
;; autoloaded macros/packages.
|
2019-07-22 18:57:17 +02:00
|
|
|
(eval-after-load ',package ',body)))))
|
|
|
|
(let ((p (car package)))
|
|
|
|
(cond ((not (keywordp p))
|
2019-07-23 01:27:20 +02:00
|
|
|
`(after! (:and ,@package) ,@body))
|
2019-07-22 18:57:17 +02:00
|
|
|
((memq p '(:or :any))
|
Refactor after! macro
The trouble with with-eval-after-load is it arranges for the body to be
byte-compiled, whereas eval-after-load does not. I won't go into how
they do that here, but it causes us some trouble:
Macro calls in with-eval-after-load are eagerly (immediately) expanded
at startup, whether or not the package or macro is available and
regardless of its execution path.
This sucks for Doom because, when expanded, autoloaded macros will be
loaded, along with whatever baggage they've got with them, and this
happens long before they're actually used. We also can't guarantee those
macros are available at startup, which will cause void-function errors
when the interpreter later treats them like an ordinary function call.
So, the simple fix is to pass a quoted body form to eval-after-load
instead of the closure that with-eval-after-load will wrap it in. This
means the body won't get byte-compiled if we compile our config, but in
exchange, macros stay lazy-loaded until they're finally needed!
Wonderful.
2019-07-22 14:43:58 +02:00
|
|
|
(macroexp-progn
|
2019-07-22 18:57:17 +02:00
|
|
|
(cl-loop for next in (cdr package)
|
Refactor after! macro
The trouble with with-eval-after-load is it arranges for the body to be
byte-compiled, whereas eval-after-load does not. I won't go into how
they do that here, but it causes us some trouble:
Macro calls in with-eval-after-load are eagerly (immediately) expanded
at startup, whether or not the package or macro is available and
regardless of its execution path.
This sucks for Doom because, when expanded, autoloaded macros will be
loaded, along with whatever baggage they've got with them, and this
happens long before they're actually used. We also can't guarantee those
macros are available at startup, which will cause void-function errors
when the interpreter later treats them like an ordinary function call.
So, the simple fix is to pass a quoted body form to eval-after-load
instead of the closure that with-eval-after-load will wrap it in. This
means the body won't get byte-compiled if we compile our config, but in
exchange, macros stay lazy-loaded until they're finally needed!
Wonderful.
2019-07-22 14:43:58 +02:00
|
|
|
collect `(after! ,next ,@body))))
|
2019-07-22 18:57:17 +02:00
|
|
|
((memq p '(:and :all))
|
|
|
|
(dolist (next (cdr package))
|
Refactor after! macro
The trouble with with-eval-after-load is it arranges for the body to be
byte-compiled, whereas eval-after-load does not. I won't go into how
they do that here, but it causes us some trouble:
Macro calls in with-eval-after-load are eagerly (immediately) expanded
at startup, whether or not the package or macro is available and
regardless of its execution path.
This sucks for Doom because, when expanded, autoloaded macros will be
loaded, along with whatever baggage they've got with them, and this
happens long before they're actually used. We also can't guarantee those
macros are available at startup, which will cause void-function errors
when the interpreter later treats them like an ordinary function call.
So, the simple fix is to pass a quoted body form to eval-after-load
instead of the closure that with-eval-after-load will wrap it in. This
means the body won't get byte-compiled if we compile our config, but in
exchange, macros stay lazy-loaded until they're finally needed!
Wonderful.
2019-07-22 14:43:58 +02:00
|
|
|
(setq body `((after! ,next ,@body))))
|
|
|
|
(car body))))))
|
2019-05-01 19:12:52 -04:00
|
|
|
|
2019-10-31 14:35:24 -04:00
|
|
|
;; DEPRECATED
|
|
|
|
(defmacro def-package! (&rest args)
|
|
|
|
(make-obsolete 'def-package! 'use-package! "2.0.9")
|
|
|
|
(message "`def-package!' is renamed and is now deprecated; use `use-package!' instead")
|
|
|
|
`(use-package! ,@args))
|
|
|
|
|
|
|
|
(defmacro def-package-hook! (&rest args)
|
|
|
|
(make-obsolete 'def-package-hook! 'use-package-hook! "2.0.9")
|
|
|
|
(message "`def-package-hook!' is renamed and is now deprecated; use `use-package-hook!' instead")
|
|
|
|
`(use-package-hook! ,@args))
|
|
|
|
|
2018-06-11 23:18:15 +02:00
|
|
|
(provide 'core-modules)
|
|
|
|
;;; core-modules.el ends here
|