Emacs 24 Package System Initialization Problems

dot-emacs, emacs, emacs24

Solution

The packages that you install with `package.el` are activated by default after your `.emacs` is loaded. To be able to use them before the end of your `.emacs` you need to activate them by using the commands:

(setq package-enable-at-startup nil)
(package-initialize)

Problem

It seems to me that the new Package system that is built-in on Emacs 24 has some flaws when it comes to properly loading and initializing the installed packages. Recently, I upgraded to Emacs 24.1.1 which was realeased on 6/10/2012 and I have been trying to use the built-in package system and have installed several packages using it, but they all have a similar problem related to autoload and initialization. For example, I use a package called `smex` which provides enhancements for using the `M-x` chord. It requires you to define a key for `M-x`, so I added `(global-set-key (kbd "M-x") 'smex)` in my `init.el` file. But after starting emacs I press the `M-x` chord and I get the message "Symbol's function definition is void: smex" ... If I also put `(require 'smex)` in my init.el file I get the error message "File error: Cannot open load file, smex" Adding the location of smex to the load-path variable makes it work as expected, however, that seems to defeat the whole purpose of having a package system in the first place... Any thoughts? Is there a better way or do we live with this limitation for now?

Original source