emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: off-topic: Conversion multi-line diff to single-line


From: Stefan Monnier
Subject: Re: off-topic: Conversion multi-line diff to single-line
Date: Mon, 29 Aug 2011 12:08:34 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

> I have an off-topic question, and maybe you can help.  Is there a
> program or script which converts the multiline chunks of diff (without
> -u or -c) into single-line chunks?  This is, I want to have this

>    XXX
>    < foo1
>    < foo2
>    < foo3
>    ---
>> bar1
>> bar2
>> bar3

> converted into

>    XXX
>    < foo1
>    ---
>> bar1
>    YYY
>    < foo2
>    ---
>> bar2
>    ZZZ
>> foo3
>    ---
>    < bar3

> Such an output greatly simplifies comparison of large sorted word
> lists with sparse or systematic insertions, deletions, or changes.

Very good question.  I'd also like to see such a thing (tho on
the unified-diff format since that's the one I prefer).  I.e. turn

   --- .dir-locals.el   2011-04-24 18:34:57 +0000
   +++ .dir-locals.el   2011-05-27 23:05:19 +0000
   @@ -1,6 +1,6 @@
    ((nil . ((tab-width . 8)
   -         (sentence-end-double-space . t)
   -         (fill-column . 70)))
   +         (sentence-end-double-space . nil)
   +         (foo . 5)
   +         (fill-column . 79)
   +         (bar . 10)))
     (c-mode . ((c-file-style . "GNU")))

into

   --- .dir-locals.el   2011-04-24 18:34:57 +0000
   +++ .dir-locals.el   2011-05-27 23:05:19 +0000
   @@ -1,6 +1,6 @@
    ((nil . ((tab-width . 8)
   -         (sentence-end-double-space . t)
   +         (sentence-end-double-space . nil)
   +         (foo . 5)
   -         (fill-column . 70)))
   +         (fill-column . 79)
   +         (bar . 10)))
     (c-mode . ((c-file-style . "GNU")))

Your example is simpler but I think it's possible to handle mine
as well.  The needed info is available to diff-refine-hunk, so it should
be possible to extend diff-refine-hunk to diff-reorganize-hunk so as to
reduce the distance between matching words in the + and - lines.
Patches welcome.


        Stefan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]