annotate runtime/tutor/tutor.vim @ 3982:4934eb2e22dc v7.3.746

updated for version 7.3.746 Problem: Memory leaks when using location lists. Solution: Set qf_title to something. (Christian Brabandt)
author Bram Moolenaar <bram@vim.org>
date Wed, 05 Dec 2012 15:16:47 +0100
parents 04592728474a
children 7b83c190d370
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 " Vim tutor support file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 " Author: Eduardo F. Amatria <eferna1@platea.pntic.mec.es>
1698
f4f8014d516e updated for version 7.2c-000
vimboss
parents: 1621
diff changeset
3 " Maintainer: Bram Moolenaar
3830
04592728474a Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1698
diff changeset
4 " Last Change: 2012 Sep 21
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5
1698
f4f8014d516e updated for version 7.2c-000
vimboss
parents: 1621
diff changeset
6 " This Vim script is used for detecting if a translation of the
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 " tutor file exist, i.e., a tutor.xx file, where xx is the language.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 " If the translation does not exist, or no extension is given,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 " it defaults to the english version.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 " It is invoked by the vimtutor shell script.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 " 1. Build the extension of the file, if any:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 let s:ext = ""
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 if strlen($xx) > 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 let s:ext = "." . $xx
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 let s:lang = ""
782
d20041a02ee5 updated for version 7.0228
vimboss
parents: 557
diff changeset
19 " Check that a potential value has at least two letters.
d20041a02ee5 updated for version 7.0228
vimboss
parents: 557
diff changeset
20 " Ignore "1043" and "C".
d20041a02ee5 updated for version 7.0228
vimboss
parents: 557
diff changeset
21 if exists("v:lang") && v:lang =~ '\a\a'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 let s:lang = v:lang
782
d20041a02ee5 updated for version 7.0228
vimboss
parents: 557
diff changeset
23 elseif $LC_ALL =~ '\a\a'
205
d292c40ca788 updated for version 7.0060
vimboss
parents: 24
diff changeset
24 let s:lang = $LC_ALL
782
d20041a02ee5 updated for version 7.0228
vimboss
parents: 557
diff changeset
25 elseif $LANG =~ '\a\a'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 let s:lang = $LANG
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 if s:lang != ""
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 " Remove "@euro" (ignoring case), it may be at the end
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 let s:lang = substitute(s:lang, '\c@euro', '', '')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 " On MS-Windows it may be German_Germany.1252 or Polish_Poland.1250. How
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 " about other languages?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 if s:lang =~ "German"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 let s:ext = ".de"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 elseif s:lang =~ "Polish"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 let s:ext = ".pl"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 elseif s:lang =~ "Slovak"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 let s:ext = ".sk"
1154
f23b876b21ff updated for version 7.1a
vimboss
parents: 969
diff changeset
39 elseif s:lang =~ "Czech"
f23b876b21ff updated for version 7.1a
vimboss
parents: 969
diff changeset
40 let s:ext = ".cs"
782
d20041a02ee5 updated for version 7.0228
vimboss
parents: 557
diff changeset
41 elseif s:lang =~ "Dutch"
d20041a02ee5 updated for version 7.0228
vimboss
parents: 557
diff changeset
42 let s:ext = ".nl"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 let s:ext = "." . strpart(s:lang, 0, 2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
49 " Somehow ".ge" (Germany) is sometimes used for ".de" (Deutsch).
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
50 if s:ext =~? '\.ge'
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
51 let s:ext = ".de"
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
52 endif
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
53
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
54 if s:ext =~? '\.en'
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
55 let s:ext = ""
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
56 endif
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
57
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 " The japanese tutor is available in two encodings, guess which one to use
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 " The "sjis" one is actually "cp932", it doesn't matter for this text.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 if s:ext =~? '\.ja'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 if &enc =~ "euc"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 let s:ext = ".ja.euc"
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
63 elseif &enc != "utf-8"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 let s:ext = ".ja.sjis"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 " The korean tutor is available in two encodings, guess which one to use
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 if s:ext =~? '\.ko'
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
70 if &enc != "utf-8"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 let s:ext = ".ko.euc"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74
3830
04592728474a Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1698
diff changeset
75 " The Chinese tutor is available in three encodings, guess which one to use
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 " This segment is from the above lines and modified by
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 " Mendel L Chan <beos@turbolinux.com.cn> for Chinese vim tutorial
3830
04592728474a Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1698
diff changeset
78 " When 'encoding' is utf-8, choose between China (simplified) and Taiwan
04592728474a Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1698
diff changeset
79 " (traditional) based on the language, suggested by Alick Zhao.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 if s:ext =~? '\.zh'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 if &enc =~ 'big5\|cp950'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 let s:ext = ".zh.big5"
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
83 elseif &enc != 'utf-8'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 let s:ext = ".zh.euc"
3830
04592728474a Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1698
diff changeset
85 elseif s:ext =~? 'zh_tw' || (exists("s:lang") && s:lang =~? 'zh_tw')
04592728474a Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1698
diff changeset
86 let s:ext = ".zh_tw"
04592728474a Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1698
diff changeset
87 else
04592728474a Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1698
diff changeset
88 let s:ext = ".zh_cn"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 " The Polish tutor is available in two encodings, guess which one to use.
24
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
93 if s:ext =~? '\.pl'
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
94 if &enc =~ 1250
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
95 let s:ext = ".pl.cp1250"
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
96 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98
557
862863033fdd updated for version 7.0158
vimboss
parents: 205
diff changeset
99 " The Turkish tutor is available in two encodings, guess which one to use
862863033fdd updated for version 7.0158
vimboss
parents: 205
diff changeset
100 if s:ext =~? '\.tr'
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
101 if &enc == "iso-8859-9"
557
862863033fdd updated for version 7.0158
vimboss
parents: 205
diff changeset
102 let s:ext = ".tr.iso9"
862863033fdd updated for version 7.0158
vimboss
parents: 205
diff changeset
103 endif
862863033fdd updated for version 7.0158
vimboss
parents: 205
diff changeset
104 endif
862863033fdd updated for version 7.0158
vimboss
parents: 205
diff changeset
105
969
cf4d73a8924e updated for version 7.0-095
vimboss
parents: 953
diff changeset
106 " The Greek tutor is available in three encodings, guess what to use.
cf4d73a8924e updated for version 7.0-095
vimboss
parents: 953
diff changeset
107 " We used ".gr" (Greece) instead of ".el" (Greek); accept both.
cf4d73a8924e updated for version 7.0-095
vimboss
parents: 953
diff changeset
108 if s:ext =~? '\.gr\|\.el'
cf4d73a8924e updated for version 7.0-095
vimboss
parents: 953
diff changeset
109 if &enc == "iso-8859-7"
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
110 let s:ext = ".el"
969
cf4d73a8924e updated for version 7.0-095
vimboss
parents: 953
diff changeset
111 elseif &enc == "utf-8"
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
112 let s:ext = ".el.utf-8"
969
cf4d73a8924e updated for version 7.0-095
vimboss
parents: 953
diff changeset
113 elseif &enc =~ 737
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
114 let s:ext = ".el.cp737"
969
cf4d73a8924e updated for version 7.0-095
vimboss
parents: 953
diff changeset
115 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117
1154
f23b876b21ff updated for version 7.1a
vimboss
parents: 969
diff changeset
118 " The Slovak tutor is available in three encodings, guess which one to use
f23b876b21ff updated for version 7.1a
vimboss
parents: 969
diff changeset
119 if s:ext =~? '\.sk'
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
120 if &enc =~ 1250
1154
f23b876b21ff updated for version 7.1a
vimboss
parents: 969
diff changeset
121 let s:ext = ".sk.cp1250"
f23b876b21ff updated for version 7.1a
vimboss
parents: 969
diff changeset
122 endif
f23b876b21ff updated for version 7.1a
vimboss
parents: 969
diff changeset
123 endif
f23b876b21ff updated for version 7.1a
vimboss
parents: 969
diff changeset
124
f23b876b21ff updated for version 7.1a
vimboss
parents: 969
diff changeset
125 " The Czech tutor is available in three encodings, guess which one to use
f23b876b21ff updated for version 7.1a
vimboss
parents: 969
diff changeset
126 if s:ext =~? '\.cs'
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
127 if &enc =~ 1250
1154
f23b876b21ff updated for version 7.1a
vimboss
parents: 969
diff changeset
128 let s:ext = ".cs.cp1250"
f23b876b21ff updated for version 7.1a
vimboss
parents: 969
diff changeset
129 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131
953
2fb204616c9b updated for version 7.0-079
vimboss
parents: 782
diff changeset
132 " The Russian tutor is available in three encodings, guess which one to use.
2fb204616c9b updated for version 7.0-079
vimboss
parents: 782
diff changeset
133 if s:ext =~? '\.ru'
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
134 if &enc =~ '1251'
953
2fb204616c9b updated for version 7.0-079
vimboss
parents: 782
diff changeset
135 let s:ext = '.ru.cp1251'
2fb204616c9b updated for version 7.0-079
vimboss
parents: 782
diff changeset
136 elseif &enc =~ 'koi8'
2fb204616c9b updated for version 7.0-079
vimboss
parents: 782
diff changeset
137 let s:ext = '.ru'
2fb204616c9b updated for version 7.0-079
vimboss
parents: 782
diff changeset
138 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
141 " The Hungarian tutor is available in three encodings, guess which one to use.
1154
f23b876b21ff updated for version 7.1a
vimboss
parents: 969
diff changeset
142 if s:ext =~? '\.hu'
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
143 if &enc =~ 1250
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
144 let s:ext = ".hu.cp1250"
1154
f23b876b21ff updated for version 7.1a
vimboss
parents: 969
diff changeset
145 elseif &enc =~ 'iso-8859-2'
f23b876b21ff updated for version 7.1a
vimboss
parents: 969
diff changeset
146 let s:ext = '.hu'
f23b876b21ff updated for version 7.1a
vimboss
parents: 969
diff changeset
147 endif
f23b876b21ff updated for version 7.1a
vimboss
parents: 969
diff changeset
148 endif
f23b876b21ff updated for version 7.1a
vimboss
parents: 969
diff changeset
149
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
150 " The Croatian tutor is available in three encodings, guess which one to use.
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
151 if s:ext =~? '\.hr'
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
152 if &enc =~ 1250
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
153 let s:ext = ".hr.cp1250"
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
154 elseif &enc =~ 'iso-8859-2'
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
155 let s:ext = '.hr'
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
156 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
157 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
158
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
159 " Esperanto is only available in utf-8
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
160 if s:ext =~? '\.eo'
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
161 let s:ext = ".eo.utf-8"
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
162 endif
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
163 " Vietnamese is only available in utf-8
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
164 if s:ext =~? '\.vi'
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
165 let s:ext = ".vi.utf-8"
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
166 endif
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
167
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
168 " If 'encoding' is utf-8 s:ext must end in utf-8.
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
169 if &enc == 'utf-8' && s:ext !~ '\.utf-8'
1698
f4f8014d516e updated for version 7.2c-000
vimboss
parents: 1621
diff changeset
170 let s:ext .= '.utf-8'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
171 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
172
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
173 " 2. Build the name of the file:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
174 let s:tutorfile = "/tutor/tutor"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
175 let s:tutorxx = $VIMRUNTIME . s:tutorfile . s:ext
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
176
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
177 " 3. Finding the file:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
178 if filereadable(s:tutorxx)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
179 let $TUTOR = s:tutorxx
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
180 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
181 let $TUTOR = $VIMRUNTIME . s:tutorfile
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
182 echo "The file " . s:tutorxx . " does not exist.\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183 echo "Copying English version: " . $TUTOR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
184 4sleep
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187 " 4. Making the copy and exiting Vim:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188 e $TUTOR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
189 wq! $TUTORCOPY