~ubuntu-branches/ubuntu/maverick/vim/maverick

« back to all changes in this revision

Viewing changes to runtime/autoload/spellfile.vim

  • Committer: Bazaar Package Importer
  • Author(s): Steve Langasek
  • Date: 2009-05-04 11:13:42 UTC
  • mfrom: (1.1.8 upstream) (0.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090504111342-60miqybsixdpc345
Tags: 2:7.2.148-2ubuntu1
* Merge from Debian unstable, remaining changes:
  - debian/runtime/vimrc: "syntax on" is a sane default for non-tiny vim.
  - runtime/syntax/debcontrol.vim:
    + Add "metapackages" to the list of valid sections.
  - runtime/syntax/grub.vim:
    + Add Ubuntu-specific 'quiet' keyword.
  - Drop vim-lesstif package and lesstif2-dev build-dependency.
  - Enable Python interpreter on basic builds.
  - Disable autoindent, line-wrapping, and backup files by default.
* Dropped changes, merged in Debian:
  - Add jaunty, karmic to the list of valid suites.
  - runtime/syntax/debsources.vim:
    + Add "jaunty" to debsourcesDistrKeyword
  - Create a .pot file for translations.
* Drop gutsy from the list of valid distro series, it's been EOLed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
" Vim script to download a missing spell file
2
2
" Maintainer:   Bram Moolenaar <Bram@vim.org>
3
 
" Last Change:  2008 Jun 27
 
3
" Last Change:  2008 Nov 29
4
4
 
5
5
if !exists('g:spellfile_URL')
6
6
  " Prefer using http:// when netrw should be able to use it, since
39
39
  let s:donedict[a:lang . &enc] = 1
40
40
 
41
41
  " Find spell directories we can write in.
42
 
  let dirlist = []
43
 
  let dirchoices = '&Cancel'
44
 
  for dir in split(globpath(&rtp, 'spell'), "\n")
45
 
    if filewritable(dir) == 2
46
 
      call add(dirlist, dir)
47
 
      let dirchoices .= "\n&" . len(dirlist)
48
 
    endif
49
 
  endfor
 
42
  let [dirlist, dirchoices] = spellfile#GetDirChoices()
50
43
  if len(dirlist) == 0
51
 
    if &verbose
 
44
    let dir_to_create = spellfile#WritableSpellDir()
 
45
    if &verbose || dir_to_create != ''
52
46
      echomsg 'spellfile#LoadFile(): There is no writable spell directory.'
53
47
    endif
54
 
    return
 
48
    if dir_to_create != ''
 
49
      if confirm("Shall I create " . dir_to_create, "&Yes\n&No", 2) == 1
 
50
        " After creating the directory it should show up in the list.
 
51
        call mkdir(dir_to_create, "p")
 
52
        let [dirlist, dirchoices] = spellfile#GetDirChoices()
 
53
      endif
 
54
    endif
 
55
    if len(dirlist) == 0
 
56
      return
 
57
    endif
55
58
  endif
56
59
 
57
60
  let msg = 'Cannot find spell file for "' . a:lang . '" in ' . &enc
177
180
    unlet g:netrw_use_errorwindow
178
181
  endif
179
182
endfunc
 
183
 
 
184
" Get a list of writable spell directories and choices for confirm().
 
185
function! spellfile#GetDirChoices()
 
186
  let dirlist = []
 
187
  let dirchoices = '&Cancel'
 
188
  for dir in split(globpath(&rtp, 'spell'), "\n")
 
189
    if filewritable(dir) == 2
 
190
      call add(dirlist, dir)
 
191
      let dirchoices .= "\n&" . len(dirlist)
 
192
    endif
 
193
  endfor
 
194
  return [dirlist, dirchoices]
 
195
endfunc
 
196
 
 
197
function! spellfile#WritableSpellDir()
 
198
  if has("unix")
 
199
    " For Unix always use the $HOME/.vim directory
 
200
    return $HOME . "/.vim/spell"
 
201
  endif
 
202
  for dir in split(&rtp, ',')
 
203
    if filewritable(dir) == 2
 
204
      return dir . "/spell"
 
205
    endif
 
206
  endfor
 
207
  return ''
 
208
endfunction