If my :config section is entirely wrapped in with-eval-after-load, is that equivalent to simply specifying an :after directive? That is, can I replace this:

(use-package company-tern
  (with-eval-after-load 'company
    (add-to-list 'company-backends 'company-tern)))

with this

(use-package company-tern
  :after company
  (add-to-list 'company-backends 'company-tern))

Am I correct in my understanding that if there is other configuration that isn't inside of the with-eval-after-load then it wouldn't be useful to replace it with an :after directive since that would defer the loading of the entire package just for the subset of the configuration that depends on the feature?

I should note, in the above situation it seems simple enough to just nest company-tern's use-package under company's :config section, since they're logically related. However, my question is for the more general case where the "dependency" doesn't necessarily have a logical connection, or when there is more than one "dependency."

  • From what I understand of use-package's semantics, an alternative (cleaner?) possibility would be to put this (add-to-list ...) line in company's :config. And if you want to defer the loading of the entire company-tern package, you could put (use-package company-tern :config (add-to-list...)) in company's :config.
    – T. Verron
    Commented Jan 20, 2016 at 8:58
  • Thank you for responding @T.Verron! I actually had a larger post/question and I split it up at the request of another user. I forgot to migrate over to this one the fact that I wanted to find a way to avoid nesting use-package inside of the :config. The reason for this doesn't apply to the example I gave, but consider other situations where there is no real logical connection other than using e.g. a function of another package, or when there is more than one such "dependencies," it wouldn't make sense to nest the package under more than one package's :config section after all. Commented Jan 20, 2016 at 9:04
  • Nesting use-packages is not a proper way to handle dependencies indeed. But for situations where the second package provides additional configuration to the first one, it kinda makes sense. Someone wrote blog posts on managing a configuration using use-package (maybe it was the author of the package himself), and he made extensive use of that, for example encapsulating his configuration into "personal" packages.
    – T. Verron
    Commented Jan 20, 2016 at 9:09
  • I agree completely. I'm already doing this for example with evil-related plugins, nesting them under evil's :config. I'm looking for approaches to situations where there isn't really a logical connection. I will clarify my question for other readers. By the way, if you find and link me those posts I would really appreciate it! Commented Jan 20, 2016 at 9:11
  • 2
    Here are a couple : lunaryorn.com/2015/01/06/… sachachua.com/blog/2014/12/emacs-configuration-use-package (the second contains a link to a video demonstration by the author of use-package, but I didn't watch it) Sadly, I cannot find the one post that I had in mind.
    – T. Verron
    Commented Jan 20, 2016 at 9:19

1 Answer 1


Yes, I believe those are equivalent. If there's additional configuration outside of with-eval-after-load, then switching to use :after should be semantically equivalent to moving them inside the with-eval-after-load form and so may change when they are executed. Whether this is a problem or not will depend on the exact configuration details.

Now, I don't know the exact details of how things are implemented, so it's possible that there's some very subtle timing issue, but at least your intuition seems to match mine here.

  • It's good to have a second opinion. Thanks! Commented Jan 20, 2016 at 23:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.