unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* ediff maximum line length?
@ 2011-02-11  4:18 Giorgos Keramidas
  2011-02-11  4:48 ` Stefan Monnier
  0 siblings, 1 reply; 9+ messages in thread
From: Giorgos Keramidas @ 2011-02-11  4:18 UTC (permalink / raw)
  To: emacs-devel

ediff-mode highlights nicely all fine diffs within lines, using a
different face and this has proven *very* useful in many cases, but I've
now bumped on a case (and it will be often the case with some of the
stuff I'm lately doing) where ediff does not display fine diffs for
*very* long lines...

I did try setting up `ediff-auto-refine-limit' to a larger value, e.g.:

    (setq-default ediff-auto-refine-limit 16000)

But then the entire line is marked as 'fine diff' when I try for example
to diff the following files:

    perl -e 'print "x" x 15000 . "\n"' > file-a.txt
    perl -e 'print "x" x  8000 . "yyy" . "x" x 6977 . "\n"' > file-b.txt

Is the behavior of highlighting the full line as fine diff bogus when I
have configured `ediff-auto-refine-limit' to 16000?

If this is not a bug, is there any way to really highlight only the
"yyy" characters in the middle of such a huge line?




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: ediff maximum line length?
  2011-02-11  4:18 ediff maximum line length? Giorgos Keramidas
@ 2011-02-11  4:48 ` Stefan Monnier
  2011-02-11  9:02   ` Giorgos Keramidas
  0 siblings, 1 reply; 9+ messages in thread
From: Stefan Monnier @ 2011-02-11  4:48 UTC (permalink / raw)
  To: Giorgos Keramidas; +Cc: emacs-devel

> ediff-mode highlights nicely all fine diffs within lines, using a
> different face and this has proven *very* useful in many cases, but I've
> now bumped on a case (and it will be often the case with some of the
> stuff I'm lately doing) where ediff does not display fine diffs for
> *very* long lines...

I don't know ediff very much, but diff-mode also highlights fine diffs
(via diff-refine-hunk or diff-auto-refine-mode, for example).  I know
this code fairly well since I wrote it, and to the best of my knowledge
it should not care about line-length (tho I haven't checked its
efficiency in the presence of very long lines).


        Stefan



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: ediff maximum line length?
  2011-02-11  4:48 ` Stefan Monnier
@ 2011-02-11  9:02   ` Giorgos Keramidas
  2011-02-11  9:06     ` Lennart Borgman
  2011-02-11 14:27     ` Stefan Monnier
  0 siblings, 2 replies; 9+ messages in thread
From: Giorgos Keramidas @ 2011-02-11  9:02 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

On Thu, 10 Feb 2011 23:48:55 -0500, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>> ediff-mode highlights nicely all fine diffs within lines, using a
>> different face and this has proven *very* useful in many cases, but
>> I've now bumped on a case (and it will be often the case with some of
>> the stuff I'm lately doing) where ediff does not display fine diffs
>> for *very* long lines...
>
> I don't know ediff very much, but diff-mode also highlights fine diffs
> (via diff-refine-hunk or diff-auto-refine-mode, for example).  I know
> this code fairly well since I wrote it, and to the best of my
> knowledge it should not care about line-length (tho I haven't checked
> its efficiency in the presence of very long lines).

That's good to know. Thank you.

I am looking for something that can compare two files, so that I can
launch Emacs as my diff tool, e.g. from Perforce, Subversion, etc.  I
don't know if diff-mode can compare two files instead of a buffer and
its file.  That's why I used ediff.  (Another reason is that I know its
key bindings from vc, but that's not something I can't live without.)

Right now I have a small shell script as a wrapper that does something
like this simplified version:

    if test -d "$1"/. && test -d "$2"/. ; then
        exec emacs --eval "(ediff-directories \"$1\" \"$2\" nil)"
    else
        exec emacs --eval "(ediff-files \"$1\" \"$2\")"
    fi

Is it possible to use diff-mode for the same sort of comparison?




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: ediff maximum line length?
  2011-02-11  9:02   ` Giorgos Keramidas
@ 2011-02-11  9:06     ` Lennart Borgman
  2011-02-11  9:17       ` Giorgos Keramidas
  2011-02-11 14:27     ` Stefan Monnier
  1 sibling, 1 reply; 9+ messages in thread
From: Lennart Borgman @ 2011-02-11  9:06 UTC (permalink / raw)
  To: Giorgos Keramidas; +Cc: Stefan Monnier, emacs-devel

On Fri, Feb 11, 2011 at 10:02 AM, Giorgos Keramidas
<keramida@ceid.upatras.gr> wrote:
>
> Right now I have a small shell script as a wrapper that does something
> like this simplified version:
>
>    if test -d "$1"/. && test -d "$2"/. ; then
>        exec emacs --eval "(ediff-directories \"$1\" \"$2\" nil)"
>    else
>        exec emacs --eval "(ediff-files \"$1\" \"$2\")"
>    fi
>
> Is it possible to use diff-mode for the same sort of comparison?

I never use diff-mode so I know little about that, but I wonder why
you do not use emacsclient in the above script. Would not that be very
much faster?



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: ediff maximum line length?
  2011-02-11  9:06     ` Lennart Borgman
@ 2011-02-11  9:17       ` Giorgos Keramidas
  0 siblings, 0 replies; 9+ messages in thread
From: Giorgos Keramidas @ 2011-02-11  9:17 UTC (permalink / raw)
  To: Lennart Borgman; +Cc: Stefan Monnier, emacs-devel

On Fri, 11 Feb 2011 10:06:49 +0100, Lennart Borgman <lennart.borgman@gmail.com> wrote:
>On Fri, Feb 11, 2011 at 10:02 AM, Giorgos Keramidas <keramida@ceid.upatras.gr> wrote:
>> Right now I have a small shell script as a wrapper that does something
>> like this simplified version:
>>
>>    if test -d "$1"/. && test -d "$2"/. ; then
>>        exec emacs --eval "(ediff-directories \"$1\" \"$2\" nil)"
>>    else
>>        exec emacs --eval "(ediff-files \"$1\" \"$2\")"
>>    fi
>>
>> Is it possible to use diff-mode for the same sort of comparison?
>
> I never use diff-mode so I know little about that, but I wonder why
> you do not use emacsclient in the above script. Would not that be very
> much faster?

You're right, of course.  I'm just trying to keep things 'simple' for
now.  Once I get it working, I'll try to make it faster.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: ediff maximum line length?
  2011-02-11  9:02   ` Giorgos Keramidas
  2011-02-11  9:06     ` Lennart Borgman
@ 2011-02-11 14:27     ` Stefan Monnier
  2011-02-11 21:45       ` Giorgos Keramidas
  1 sibling, 1 reply; 9+ messages in thread
From: Stefan Monnier @ 2011-02-11 14:27 UTC (permalink / raw)
  To: Giorgos Keramidas; +Cc: emacs-devel

> I am looking for something that can compare two files, so that I can
> launch Emacs as my diff tool, e.g. from Perforce, Subversion, etc.  I
> don't know if diff-mode can compare two files instead of a buffer and
> its file.

diff-mode is not a replacement for ediff in that it only helps you read
contextual diffs (i.e. the output of `diff' or other tools that output
in the same format).
So, if you do

  exec emacs --eval "(diff \"$1\" \"$2\")"

the resulting *diff* buffer will be in diff-mode.
  
> That's why I used ediff.  (Another reason is that I know its
> key bindings from vc, but that's not something I can't live without.)

From VC, C-x v = will give you a diff that's displayed in diff-mode.

For some uses, this is much better than ediff, but for others ediff is
more appropriate.  I've gotten so used to reading diffs that I don't use
ediff nearly as much as diff-mode, tho.

> Is it possible to use diff-mode for the same sort of comparison?

Yes, see above.


        Stefan


PS: For 3-way "diffs", smerge-mode provides a similar alternative to
ediff3, and also supports highlighting of fine diffs.
And there's probably a way to get diff3-style output from `diff', so as
to use smerge-mode for 2-way comparisons.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: ediff maximum line length?
  2011-02-11 14:27     ` Stefan Monnier
@ 2011-02-11 21:45       ` Giorgos Keramidas
  2011-02-11 22:01         ` Andreas Schwab
  0 siblings, 1 reply; 9+ messages in thread
From: Giorgos Keramidas @ 2011-02-11 21:45 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

On Fri, 11 Feb 2011 09:27:26 -0500, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>> I am looking for something that can compare two files, so that I can
>> launch Emacs as my diff tool, e.g. from Perforce, Subversion, etc.  I
>> don't know if diff-mode can compare two files instead of a buffer and
>> its file.
>
> diff-mode is not a replacement for ediff in that it only helps you read
> contextual diffs (i.e. the output of `diff' or other tools that output
> in the same format).
> So, if you do
>
>   exec emacs --eval "(diff \"$1\" \"$2\")"
>
> the resulting *diff* buffer will be in diff-mode.

Without fine diff highlighting though.  In the pathological case of very
long lines that I find myself often into lately (looking at diffs of
auto-generated code), fine diff highlighting is not only convenient, but
often necessary to spot tiny changes in the middle of a long line of
text that includes command-line options, removed arguments, new options
that replace old ones, etc.

>> Is it possible to use diff-mode for the same sort of comparison?
>
> Yes, see above.
>
>
>         Stefan
>
>
> PS: For 3-way "diffs", smerge-mode provides a similar alternative to
> ediff3, and also supports highlighting of fine diffs.  And there's
> probably a way to get diff3-style output from `diff', so as to use
> smerge-mode for 2-way comparisons.

That's nice.  I can produce a diff3 style patch by running:

    diff3 -m -L local -L base -L other \
        "my-file" /dev/null "other-file"

Then smerge-mode seems to be able to highlight fine diffs, as long as
there are non-word separators somewhere in the line.  It may take a bit
of getting used to, but I'll give it a try.  In the meantime, I'll try
to read some ediff source to understand where the fine-diff highlighting
limitation comes from.




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: ediff maximum line length?
  2011-02-11 21:45       ` Giorgos Keramidas
@ 2011-02-11 22:01         ` Andreas Schwab
  2011-02-12  9:00           ` Giorgos Keramidas
  0 siblings, 1 reply; 9+ messages in thread
From: Andreas Schwab @ 2011-02-11 22:01 UTC (permalink / raw)
  To: Giorgos Keramidas; +Cc: Stefan Monnier, emacs-devel

Giorgos Keramidas <keramida@ceid.upatras.gr> writes:

> On Fri, 11 Feb 2011 09:27:26 -0500, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>> diff-mode is not a replacement for ediff in that it only helps you read
>> contextual diffs (i.e. the output of `diff' or other tools that output
>> in the same format).
>> So, if you do
>>
>>   exec emacs --eval "(diff \"$1\" \"$2\")"
>>
>> the resulting *diff* buffer will be in diff-mode.
>
> Without fine diff highlighting though.

Anything wrong with diff-refine-hunk?

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: ediff maximum line length?
  2011-02-11 22:01         ` Andreas Schwab
@ 2011-02-12  9:00           ` Giorgos Keramidas
  0 siblings, 0 replies; 9+ messages in thread
From: Giorgos Keramidas @ 2011-02-12  9:00 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Stefan Monnier, emacs-devel

On Fri, 11 Feb 2011 23:01:18 +0100, Andreas Schwab <schwab@linux-m68k.org> wrote:
>Giorgos Keramidas <keramida@ceid.upatras.gr> writes:
>>On Fri, 11 Feb 2011 09:27:26 -0500, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>>> diff-mode is not a replacement for ediff in that it only helps you
>>> read contextual diffs (i.e. the output of `diff' or other tools that
>>> output in the same format).  So, if you do
>>>
>>>   exec emacs --eval "(diff \"$1\" \"$2\")"
>>>
>>> the resulting *diff* buffer will be in diff-mode.
>>
>> Without fine diff highlighting though.
>
> Anything wrong with diff-refine-hunk?

Now that I've modified the shell wrapper to `diff -u' first, that should
work too.  Thanks! :-)




^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2011-02-12  9:00 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-11  4:18 ediff maximum line length? Giorgos Keramidas
2011-02-11  4:48 ` Stefan Monnier
2011-02-11  9:02   ` Giorgos Keramidas
2011-02-11  9:06     ` Lennart Borgman
2011-02-11  9:17       ` Giorgos Keramidas
2011-02-11 14:27     ` Stefan Monnier
2011-02-11 21:45       ` Giorgos Keramidas
2011-02-11 22:01         ` Andreas Schwab
2011-02-12  9:00           ` Giorgos Keramidas

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).