Elpaca:一款 Emacs Lisp 包管理器
elpaca An elisp package manager 项目地址: https://gitcode.com/gh_mirrors/el/elpaca
Elpaca 是一款为 Emacs 编辑器设计的 Lisp 包管理器。它允许用户查找、安装、更新和删除第三方包。Elpaca 是内置的 Emacs 包管理器 package.el 的替代品,提供了多项优势。
1. 项目介绍
Elpaca 的特点包括:
- 异步并行安装包,快速且不会阻塞操作。
- 提供灵活的用户界面,便于查找和操作包。
- 从源代码下载包,方便 elisp 开发。
- 支持数千种 elisp 包(包括 MELPA、NonGNU/GNU ELPA、Org/org-contrib)。
- 方便用户创建自己的 ELPA。
2. 项目快速启动
要安装 Elpaca,请将以下 Emacs Lisp 代码添加到您的 init.el
文件中。确保这部分代码位于任何其他 Elpaca 函数或宏调用之前。
(defvar elpaca-installer-version "0.10")
(defvar elpaca-directory (expand-file-name "elpaca/" user-emacs-directory))
(defvar elpaca-builds-directory (expand-file-name "builds/" elpaca-directory))
(defvar elpaca-repos-directory (expand-file-name "repos/" elpaca-directory))
(defvar elpaca-order '(elpaca :repo "https://github.com/progfolio/elpaca.git" :ref nil :depth 1 :inherit ignore :files '(:defaults "elpaca-test.el" (:exclude "extensions")) :build '(:not elpaca--activate-package)))
(let* ((repo (expand-file-name "elpaca/" elpaca-repos-directory))
(build (expand-file-name "elpaca/" elpaca-builds-directory))
(order (cdr elpaca-order))
(default-directory repo))
(add-to-list 'load-path (if (file-exists-p build) build repo))
(unless (file-exists-p repo)
(make-directory repo t)
(when (<= emacs-major-version 28)
(require 'subr-x))
(condition-case-unless-debug err
(if-let* ((buffer (pop-to-buffer-same-window "*elpaca-bootstrap*" ))
((zerop (apply #'-call-process "git" nil buffer t
(concat "--depth=" depth " --no-single-branch" (plist-get order :repo)) repo)))
((zerop (call-process "git" nil buffer t "checkout" (or (plist-get order :ref) "--"))))
((zerop (call-process emacs nil buffer nil "-Q" "-L" "." "--batch" "--eval" "(byte-recompile-directory \".\" 0 'force)"))))
(progn
(message "%s" (buffer-string))
(kill-buffer buffer))
(error "%s" (with-current-buffer buffer (buffer-string))))
((error) (warn "%s" err) (delete-directory repo 'recursive))))
(unless (require 'elpaca-autoloads nil t)
(require 'elpaca)
(elpaca-generate-autoloads "elpaca" repo)
(load "./elpaca-autoloads"))
(add-hook 'after-init-hook #'-elpaca-process-queues)
(elpaca `(@ ,elpaca-order)))
;; Windows 用户如果不能创建符号链接,则需要注释下面一行以启用 elpaca-no-symlink-mode。
;; (elpaca-no-symlink-mode)
;; 在 early-init 文件中禁用 package.el:
;; (setq package-enable-at-startup nil)
3. 应用案例和最佳实践
以下是一些使用 Elpaca 的案例和最佳实践:
- 使用 elpaca 安装包:将
(elpaca package-name)
添加到你的init.el
文件中。 - 使用 use-package 集成:通过
(elpaca elpaca-use-package)
启用对 use-package 的支持。 - 等待包安装:如果包在初始化文件中使用,可以使用
:wait
选项确保包安装后再继续。
示例:
(use-package evil :ensure t :demand t)
- 配置内置功能:对于需要在初始化阶段立即配置的内置功能,可以不使用
elpaca-use-package
。
示例:
(use-package emacs :ensure nil :config (setq ring-bell-function #'ignore))
4. 典型生态项目
Elpaca 的生态中包括了许多优秀的项目,例如:
- Evil:将 Vim 键绑定带到 Emacs。
- Org Mode:强大的笔记和组织工具。
- Magit:Git 的 Emacs 接口。
这些项目都可以通过 Elpaca 轻松安装和集成到 Emacs 工作流程中。
elpaca An elisp package manager 项目地址: https://gitcode.com/gh_mirrors/el/elpaca
创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考