GNU bug report logs -
#60660
Support git-formatted patches in diff-mode
Previous Next
Reported by: Juri Linkov <juri <at> linkov.net>
Date: Sun, 8 Jan 2023 18:30:02 UTC
Severity: normal
Tags: patch
Done: Stefan Kangas <stefankangas <at> gmail.com>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 60660 in the body.
You can then email your comments to 60660 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#60660
; Package
emacs
.
(Sun, 08 Jan 2023 18:30:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Juri Linkov <juri <at> linkov.net>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Sun, 08 Jan 2023 18:30:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Currently, there is a lot of misfontification in diff-mode visiting a git patch.
Two dashes in the signature separator are highlighted with the diff-removed face
(the existing diff-prev-line-if-patch-separator is used for something else).
Three dashes in the git patch header that separate a list of affected files
are highlighted with the diff-hunk-header face, etc.
But the worst case that raises an error is when an exclamation mark is used
at the beginning of the line in the git patch message.
This patch for emacs-29 fixes this bug, and the rest of fontification
could be implemented in master.
[diff-font-lock-changed.patch (text/x-diff, inline)]
diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el
index acfd2c30f0c..eb01dede56e 100644
--- a/lisp/vc/diff-mode.el
+++ b/lisp/vc/diff-mode.el
@@ -485,17 +485,19 @@ diff-font-lock-keywords
;; if below, use `diff-added'.
(save-match-data
(let ((limit (save-excursion (diff-beginning-of-hunk))))
- (if (save-excursion (re-search-backward diff-context-mid-hunk-header-re limit t))
- diff-indicator-added-face
- diff-indicator-removed-face)))))
+ (when (< limit (point))
+ (if (save-excursion (re-search-backward diff-context-mid-hunk-header-re limit t))
+ diff-indicator-added-face
+ diff-indicator-removed-face))))))
(2 (if diff-use-changed-face
'diff-changed-unspecified
;; Otherwise, use the same method as above.
(save-match-data
(let ((limit (save-excursion (diff-beginning-of-hunk))))
- (if (save-excursion (re-search-backward diff-context-mid-hunk-header-re limit t))
- 'diff-added
- 'diff-removed))))))
+ (when (< limit (point))
+ (if (save-excursion (re-search-backward diff-context-mid-hunk-header-re limit t))
+ 'diff-added
+ 'diff-removed)))))))
("^\\(?:Index\\|revno\\): \\(.+\\).*\n"
(0 'diff-header) (1 'diff-index prepend))
("^\\(?:index .*\\.\\.\\|diff \\).*\n" . 'diff-header)
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#60660
; Package
emacs
.
(Sun, 08 Jan 2023 18:52:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 60660 <at> debbugs.gnu.org (full text, mbox):
> From: Juri Linkov <juri <at> linkov.net>
> Date: Sun, 08 Jan 2023 20:21:23 +0200
>
> Currently, there is a lot of misfontification in diff-mode visiting a git patch.
> Two dashes in the signature separator are highlighted with the diff-removed face
> (the existing diff-prev-line-if-patch-separator is used for something else).
> Three dashes in the git patch header that separate a list of affected files
> are highlighted with the diff-hunk-header face, etc.
>
> But the worst case that raises an error is when an exclamation mark is used
> at the beginning of the line in the git patch message.
>
> This patch for emacs-29 fixes this bug, and the rest of fontification
> could be implemented in master.
OK for the emacs-29 branch (although I'm surprised that
diff-beginning-of-hunk can return a position that is not before
point).
Thanks.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#60660
; Package
emacs
.
(Mon, 09 Jan 2023 07:57:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 60660 <at> debbugs.gnu.org (full text, mbox):
>> This patch for emacs-29 fixes this bug, and the rest of fontification
>> could be implemented in master.
>
> OK for the emacs-29 branch
Pushed to the emacs-29 branch.
> (although I'm surprised that diff-beginning-of-hunk can return
> a position that is not before point).
Indeed, strange to see this in 'diff-beginning-of-hunk':
(cond ...
((re-search-backward regexp nil t)) ; In the middle of a hunk.
((re-search-forward regexp nil t) ; At first hunk header.
=======
Need to experiment more with this in master.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#60660
; Package
emacs
.
(Tue, 05 Sep 2023 23:31:01 GMT)
Full text and
rfc822 format available.
Message #14 received at 60660 <at> debbugs.gnu.org (full text, mbox):
Juri Linkov <juri <at> linkov.net> writes:
>>> This patch for emacs-29 fixes this bug, and the rest of fontification
>>> could be implemented in master.
>>
>> OK for the emacs-29 branch
>
> Pushed to the emacs-29 branch.
So is there more to do here, or should this bug be closed? I'm not sure
if it's still needed to track the below.
>> (although I'm surprised that diff-beginning-of-hunk can return
>> a position that is not before point).
>
> Indeed, strange to see this in 'diff-beginning-of-hunk':
>
> (cond ...
> ((re-search-backward regexp nil t)) ; In the middle of a hunk.
> ((re-search-forward regexp nil t) ; At first hunk header.
> =======
>
> Need to experiment more with this in master.
Added tag(s) patch.
Request was from
Stefan Kangas <stefankangas <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Fri, 08 Sep 2023 11:45:02 GMT)
Full text and
rfc822 format available.
Reply sent
to
Stefan Kangas <stefankangas <at> gmail.com>
:
You have taken responsibility.
(Wed, 10 Jan 2024 22:38:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Juri Linkov <juri <at> linkov.net>
:
bug acknowledged by developer.
(Wed, 10 Jan 2024 22:38:02 GMT)
Full text and
rfc822 format available.
Message #21 received at 60660-done <at> debbugs.gnu.org (full text, mbox):
Stefan Kangas <stefankangas <at> gmail.com> writes:
> Juri Linkov <juri <at> linkov.net> writes:
>
>>>> This patch for emacs-29 fixes this bug, and the rest of fontification
>>>> could be implemented in master.
>>>
>>> OK for the emacs-29 branch
>>
>> Pushed to the emacs-29 branch.
>
> So is there more to do here, or should this bug be closed? I'm not sure
> if it's still needed to track the below.
>
>>> (although I'm surprised that diff-beginning-of-hunk can return
>>> a position that is not before point).
>>
>> Indeed, strange to see this in 'diff-beginning-of-hunk':
>>
>> (cond ...
>> ((re-search-backward regexp nil t)) ; In the middle of a hunk.
>> ((re-search-forward regexp nil t) ; At first hunk header.
>> =======
>>
>> Need to experiment more with this in master.
No further comments, so I'm closing this now. Please reopen if it's
needed to track the above.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Thu, 08 Feb 2024 12:24:13 GMT)
Full text and
rfc822 format available.
This bug report was last modified 1 year and 90 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.