~spacexplorer/+junk/myenv

« back to all changes in this revision

Viewing changes to vim/vim/ftplugin/latex-suite/main.vim

  • Committer: Kim Allamandola
  • Date: 2011-05-02 05:39:17 UTC
  • Revision ID: spacexplorer@gmail.com-20110502053917-x0yl2lr9ri4yskr2
InitĀ import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
" LaTeX filetype
 
2
"         Language: LaTeX (ft=tex)
 
3
"       Maintainer: Srinath Avadhanula
 
4
"                  CVS: $Id: main.vim 999 2006-03-21 05:32:37Z srinathava $
 
5
"                  URL: 
 
6
 
 
7
" line continuation used here.
 
8
let s:save_cpo = &cpo
 
9
set cpo&vim
 
10
 
 
11
" avoiding re-inclusion {{{
 
12
" the avoiding re-inclusion statement is not provided here because the files
 
13
" which call this file should in the normal course of events handle the
 
14
" re-inclusion stuff.
 
15
 
 
16
" we definitely dont want to run through the entire file each and every time.
 
17
" only once to define the functions. for successive latex files, just set up
 
18
" the folding and mappings and quit.
 
19
if exists('s:doneFunctionDefinitions') && !exists('b:forceRedoLocalTex')
 
20
        call s:SetTeXOptions()
 
21
        finish
 
22
endif
 
23
 
 
24
let s:doneFunctionDefinitions = 1
 
25
 
 
26
" get the place where this plugin resides for setting cpt and dict options.
 
27
" these lines need to be outside the function.
 
28
let s:path = expand('<sfile>:p:h')
 
29
" set up personal defaults.
 
30
runtime ftplugin/tex/texrc
 
31
" set up global defaults.
 
32
exe "so ".s:path.'/texrc'
 
33
 
 
34
" }}}
 
35
 
 
36
nmap <silent> <script> <plug> i
 
37
imap <silent> <script> <C-o><plug> <Nop>
 
38
 
 
39
" ==============================================================================
 
40
" mappings
 
41
" ==============================================================================
 
42
" {{{
 
43
" calculate the mapleader character.
 
44
let s:ml = exists('g:mapleader') ? g:mapleader : '\'
 
45
 
 
46
if !exists('s:doneMappings')
 
47
        let s:doneMappings = 1
 
48
        " short forms for latex formatting and math elements. {{{
 
49
        " taken from auctex.vim or miktexmacros.vim
 
50
        call IMAP ('__', '_{<++>}<++>', "tex")
 
51
        call IMAP ('()', '(<++>)<++>', "tex")
 
52
        call IMAP ('[]', '[<++>]<++>', "tex")
 
53
        call IMAP ('{}', '{<++>}<++>', "tex")
 
54
        call IMAP ('^^', '^{<++>}<++>', "tex")
 
55
        call IMAP ('$$', '$<++>$<++>', "tex")
 
56
        call IMAP ('==', '&=& ', "tex")
 
57
        call IMAP ('~~', '&\approx& ', "tex")
 
58
        call IMAP ('=~', '\approx', "tex")
 
59
        call IMAP ('::', '\dots', "tex")
 
60
        call IMAP ('((', '\left( <++> \right)<++>', "tex")
 
61
        call IMAP ('[[', '\left[ <++> \right]<++>', "tex")
 
62
        call IMAP ('{{', '\left\{ <++> \right\}<++>', "tex")
 
63
        call IMAP (g:Tex_Leader.'^', '\hat{<++>}<++>', "tex")
 
64
        call IMAP (g:Tex_Leader.'_', '\bar{<++>}<++>', "tex")
 
65
        call IMAP (g:Tex_Leader.'6', '\partial', "tex")
 
66
        call IMAP (g:Tex_Leader.'8', '\infty', "tex")
 
67
        call IMAP (g:Tex_Leader.'/', '\frac{<++>}{<++>}<++>', "tex")
 
68
        call IMAP (g:Tex_Leader.'%', '\frac{<++>}{<++>}<++>', "tex")
 
69
        call IMAP (g:Tex_Leader.'@', '\circ', "tex")
 
70
        call IMAP (g:Tex_Leader.'0', '^\circ', "tex")
 
71
        call IMAP (g:Tex_Leader.'=', '\equiv', "tex")
 
72
        call IMAP (g:Tex_Leader."\\",'\setminus', "tex")
 
73
        call IMAP (g:Tex_Leader.'.', '\cdot', "tex")
 
74
        call IMAP (g:Tex_Leader.'*', '\times', "tex")
 
75
        call IMAP (g:Tex_Leader.'&', '\wedge', "tex")
 
76
        call IMAP (g:Tex_Leader.'-', '\bigcap', "tex")
 
77
        call IMAP (g:Tex_Leader.'+', '\bigcup', "tex")
 
78
        call IMAP (g:Tex_Leader.'M', '\sum_{<++>}^{<++>}<++>', 'tex')
 
79
        call IMAP (g:Tex_Leader.'S', '\sum_{<++>}^{<++>}<++>', 'tex')
 
80
        call IMAP (g:Tex_Leader.'(', '\subset', "tex")
 
81
        call IMAP (g:Tex_Leader.')', '\supset', "tex")
 
82
        call IMAP (g:Tex_Leader.'<', '\le', "tex")
 
83
        call IMAP (g:Tex_Leader.'>', '\ge', "tex")
 
84
        call IMAP (g:Tex_Leader.',', '\nonumber', "tex")
 
85
        call IMAP (g:Tex_Leader.'~', '\tilde{<++>}<++>', "tex")
 
86
        call IMAP (g:Tex_Leader.';', '\dot{<++>}<++>', "tex")
 
87
        call IMAP (g:Tex_Leader.':', '\ddot{<++>}<++>', "tex")
 
88
        call IMAP (g:Tex_Leader.'2', '\sqrt{<++>}<++>', "tex")
 
89
        call IMAP (g:Tex_Leader.'|', '\Big|', "tex")
 
90
        call IMAP (g:Tex_Leader.'I', "\\int_{<++>}^{<++>}<++>", 'tex')
 
91
        " }}}
 
92
        " Greek Letters {{{
 
93
        call IMAP(g:Tex_Leader.'a', '\alpha', 'tex')
 
94
        call IMAP(g:Tex_Leader.'b', '\beta', 'tex')
 
95
        call IMAP(g:Tex_Leader.'c', '\chi', 'tex')
 
96
        call IMAP(g:Tex_Leader.'d', '\delta', 'tex')
 
97
        call IMAP(g:Tex_Leader.'e', '\varepsilon', 'tex')
 
98
        call IMAP(g:Tex_Leader.'f', '\varphi', 'tex')
 
99
        call IMAP(g:Tex_Leader.'g', '\gamma', 'tex')
 
100
        call IMAP(g:Tex_Leader.'h', '\eta', 'tex')
 
101
        call IMAP(g:Tex_Leader.'k', '\kappa', 'tex')
 
102
        call IMAP(g:Tex_Leader.'l', '\lambda', 'tex')
 
103
        call IMAP(g:Tex_Leader.'m', '\mu', 'tex')
 
104
        call IMAP(g:Tex_Leader.'n', '\nu', 'tex')
 
105
        call IMAP(g:Tex_Leader.'p', '\pi', 'tex')
 
106
        call IMAP(g:Tex_Leader.'q', '\theta', 'tex')
 
107
        call IMAP(g:Tex_Leader.'r', '\rho', 'tex')
 
108
        call IMAP(g:Tex_Leader.'s', '\sigma', 'tex')
 
109
        call IMAP(g:Tex_Leader.'t', '\tau', 'tex')
 
110
        call IMAP(g:Tex_Leader.'u', '\upsilon', 'tex')
 
111
        call IMAP(g:Tex_Leader.'v', '\varsigma', 'tex')
 
112
        call IMAP(g:Tex_Leader.'w', '\omega', 'tex')
 
113
        call IMAP(g:Tex_Leader.'w', '\wedge', 'tex')  " AUCTEX style
 
114
        call IMAP(g:Tex_Leader.'x', '\xi', 'tex')
 
115
        call IMAP(g:Tex_Leader.'y', '\psi', 'tex')
 
116
        call IMAP(g:Tex_Leader.'z', '\zeta', 'tex')
 
117
        " not all capital greek letters exist in LaTeX!
 
118
        " reference: http://www.giss.nasa.gov/latex/ltx-405.html
 
119
        call IMAP(g:Tex_Leader.'D', '\Delta', 'tex')
 
120
        call IMAP(g:Tex_Leader.'F', '\Phi', 'tex')
 
121
        call IMAP(g:Tex_Leader.'G', '\Gamma', 'tex')
 
122
        call IMAP(g:Tex_Leader.'Q', '\Theta', 'tex')
 
123
        call IMAP(g:Tex_Leader.'L', '\Lambda', 'tex')
 
124
        call IMAP(g:Tex_Leader.'X', '\Xi', 'tex')
 
125
        call IMAP(g:Tex_Leader.'Y', '\Psi', 'tex')
 
126
        call IMAP(g:Tex_Leader.'S', '\Sigma', 'tex')
 
127
        call IMAP(g:Tex_Leader.'U', '\Upsilon', 'tex')
 
128
        call IMAP(g:Tex_Leader.'W', '\Omega', 'tex')
 
129
        " }}}
 
130
        " ProtectLetters: sets up indentity maps for things like ``a {{{
 
131
        " " Description: If we simply do
 
132
        "               call IMAP('`a', '\alpha', 'tex')
 
133
        " then we will never be able to type 'a' after a tex-quotation. Since
 
134
        " IMAP() always uses the longest map ending in the letter, this problem
 
135
        " can be avoided by creating a fake map for ``a -> ``a.
 
136
        " This function sets up fake maps of the following forms:
 
137
        "       ``[aA]  -> ``[aA]    (for writing in quotations)
 
138
        "       \`[aA]  -> \`[aA]    (for writing diacritics)
 
139
        "       "`[aA]  -> "`[aA]    (for writing german quotations)
 
140
        " It does this for all printable lower ascii characters just to make sure
 
141
        " we dont let anything slip by.
 
142
        function! s:ProtectLetters(first, last)
 
143
                let i = a:first
 
144
                while i <= a:last
 
145
                        if nr2char(i) =~ '[[:print:]]'
 
146
                                call IMAP('``'.nr2char(i), '``'.nr2char(i), 'tex')
 
147
                                call IMAP('\`'.nr2char(i), '\`'.nr2char(i), 'tex')
 
148
                                call IMAP('"`'.nr2char(i), '"`'.nr2char(i), 'tex')
 
149
                        endif
 
150
                        let i = i + 1
 
151
                endwhile
 
152
        endfunction 
 
153
        call s:ProtectLetters(32, 127)
 
154
        " }}}
 
155
        " vmaps: enclose selected region in brackets, environments {{{ 
 
156
        " The action changes depending on whether the selection is character-wise
 
157
        " or line wise. for example, selecting linewise and pressing \v will
 
158
        " result in the region being enclosed in \begin{verbatim}, \end{verbatim},
 
159
        " whereas in characterise visual mode, the thingie is enclosed in \verb|
 
160
        " and |.
 
161
        exec 'vnoremap <silent> '.g:Tex_Leader."( \<C-\\>\<C-N>:call VEnclose('\\left( ', ' \\right)', '\\left(', '\\right)')\<CR>"
 
162
        exec 'vnoremap <silent> '.g:Tex_Leader."[ \<C-\\>\<C-N>:call VEnclose('\\left[ ', ' \\right]', '\\left[', '\\right]')\<CR>"
 
163
        exec 'vnoremap <silent> '.g:Tex_Leader."{ \<C-\\>\<C-N>:call VEnclose('\\left\\{ ', ' \\right\\}', '\\left\\{', '\\right\\}')\<CR>"
 
164
        exec 'vnoremap <silent> '.g:Tex_Leader."$ \<C-\\>\<C-N>:call VEnclose('$', '$', '\\[', '\\]')\<CR>"
 
165
        " }}}
 
166
end
 
167
 
 
168
" }}}
 
169
 
 
170
" ==============================================================================
 
171
" Helper functions for debugging
 
172
" ============================================================================== 
 
173
" Tex_Debug: appends the argument into s:debugString {{{
 
174
" Description: 
 
175
 
176
" Do not want a memory leak! Set this to zero so that latex-suite always
 
177
" starts out in a non-debugging mode.
 
178
if !exists('g:Tex_Debug')
 
179
        let g:Tex_Debug = 0
 
180
endif
 
181
function! Tex_Debug(str, ...)
 
182
        if !g:Tex_Debug
 
183
                return
 
184
        endif
 
185
        if a:0 > 0
 
186
                let pattern = a:1
 
187
        else
 
188
                let pattern = ''
 
189
        endif
 
190
        if !exists('s:debugString_'.pattern)
 
191
                let s:debugString_{pattern} = ''
 
192
        endif
 
193
        let s:debugString_{pattern} = s:debugString_{pattern}.a:str."\n"
 
194
 
 
195
        let s:debugString_ = (exists('s:debugString_') ? s:debugString_ : '')
 
196
                \ . pattern.' : '.a:str."\n"
 
197
 
 
198
        if Tex_GetVarValue('Tex_DebugLog') != ''
 
199
                exec 'redir! >> '.Tex_GetVarValue('Tex_DebugLog')
 
200
                silent! echo pattern.' : '.a:str
 
201
                redir END
 
202
        endif
 
203
endfunction " }}}
 
204
" Tex_PrintDebug: prings s:debugString {{{
 
205
" Description: 
 
206
 
207
function! Tex_PrintDebug(...)
 
208
        if a:0 > 0
 
209
                let pattern = a:1
 
210
        else
 
211
                let pattern = ''
 
212
        endif
 
213
        if exists('s:debugString_'.pattern)
 
214
                echo s:debugString_{pattern}
 
215
        endif
 
216
endfunction " }}}
 
217
" Tex_ClearDebug: clears the s:debugString string {{{
 
218
" Description: 
 
219
 
220
function! Tex_ClearDebug(...)
 
221
        if a:0 > 0
 
222
                let pattern = a:1
 
223
        else
 
224
                let pattern = ''
 
225
        endif
 
226
        if exists('s:debugString_'.pattern)
 
227
                let s:debugString_{pattern} = ''
 
228
        endif
 
229
endfunction " }}}
 
230
" Tex_ShowVariableValue: debugging help {{{
 
231
" provides a way to examine script local variables from outside the script.
 
232
" very handy for debugging.
 
233
function! Tex_ShowVariableValue(...)
 
234
        let i = 1
 
235
        while i <= a:0
 
236
                exe 'let arg = a:'.i
 
237
                if exists('s:'.arg) ||
 
238
                \  exists('*s:'.arg)
 
239
                        exe 'let val = s:'.arg
 
240
                        echomsg 's:'.arg.' = '.val
 
241
                end
 
242
                let i = i + 1
 
243
        endwhile
 
244
endfunction
 
245
 
 
246
" }}}
 
247
 
 
248
" ==============================================================================
 
249
" Helper functions for grepping
 
250
" ============================================================================== 
 
251
" Tex_Grep: shorthand for :grep or :vimgrep {{{
 
252
function! Tex_Grep(string, where)
 
253
        if v:version >= 700
 
254
                exec 'silent! vimgrep! /'.a:string.'/ '.a:where
 
255
        else
 
256
                exec 'silent! grep! '.Tex_EscapeForGrep(a:string).' '.a:where
 
257
        endif
 
258
endfunction
 
259
 
 
260
" }}}
 
261
" Tex_Grepadd: shorthand for :grepadd or :vimgrepadd {{{
 
262
function! Tex_Grepadd(string, where)
 
263
        if v:version >= 700
 
264
                exec 'silent! vimgrepadd! /'.a:string.'/ '.a:where
 
265
        else
 
266
                exec "silent! grepadd! ".Tex_EscapeForGrep(a:string).' '.a:where
 
267
        endif
 
268
endfunction
 
269
 
 
270
" }}}
 
271
" Tex_EscapeForGrep: escapes back-slashes and doublequotes the correct number of times {{{
 
272
" Description: This command escapes the backslash and double quotes in a
 
273
"       search pattern the correct number of times so it can be used in the ``:grep``
 
274
"       command. This command is meant to be used as::
 
275
"
 
276
"               exec "silent! grep ".Tex_EscapeForGrep(pattern)." file"
 
277
"
 
278
"       The input argument to this function should be the string which you want
 
279
"       the external command to finally see. For example, to search for a string
 
280
"       ``'\bibitem'``, the grep command needs to be passed a string like
 
281
"       ``'\\bibitem'``.  Examples::
 
282
"
 
283
"               Tex_EscapeForGrep('\\bibitem')          " correct
 
284
"               Tex_EscapeForGrep('\bibitem')                   " wrong
 
285
"               Tex_EscapeForGrep("\\bibitem")                  " wrong
 
286
"               Tex_EscapeForGrep('\<word\>')                   " correct
 
287
"
 
288
function! Tex_EscapeForGrep(string)
 
289
        let retVal = a:string
 
290
 
 
291
        " The shell halves the backslashes.
 
292
        if &shell =~ 'sh'
 
293
                let retVal = escape(retVal, "\\")
 
294
 
 
295
                " If shellxquote is set, then the backslashes are halved yet again.
 
296
                if &shellxquote == '"'
 
297
                        let retVal = escape(retVal, "\"\\")
 
298
                endif
 
299
 
 
300
        endif
 
301
        " escape special characters which bash/cmd.exe might interpret
 
302
        let retVal = escape(retVal, "<>")
 
303
 
 
304
        return retVal
 
305
endfunction " }}}
 
306
 
 
307
" ==============================================================================
 
308
" Uncategorized helper functions
 
309
" ============================================================================== 
 
310
" Tex_Strntok: extract the n^th token from a list {{{
 
311
" example: Strntok('1,23,3', ',', 2) = 23
 
312
fun! Tex_Strntok(s, tok, n)
 
313
        return matchstr( a:s.a:tok[0], '\v(\zs([^'.a:tok.']*)\ze['.a:tok.']){'.a:n.'}')
 
314
endfun
 
315
 
 
316
" }}}
 
317
" Tex_CreatePrompt: creates a prompt string {{{
 
318
" Description: 
 
319
" Arguments:
 
320
"     promptList: This is a string of the form:
 
321
"         'item1,item2,item3,item4'
 
322
"     cols: the number of columns in the resultant prompt
 
323
"     sep: the list seperator token
 
324
"
 
325
" Example:
 
326
" Tex_CreatePrompt('item1,item2,item3,item4', 2, ',')
 
327
" returns
 
328
" "(1) item1\t(2)item2\n(3)item3\t(4)item4"
 
329
"
 
330
" This string can be used in the input() function.
 
331
function! Tex_CreatePrompt(promptList, cols, sep)
 
332
 
 
333
        let g:listSep = a:sep
 
334
        let num_common = GetListCount(a:promptList)
 
335
 
 
336
        let i = 1
 
337
        let promptStr = ""
 
338
 
 
339
        while i <= num_common
 
340
 
 
341
                let j = 0
 
342
                while j < a:cols && i + j <= num_common
 
343
                        let com = Tex_Strntok(a:promptList, a:sep, i+j)
 
344
                        let promptStr = promptStr.'('.(i+j).') '. 
 
345
                                                \ com."\t".( strlen(com) < 4 ? "\t" : '' )
 
346
 
 
347
                        let j = j + 1
 
348
                endwhile
 
349
 
 
350
                let promptStr = promptStr."\n"
 
351
 
 
352
                let i = i + a:cols
 
353
        endwhile
 
354
        return promptStr
 
355
endfunction 
 
356
 
 
357
" }}}
 
358
" Tex_CleanSearchHistory: removes last search item from search history {{{
 
359
" Description: This function needs to be globally visible because its
 
360
"              called from outside the script during expansion.
 
361
function! Tex_CleanSearchHistory()
 
362
  call histdel("/", -1)
 
363
  let @/ = histget("/", -1)
 
364
endfunction
 
365
nmap <silent> <script> <plug>cleanHistory :call Tex_CleanSearchHistory()<CR>
 
366
 
 
367
" }}}
 
368
" Tex_GetVarValue: gets the value of the variable {{{
 
369
" Description: 
 
370
"       See if a window-local, buffer-local or global variable with the given name
 
371
"       exists and if so, returns the corresponding value. If none exist, return
 
372
"       an empty string.
 
373
function! Tex_GetVarValue(varname, ...)
 
374
        if exists('w:'.a:varname)
 
375
                return w:{a:varname}
 
376
        elseif exists('b:'.a:varname)
 
377
                return b:{a:varname}
 
378
        elseif exists('g:'.a:varname)
 
379
                return g:{a:varname}
 
380
        elseif a:0 > 0
 
381
                return a:1
 
382
        else
 
383
                return ''
 
384
        endif
 
385
endfunction " }}}
 
386
" Tex_GetMainFileName: gets the name of the main file being compiled. {{{
 
387
" Description:  returns the full path name of the main file.
 
388
"               This function checks for the existence of a .latexmain file
 
389
"               which might point to the location of a "main" latex file.
 
390
"               If .latexmain exists, then return the full path name of the
 
391
"               file being pointed to by it.
 
392
"
 
393
"               Otherwise, return the full path name of the current buffer.
 
394
"
 
395
"               You can supply an optional "modifier" argument to the
 
396
"               function, which will optionally modify the file name before
 
397
"               returning.
 
398
"               NOTE: From version 1.6 onwards, this function always trims
 
399
"               away the .latexmain part of the file name before applying the
 
400
"               modifier argument.
 
401
function! Tex_GetMainFileName(...)
 
402
        if a:0 > 0
 
403
                let modifier = a:1
 
404
        else
 
405
                let modifier = ':p'
 
406
        endif
 
407
 
 
408
        " If the user wants to use his own way to specify the main file name, then
 
409
        " use it straight away.
 
410
        if Tex_GetVarValue('Tex_MainFileExpression') != ''
 
411
                exec 'let retval = '.Tex_GetVarValue('Tex_MainFileExpression')
 
412
                return retval
 
413
        endif
 
414
 
 
415
        let curd = getcwd()
 
416
 
 
417
        let dirmodifier = '%:p:h'
 
418
        let dirLast = expand(dirmodifier)
 
419
        call Tex_CD(dirLast)
 
420
 
 
421
        " move up the directory tree until we find a .latexmain file.
 
422
        " TODO: Should we be doing this recursion by default, or should there be a
 
423
        "       setting?
 
424
        while glob('*.latexmain') == ''
 
425
                let dirmodifier = dirmodifier.':h'
 
426
                " break from the loop if we cannot go up any further.
 
427
                if expand(dirmodifier) == dirLast
 
428
                        break
 
429
                endif
 
430
                let dirLast = expand(dirmodifier)
 
431
                call Tex_CD(dirLast)
 
432
        endwhile
 
433
 
 
434
        let lheadfile = glob('*.latexmain')
 
435
        if lheadfile != ''
 
436
                " Remove the trailing .latexmain part of the filename... We never want
 
437
                " that.
 
438
                let lheadfile = fnamemodify(substitute(lheadfile, '\.latexmain$', '', ''), modifier)
 
439
        else
 
440
                " If we cannot find any main file, just modify the filename of the
 
441
                " current buffer.
 
442
                let lheadfile = expand('%'.modifier)
 
443
        endif
 
444
 
 
445
        call Tex_CD(curd)
 
446
 
 
447
        " NOTE: The caller of this function needs to escape spaces in the
 
448
        "       file name as appropriate. The reason its not done here is that
 
449
        "       escaping spaces is not safe if this file is to be used as part of
 
450
        "       an external command on certain platforms.
 
451
        return lheadfile
 
452
endfunction 
 
453
 
 
454
" }}}
 
455
" Tex_ChooseFromPrompt: process a user input to a prompt string {{{
 
456
" " Description: 
 
457
function! Tex_ChooseFromPrompt(dialog, list, sep)
 
458
        let g:Tex_ASDF = a:dialog
 
459
        let inp = input(a:dialog)
 
460
        if inp =~ '\d\+'
 
461
                return Tex_Strntok(a:list, a:sep, inp)
 
462
        else
 
463
                return inp
 
464
        endif
 
465
endfunction " }}}
 
466
" Tex_ChooseFile: produces a file list and prompts for choice {{{
 
467
" Description: 
 
468
function! Tex_ChooseFile(dialog)
 
469
        let files = glob('*')
 
470
        if files == ''
 
471
                return ''
 
472
        endif
 
473
        let s:incnum = 0
 
474
        echo a:dialog
 
475
        let filenames = substitute(files, "\\v(^|\n)", "\\=submatch(0).Tex_IncrementNumber(1).' : '", 'g')
 
476
        echo filenames
 
477
        let choice = input('Enter Choice : ')
 
478
        let g:choice = choice
 
479
        if choice == ''
 
480
                return ''
 
481
        endif
 
482
        if choice =~ '^\s*\d\+\s*$'
 
483
                let retval = Tex_Strntok(files, "\n", choice)
 
484
        else
 
485
                let filescomma = substitute(files, "\n", ",", "g")
 
486
                let retval = GetListMatchItem(filescomma, choice)
 
487
        endif
 
488
        if retval == ''
 
489
                return ''
 
490
        endif
 
491
        return retval
 
492
endfunction 
 
493
 
 
494
" }}}
 
495
" Tex_IncrementNumber: returns an incremented number each time {{{
 
496
" Description: 
 
497
let s:incnum = 0
 
498
function! Tex_IncrementNumber(increm)
 
499
        let s:incnum = s:incnum + a:increm
 
500
        return s:incnum
 
501
endfunction 
 
502
 
 
503
" }}}
 
504
" Tex_ResetIncrementNumber: increments s:incnum to zero {{{
 
505
" Description: 
 
506
function! Tex_ResetIncrementNumber(val)
 
507
        let s:incnum = a:val
 
508
endfunction " }}}
 
509
" Tex_FindInRtp: check if file exists in &rtp {{{
 
510
" Description:  Checks if file exists in globpath(&rtp, ...) and cuts off the
 
511
"                               rest of returned names. This guarantees that sourced file is
 
512
"                               from $HOME.
 
513
"               If an optional argument is given, it specifies how to expand
 
514
"               each filename found. For example, '%:p' will return a list of
 
515
"               the complete paths to the files. By default returns trailing
 
516
"               path-names without extenions.
 
517
"               NOTE: This function is very slow when a large number of
 
518
"                     matches are found because of a while loop which modifies
 
519
"                     each filename found. Some speedup was acheived by using
 
520
"                     a tokenizer approach rather than using Tex_Strntok which
 
521
"                     would have been more obvious.
 
522
function! Tex_FindInRtp(filename, directory, ...)
 
523
        " how to expand each filename. ':p:t:r' modifies each filename to its
 
524
        " trailing part without extension.
 
525
        let expand = (a:0 > 0 ? a:1 : ':p:t:r')
 
526
        " The pattern used... An empty filename should be regarded as '*'
 
527
        let pattern = (a:filename != '' ? a:filename : '*')
 
528
 
 
529
        let filelist = globpath(&rtp, 'ftplugin/latex-suite/'.a:directory.'/'.pattern)."\n"
 
530
 
 
531
        if filelist == "\n"
 
532
                return ''
 
533
        endif
 
534
 
 
535
        if a:filename != ''
 
536
                return fnamemodify(Tex_Strntok(filelist, "\n", 1), expand)
 
537
        endif
 
538
 
 
539
        " Now cycle through the files modifying each filename in the desired
 
540
        " manner.
 
541
        let retfilelist = ''
 
542
        let i = 1
 
543
        while 1
 
544
                " Extract the portion till the next newline. Then shorten the filelist
 
545
                " by removing till the newline.
 
546
                let nextnewline = stridx(filelist, "\n")
 
547
                if nextnewline == -1
 
548
                        break
 
549
                endif
 
550
                let filename = strpart(filelist, 0, nextnewline)
 
551
                let filelist = strpart(filelist, nextnewline+1)
 
552
 
 
553
                " The actual modification.
 
554
                if fnamemodify(filename, expand) != ''
 
555
                        let retfilelist = retfilelist.fnamemodify(filename, expand).","
 
556
                endif
 
557
                let i = i + 1
 
558
        endwhile
 
559
 
 
560
        return substitute(retfilelist, ',$', '', '')
 
561
endfunction
 
562
 
 
563
" }}}
 
564
" Tex_GetErrorList: returns vim's clist {{{
 
565
" Description: returns the contents of the error list available via the :clist
 
566
"              command.
 
567
function! Tex_GetErrorList()
 
568
        let _a = @a
 
569
        redir @a | silent! clist | redir END
 
570
        let errlist = @a
 
571
        let @a = _a
 
572
 
 
573
        if errlist =~ 'E42: '
 
574
                let errlist = ''
 
575
        endif
 
576
 
 
577
        return errlist
 
578
endfunction " }}}
 
579
" Tex_GetTempName: get the name of a temporary file in specified directory {{{
 
580
" Description: Unlike vim's native tempname(), this function returns the name
 
581
"              of a temporary file in the directory specified. This enables
 
582
"              us to create temporary files in a specified directory.
 
583
function! Tex_GetTempName(dirname)
 
584
        let prefix = 'latexSuiteTemp'
 
585
        let slash = (a:dirname =~ '\\\|/$' ? '' : '/')
 
586
        let i = 0
 
587
        while filereadable(a:dirname.slash.prefix.i.'.tex') && i < 1000
 
588
                let i = i + 1
 
589
        endwhile
 
590
        if filereadable(a:dirname.slash.prefix.i.'.tex')
 
591
                echoerr "Temporary file could not be created in ".a:dirname
 
592
                return ''
 
593
        endif
 
594
        return expand(a:dirname.slash.prefix.i.'.tex', ':p')
 
595
endfunction
 
596
" }}}
 
597
" Tex_MakeMap: creates a mapping from lhs to rhs if rhs is not already mapped {{{
 
598
" Description:  
 
599
function! Tex_MakeMap(lhs, rhs, mode, extraargs)
 
600
        if !hasmapto(a:rhs, a:mode)
 
601
                exec a:mode.'map '.a:extraargs.' '.a:lhs.' '.a:rhs
 
602
        endif
 
603
endfunction " }}}
 
604
" Tex_CD: cds to given directory escaping spaces if necessary {{{
 
605
" " Description: 
 
606
function! Tex_CD(dirname)
 
607
        exec 'cd '.Tex_EscapeSpaces(a:dirname)
 
608
endfunction " }}}
 
609
" Tex_EscapeSpaces: escapes unescaped spaces from a path name {{{
 
610
" Description:
 
611
function! Tex_EscapeSpaces(path)
 
612
        return substitute(a:path, '[^\\]\(\\\\\)*\zs ', '\\ ', 'g')
 
613
endfunction " }}}
 
614
" Tex_FindFile: finds a file in the vim's 'path' {{{
 
615
" Description: finds a file in vim's 'path'
 
616
function! Tex_FindFile(fname, path, suffixesadd)
 
617
        if exists('*findfile')
 
618
                let _suffixesadd = &suffixesadd
 
619
                let &suffixesadd = a:suffixesadd
 
620
                let retval = findfile(a:fname, a:path)
 
621
                let &suffixesadd = _suffixesadd
 
622
        else
 
623
                " split a new window so we do not screw with the current buffer. We
 
624
                " want to use the same filename each time so that multiple scratch
 
625
                " buffers are not created.
 
626
                let retval = ''
 
627
                silent! split __HOPEFULLY_THIS_FILE_DOES_NOT_EXIST__
 
628
                let _suffixesadd = &suffixesadd
 
629
                let _path = &path
 
630
                let &suffixesadd = a:suffixesadd
 
631
                let &path = a:path
 
632
                exec 'silent! find '.a:fname
 
633
                if bufname('%') != '__HOPEFULLY_THIS_FILE_DOES_NOT_EXIST__'
 
634
                        let retval = expand('%:p')
 
635
                end
 
636
                silent! bdelete!
 
637
                let &suffixesadd = _suffixesadd
 
638
                let &path = _path
 
639
        endif
 
640
        return retval
 
641
endfunction " }}}
 
642
 
 
643
" ==============================================================================
 
644
" Smart key-mappings
 
645
" ============================================================================== 
 
646
" TexQuotes: inserts `` or '' instead of " {{{
 
647
if g:Tex_SmartKeyQuote
 
648
 
 
649
        " TexQuotes: inserts `` or '' instead of "
 
650
        " Taken from texmacro.vim by Benji Fisher <benji@e-math.AMS.org>
 
651
        " TODO:  Deal with nested quotes.
 
652
        " The :imap that calls this function should insert a ", move the cursor to
 
653
        " the left of that character, then call this with <C-R>= .
 
654
        function! s:TexQuotes()
 
655
                let l = line(".")
 
656
                let c = col(".")
 
657
                let restore_cursor = l . "G" . virtcol(".") . "|"
 
658
                normal! H
 
659
                let restore_cursor = "normal!" . line(".") . "Gzt" . restore_cursor
 
660
                execute restore_cursor
 
661
                " In math mode, or when preceded by a \, just move the cursor past the
 
662
                " already-inserted " character.
 
663
                if synIDattr(synID(l, c, 1), "name") =~ "^texMath"
 
664
                        \ || (c > 1 && getline(l)[c-2] == '\')
 
665
                        return "\<Right>"
 
666
                endif
 
667
                " Find the appropriate open-quote and close-quote strings.
 
668
                if exists("b:Tex_SmartQuoteOpen")
 
669
                        let open = b:Tex_SmartQuoteOpen
 
670
                elseif exists("g:Tex_SmartQuoteOpen")
 
671
                        let open = g:Tex_SmartQuoteOpen
 
672
                else
 
673
                        let open = "``"
 
674
                endif
 
675
                if exists("b:Tex_SmartQuoteClose")
 
676
                        let close = b:Tex_SmartQuoteClose
 
677
                elseif exists("g:Tex_SmartQuoteClose")
 
678
                        let close = g:Tex_SmartQuoteClose
 
679
                else
 
680
                        let close = "''"
 
681
                endif
 
682
                let boundary = '\|'
 
683
                " This code seems to be obsolete, since this script variable is never
 
684
                " set. The idea is that some languages use ",," as an open- or
 
685
                " close-quote string, and we want to avoid confusing ordinary ","
 
686
                " with a quote boundary.
 
687
                if exists("s:TeX_strictquote")
 
688
                        if( s:TeX_strictquote == "open" || s:TeX_strictquote == "both" )
 
689
                                let boundary = '\<' . boundary
 
690
                        endif
 
691
                        if( s:TeX_strictquote == "close" || s:TeX_strictquote == "both" )
 
692
                                let boundary = boundary . '\>'
 
693
                        endif
 
694
                endif
 
695
 
 
696
                " Eventually return q; set it to the default value now.
 
697
                let q = open
 
698
                let pattern = 
 
699
                        \ escape(open, '\~') .
 
700
                        \ boundary .
 
701
                        \ escape(close, '\~') .
 
702
                        \ '\|^$\|"'
 
703
 
 
704
                while 1 " Look for preceding quote (open or close), ignoring
 
705
                        " math mode and '\"' .
 
706
                        call search(pattern, "bw")
 
707
                        if synIDattr(synID(line("."), col("."), 1), "name") !~ "^texMath"
 
708
                                \ && strpart(getline('.'), col('.')-2, 2) != '\"'
 
709
                                break
 
710
                        endif
 
711
                endwhile
 
712
                
 
713
                " Now, test whether we actually found a _preceding_ quote; if so, is it
 
714
                " an open quote?
 
715
                if ( line(".") < l || line(".") == l && col(".") < c )
 
716
                        if strpart(getline("."), col(".")-1) =~ '\V\^' . escape(open, '\')
 
717
                                if line(".") == l && col(".") + strlen(open) == c
 
718
                                        " Insert "<++>''<++>" instead of just "''".
 
719
                                        let q = IMAP_PutTextWithMovement("<++>".close."<++>")
 
720
                                else
 
721
                                        let q = close
 
722
                                endif
 
723
                        endif
 
724
                endif
 
725
 
 
726
                " Return to line l, column c:
 
727
                execute restore_cursor
 
728
                " Start with <Del> to remove the " put in by the :imap .
 
729
                return "\<Del>" . q
 
730
 
 
731
        endfunction
 
732
 
 
733
endif
 
734
" }}}
 
735
" SmartBS: smart backspacing {{{
 
736
if g:Tex_SmartKeyBS 
 
737
 
 
738
        " SmartBS: smart backspacing
 
739
        " SmartBS lets you treat diacritic characters (those \'{a} thingies) as a
 
740
        " single character. This is useful for example in the following situation:
 
741
        "
 
742
        " \v{s}\v{t}astn\'{y}    ('happy' in Slovak language :-) )
 
743
        " If you will delete this normally (without using smartBS() function), you
 
744
        " must press <BS> about 19x. With function smartBS() you must press <BS> only
 
745
        " 7x. Strings like "\v{s}", "\'{y}" are considered like one character and are
 
746
        " deleted with one <BS>.
 
747
        let s:smartBS_pat = Tex_GetVarValue('Tex_SmartBSPattern')
 
748
 
 
749
        fun! s:SmartBS_pat()
 
750
                return s:smartBS_pat
 
751
        endfun
 
752
 
 
753
        " This function comes from Benji Fisher <benji@e-math.AMS.org>
 
754
        " http://vim.sourceforge.net/scripts/download.php?src_id=409 
 
755
        " (modified/patched by Lubomir Host 'rajo' <host8 AT keplerDOTfmphDOTuniba.sk>)
 
756
        function! s:SmartBS(pat)
 
757
                let init = strpart(getline("."), 0, col(".")-1)
 
758
                let matchtxt = matchstr(init, a:pat)
 
759
                if matchtxt != ''
 
760
                        let bstxt = substitute(matchtxt, '.', "\<bs>", 'g')
 
761
                        return bstxt
 
762
                else
 
763
                        return "\<bs>"
 
764
                endif
 
765
        endfun
 
766
        
 
767
endif " }}}
 
768
" SmartDots: inserts \cdots instead of ... in math mode otherwise \ldots {{{
 
769
" if amsmath package is detected then just use \dots and let amsmath take care
 
770
" of it.
 
771
if g:Tex_SmartKeyDot
 
772
 
 
773
        function! <SID>SmartDots()
 
774
                if strpart(getline('.'), col('.')-3, 2) == '..' && 
 
775
                        \ g:Tex_package_detected =~ '\<amsmath\>'
 
776
                        return "\<bs>\<bs>\\dots"
 
777
                elseif synIDattr(synID(line('.'),col('.')-1,0),"name") =~ '^texMath'
 
778
                        \&& strpart(getline('.'), col('.')-3, 2) == '..' 
 
779
                        return "\<bs>\<bs>\\cdots"
 
780
                elseif strpart(getline('.'), col('.')-3, 2) == '..' 
 
781
                        return "\<bs>\<bs>\\ldots"
 
782
                else
 
783
                        return '.'
 
784
                endif
 
785
        endfunction 
 
786
 
 
787
endif
 
788
" }}}
 
789
 
 
790
" source texproject.vim before other files
 
791
exe 'source '.s:path.'/texproject.vim'
 
792
 
 
793
" source all the relevant files.
 
794
exe 'source '.s:path.'/texmenuconf.vim'
 
795
exe 'source '.s:path.'/envmacros.vim'
 
796
exe 'source '.s:path.'/elementmacros.vim'
 
797
 
 
798
" source utf-8 or plain math menus
 
799
if exists("g:Tex_UseUtfMenus") && g:Tex_UseUtfMenus != 0 && has("gui_running")
 
800
        exe 'source '.s:path.'/mathmacros-utf.vim'
 
801
else
 
802
        exe 'source '.s:path.'/mathmacros.vim'
 
803
endif
 
804
 
 
805
exe 'source '.s:path.'/multicompile.vim'
 
806
exe 'source '.s:path.'/compiler.vim'
 
807
exe 'source '.s:path.'/folding.vim'
 
808
exe 'source '.s:path.'/templates.vim'
 
809
exe 'source '.s:path.'/custommacros.vim'
 
810
exe 'source '.s:path.'/bibtex.vim'
 
811
 
 
812
" source advanced math functions
 
813
if g:Tex_AdvancedMath == 1
 
814
        exe 'source '.s:path.'/brackets.vim'
 
815
        exe 'source '.s:path.'/smartspace.vim'
 
816
endif
 
817
 
 
818
if g:Tex_Diacritics != 0
 
819
        exe 'source '.s:path.'/diacritics.vim'
 
820
endif
 
821
 
 
822
exe 'source '.s:path.'/texviewer.vim'
 
823
exe 'source '.s:path.'/version.vim'
 
824
 
 
825
" ==============================================================================
 
826
" Finally set up the folding, options, mappings and quit.
 
827
" ============================================================================== 
 
828
" SetTeXOptions: sets options/mappings for this file. {{{
 
829
function! <SID>SetTeXOptions()
 
830
        " Avoid reinclusion.
 
831
        if exists('b:doneSetTeXOptions')
 
832
                return
 
833
        endif
 
834
        let b:doneSetTeXOptions = 1
 
835
 
 
836
        exe 'setlocal dict^='.s:path.'/dictionaries/dictionary'
 
837
 
 
838
        call Tex_Debug('SetTeXOptions: sourcing maps', 'main')
 
839
        " smart functions
 
840
        if g:Tex_SmartKeyQuote 
 
841
                inoremap <buffer> <silent> " "<Left><C-R>=<SID>TexQuotes()<CR>
 
842
        endif
 
843
        if g:Tex_SmartKeyBS
 
844
                inoremap <buffer> <silent> <BS> <C-R>=<SID>SmartBS(<SID>SmartBS_pat())<CR>
 
845
        endif
 
846
        if g:Tex_SmartKeyDot
 
847
                inoremap <buffer> <silent> . <C-R>=<SID>SmartDots()<CR>
 
848
        endif
 
849
 
 
850
        " This line seems to be necessary to source our compiler/tex.vim file.
 
851
        " The docs are unclear why this needs to be done even though this file is
 
852
        " the first compiler plugin in 'runtimepath'.
 
853
        runtime compiler/tex.vim
 
854
 
 
855
endfunction
 
856
 
 
857
augroup LatexSuite
 
858
        au LatexSuite User LatexSuiteFileType 
 
859
                \ call Tex_Debug('main.vim: Catching LatexSuiteFileType event', 'main') | 
 
860
                \ call <SID>SetTeXOptions()
 
861
augroup END
 
862
 
 
863
" }}}
 
864
 
 
865
" ==============================================================================
 
866
" Settings for taglist.vim plugin
 
867
" ============================================================================== 
 
868
" Sets Tlist_Ctags_Cmd for taglist.vim and regexps for ctags {{{
 
869
if exists("g:Tex_TaglistSupport") && g:Tex_TaglistSupport == 1 
 
870
        if !exists("g:tlist_tex_settings") 
 
871
                let g:tlist_tex_settings = 'tex;s:section;c:chapter;l:label;r:ref'
 
872
        endif
 
873
 
 
874
        if exists("Tlist_Ctags_Cmd")
 
875
                let s:tex_ctags = Tlist_Ctags_Cmd
 
876
        else
 
877
                let s:tex_ctags = 'ctags' " Configurable in texrc?
 
878
        endif
 
879
 
 
880
        if exists("g:Tex_InternalTagsDefinitions") && g:Tex_InternalTagsDefinitions == 1
 
881
                let Tlist_Ctags_Cmd = s:tex_ctags ." --langdef=tex --langmap=tex:.tex.ltx.latex"
 
882
                \.' --regex-tex="/\\\\begin{abstract}/Abstract/s,abstract/"'
 
883
                \.' --regex-tex="/\\\\part[ \t]*\*?\{[ \t]*([^}]*)\}/\1/s,part/"'
 
884
                \.' --regex-tex="/\\\\chapter[ \t]*\*?\{[ \t]*([^}]*)\}/\1/s,chapter/"'
 
885
                \.' --regex-tex="/\\\\section[ \t]*\*?\{[ \t]*([^}]*)\}/\1/s,section/"'
 
886
                \.' --regex-tex="/\\\\subsection[ \t]*\*?\{[ \t]*([^}]*)\}/+ \1/s,subsection/"'
 
887
                \.' --regex-tex="/\\\\subsubsection[ \t]*\*?\{[ \t]*([^}]*)\}/+  \1/s,subsubsection/"'
 
888
                \.' --regex-tex="/\\\\paragraph[ \t]*\*?\{[ \t]*([^}]*)\}/+   \1/s,paragraph/"'
 
889
                \.' --regex-tex="/\\\\subparagraph[ \t]*\*?\{[ \t]*([^}]*)\}/+    \1/s,subparagraph/"'
 
890
                \.' --regex-tex="/\\\\begin{thebibliography}/BIBLIOGRAPHY/s,thebibliography/"'
 
891
                \.' --regex-tex="/\\\\tableofcontents/TABLE OF CONTENTS/s,tableofcontents/"'
 
892
                \.' --regex-tex="/\\\\frontmatter/FRONTMATTER/s,frontmatter/"'
 
893
                \.' --regex-tex="/\\\\mainmatter/MAINMATTER/s,mainmatter/"'
 
894
                \.' --regex-tex="/\\\\backmatter/BACKMATTER/s,backmatter/"'
 
895
                \.' --regex-tex="/\\\\appendix/APPENDIX/s,appendix/"'
 
896
                \.' --regex-tex="/\\\\label[ \t]*\*?\{[ \t]*([^}]*)\}/\1/l,label/"'
 
897
                \.' --regex-tex="/\\\\ref[ \t]*\*?\{[ \t]*([^}]*)\}/\1/r,ref/"'
 
898
        endif
 
899
endif
 
900
 
 
901
" }}}
 
902
 
 
903
" commands to completion
 
904
let g:Tex_completion_explorer = ','
 
905
 
 
906
" Mappings defined in package files will overwrite all other
 
907
exe 'source '.s:path.'/packages.vim'
 
908
 
 
909
" ==============================================================================
 
910
" These functions are used to immitate certain operating system type functions
 
911
" (like reading the contents of a file), which are not available in vim. For
 
912
" example, in Vim, its not possible to read the contents of a file without
 
913
" opening a buffer on it, which means that over time, lots of buffers can open
 
914
" up needlessly.
 
915
"
 
916
" If python is available (and allowed), then these functions utilize python
 
917
" library functions without making calls to external programs.
 
918
" ============================================================================== 
 
919
" Tex_GotoTempFile: open a temp file. reuse from next time on {{{
 
920
function! Tex_GotoTempFile()
 
921
        if !exists('s:tempFileName')
 
922
                let s:tempFileName = tempname()
 
923
        endif
 
924
        exec 'silent! split '.s:tempFileName
 
925
endfunction " }}}
 
926
" Tex_IsPresentInFile: finds if a string str, is present in filename {{{
 
927
if has('python') && g:Tex_UsePython
 
928
        function! Tex_IsPresentInFile(regexp, filename)
 
929
                exec 'python isPresentInFile(r"'.a:regexp.'", r"'.a:filename.'")'
 
930
 
 
931
                return retval
 
932
        endfunction
 
933
else
 
934
        function! Tex_IsPresentInFile(regexp, filename)
 
935
                call Tex_GotoTempFile()
 
936
 
 
937
                silent! 1,$ d _
 
938
                let _report = &report
 
939
                let _sc = &sc
 
940
                set report=9999999 nosc
 
941
                exec 'silent! 0r! '.g:Tex_CatCmd.' '.a:filename
 
942
                set nomod
 
943
                let &report = _report
 
944
                let &sc = _sc
 
945
 
 
946
                if search(a:regexp, 'w')
 
947
                        let retval = 1
 
948
                else
 
949
                        let retval = 0
 
950
                endif
 
951
                silent! bd
 
952
                return retval
 
953
        endfunction
 
954
endif " }}}
 
955
" Tex_CatFile: returns the contents of a file in a <NL> seperated string {{{
 
956
if has('*readfile')
 
957
        function! Tex_CatFile(filename)
 
958
                return join(readfile(filename), "\n")
 
959
        endfunction
 
960
elseif has('python') && g:Tex_UsePython
 
961
        function! Tex_CatFile(filename)
 
962
                " catFile assigns a value to retval
 
963
                exec 'python catFile("'.a:filename.'")'
 
964
 
 
965
                return retval
 
966
        endfunction
 
967
else
 
968
        function! Tex_CatFile(filename)
 
969
                if glob(a:filename) == ''
 
970
                        return ''
 
971
                endif
 
972
 
 
973
                call Tex_GotoTempFile()
 
974
 
 
975
                silent! 1,$ d _
 
976
 
 
977
                let _report = &report
 
978
                let _sc = &sc
 
979
                set report=9999999 nosc
 
980
                exec 'silent! 0r! '.g:Tex_CatCmd.' '.a:filename
 
981
 
 
982
                set nomod
 
983
                let _a = @a
 
984
                silent! normal! ggVG"ay
 
985
                let retval = @a
 
986
                let @a = _a
 
987
 
 
988
                silent! bd
 
989
                let &report = _report
 
990
                let &sc = _sc
 
991
                return retval
 
992
        endfunction
 
993
endif
 
994
" }}}
 
995
" Tex_DeleteFile: removes a file if present {{{
 
996
" Description: 
 
997
if has('python') && g:Tex_UsePython
 
998
        function! Tex_DeleteFile(filename)
 
999
                exec 'python deleteFile(r"'.a:filename.'")'
 
1000
                
 
1001
                if exists('retval')
 
1002
                        return retval
 
1003
                endif
 
1004
        endfunction 
 
1005
else
 
1006
        function! Tex_DeleteFile(filename)
 
1007
                if filereadable(a:filename)
 
1008
                        exec '! '.g:Tex_RmCmd.' '.a:filename
 
1009
                endif
 
1010
        endfunction
 
1011
endif
 
1012
" }}}
 
1013
 
 
1014
 
 
1015
let &cpo = s:save_cpo
 
1016
 
 
1017
" Define the functions in python if available.
 
1018
if !has('python') || !g:Tex_UsePython
 
1019
        finish
 
1020
endif
 
1021
 
 
1022
exec 'pyfile '.expand('<sfile>:p:h').'/pytools.py'
 
1023
 
 
1024
" vim:fdm=marker:ff=unix:noet:ts=4:sw=4:nowrap