This is a specific scenario from a thread Ben and I have been having from
the "Diff mode via Tabs" thread.

What I would like to do is use Windows SendTo menu, which allows the user
to choose "n" number of files and send them to Vim.

Easy to do, create a SendTo item which has gvim.exe, highlight multiple
files, right click and choose your SentTo shortcut and voila.

Now here is the twist.

I don't want Vim to load any of the files passed to it.  I simply want the
argument list (:echo argv()).

Reasoning below to read through.

The --remote-* commands don't work, since the Vim instance I want may or
may not already be running.

-n (no swap file) on the command line doesn't work, if this is the correct
Vim instance, I want the swap file.

I was hoping for ideas like:

1.  A setting I can change

2.  An autocmd I can create and therefore provide some command line
argument to tell it not to load the files from the command line

3.  ...



Here is my full story with some various ways I have tried and problems with
each.


I am wondering if there is a command line argument or some setting which I
can change to tell Vim to simply update it argument list.

The goal would be something like this:
gvim.exe --servername DIFF +"MyCommand"

The idea here is "MyCommand" will use the argument list provided and do
something with it.

I have explored the use of the --remote-* commands.

The main issue with these is they FAIL is that Vim instance needed is not
already running.


$ gvim.exe --servername DIFF --remote-send "echo 1"

This one tells me the vim instance DIFF isn't running (which it isn't).

$ gvim.exe --servername DIFF --remote-expr "echo 1"

Same with this one.

I don't want to pre-start my instance of Vim, nor do I want the user to
have to do this.

Best case scenario:
If that Vim instance is not already running, then the instance just
launched (which --remote-expr) should assume it's name (and stay running).

But that is not how those command works.

So my next best option is to launch Vim normally (accepting the file list
from the SendTo command), but preventing Vim from opening the files.  That
way, after the argument list is updated and "MyCommand" is called, it can
choose what to do with the files in the argument list.

I can start Vim using -n (noswapfile), but if this is the first instance of
DIFF, then I am lacking the swap file, which is not what I want.


If you do the following:
gvim.exe --servername DIFF
gvim.exe --servername DIFF

You get two instances of Vim running with server names of:
DIFF
DIFF1

So in the 2nd case, my plugin notices we are not in the correct instance
and sends the files over to the first instance.

That is why I cannot allow the DIFF1 instance to open the files, since they
will be edited in the DIFF instance.  If the files are already open in
another Vim instance, you will get a prompt indicating the .swp file
exists.  My plugin already deals with this in the CORRECT instance of Vim,
which is why in the DIFF1 instance, I don't want Vim to begin editing the
file.

But yet I want the argument list that DIFF1 was started with, so I know
which files to send over to the DIFF instance.


Looking through gvim --help:

--cmd fires before loading any vimrc, this is too early as my plugin has
not even loaded.

-c files _after_ the first file is loaded, which is too late.

--remote-* requires the Vim instance to be started ahead of time


Any ideas is greatly appreciated.

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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to