ELPA 背后的魔力是什么?

发布于 2024-09-15 15:27:01 字数 1354 浏览 6 评论 0原文

我使用 Aquamacs,并且使用 ELPA 将文件安装在 ~/.emacs.d/elpa 中?

这个ELPA背后有何魔力?我的意思是,如果没有 ELPA,我应该下载软件包并将其安装在特定目录中,然后将这两行添加到 .emacs 中。

(添加到列表'加载路径“PACKAGE_DIRECTORY”)
(需要“包”)

但是,使用 ELPA,我没有看到任何内容添加到 .emacs 或 /Users/smcho/Library/Preferences/Aquamacs Emacs/{Preferences.el,customizations.el} 中。这怎么可能?

添加

这是我在 Aquamacs 中发现的。

  1. Aquamacs 读取 ~/Preference/Aquamacs Emacs/Preference,它有“(add-to-list 'load-path kitfiles-dir)(require 'init)”,它读取启动套件。
  2. 启动套件的 init.el 有“(require 'package)(package-initialize)”
  3. ~/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.

  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)))

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

千纸鹤带着心事 2024-09-22 15:27:01

(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 at load-path (C-hvload-path), it will have all those subdirectories added. So at this point, file loading will use the normal mechanisms.

各自安好 2024-09-22 15:27:01

您的初始化文件中的某处有一个 (require 'package) (package-initialize) 对。 Package.el 发挥了魔力:)

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文