What's the magic behind the ELPA?

旧时模样 提交于 2020-01-12 14:29:28

问题


I use Aquamacs, and I use ELPA that installs files in ~/.emacs.d/elpa?

What's the magic behind this ELPA? I mean, without ELPA, I should download and install the packages in a specific directory, and add those two lines in .emacs.

(add-to-list 'load-path "PACKAGE_DIRECTORY")
(require 'PACKAGE)

But, with ELPA, I don't see anything added to .emacs or /Users/smcho/Library/Preferences/Aquamacs Emacs/{Preferences.el, customizations.el}. How is this possible?

Added

This is what I found with Aquamacs.

  1. Aquamacs reads ~/Preference/Aquamacs Emacs/Preference, and it has "(add-to-list 'load-path kitfiles-dir)(require 'init)", which reads start kit.
  2. The init.el of start kit has the "(require 'package)(package-initialize)"
  3. ~/Library/Preferences/Aquamacs Emacs/aquamacs-emacs-starter-kit/vendor has the package.el

I guess the initialization files are not changed, but the package manager reads the ~/.emacs.d/elpd/* to initialize automatically, as I see ***-autoloads.el in each of it.

Added2

With emacs 24, it seems that package is pre-built. I need only to have these lines in .emacs or .emacs.d/init.el to get ELPA working. Hints from this site.

(require 'package)
(add-to-list 'package-archives
         '("marmalade" . "http://marmalade-repo.org/packages/"))
(package-initialize)

(when (not package-archive-contents)
  (package-refresh-contents))
(defvar my-packages '(clojure-mode
               nrepl))
(dolist (p my-packages)
  (when (not (package-installed-p p))
    (package-install p)))

回答1:


(package-initialize) will go through all the installed packages (in ~/.emacs.d/elpa/ or similar, depending on configuration), and add them to the load path. One you have run it, take a look at load-path (C-hvload-path), it will have all those subdirectories added. So at this point, file loading will use the normal mechanisms.




回答2:


You have a (require 'package) (package-initialize) pair somewhere in your initialization files. Package.el does the magic :)



来源:https://stackoverflow.com/questions/3550899/whats-the-magic-behind-the-elpa

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!