I have written a snippet for
git-commit-mode. However when I'm writing a commit message (from Magit), the snippet won't trigger. Does anyone know how to fix this?
I have yasnippet version 20160924.2001, and Emacs 24.5.1.
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.Sign up to join this community
git-commit-mode is a minor-mode but you have limited the snippets to be used with a major-mode
git-commit-mode. Such a major-mode no longer exists, so you have to use a different mechanism to restrict your snippets to "when I edit a commit message".
git-commit-mode is a minor-mode is to allow you to choose the major-mode most suitable for commit messages according to the conventions used by the projects you contribute to. By default this is
text-mode, but if some project uses Markdown or Org-Mode for commit messages, then you can configure that on a per project basis.
Assuming you have some snippets that are appropriate for
git-commit-mode, but not just
text-mode or say
git-commit-mode, then use something like:
(add-hook 'git-commit-mode (lambda () (when (derived-mode-p 'text-mode) (yas-activate-extra-mode 'text-mode+git-commit-mode))))
You then have to define your snippets as if there actually existed a major-mode named
By default the major-mode for
text-mode, if your
yasnippet doesn't work in
text-mode, it won't work in
git-commit-mode either, so you may want to change it to other mode like
(setq git-commit-major-mode 'org-mode)
org-mode is my default major-mode for unrecognized files.