ELPA 背后的魔力是什么?
我使用 Aquamacs,并且使用 ELPA 将文件安装在 ~/.emacs.d/elpa 中?
这个ELPA背后有何魔力?我的意思是,如果没有 ELPA,我应该下载软件包并将其安装在特定目录中,然后将这两行添加到 .emacs 中。
(添加到列表'加载路径“PACKAGE_DIRECTORY”)
(需要“包”)
但是,使用 ELPA,我没有看到任何内容添加到 .emacs 或 /Users/smcho/Library/Preferences/Aquamacs Emacs/{Preferences.el,customizations.el} 中。这怎么可能?
添加
这是我在 Aquamacs 中发现的。
- Aquamacs 读取 ~/Preference/Aquamacs Emacs/Preference,它有“(add-to-list 'load-path kitfiles-dir)(require 'init)”,它读取启动套件。
- 启动套件的 init.el 有“(require 'package)(package-initialize)”
- ~/Library/Preferences/Aquamacs Emacs/aquamacs-emacs-starter-kit/vendor 有 package.el
我猜初始化文件是没有改变,但是包管理器读取 ~/.emacs.d/elpd/* 来自动初始化,正如我在每个文件中看到的 ***-autoloads.el 一样。
添加2
对于 emacs 24,似乎该包是预先构建的。我只需要在 .emacs 或 .emacs.d/init.el 中包含这些行即可使 ELPA 正常工作。来自此网站的提示。
(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)))
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.
- Aquamacs reads ~/Preference/Aquamacs Emacs/Preference, and it has "(add-to-list 'load-path kitfiles-dir)(require 'init)", which reads start kit.
- The init.el of start kit has the "(require 'package)(package-initialize)"
- ~/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)))
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
(package-initialize)
将遍历所有已安装的软件包(在~/.emacs.d/elpa/
或类似位置,具体取决于配置),并将它们添加到加载路径。一旦你运行了它,看一下load-path
(Chvload-path
),它将添加所有这些子目录。所以此时,文件加载将使用正常的机制。(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 atload-path
(C-hvload-path
), it will have all those subdirectories added. So at this point, file loading will use the normal mechanisms.您的初始化文件中的某处有一个
(require 'package) (package-initialize)
对。 Package.el 发挥了魔力:)You have a
(require 'package) (package-initialize)
pair somewhere in your initialization files. Package.el does the magic :)