git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Emacs git-mode feature request: support fill-paragraph correctly

From
BSBruce Stephens <bruce.stephens@isode.com>
Date
Jan 26, 2009, 19:11 UTC
Message-ID
<8063k1zxts.fsf@tiny.isode.net>
In-Reply-To
<87mydet0yg.fsf@write-only.cryp.to>
Peter Simons <simons@cryp.to> writes:
[...]
> The buffer is in "log-edit" mode.
Ah, OK.  That makes sense.
Show 6 quoted lines
>  > 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.

Previous: Peter SimonsNext: Alexandre Julliard
Message 4 of 8 in “Emacs git-mode feature request: support fill-paragraph correctly”
  1. Peter SimonsJan 26, 2009
  2. Bruce StephensJan 26, 2009
  3. Peter SimonsJan 26, 2009
  4. Bruce StephensJan 26, 2009
  5. Alexandre JulliardJan 27, 2009
  6. Peter SimonsJan 27, 2009
  7. Junio C HamanoJan 28, 2009
  8. Alexandre JulliardJan 29, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.