1
votes

I have set Git's "core.editor" config to "emacsclient" and have an Emacs session running with a server started. When I run "git commit" from a terminal, it opens a new buffer in my Emacs as expected, but this buffer is always in "fundamental mode". It used to open in whatever mode that magit uses to edit commit messages but this is a new computer and I am just not sure how all the pieces work together. It's not even clear to me what mode magit is using since it's a collection of minor modes not a major mode. So I'm a bit stumped how to fix this.

Any help appreciated!

3
Magit uses git-commit mode to write commit messages. You can check if that is installedTheGeorgeous
That's not what I see when I commit from magit, I think it's in text mode with a bunch of minor modes. This is what describe-mode says: "Enabled minor modes: Async-Bytecomp-Package Auto-Composition Auto-Compression Auto-Encryption Auto-Fill Blink-Cursor Diff-Auto-Refine Electric-Indent File-Name-Shadow Font-Lock Git-Commit Global-Font-Lock Global-Git-Commit Ido-Everywhere Line-Number Magit-Auto-Revert Menu-Bar Mouse-Wheel Shell-Dirtrack Tooltip Transient-Mark With-Editor"michiakig
Hmm this is weird. I was going to add that "git commit mode" didn't seem to be installed or available, but it actually is available only AFTER I start using magit in a particular sessionmichiakig

3 Answers

2
votes

I'm not sure what magit uses, but vc should use a variant of log-edit-mode.

(require 'log-edit)
(require 'vc-git)
(add-to-list 'auto-mode-alist '("COMMIT_EDITMSG\\'" . vc-git-log-edit-mode))

It's really weird that I need the requires; there's either a bug in Emacs or I'm doing something weird (though it doesn't seem the least bit weird to me).

1
votes

I had the same problem and found solution here:

https://emacs.stackexchange.com/a/17733/12560

Actually I just had to add

(global-git-commit-mode)

to my init and it worked.

1
votes

As an extension to @bingen's answer, if you are a use-package user,

(use-package git-commit
  :init
  (global-git-commit-mode)
  )

which works even with lazy loading turned on:

(setq
 use-package-always-defer t
 use-package-always-ensure t
 )