|
Revision 7165, 0.9 kB
(checked in by motemen, 5 years ago)
|
|
lang/vim/sync/sync-file.vim: 付け忘れの let を修正
|
| Line | |
|---|
| 1 | "sync-file.vim |
|---|
| 2 | "sync to file. |
|---|
| 3 | "used by sync.vim |
|---|
| 4 | |
|---|
| 5 | function! SyncFile(method,head,tail,opt_string) |
|---|
| 6 | let v:errmsg="" |
|---|
| 7 | let l=matchlist(a:opt_string,'\s*path=\([^ ]\+\)\s*') |
|---|
| 8 | if len(l)==0 |
|---|
| 9 | echoerr 'need path param' |
|---|
| 10 | return |
|---|
| 11 | endif |
|---|
| 12 | let path=l[1] |
|---|
| 13 | if v:errmsg!="" |
|---|
| 14 | echoerr '�G���[��������̂Œ��~���܂���' |
|---|
| 15 | return |
|---|
| 16 | endif |
|---|
| 17 | if a:method=="pull" |
|---|
| 18 | execute 'new '.path |
|---|
| 19 | let content=getline(1,line('$')) |
|---|
| 20 | bdelete |
|---|
| 21 | redraw |
|---|
| 22 | call s:delete_range(a:head,a:tail) |
|---|
| 23 | call append(a:head-1,content) |
|---|
| 24 | elseif a:method=="push" |
|---|
| 25 | let content=getline(a:head,a:tail) |
|---|
| 26 | execute 'new '.path |
|---|
| 27 | call s:delete_range(1,line('$')) |
|---|
| 28 | call append(0,content) |
|---|
| 29 | execute line('$').'delete' |
|---|
| 30 | write |
|---|
| 31 | bdelete |
|---|
| 32 | redraw |
|---|
| 33 | else |
|---|
| 34 | echoerr 'wrong method' |
|---|
| 35 | return |
|---|
| 36 | endif |
|---|
| 37 | return {'new_opts': 'path='.path} |
|---|
| 38 | endfunction |
|---|
| 39 | |
|---|
| 40 | function! s:delete_range(head,tail) |
|---|
| 41 | if a:head > a:tail |
|---|
| 42 | return |
|---|
| 43 | endif |
|---|
| 44 | execute a:head.','.a:tail.'delete' |
|---|
| 45 | endfunction |
|---|