> Please explain what this would do what vim.command() isn't doing.
> I mean the one explained below ":he python-vim".
You can start multiple threads in python. The help didn't say tat
vim.command() is thread safe. However it would be nice to replace this
executeVimCommand hackery with a more native, non blocking thread safe command.
Then you could start writing nice interfaces for debuggers more easily.
Marc
py << EOF
from subprocess import Popen, PIPE
import threading
import os
import vim
class MyThread ( threading.Thread ):
def __init__(self, vimPID, command):
threading.Thread.__init__(self)
self.vimPID=vimPID
self.command=command
def run ( self ):
try:
popenobj = Popen(self.cmd,stdout=PIPE,stderr=PIPE)
self.executeVimCommand("call
vl#lib#quickfix#runtaskinbackground#NotifyProcessId(%s,%s)"%(self.vimPID,popenobj.pid))
stdoutwriter = open(self.stdout,'w')
stdoutwriter.writelines(popenobj.stdout.readlines())
stdoutwriter.writelines(popenobj.stderr.readlines())
stdoutwriter.close()
popenobj.wait()
self.executeVimCommand("call
vl#lib#quickfix#runtaskinbackground#ProcessFinished(%s,%d)"%(self.vimPID,popenobj.returncode))
except Exception, e:
self.executeVimCommand("call
vl#lib#quickfix#runtaskinbackground#ProcessHasentBeenStartedBecause(%s,'%s')"%(self.vimPID,"exception:
"+str(e)))
except:
# I hope command not found is the only error which might occur here
self.executeVimCommand("call
vl#lib#quickfix#runtaskinbackground#ProcessHasentBeenStartedBecause(%s,'%s')"%(self.vimPID,"command
not foun"))
def executeVimCommand(self, cmd):
# can't use vim.command! here because vim hasn't been written for multiple
# threads. I'm getting Xlib: unexpected async reply (sequence 0x859) ;-)
# will use server commands again
popenobj =
Popen([self.vim,"--servername","%s"%(self.servername),"--remote-send","<esc>:%(cmd)s<cr>"%locals()])
popenobj.wait()
EOF
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---