LoginSignup
8
6

More than 5 years have passed since last update.

[Emacs] emacsclient を快適に使うための設定

Posted at

emacsclient ってなに?
どんなことができるの?
と思った人はグーグル先生に教えてもらうといい。
ここではそれを使いやすくするために個人的に使用している設定を書く。

この設定はターミナルで emacs を使用していることを前提とする。

以下のものを ~/.zshrc に追加するべし。

.bashrc でも動く気がする。

起動関数

emacs daemon が起動していなければホームディレクトリで emacs --daemon を実行する。

function estart() {
  if ! emacsclient -e 0 > /dev/null 2>&1; then
    cd > /dev/null 2>&1
    emacs --daemon
    cd - > /dev/null 2>&1
  fi
}

シェルを立ち上げる時に自動で daemon 起動

.zshrc の最後の行にこれを追加する。

estart

エイリアス定義

使いやすくするエイリアスを追加。

ファイルを開く。

alias e='emacsclient -nw'

daemon を止める。

alias ekill="emacsclient -e '(kill-emacs)'"

daemon 再起動。

alias erestart="emacsclient -e '(kill-emacs)' && estart"

EDITOR 変数設定

デフォルトのエディタを emacsclient に変更する。

export EDITOR='emacsclient -nw'

git でも使用する

git commit で立ち上がるエディタも変更。
.gitconfig に追加。

[core]
  editor = emacsclient -nw
8
6
0

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
  3. You can use dark theme
What you can do with signing up
8
6