Difference between after! and :after

Hey all,

I’m hoping this question isn’t as dumb as my last one.

I’m rewriting my configs from scratch right now because I realized that I was just kind of stumbling my way through with other peoples code and not learning much. I noticed something that I had noticed before, but just ignored. What exactly is the difference programatically between after! here:

(after! package-a
 use-package package-b
  ...)

and :after here:

(use-package package-b
  :after package-a
 ...)

Is one correct and the other isn’t? Or are both correct? Until now I’ve just been using whichever one the tutorial I was using said to use. As far as I can tell, they both seem to work just fine. But I’d like to actually start doing things the right way, and as uniformly as possible.

:after is somewhat misleading: `:after` does not respect `after-load-alist` insertion order · Issue #829 · jwiegley/use-package · GitHub

I would recommend either the after! wrapper:

(after! package-a
  (use-package! package-b
    :config
    …))

or:

(use-package! package-b
  :defer t
  :init (after! package-a (require 'package-b))
  :config
  …)

Those are effectively identical. Use whichever you prefer aesthetically.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.