Files
jcutmirror/docs/zh/elpa.mdx
2024-02-16 13:11:30 +08:00

91 lines
2.9 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
mirrorId: elpa
---
ELPA 是 Emacs 内建包管理器 `package.el` 的软件源,镜像站支持了如下 ELPA
- gnu
- gnu-devel
- melpa
- nongnu
- nongnu-devel
- org
- stable-melpa
根据你的需求,设置 package-archives比如用 GNU ELPA 和 MELPA
```lisp
(setq package-archives '(("gnu" . "https://mirrors.jcut.edu.cn/elpa/gnu/")
("nongnu" . "https://mirrors.jcut.edu.cn/elpa/nongnu/")
("melpa" . "https://mirrors.jcut.edu.cn/elpa/melpa/")))
(package-initialize) ;; You might already have this line
```
### Spacemacs 用户
#### master 分支
添加下面的代码到`.spacemacs`的`dotspacemacs/user-init()`
```lisp
(setq configuration-layer--elpa-archives
'(("melpa-cn" . "https://mirrors.jcut.edu.cn/elpa/melpa/")
("org-cn" . "https://mirrors.jcut.edu.cn/elpa/org/")
("gnu-cn" . "https://mirrors.jcut.edu.cn/elpa/gnu/")))
```
#### develop 分支
使用 `configuration-layer-elpa-archives` 代替原来的 `configuration-layer--elpa-archives` `--` 换成 `-`
```lisp
(setq configuration-layer-elpa-archives
'(("melpa-cn" . "https://mirrors.jcut.edu.cn/elpa/melpa/")
("org-cn" . "https://mirrors.jcut.edu.cn/elpa/org/")
("gnu-cn" . "https://mirrors.jcut.edu.cn/elpa/gnu/")))
```
### Cask 用户
[Cask](https://github.com/cask/cask) 是一个 Emacs Lisp 的项目管理工具。这里还是以 GNU ELPA 和 MELPA 为例,在添加下面的代码到 Cask
```lisp
(source "gnu" "https://mirrors.jcut.edu.cn/elpa/gnu/")
(source "melpa" "https://mirrors.jcut.edu.cn/elpa/melpa/")
```
### 关于 ELPA 的选择
(来自[@xuchunyang](https://github.com/xuchunyang))
假如不清楚需要用哪些 ELPA 的话
- `gnu` 一般是必备的,其它的 elpa 中的包会依赖 `gnu` 中的包
- `nongnu` 建议启用,类似于 `melpa` 但是 Emacs 官方维护的
- `melpa` 滚动升级,收录了的包的数量最大
- `stable-melpa` 依据源码的 TagGit升级数量比 `melpa` 少,因为很多包作者根本不打 Tag
- `org` 仅仅为了 `org-plus-contrib` 这一个包org 重度用户使用
- `gnu-devel` 收录 `gnu` 中的包的开发中版本,一般不必启用(与 `gnu` 的关系类似于 `melpa` 与 `stable-melpa` 的关系)
- `nongnu-devel` 收录 `nongnu` 中的包的开发中版本,一般不必启用
### 上游
本文档参考了 http://elpa.emacs-china.org/ 提供的帮助。
### URL Bug
各个仓库的 URL 末尾一定要加`/`,否则会无法拉取,提示`Failed to download melpa archive`。
事实上,末尾没有`/`的话emacs 会去尝试取以下链接:
```plaintext
https://mirrors.jcut.edu.cn/elpa/melpaarchive-contents
```
而正常的链接应该是
```plaintext
https://mirrors.jcut.edu.cn/elpa/melpa/archive-contents
```
这个是 emacs 自己的 bug。在 https://github.com/melpa/melpa/issues/2139 中有描述。