Mercurial > vim
annotate runtime/plugin/rrhelper.vim @ 17439:8be5444ee2cb
Added tag v8.1.1717 for changeset 967e2ee9b656206e39b33e6d10aab417f930b1b0
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 20 Jul 2019 15:15:07 +0200 |
parents | f177a6431514 |
children |
rev | line source |
---|---|
7 | 1 " Vim plugin with helper function(s) for --remote-wait |
2 " Maintainer: Flemming Madsen <fma@cci.dk> | |
1623 | 3 " Last Change: 2008 May 29 |
7 | 4 |
5 " Has this already been loaded? | |
2325
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
6 if exists("loaded_rrhelper") || !has("clientserver") |
7 | 7 finish |
8 endif | |
9 let loaded_rrhelper = 1 | |
10 | |
11 " Setup answers for a --remote-wait client who will assume | |
12 " a SetupRemoteReplies() function in the command server | |
13 | |
2325
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
14 function SetupRemoteReplies() |
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
15 let cnt = 0 |
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
16 let max = argc() |
7 | 17 |
2325
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
18 let id = expand("<client>") |
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
19 if id == 0 |
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
20 return |
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
21 endif |
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
22 while cnt < max |
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
23 " Handle same file from more clients and file being more than once |
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
24 " on the command line by encoding this stuff in the group name |
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
25 let uniqueGroup = "RemoteReply_".id."_".cnt |
7 | 26 |
2325
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
27 " Path separators are always forward slashes for the autocommand pattern. |
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
28 " Escape special characters with a backslash. |
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
29 let f = substitute(argv(cnt), '\\', '/', "g") |
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
30 if exists('*fnameescape') |
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
31 let f = fnameescape(f) |
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
32 else |
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
33 let f = escape(f, " \t\n*?[{`$\\%#'\"|!<") |
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
34 endif |
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
35 execute "augroup ".uniqueGroup |
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
36 execute "autocmd ".uniqueGroup." BufUnload ". f ." call DoRemoteReply('".id."', '".cnt."', '".uniqueGroup."', '". f ."')" |
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
37 let cnt = cnt + 1 |
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
38 endwhile |
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
39 augroup END |
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
40 endfunc |
7 | 41 |
2325
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
42 function DoRemoteReply(id, cnt, group, file) |
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
43 call server2client(a:id, a:cnt) |
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
44 execute 'autocmd! '.a:group.' BufUnload '.a:file |
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
45 execute 'augroup! '.a:group |
f177a6431514
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Bram Moolenaar <bram@vim.org>
parents:
1623
diff
changeset
|
46 endfunc |
7 | 47 |
48 " vim: set sw=2 sts=2 : |