[PATCH] Add support for rafl's git-commit-mode

76 views
Skip to first unread message

Ramkumar Ramachandra

unread,
Dec 24, 2011, 8:32:36 AM12/24/11
to Magit list
Florian Ragwitz (rafl) has written a git-commit-mode [1], a major mode
for editing log messages that people might like to use in conjunction
with Magit. So, add this project as a submodule to the Magit project,
and make magit-log-edit-mode derive this mode.

[1]: https://github.com/rafl/git-commit-mode

Signed-off-by: Ramkumar Ramachandra <arta...@gmail.com>
---
I've been using this locally for a long time now. Although I posted
this patch on the list a long time ago, I'm guilty of not pushing.
Christmas is a perfect time to fix this :)

Thoughts?

[1]: http://thread.gmane.org/gmane.comp.version-control.git.magit/1022/focus=1057

.gitmodules | 3 +++
git-commit-mode | 1 +
magit.el | 14 ++++++++++----
3 files changed, 14 insertions(+), 4 deletions(-)
create mode 100644 .gitmodules
create mode 160000 git-commit-mode

diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..3a55da4
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "git-commit-mode"]
+ path = git-commit-mode
+ url = git://github.com/rafl/git-commit-mode.git
diff --git a/git-commit-mode b/git-commit-mode
new file mode 160000
index 0000000..ec88948
--- /dev/null
+++ b/git-commit-mode
@@ -0,0 +1 @@
+Subproject commit ec88948e06f787fcc1c3b9951930ef00b25d0b8a
diff --git a/magit.el b/magit.el
index 1c0d73d..aaa2fdc 100644
--- a/magit.el
+++ b/magit.el
@@ -4026,10 +4026,16 @@ typing and automatically refreshes the status buffer."

(defvar magit-pre-log-edit-window-configuration nil)

-(define-derived-mode magit-log-edit-mode text-mode "Magit Log Edit"
- ;; Recognize changelog-style paragraphs
- (set (make-local-variable 'paragraph-start)
- (concat paragraph-start "\\|*\\|(")))
+(if (require 'git-commit nil 'noerror)
+ (define-derived-mode magit-log-edit-mode git-commit-mode "Magit Log Edit"
+ (define-key magit-log-edit-mode-map (kbd "C-c C-s")
+ 'git-commit-signoff)
+ ;; Recognize changelog-style paragraphs
+ (set (make-local-variable 'paragraph-start)
+ (concat paragraph-start "\\|*\\|(")))
+ (define-derived-mode magit-log-edit-mode text-mode "Magit Log Edit"
+ (set (make-local-variable 'paragraph-start)
+ (concat paragraph-start "\\|*\\|("))))

(defun magit-log-edit-cleanup ()
(save-excursion
--
1.7.8.1.362.g5d6df.dirty

Yann Hodique

unread,
Dec 25, 2011, 7:13:25 AM12/25/11
to Ramkumar Ramachandra, Magit list
>>>>> "Ramkumar" == Ramkumar Ramachandra <arta...@gmail.com> writes:

> Florian Ragwitz (rafl) has written a git-commit-mode [1], a major mode
> for editing log messages that people might like to use in conjunction
> with Magit. So, add this project as a submodule to the Magit project,
> and make magit-log-edit-mode derive this mode.

> [1]: https://github.com/rafl/git-commit-mode

Thanks, I'll give it a try. What about the metadata magit puts in the
log-edit buffer before submitting ? Are there equivalent flags with
git-commit-mode ?

> .gitmodules | 3 +++

Is there a reason why we'd like to maintain a submodule within magit?
I mean, it won't be a strong dependency anyway. So we should probably
just mention the location of git-commit-mode (or better an elpa package)
and leave the rest to the user.

> -(define-derived-mode magit-log-edit-mode text-mode "Magit Log Edit"
> - ;; Recognize changelog-style paragraphs
> - (set (make-local-variable 'paragraph-start)
> - (concat paragraph-start "\\|*\\|(")))
> +(if (require 'git-commit nil 'noerror)
> + (define-derived-mode magit-log-edit-mode git-commit-mode "Magit Log Edit"
> + (define-key magit-log-edit-mode-map (kbd "C-c C-s")
> + 'git-commit-signoff)
> + ;; Recognize changelog-style paragraphs
> + (set (make-local-variable 'paragraph-start)
> + (concat paragraph-start "\\|*\\|(")))
> + (define-derived-mode magit-log-edit-mode text-mode "Magit Log Edit"
> + (set (make-local-variable 'paragraph-start)
> + (concat paragraph-start "\\|*\\|("))))

I'd prefer we don't use git-commit-mode automatically when it exists,
but rather when the user asks for it (with a call to
`magit-git-commit-mode-insinuate' or something). We should also provide
a way to fallback to regular mode upon user request.

Yann.

--
We tend to become like the worst in those we oppose.

-- Bene Gesserit Coda

Ramkumar Ramachandra

unread,
Jan 5, 2012, 5:54:52 AM1/5/12
to Yann Hodique, Magit list
Hi Yann,

Yann Hodique wrote:
>>>>>> "Ramkumar" == Ramkumar Ramachandra <arta...@gmail.com> writes:
>> [1]: https://github.com/rafl/git-commit-mode
>
> Thanks, I'll give it a try. What about the metadata magit puts in the
> log-edit buffer before submitting ? Are there equivalent flags with
> git-commit-mode ?

No. But I'm just deriving it from magit-log-edit-mode which puts in
those headers anyway, no? git-commit-mode just does some "syntax
highlighting".

Tried it out? Do you like it?

>>  .gitmodules     |    3 +++
>
> Is there a reason why we'd like to maintain a submodule within magit?
> I mean, it won't be a strong dependency anyway. So we should probably
> just mention the location of git-commit-mode (or better an elpa package)
> and leave the rest to the user.

Sure, that'd work too.

> I'd prefer we don't use git-commit-mode automatically when it exists,
> but rather when the user asks for it (with a call to
> `magit-git-commit-mode-insinuate' or something). We should also provide
> a way to fallback to regular mode upon user request.

Okay, I'll rewrite that bit shortly.

p.s- Sorry about the delay; was on vacation.

-- Ram

Yann Hodique

unread,
Jan 5, 2012, 6:04:47 AM1/5/12
to Ramkumar Ramachandra, Magit list
On Thu, Jan 5, 2012 at 11:54 AM, Ramkumar Ramachandra
<arta...@gmail.com> wrote:
> Hi Yann,
>
> Yann Hodique wrote:
>>>>>>> "Ramkumar" == Ramkumar Ramachandra <arta...@gmail.com> writes:
>>> [1]: https://github.com/rafl/git-commit-mode
>>
>> Thanks, I'll give it a try. What about the metadata magit puts in the
>> log-edit buffer before submitting ? Are there equivalent flags with
>> git-commit-mode ?
>
> No.  But I'm just deriving it from magit-log-edit-mode which puts in
> those headers anyway, no?  git-commit-mode just does some "syntax
> highlighting".
>
> Tried it out?  Do you like it?

Hey,

yes I tried it, and somewhat liked it, but integration is still not great.
In particular, syntax highlighting is broken when we make use of those
magit metadata (like amending, or setting author) since
git-commit-mode is very strict and expects first line to be the short
description, second line to be empty, and so on. So that our
additional text interferes.
In the end, the buffer is still colorized, but with meaningless colors :)

I can see 2 tracks to fix this:
- either we can make git-commit-mode somehow skip our metadata
altogether, if present
- or we can get rid of our metadata block (I personally don't like it
anyway), and for example put equivalent information in
`header-line-format' where it would not "pollute" the actual commit
text.

Any idea ?

Yann.

Ramkumar Ramachandra

unread,
Jan 5, 2012, 6:12:33 AM1/5/12
to Yann Hodique, Magit list
Hi Yann,

Yann Hodique wrote:
> yes I tried it, and somewhat liked it, but integration is still not great.
> In particular, syntax highlighting is broken when we make use of those
> magit metadata (like amending, or setting author) since
> git-commit-mode is very strict and expects first line to be the short
> description, second line to be empty, and so on. So that our
> additional text interferes.

Right; I forgot to mention this.

> - or we can get rid of our metadata block (I personally don't like it
> anyway), and for example put equivalent information in
> `header-line-format' where it would not "pollute" the actual commit
> text.

I don't like the metadata header either. Yes, I think we should pick
this option.

-- Ram

Reply all
Reply to author
Forward
0 new messages