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.

1 Answer 1

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!

3
  • 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 Commented Sep 12, 2015 at 10:58
  • 1
    git-commit-mode-hook might be more appropriate for your purpose Commented Sep 12, 2015 at 11:10
  • 1
    fyi, this breaks latest magit since magit-process no longer exists - see github.com/magit/with-editor/issues/61 Commented Feb 4, 2019 at 22:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.