LoginSignup
8

More than 5 years have passed since last update.

Spacemacsとやらをインストールしてみる

Last updated at Posted at 2016-12-24

はじめに

EmacsのAdvent Calendarが空いていたので、(そして私のクリスマスイブの予定も空いていたので)若輩者で大変恐縮ですが、最近気になっていたSpacemacsの導入記事を書きました。

SpacemacsはEmacsから派生したエディタなのかと思っていたのですが、Emacsのディストリビューションのようです。

公式サイトでは次のように謳っています。

The best editor is neither Emacs nor Vim, It's Emacs+Vim

もしかするとVim vs Emacsのエディタ戦争に終止符を打つ最終兵器となるのでしょうか。

環境

  • macOS Sierra version 10.12.2
  • Homebrew 1.1.2

Emacsインストール

SpacemacsはEmacsがなければ使えないため、homebrewでEmacsをインストールします。24.4以上が必要です。

$ brew tap d12frosted/emacs-plus
$ brew install emacs-plus

$ emacs --version

Spacemacsのインストール

Spacemacsは.emacs.dにcloneするので既存の設定ファイルをリネームしておきます。
.emacsファイルがある人は少ないと思いますが、これがある場合は忘れずにリネームしておかないとSpacemacsは動かないそうです。

$ cd ~
$ mv .emacs.d .emacs.d.bak
$ mv .emacs .emacs.bak

git cloneでインストールします。

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

初回起動

emacs -nwで起動すると、初回起動時に3つの質問をされます。

一つ目はEmacsとvimどちらのキーバインドをメインで使うかです。
私はもちろんEmacsを選択しました。

What is your preferred editing style?
{Among the stars aboard the Evil flagship (vim) | On the planet Emacs in the Holy control tower (emacs)}

Spacemacsを標準構成と最小構成のどちらでインストールするかです。初めてなのでとりあえず標準を選択します。

What distribution of spacemacs would you like to start with?
{The standard distribution, recommended (spacemacs) | A minimalist distribution that you can build on (spacemacs-base)}

補完フレームワークに何を使うかという選択です。

What type of completion framework do you want?
{A heavy one but full-featured (helm) | A lighter one but still very powerful (ivy) | None (not recommended)}

これまではAnythingを使っていたのですが、helmかivyの2択で迷ってしまったので次の記事を参考にしてivyにしました。

君は誰とEmacsる? (補完インターフェイス紹介篇)

もしかしたらNoneを選択してAnythingにする方法もあるのかもしれないのですが、その辺ものちのち調べたいと思います。

最低限のカスタマイズ

~/.emacs.d/init.elにあたるのが~/.spacemacsだそうです。C-m f e dでこの設定ファイルを開くことができます。
dotspacemacs/user-config()init.elに書いていた設定を書きます。

C-hがbackspaceとして動作するように設定を書いてみました。

.spacemacs
(defun dotspacemacs/user-config()
  (define-key global-map "\C-h" 'delete-backward-char)
  )

.spacemacs.spacemacs.d/init.elに記述しても良いそうなのですが、まだ試していません。
spacemacsにはlayerという概念があり、自分用のprivate layerもあるので、その辺の設定をし始めるとディレクトリを作成した方がgit管理しやすそうです。

おわりに

標準では行番号が表示されていないなど、やはり若干のカスタマイズは必要であり、layer等を理解して設定しなければならなそうです。
しかし、最初から補完フレームワークが使えるようになっていたりと、初めてemacsを使う人にとっては労せずにemacsの利便性を引き出せると感じました。

カスタマイズについて調べていましたが、まだ日本語の記事が少ないですね。もっと多くの人が使って日本語で記事を書いていただけたら嬉しいです。

参考

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
What you can do with signing up
8