annotate runtime/autoload/spellfile.vim @ 13074:66c014c71dad v8.0.1412

patch 8.0.1412: using free memory using setloclist() commit https://github.com/vim/vim/commit/12237448499aaeb8c4f2be7a1deda60c0f160627 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Dec 19 12:38:52 2017 +0100 patch 8.0.1412: using free memory using setloclist() Problem: Using free memory using setloclist(). (Dominique Pelle) Solution: Mark location list context as still in use when needed. (Yegappan Lakshmanan, closes #2462)
author Christian Brabandt <cb@256bit.org>
date Tue, 19 Dec 2017 12:45:06 +0100
parents ba708ee8d69d
children 2a4a2dc35c55
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
651
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
1 " Vim script to download a missing spell file
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
2 " Maintainer: Bram Moolenaar <Bram@vim.org>
3256
ba708ee8d69d Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
3 " Last Change: 2012 Jan 08
651
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
4
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
5 if !exists('g:spellfile_URL')
1652
e97a97d6a0eb updated for version 7.2a-004
vimboss
parents: 1624
diff changeset
6 " Prefer using http:// when netrw should be able to use it, since
e97a97d6a0eb updated for version 7.2a-004
vimboss
parents: 1624
diff changeset
7 " more firewalls let this through.
e97a97d6a0eb updated for version 7.2a-004
vimboss
parents: 1624
diff changeset
8 if executable("curl") || executable("wget") || executable("fetch")
e97a97d6a0eb updated for version 7.2a-004
vimboss
parents: 1624
diff changeset
9 let g:spellfile_URL = 'http://ftp.vim.org/pub/vim/runtime/spell'
e97a97d6a0eb updated for version 7.2a-004
vimboss
parents: 1624
diff changeset
10 else
e97a97d6a0eb updated for version 7.2a-004
vimboss
parents: 1624
diff changeset
11 let g:spellfile_URL = 'ftp://ftp.vim.org/pub/vim/runtime/spell'
e97a97d6a0eb updated for version 7.2a-004
vimboss
parents: 1624
diff changeset
12 endif
651
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
13 endif
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
14 let s:spellfile_URL = '' " Start with nothing so that s:donedict is reset.
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
15
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
16 " This function is used for the spellfile plugin.
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
17 function! spellfile#LoadFile(lang)
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
18 " If the netrw plugin isn't loaded we silently skip everything.
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
19 if !exists(":Nread")
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
20 if &verbose
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
21 echomsg 'spellfile#LoadFile(): Nread command is not available.'
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
22 endif
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
23 return
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
24 endif
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
25
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
26 " If the URL changes we try all files again.
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
27 if s:spellfile_URL != g:spellfile_URL
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
28 let s:donedict = {}
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
29 let s:spellfile_URL = g:spellfile_URL
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
30 endif
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
31
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
32 " I will say this only once!
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
33 if has_key(s:donedict, a:lang . &enc)
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
34 if &verbose
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
35 echomsg 'spellfile#LoadFile(): Tried this language/encoding before.'
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
36 endif
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
37 return
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
38 endif
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
39 let s:donedict[a:lang . &enc] = 1
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
40
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
41 " Find spell directories we can write in.
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
42 let [dirlist, dirchoices] = spellfile#GetDirChoices()
651
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
43 if len(dirlist) == 0
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
44 let dir_to_create = spellfile#WritableSpellDir()
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
45 if &verbose || dir_to_create != ''
651
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
46 echomsg 'spellfile#LoadFile(): There is no writable spell directory.'
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
47 endif
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
48 if dir_to_create != ''
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
49 if confirm("Shall I create " . dir_to_create, "&Yes\n&No", 2) == 1
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
50 " After creating the directory it should show up in the list.
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
51 call mkdir(dir_to_create, "p")
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
52 let [dirlist, dirchoices] = spellfile#GetDirChoices()
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
53 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
54 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
55 if len(dirlist) == 0
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
56 return
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
57 endif
651
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
58 endif
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
59
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
60 let msg = 'Cannot find spell file for "' . a:lang . '" in ' . &enc
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
61 let msg .= "\nDo you want me to try downloading it?"
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
62 if confirm(msg, "&Yes\n&No", 2) == 1
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
63 let enc = &encoding
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
64 if enc == 'iso-8859-15'
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
65 let enc = 'latin1'
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
66 endif
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
67 let fname = a:lang . '.' . enc . '.spl'
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
68
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
69 " Split the window, read the file into a new buffer.
1185
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
70 " Remember the buffer number, we check it below.
651
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
71 new
1185
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
72 let newbufnr = winbufnr(0)
3256
ba708ee8d69d Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
73 setlocal bin fenc=
651
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
74 echo 'Downloading ' . fname . '...'
884
9f184758f277 updated for version 7.0-010
vimboss
parents: 651
diff changeset
75 call spellfile#Nread(fname)
651
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
76 if getline(2) !~ 'VIMspell'
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
77 " Didn't work, perhaps there is an ASCII one.
1185
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
78 " Careful: Nread() may have opened a new window for the error message,
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
79 " we need to go back to our own buffer and window.
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
80 if newbufnr != winbufnr(0)
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
81 let winnr = bufwinnr(newbufnr)
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
82 if winnr == -1
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
83 " Our buffer has vanished!? Open a new window.
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
84 echomsg "download buffer disappeared, opening a new one"
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
85 new
3256
ba708ee8d69d Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
86 setlocal bin fenc=
1185
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
87 else
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
88 exe winnr . "wincmd w"
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
89 endif
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
90 endif
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
91 if newbufnr == winbufnr(0)
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
92 " We are back the old buffer, remove any (half-finished) download.
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
93 g/^/d
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
94 else
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
95 let newbufnr = winbufnr(0)
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
96 endif
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
97
651
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
98 let fname = a:lang . '.ascii.spl'
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
99 echo 'Could not find it, trying ' . fname . '...'
884
9f184758f277 updated for version 7.0-010
vimboss
parents: 651
diff changeset
100 call spellfile#Nread(fname)
651
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
101 if getline(2) !~ 'VIMspell'
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
102 echo 'Sorry, downloading failed'
1185
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
103 exe newbufnr . "bwipe!"
651
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
104 return
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
105 endif
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
106 endif
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
107
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
108 " Delete the empty first line and mark the file unmodified.
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
109 1d
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
110 set nomod
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
111
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
112 let msg = "In which directory do you want to write the file:"
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
113 for i in range(len(dirlist))
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
114 let msg .= "\n" . (i + 1) . '. ' . dirlist[i]
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
115 endfor
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
116 let dirchoice = confirm(msg, dirchoices) - 2
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
117 if dirchoice >= 0
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1226
diff changeset
118 if exists('*fnameescape')
18ee39301b82 updated for version 7.2a
vimboss
parents: 1226
diff changeset
119 let dirname = fnameescape(dirlist[dirchoice])
18ee39301b82 updated for version 7.2a
vimboss
parents: 1226
diff changeset
120 else
18ee39301b82 updated for version 7.2a
vimboss
parents: 1226
diff changeset
121 let dirname = escape(dirlist[dirchoice], ' ')
18ee39301b82 updated for version 7.2a
vimboss
parents: 1226
diff changeset
122 endif
3256
ba708ee8d69d Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
123 setlocal fenc=
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1226
diff changeset
124 exe "write " . dirname . '/' . fname
651
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
125
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
126 " Also download the .sug file, if the user wants to.
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
127 let msg = "Do you want me to try getting the .sug file?\n"
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
128 let msg .= "This will improve making suggestions for spelling mistakes,\n"
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
129 let msg .= "but it uses quite a bit of memory."
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
130 if confirm(msg, "&No\n&Yes") == 2
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
131 g/^/d
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
132 let fname = substitute(fname, '\.spl$', '.sug', '')
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
133 echo 'Downloading ' . fname . '...'
884
9f184758f277 updated for version 7.0-010
vimboss
parents: 651
diff changeset
134 call spellfile#Nread(fname)
1185
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
135 if getline(2) =~ 'VIMsug'
651
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
136 1d
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1226
diff changeset
137 exe "write " . dirname . '/' . fname
1185
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
138 set nomod
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
139 else
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
140 echo 'Sorry, downloading failed'
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
141 " Go back to our own buffer/window, Nread() may have taken us to
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
142 " another window.
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
143 if newbufnr != winbufnr(0)
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
144 let winnr = bufwinnr(newbufnr)
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
145 if winnr != -1
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
146 exe winnr . "wincmd w"
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
147 endif
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
148 endif
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
149 if newbufnr == winbufnr(0)
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
150 set nomod
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
151 endif
651
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
152 endif
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
153 endif
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
154 endif
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
155
1185
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
156 " Wipe out the buffer we used.
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
157 exe newbufnr . "bwipe"
651
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
158 endif
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
159 endfunc
884
9f184758f277 updated for version 7.0-010
vimboss
parents: 651
diff changeset
160
950
f03c3fae0a99 updated for version 7.0-076
vimboss
parents: 884
diff changeset
161 " Read "fname" from the server.
884
9f184758f277 updated for version 7.0-010
vimboss
parents: 651
diff changeset
162 function! spellfile#Nread(fname)
1226
a49d06539452 updated for version 7.1b
vimboss
parents: 1185
diff changeset
163 " We do our own error handling, don't want a window for it.
a49d06539452 updated for version 7.1b
vimboss
parents: 1185
diff changeset
164 if exists("g:netrw_use_errorwindow")
a49d06539452 updated for version 7.1b
vimboss
parents: 1185
diff changeset
165 let save_ew = g:netrw_use_errorwindow
a49d06539452 updated for version 7.1b
vimboss
parents: 1185
diff changeset
166 endif
a49d06539452 updated for version 7.1b
vimboss
parents: 1185
diff changeset
167 let g:netrw_use_errorwindow=0
a49d06539452 updated for version 7.1b
vimboss
parents: 1185
diff changeset
168
950
f03c3fae0a99 updated for version 7.0-076
vimboss
parents: 884
diff changeset
169 if g:spellfile_URL =~ '^ftp://'
f03c3fae0a99 updated for version 7.0-076
vimboss
parents: 884
diff changeset
170 " for an ftp server use a default login and password to avoid a prompt
f03c3fae0a99 updated for version 7.0-076
vimboss
parents: 884
diff changeset
171 let machine = substitute(g:spellfile_URL, 'ftp://\([^/]*\).*', '\1', '')
f03c3fae0a99 updated for version 7.0-076
vimboss
parents: 884
diff changeset
172 let dir = substitute(g:spellfile_URL, 'ftp://[^/]*/\(.*\)', '\1', '')
f03c3fae0a99 updated for version 7.0-076
vimboss
parents: 884
diff changeset
173 exe 'Nread "' . machine . ' anonymous vim7user ' . dir . '/' . a:fname . '"'
f03c3fae0a99 updated for version 7.0-076
vimboss
parents: 884
diff changeset
174 else
f03c3fae0a99 updated for version 7.0-076
vimboss
parents: 884
diff changeset
175 exe 'Nread ' g:spellfile_URL . '/' . a:fname
f03c3fae0a99 updated for version 7.0-076
vimboss
parents: 884
diff changeset
176 endif
1226
a49d06539452 updated for version 7.1b
vimboss
parents: 1185
diff changeset
177
a49d06539452 updated for version 7.1b
vimboss
parents: 1185
diff changeset
178 if exists("save_ew")
a49d06539452 updated for version 7.1b
vimboss
parents: 1185
diff changeset
179 let g:netrw_use_errorwindow = save_ew
a49d06539452 updated for version 7.1b
vimboss
parents: 1185
diff changeset
180 else
a49d06539452 updated for version 7.1b
vimboss
parents: 1185
diff changeset
181 unlet g:netrw_use_errorwindow
a49d06539452 updated for version 7.1b
vimboss
parents: 1185
diff changeset
182 endif
884
9f184758f277 updated for version 7.0-010
vimboss
parents: 651
diff changeset
183 endfunc
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
184
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
185 " Get a list of writable spell directories and choices for confirm().
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
186 function! spellfile#GetDirChoices()
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
187 let dirlist = []
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
188 let dirchoices = '&Cancel'
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
189 for dir in split(globpath(&rtp, 'spell'), "\n")
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
190 if filewritable(dir) == 2
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
191 call add(dirlist, dir)
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
192 let dirchoices .= "\n&" . len(dirlist)
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
193 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
194 endfor
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
195 return [dirlist, dirchoices]
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
196 endfunc
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
197
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
198 function! spellfile#WritableSpellDir()
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
199 if has("unix")
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
200 " For Unix always use the $HOME/.vim directory
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
201 return $HOME . "/.vim/spell"
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
202 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
203 for dir in split(&rtp, ',')
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
204 if filewritable(dir) == 2
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
205 return dir . "/spell"
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
206 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
207 endfor
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
208 return ''
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
209 endfunction