logcat
logcat

Reputation: 3454

Emacs as git editor does not load COMMIT_EDITMSG

I am using git (on linux) and want to use emacs as editor. However after git config --global core.editor emacs any git commit open emacs in *scratch* buffer and does not load COMMIT_EDITMSG at all.

How to force them to work with each other? So git commit will open emacs editor with COMMIT_EDITMSG loaded?

Upvotes: 1

Views: 923

Answers (3)

Deve
Deve

Reputation: 4648

The buffer that is displayed on startup is controlled by the variable initial-buffer-choice. In your .emacs file set it to nil:

(custom-set-variables
  ;; ...other variables might be set here
 '(initial-buffer-choice nil))

If you call emacs with emacs <filename> it will now display the file instead of the scratch buffer on startup. This also holds for COMMIT_EDITMSG. If you don't pass a filenam to emacs it will display the scratch buffer.

You might also want to disable the splash screen to be dipslayed in a split screen. To do this add the following line to your .emacs file:

(setq inhibit-splash-screen t)

Upvotes: 0

logcat
logcat

Reputation: 3454

Executing emacs ./.git/COMMIT_EDITMSG had the same behavior (scratch buffer was opened). That's because owner of .emacs.d folder was root. All I need to do is simply change the owner sudo chown -hR logcat:logcat .emacs.d/

Upvotes: 1

abo-abo
abo-abo

Reputation: 20342

If you're on linux, you don't have to touch ~/.gitconfig to change the editor. You can just

export VISUAL=emacsclient

To make this change permanent, add this line to ~/.bashrc.

Upvotes: 0

Related Questions