{"thread":{"id":"17369","subject":"Emacs git-mode feature request: support fill-paragraph correctly","startedAt":"2009-01-26T11:57:39Z","lastAt":"2009-01-29T10:42:10Z","messageCount":8,"participants":["Peter Simons","Bruce Stephens","Alexandre Julliard","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"101976","messageId":"87tz7mth3g.fsf@write-only.cryp.to","threadId":"17369","inReplyTo":null,"subject":"Emacs git-mode feature request: support fill-paragraph correctly","fromName":"Peter Simons","fromEmail":"simons@cryp.to","sentAt":"2009-01-26T11:57:39Z","receivedAt":"2009-01-26T11:57:39Z","isPatch":false,"sender":{"key":"simons@cryp.to","avatar":"https://gravatar.com/avatar/56227a0fffc05e2d0584aecce45f0f1fd2b2c0a464a266dff6c2a4aa9191241e?d=mp&s=160"},"body":"Hi,\n\nwhen I choose to commit in Emacs' git mode, I'm prompted to enter a\ncommit message in a buffer that looks something like this:\n\n   Author: Joe Doe <joe.doe@example.org>\n   --- log message follows this line ---\n   foo.txt: lots of important changes\n\nNow, when I hit M-q (fill-paragraph), Emacs doesn't recognize that\nthe \"--- log message ...\" line ought to be considered a paragraph\nseparator. As a result, the re-filled buffer is messed up:\n\n   Author: Joe Doe <joe.doe@example.org> --- log message follows\n   this line --- foo.txt: lots of important changes\n\nOther modes, such as message-mode, do support that kind of thing\ncorrectly, so apparently it is possible to configure what the editor\nconsiders as a paragraph. Is there some Emacs wizard out there who'd\nbe kind enough to improve git-mode accordingly?\n\nTake care,\nPeter\n"},{"id":"101978","messageId":"808woyz2k7.fsf@tiny.isode.net","threadId":"17369","inReplyTo":"87tz7mth3g.fsf@write-only.cryp.to","subject":"Re: Emacs git-mode feature request: support fill-paragraph correctly","fromName":"Bruce Stephens","fromEmail":"bruce.stephens@isode.com","sentAt":"2009-01-26T12:15:04Z","receivedAt":"2009-01-26T12:15:04Z","isPatch":false,"sender":{"key":"bruce.stephens@isode.com","avatar":null},"body":"Peter Simons <simons@cryp.to> writes:\n\n[...]\n\n> Other modes, such as message-mode, do support that kind of thing\n> correctly, so apparently it is possible to configure what the editor\n> considers as a paragraph. Is there some Emacs wizard out there who'd\n> be kind enough to improve git-mode accordingly?\n\nI suspect this doesn't directly relate to git-mode.  What mode does\nemacs say you're in at this point?  I'm guessing the buffer name is\nCOMMIT_EDITMSG and the mode is fundamental-mode?\n\nIn that case you could stick this in your .emacs if you wanted to use\nmessage-mode:\n\n(setq auto-mode-alist (cons '(\"COMMIT_EDITMSG\" . message-mode) auto-mode-alist))\n"},{"id":"102010","messageId":"87mydet0yg.fsf@write-only.cryp.to","threadId":"17369","inReplyTo":"808woyz2k7.fsf@tiny.isode.net","subject":"Re: Emacs git-mode feature request: support fill-paragraph correctly","fromName":"Peter Simons","fromEmail":"simons@cryp.to","sentAt":"2009-01-26T17:46:15Z","receivedAt":"2009-01-26T17:46:15Z","isPatch":false,"sender":{"key":"simons@cryp.to","avatar":"https://gravatar.com/avatar/56227a0fffc05e2d0584aecce45f0f1fd2b2c0a464a266dff6c2a4aa9191241e?d=mp&s=160"},"body":"Bruce Stephens <bruce.stephens@isode.com> writes:\n\n >> Other modes, such as message-mode, do support that kind of thing\n >> correctly, so apparently it is possible to configure what the\n >> editor considers as a paragraph. Is there some Emacs wizard out\n >> there who'd be kind enough to improve git-mode accordingly?\n >\n > I suspect this doesn't directly relate to git-mode. What mode\n > does emacs say you're in at this point? I'm guessing the buffer\n > name is COMMIT_EDITMSG and the mode is fundamental-mode?\n\nThe buffer is in \"log-edit\" mode.\n\n > In that case you could stick this in your .emacs if you wanted to\n > use message-mode:\n >\n > (setq auto-mode-alist (cons '(\"COMMIT_EDITMSG\" . message-mode) auto-mode-alist))\n\nUnfortunately, it's not that easy. I'm not an Emacs expert, but I'd\nassume that switching into a different mode would change the meaning\nof C-c C-c.\n\nPeter\n"},{"id":"102025","messageId":"8063k1zxts.fsf@tiny.isode.net","threadId":"17369","inReplyTo":"87mydet0yg.fsf@write-only.cryp.to","subject":"Re: Emacs git-mode feature request: support fill-paragraph correctly","fromName":"Bruce Stephens","fromEmail":"bruce.stephens@isode.com","sentAt":"2009-01-26T19:11:59Z","receivedAt":"2009-01-26T19:11:59Z","isPatch":false,"sender":{"key":"bruce.stephens@isode.com","avatar":null},"body":"Peter Simons <simons@cryp.to> writes:\n\n[...]\n\n> The buffer is in \"log-edit\" mode.\n\nAh, OK.  That makes sense.\n\n>  > In that case you could stick this in your .emacs if you wanted to\n>  > use message-mode:\n>  >\n>  > (setq auto-mode-alist (cons '(\"COMMIT_EDITMSG\" . message-mode) auto-mode-alist))\n>\n> Unfortunately, it's not that easy.\n\nTrue.  I don't use git-mode (well, not much).  I use git commit from\nthe command line, which runs emacsclient as its editor.\n\n> I'm not an Emacs expert, but I'd assume that switching into a\n> different mode would change the meaning of C-c C-c.\n\nYep.  Quite likely other things, too.\n\nOK, something like this:\n\n(add-hook 'log-edit-mode-hook (lambda ()\n\t\t(let ((regexp \"--text follows this line--$\\\\|[  ]*$\\\\|-- $\\\\|---+$\\\\|^\\f$\\\\|.*wrote:$\\\\|\\\\(\\\\([         ]*[-_.[:word:]]+>+\\\\|[  ]*[]>|}+]\\\\)+\\\\)[  ]*$\\\\|<#!*/?\\\\(multipart\\\\|part\\\\|external\\\\|mml\\\\|secure\\\\)\"))\n                   (setq paragraph-start regexp\n                         paragraph-separate regexp)))\n\nI copied the regexp from the value in message-mode.  (In a junk buffer\nuse M-x message-mode, then C-h v paragraph-start and copy & paste.)\n\nI imagine large parts of the regexp aren't relevant for your purposes\nso you could remove them if you wanted.  You might also define a\nfunction rather than using lambda---that would make it a bit easier to\ntest.\n"},{"id":"102105","messageId":"873af59fkm.fsf@wine.dyndns.org","threadId":"17369","inReplyTo":"87tz7mth3g.fsf@write-only.cryp.to","subject":"Re: Emacs git-mode feature request: support fill-paragraph correctly","fromName":"Alexandre Julliard","fromEmail":"julliard@winehq.org","sentAt":"2009-01-27T11:03:05Z","receivedAt":"2009-01-27T11:03:05Z","isPatch":false,"sender":{"key":"julliard@winehq.org","avatar":null},"body":"Peter Simons <simons@cryp.to> writes:\n\n> Other modes, such as message-mode, do support that kind of thing\n> correctly, so apparently it is possible to configure what the editor\n> considers as a paragraph. Is there some Emacs wizard out there who'd\n> be kind enough to improve git-mode accordingly?\n\nYou could try something like this:\n\ndiff --git a/contrib/emacs/git.el b/contrib/emacs/git.el\nindex 3c37d0d..e314c44 100644\n--- a/contrib/emacs/git.el\n+++ b/contrib/emacs/git.el\n@@ -1331,6 +1331,7 @@ Return the list of files that haven't been handled.\"\n \t\t\t\t\t (log-edit-diff-function . git-log-edit-diff)) buffer)\n \t(log-edit 'git-do-commit nil 'git-log-edit-files buffer))\n       (setq font-lock-keywords (font-lock-compile-keywords git-log-edit-font-lock-keywords))\n+      (setq paragraph-separate (concat (regexp-quote git-log-msg-separator) \"$\\\\|Author: \\\\|Date: \\\\|Merge: \\\\|Signed-off-by: \\\\|\\f\\\\|[ \t]*$\"))\n       (setq buffer-file-coding-system coding-system)\n       (re-search-forward (regexp-quote (concat git-log-msg-separator \"\\n\")) nil t))))\n \n\n-- \nAlexandre Julliard\njulliard@winehq.org\n"},{"id":"102120","messageId":"878wow7sgx.fsf@write-only.cryp.to","threadId":"17369","inReplyTo":"873af59fkm.fsf@wine.dyndns.org","subject":"Re: Emacs git-mode feature request: support fill-paragraph correctly","fromName":"Peter Simons","fromEmail":"simons@cryp.to","sentAt":"2009-01-27T14:07:26Z","receivedAt":"2009-01-27T14:07:26Z","isPatch":false,"sender":{"key":"simons@cryp.to","avatar":"https://gravatar.com/avatar/56227a0fffc05e2d0584aecce45f0f1fd2b2c0a464a266dff6c2a4aa9191241e?d=mp&s=160"},"body":"Hi Alexandre,\n\n > diff --git a/contrib/emacs/git.el b/contrib/emacs/git.el\n > index 3c37d0d..e314c44 100644\n > --- a/contrib/emacs/git.el\n > +++ b/contrib/emacs/git.el\n > @@ -1331,6 +1331,7 @@ Return the list of files that haven't been handled.\"\n >  \t\t\t\t\t (log-edit-diff-function . git-log-edit-diff)) buffer)\n >  \t(log-edit 'git-do-commit nil 'git-log-edit-files buffer))\n >        (setq font-lock-keywords (font-lock-compile-keywords git-log-edit-font-lock-keywords))\n > +      (setq paragraph-separate (concat (regexp-quote git-log-msg-separator) \"$\\\\|Author: \\\\|Date: \\\\|Merge: \\\\|Signed-off-by: \\\\|\\f\\\\|[ \t]*$\"))\n >        (setq buffer-file-coding-system coding-system)\n >        (re-search-forward (regexp-quote (concat git-log-msg-separator \"\\n\")) nil t))))\n\nthat patch has the desired effect (tested with GNU Emacs 22.3.1 and\nGIT 1.6.1). Thank you very much.\n\nNow, I'd be hugely in favor of applying that change to the repository\nso that future versions of GIT have it.\n\nTake care,\nPeter\n"},{"id":"102355","messageId":"7vk58fktfy.fsf@gitster.siamese.dyndns.org","threadId":"17369","inReplyTo":"878wow7sgx.fsf@write-only.cryp.to","subject":"Re: Emacs git-mode feature request: support fill-paragraph correctly","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-01-28T21:32:33Z","receivedAt":"2009-01-28T21:32:33Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Peter Simons <simons@cryp.to> writes:\n\n> Hi Alexandre,\n>\n>  > diff --git a/contrib/emacs/git.el b/contrib/emacs/git.el\n>  > index 3c37d0d..e314c44 100644\n>  > --- a/contrib/emacs/git.el\n>  > +++ b/contrib/emacs/git.el\n>  > @@ -1331,6 +1331,7 @@ Return the list of files that haven't been handled.\"\n>  >  \t\t\t\t\t (log-edit-diff-function . git-log-edit-diff)) buffer)\n>  >  \t(log-edit 'git-do-commit nil 'git-log-edit-files buffer))\n>  >        (setq font-lock-keywords (font-lock-compile-keywords git-log-edit-font-lock-keywords))\n>  > +      (setq paragraph-separate (concat (regexp-quote git-log-msg-separator) \"$\\\\|Author: \\\\|Date: \\\\|Merge: \\\\|Signed-off-by: \\\\|\\f\\\\|[ \t]*$\"))\n>  >        (setq buffer-file-coding-system coding-system)\n>  >        (re-search-forward (regexp-quote (concat git-log-msg-separator \"\\n\")) nil t))))\n>\n> that patch has the desired effect (tested with GNU Emacs 22.3.1 and\n> GIT 1.6.1). Thank you very much.\n>\n> Now, I'd be hugely in favor of applying that change to the repository\n> so that future versions of GIT have it.\n\nAlexandre?\n"},{"id":"102427","messageId":"87tz7i4cn1.fsf@wine.dyndns.org","threadId":"17369","inReplyTo":"7vk58fktfy.fsf@gitster.siamese.dyndns.org","subject":"Re: Emacs git-mode feature request: support fill-paragraph correctly","fromName":"Alexandre Julliard","fromEmail":"julliard@winehq.org","sentAt":"2009-01-29T10:42:10Z","receivedAt":"2009-01-29T10:42:10Z","isPatch":false,"sender":{"key":"julliard@winehq.org","avatar":null},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Peter Simons <simons@cryp.to> writes:\n>\n>> that patch has the desired effect (tested with GNU Emacs 22.3.1 and\n>> GIT 1.6.1). Thank you very much.\n>>\n>> Now, I'd be hugely in favor of applying that change to the repository\n>> so that future versions of GIT have it.\n>\n> Alexandre?\n\nSure, I'll include it in my next pull request.\n\n-- \nAlexandre Julliard\njulliard@winehq.org\n"}]}