Is `with-eval-after-load’ Always A Bad Idea?


It usually is.

My own experience has only been to use it when I don’t understand the load order and want to “just make it work”. Very pragmatic and in the long run it has to change.

According to the manual:

Normally, well-designed Lisp programs should not use with-eval-after-load.

Its great to be normal.

Addendum: 2019-09-09

Thank you Phil for pointing out the inaccuracy in this post. I’d written the wrong thing down and it totally changed the meaning of the post. The title had been “Is Are Load Hooks Always A Bad Idea?” and I changed it to “Is `with-eval-after-load’ Always A Bad Idea?”

2 thoughts on “Is `with-eval-after-load’ Always A Bad Idea?”

  1. Curious. I think of “load hooks” as being specifically the likes of: (apropos-variable ‘(“-load-hook”))

    In any case, without quoting the *rest* of that paragraph in the manual, you are definitely losing context!

    > Normally, well-designed Lisp programs should not use with-eval-after-load. If you need to examine and set the variables defined in another library (those meant for outside use), you can do it immediately—there is no need to wait until the library is loaded. If you need to call functions defined by that library, you should load the library, preferably with require

    with-eval-after-load is indeed for other scenarios than those mentioned — but sometimes that’s exactly what you want, and it is certainly not bad practice to use it when it is the appropriate thing.

Leave a Reply

Your email address will not be published. Required fields are marked *