Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git commits in emacs without changing window layout?

Tags:

git

emacs

I normally work in emacs with the frame split into two side-by-side windows. Committing a change via git (C-x v v) opens a buffer in the other window for the change comment. The problem is that when I finish the comment and type C-c C-c, the window containing the comment is killed along with the VC-log buffer. Then I have to split the frame into two windows again and find the buffer that had been in deleted window.

Is there any way to keep this process (C-x v v [commit message] C-c C-c) from messing up my window layout? I'd be happy for the VC-log to open in the other window and then disappear without changing the window layout, or for the VC-log to temporarily split one of the windows, as long as my original buffer/window layout is restored when I'm done with the commit. I could write a wrapper function for vc-next-action that saves and restores the window configuration, but it seems like there should be a more straightforward way to do this. Any ideas?

like image 549
Asher L. Avatar asked Aug 05 '11 22:08

Asher L.


2 Answers

A quick look through the vc options offered no possibility, but you can advise vc-next-action (bound to C-x v v) with a save-window-excursion that restores the windows

(defadvice vc-next-action (around keep-windows activate)
  (save-window-excursion
    ad-do-it))

There is also winner-mode for general restoring. And if you use git, you definitely should look at magit.

like image 176
Michael Markert Avatar answered Nov 07 '22 20:11

Michael Markert


I was stuck with the same problem. This seem to work.

(defadvice log-edit-done (around keep-windows activate)
  (save-window-excursion
    ad-do-it))

help for C-c C-c in vc-log buffer shows this:

C-c C-c runs the command log-edit-done, which is an interactive compiled Lisp function in `log-edit.el'.

like image 33
kaz Avatar answered Nov 07 '22 20:11

kaz