LoginSignup
2
2

More than 5 years have passed since last update.

magit でコミットするときに新しいウィンドウを立ち上げないようにする

Last updated at Posted at 2013-10-10

(2019-03-07 追記)

.emacs.d 大掃除をやってて気づいたのですが、このハックは現代の Emacs + magit では不要になっていました。

GNU Emacs 26.1 (build 1, x86_64-apple-darwin18.0.0, Carbon Version 158 AppKit 1671) of 2018-11-18
magit-20190306.413

(以下 2013-10-11 時点での投稿)

2ヶ月ほど前に magit のコミット周りの実装が大きく変わりました。それまではコミットメッセージの入力をミニバッファで行っていましたが、この変更に伴い git-commit-mode というメジャーモードを用いて入力、つまり一つのバッファを占有して行うようになりました。

本来この git-commit-mode は 同じ ウィンドウ内の別バッファに開くことが意図されており、Linux 版ではこの通りの挙動を示します。
しかし、Mac 版 (Cocoa) Emacs では 新しく ウィンドウを開いて(もう一つ Emacs を起動して)そこに git-commit-mode を開くという挙動を示し、大変面倒くさい感じになっていました。

2ヶ月間この挙動に悩まされていましたが、この度改善するための設定を発見したため、ここに共有します。

Mac でも同一ウィンドウ内でコミットアクションを完結させる

/Application に Emacs.app を置いた場合は

init.el
(set-variable 'magit-emacsclient-executable "/Applications/Emacs.app/Contents/MacOS/bin/emacsclient")

Homebrew で Emacs をインストールした場合は

init.el
(set-variable 'magit-emacsclient-executable "/usr/local/Cellar/emacs/24.3/bin/emacsclient")

を init.el などに追記しましょう。

これで次回から git-commit-mode は 同じ ウィンドウ内の別バッファに立ち上がるようになります。c を2回押したあと、ウィンドウを切り替えてメッセージ入れて C-c C-c したら手動でウィンドウを閉じる・・・といった煩わしさから開放されます。

magit-commit.png

Emacs + magit で、さらなる作業効率の向上を!

ついでに僕の .emacs.d は dtan4/dot.emacs.d に置いてあります。

参考

上記挙動に関する Issue #862 に投稿された aisipos 氏の投稿

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