3

I'd like to configure magit so that when I decide to commit my changes I'm shown not only the buffer to edit commit message and the diff of changes but also the magit-process buffer. Is there a way of doing that?

This would help me with my git repos where I have pre-commit hooks defined that return some useful info but don't block the commit.

Ignacy Moryc
  • 185
  • 6

1 Answers1

1

I managed to solve this by using those settings:

(setq magit-diff-auto-show nil) ;; This should be the defult IMHO
(add-hook 'server-switch-hook 'magit-process)

The only problem I got left is that the focus ends in my process buffer and it's not easy (using switch-to-buffer or other-window) to get back to commit message in the hook, as it's messing with the emacs-client that's being used here.

Still this is good enough for me as now I see the output of pre-commit hook when editing the message.

Edit

Following Iqbal's comment I changed my solution to:

(setq magit-diff-auto-show nil)
(add-hook 'git-commit-mode-hook (lambda () (save-selected-window (magit-process))))

which works as a charm!

Ignacy Moryc
  • 185
  • 6
  • 1
    You can wrap the call to magit-process in save-selected-window macro and add it to server-switch-hook like so (add-hook 'server-switch-hook (lambda () (save-selected-window (magit-process)))) . But your solution isn't cleanest since server-switch-hook is not magit specific can be called in other circumstances – Iqbal Ansari Sep 12 '15 at 10:58
  • 1
    git-commit-mode-hook might be more appropriate for your purpose – Iqbal Ansari Sep 12 '15 at 11:10
  • 1
    fyi, this breaks latest magit since magit-process no longer exists - see https://github.com/magit/with-editor/issues/61 – Max Rydahl Andersen Feb 04 '19 at 22:45