bug#81375: diff-refine-hunk over-refines large unrelated replacement blocks

Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <[email protected]> Fri, 31 Jul 2026 10:27:17 -0400
Newsgroups gmane.emacs.bugs
Message-ID <[email protected]>
> Joining up hunks seems like something that ought to be diff(1)'s
> business, not Emacs?

`diff` aims to give a "minimal" set of changes, defined by some cost
measure, whereas what I find problematic in some cases of refinement is
that some "minimal" set of changes ends up too "complex", so I'd prefer
a suboptimal set.

I'm not sure we can easily tweak `diff`s cost measure to get what
we want, but it would be worth looking into it.  I think that's a much
larger change because I can't see any command line option to control the
cost measure, so it would require using some other tool.

BTW, it might be worth looking into the (re)use of the diff code we're
already using for `replace-region-contents`.


=== Stefan