[英]Load and activate of Emacs package.el
I have something like (to be simplify) 我有类似的东西(为简化起见)
(require 'package)
(setq package-archives
'(("org" . "http://orgmode.org/elpa/")
("melpa" . "http://melpa.org/packages/")
("melpa-stable" . "http://stable.melpa.org/packages/")
("gnu" . "http://elpa.gnu.org/packages/")))
(setq package-enable-at-startup nil)
(package-initialize t)
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(let ((default-directory (expand-file-name user-emacs-directory "elpa")))
(normal-top-level-add-subdirs-to-load-path))
(require 'use-package)
(use-package helm
:ensure t
:commands (helm-M-x
helm-mini
helm-find-files
helm-show-kill-ring)
:init
(add-hook 'after-init-hook 'helm-mode)
:config
(helm-autoresize-mode 1))
in my .emacs
. 在我的
.emacs
。 But I was told that Symbol's function definition is void: helm-mode
after startup emacs. 但是有人告诉我
Symbol's function definition is void: helm-mode
启动emacs之后Symbol's function definition is void: helm-mode
。
After reading the manual of Packaging Basics and this answer , I find I still don't understand the mechanism of package.el
. 阅读包装基础手册和这个答案之后 ,我发现我仍然不理解
package.el
的机制。
I notice that the words load
and activate
are used in the manual, I suppose that load
is 'Emacs adds the package's content directory to load-path, and evaluates the autoload definitions in name-autoloads.el.' 我注意到手册中使用了“
load
和“ activate
两个词,我认为“ load
是“ Emacs将软件包的内容目录添加到加载路径,并在name-autoloads.el中评估自动加载定义”。 and activate
is to 'fully require
'. 并
activate
是“完全require
”。 I know if I change (package-initialize t)
into (package-initialize)
everything will be fine. 我知道如果我将
(package-initialize t)
更改为(package-initialize)
一切都会好起来的。
I confirm that something like "/Users/gaki/.emacs.d/elpa/helm-20160112.258"
is in load-path
and helm-mode
is autoload
. 我确认类似
"/Users/gaki/.emacs.d/elpa/helm-20160112.258"
内容位于load-path
而helm-mode
为autoload
。 Isn't it can be autoload and even in the after-init-hook
? 难道它甚至可以在
after-init-hook
自动加载?
A look at the code for package-activate
and its helper package-activate-1
shows that a package's autoloads file is not loaded unless the package has been 'activated'. 查看
package-activate
及其助手package-activate-1
的代码,可以看到除非已“激活”软件包,否则不会加载软件包的自动加载文件。
You've told Emacs not to activate any packages by using (package-initialize t)
, and you've prevented it from activating them after loading your init file with (setq package-enable-at-startup nil)
, so none of your package autoloads are known to Emacs. 您已经告诉Emacs不要使用
(package-initialize t)
来激活任何软件包,并且已经阻止了它在使用(setq package-enable-at-startup nil)
加载init文件后激活它们。软件包自动加载是Emacs已知的。
I suggest changing (package-initialize t)
to (package-initialize)
. 我建议将
(package-initialize t)
更改为(package-initialize)
。
Note that the documentation you linked to describes the NO-ACTIVATE
argument as "for internal use only". 请注意,链接到的文档将
NO-ACTIVATE
参数描述为“仅供内部使用”。
ps Activation does not require
the package features -- there would be no purpose to the autoloads if it did -- so this should not take a very significant amount of time, unless perhaps you have a really large number of packages? PS激活并不
require
的软件包功能部件-就没有目的的自动加载,如果它没有-所以这不应该采取的时间很显著量,除非也许你有一个非常大的包数? What kind of time difference are you actually seeing here? 您在这里实际看到的是哪种时差? ( https://emacs.stackexchange.com/a/19263/454 may help with answering that.)
( https://emacs.stackexchange.com/a/19263/454可能有助于回答。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.