[ACCEPTED]-What is "with-eval-after-load" in Emacs Lisp-elisp
* Lisp Changes in Emacs 24.4 ... ** New macro `with-eval-after-load'. This is like the old `eval-after-load', but better behaved.
Emacs 24.4 was released on 20th October 12 2014.
eval-after-load is considered ill-behaved because 11 it is a function, not a macro, and thus 10 requires the code inside it to be quoted, which 9 means that it cannot be byte-compiled. It 8 also accepts only one form, so if you have 7 more than one, you need to use
progn. For example:
(eval-after-load "foo" '(progn (setq foo 42) (setq bar 17)))
The 6 equivalent version with
with-eval-after-load would be:
(with-eval-after-load "foo" (setq foo 42) (setq bar 17))
As noted 5 by Clément in a comment, one disadvantage of
with-eval-after-load is 4 that you cannot rely on macros defined in 3 the module in question, while with
eval-after-load you 2 can be sure that such macros are defined 1 and available to use. This was discussed on emacs-devel.
More Related questions