I frequently source the body of my GitHub PRs from my commits, and thus is makes sense to consider my commits to be made in Markdown (it is nice to have a markup language for commits anyway). Thus I customized Magit's git-commit-major-mode
to be markdown-mode
, but then all the #
comment lines that Git inserts get formatted like markdown headers---highly undesirable! So I switched away from #
as Git's comment delimiter. Somewhat randomly, I picked !
, and added to my .gitconfig
:
[core]
commentChar = !
This keeps them from being formatted like headers, but I previously enjoyed the way that Magit had some understanding of these lines and would syntax-highlight them. I was hoping that there was some intelligence in the Git commit mode that would be able to mesh markdown mode with the original abilities of Magit, so that above the comment lines would be highlighted with Markdown, and the comment lines themselves would be highlighted by Magit (which is already aware of core.commentChar
, because when I set commit buffers to have no major mode, it properly highlights the comments that use !
).
My current configuration is usable, but with Emacs (and Magit especially) I always shoot for the stars. How do I achieve this?
comment-start
to take. I added(defun kazark/!-as-comment-char () (setq-local comment-start "!"))
to my.spacemacs
and then usedcustomize
to add that togit-commit-setup-hook
. However, it makes no difference, and when I check the value ofcomment-start
in that buffer, it is still<!--
.(setq-local comment-start "!")
in that buffer, which does setcomment-start
, nothing changes.core.commentChar
. That's implemented ingit-commit-setup-font-lock
. I just tested it and it works for me. I don't know why it doesn't work for you. Maybe you are using a very old version of thegit-commit
package.git-commit
version is20200828.1753
though: very new.