emacsslime

How to stop a package from initializing with package-initialize on emacs (slime)


I've been trying to get slime+sbcl working on my emacs (26.3) for a while. I first installed slime via melpa and that didn't work. I finally got slime able to work on a clean emacs (emacs -q) using quicklisp and the following code:

(load "~/quicklisp/slime-helper.el")
(setq inferior-lisp-program "sbcl")

However, when I put it into my actual init file and run it, it doesn't work. I figured that if I put package-enable-at-startup to nil and commented out package-initialize, that slime works. My guess is that the installed slime through melpa is "overriding" the slime initialization using slime-helper. I can't uninstall slime via melpa because of package dependencies and am worried I might mess something up. But I also need all of my packages to initialize except slime. So I was wondering if there was anyway to initialize all my packages, but suppress the slime package.


Solution

  • I think the easiest method would be to disable the loading of "elpa slime" with package-load-list. See its documentation with C-hv package-load-list Return. In short you'd put something like this in your init file.

    (require 'package)
    (setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3")
    (add-to-list 'package-archives
                 '("melpa" . "https://melpa.org/packages/")
                 '("gnu" . "https://elpa.gnu.org/packages/"))
    (setq package-load-list '((slime nil))) ;; don't load slime
    (package-initialize)
    
    (load (expand-file-name "~/quicklisp/slime-helper.el"))
    (setq inferior-lisp-program "sbcl")
    

    package-initialize will skip loading slime (and manipulating your load-path), allowing the "quicklisp slime" to appear first on your load-path. This may or may not break dependencies loaded by the package system. If they do break, I'd see if quicklisp can manage them and deal with them that way, or I would manually manage them.