Please read the documentation of eval-after-load
:
eval-after-load LIBRARY FORM
This function arranges to evaluate form at the end of loading the file LIBRARY, each time LIBRARY is loaded. If LIBRARY is already loaded, it evaluates form right away. Don't forget to quote form!
[…] LIBRARY can also be a feature (i.e., a symbol), in which case form is evaluated at the end of any file where (provide LIBRARY)
is called.
You have to pass the name of the file or library, which defines the major mode, as argument.
While some modes are defined in files of the same name (e.g. clojure-mode
in clojure-mode.el
), many files a different name, especially if the actually define multiple major modes.
emacs-lisp-mode
is defined in lisp-mode.el
, along with some other modes for Emacs Lisp editing (e.g. lisp-mode
as a generic Lisp language mode, or lisp-interaction-mode
for *scratch*
buffers).
Hence, use (eval-after-load 'lisp-mode …
)
Also, you have to give a single sexp as second argument, so you'll likely want to use (eval-after-load 'lisp-mode '(do-something))
, to call the function do-something
.
If you are using a snapshot build of Emacs, use with-eval-after-load
, i.e. (with-eval-after-load 'lisp-mode (do-something))
. It allows for more than a single form, and doesn't require quoting.