How are the packages installed with 'package-install'(elpa) in Emacs loaded?
Asked Answered
I

1

0

I have installed some packages by using elpa in my Emacs, but how are they loaded when launching Emacs?

Imparadise answered 26/4, 2014 at 2:57 Comment(0)
H
1

package-install is a part of package.el -- which You can see with describe-function. From package.el documentation:

;; At activation time we will set up the load-path and the info path,
;; and we will load the package's autoloads.  If a package's
;; dependencies are not available, we will not activate that package.

So in every package there's a file

NAME-autoloads.el

and this file is loaded at start up.

The whole package is contained under the package-user-dir:

(setq package-user-dir "~/.emacs.d/site-lisp/package-install")
(require 'package)

Each package also contains NAME-pkg.el with package version and description. For example here're files related to tabbar package:

package-install             # that's my package-user-dir
└── tabbar-2.0.1            # each package dir is in the separate dir
    ├── tabbar-autoloads.el # this file is loaded at start up
    ├── tabbar.el           # the package itself. In this case it is just a single file
    └── tabbar-pkg.el       # information about the package for package managment

To quote the manual: 39.1.1 Summary: Sequence of Actions at Startup:

15. If package-enable-at-startup is non-nil, it calls the function package-initialize to activate any optional Emacs Lisp package that has been installed.

package-initialize is then calls package-activate which in turn calls package-activate-1 which ends with loading NAME-autoload.el:

(load (expand-file-name (concat name "-autoloads") pkg-dir) nil t)
Hui answered 26/4, 2014 at 4:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.