I've been using SLIME mode with the quicklisp slime helper, and I load the package with the following code (in my .emacs):

(load (expand-file-name slime-helper-path))
(setq inferior-lisp-program "sbcl")
(require 'slime-autoloads)

However, I noticed that the load uses a lot of startup time. I'd like to only call that code when I open a lisp file (and not on startup), or when I call the slime function. How could I do that ?

  • 1
    Check out autoload.
    – Dan
    Commented Nov 6, 2017 at 18:58
  • Not too clear (to me). You seem to be saying that (1) you want to use slime before you visit any Lisp file, (2) you cannot use slime without first loading the helper file, and (3) you don't want to load the helper file until you visit a Lisp file. That's sounds logically impossible. Please try to clarify the problem/question.
    – Drew
    Commented Nov 6, 2017 at 19:07
  • @Drew Sorry my question is indeed quite unclear. I only meant (2) and (3). However, Dan's solution with using autoload solves it. Commented Nov 6, 2017 at 19:16

1 Answer 1


Thanks to @Dan for suggesting to use autoload.

Instead of detecting the file type, I binded the load to the slime function, like this:

(autoload 'slime "path/to/slime-helper.el "Launch SLIME" t nil)

Evaluating this expression tells Emacs to automatically load the library slime-helper.el from load-path, when slime is called for the first time—either from Lisp, or interactively with M-x slime.

(modified source)

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.