My .emacs
still uses old-style (pre MELPA, pre package.el) initializations.
Current (this works)
I'll use web-mode
as a concrete example.
If I manually download web-mode.el
and put it in ~/elisp
, then start Emacs (25) with the .emacs
file
(package-initialize) ; Irrelevant here. Added by Emacs.
(setq load-path
(cons "~/elisp" load-path))
(require 'web-mode)
(set-face-attribute 'web-mode-css-at-rule-face nil :foreground "magenta red")
all is well.
I'd like to change this .emacs
to be able to use any machine+account without having to install manually an ~/elisp
on each machine/account.
MELPA + package.el attempt (this doesn't work)
My attempt is:
(require 'package)
(add-to-list 'package-archives
'("MELPA Stable" . "https://stable.melpa.org/packages/") t)
(package-initialize)
(custom-set-variables
'(package-selected-packages
(quote
(web-mode))))
(set-face-attribute 'web-mode-css-at-rule-face nil :foreground "magenta red")
but this fails with
error: Invalid face, web-mode-css-at-rule-face
What am I doing wrong?
Update
When I run package-list-packages
I see
and so it appears that web-mode is installed.
I now have the impression from phil's comment that using package.el + MELPA may not actually spare me from having to download and install elisp packages manually. Please confirm one way or the other.
Post answer
It turns out that this change cannot be completely made. Too many packages are not on MELPA.
package.el
a package manager,package-selected-packages
can therefore not be a MELPA-specific thing.web-mode
was not loaded. Did you do(package-initialize)
? It sounds like you have "installed" it but not loaded it.package-initalize
after your setting ofpackage-selected-packages
. The former activates autoloads provided by packages. If you don't tell it to choose packageweb-mode
until after you tell it to activate the autoloads of installed packages, then perhaps that is your problem. Dunno.