MacOS Sierra に Emacs をインストール

背景

これまでずっと Vi や Vim を使うたびに使い方をググるという非生産的なことをしていたので
エディタのキーバインドをEmacsのキーバインドにしたタイミングで
思い切ってターミナル場で使うエディタをEmacsに変えてみようと思いました

自分用の備忘録としてメモ

参考
[Mac]HomebrewでEmacs導入&エイリアス設定で起動速度UP | vdeep

作業

emacs --version

と打つと

GNU Emacs 22.1.1
Copyright (C) 2007 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.

22.1.1は古いようなので
新しいバージョンのEmacsを入れることに

brew install --with-cocoa --srgb emacs

--with-cocoa GUIアプリも一緒にインストール
--srgb Emacs.appで可愛らしい色が使える
EmacsWiki: Emacs For Mac OS

シンボリックリンクを貼る

ln -s /usr/local/Cellar/emacs/24.5/Emacs.app /Applications

シンボリックリンクってなんだっけ?といつも迷うので
わかりやすい説明(シンボリックリンクとショートカットの違いがよくわかる)

シンボリックリンクの使い方と落とし穴 - Qiita

Emacsがちゃんとインストールされているか確認すると

$ emacs --version
GNU Emacs 22.1.1
Copyright (C) 2007 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.
$ emacsclient --version
emacsclient 22.1

あれっ!
macのデフォルトのEmacを見てるので
ターミナルを再起動 or 別タブを開いて見ると解決

alias e='emacsclient -nw -a ""'
alias e-kill='emacsclient -e "(kill-emacs)"'

bashrc に上の2行を追加
使っているシェルが zsh なので zshrc に書く必要があるかと思ったが bashrc に書いても
zshで反映されていた(詳しいことはわからない)