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

允我心安 提交于 2019-12-08 12:44:08

问题


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


回答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)


来源:https://stackoverflow.com/questions/23306091/how-are-the-packages-installed-with-package-installelpa-in-emacs-loaded

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!