Argument switcharoo

This commit is contained in:
Tim Pope 2014-01-07 23:53:20 -05:00
parent 01e16d236b
commit 760f50f46e
2 changed files with 5 additions and 5 deletions

View File

@ -170,10 +170,10 @@ call writefile([getpid()], s:keepalive)
function! s:nrepl_dispatch(command, ...) dict abort function! s:nrepl_dispatch(command, ...) dict abort
let in = 'python' let in = 'python'
\ . ' ' . s:shellesc(s:python_dir.'/nrepl_fireplace.py') \ . ' ' . s:shellesc(s:python_dir.'/nrepl_fireplace.py')
\ . ' ' . s:shellesc(a:command)
\ . ' ' . s:shellesc(self.host) \ . ' ' . s:shellesc(self.host)
\ . ' ' . s:shellesc(self.port) \ . ' ' . s:shellesc(self.port)
\ . ' ' . s:shellesc(s:keepalive) \ . ' ' . s:shellesc(s:keepalive)
\ . ' ' . s:shellesc(a:command)
\ . ' ' . join(map(copy(a:000), 's:shellesc(v:val)'), ' ') \ . ' ' . join(map(copy(a:000), 's:shellesc(v:val)'), ' ')
let out = system(in) let out = system(in)
if !v:shell_error if !v:shell_error
@ -238,7 +238,7 @@ def fireplace_check():
def fireplace_repl_dispatch(command, *args): def fireplace_repl_dispatch(command, *args):
try: try:
fireplace_let('out', nrepl_fireplace.dispatch(command, vim.eval('self.host'), vim.eval('self.port'), fireplace_check, None, *args)) fireplace_let('out', nrepl_fireplace.dispatch(vim.eval('self.host'), vim.eval('self.port'), fireplace_check, None, command, *args))
except Exception, e: except Exception, e:
fireplace_let('err', str(e)) fireplace_let('err', str(e))
EOF EOF

View File

@ -97,16 +97,16 @@ class Connection:
if 'status' in responses[-1] and 'done' in responses[-1]['status']: if 'status' in responses[-1] and 'done' in responses[-1]['status']:
return responses return responses
def dispatch(command, host, port, poll, keepalive, *args): def dispatch(host, port, poll, keepalive, command, *args):
conn = Connection(host, port, poll, keepalive) conn = Connection(host, port, poll, keepalive)
try: try:
return getattr(conn, command)(*args) return getattr(conn, command)(*args)
finally: finally:
conn.close() conn.close()
def main(command, host, port, keepalive, *args): def main(host, port, keepalive, command, *args):
try: try:
sys.stdout.write(vim_encode(dispatch(command, host, port, noop, keepalive, *args))) sys.stdout.write(vim_encode(dispatch(host, port, noop, keepalive, command, *args)))
except Exception, e: except Exception, e:
print(e) print(e)
exit(1) exit(1)