fix(lib): preserve package order in after! macro

Prior to this, (after! (a b) ...) would expand to

  (after! b
    (after! a
      ...))

After this, it expands to

  (after! a
    (after! b
      ...))

This fixes load order issues with packages whose deferred configs are
nested, such as org and ob-ditaa.

Ref https://www.reddit.com/r/emacs/comments/pp3sye/hd311nz
This commit is contained in:
Henrik Lissner 2021-09-16 20:16:54 +02:00
parent 650f7a82e3
commit 2c5cc752ff

View file

@ -378,16 +378,14 @@ This is a wrapper around `eval-after-load' that:
;; macros/packages.
`(eval-after-load ',package ',(macroexp-progn body))))
(let ((p (car package)))
(cond ((not (keywordp p))
`(after! (:and ,@package) ,@body))
((memq p '(:or :any))
(cond ((memq p '(:or :any))
(macroexp-progn
(cl-loop for next in (cdr package)
collect `(after! ,next ,@body))))
((memq p '(:and :all))
(dolist (next (cdr package))
(setq body `((after! ,next ,@body))))
(car body))))))
(dolist (next (reverse (cdr package)) (car body))
(setq body `((after! ,next ,@body)))))
(`(after! (:and ,@package) ,@body))))))
(defun doom--handle-load-error (e target path)
(let* ((source (file-name-sans-extension target))