1

Linux Mint 20, Emacs 27.1

In my init.el file I loaded many packages.

But sometime I need to load only some specific packages.

E.g.

emacs -Q and only vertico+marginalia+theme

The question is: How I can start Emacs only with specific packages?

P.S.

Example of my init.el

(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(require 'dired-narrow)


(dired-recent-mode 1)

(add-to-list 'load-path "~/.emacs.d/elpa/dired+")
(require 'dired+)

(require 'highlight-symbol)
1
  • I don't really understand where the issue is. You can name this initialization file "my-specific-init.el" and start emacs with the command "emacs -Q -l my-specific-init.el
    – gigiair
    Sep 4 at 16:59
1

If you use require in your init file, then Emacs must load the package. If you don’t use require, then Emacs doesn’t need to load anything. The mistake most people make is to require every package that they want to use.

99% of the time you can configure any package you want (by setting its variables, for example), without ever requireing the package. The package will not actually be loaded until you start calling any of the functions it defines. Emacs has a big list of autoloaded functions that tells it what files to load when one of them is called.

1
  • +1. Just comment (for other readers) to add that you can also "soft-require" a package, meaning that if it's not in your load-path then it's a no-op instead of raising an error. To do that, add a non-nil 3rd arg: (require 'foo nil t).
    – Drew
    Sep 4 at 15:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.