Re: Emacs git-mode feature request: support fill-paragraph correctly
From: Bruce Stephens <hidden>
Date: 2016-06-15 22:46:02
Peter Simons [off-list ref] writes: [...]
The buffer is in "log-edit" mode.
Ah, OK. That makes sense.
> In that case you could stick this in your .emacs if you wanted to
> use message-mode:
>
> (setq auto-mode-alist (cons '("COMMIT_EDITMSG" . message-mode) auto-mode-alist))
Unfortunately, it's not that easy.True. I don't use git-mode (well, not much). I use git commit from the command line, which runs emacsclient as its editor.
I'm not an Emacs expert, but I'd assume that switching into a different mode would change the meaning of C-c C-c.
Yep. Quite likely other things, too.
OK, something like this:
(add-hook 'log-edit-mode-hook (lambda ()
(let ((regexp "--text follows this line--$\\|[ ]*$\\|-- $\\|---+$\\|^\f$\\|.*wrote:$\\|\\(\\([ ]*[-_.[:word:]]+>+\\|[ ]*[]>|}+]\\)+\\)[ ]*$\\|<#!*/?\\(multipart\\|part\\|external\\|mml\\|secure\\)"))
(setq paragraph-start regexp
paragraph-separate regexp)))
I copied the regexp from the value in message-mode. (In a junk buffer
use M-x message-mode, then C-h v paragraph-start and copy & paste.)
I imagine large parts of the regexp aren't relevant for your purposes
so you could remove them if you wanted. You might also define a
function rather than using lambda---that would make it a bit easier to
test.