1 " Vim plugin with helper function(s) for --remote-wait
2 " Maintainer: Flemming Madsen <fma@cci.dk>
3 " Last Change: 2008 May 29
5 " Has this already been loaded?
6 if exists("loaded_rrhelper")
9 let loaded_rrhelper = 1
11 " Setup answers for a --remote-wait client who will assume
12 " a SetupRemoteReplies() function in the command server
14 if has("clientserver")
15 function SetupRemoteReplies()
19 let id = expand("<client>")
24 " Handle same file from more clients and file being more than once
25 " on the command line by encoding this stuff in the group name
26 let uniqueGroup = "RemoteReply_".id."_".cnt
28 " Path separators are always forward slashes for the autocommand pattern.
29 " Escape special characters with a backslash.
30 let f = substitute(argv(cnt), '\\', '/', "g")
31 if exists('*fnameescape')
32 let f = fnameescape(f)
34 let f = escape(f, " \t\n*?[{`$\\%#'\"|!<")
36 execute "augroup ".uniqueGroup
37 execute "autocmd ".uniqueGroup." BufUnload ". f ." call DoRemoteReply('".id."', '".cnt."', '".uniqueGroup."', '". f ."')"
43 function DoRemoteReply(id, cnt, group, file)
44 call server2client(a:id, a:cnt)
45 execute 'autocmd! '.a:group.' BufUnload '.a:file
46 execute 'augroup! '.a:group
52 " vim: set sw=2 sts=2 :