Magit comes with the minor mode git-commit-mode
, enabled via the entry-point global-git-commit-mode
, which runs the hook and user option git-commit-setup-hook
as its last step. You can add your git-commit-mode
-specific setup code to this as you would any other hook variable:
(add-hook 'git-commit-setup-hook #'my-git-commit-setup-yasnippet)
or
(add-hook 'git-commit-setup-hook
(lambda ()
(do-something-with-yasnippet)))
You could also use the Customize interface to achieve this via M-x customize-option RET git-commit-setup-hook RET
. Either way I recommend you look at the documentation and suggested and already enabled hook functions reported by Customize for this hook.
The setup code for git-commit-mode
also enables an arbitrary major mode which controls the overall editing behaviour for commit messages. This mode is determined by the user option git-commit-major-mode
. Thus the hook for whichever major mode you specify could offer another means of running custom setup code.
git-commit-setup-hook
. – Basil May 21 '17 at 20:36