GNU bug report logs - #18128
Diff-mode doesn't refine hunks automatically

Previous Next

Package: emacs;

Reported by: Paul Pogonyshev <pogonyshev <at> gmail.com>

Date: Mon, 28 Jul 2014 14:00:02 UTC

Severity: wishlist

Tags: fixed

Merged with 12747, 16798, 21744

Found in versions 23.4, 24.5

Fixed in version 27.1

Done: Noam Postavsky <npostavs <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 18128 in the body.
You can then email your comments to 18128 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#18128; Package emacs. (Mon, 28 Jul 2014 14:00:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Paul Pogonyshev <pogonyshev <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 28 Jul 2014 14:00:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Paul Pogonyshev <pogonyshev <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Diff-mode doesn't refine hunks automatically
Date: Mon, 28 Jul 2014 15:59:12 +0200
[Message part 1 (text/plain, inline)]
Diff-mode should just refine hunks automatically when visiting a buffer. If
it is a performance concern, there should be some customization option for
it and/or this could be done lazily.

Chunk refining is just too useful to not have.

Paul
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18128; Package emacs. (Mon, 28 Jul 2014 14:29:01 GMT) Full text and rfc822 format available.

Message #8 received at 18128 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Paul Pogonyshev <pogonyshev <at> gmail.com>
Cc: 18128 <at> debbugs.gnu.org
Subject: Re: bug#18128: Diff-mode doesn't refine hunks automatically
Date: Mon, 28 Jul 2014 17:28:09 +0300
> Date: Mon, 28 Jul 2014 15:59:12 +0200
> From: Paul Pogonyshev <pogonyshev <at> gmail.com>
> 
> Diff-mode should just refine hunks automatically when visiting a buffer. If
> it is a performance concern, there should be some customization option for
> it and/or this could be done lazily.
> 
> Chunk refining is just too useful to not have.

Why isn't diff-auto-refine-mode enough?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18128; Package emacs. (Mon, 28 Jul 2014 14:41:02 GMT) Full text and rfc822 format available.

Message #11 received at 18128 <at> debbugs.gnu.org (full text, mbox):

From: Paul Pogonyshev <pogonyshev <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 18128 <at> debbugs.gnu.org
Subject: Re: bug#18128: Diff-mode doesn't refine hunks automatically
Date: Mon, 28 Jul 2014 16:39:56 +0200
[Message part 1 (text/plain, inline)]
It is enough. Then please add a reference to it to documentation of
diff-refine-hunk, I wasn't even aware of that mode.

Paul


On 28 July 2014 16:28, Eli Zaretskii <eliz <at> gnu.org> wrote:

> > Date: Mon, 28 Jul 2014 15:59:12 +0200
> > From: Paul Pogonyshev <pogonyshev <at> gmail.com>
> >
> > Diff-mode should just refine hunks automatically when visiting a buffer.
> If
> > it is a performance concern, there should be some customization option
> for
> > it and/or this could be done lazily.
> >
> > Chunk refining is just too useful to not have.
>
> Why isn't diff-auto-refine-mode enough?
>
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18128; Package emacs. (Mon, 28 Jul 2014 14:45:02 GMT) Full text and rfc822 format available.

Message #14 received at 18128 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Paul Pogonyshev <pogonyshev <at> gmail.com>
Cc: 18128 <at> debbugs.gnu.org
Subject: Re: bug#18128: Diff-mode doesn't refine hunks automatically
Date: Mon, 28 Jul 2014 17:44:36 +0300
> Date: Mon, 28 Jul 2014 16:39:56 +0200
> From: Paul Pogonyshev <pogonyshev <at> gmail.com>
> Cc: 18128 <at> debbugs.gnu.org
> 
> It is enough. Then please add a reference to it to documentation of
> diff-refine-hunk, I wasn't even aware of that mode.

It is currently mentioned there as follows:

   `M-n'
	Move to the next hunk-start (`diff-hunk-next').

	This command has a side effect: it "refines" the hunk you move to,
	highlighting its changes with better granularity.  To disable this
	feature, type `M-x diff-auto-refine-mode' to toggle off the minor
	mode Diff Auto-Refine mode.  To disable Diff Auto Refine mode by
	default, add this to your init file (*note Hooks::):

	     (add-hook 'diff-mode-hook
		       (lambda () (diff-auto-refine-mode -1)))

If you think this is not enough, please tell what else would you like
to see there about this minor mode.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18128; Package emacs. (Mon, 28 Jul 2014 14:46:02 GMT) Full text and rfc822 format available.

Message #17 received at 18128 <at> debbugs.gnu.org (full text, mbox):

From: Paul Pogonyshev <pogonyshev <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 18128 <at> debbugs.gnu.org
Subject: Re: bug#18128: Diff-mode doesn't refine hunks automatically
Date: Mon, 28 Jul 2014 16:45:39 +0200
[Message part 1 (text/plain, inline)]
Actually, it seems it is not enough. My usecase: I open a fairly large diff
file with many changes like

-bla bla bla a long line were some word was changed or maybe two
+bla bla bla a long line where some word was changed or maybe two

I want to be able to immediately see the changes, without reading whole
lines and certainly without visiting the hunks. When Emacs highlights the
change (there is only one above), I see it right away. Otherwise I have to
scan the lines with my eyes, which is tedious and error-prone. Of course I
can also hit C-c C-b on each hunk, but it feels like some sort of work I'd
prefer Emacs do for me.

Paul


On 28 July 2014 16:39, Paul Pogonyshev <pogonyshev <at> gmail.com> wrote:

> It is enough. Then please add a reference to it to documentation of
> diff-refine-hunk, I wasn't even aware of that mode.
>
> Paul
>
>
> On 28 July 2014 16:28, Eli Zaretskii <eliz <at> gnu.org> wrote:
>
>> > Date: Mon, 28 Jul 2014 15:59:12 +0200
>> > From: Paul Pogonyshev <pogonyshev <at> gmail.com>
>> >
>> > Diff-mode should just refine hunks automatically when visiting a
>> buffer. If
>> > it is a performance concern, there should be some customization option
>> for
>> > it and/or this could be done lazily.
>> >
>> > Chunk refining is just too useful to not have.
>>
>> Why isn't diff-auto-refine-mode enough?
>>
>
>
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18128; Package emacs. (Mon, 28 Jul 2014 14:50:02 GMT) Full text and rfc822 format available.

Message #20 received at 18128 <at> debbugs.gnu.org (full text, mbox):

From: Paul Pogonyshev <pogonyshev <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 18128 <at> debbugs.gnu.org
Subject: Re: bug#18128: Diff-mode doesn't refine hunks automatically
Date: Mon, 28 Jul 2014 16:49:36 +0200
[Message part 1 (text/plain, inline)]
I'd like hunks to be refined regardless of the way I move around the file.
E.g. if I chose to page-up through uninteresting parts of the diff,
auto-refinining shouldn't stop.

Paul


On 28 July 2014 16:44, Eli Zaretskii <eliz <at> gnu.org> wrote:

> > Date: Mon, 28 Jul 2014 16:39:56 +0200
> > From: Paul Pogonyshev <pogonyshev <at> gmail.com>
> > Cc: 18128 <at> debbugs.gnu.org
> >
> > It is enough. Then please add a reference to it to documentation of
> > diff-refine-hunk, I wasn't even aware of that mode.
>
> It is currently mentioned there as follows:
>
>    `M-n'
>         Move to the next hunk-start (`diff-hunk-next').
>
>         This command has a side effect: it "refines" the hunk you move to,
>         highlighting its changes with better granularity.  To disable this
>         feature, type `M-x diff-auto-refine-mode' to toggle off the minor
>         mode Diff Auto-Refine mode.  To disable Diff Auto Refine mode by
>         default, add this to your init file (*note Hooks::):
>
>              (add-hook 'diff-mode-hook
>                        (lambda () (diff-auto-refine-mode -1)))
>
> If you think this is not enough, please tell what else would you like
> to see there about this minor mode.
>
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18128; Package emacs. (Mon, 28 Jul 2014 23:29:01 GMT) Full text and rfc822 format available.

Message #23 received at 18128 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Paul Pogonyshev <pogonyshev <at> gmail.com>
Cc: 18128 <at> debbugs.gnu.org
Subject: Re: bug#18128: Diff-mode doesn't refine hunks automatically
Date: Mon, 28 Jul 2014 19:28:21 -0400
> Diff-mode should just refine hunks automatically when visiting a buffer. If
> it is a performance concern, there should be some customization option for
> it and/or this could be done lazily.

Agreed, it should be done "as part of font-locking".


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18128; Package emacs. (Sun, 17 Jan 2016 06:23:01 GMT) Full text and rfc822 format available.

Message #26 received at 18128 <at> debbugs.gnu.org (full text, mbox):

From: Hong Xu <hong <at> topbug.net>
To: 18128 <at> debbugs.gnu.org
Subject: Should be done as part of the font-lock
Date: Sat, 16 Jan 2016 22:22:45 -0800
[Message part 1 (text/plain, inline)]
I agree that this should be done as part of the font-lock. This issue
not only causes inconvenience, but also causes bug #21990, which does
not allow htmlfontify to correctly display the highlighting.

Hong

[signature.asc (application/pgp-signature, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18128; Package emacs. (Fri, 04 Nov 2016 07:55:01 GMT) Full text and rfc822 format available.

Message #29 received at 18128 <at> debbugs.gnu.org (full text, mbox):

From: Hong Xu <hong <at> topbug.net>
To: 18128 <at> debbugs.gnu.org
Subject: Re: Should be done as part of the font-lock
Date: Fri, 04 Nov 2016 00:54:17 -0700
[Message part 1 (text/plain, inline)]
I currently use the following to do auto refining: (modified from
http://emacs.stackexchange.com/a/28321/2755 )

    (defun my-diff-refine-all ()
    "Refine all diffs."
    (interactive)
    (save-excursion
        (goto-char (point-min))
        (ignore-errors
            (diff-beginning-of-hunk t))
        (ignore-errors
            (while (not (eobp))
            (diff-refine-hunk)
            (diff-hunk-next)))))
    (defun my-diff-hunks-highlight-all ()
    "Highlight all hunks in diff-mode."
    (add-hook 'font-lock-mode-hook #'my-diff-refine-all t t))
    (add-hook 'diff-mode-hook 'my-diff-hunks-highlight-all)

Not sure whether it is possible to merge into Emacs after some
adjustment.
[signature.asc (application/pgp-signature, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18128; Package emacs. (Sat, 05 Nov 2016 02:10:01 GMT) Full text and rfc822 format available.

Message #32 received at 18128 <at> debbugs.gnu.org (full text, mbox):

From: npostavs <at> users.sourceforge.net
To: Paul Pogonyshev <pogonyshev <at> gmail.com>
Cc: 18128 <at> debbugs.gnu.org
Subject: Re: bug#18128: Diff-mode doesn't refine hunks automatically
Date: Fri, 04 Nov 2016 22:10:13 -0400
Paul Pogonyshev <pogonyshev <at> gmail.com> writes:

> Diff-mode should just refine hunks automatically when visiting a
> buffer. If it is a performance concern, there should be some
> customization option for it and/or this could be done lazily.
>

A patch was recently added to magit that let-binds
write-region-inhibit-fsync around the call to diff-refine-hunk, this was
reported to make a significant improvement in speed when refining all
hunks in a diff.  We should do the same for smerge-refine-subst (or is
it possible to do this automatically for all temp files?) before
extending diff refinement over the whole buffer.

https://patch-diff.githubusercontent.com/raw/magit/magit/pull/2834.patch




Merged 12747 16798 18128 21744. Request was from Noam Postavsky <npostavs <at> gmail.com> to control <at> debbugs.gnu.org. (Thu, 12 Jul 2018 00:29:02 GMT) Full text and rfc822 format available.

Added tag(s) fixed. Request was from Noam Postavsky <npostavs <at> gmail.com> to control <at> debbugs.gnu.org. (Thu, 12 Jul 2018 00:29:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 27.1, send any further explanations to 12747 <at> debbugs.gnu.org and Oleksandr Gavenko <gavenkoa <at> gmail.com> Request was from Noam Postavsky <npostavs <at> gmail.com> to control <at> debbugs.gnu.org. (Thu, 12 Jul 2018 00:29:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 10 Aug 2018 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 7 years and 2 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.