在Emacs中安装了“package-install”(elpa)的软件包是如何加载的? [英] How are the packages installed with 'package-install'(elpa) in Emacs loaded?

查看:996
本文介绍了在Emacs中安装了“package-install”(elpa)的软件包是如何加载的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

解决方案

我在Emacs中使用elpa安装了一些软件包, code> package-install 是 package.el 的一部分,您可以使用 describe-功能。从 package.el 文档:

  ;;在启动时,我们将设置加载路径和信息路径
;;我们将加载软件包的自动加载。如果一个包的
;;依赖关系不可用,我们不会激活该包。

所以在每个包中都有一个文件

  NAME-autoloads.el 



整个包包含在 package-user-dir 下:

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

每个包也包含 NAME-pkg.el 带包版本和说明。例如here.re文件与 tabbar 包相关:



  package-install#这是我的package-user-dir 
└──tabbar-2.0.1#每个包dir都在单独的目录
├ ──tabbar-autoloads.el#这个文件在启动时加载
├──tabbar.el#包本身。在这种情况下,它只是一个文件
└──tabbar-pkg.el#关于包管理的包的信息

引用手册: 39.1.1摘要:启动时的操作顺序


15。如果package-enable-at-startup不为零,它将调用函数package-initialize来激活任何已安装的Emacs Lisp软件包。


package-initialize 然后调用 package-activate ,然后调用 package-activate-1 以加载 NAME-autoload.el 结束:

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


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

解决方案

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)

这篇关于在Emacs中安装了“package-install”(elpa)的软件包是如何加载的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆