Eric Schulte <[email protected]> writes:

> Noam Postavsky <[email protected]> writes:
>
>> On Sun, Aug 25, 2013 at 3:10 PM, Eric Schulte <[email protected]> wrote:
>>> The commit edit log is now in `fundamental-mode', and I can find no hook
>>> run when this buffer is opened.  What would be the recommended way to
>>> re-enable such customization?
>>
>> You can install git-commit-mode from github.com/magit/git-modes, which
>> is now a dependency of magit (along with git-rebase-mode):
>>
>> (define-package "magit" "1.2.1-git"
>>   "Control Git from Emacs."
>>   '((cl-lib "0.3")
>>     (git-commit-mode "0.14.0")
>>     (git-rebase-mode "0.14.0")))
>>
>> It runs git-commit-mode-hook (and fontifies the characters on the
>> first line past column 51 in git-commit-overlong-summary-face out of
>> the box).
>
> Thanks, after installing these extra packages I can indeed use these
> hooks.
>
> The first line of the pre-populated git commit boilerplate is fontified
> in the `git-commit-overlong-summary-face'.  To be clear, my
> COMMIT_EDITMSG buffer is opened with the following, and the second line
> is all in red.
>
> ,----
> | 
> | # Please enter the commit message for your changes. Lines starting
> | # with '#' will be ignored, and an empty message aborts the commit.
> | # On branch master
> | # Changes to be committed:
> | #   (use "git reset HEAD <file>..." to unstage)
> | #
> `----

The attached patch fixes this bug.

Cheers,

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D
>From 3869ff313bd755a362d25cd962372bc8d5221abe Mon Sep 17 00:00:00 2001
From: Eric Schulte <[email protected]>
Date: Mon, 26 Aug 2013 12:12:42 -0600
Subject: [PATCH] don't mark first comment as error, and rx cleanup

  The previous version of `git-commit-summary-regexp' highlighted the
  first comment line as a git commit style error.  This was because it
  did not check if bad non-empty second lines were actually comments.
  In addition this commit removes some messy line-start and grouping
  constructs which were not necessary.
---
 git-commit-mode.el | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/git-commit-mode.el b/git-commit-mode.el
index 7a095a7..664c4e9 100644
--- a/git-commit-mode.el
+++ b/git-commit-mode.el
@@ -375,19 +375,13 @@ use for fontification.")
     (or (one-or-more (syntax whitespace))
         (and (syntax comment-start) (zero-or-more not-newline)))
     "\n")
-   ;; The actual summary line
-   ;; Hack to force grouping, since for some stupid reason Emacs won't handle
-   ;; "line-start" in the middle of a regexp.  Fuck you, Emacs!
-   (= 1 line-start
-        (group (** 0 50 not-newline))      ; The real summary
-        (group (zero-or-more not-newline)) ; The overlong part
-        line-end)
-   ;; A non-empty second line
-   (optional
-    "\n"
-    (group (zero-or-more not-newline))
-    line-end)
-   )
+   ;; The summary line
+   (group (** 0 50 not-newline))      ; The real summary
+   (group (zero-or-more not-newline)) ; The overlong part
+   ;; A non-empty non-comment second line
+   (optional "\n"
+             (group (not (any "#" "\n")) (one-or-more not-newline))
+             line-end))
   "Regexp to match the summary line.")
 
 (defun git-commit-has-style-errors-p ()
-- 
1.8.3.4

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"magit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to