Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how to highlight fine differences in Diff mode?

47 views
Skip to first unread message

Kevin Rodgers

unread,
Dec 6, 2005, 3:16:53 PM12/6/05
to help-gn...@gnu.org
I love Ediff. I mean, I really, really love it.

But sometimes I have to compare extremely large files, larger than Emacs
maximum buffer size. So I simply run diff and redirect its output to a
.diff file, which is easily small enought to visit and navigate in Diff
mode. What I'd like at that point is a command to highlight the changed
text within the current hunk, just like "*" does in Ediff:

,----[ C-h k * ]
| * runs the command ediff-make-or-kill-fine-diffs
| which is an interactive compiled Lisp function in `ediff-util'.
| (ediff-make-or-kill-fine-diffs ARG)
|
| Compute fine diffs. With negative prefix arg, kill fine diffs.
| In both cases, operates on the current difference region.
`----

Is there any way to take advantage of the Ediff machinery inside
Diff mode?

--
Kevin Rodgers

Stefan Monnier

unread,
Dec 6, 2005, 10:45:17 PM12/6/05
to
> Is there any way to take advantage of the Ediff machinery inside
> Diff mode?

Not right now, tho I'd be happy to take a patch for it.
It's been on the TODO list in diff-mode for a while now.
Note that I have recently written some related code for smerge-mode to do
a similar highlighting of refined differences in diff3 conflicts.


Stefan

Matthieu Moy

unread,
Dec 7, 2005, 2:54:06 AM12/7/05
to
Stefan Monnier <mon...@iro.umontreal.ca> writes:

Just my 2 cents: That would be GREAT!

--
Matthieu

Drew Adams

unread,
Dec 7, 2005, 11:19:35 AM12/7/05
to help-gn...@gnu.org
But sometimes I have to compare extremely large files, larger than Emacs
maximum buffer size. So I simply run diff and redirect its output to a
.diff file, which is easily small enought to visit and navigate in Diff
mode. What I'd like at that point is a command to highlight the changed
text within the current hunk, just like "*" does in Ediff:

,----[ C-h k * ]
| * runs the command ediff-make-or-kill-fine-diffs
| which is an interactive compiled Lisp function in `ediff-util'.
| (ediff-make-or-kill-fine-diffs ARG)
|
| Compute fine diffs. With negative prefix arg, kill fine diffs.
| In both cases, operates on the current difference region.
`----

Is there any way to take advantage of the Ediff machinery inside
Diff mode?

I don't have an answer for you, unfortunately. I do have some code that
improves the highlighting of regular `diff' output slightly:
http://www.emacswiki.org/cgi-bin/wiki/diff-mode-.el, but it doesn't do what
you're asking.

Alan Mackenzie

unread,
Dec 8, 2005, 9:29:54 AM12/8/05
to
Stefan Monnier <mon...@iro.umontreal.ca> wrote on Tue, 06 Dec 2005
22:45:17 -0500:

FWIW, Diff Mode is right up at the top of my list of favourite modes.

It has been my standard answer to colleagues who sometimes ask "what's so
good about Emacs?". I just put up a file.diff, and let the goggle over
the fontification - then I show them navigation with n, p, M-{, and M=},
which increases their interest, and finally I show them C-c C-c and C-c
C-a. It gets them interested. :-)

> Stefan

--
Alan Mackenzie (Munich, Germany)
Email: aa...@muuc.dee; to decode, wherever there is a repeated letter
(like "aa"), remove half of them (leaving, say, "a").

Kevin Rodgers

unread,
Dec 8, 2005, 1:58:43 PM12/8/05
to help-gn...@gnu.org

Just to let everyone know, I'm making pretty good progress. I'll
post as soon as I've got something useful.

--
Kevin Rodgers

David Combs

unread,
Jan 6, 2006, 8:38:36 PM1/6/06
to
In article <mailman.18320.11339724...@gnu.org>,

1: "diff-mode": never heard of it. Yes, there is one in the lisp
subdirectory, at least of 22.0.50.1 (old) cvs.

2: So, I suppose the diff-mode.el in the wiki, vs the one that
comes "in the box", have no relation to each other. (Well,
at least the on in the lisp dir says nothing about "drew adams".)

3: not seeing much doc in the built-in one (or in info, either),
what does diff-mode enable me to do (easily) that ediff-mode
doesn't?

4: In fact, are the two packages (for lack of better word)
based on different concepts of what a "diff in emacs"
should do?

5: Here's the tail end of the info-node "comparing files":


Differences between versions of files are often distributed as
"patches", which are the output from `diff' or a version control system
that uses `diff'. `M-x diff-mode' turns on Diff mode, a major mode for
viewing and editing patches, either as "unified diffs" or "context
diffs."

You can use `M-x smerge-mode' to turn on Smerge mode, a minor mode
for editing output from the `diff3' program. This is typically the
result of a failed merge from a version control system "update" outside
VC, due to conflicting changes to a file. Smerge mode provides
commands to resolve conflicts by selecting specific changes.

See also *Note Emerge::, and *Note Top: (ediff)Top, for convenient
facilities for merging two similar files.

Sure doesn't say much about diff-mode -- and suggests looking
at ediff ONLY IF YOU NEED TO *MERGE* FILES.

Methinks ediff has more uses than that????

David


Drew Adams

unread,
Jan 6, 2006, 8:58:31 PM1/6/06
to help-gn...@gnu.org
>I don't have an answer for you, unfortunately. I do have some code that
>improves the highlighting of regular `diff' output slightly:
>http://www.emacswiki.org/cgi-bin/wiki/diff-mode-.el, but it
>doesn't do what you're asking.

1: "diff-mode": never heard of it. Yes, there is one in the lisp
subdirectory, at least of 22.0.50.1 (old) cvs.

The library I mentioned was diff-mode-.el, not diff-mode.el. The former is a
minor enhancement to the latter. The latter has recently been updated in
CVS, and is now very similar to the former. If you are using CVS Emacs, you
can use just the latter. If you are using Emacs 21, you might want to use
both.

In any case, as I said, this does not respond directly to your question.

2: So, I suppose the diff-mode.el in the wiki, vs the one that
comes "in the box", have no relation to each other. (Well,
at least the on in the lisp dir says nothing about "drew adams".)

See above. I think the confusion is because of the similarity in library
names. I use a + or - after a standard library name when I write a library
that tweaks a standardard library. Sorry about the confusion.

3: not seeing much doc in the built-in one (or in info, either),
what does diff-mode enable me to do (easily) that ediff-mode
doesn't?

Diff-mode highlights an existing `diff' buffer, regardless of its source.
Ediff runs `diff' and then formats the result in a particularly useful way.
Ediff works on buffers, not just files.

If you just want to compare two buffers, use `ediff'.

4: In fact, are the two packages (for lack of better word)
based on different concepts of what a "diff in emacs"
should do?

Yes. It's harder to describe than to see - just try using `diff' on two
files and then using `ediff' on them.

5: Here's the tail end of the info-node "comparing files":

Differences between versions of files are often distributed as
"patches", which are the output from `diff' or a version control system
that uses `diff'. `M-x diff-mode' turns on Diff mode, a major mode for
viewing and editing patches, either as "unified diffs" or "context
diffs."

You can use `M-x smerge-mode' to turn on Smerge mode, a minor mode
for editing output from the `diff3' program. This is typically the
result of a failed merge from a version control system "update" outside
VC, due to conflicting changes to a file. Smerge mode provides
commands to resolve conflicts by selecting specific changes.

See also *Note Emerge::, and *Note Top: (ediff)Top, for convenient
facilities for merging two similar files.


Sure doesn't say much about diff-mode -- and suggests looking
at ediff ONLY IF YOU NEED TO *MERGE* FILES.

Methinks ediff has more uses than that????

Yes, `ediff' is very useful. `diff-mode' just provides highlighting for the
output from `diff'. If someone gives you `diff' output (e.g. a patch), then
you can browse (and even edit) it while it is highlighted by `diff-mode'.

David Combs

unread,
Jan 10, 2006, 8:59:19 PM1/10/06
to
In article <mailman.217.113659923...@gnu.org>,

Drew Adams <drew....@oracle.com> wrote:
> >I don't have an answer for you, unfortunately. I do have some code that
> >improves the highlighting of regular `diff' output slightly:
> >http://www.emacswiki.org/cgi-bin/wiki/diff-mode-.el, but it
> >doesn't do what you're asking.
>
> 1: "diff-mode": never heard of it. Yes, there is one in the lisp
> subdirectory, at least of 22.0.50.1 (old) cvs.
>
>The library I mentioned was diff-mode-.el, not diff-mode.el. The former is a
>minor enhancement to the latter. The latter has recently been updated in
>CVS, and is now very similar to the former. If you are using CVS Emacs, you
>can use just the latter. If you are using Emacs 21, you might want to use
>both.
>
...


Thanks so much for the explanation! Makes it all clear.

Maybe edit that (excellent) explanation into the file (if it's
not already there -- haven't yet grabbed diff-mode-.el).

Thanks!

David


Drew Adams

unread,
Jan 10, 2006, 10:09:30 PM1/10/06
to help-gn...@gnu.org
> The library I mentioned was diff-mode-.el, not diff-mode.el.
> The former is a minor enhancement to the latter. The latter
> has recently been updated in CVS, and is now very similar to
> the former. If you are using CVS Emacs, you can use just the
> latter. If you are using Emacs 21, you might want to use
> both.

Thanks so much for the explanation! Makes it all clear.

Maybe edit that (excellent) explanation into the file (if it's
not already there -- haven't yet grabbed diff-mode-.el).

Yes, there is such an explanation in the file.

There is also a more general explanation here:
http://www.emacswiki.org/cgi-bin/wiki/DrewsElispLibraries#LibraryNames.

0 new messages