* off-topic: Conversion multi-line diff to single-line
@ 2011-08-29 5:39 Werner LEMBERG
2011-08-29 16:08 ` Stefan Monnier
2011-08-29 21:04 ` Juri Linkov
0 siblings, 2 replies; 6+ messages in thread
From: Werner LEMBERG @ 2011-08-29 5:39 UTC (permalink / raw)
To: emacs-devel
Folks,
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.
Werner
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: off-topic: Conversion multi-line diff to single-line
2011-08-29 5:39 off-topic: Conversion multi-line diff to single-line Werner LEMBERG
@ 2011-08-29 16:08 ` Stefan Monnier
2011-08-29 21:04 ` Juri Linkov
1 sibling, 0 replies; 6+ messages in thread
From: Stefan Monnier @ 2011-08-29 16:08 UTC (permalink / raw)
To: Werner LEMBERG; +Cc: emacs-devel
> 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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: off-topic: Conversion multi-line diff to single-line
2011-08-29 5:39 off-topic: Conversion multi-line diff to single-line Werner LEMBERG
2011-08-29 16:08 ` Stefan Monnier
@ 2011-08-29 21:04 ` Juri Linkov
2011-09-03 6:38 ` Werner LEMBERG
1 sibling, 1 reply; 6+ messages in thread
From: Juri Linkov @ 2011-08-29 21:04 UTC (permalink / raw)
To: Werner LEMBERG; +Cc: emacs-devel
> Such an output greatly simplifies comparison of large sorted word
> lists with sparse or systematic insertions, deletions, or changes.
I suggest you using `diff --side-by-side --suppress-common-lines'
as is or by converting its output to the Diff normal format
that would be trivial to do from the side-by-side format.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: off-topic: Conversion multi-line diff to single-line
2011-08-29 21:04 ` Juri Linkov
@ 2011-09-03 6:38 ` Werner LEMBERG
2011-09-03 9:42 ` Juri Linkov
0 siblings, 1 reply; 6+ messages in thread
From: Werner LEMBERG @ 2011-09-03 6:38 UTC (permalink / raw)
To: juri; +Cc: emacs-devel
>> Such an output greatly simplifies comparison of large sorted word
>> lists with sparse or systematic insertions, deletions, or changes.
>
> I suggest you using `diff --side-by-side --suppress-common-lines' as
> is or by converting its output to the Diff normal format that would
> be trivial to do from the side-by-side format.
Thanks for the idea, but this is exactly equivalent to a normal diff
output. Note that you can get output like this
> foo1
> foo2
> foo3
> foo4
bar1 <
bar2 <
bar3 <
which is no longer trivial to convert.
Werner
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: off-topic: Conversion multi-line diff to single-line
2011-09-03 6:38 ` Werner LEMBERG
@ 2011-09-03 9:42 ` Juri Linkov
2011-09-03 10:28 ` Werner LEMBERG
0 siblings, 1 reply; 6+ messages in thread
From: Juri Linkov @ 2011-09-03 9:42 UTC (permalink / raw)
To: Werner LEMBERG; +Cc: emacs-devel
> Thanks for the idea, but this is exactly equivalent to a normal diff
> output. Note that you can get output like this
>
> > foo1
> > foo2
> > foo3
> > foo4
> bar1 <
> bar2 <
> bar3 <
>
> which is no longer trivial to convert.
I don't know what kind of input can produce such an output.
When I run `diff --side-by-side --suppress-common-lines' it returns:
foo1 | bar1
foo2 | bar2
foo3 | bar3
foo4 <
Writing a script that replaces " | " with "< " and " >" you can get:
< foo1
> bar1
< foo2
> bar2
< foo3
> bar3
< foo4
that is not equivalent to a normal diff output that groups adjacent lines
into diff hunks like:
< foo1
< foo2
< foo3
< foo4
> bar1
> bar2
> bar3
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: off-topic: Conversion multi-line diff to single-line
2011-09-03 9:42 ` Juri Linkov
@ 2011-09-03 10:28 ` Werner LEMBERG
0 siblings, 0 replies; 6+ messages in thread
From: Werner LEMBERG @ 2011-09-03 10:28 UTC (permalink / raw)
To: juri; +Cc: emacs-devel
>> Note that you can get output like this
>>
>> > foo1
>> > foo2
>> > foo3
>> > foo4
>> bar1 <
>> bar2 <
>> bar3 <
>>
>> which is no longer trivial to convert.
>
> I don't know what kind of input can produce such an output.
:-) Here an example:
Ab-na-be-lungs|pro-zeß | Ab-na-be-lungs|pro-zess
Ab·neh·mer·in.du·strie | Ab·neh·mer·in.dus·trie
Ab·neh·mer·in.du·stri·en | Ab·neh·mer·in.dus·tri·en
> ab-ni-cken
> Ab-ni-ckens
> Ab-ni-cker
> Ab-ni-ckern
ab·ni{ck/k·k}en <
Ab·ni{ck/k·k}ens <
Ab·ni{ck/k·k}er <
Ab·ni{ck/k·k}ern <
ab-nor-mal-ste | ab-nor-mals-te
ab-nor-mal-stem | ab-nor-mals-tem
ab-nor-mal-sten | ab-nor-mals-ten
I suppose that `diff' is doing this if the lines are too different,
according to a certain built-in algorithm.
BTW, I also have this:
ab·pa{ck/k·k}en | ab-pa-cken
Ab·pa{ck/k·k}er | Ab-pa-cker
Ab·pa{ck/k·k}ung <
Ab·pa{ck/k·k}un·gen <
> Ab-pa-ckung
> Ab-pa-ckun-gen
ab-paßt | ab-passt
ab-paß-te | ab-pass-te
(this is, first lines with < and then lines with >).
Werner
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-09-03 10:28 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-29 5:39 off-topic: Conversion multi-line diff to single-line Werner LEMBERG
2011-08-29 16:08 ` Stefan Monnier
2011-08-29 21:04 ` Juri Linkov
2011-09-03 6:38 ` Werner LEMBERG
2011-09-03 9:42 ` Juri Linkov
2011-09-03 10:28 ` Werner LEMBERG
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.