annotate runtime/autoload/gzip.vim @ 32770:4027cefc2aab

Farewell to Bram and dedicate upcoming Vim 9.1 to him (#12749) Commit: https://github.com/vim/vim/commit/e978b4534a5e10471108259118c0ef791106fd92 Author: Christian Brabandt <cb@256bit.org> Date: Sun Aug 13 10:33:05 2023 +0200 Farewell to Bram and dedicate upcoming Vim 9.1 to him (https://github.com/vim/vim/issues/12749) * Dedicate upcoming Vim 9.1 to Bram Also replace in a few more places Brams email address and mention new maintainers. * Remove Bram from any Maintainer role * runtime: Align Header * it's mailing list not mailinglist
author Christian Brabandt <cb@256bit.org>
date Sun, 13 Aug 2023 10:45:08 +0200
parents 876fbdd84e52
children 828bcb1a37e7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
446
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
1 " Vim autoload file for editing compressed files.
32770
4027cefc2aab Farewell to Bram and dedicate upcoming Vim 9.1 to him (#12749)
Christian Brabandt <cb@256bit.org>
parents: 10244
diff changeset
2 " Maintainer: The Vim Project <https://github.com/vim/vim>
4027cefc2aab Farewell to Bram and dedicate upcoming Vim 9.1 to him (#12749)
Christian Brabandt <cb@256bit.org>
parents: 10244
diff changeset
3 " Last Change: 2023 Aug 10
4027cefc2aab Farewell to Bram and dedicate upcoming Vim 9.1 to him (#12749)
Christian Brabandt <cb@256bit.org>
parents: 10244
diff changeset
4 " Former Maintainer: Bram Moolenaar <Bram@vim.org>
446
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
5
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
6 " These functions are used by the gzip plugin.
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
7
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
8 " Function to check that executing "cmd [-f]" works.
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
9 " The result is cached in s:have_"cmd" for speed.
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
10 fun s:check(cmd)
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
11 let name = substitute(a:cmd, '\(\S*\).*', '\1', '')
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
12 if !exists("s:have_" . name)
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
13 let e = executable(name)
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
14 if e < 0
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
15 let r = system(name . " --version")
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
16 let e = (r !~ "not found" && r != "")
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
17 endif
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
18 exe "let s:have_" . name . "=" . e
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
19 endif
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
20 exe "return s:have_" . name
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
21 endfun
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
22
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
23 " Set b:gzip_comp_arg to the gzip argument to be used for compression, based on
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
24 " the flags in the compressed file.
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
25 " The only compression methods that can be detected are max speed (-1) and max
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
26 " compression (-9).
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
27 fun s:set_compression(line)
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
28 " get the Compression Method
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
29 let l:cm = char2nr(a:line[2])
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
30 " if it's 8 (DEFLATE), we can check for the compression level
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
31 if l:cm == 8
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
32 " get the eXtra FLags
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
33 let l:xfl = char2nr(a:line[8])
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
34 " max compression
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
35 if l:xfl == 2
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
36 let b:gzip_comp_arg = "-9"
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
37 " min compression
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
38 elseif l:xfl == 4
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
39 let b:gzip_comp_arg = "-1"
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
40 endif
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
41 endif
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
42 endfun
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
43
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
44
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
45 " After reading compressed file: Uncompress text in buffer with "cmd"
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
46 fun gzip#read(cmd)
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
47 " don't do anything if the cmd is not supported
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
48 if !s:check(a:cmd)
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
49 return
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
50 endif
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
51
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
52 " for gzip check current compression level and set b:gzip_comp_arg.
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
53 silent! unlet b:gzip_comp_arg
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
54 if a:cmd[0] == 'g'
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
55 call s:set_compression(getline(1))
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
56 endif
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
57
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
58 " make 'patchmode' empty, we don't want a copy of the written file
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
59 let pm_save = &pm
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
60 set pm=
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
61 " remove 'a' and 'A' from 'cpo' to avoid the alternate file changes
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
62 let cpo_save = &cpo
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
63 set cpo-=a cpo-=A
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
64 " set 'modifiable'
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
65 let ma_save = &ma
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
66 setlocal ma
10244
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 6336
diff changeset
67 " set 'write'
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 6336
diff changeset
68 let write_save = &write
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 6336
diff changeset
69 set write
1190
4e90dc161511 updated for version 7.1b
vimboss
parents: 1132
diff changeset
70 " Reset 'foldenable', otherwise line numbers get adjusted.
4e90dc161511 updated for version 7.1b
vimboss
parents: 1132
diff changeset
71 if has("folding")
4e90dc161511 updated for version 7.1b
vimboss
parents: 1132
diff changeset
72 let fen_save = &fen
4e90dc161511 updated for version 7.1b
vimboss
parents: 1132
diff changeset
73 setlocal nofen
4e90dc161511 updated for version 7.1b
vimboss
parents: 1132
diff changeset
74 endif
4e90dc161511 updated for version 7.1b
vimboss
parents: 1132
diff changeset
75
446
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
76 " when filtering the whole buffer, it will become empty
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
77 let empty = line("'[") == 1 && line("']") == line("$")
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
78 let tmp = tempname()
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
79 let tmpe = tmp . "." . expand("<afile>:e")
1592
e06e177de52a updated for version 7.1-305
vimboss
parents: 1190
diff changeset
80 if exists('*fnameescape')
e06e177de52a updated for version 7.1-305
vimboss
parents: 1190
diff changeset
81 let tmp_esc = fnameescape(tmp)
e06e177de52a updated for version 7.1-305
vimboss
parents: 1190
diff changeset
82 let tmpe_esc = fnameescape(tmpe)
e06e177de52a updated for version 7.1-305
vimboss
parents: 1190
diff changeset
83 else
e06e177de52a updated for version 7.1-305
vimboss
parents: 1190
diff changeset
84 let tmp_esc = escape(tmp, ' ')
e06e177de52a updated for version 7.1-305
vimboss
parents: 1190
diff changeset
85 let tmpe_esc = escape(tmpe, ' ')
e06e177de52a updated for version 7.1-305
vimboss
parents: 1190
diff changeset
86 endif
446
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
87 " write the just read lines to a temp file "'[,']w tmp.gz"
1592
e06e177de52a updated for version 7.1-305
vimboss
parents: 1190
diff changeset
88 execute "silent '[,']w " . tmpe_esc
446
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
89 " uncompress the temp file: call system("gzip -dn tmp.gz")
985
656853d9c014 updated for version 7.0-111
vimboss
parents: 922
diff changeset
90 call system(a:cmd . " " . s:escape(tmpe))
446
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
91 if !filereadable(tmp)
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
92 " uncompress didn't work! Keep the compressed file then.
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
93 echoerr "Error: Could not read uncompressed file"
1190
4e90dc161511 updated for version 7.1b
vimboss
parents: 1132
diff changeset
94 let ok = 0
446
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
95 else
1190
4e90dc161511 updated for version 7.1b
vimboss
parents: 1132
diff changeset
96 let ok = 1
4e90dc161511 updated for version 7.1b
vimboss
parents: 1132
diff changeset
97 " delete the compressed lines; remember the line number
4e90dc161511 updated for version 7.1b
vimboss
parents: 1132
diff changeset
98 let l = line("'[") - 1
4e90dc161511 updated for version 7.1b
vimboss
parents: 1132
diff changeset
99 if exists(":lockmarks")
4e90dc161511 updated for version 7.1b
vimboss
parents: 1132
diff changeset
100 lockmarks '[,']d _
4e90dc161511 updated for version 7.1b
vimboss
parents: 1132
diff changeset
101 else
4e90dc161511 updated for version 7.1b
vimboss
parents: 1132
diff changeset
102 '[,']d _
4e90dc161511 updated for version 7.1b
vimboss
parents: 1132
diff changeset
103 endif
4e90dc161511 updated for version 7.1b
vimboss
parents: 1132
diff changeset
104 " read in the uncompressed lines "'[-1r tmp"
4e90dc161511 updated for version 7.1b
vimboss
parents: 1132
diff changeset
105 " Use ++edit if the buffer was empty, keep the 'ff' and 'fenc' options.
4e90dc161511 updated for version 7.1b
vimboss
parents: 1132
diff changeset
106 setlocal nobin
4e90dc161511 updated for version 7.1b
vimboss
parents: 1132
diff changeset
107 if exists(":lockmarks")
4e90dc161511 updated for version 7.1b
vimboss
parents: 1132
diff changeset
108 if empty
1592
e06e177de52a updated for version 7.1-305
vimboss
parents: 1190
diff changeset
109 execute "silent lockmarks " . l . "r ++edit " . tmp_esc
1190
4e90dc161511 updated for version 7.1b
vimboss
parents: 1132
diff changeset
110 else
1592
e06e177de52a updated for version 7.1-305
vimboss
parents: 1190
diff changeset
111 execute "silent lockmarks " . l . "r " . tmp_esc
1190
4e90dc161511 updated for version 7.1b
vimboss
parents: 1132
diff changeset
112 endif
4e90dc161511 updated for version 7.1b
vimboss
parents: 1132
diff changeset
113 else
1592
e06e177de52a updated for version 7.1-305
vimboss
parents: 1190
diff changeset
114 execute "silent " . l . "r " . tmp_esc
1190
4e90dc161511 updated for version 7.1b
vimboss
parents: 1132
diff changeset
115 endif
4e90dc161511 updated for version 7.1b
vimboss
parents: 1132
diff changeset
116
4e90dc161511 updated for version 7.1b
vimboss
parents: 1132
diff changeset
117 " if buffer became empty, delete trailing blank line
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 446
diff changeset
118 if empty
1190
4e90dc161511 updated for version 7.1b
vimboss
parents: 1132
diff changeset
119 silent $delete _
4e90dc161511 updated for version 7.1b
vimboss
parents: 1132
diff changeset
120 1
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 446
diff changeset
121 endif
1190
4e90dc161511 updated for version 7.1b
vimboss
parents: 1132
diff changeset
122 " delete the temp file and the used buffers
4e90dc161511 updated for version 7.1b
vimboss
parents: 1132
diff changeset
123 call delete(tmp)
1592
e06e177de52a updated for version 7.1-305
vimboss
parents: 1190
diff changeset
124 silent! exe "bwipe " . tmp_esc
e06e177de52a updated for version 7.1-305
vimboss
parents: 1190
diff changeset
125 silent! exe "bwipe " . tmpe_esc
446
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
126 endif
6336
4abac79c0b7a Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1668
diff changeset
127 " Store the OK flag, so that we can use it when writing.
4abac79c0b7a Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1668
diff changeset
128 let b:uncompressOk = ok
446
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
129
1190
4e90dc161511 updated for version 7.1b
vimboss
parents: 1132
diff changeset
130 " Restore saved option values.
446
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
131 let &pm = pm_save
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
132 let &cpo = cpo_save
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
133 let &l:ma = ma_save
10244
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 6336
diff changeset
134 let &write = write_save
1190
4e90dc161511 updated for version 7.1b
vimboss
parents: 1132
diff changeset
135 if has("folding")
4e90dc161511 updated for version 7.1b
vimboss
parents: 1132
diff changeset
136 let &l:fen = fen_save
4e90dc161511 updated for version 7.1b
vimboss
parents: 1132
diff changeset
137 endif
4e90dc161511 updated for version 7.1b
vimboss
parents: 1132
diff changeset
138
446
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
139 " When uncompressed the whole buffer, do autocommands
1190
4e90dc161511 updated for version 7.1b
vimboss
parents: 1132
diff changeset
140 if ok && empty
1592
e06e177de52a updated for version 7.1-305
vimboss
parents: 1190
diff changeset
141 if exists('*fnameescape')
e06e177de52a updated for version 7.1-305
vimboss
parents: 1190
diff changeset
142 let fname = fnameescape(expand("%:r"))
e06e177de52a updated for version 7.1-305
vimboss
parents: 1190
diff changeset
143 else
e06e177de52a updated for version 7.1-305
vimboss
parents: 1190
diff changeset
144 let fname = escape(expand("%:r"), " \t\n*?[{`$\\%#'\"|!<")
e06e177de52a updated for version 7.1-305
vimboss
parents: 1190
diff changeset
145 endif
446
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
146 if &verbose >= 8
1592
e06e177de52a updated for version 7.1-305
vimboss
parents: 1190
diff changeset
147 execute "doau BufReadPost " . fname
446
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
148 else
1592
e06e177de52a updated for version 7.1-305
vimboss
parents: 1190
diff changeset
149 execute "silent! doau BufReadPost " . fname
446
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
150 endif
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
151 endif
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
152 endfun
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
153
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
154 " After writing compressed file: Compress written file with "cmd"
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
155 fun gzip#write(cmd)
6336
4abac79c0b7a Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1668
diff changeset
156 if exists('b:uncompressOk') && !b:uncompressOk
4abac79c0b7a Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1668
diff changeset
157 echomsg "Not compressing file because uncompress failed; reset b:uncompressOk to compress anyway"
446
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
158 " don't do anything if the cmd is not supported
6336
4abac79c0b7a Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1668
diff changeset
159 elseif s:check(a:cmd)
446
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
160 " Rename the file before compressing it.
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
161 let nm = resolve(expand("<afile>"))
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
162 let nmt = s:tempname(nm)
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
163 if rename(nm, nmt) == 0
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
164 if exists("b:gzip_comp_arg")
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1592
diff changeset
165 call system(a:cmd . " " . b:gzip_comp_arg . " -- " . s:escape(nmt))
446
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
166 else
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1592
diff changeset
167 call system(a:cmd . " -- " . s:escape(nmt))
446
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
168 endif
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
169 call rename(nmt . "." . expand("<afile>:e"), nm)
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
170 endif
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
171 endif
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
172 endfun
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
173
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
174 " Before appending to compressed file: Uncompress file with "cmd"
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
175 fun gzip#appre(cmd)
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
176 " don't do anything if the cmd is not supported
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
177 if s:check(a:cmd)
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
178 let nm = expand("<afile>")
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
179
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
180 " for gzip check current compression level and set b:gzip_comp_arg.
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
181 silent! unlet b:gzip_comp_arg
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
182 if a:cmd[0] == 'g'
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
183 call s:set_compression(readfile(nm, "b", 1)[0])
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
184 endif
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
185
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
186 " Rename to a weird name to avoid the risk of overwriting another file
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
187 let nmt = expand("<afile>:p:h") . "/X~=@l9q5"
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
188 let nmte = nmt . "." . expand("<afile>:e")
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
189 if rename(nm, nmte) == 0
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
190 if &patchmode != "" && getfsize(nm . &patchmode) == -1
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
191 " Create patchmode file by creating the decompressed file new
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1592
diff changeset
192 call system(a:cmd . " -c -- " . s:escape(nmte) . " > " . s:escape(nmt))
446
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
193 call rename(nmte, nm . &patchmode)
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
194 else
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1592
diff changeset
195 call system(a:cmd . " -- " . s:escape(nmte))
446
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
196 endif
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
197 call rename(nmt, nm)
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
198 endif
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
199 endif
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
200 endfun
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
201
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
202 " find a file name for the file to be compressed. Use "name" without an
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
203 " extension if possible. Otherwise use a weird name to avoid overwriting an
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
204 " existing file.
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
205 fun s:tempname(name)
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
206 let fn = fnamemodify(a:name, ":r")
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
207 if !filereadable(fn) && !isdirectory(fn)
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
208 return fn
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
209 endif
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
210 return fnamemodify(a:name, ":p:h") . "/X~=@l9q5"
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
211 endfun
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
212
985
656853d9c014 updated for version 7.0-111
vimboss
parents: 922
diff changeset
213 fun s:escape(name)
656853d9c014 updated for version 7.0-111
vimboss
parents: 922
diff changeset
214 " shellescape() was added by patch 7.0.111
1132
857a5e3e1d34 updated for version 7.1a
vimboss
parents: 985
diff changeset
215 if exists("*shellescape")
985
656853d9c014 updated for version 7.0-111
vimboss
parents: 922
diff changeset
216 return shellescape(a:name)
656853d9c014 updated for version 7.0-111
vimboss
parents: 922
diff changeset
217 endif
656853d9c014 updated for version 7.0-111
vimboss
parents: 922
diff changeset
218 return "'" . a:name . "'"
656853d9c014 updated for version 7.0-111
vimboss
parents: 922
diff changeset
219 endfun
656853d9c014 updated for version 7.0-111
vimboss
parents: 922
diff changeset
220
446
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
221 " vim: set sw=2 :