江湖夜雨十年灯

ubuntu 下的 spacemacs 安装

李二花 / 2020-03-10


关键词:ubuntu, spacemacs

ubuntu 下安装 spacemacs

spacemacs 一直是我非常喜欢的编辑器,我使用他进行 org 的编辑和查看。

就安装来说,spacemacs github 上已经说的很清楚了,但是在实际的操作过程中,会有一些需要注意的地方

首先就是需要安装 emacs, 版本需要大于 26,安装完之后按照 github 的步骤,在 linux 上安装

Default installation
If you have an existing Emacs configuration, back it up first by running the following code in your terminal:

cd ~
mv .emacs.d .emacs.d.bak
mv .emacs .emacs.bak
Don't forget to backup and remove the ~/.emacs file. Otherwise Spacemacs WILL NOT be able to load. Because that file prevents Emacs from loading the proper initialization file.

Clone the repository with Git:

git clone https://github.com/syl20bnr/spacemacs ~/.emacs.d
Or

git clone --depth 1 https://github.com/syl20bnr/spacemacs ~/.emacs.d
In case you have a limited internet connection or speed.

master is the stable branch and it is immutable, DO NOT make any modification to it or you will break the update mechanism. If you want to fork Spacemacs safely, use the develop branch where you'll handle updates manually.

Note for Windows users If you use windows, then you'll have to modify the git command by inserting the correct path to your .emacs.d folder. The dot before the folder means that it's hidden. You'll have to search for hidden files to find the folder. When you have found the folder, substitute the original path with the correct one. The proper code would look something like this:

git clone https://github.com/syl20bnr/spacemacs /path/to/your/.emacs.d
(Optional) Install the default fonts

It's recommended to install Source Code Pro by Adobe, as the default font. It ensures that, for example the symbols on the modeline (bottom bar) looks correct. It's also recommended to use a "Fallback font". These depend on the system:

GNU/Linux: NanumGothic (package named fonts-nanum on Debian, for example)
macOS: Arial Unicode MS
Windows: MS Gothic or Lucida Sans Unicode
If the modeline doesn't look similar to the picture at the top of this page, then make sure you have the correct fallback font installed.

If you're running in a terminal then you'll also need to change the terminals font settings.

Launch Emacs. Spacemacs will automatically install the packages it requires. There is a well-known issue with some GPG keys having expired end of 2019. This can be fixed by upgrading to Emacs 26.3 or above or by manually adding the new keys using something like:

gpg --homedir ~/.emacs.d/elpa/gnupg --receive-keys 066DAFCB81E42C40
If you have a restrictive firewall it may help to manually specify the keyserver:

gpg --keyserver keyserver.ubuntu.com --homedir ~/.emacs.d/elpa/gnupg/ --receive-keys 066DAFCB81E42C40
Launch Emacs, and answer the questions in the Dotfile wizard installer. If you are new to Emacs and Spacemacs, then it's fine to just accept the default choices. It's easy to try the other choices later, without having to reinstall Spacemacs. They can be changed in the dotfile ~/.spacemacs.

After answering the questions, then Spacemacs starts downloading and installing the packages it requires. When the packages have been installed. Restart Emacs to complete the installation.

Notes: If you are behind a firewall or similar and you get an error regarding package downloads then you may try to disable the HTTPS protocol by starting Emacs with

emacs --insecure
but this should be a last resort because of the security implications.

You can set the dotspacemacs-elpa-https variable to nil in your dotfile ~/.spacemacs but this has the same security implications as the insecure flag. You may also want to clear out your .emacs.d/elpa directory before doing this, so that any corrupted packages you may have downloaded will be re-installed.

error: Package 'package-build-' is unavailable may occur due to heavy network taffic. You can fix it by setting the dotspacemacs-elpa-timeout variable to 70 in your dotfile.

Warning (bytecomp) and other compilation warnings are perfectly normal. If you're curious, you can find out why these occur here.

If the mode-line turns red then be sure to consult the FAQ.


特别注意的是,在启动 emacs 之前,需要修改以下 .emacs.d/init.el 文件里增加如下的配置

;; 使用子龙山人的源来下载 mepla的数据
  (setq configuration-layer--elpa-archives
        '(("melpa-cn" . "http://elpa.zilongshanren.com/melpa/")
          ("org-cn"   . "http://elpa.zilongshanren.com/org/")
          ("gnu-cn"   . "http://elpa.zilongshanren.com/gnu/")))

这样可以保证从国内的源下载对应的安装 layer, 速度不至于太慢。