> Птн, 07 Май 2010, David Fishburn писал(а):
>>
>> I was reading :h ole-interface.
>>
>> Is there anyway to spawn a new instance of Vim via OLE, through some
>> command (or anything)?
>> OLE automatically picks up the first already running Vim instance
>> which supports OLE.
>> If one is not running it spawns one.
>>
>> I was wanting to spawn a new one everytime.
>
> I forgot nearly all visual basic ole stuff by now. IIRC when a ole
> server is first registered, it stored a flag 'multiuse' inside window
> registry. If this flag is set, then you the same loaded server will be
> shared by different client. On the other hand, if it is 'singleuse',
> it will be the behavior that you asked for. Therefore this property
> is controlled by a flag in registry.
Thanks Bill.
I see in the code where we set the flags. These do not appear to set
in the Windows Registry though (or at least I couldn't find it). I
was originally hoping to tweak it after Vim was started.
Once I hit the above road block I started thinking about Vim's client
server feature. I have use the --servername and --remote-send
features from the command line in the past.
:h clientserver
Shows there are similar functions which can be used from within Vim
script. So in the end, I was able to accomplish what I was looking
for, by something as simple as:
function! MyFunction(filename, encoding)
let cmd = ':e '.' '.a:filename. "\n"
if g:my_servername == '' || g:my_servername == v:servername
exec cmd
else
if match( serverlist(), '\<'.g:my_servername.'\>' ) > -1
call remote_send( g:my_servername, cmd )
endif
endif
So this essentially forwarded my request on to the correct Vim
instance. Since all Vim's register OLE, you don't really have any
control over which one you talk to. So this works quite well.
Dave
--
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
No comments:
Post a Comment