投奔Prelude

好久以来我就是个Emacs用户,但是并不坚定。各种编辑器中都用用,有的时候为了一个特定的功能就会打开Sublime Text。现在我的电脑里装了Emacs、GVim、Sublime Text、VSCode、UltraEdit,这么多编辑器,还不算上PyCharm、IntelliJ一类的IDE。

Emacs和Vim的圣战中我一直站在Emacs一边,多年来也捅咕着自己的配置文件。有一年多,我是在用Spacemacs的,但是我的观念就是绝对不会设置成Vim模式。后来又听说了Doom Emacs,虽然说快一些,但是默认的Vim模式我也是很不喜欢。我喜欢那种按住CTRL键天花乱坠的章鱼感觉。

还有一点,在不同的配置之间切换也是我一直头疼的事情。既然Spacemacs、Doom Emacs只是GNU Emacs配合的一套配置文件,那应该有办法把它们装在不同的目录下,然后用脚本进行切换的。

这个礼拜在RSS上看到https://emacsredux.com/blog/2020/09/15/emacs-prelude-1-0/ 这一篇,原来Prelude终于升级到1.0啦。其中有一句话特别中我的意:

Prelude aims to enhance the classic Emacs experience without deviating a lot from it – e.g. it would never enable something like evil-mode (vim keybindings) by default and so on.

对吗,这才是Emacs该有的样子。Spacemacs还是Emacs吗?好怀疑。文档里有安装方法,可以把这套配置文件安装到一个制定的地方。

$ export PRELUDE_INSTALL_DIR="$HOME/.prelude.emacs.d" && curl -L https://github.com/bbatsov/prelude/raw/master/utils/installer.sh | sh

这样就行了。感觉上就是一个增强版的Vanilla Emacs啦。

后面一个多配置共享的问题,我在StackOverflow上搜到一个答案。https://emacs.stackexchange.com/a/44678,安装一个叫chemacs的工具。

$ git clone https://github.com/plexus/chemacs.git
$ cd chemacs
$ ./install.sh

然后在自己的家目录维护一个 .emacs-profiles.el 文件。在里面列举你的配置。

(("prelude" . ((user-emacs-directory . "~/.prelude.emacs.d")))
 ("spacemacs" . ((user-emacs-directory . "~/spacemacs"))))

最后就可以用相应的配置来启动Emacs啦。

$ emacs --with-profile prelude
$ emacs --with-profile spacemacs 

这样在保留Spacemacs的情况下又可以用Prelude了,很好。