LoginSignup
21
21

More than 5 years have passed since last update.

git commit のログをEmacsで書く設定を3行で

Last updated at Posted at 2013-03-17
  • .gitconfigのeditorにemacsclientを設定する。
  • alternate-editorにemacsを設定する。
  • -t を忘れると日本語が入らなかった。

git commitしたときのエディタをemacsにしました。ただemacsclientを使っているのでその辺で詰まったりしたのでメモ書き。

.gitconfigに、emacslientとemacsを両方設定

以下を.gitconfigに追加します。

[core]
    editor = "/usr/local/bin/emacsclient -t" --alternate-editor /usr/local/bin/emacs

homebrewでemacsを入れたので/home/local/bin/以下のemacsを指定します。また普通はemacsclientを使っているので、起動できたらemacsclient→出来なかったら素のemacs とします。

-t を忘れると日本語が入らなかった

最初は"-t"無しでやって日本語が入らず悩みました。emacs起動して英語でログを入力する分にはOKだったけど、日本語入力でNGでした。
manによれば、-t は -tty -nwと同じ意味で、今開いてるターミナルでemacsclientを起動するフラグです。
通常ターミナルで、"-t"無しの場合起動しません。

macmini% /usr/local/bin/emacsclient
/usr/local/bin/emacsclient: file name or argument required
Try `/usr/local/bin/emacsclient --help' for more information

"-t"無しでファイル名付きの場合、Emacsの起動待ち?で止まります。

macmini% emacsclient .git/COMMIT_EDITMSG
Waiting for Emacs...^C  # ここでCtrl+C
macmini% 

gitコマンドからemacsを起動する際、-t無しでファイル名付きのパターンになったのでしょう。

21
21
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
21
21