annotate runtime/autoload/vimball.vim @ 1951:f234c87ac7e9 v7.2.248

updated for version 7.2-248
author vimboss
date Fri, 11 Sep 2009 10:49:58 +0000
parents f4f8014d516e
children 7bc41231fbc7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
1 " vimball.vim : construct a file containing both paths and files
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
2 " Author: Charles E. Campbell, Jr.
1698
f4f8014d516e updated for version 7.2c-000
vimboss
parents: 1618
diff changeset
3 " Date: Jul 30, 2008
f4f8014d516e updated for version 7.2c-000
vimboss
parents: 1618
diff changeset
4 " Version: 29
792
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
5 " GetLatestVimScripts: 1502 1 :AutoInstall: vimball.vim
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
6 " Copyright: (c) 2004-2008 by Charles E. Campbell, Jr.
792
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
7 " The VIM LICENSE applies to Vimball.vim, and Vimball.txt
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
8 " (see |copyright|) except use "Vimball" instead of "Vim".
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
9 " No warranty, express or implied.
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
10 " *** *** Use At-Your-Own-Risk! *** ***
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
11
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
12 " ---------------------------------------------------------------------
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
13 " Load Once: {{{1
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
14 if &cp || exists("g:loaded_vimball") || v:version < 700
792
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
15 finish
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
16 endif
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
17 let s:keepcpo = &cpo
1698
f4f8014d516e updated for version 7.2c-000
vimboss
parents: 1618
diff changeset
18 let g:loaded_vimball = "v29"
792
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
19 set cpo&vim
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
20 "DechoTabOn
792
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
21
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
22 " =====================================================================
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
23 " Constants: {{{1
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
24 if !exists("s:USAGE")
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
25 let s:USAGE = 0
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
26 let s:WARNING = 1
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
27 let s:ERROR = 2
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
28
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
29 " determine if cygwin is in use or not
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
30 if !exists("g:netrw_cygwin")
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
31 if has("win32") || has("win95") || has("win64") || has("win16")
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
32 if &shell =~ '\%(\<bash\>\|\<zsh\>\)\%(\.exe\)\=$'
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
33 let g:netrw_cygwin= 1
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
34 else
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
35 let g:netrw_cygwin= 0
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
36 endif
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
37 else
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
38 let g:netrw_cygwin= 0
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
39 endif
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
40 endif
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
41
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
42 " set up g:vimball_mkdir if the mkdir() call isn't defined
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
43 if !exists("*mkdir")
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
44 if exists("g:netrw_local_mkdir")
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
45 let g:vimball_mkdir= g:netrw_local_mkdir
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
46 elseif executable("mkdir")
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
47 let g:vimball_mkdir= "mkdir"
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
48 elseif executable("makedir")
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
49 let g:vimball_mkdir= "makedir"
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
50 endif
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
51 if !exists(g:vimball_mkdir)
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
52 call vimball#ShowMesg(s:WARNING,"(vimball) g:vimball_mkdir undefined")
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
53 endif
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
54 endif
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
55
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
56 " set up shell quoting character
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
57 if exists("g:vimball_shq") && !exists("g:netrw_shq")
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
58 let g:netrw_shq= g:vimball_shq
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
59 endif
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
60 if !exists("g:netrw_shq")
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
61 if exists("&shq") && &shq != ""
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
62 let g:netrw_shq= &shq
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
63 elseif has("win32") || has("win95") || has("win64") || has("win16")
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
64 if g:netrw_cygwin
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
65 let g:netrw_shq= "'"
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
66 else
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
67 let g:netrw_shq= '"'
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
68 endif
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
69 else
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
70 let g:netrw_shq= "'"
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
71 endif
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
72 " call Decho("g:netrw_shq<".g:netrw_shq.">")
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
73 endif
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
74
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
75 " set up escape string (used to protect paths)
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
76 if !exists("g:vimball_path_escape")
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
77 let g:vimball_path_escape= ' ;#%'
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
78 endif
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
79 endif
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
80
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
81 " =====================================================================
792
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
82 " Functions: {{{1
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
83
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
84 " ---------------------------------------------------------------------
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
85 " vimball#MkVimball: creates a vimball given a list of paths to files {{{2
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
86 " Input:
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
87 " line1,line2: a range of lines containing paths to files to be included in the vimball
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
88 " writelevel : if true, force a write to filename.vba, even if it exists
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
89 " (usually accomplished with :MkVimball! ...
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
90 " filename : base name of file to be created (ie. filename.vba)
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
91 " Output: a filename.vba using vimball format:
792
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
92 " path
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
93 " filesize
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
94 " [file]
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
95 " path
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
96 " filesize
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
97 " [file]
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
98 fun! vimball#MkVimball(line1,line2,writelevel,...) range
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
99 " call Dfunc("MkVimball(line1=".a:line1." line2=".a:line2." writelevel=".a:writelevel." vimballname<".a:1.">) a:0=".a:0)
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
100 if a:1 =~ '\.vim$' || a:1 =~ '\.txt$'
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
101 let vbname= substitute(a:1,'\.\a\{3}$','.vba','')
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
102 else
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
103 let vbname= a:1
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
104 endif
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
105 if vbname !~ '\.vba$'
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
106 let vbname= vbname.'.vba'
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
107 endif
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
108 " call Decho("vbname<".vbname.">")
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
109 if a:1 =~ '[\/]'
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
110 call vimball#ShowMesg(s:ERROR,"(MkVimball) vimball name<".a:1."> should not include slashes")
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
111 " call Dret("MkVimball : vimball name<".a:1."> should not include slashes")
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
112 return
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
113 endif
792
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
114 if !a:writelevel && filereadable(vbname)
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
115 call vimball#ShowMesg(s:ERROR,"(MkVimball) file<".vbname."> exists; use ! to insist")
792
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
116 " call Dret("MkVimball : file<".vbname."> already exists; use ! to insist")
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
117 return
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
118 endif
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
119
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
120 " user option bypass
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
121 call vimball#SaveSettings()
792
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
122
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
123 if a:0 >= 2
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
124 " allow user to specify where to get the files
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
125 let home= expand(a:2)
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
126 else
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
127 " use first existing directory from rtp
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
128 let home= s:VimballHome()
844
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 843
diff changeset
129 endif
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 843
diff changeset
130
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 843
diff changeset
131 " save current directory
792
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
132 let curdir = getcwd()
844
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 843
diff changeset
133 call s:ChgDir(home)
792
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
134
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
135 " record current tab, initialize while loop index
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
136 let curtabnr = tabpagenr()
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
137 let linenr = a:line1
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
138 " call Decho("curtabnr=".curtabnr)
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
139
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
140 while linenr <= a:line2
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
141 let svfile = getline(linenr)
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
142 " call Decho("svfile<".svfile.">")
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
143
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
144 if !filereadable(svfile)
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
145 call vimball#ShowMesg(s:ERROR,"unable to read file<".svfile.">")
844
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 843
diff changeset
146 call s:ChgDir(curdir)
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
147 call vimball#RestoreSettings()
792
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
148 " call Dret("MkVimball")
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
149 return
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
150 endif
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
151
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
152 " create/switch to mkvimball tab
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
153 if !exists("vbtabnr")
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
154 tabnew
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
155 silent! file Vimball
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
156 let vbtabnr= tabpagenr()
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
157 else
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
158 exe "tabn ".vbtabnr
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
159 endif
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
160
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
161 let lastline= line("$") + 1
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
162 if lastline == 2 && getline("$") == ""
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
163 call setline(1,'" Vimball Archiver by Charles E. Campbell, Jr., Ph.D.')
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
164 call setline(2,'UseVimball')
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
165 call setline(3,'finish')
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
166 let lastline= line("$") + 1
792
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
167 endif
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
168 call setline(lastline ,substitute(svfile,'$',' [[[1',''))
792
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
169 call setline(lastline+1,0)
844
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 843
diff changeset
170
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 843
diff changeset
171 " write the file from the tab
1698
f4f8014d516e updated for version 7.2c-000
vimboss
parents: 1618
diff changeset
172 " call Decho("exe $r ".fnameescape(svfile))
f4f8014d516e updated for version 7.2c-000
vimboss
parents: 1618
diff changeset
173 exe "$r ".fnameescape(svfile)
844
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 843
diff changeset
174
792
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
175 call setline(lastline+1,line("$") - lastline - 1)
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
176 " call Decho("lastline=".lastline." line$=".line("$"))
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
177
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
178 " restore to normal tab
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
179 exe "tabn ".curtabnr
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
180 let linenr= linenr + 1
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
181 endwhile
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
182
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
183 " write the vimball
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
184 exe "tabn ".vbtabnr
844
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 843
diff changeset
185 call s:ChgDir(curdir)
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
186 setlocal ff=unix
796
cc3902a09300 updated for version 7.0232
vimboss
parents: 792
diff changeset
187 if a:writelevel
1698
f4f8014d516e updated for version 7.2c-000
vimboss
parents: 1618
diff changeset
188 " call Decho("exe w! ".fnameescape(vbname))
f4f8014d516e updated for version 7.2c-000
vimboss
parents: 1618
diff changeset
189 exe "w! ".fnameescape(vbname)
796
cc3902a09300 updated for version 7.0232
vimboss
parents: 792
diff changeset
190 else
1698
f4f8014d516e updated for version 7.2c-000
vimboss
parents: 1618
diff changeset
191 " call Decho("exe w ".fnameescape(vbname))
f4f8014d516e updated for version 7.2c-000
vimboss
parents: 1618
diff changeset
192 exe "w ".fnameescape(vbname)
792
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
193 endif
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
194 " call Decho("Vimball<".vbname."> created")
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
195 echo "Vimball<".vbname."> created"
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
196
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
197 " remove the evidence
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
198 setlocal nomod bh=wipe
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
199 exe "tabn ".curtabnr
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
200 exe "tabc ".vbtabnr
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
201
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
202 " restore options
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
203 call vimball#RestoreSettings()
792
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
204
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
205 " call Dret("MkVimball")
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
206 endfun
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
207
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
208 " ---------------------------------------------------------------------
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
209 " vimball#Vimball: extract and distribute contents from a vimball {{{2
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
210 " (invoked the the UseVimball command embedded in
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
211 " vimballs' prologue)
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
212 fun! vimball#Vimball(really,...)
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
213 " call Dfunc("vimball#Vimball(really=".a:really.") a:0=".a:0)
792
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
214
1698
f4f8014d516e updated for version 7.2c-000
vimboss
parents: 1618
diff changeset
215 if v:version < 701 || (v:version == 701 && !exists('*fnameescape'))
f4f8014d516e updated for version 7.2c-000
vimboss
parents: 1618
diff changeset
216 echoerr "your vim is missing the fnameescape() function"
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
217 " call Dret("vimball#Vimball : needs 7.1 with patch 299")
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
218 return
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
219 endif
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
220
792
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
221 if getline(1) !~ '^" Vimball Archiver by Charles E. Campbell, Jr., Ph.D.$'
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
222 echoerr "(Vimball) The current file does not appear to be a Vimball!"
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
223 " call Dret("vimball#Vimball")
792
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
224 return
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
225 endif
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
226
845
0fe7765dcb8e updated for version 7.0f03
vimboss
parents: 844
diff changeset
227 " set up standard settings
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
228 call vimball#SaveSettings()
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
229 let curtabnr = tabpagenr()
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
230 let vimballfile = expand("%:tr")
792
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
231
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
232 " set up vimball tab
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
233 " call Decho("setting up vimball tab")
792
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
234 tabnew
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
235 silent! file Vimball
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
236 let vbtabnr= tabpagenr()
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
237 let didhelp= ""
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
238
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
239 " go to vim plugin home
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
240 if a:0 > 0
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
241 let home= expand(a:1)
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
242 else
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
243 let home= s:VimballHome()
844
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 843
diff changeset
244 endif
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 843
diff changeset
245 " call Decho("home<".home.">")
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 843
diff changeset
246
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
247 " save current directory and remove older same-named vimball, if any
792
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
248 let curdir = getcwd()
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
249 " call Decho("home<".home.">")
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
250 " call Decho("curdir<".curdir.">")
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
251
844
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 843
diff changeset
252 call s:ChgDir(home)
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
253 let s:ok_unablefind= 1
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
254 call vimball#RmVimball(vimballfile)
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
255 unlet s:ok_unablefind
844
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 843
diff changeset
256
792
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
257 let linenr = 4
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
258 let filecnt = 0
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
259
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
260 " give title to listing of (extracted) files from Vimball Archive
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
261 if a:really
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
262 echohl Title | echomsg "Vimball Archive" | echohl None
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
263 else
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
264 echohl Title | echomsg "Vimball Archive Listing" | echohl None
845
0fe7765dcb8e updated for version 7.0f03
vimboss
parents: 844
diff changeset
265 echohl Statement | echomsg "files would be placed under: ".home | echohl None
792
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
266 endif
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
267
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
268 " apportion vimball contents to various files
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
269 " call Decho("exe tabn ".curtabnr)
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
270 exe "tabn ".curtabnr
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
271 " call Decho("linenr=".linenr." line$=".line("$"))
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
272 while 1 < linenr && linenr < line("$")
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
273 let fname = substitute(getline(linenr),'\t\[\[\[1$','','')
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
274 let fname = substitute(fname,'\\','/','g')
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
275 let fsize = getline(linenr+1)+0
792
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
276 let filecnt = filecnt + 1
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
277 " call Decho("fname<".fname."> fsize=".fsize." filecnt=".filecnt)
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
278
792
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
279 if a:really
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
280 echomsg "extracted <".fname.">: ".fsize." lines"
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
281 else
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
282 echomsg "would extract <".fname.">: ".fsize." lines"
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
283 endif
842
a209672376fd updated for version 7.0f
vimboss
parents: 819
diff changeset
284 " call Decho("using L#".linenr.": will extract file<".fname.">")
a209672376fd updated for version 7.0f
vimboss
parents: 819
diff changeset
285 " call Decho("using L#".(linenr+1).": fsize=".fsize)
792
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
286
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
287 " Allow AsNeeded/ directory to take place of plugin/ directory
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
288 " when AsNeeded/filename is filereadable or was present in VimballRecord
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
289 if fname =~ '\<plugin/'
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
290 let anfname= substitute(fname,'\<plugin/','AsNeeded/','')
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
291 if filereadable(anfname) || (exists("s:VBRstring") && s:VBRstring =~ anfname)
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
292 " call Decho("using anfname<".anfname."> instead of <".fname.">")
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
293 let fname= anfname
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
294 endif
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
295 endif
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
296
792
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
297 " make directories if they don't exist yet
845
0fe7765dcb8e updated for version 7.0f03
vimboss
parents: 844
diff changeset
298 if a:really
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
299 " call Decho("making directories if they don't exist yet (fname<".fname.">)")
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
300 let fnamebuf= substitute(fname,'\\','/','g')
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
301 let dirpath = substitute(home,'\\','/','g')
845
0fe7765dcb8e updated for version 7.0f03
vimboss
parents: 844
diff changeset
302 while fnamebuf =~ '/'
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
303 let dirname = dirpath."/".substitute(fnamebuf,'/.*$','','')
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
304 let dirpath = dirname
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
305 let fnamebuf = substitute(fnamebuf,'^.\{-}/\(.*\)$','\1','')
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
306 " call Decho("dirname<".dirname.">")
845
0fe7765dcb8e updated for version 7.0f03
vimboss
parents: 844
diff changeset
307 if !isdirectory(dirname)
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
308 " call Decho("making <".dirname.">")
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
309 if exists("g:vimball_mkdir")
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
310 call system(g:vimball_mkdir." ".s:Escape(dirname))
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
311 else
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
312 call mkdir(dirname)
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
313 endif
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
314 call s:RecordInVar(home,"rmdir('".dirname."')")
845
0fe7765dcb8e updated for version 7.0f03
vimboss
parents: 844
diff changeset
315 endif
0fe7765dcb8e updated for version 7.0f03
vimboss
parents: 844
diff changeset
316 endwhile
0fe7765dcb8e updated for version 7.0f03
vimboss
parents: 844
diff changeset
317 endif
844
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 843
diff changeset
318 call s:ChgDir(home)
792
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
319
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
320 " grab specified qty of lines and place into "a" buffer
842
a209672376fd updated for version 7.0f
vimboss
parents: 819
diff changeset
321 " (skip over path/filename and qty-lines)
a209672376fd updated for version 7.0f
vimboss
parents: 819
diff changeset
322 let linenr = linenr + 2
a209672376fd updated for version 7.0f
vimboss
parents: 819
diff changeset
323 let lastline = linenr + fsize - 1
a209672376fd updated for version 7.0f
vimboss
parents: 819
diff changeset
324 " call Decho("exe ".linenr.",".lastline."yank a")
844
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 843
diff changeset
325 exe "silent ".linenr.",".lastline."yank a"
792
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
326
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
327 " copy "a" buffer into tab
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
328 " call Decho('copy "a buffer into tab#'.vbtabnr)
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
329 exe "tabn ".vbtabnr
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
330 setlocal ma
792
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
331 silent! %d
844
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 843
diff changeset
332 silent put a
842
a209672376fd updated for version 7.0f
vimboss
parents: 819
diff changeset
333 1
844
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 843
diff changeset
334 silent d
792
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
335
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
336 " write tab to file
796
cc3902a09300 updated for version 7.0232
vimboss
parents: 792
diff changeset
337 if a:really
1698
f4f8014d516e updated for version 7.2c-000
vimboss
parents: 1618
diff changeset
338 let fnamepath= home."/".fname
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
339 " call Decho("exe w! ".fnameescape(fnamepath))
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
340 exe "silent w! ".fnameescape(fnamepath)
844
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 843
diff changeset
341 echo "wrote ".fnamepath
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
342 call s:RecordInVar(home,"call delete('".fnameescape(fnamepath)."')")
796
cc3902a09300 updated for version 7.0232
vimboss
parents: 792
diff changeset
343 endif
792
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
344
842
a209672376fd updated for version 7.0f
vimboss
parents: 819
diff changeset
345 " return to tab with vimball
792
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
346 " call Decho("exe tabn ".curtabnr)
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
347 exe "tabn ".curtabnr
842
a209672376fd updated for version 7.0f
vimboss
parents: 819
diff changeset
348
a209672376fd updated for version 7.0f
vimboss
parents: 819
diff changeset
349 " set up help if its a doc/*.txt file
a209672376fd updated for version 7.0f
vimboss
parents: 819
diff changeset
350 " call Decho("didhelp<".didhelp."> fname<".fname.">")
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
351 if a:really && didhelp == "" && fname =~ 'doc/[^/]\+\.\(txt\|..x\)$'
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
352 let didhelp= substitute(fname,'^\(.*\<doc\)[/\\][^.]*\.\(txt\|..x\)$','\1','')
842
a209672376fd updated for version 7.0f
vimboss
parents: 819
diff changeset
353 " call Decho("didhelp<".didhelp.">")
a209672376fd updated for version 7.0f
vimboss
parents: 819
diff changeset
354 endif
a209672376fd updated for version 7.0f
vimboss
parents: 819
diff changeset
355
a209672376fd updated for version 7.0f
vimboss
parents: 819
diff changeset
356 " update for next file
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
357 " call Decho("update linenr= [linenr=".linenr."] + [fsize=".fsize."] = ".(linenr+fsize))
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
358 let linenr= linenr + fsize
792
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
359 endwhile
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
360
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
361 " set up help
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
362 " call Decho("about to set up help: didhelp<".didhelp.">")
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
363 if didhelp != ""
1698
f4f8014d516e updated for version 7.2c-000
vimboss
parents: 1618
diff changeset
364 let htpath= home."/".didhelp
844
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 843
diff changeset
365 " call Decho("exe helptags ".htpath)
1698
f4f8014d516e updated for version 7.2c-000
vimboss
parents: 1618
diff changeset
366 exe "helptags ".fnameescape(htpath)
844
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 843
diff changeset
367 echo "did helptags"
792
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
368 endif
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
369
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
370 " make sure a "Press ENTER..." prompt appears to keep the messages showing!
796
cc3902a09300 updated for version 7.0232
vimboss
parents: 792
diff changeset
371 while filecnt <= &ch
792
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
372 echomsg " "
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
373 let filecnt= filecnt + 1
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
374 endwhile
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
375
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
376 " record actions in <.VimballRecord>
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
377 call s:RecordInFile(home)
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
378
792
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
379 " restore events, delete tab and buffer
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
380 exe "tabn ".vbtabnr
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
381 setlocal nomod bh=wipe
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
382 exe "tabn ".curtabnr
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
383 exe "tabc ".vbtabnr
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
384 call vimball#RestoreSettings()
844
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 843
diff changeset
385 call s:ChgDir(curdir)
792
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
386
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
387 " call Dret("vimball#Vimball")
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
388 endfun
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
389
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
390 " ---------------------------------------------------------------------
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
391 " vimball#RmVimball: remove any files, remove any directories made by any {{{2
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
392 " previous vimball extraction based on a file of the current
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
393 " name.
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
394 " Usage: RmVimball (assume current file is a vimball; remove)
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
395 " RmVimball vimballname
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
396 fun! vimball#RmVimball(...)
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
397 " call Dfunc("vimball#RmVimball() a:0=".a:0)
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
398 if exists("g:vimball_norecord")
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
399 " call Dret("vimball#RmVimball : (g:vimball_norecord)")
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
400 return
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
401 endif
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
402
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
403 if a:0 == 0
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
404 let curfile= expand("%:tr")
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
405 " call Decho("case a:0=0: curfile<".curfile."> (used expand(%:tr))")
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
406 else
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
407 if a:1 =~ '[\/]'
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
408 call vimball#ShowMesg(s:USAGE,"RmVimball vimballname [path]")
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
409 " call Dret("vimball#RmVimball : suspect a:1<".a:1.">")
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
410 return
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
411 endif
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
412 let curfile= a:1
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
413 " call Decho("case a:0=".a:0.": curfile<".curfile.">")
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
414 endif
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
415 if curfile =~ '\.vba$'
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
416 let curfile= substitute(curfile,'\.vba','','')
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
417 endif
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
418 if a:0 >= 2
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
419 let home= expand(a:2)
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
420 else
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
421 let home= s:VimballHome()
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
422 endif
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
423 let curdir = getcwd()
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
424 " call Decho("home <".home.">")
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
425 " call Decho("curfile<".curfile.">")
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
426 " call Decho("curdir <".curdir.">")
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
427
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
428 call s:ChgDir(home)
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
429 if filereadable(".VimballRecord")
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
430 " call Decho(".VimballRecord is readable")
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
431 " call Decho("curfile<".curfile.">")
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
432 keepalt keepjumps 1split
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
433 silent! keepalt keepjumps e .VimballRecord
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
434 let keepsrch= @/
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
435 " call Decho("search for ^".curfile.".vba:")
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
436 " call Decho("search for ^".curfile."[-0-9.]*.vba:")
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
437 if search('^'.curfile.": ".'cw')
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
438 let foundit= 1
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
439 elseif search('^'.curfile.".vba: ",'cw')
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
440 let foundit= 1
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
441 elseif search('^'.curfile.'[-0-9.]*.vba: ','cw')
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
442 let foundit= 1
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
443 else
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
444 let foundit = 0
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
445 endif
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
446 if foundit
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
447 let exestring = substitute(getline("."),'^'.curfile.'\S\{-}\.vba: ','','')
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
448 let s:VBRstring= substitute(exestring,'call delete(','','g')
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
449 let s:VBRstring= substitute(s:VBRstring,"[')]",'','g')
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
450 " call Decho("exe ".exestring)
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
451 silent! keepalt keepjumps exe exestring
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
452 silent! keepalt keepjumps d
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
453 let exestring= strlen(substitute(exestring,'call delete(.\{-})|\=',"D","g"))
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
454 " call Decho("exestring<".exestring.">")
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
455 echomsg "removed ".exestring." files"
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
456 else
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
457 let s:VBRstring= ''
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
458 let curfile = substitute(curfile,'\.vba','','')
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
459 " call Decho("unable to find <".curfile."> in .VimballRecord")
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
460 if !exists("s:ok_unablefind")
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
461 call vimball#ShowMesg(s:WARNING,"(RmVimball) unable to find <".curfile."> in .VimballRecord")
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
462 endif
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
463 endif
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
464 silent! keepalt keepjumps g/^\s*$/d
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
465 silent! keepalt keepjumps wq!
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
466 let @/= keepsrch
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
467 endif
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
468 call s:ChgDir(curdir)
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
469
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
470 " call Dret("vimball#RmVimball")
792
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
471 endfun
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
472
843
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
473 " ---------------------------------------------------------------------
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
474 " vimball#Decompress: attempts to automatically decompress vimballs {{{2
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
475 fun! vimball#Decompress(fname)
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
476 " call Dfunc("Decompress(fname<".a:fname.">)")
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
477
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
478 " decompression:
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
479 if expand("%") =~ '.*\.gz' && executable("gunzip")
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
480 " handle *.gz with gunzip
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
481 silent exe "!gunzip ".s:Escape(a:fname)
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
482 if v:shell_error != 0
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
483 call vimball#ShowMesg(s:WARNING,"(vimball#Decompress) gunzip may have failed with <".a:fname.">")
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
484 endif
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
485 let fname= substitute(a:fname,'\.gz$','','')
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
486 exe "e ".escape(fname,' \')
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
487 call vimball#ShowMesg(s:USAGE,"Source this file to extract it! (:so %)")
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
488
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
489 elseif expand("%") =~ '.*\.gz' && executable("gzip")
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
490 " handle *.gz with gzip -d
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
491 silent exe "!gzip -d ".s:Escape(a:fname)
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
492 if v:shell_error != 0
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
493 call vimball#ShowMesg(s:WARNING,'(vimball#Decompress) "gzip -d" may have failed with <'.a:fname.">")
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
494 endif
843
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
495 let fname= substitute(a:fname,'\.gz$','','')
844
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 843
diff changeset
496 exe "e ".escape(fname,' \')
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
497 call vimball#ShowMesg(s:USAGE,"Source this file to extract it! (:so %)")
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
498
843
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
499 elseif expand("%") =~ '.*\.bz2' && executable("bunzip2")
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
500 " handle *.bz2 with bunzip2
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
501 silent exe "!bunzip2 ".s:Escape(a:fname)
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
502 if v:shell_error != 0
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
503 call vimball#ShowMesg(s:WARNING,"(vimball#Decompress) bunzip2 may have failed with <".a:fname.">")
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
504 endif
843
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
505 let fname= substitute(a:fname,'\.bz2$','','')
844
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 843
diff changeset
506 exe "e ".escape(fname,' \')
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
507 call vimball#ShowMesg(s:USAGE,"Source this file to extract it! (:so %)")
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
508
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
509 elseif expand("%") =~ '.*\.bz2' && executable("bzip2")
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
510 " handle *.bz2 with bzip2 -d
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
511 silent exe "!bzip2 -d ".s:Escape(a:fname)
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
512 if v:shell_error != 0
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
513 call vimball#ShowMesg(s:WARNING,'(vimball#Decompress) "bzip2 -d" may have failed with <'.a:fname.">")
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
514 endif
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
515 let fname= substitute(a:fname,'\.bz2$','','')
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
516 exe "e ".escape(fname,' \')
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
517 call vimball#ShowMesg(s:USAGE,"Source this file to extract it! (:so %)")
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
518
843
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
519 elseif expand("%") =~ '.*\.zip' && executable("unzip")
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
520 " handle *.zip with unzip
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
521 silent exe "!unzip ".s:Escape(a:fname)
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
522 if v:shell_error != 0
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
523 call vimball#ShowMesg(s:WARNING,"(vimball#Decompress) unzip may have failed with <".a:fname.">")
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
524 endif
843
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
525 let fname= substitute(a:fname,'\.zip$','','')
844
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 843
diff changeset
526 exe "e ".escape(fname,' \')
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
527 call vimball#ShowMesg(s:USAGE,"Source this file to extract it! (:so %)")
843
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
528 endif
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
529
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
530 set noma bt=nofile fmr=[[[,]]] fdm=marker
843
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
531
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
532 " call Dret("Decompress")
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
533 endfun
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
534
844
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 843
diff changeset
535 " ---------------------------------------------------------------------
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
536 " vimball#ShowMesg: {{{2
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
537 fun! vimball#ShowMesg(level,msg)
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
538 " call Dfunc("vimball#ShowMesg(level=".a:level." msg<".a:msg.">)")
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
539 let rulerkeep = &ruler
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
540 let showcmdkeep = &showcmd
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
541 set noruler noshowcmd
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
542 redraw!
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
543
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
544 if &fo =~ '[ta]'
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
545 echomsg "***vimball*** " a:msg
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
546 else
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
547 if a:level == s:WARNING || a:level == s:USAGE
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
548 echohl WarningMsg
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
549 elseif a:level == s:ERROR
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
550 echohl Error
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
551 endif
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
552 echomsg "***vimball*** " a:msg
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
553 echohl None
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
554 endif
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
555
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
556 if a:level != s:USAGE
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
557 call inputsave()|let ok= input("Press <cr> to continue")|call inputrestore()
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
558 endif
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
559
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
560 let &ruler = rulerkeep
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
561 let &showcmd = showcmdkeep
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
562
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
563 " call Dret("vimball#ShowMesg")
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
564 endfun
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
565 " =====================================================================
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
566 " s:ChgDir: change directory (in spite of Windoze) {{{2
844
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 843
diff changeset
567 fun! s:ChgDir(newdir)
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 843
diff changeset
568 " call Dfunc("ChgDir(newdir<".a:newdir.">)")
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 843
diff changeset
569 if (has("win32") || has("win95") || has("win64") || has("win16"))
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
570 exe 'silent cd '.fnameescape(substitute(a:newdir,'/','\\','g'))
844
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 843
diff changeset
571 else
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
572 exe 'silent cd '.fnameescape(a:newdir)
844
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 843
diff changeset
573 endif
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
574 " call Dret("ChgDir : curdir<".getcwd().">")
844
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 843
diff changeset
575 endfun
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 843
diff changeset
576
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 843
diff changeset
577 " ---------------------------------------------------------------------
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
578 " s:RecordInVar: record a un-vimball command in the .VimballRecord file {{{2
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
579 fun! s:RecordInVar(home,cmd)
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
580 " call Dfunc("RecordInVar(home<".a:home."> cmd<".a:cmd.">)")
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
581 if a:cmd =~ '^rmdir'
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
582 " if !exists("s:recorddir")
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
583 " let s:recorddir= substitute(a:cmd,'^rmdir',"call s:Rmdir",'')
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
584 " else
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
585 " let s:recorddir= s:recorddir."|".substitute(a:cmd,'^rmdir',"call s:Rmdir",'')
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
586 " endif
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
587 elseif !exists("s:recordfile")
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
588 let s:recordfile= a:cmd
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
589 else
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
590 let s:recordfile= s:recordfile."|".a:cmd
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
591 endif
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
592 " call Dret("RecordInVar : s:recordfile<".(exists("s:recordfile")? s:recordfile : "")."> s:recorddir<".(exists("s:recorddir")? s:recorddir : "").">")
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
593 endfun
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
594
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
595 " ---------------------------------------------------------------------
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
596 " s:RecordInFile: {{{2
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
597 fun! s:RecordInFile(home)
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
598 " call Dfunc("s:RecordInFile()")
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
599 if exists("g:vimball_norecord")
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
600 " call Dret("s:RecordInFile : g:vimball_norecord")
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
601 return
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
602 endif
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
603
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
604 if exists("s:recordfile") || exists("s:recorddir")
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
605 let curdir= getcwd()
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
606 call s:ChgDir(a:home)
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
607 keepalt keepjumps 1split
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
608
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
609 let cmd= expand("%:tr").": "
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
610 " call Decho("cmd<".cmd.">")
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
611
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
612 silent! keepalt keepjumps e .VimballRecord
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
613 setlocal ma
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
614 $
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
615 if exists("s:recordfile") && exists("s:recorddir")
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
616 let cmd= cmd.s:recordfile."|".s:recorddir
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
617 elseif exists("s:recorddir")
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
618 let cmd= cmd.s:recorddir
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
619 elseif exists("s:recordfile")
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
620 let cmd= cmd.s:recordfile
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
621 else
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
622 " call Dret("s:RecordInFile : neither recordfile nor recorddir exist")
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
623 return
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
624 endif
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
625 " call Decho("cmd<".cmd.">")
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
626
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
627 " put command into buffer, write .VimballRecord `file
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
628 keepalt keepjumps put=cmd
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
629 silent! keepalt keepjumps g/^\s*$/d
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
630 silent! keepalt keepjumps wq!
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
631 call s:ChgDir(curdir)
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
632
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
633 if exists("s:recorddir")
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
634 " call Decho("unlet s:recorddir<".s:recorddir.">")
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
635 unlet s:recorddir
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
636 endif
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
637 if exists("s:recordfile")
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
638 " call Decho("unlet s:recordfile<".s:recordfile.">")
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
639 unlet s:recordfile
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
640 endif
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
641 else
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
642 " call Decho("s:record[file|dir] doesn't exist")
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
643 endif
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
644
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
645 " call Dret("s:RecordInFile")
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
646 endfun
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
647
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
648 " ---------------------------------------------------------------------
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
649 " s:VimballHome: determine/get home directory path (usually from rtp) {{{2
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
650 fun! s:VimballHome()
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
651 " call Dfunc("VimballHome()")
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
652 if exists("g:vimball_home")
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
653 let home= g:vimball_home
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
654 else
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
655 " go to vim plugin home
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
656 for home in split(&rtp,',') + ['']
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
657 if isdirectory(home) && filewritable(home) | break | endif
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
658 let basehome= substitute(home,'[/\\]\.vim$','','')
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
659 if isdirectory(basehome) && filewritable(basehome)
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
660 let home= basehome."/.vim"
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
661 break
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
662 endif
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
663 endfor
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
664 if home == ""
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
665 " just pick the first directory
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
666 let home= substitute(&rtp,',.*$','','')
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
667 endif
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
668 if (has("win32") || has("win95") || has("win64") || has("win16"))
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
669 let home= substitute(home,'/','\\','g')
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
670 endif
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
671 endif
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
672 " insure that the home directory exists
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
673 " call Decho("picked home<".home.">")
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
674 if !isdirectory(home)
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
675 if exists("g:vimball_mkdir")
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
676 " call Decho("home<".home."> isn't a directory -- making it now with g:vimball_mkdir<".g:vimball_mkdir.">")
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
677 " call Decho("system(".g:vimball_mkdir." ".s:Escape(home).")")
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
678 call system(g:vimball_mkdir." ".s:Escape(home))
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
679 else
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
680 " call Decho("home<".home."> isn't a directory -- making it now with mkdir()")
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
681 call mkdir(home)
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
682 endif
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
683 endif
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
684 " call Dret("VimballHome <".home.">")
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
685 return home
844
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 843
diff changeset
686 endfun
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 843
diff changeset
687
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 843
diff changeset
688 " ---------------------------------------------------------------------
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
689 " vimball#SaveSettings: {{{2
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
690 fun! vimball#SaveSettings()
845
0fe7765dcb8e updated for version 7.0f03
vimboss
parents: 844
diff changeset
691 " call Dfunc("SaveSettings()")
0fe7765dcb8e updated for version 7.0f03
vimboss
parents: 844
diff changeset
692 let s:makeep = getpos("'a")
0fe7765dcb8e updated for version 7.0f03
vimboss
parents: 844
diff changeset
693 let s:regakeep= @a
857
b933657f7c9d updated for version 7.0g01
vimboss
parents: 845
diff changeset
694 if exists("&acd")
b933657f7c9d updated for version 7.0g01
vimboss
parents: 845
diff changeset
695 let s:acdkeep = &acd
b933657f7c9d updated for version 7.0g01
vimboss
parents: 845
diff changeset
696 endif
845
0fe7765dcb8e updated for version 7.0f03
vimboss
parents: 844
diff changeset
697 let s:eikeep = &ei
1698
f4f8014d516e updated for version 7.2c-000
vimboss
parents: 1618
diff changeset
698 let s:fenkeep = &l:fen
845
0fe7765dcb8e updated for version 7.0f03
vimboss
parents: 844
diff changeset
699 let s:hidkeep = &hidden
0fe7765dcb8e updated for version 7.0f03
vimboss
parents: 844
diff changeset
700 let s:ickeep = &ic
1186
2de44d8f2cf1 updated for version 7.1b
vimboss
parents: 1118
diff changeset
701 let s:lzkeep = &lz
2de44d8f2cf1 updated for version 7.1b
vimboss
parents: 1118
diff changeset
702 let s:pmkeep = &pm
845
0fe7765dcb8e updated for version 7.0f03
vimboss
parents: 844
diff changeset
703 let s:repkeep = &report
0fe7765dcb8e updated for version 7.0f03
vimboss
parents: 844
diff changeset
704 let s:vekeep = &ve
1698
f4f8014d516e updated for version 7.2c-000
vimboss
parents: 1618
diff changeset
705 let s:ffkeep = &l:ff
857
b933657f7c9d updated for version 7.0g01
vimboss
parents: 845
diff changeset
706 if exists("&acd")
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
707 setlocal ei=all ve=all noacd nofen noic report=999 nohid bt= ma lz pm= ff=unix
857
b933657f7c9d updated for version 7.0g01
vimboss
parents: 845
diff changeset
708 else
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
709 setlocal ei=all ve=all nofen noic report=999 nohid bt= ma lz pm= ff=unix
857
b933657f7c9d updated for version 7.0g01
vimboss
parents: 845
diff changeset
710 endif
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
711 " vimballs should be in unix format
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
712 setlocal ff=unix
845
0fe7765dcb8e updated for version 7.0f03
vimboss
parents: 844
diff changeset
713 " call Dret("SaveSettings")
0fe7765dcb8e updated for version 7.0f03
vimboss
parents: 844
diff changeset
714 endfun
0fe7765dcb8e updated for version 7.0f03
vimboss
parents: 844
diff changeset
715
0fe7765dcb8e updated for version 7.0f03
vimboss
parents: 844
diff changeset
716 " ---------------------------------------------------------------------
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
717 " vimball#RestoreSettings: {{{2
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
718 fun! vimball#RestoreSettings()
845
0fe7765dcb8e updated for version 7.0f03
vimboss
parents: 844
diff changeset
719 " call Dfunc("RestoreSettings()")
0fe7765dcb8e updated for version 7.0f03
vimboss
parents: 844
diff changeset
720 let @a = s:regakeep
857
b933657f7c9d updated for version 7.0g01
vimboss
parents: 845
diff changeset
721 if exists("&acd")
b933657f7c9d updated for version 7.0g01
vimboss
parents: 845
diff changeset
722 let &acd = s:acdkeep
b933657f7c9d updated for version 7.0g01
vimboss
parents: 845
diff changeset
723 endif
1698
f4f8014d516e updated for version 7.2c-000
vimboss
parents: 1618
diff changeset
724 let &l:fen = s:fenkeep
845
0fe7765dcb8e updated for version 7.0f03
vimboss
parents: 844
diff changeset
725 let &hidden = s:hidkeep
0fe7765dcb8e updated for version 7.0f03
vimboss
parents: 844
diff changeset
726 let &ic = s:ickeep
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
727 let &lz = s:lzkeep
1186
2de44d8f2cf1 updated for version 7.1b
vimboss
parents: 1118
diff changeset
728 let &pm = s:pmkeep
845
0fe7765dcb8e updated for version 7.0f03
vimboss
parents: 844
diff changeset
729 let &report = s:repkeep
0fe7765dcb8e updated for version 7.0f03
vimboss
parents: 844
diff changeset
730 let &ve = s:vekeep
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents: 857
diff changeset
731 let &ei = s:eikeep
1698
f4f8014d516e updated for version 7.2c-000
vimboss
parents: 1618
diff changeset
732 let &l:ff = s:ffkeep
845
0fe7765dcb8e updated for version 7.0f03
vimboss
parents: 844
diff changeset
733 if s:makeep[0] != 0
0fe7765dcb8e updated for version 7.0f03
vimboss
parents: 844
diff changeset
734 " restore mark a
0fe7765dcb8e updated for version 7.0f03
vimboss
parents: 844
diff changeset
735 " call Decho("restore mark-a: makeep=".string(makeep))
0fe7765dcb8e updated for version 7.0f03
vimboss
parents: 844
diff changeset
736 call setpos("'a",s:makeep)
0fe7765dcb8e updated for version 7.0f03
vimboss
parents: 844
diff changeset
737 endif
857
b933657f7c9d updated for version 7.0g01
vimboss
parents: 845
diff changeset
738 if exists("&acd")
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
739 unlet s:acdkeep
857
b933657f7c9d updated for version 7.0g01
vimboss
parents: 845
diff changeset
740 endif
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
741 unlet s:regakeep s:eikeep s:fenkeep s:hidkeep s:ickeep s:repkeep s:vekeep s:makeep s:lzkeep s:pmkeep s:ffkeep
845
0fe7765dcb8e updated for version 7.0f03
vimboss
parents: 844
diff changeset
742 " call Dret("RestoreSettings")
0fe7765dcb8e updated for version 7.0f03
vimboss
parents: 844
diff changeset
743 endfun
0fe7765dcb8e updated for version 7.0f03
vimboss
parents: 844
diff changeset
744
0fe7765dcb8e updated for version 7.0f03
vimboss
parents: 844
diff changeset
745 " ---------------------------------------------------------------------
1618
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
746 " s:Escape: {{{2
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
747 fun s:Escape(name)
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
748 " shellescape() was added by patch 7.0.111
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
749 if exists("*shellescape")
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
750 return shellescape(a:name)
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
751 endif
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
752 return g:netrw_shq . a:name . g:netrw_shq
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
753 endfun
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
754
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
755 " ---------------------------------------------------------------------
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
756 " Restore:
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
757 let &cpo= s:keepcpo
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
758 unlet s:keepcpo
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
759
46bbe11644e0 updated for version 7.2a
vimboss
parents: 1186
diff changeset
760 " ---------------------------------------------------------------------
792
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
761 " Modelines: {{{1
860b73800cd7 updated for version 7.0231
vimboss
parents:
diff changeset
762 " vim: fdm=marker