Friday, July 3, 2015

Re: Diff mode via Tabs



On Thu, Jun 18, 2015 at 11:31 AM, Ben Fritz <fritzophrenic@gmail.com> wrote:
...
 
(Adapted from a .bat file I use in my "send to" menu on Windows, for choosing files one at a time for diff).

This is my first time trying to use Windows SendTo with Vim.

I created a SendTo short cut and created the following command line:

C:\Vim\vim74\gvim.exe --servername gDiff  +":RemoteDiffFiles"

Now, what I _really_ want it to do is this:

C:\Vim\vim74\gvim.exe --servername gDiff  +":RemoteDiffFiles %1"

In other words, do not let Vim "edit" the file, but pass the filename in as a argument to my command.

Let me tell you what I have working and where my current challenges are and what I am looking for.


For this command:
C:\Vim\vim74\gvim.exe --servername gDiff  +":RemoteDiffFiles"

I have setup the function that is called to loop through the argv() list which Vim provides and call the appropriate functions for each file in that list :echo argv().

This works great _but_, Vim opens that file first.  Which means if I already have the file open in another instance of Vim, I have to deal with the dialog ("Open read only, delete the swap, abort, quit, ...).  But really, I am not trying to edit the file at all, I am simply trying to take the filename and pass it along to a function (which in turn sends it to a different Vim).

Now, my plugin once it receives the file in the correct Vim instance uses the SwapExists autocmd and deals with everything appropriately.

Of course the SendTo command could highlight 10 files and "SendTo" Vim, so this format would never work:
C:\Vim\vim74\gvim.exe --servername gDiff  +":RemoteDiffFiles %1"

As there can be an unlimited number of files.  But it does represent what I really want to do, open Vim without a filelist, and instead pass the filename to my command.


So I had another idea.
Looking at gvim -h, it has the --cmd switch: {command} will be executed before processing any vimrc file.

If I could somehow get to argv() BEFORE Vim opened the files then I could hopefully use :argdelete to remove the list of files after my plugin has worked through each one.

When I tried with --cmd, it hasn't even loaded plugins yet and reported:
E492: Not an editor command: :RemoteDiffFiles


Any ideas on this one?

TIA,
David


--
--
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 vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: