Reputation: 3226
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
. But I was told that Symbol's function definition is void: helm-mode
after startup emacs.
After reading the manual of Packaging Basics and this answer, I find I still don't understand the mechanism of 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.' and activate
is to 'fully require
'. I know if I change (package-initialize t)
into (package-initialize)
everything will be fine.
I confirm that something like "/Users/gaki/.emacs.d/elpa/helm-20160112.258"
is in load-path
and helm-mode
is autoload
. Isn't it can be autoload and even in the after-init-hook
?
Upvotes: 1
Views: 2003
Reputation: 73266
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'.
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.
I suggest changing (package-initialize t)
to (package-initialize)
.
Note that the documentation you linked to describes the NO-ACTIVATE
argument as "for internal use only".
p.s. 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? What kind of time difference are you actually seeing here? (https://emacs.stackexchange.com/a/19263/454 may help with answering that.)
Upvotes: 2