TomCaps
TomCaps

Reputation: 2527

How to evaluate a piece of elisp code after all install packages are loaded?

I have installed several Emacs packages by M-x install-package. The starter-kit package hide the tool-bar and menu bar of emacs but I want them show back.

I added

(tool-bar-mode t)

in my ~/.emacs file but it seems get evaluated before starter-kit package get loaded.

Where should I put those code if I want evaluate them when all installed packages finished loading ?

Upvotes: 1

Views: 358

Answers (2)

Nicolas Dudebout
Nicolas Dudebout

Reputation: 9262

Have a look at the package.el file, in particular:

(defcustom package-enable-at-startup t
  "Whether to activate installed packages when Emacs starts.
If non-nil, packages are activated after reading the init file
and before `after-init-hook'.  Activation is not done if
`user-init-file' is nil (e.g. Emacs was started with \"-q\").

Even if the value is nil, you can type \\[package-initialize] to
activate the package system at any time."
  :type 'boolean
  :group 'package
 :version "24.1")

So you can call package-initialize early in your .emacs and then overwrite what you need such as tool-bar-mode.

You could also put your overwrites in the after-init-hook.

Upvotes: 1

Trey Jackson
Trey Jackson

Reputation: 74480

Assuming that the starter kit package is in library called "starter-kit", this should work:

(eval-after-load "starter-kit"
   '(tool-bar-mode t))

Upvotes: 2

Related Questions