reddit / emacs

with-eval-after-load vs use-package

MhvxvLvJrg · 2022-04-22 18:21
After 1 year with Emacs, I think it’s about the time to refactor my config which consists of multiple elisp files. What are your thoughts about use-package or eval-after-load? Now I’m using the latter, but it feels it’s a little messy, with ‘require’ here and there and not much lazy loaded.
lebensterben · 2022-04-22 18:51
use-package is a high-level abstraction of packages loading and configuration. with-eval-after-load is low level and is not specific to package. you may combine both.
SlowValue · 2022-04-22 19:32
Use `use-package` that's why it was "invented". `use-package` is a DSL (domain specific language) for exactly this (and some more). This DSL stuff (made out of a feature called [Lisp Macros](https://gigamonkeys.com/book/macros-defining-your-own.html)) is one thing, why Lisp is cool. `use-package` is hiding the ugly stuff from you and makes it look pretty. Go for `use-package`!
pwnedary · 2022-04-22 19:37
I do not use `use-package` yet I only have a single explicit `(require ...)` in my config, and that is because everything else gets auto-loaded. The reason why I would discourage use of `use-package` is because configuring Emacs is not just enabling a bunch of packages. Rather you configure features; such as Evil mode, minibuffer completions or IDE aspects; and for each of those tasks you may need multiple packages with intertwining configuration/function definitions. Therefore I think `use-package` stanzas are the wrong grouping and only a local, not global, maximum in terms of neatness.
SlowValue · 2022-04-22 19:46
Every package brings it own settings and keymaps, therefore it is useful to cluster settings which belongs to one package. That makes packages more easily exangable|removable. Intertwining just makes a complex mess, which it does not have to be (in most cases).
pwnedary · 2022-04-22 20:01
> Intertwining just makes a complex mess, which it does not have to be (in most cases). I did not say you should intertwine just for the sake of it.
deaddyfreddy · 2022-04-23 08:33
`:after`