如何在Windows上优雅的使用Spacemacs(一)

如何在Windows上优雅的使用Spacemacs?这是个问题。

1 Spacemacs是什么?

1.1 Emacs和Vim,一场永无止境的“圣战”

自古以来,江湖中流传着两大门派,Emacs派和Vim派,这两大派之间关于谁是最好用的编辑器这个问题,一直以来,“战争”不断。

1.2 为什么使用Spacemacs?

Spacemacs不是什么新的软件,它只是Emacs的一个配置;但是,为什么这个配置会吸引我呢?

首先他把Emacs和Vim的优点结合起来,使得Spacemacs既有了Emacs超强的可扩展性,又有了Vim的键位的实用性,让我的小拇指得到解放:P。

第二Spacemacs是社区驱动的,这使得他的文档和支持都很完善,遇到问题可以很方便地和其他使用者交流,解决。

基于以上原因,便让我有了学习并使用Spacmacs的动力。

2 Spaceemacs入门

2.1 安装Spacemacs

  1. 安装Emacs 安装Emacs非常简单,从GNU.org下载Eemacs二进制文件,解压后设置好 HOME 环境变量即可。
  2. 从github克隆Spacemacs配置文件
    cd ~
    git clone https://github.com/syl20bnr/spacemacs ~/.emacs.d
  3. 打开emacs/bin目录下runemacs.exe就可以看到spacemacs的界面了

    第一次启动runemacs.exe可能会很慢,因为需要从melpa安装所需要的package,当然这里,我使用了melpa国内的镜像源来提高访问速度,具体方法是,在.spacemacs文件夹的 dotspacemacs/use-init 函数中添加如下代码

    (setq configuration-layer--elpa-archives
    		'(("melpa-cn"."http://elpa.emacs-china.org/melpa/")
    		      ("org-cn"."http://elpa.emacs-china.org/org/")
    		      ("gnu-cn"."http://elpa.emacs-china.org/gnu/")))

    Spacemacs默认生成一个.spaceamcs文件,它是Spacemacs的默认配置文件,当然你也可以在 HOME 目录下建立.spaceamcs.d文件夹,将.spacemacs文件移动到.spaceamcs.d文件夹下,并且更名为 init.el 方便使用 git 管理自己的配置。

3 关于HOME环境变量

On MS-Windows, the installation program addpm.exe adds values for emacs_dir, EMACSLOADPATH, EMACSDATA, EMACSPATH, EMACSDOC, SHELL and TERM to the HKEY_LOCAL_MACHINE section of the system registry, under /Software/GNU/Emacs. It does this because there is no standard place to set environment variables across different versions of Windows. Running addpm.exe is no longer strictly necessary in recent versions of Emacs, but if you are upgrading from an older version, running addpm.exe ensures that you do not have older registry entries from a previous installation, which may not be compatible with the latest version of Emacs.

When Emacs starts, as well as checking the environment, it also checks the System Registry for those variables and for HOME, LANG and PRELOAD_WINSOCK.

To determine the value of those variables, Emacs goes through the following procedure. First, the environment is checked. If the variable is not found there, Emacs looks for registry keys by that name under /Software/GNU/Emacs; first in the HKEY_CURRENT_USER section of the registry, and if not found there, in the HKEY_LOCAL_MACHINE section. Finally, if Emacs still cannot determine the values, compiled-in defaults are used.

In addition to the environment variables above, you can also add many of the settings which on X belong in the .Xdefaults file (see X Resources) to the /Software/GNU/Emacs registry key.

Emacs在启动时按照如下顺序检查环境变量,第一检查环境变量中的HOME变量,如果不存在,则会搜索注册表中HKEY_CURRENT_USER下的/Software/GNU/Emacs中是否存在HOME这一下,如果不存在,则会检查HKEY_LOCAL_MACHINE这一节的相同位置是否存在HOME变量,当然,我们也可以使用.Xdefaults文件来配置HOME目录。

4 Spacemacs在Windows上的优化

由于Emacs是GNU下的一款非常重要的开源软件,一直以来在Linux系统上发展的比较好,后来为了让更多的人使用eamcs,GNU开始发行兼容Windows,Mac的版本,但是要想在Windows上优雅的使用Spacemacs,有些问题还是需要解决的。

4.1 关于中文字体的问题

4.2 以C/S方式运行Spacesmacs

Spacmacs每次打开,都要加载很多package,所以加载速度很慢,每次启动Spacemacs都要等待相当长的时间,所幸Emacs支持以C/S方式运行。 要以C/S方式运行Spacemacs,需要做如下设置;

Last Updated 2018-03-26 周一 17:42.
Render by hexo-renderer-org with Emacs 25.2.1 (Org mode 8.2.10)