[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Adding git-commit highlight mode?
From: |
Jim Porter |
Subject: |
Re: Adding git-commit highlight mode? |
Date: |
Sun, 5 Jan 2025 10:47:32 -0800 |
On 1/4/2025 4:50 AM, Jonas Bernoulli wrote:
1. Font-locking, including for "violations of the conventions" like
non-empty second line and overly long lines.
My code has font-locking, but it's very basic. It mostly just font-locks
comments and a few syntactic bits in the default Git comment (like the
rebase verbs). I wouldn't mind more font-locking for my mode though.
2. Support for inserting "Git trailers" (here still called
"pseudo-headers"). E.g., "Signed-off-by: Name <email>"
That makes sense and would probably be pretty easy to add to my mode.
3. Support for nagging the user about violations of the conventions
when trying to finish the commit.
Maybe this could just be a hook in my mode? Then if it becomes built-in,
Emacs just provides the basics, but Magit (or some other package) can
enhance the experience however it likes.
4. Options to control whether certain optional functionality, such as
flyspell, is turned on.
I imagine the usual mode hooks would suffice for this, at least for a
"minimal" commit msg mode.
5. Support for cycling through past messages. This is based on similar
functionality in log-edit.el. It might be best to just port the
improvements to that built-in library.
I don't know anything about log-edit, but if we're upstreaming
something, I think it makes sense to improve log-edit to handle this so
we're not reinventing the wheel.
6. Allow for an arbitrary major-mode to be used. git-commit-mode is
just minor-mode which enables additional font-locking, adds to some
hooks, and adds some key bindings. However we briefly pretend that
git-commit-mode is a major-mode, so that .dir-locals[-2].el settings
can be taken into account.
This is a good idea and would hopefully resolve the question elsewhere
in the thread about whether to inherit from change-log-mode or not.
7. Setup commands for finishing and aborting the commit process in
co-operation with magit and with-editor.
For what it's worth, my package works fine with 'with-editor' without
needing to do anything special. That's probably because it's meant to be
used when you call "git commit" from a shell, so the 'with-editor'
tricks just work. It even works via Eshell over Tramp (all due to
'with-editor' I'm sure). If Magit needs some extra setup, maybe we could
just provide some hooks as needed.
- I imagine that one likely way of doing it is to ripping out the Magit-
and With-Editor specific bits, and instead adding hooks and such, to
allow Magit to bring them back. Maybe that would work well for
me/Magit, put it could also turn out to be very painful. It would
certainly complicate the code.
Despite what I wrote above, I don't think there's any *need* for Magit
to use my package, even if it gets upstreamed. I think all the symbol
names in my code are different from Magit, though to be fair I haven't
looked closely at Magit's code so that I could do a clean implementation.
- Many users are going to stick to Emacs releases that don't have a
bundled git-commit.el for many years to come (beyond the end of the
decade, I am afraid). It will become increasingly hard for me to
continue to support Emacs releases from before the addition.
If we do want to pursue Magit using this code, then I agree with your
comment elsewhere that we should distribute it on ELPA as well so that
you don't need to worry about the Emacs version.
I'm happy to work on the basics for this so long as there's a clear
direction. I don't know if we need to provide everything Magit would
need immediately, so long as we don't paint ourselves into a corner.
It seems the first big decision would be whether my code should be a
major or minor mode. Once we resolve that, I think we could probably
upstream parts of my code into Emacs and then keep adding features
gradually. So long as this initial mode doesn't conflict with Magit,
then I think we can just continue independently for a while, with the
eventual goal of making it *possible* for Magit to use the mode.
- Re: Adding git-commit highlight mode?, (continued)
- Re: Adding git-commit highlight mode?, Eli Zaretskii, 2025/01/02
- Re: Adding git-commit highlight mode?, Björn Bidar, 2025/01/03
- Re: Adding git-commit highlight mode?, Konstantin Kharlamov, 2025/01/03
- Re: Adding git-commit highlight mode?, Björn Bidar, 2025/01/03
- Re: Adding git-commit highlight mode?, Konstantin Kharlamov, 2025/01/03
- Re: Adding git-commit highlight mode?, Björn Bidar, 2025/01/04
- Re: Adding git-commit highlight mode?, Konstantin Kharlamov, 2025/01/04
- Re: Adding git-commit highlight mode?, Jonas Bernoulli, 2025/01/04
- Re: Adding git-commit highlight mode?, Jonas Bernoulli, 2025/01/04
- Re: Adding git-commit highlight mode?, Björn Bidar, 2025/01/04
- Re: Adding git-commit highlight mode?,
Jim Porter <=
Message not available
Re: Adding git-commit highlight mode?, Björn Bidar, 2025/01/04