Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git commit with emacs as editor under Windows

Tags:

git

emacs

windows

Using git bash in Windows, I set my core.editor to the following:

 c:/program/emacs-24.2/bin/emacs --no-splash -geometry 110x58+200+2

Upon git commit, a new emacs frame opens as expected. The opened buffer has $@ as a name. I cannot save the buffer and exit emacs. Git complains that the commit message was empty.

I have a workaround, which is to set my core.editor to:

c:/program/emacs-24.2/bin/emacs --no-splash -geometry 110x58+200+2 .git/COMMIT_EDITMSG

This works, but with a couple of drawbacks:

  • I must be in the directory that contains the .git folder. It does not work if I am in a child directory.
  • the emacs frame that opens has two windows, one with COMMIT_EDITMSG, one with $@.

Is there a better way to choose emacs as commit editor (besides making it open in the terminal)?

like image 961
Gauthier Avatar asked Mar 11 '13 15:03

Gauthier


2 Answers

I suggest that you either

  • run Emacs as a daemon - but that is, apparently, unix-only, or
  • run Emacs as usual and start the server with M-x server-start RET or add (server-start) to .emacs

and use emacsclient instead of emacs as your core.editor if you insist on running git from the command line (hit C-x # in the client buffer when done editing to pass the control back to git).

However, the best way to use Emacs with git is vc:

In Emacs, type C-x v d your/git/repo/root/dir RET to get the list of modified files, mark those you want to commit with m, type C-x v v to commit them - a buffer for the commit message appears (initialized for you with the ChangeLog entry, if any), edit it, type C-c C-c and you are done.

like image 165
sds Avatar answered Oct 12 '22 15:10

sds


This works for me under msysgit 1.7.11:

git config core.editor '/d/bin/emacs-24.3/bin/emacs.exe'

but when I switched to this:

git config core.editor '/d/bin/emacs-24.3/bin/emacs.exe --no-splash'

I got the same '$@' buffer as you do.

like image 2
sean Avatar answered Oct 12 '22 15:10

sean