简体   繁体   English

如何在Emacs中使用“ package-install”(elpa)安装的软件包被加载?

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

我已经在Emacs中使用elpa安装了一些软件包,但是在启动Emacs时如何加载它们?

package-install is a part of package.el -- which You can see with describe-function . package-installpackage.el的一部分-您可以通过describe-function查看。 From package.el documentation: package.el文档中:

;; 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 : 整个软件包都包含在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. 每个软件包还包含带有软件包版本和描述的NAME-pkg.el For example here're files related to tabbar package: 比如我这里还有文件相关tabbar包:

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 : 引用该手册: 39.1.1摘要:启动时的操作顺序

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. 15.如果package-enable-at-startup为非nil,它将调用函数package-initialize激活任何已安装的可选Emacs Lisp软件包。

package-initialize is then calls package-activate which in turn calls package-activate-1 which ends with loading NAME-autoload.el : 然后, package-initialize调用package-activate ,后者依次调用package-activate-1 ,最后以加载NAME-autoload.el结束:

(load (expand-file-name (concat name "-autoloads") pkg-dir) nil t)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM