试着在命令行管理 Emacs Package

之前偶然发现 Atom 在命令行下有个 apm - Atom Package Manager,所以就试着给 Emacs 也写了一个 epm - Emacs Package Manager,实际上并不是货真价实的包管理器,只能算是 package.el 的一个命令行前端,用这个名字是因为我想不出更好的了。另外,我只用 Emacs 24.5 和 trunk 测试过,更老版本的 Emacs 很可能不支持。

Repo: https://github.com/xuchunyang/epm

4 个赞

蛮好玩的,只是似乎想不到什么场景下使用…

大概在没用镜像的情况下可以很轻松的 proxychain epm install xxx?

是可以的:

~ $ proxychains4 epm install plur
[proxychains] config file found: /Users/xcy/.proxychains/proxychains.conf
[proxychains] preloading /usr/local/Cellar/proxychains-ng/4.11/lib/libproxychains4.dylib
[proxychains] DLL init: proxychains-ng 4.11
[proxychains] DLL init: proxychains-ng 4.11
[proxychains] DLL init: proxychains-ng 4.11
[proxychains] DLL init: proxychains-ng 4.11
Contacting host: elpa.zilongshanren.com:80
[proxychains] Strict chain  ...  127.0.0.1:1080  ...  elpa.zilongshanren.com:80  ...  OK
Contacting host: elpa.zilongshanren.com:80
Making version-control local to plur-autoloads.el while let-bound!
Generating autoloads for plur.el...
Generating autoloads for plur.el...done
Saving file /Users/xcy/.emacs.d/elpa/plur-20160504.224/plur-autoloads.el...
Wrote /Users/xcy/.emacs.d/elpa/plur-20160504.224/plur-autoloads.el
(No changes need to be saved)
Checking /Users/xcy/.emacs.d/elpa/plur-20160504.224...
Compiling /Users/xcy/.emacs.d/elpa/plur-20160504.224/plur-autoloads.el...
Compiling /Users/xcy/.emacs.d/elpa/plur-20160504.224/plur-pkg.el...
Wrote /Users/xcy/.emacs.d/elpa/plur-20160504.224/plur-pkg.elc
Compiling /Users/xcy/.emacs.d/elpa/plur-20160504.224/plur.el...

In plur-isearch-query-replace:
plur.el:167:51:Warning: reference to free variable `isearch-regexp-function'

In end of data:
plur.el:294:1:Warning: the function `isearch--describe-regexp-mode' is not
    known to be defined.
Wrote /Users/xcy/.emacs.d/elpa/plur-20160504.224/plur.elc
Done (Total of 2 files compiled, 1 skipped)

赞。不过我这里使用有些问题:

⋊> ./epm install helm-ag
Setting ‘package-selected-packages’ temporarily since "emacs -q" would overwrite customizations
Setting ‘package-selected-packages’ temporarily since "emacs -q" would overwrite customizations
Package ‘helm-ag-’ is unavailable

也许跟我的 elpa 路径设置有关:

(setq package-user-dir (format "%s/elpa-%s" user-emacs-directory emacs-version))

Emacs 默认的 ELPA 只有 GNU ELPA,而 helm-ag 不在其中,所以有

Package ‘helm-ag-’ is unavailable

需要使用 GNU ELPA 之外的 ELPA 的话,还得设置 package-archives(一般跟 Emacs 的设置一样),比如 ~/.epm.el 中写入:

我乌龙了,有个残留的 ~/.emacs.d/elpa 没删除,里边正好没有 helm-ag,然后我看 epm list 有结果,就没在 .epm.el 中修改 package-user-dir