How to use my own diff tool ?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

How to use my own diff tool ?

Thomas B
Hello

I am struggling at comparing xml file (vim -d file1.xml file2.xml). Usual GNU diff does not produce useful data. So I am looking to use my custom and structure aware diff tool with vim. Because viewing difference is still a concern and vim allow to do that.

So I follow the manual notes and put following lines in my .vimrc:

set diffexpr=MyDiff()

function MyDiff()
  silent execute '!my_custom_diff '. v:fname_in . ' ' . v:fname_new . ' > ' .v:fname_out
endfunction

But all my trial finish by "E97: Cannot create diffs" message. While my_custom_diff in standalone produce an output compatible to what GNU diff can produce...
I end up to search this message in the vim source code and found that vim prior to run the diff on user's files is performing a sanity check of the diff command with pattern: "line1\n" compare to "line2\n" (source code comment refer to "quick test")
My custom tool is unable to produce the expected result since it must run exclusively on xml file.

I did not found any way to bypass this "quick test". Is there a way ?
Is my use case valid ? I mean the usage of a diff tool not correctly answering to the "quick test" procedure ?

Thanks for your help and comment.
Thomas

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to use my own diff tool ?

Bram Moolenaar

Thomas Burg wrote:

> I am struggling at comparing xml file (vim -d file1.xml file2.xml). Usual GNU diff does not produce useful data. So I am looking to use my custom and structure aware diff tool with vim. Because viewing difference is still a concern and vim allow to do that.
>
> So I follow the manual notes and put following lines in my .vimrc:
>
> set diffexpr=MyDiff()
>
> function MyDiff()
>   silent execute '!my_custom_diff '. v:fname_in . ' ' . v:fname_new . ' > ' .v:fname_out
> endfunction
>
> But all my trial finish by "E97: Cannot create diffs" message. While my_custom_diff in standalone produce an output compatible to what GNU diff can produce...
> I end up to search this message in the vim source code and found that vim prior to run the diff on user's files is performing a sanity check of the diff command with pattern: "line1\n" compare to "line2\n" (source code comment refer to "quick test")
> My custom tool is unable to produce the expected result since it must run exclusively on xml file.
>
> I did not found any way to bypass this "quick test". Is there a way ?
> Is my use case valid ? I mean the usage of a diff tool not correctly answering to the "quick test" procedure ?

There is no way around it.  Can't you make your diff command produce the
expected output?

--
One difference between a man and a machine is that a machine is quiet
when well oiled.

 /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to use my own diff tool ?

Tony Mechelynck
In reply to this post by Thomas B
On Sun, Sep 9, 2018 at 3:49 PM Thomas B <[hidden email]> wrote:

>
> Hello
>
> I am struggling at comparing xml file (vim -d file1.xml file2.xml). Usual GNU diff does not produce useful data. So I am looking to use my custom and structure aware diff tool with vim. Because viewing difference is still a concern and vim allow to do that.
>
> So I follow the manual notes and put following lines in my .vimrc:
>
> set diffexpr=MyDiff()
>
> function MyDiff()
>   silent execute '!my_custom_diff '. v:fname_in . ' ' . v:fname_new . ' > ' .v:fname_out
> endfunction
>
> But all my trial finish by "E97: Cannot create diffs" message. While my_custom_diff in standalone produce an output compatible to what GNU diff can produce...
> I end up to search this message in the vim source code and found that vim prior to run the diff on user's files is performing a sanity check of the diff command with pattern: "line1\n" compare to "line2\n" (source code comment refer to "quick test")
> My custom tool is unable to produce the expected result since it must run exclusively on xml file.
>
> I did not found any way to bypass this "quick test". Is there a way ?
> Is my use case valid ? I mean the usage of a diff tool not correctly answering to the "quick test" procedure ?
>
> Thanks for your help and comment.
> Thomas

Maybe you could "cheat" and adjust your custom tool to fall back on
/usr/bin/diff (or wherever GNU diff is found) until or unless you get
a line beginning in <?xml followed by a space?

Also, make sure that your custom tool produces "old-style" diff output
as laid out at ":help diff-diffexpr" and in particular NOT a context
or unified diff.

Best regards,
Tony.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to use my own diff tool ?

Thomas B
Bram, Tony,

I will do as you suggest. Probably use a wrapper between vim and my custom tool that will choose if I need to use the GNU diff or something else.
I already take care of the expected style.

Thanks
Thomas

Le dim. 9 sept. 2018 à 16:09, Tony Mechelynck <[hidden email]> a écrit :
On Sun, Sep 9, 2018 at 3:49 PM Thomas B <[hidden email]> wrote:
>
> Hello
>
> I am struggling at comparing xml file (vim -d file1.xml file2.xml). Usual GNU diff does not produce useful data. So I am looking to use my custom and structure aware diff tool with vim. Because viewing difference is still a concern and vim allow to do that.
>
> So I follow the manual notes and put following lines in my .vimrc:
>
> set diffexpr=MyDiff()
>
> function MyDiff()
>   silent execute '!my_custom_diff '. v:fname_in . ' ' . v:fname_new . ' > ' .v:fname_out
> endfunction
>
> But all my trial finish by "E97: Cannot create diffs" message. While my_custom_diff in standalone produce an output compatible to what GNU diff can produce...
> I end up to search this message in the vim source code and found that vim prior to run the diff on user's files is performing a sanity check of the diff command with pattern: "line1\n" compare to "line2\n" (source code comment refer to "quick test")
> My custom tool is unable to produce the expected result since it must run exclusively on xml file.
>
> I did not found any way to bypass this "quick test". Is there a way ?
> Is my use case valid ? I mean the usage of a diff tool not correctly answering to the "quick test" procedure ?
>
> Thanks for your help and comment.
> Thomas

Maybe you could "cheat" and adjust your custom tool to fall back on
/usr/bin/diff (or wherever GNU diff is found) until or unless you get
a line beginning in <?xml followed by a space?

Also, make sure that your custom tool produces "old-style" diff output
as laid out at ":help diff-diffexpr" and in particular NOT a context
or unified diff.

Best regards,
Tony.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.