Commits

Anonymous committed 073327f

latex is no use for me

Comments (0)

Files changed (108)

vim/.vim/ftplugin/bib_latexSuite.vim

-" File: bib_latexSuite.vim
-" Author: Srinath Avadhanula
-" License: Vim Charityware License
-" Description:
-" 	This file sources the bibtex.vim file distributed as part of latex-suite.
-" 	That file sets up 3 maps BBB, BAS, and BBA which are easy wasy to type in
-" 	bibliographic entries.
-"
-" CVS: $Id: bib_latexSuite.vim 997 2006-03-20 09:45:45Z srinathava $
-
-" source main.vim because we need a few functions from it.
-runtime ftplugin/latex-suite/main.vim
-" Disable smart-quotes because we need to enter real quotes in bib files.
-runtime ftplugin/latex-suite/bibtex.vim
-
-" vim:fdm=marker:ff=unix:noet:ts=4:sw=4:nowrap

vim/.vim/ftplugin/latex-suite/bibtex.vim

-"=============================================================================
-" 	       File: bibtex.vim
-"      Function: BibT
-"        Author: Alan G Isaac <aisaac@american.edu>
-"                modified by Srinath Avadhanula for latex-suite.
-"       License: Vim Charityware license.
-"           CVS: $Id: bibtex.vim 997 2006-03-20 09:45:45Z srinathava $
-"=============================================================================
-
-" Fields:
-" Define what field type each letter denotes {{{
-" 
-let s:w_standsfor = 'address'
-let s:a_standsfor = 'author'
-let s:b_standsfor = 'booktitle'
-let s:c_standsfor = 'chapter'
-let s:d_standsfor = 'edition'
-let s:e_standsfor = 'editor'
-let s:h_standsfor = 'howpublished'
-let s:i_standsfor = 'institution'
-let s:k_standsfor = 'isbn'
-let s:j_standsfor = 'journal'
-let s:m_standsfor = 'month'
-let s:n_standsfor = 'number'
-let s:o_standsfor = 'organization'
-let s:p_standsfor = 'pages'
-let s:q_standsfor = 'publisher'
-let s:r_standsfor = 'school'
-let s:s_standsfor = 'series'
-let s:t_standsfor = 'title'
-let s:u_standsfor = 'type'
-let s:v_standsfor = 'volume'
-let s:y_standsfor = 'year'
-let s:z_standsfor = 'note'
-
-" }}}
-" Define the fields required for the various entry types {{{
-" 
-" s:{type}_required defines the required fields
-" s:{type}_optional1 defines common optional fields
-" s:{type}_optional2 defines uncommmon optional fields
-" s:{type}_retval defines the first line of the formatted bib entry.
-"
-let s:key='<+key+>'
-
-let s:{'article'}_required="atjy"
-let s:{'article'}_optional1="vnpm"
-let s:{'article'}_optional2="z" " z is note
-let s:{'article'}_retval = '@ARTICLE{' . s:key . ','."\n"
-
-let s:{'book'}_required="aetqy" " requires author *or* editor
-let s:{'book'}_optional1="wd"
-let s:{'book'}_optional2="vnsmz" " w is address, d is edition
-let s:{'book'}_extras="k" " isbn
-let s:{'book'}_retval = '@BOOK{' . s:key . ','."\n"
-
-let s:{'booklet'}_required="t"
-let s:{'booklet'}_optional1="ahy"
-let s:{'booklet'}_optional2="wmz" " w is address
-let s:{'booklet'}_retval = '@BOOKLET{' . s:key . ','."\n"
-
-let s:{'inbook'}_required="aetcpqy"
-let s:{'inbook'}_optional1="w" " w is address
-let s:{'inbook'}_optional2="vnsudmz" " d is edition
-let s:{'inbook'}_extras="k" " isbn
-let s:{'inbook'}_retval = '@INBOOK{' . s:key . ','."\n"
-
-let s:{'incollection'}_required="atbqy" " b is booktitle
-let s:{'incollection'}_optional1="cpw" " w is address, c is chapter
-let s:{'incollection'}_optional2="evnsudmz" " d is edition
-let s:{'incollection'}_extras="k" " isbn
-let s:{'incollection'}_retval = '@INCOLLECTION{' . s:key . ','."\n"
-
-let s:{'inproceedings'}_required="atby" " b is booktitle
-let s:{'inproceedings'}_optional1="epwoq" " w is address, q is publisher
-let s:{'inproceedings'}_optional2="vnsmz"
-let s:{'inproceedings'}_extras="k" " isbn
-let s:{'inproceedings'}_retval = '@INPROCEEDINGS{' . s:key . ','."\n"
-
-let s:{'conference'}_required="atby" " b is booktitle
-let s:{'conference'}_optional1="epwoq" " w is address, q is publisher
-let s:{'conference'}_optional2="vnsmz"
-let s:{'conference'}_extras="k" " isbn
-let s:{'conference'}_retval = '@CONFERENCE{' . s:key . ','."\n"
-
-let s:{'manual'}_required="t"
-let s:{'manual'}_optional1="ow"
-let s:{'manual'}_optional2="admyz" " w is address
-let s:{'manual'}_retval = '@MANUAL{' . s:key . ','."\n"
-
-let s:{'msthesis'}_required="atry" " r is school
-let s:{'msthesis'}_optional1="w" " w is address
-let s:{'msthesis'}_optional2="umz" " u is type, w is address
-let s:{'msthesis'}_retval = '@MASTERSTHESIS{' . s:key . ','."\n"
-
-let s:{'misc'}_required=""
-let s:{'misc'}_optional1="ath"
-let s:{'misc'}_optional2="myz"
-let s:{'misc'}_retval = '@MISC{' . s:key . ','."\n"
-
-let s:{'phdthesis'}_required="atry" " r is school
-let s:{'phdthesis'}_optional1="w" " w is address
-let s:{'phdthesis'}_optional2="umz" " u is type
-let s:{'phdthesis'}_retval = '@PHDTHESIS{' . s:key . ','."\n"
-
-let s:{'proceedings'}_required="ty"
-let s:{'proceedings'}_optional1="ewo" " w is address
-let s:{'proceedings'}_optional2="vnsmqz" " q is publisher
-let s:{'proceedings'}_retval = '@PROCEEDINGS{' . s:key . ','."\n"
-
-let s:{'techreport'}_required="atiy"
-let s:{'techreport'}_optional1="unw" " u is type, w is address
-let s:{'techreport'}_optional2="mz"
-let s:{'techreport'}_retval = '@TECHREPORT{' . s:key . ','."\n"
-
-let s:{'unpublished'}_required="atz"
-let s:{'unpublished'}_optional1="y"
-let s:{'unpublished'}_optional2="m"
-let s:{'unpublished'}_retval = '@UNPUBLISHED{' . s:key . ','."\n"
-
-" }}}
-
-if exists('s:done')
-	finish
-endif
-let s:done = 1
-
-call IMAP ('BBB', "\<C-r>=BibT('', '', 0)\<CR>", 'bib')
-call IMAP ('BBL', "\<C-r>=BibT('', 'o', 0)\<CR>", 'bib')
-call IMAP ('BBH', "\<C-r>=BibT('', 'O', 0)\<CR>", 'bib')
-call IMAP ('BBX', "\<C-r>=BibT('', 'Ox', 0)\<CR>", 'bib')
-
-" BibT: function to generate a formatted bibtex entry {{{
-" three sample usages:
-"   :call BibT()                    will request type choice
-"   :call BibT("article")           preferred, provides most common fields
-"   :call BibT("article","ox")      more optional fields (o) and extras (x)
-"
-" Input Arguments:
-" type: is one of the types listed above. (this should be a complete name, not
-"       the acronym).
-" options: a string containing 0 or more of the letters 'oOx'
-"          where
-"          o: include a bib entry with first set of options
-"          O: include a bib entry with extended options
-"          x: incude bib entry with extra options
-" prompt: whether the fields are asked to be filled on the command prompt or
-"         whether place-holders are used. when prompt == 1, then comman line
-"         questions are used.
-"
-" Returns:
-" a string containing a formatted bib entry
-function BibT(type, options, prompt)
-	if a:type != ''
-		let choosetype = a:type
-	else
-		let types = 
-			\ 'article'."\n".
-			\ 'booklet'."\n".
-			\ 'book'."\n".
-			\ 'conference'."\n".
-			\ 'inbook'."\n".
-			\ 'incollection'."\n".
-			\ 'inproceedings'."\n".
-			\ 'manual'."\n".
-			\ 'msthesis'."\n".
-			\ 'misc'."\n".
-			\ 'phdthesis'."\n".
-			\ 'proceedings'."\n".
-			\ 'techreport'."\n".
-			\ 'unpublished'
-		let choosetype = Tex_ChooseFromPrompt(
-					\ "Choose the type of bibliographic entry: \n" . 
-					\ Tex_CreatePrompt(types, 3, "\n") .
-					\ "\nEnter number or filename :", 
-					\ types, "\n")
-		if choosetype == ''
-			let choosetype = 'article'
-		endif
-		if types !~ '^\|\n'.choosetype.'$\|\n'
-			echomsg 'Please choose only one of the given types'
-			return
-		endif
-	endif
-	if a:options != ''
-		let options = a:options
-	else
-		let options = ""
-	endif
-
-	let fields = ''
-	let extras=""
-	let retval = ""
-
-	" define fields
-	let fields = s:{choosetype}_required
-	if options =~ 'o' && exists('s:'.choosetype.'_optional1')
-		let fields = fields . s:{choosetype}_optional1
-	endif
-	if options =~ "O" && exists('s:'.choosetype.'_optional2')
-		if options !~ 'o'&& exists('s:'.choosetype.'_optional1') 
-			let fields = fields . s:{choosetype}_optional1
-		endif
-		let fields = fields . s:{choosetype}_optional2
-	endif
-	if options =~ "x" && exists('s:'.choosetype.'_extras')
-		let fields = fields . extras
-	endif
-	if exists('g:Bib_'.choosetype.'_options')
-		let fields = fields . g:Bib_{choosetype}_options
-	endif
-
-	let retval = s:{choosetype}_retval
-	
-	let i = 0
-	while i < strlen(fields)
-		let field = strpart(fields, i, 1)
-
-		if exists('s:'.field.'_standsfor')
-			let field_name = s:{field}_standsfor
-			let retval = retval.field_name." = {<++>},\n"
-		endif
-
-		let i = i + 1
-	endwhile
-	
-	" If the user wants even more fine-tuning...
-	if Tex_GetVarValue('Bib_'.choosetype.'_extrafields') != ''
-
-		let extrafields = Tex_GetVarValue('Bib_'.choosetype.'_extrafields')
-		
-		let i = 1
-		while 1
-			let field_name = Tex_Strntok(extrafields, "\n", i)
-			if field_name == ''
-				break
-			endif
-
-			let retval = retval.field_name." = {<++>},\n"
-
-			let i = i + 1
-		endwhile
-
-	endif
-
-	let retval = retval.'otherinfo = {<++>}'."\n"
-	let retval = retval."}<++>"."\n"
-
-	return IMAP_PutTextWithMovement(retval)
-endfunction
-
-" }}}
-function! s:Input(prompt, ask) " {{{
-	if a:ask == 1
-		let retval = input(a:prompt)
-		if retval == ''
-			return "<++>"
-		endif
-	else
-		return "<++>"
-	endif
-endfunction 
-
-" }}}
-
-" vim:fdm=marker:ff=unix:noet:ts=4:sw=4

vim/.vim/ftplugin/latex-suite/bibtools.py

-# Author: Srinath Avadhanula
-# This file is distributed as part of the vim-latex project
-# http://vim-latex.sf.net
-
-import re
-
-class Bibliography(dict):
-    def __init__(self, txt, macros={}):
-        """
-        txt:
-            a string which represents the entire bibtex entry. A typical
-            entry is of the form:
-                @ARTICLE{ellington:84:part3,
-                  author = {Ellington, C P},
-                  title = {The Aerodynamics of Hovering Insect Flight. III. Kinematics},
-                  journal = {Philosophical Transactions of the Royal Society of London. Series B, Biological Sciences},
-                  year = {1984},
-                  volume = {305},
-                  pages = {41-78},
-                  number = {1122},
-                  owner = {Srinath},
-                  pdf = {C:\srinath\research\papers\Ellington-3-Kinematics.pdf},
-                  timestamp = {2006.01.02},
-                }
-        """
-        
-        if macros:
-            for k, v in macros.iteritems():
-                txt = txt.replace(k, '{'+v+'}')
-        
-        m = re.match(r'\s*@(\w+){((\S+),)?(.*)}\s*', txt, re.MULTILINE | re.DOTALL)
-        if not m:
-            return None
-
-        self['bibtype'] = m.group(1).capitalize()
-        self['key'] = m.group(3)
-        self['body'] = m.group(4)
-
-        body = self['body']
-        self['bodytext'] = ''
-        while 1:
-            m = re.search(r'(\S+?)\s*=\s*(.)', body)
-            if not m:
-                break
-
-            field = m.group(1)
-
-            body = body[(m.start(2)+1):]
-            if m.group(2) == '{':
-                # search for the next closing brace. This is not simply a
-                # matter of searching for the next closing brace since
-                # braces can be nested. The following code basically goes
-                # to the next } which has not already been closed by a
-                # following {.
-                mniter = re.finditer(r'{|}', body)
-
-                count = 1
-                while 1:
-                    try:
-                        mn = mniter.next()
-                    except StopIteration:
-                        return None
-
-                    if mn.group(0) == '{':
-                        count += 1
-                    else:
-                        count -= 1
-
-                    if count == 0:
-                        value = body[:(mn.start(0))]
-                        break
-
-            elif m.group(2) == '"':
-                # search for the next unquoted double-quote. To be more
-                # precise, a double quote which is preceded by an even
-                # number of double quotes.
-                mn = re.search(r'(?!\\)(\\\\)*"', body)
-                if not mn:
-                    return None
-
-                value = body[:(mn.start(0))]
-
-            else:
-                # $ always matches. So we do not need to do any
-                # error-checking.
-                mn = re.search(r',|$', body)
-                value = m.group(2) + body[:(mn.start(0))].rstrip()
-
-            self[field] = re.sub(r'\s+', ' ', value)
-            body = body[(mn.start(0)+1):]
-
-            self['bodytext'] += ('  %s: %s\n' % (field, value))
-            if self['bibtype'].lower() == 'string':
-                self['macro'] = {field: value}
-
-        self['bodytext'] = self['bodytext'].rstrip()
-        
-
-    def __getitem__(self, key):
-        try:
-            return dict.__getitem__(self, key)
-        except KeyError:
-            return ''
-        
-    def __str__(self):
-        if self['bibtype'].lower() == 'string':
-            return 'String: %(macro)s' % self
-
-        elif self['bibtype'].lower() == 'article':
-            return ('Article [%(key)s]\n' +
-                    'TI "%(title)s"\n' +
-                    'AU %(author)s\n' +
-                    'IN In %(journal)s, %(year)s') % self
-
-        elif self['bibtype'].lower() == 'conference':
-            return ('Conference [%(key)s]\n' +
-                    'TI "%(title)s"\n' +
-                    'AU %(author)s\n' +
-                    'IN In %(booktitle)s, %(year)s') % self
-
-        elif self['bibtype'].lower() == 'mastersthesis':
-            return ('Masters [%(key)s]\n' + 
-                    'TI "%(title)s"\n' + 
-                    'AU %(author)s\n' + 
-                    'IN In %(school)s, %(year)s') % self
-
-        elif self['bibtype'].lower() == 'phdthesis':
-            return ('PhD [%(key)s]\n' + 
-                    'TI "%(title)s"\n' + 
-                    'AU %(author)s\n' + 
-                    'IN In %(school)s, %(year)s') % self
-
-        elif self['bibtype'].lower() == 'book':
-            return ('Book [%(key)s]\n' +
-                    'TI "%(title)s"\n' + 
-                    'AU %(author)s\n' + 
-                    'IN %(publisher)s, %(year)s') % self
-
-        else:
-            s = '%(bibtype)s [%(key)s]\n' % self
-            if self['title']:
-                s += 'TI "%(title)s"\n' % self
-            if self['author']:
-                s += 'AU %(author)s\n' % self
-            for k, v in self.iteritems():
-                if k not in ['title', 'author', 'bibtype', 'key', 'id', 'file', 'body', 'bodytext']:
-                    s += 'MI %s: %s\n' % (k, v)
-
-            return s.rstrip()
-
-    def satisfies(self, filters):
-        for field, regexp in filters:
-            if not re.search(regexp, self[field], re.I):
-                return False
-
-        return True
-
-class BibFile:
-
-    def __init__(self, filelist=''):
-        self.bibentries = []
-        self.filters = []
-        self.macros = {}
-        self.sortfields = []
-        if filelist:
-            for f in filelist.splitlines():
-                self.addfile(f)
-
-    def addfile(self, file):
-        fields = open(file).read().split('@')
-        for f in fields:
-            if not (f and re.match('string', f, re.I)):
-                continue
-
-            b = Bibliography('@' + f)
-            self.macros.update(b['macro'])
-
-        for f in fields:
-            if not f or re.match('string', f, re.I):
-                continue
-
-            b = Bibliography('@' + f, self.macros)
-            if b:
-                b['file'] = file
-                b['id'] = len(self.bibentries)
-                self.bibentries += [b]
-
-
-    def addfilter(self, filterspec):
-        self.filters += [filterspec.split()]
-
-    def rmfilters(self):
-        self.filters = []
-
-    def __str__(self):
-        s = ''
-        for b in self.bibentries:
-            if b['key'] and b.satisfies(self.filters):
-                s += '%s\n\n' % b
-        return s
-
-    def addsortfield(self, field):
-        self.sortfields += [field]
-
-    def rmsortfields(self):
-        self.sortfields = []
-
-    def sort(self):
-        def cmpfun(b1, b2):
-            for f in self.sortfields:
-                c = cmp(b1[f], b2[f])
-                if c:
-                    return c
-            return 0
-        self.bibentries.sort(cmp=cmpfun)
-
-if __name__ == "__main__":
-    import sys
-
-    bf = BibFile(sys.argv[1])
-    print bf

vim/.vim/ftplugin/latex-suite/brackets.vim

-" ==============================================================================
-" History: This was originally part of auctex.vim by Carl Mueller.
-"          Srinath Avadhanula incorporated it into latex-suite with
-"          significant modifications.
-"          Parts of this file may be copyrighted by others as noted.
-" CVS: $Id: brackets.vim 997 2006-03-20 09:45:45Z srinathava $
-" Description:
-" 	This ftplugin provides the following maps:
-" . <M-b> encloses the previous character in \mathbf{}
-" . <M-c> is polymorphic as follows:
-"     Insert mode:
-"     1. If the previous character is a letter or number, then capitalize it and
-"        enclose it in \mathcal{}
-"     2. otherwise insert \cite{}
-"     Visual Mode:
-"     1. Enclose selection in \mathcal{}
-" . <M-l> is also polymorphic as follows:
-"     If the character before typing <M-l> is one of '([{|<q', then do the
-"     following:
-"       1. (<M-l>       \left(\right
-"               similarly for [, |
-"          {<M-l>       \left\{\right\}
-"       2. <<M-l>       \langle\rangle
-"       3. q<M-l>       \lefteqn{}
-"     otherwise insert  \label{}
-" . <M-i> inserts \item commands at the current cursor location depending on
-"       the surrounding environment. For example, inside itemize, it will
-"       insert a simple \item, but within a description, it will insert
-"       \item[<+label+>] etc.
-" 
-" These functions make it extremeley easy to do all the \left \right stuff in
-" latex.
-" ============================================================================== 
-
-" Avoid reinclusion.
-if exists('b:did_brackets')
-	finish
-endif
-let b:did_brackets = 1
-
-" define the funtions only once.
-if exists('*Tex_MathBF')
-	finish
-endif
-
-" Tex_MathBF: encloses te previous letter/number in \mathbf{} {{{
-" Description: 
-function! Tex_MathBF()
-	return "\<Left>\\mathbf{\<Right>}"
-endfunction " }}}
-" Tex_MathCal: enclose the previous letter/number in \mathcal {{{
-" Description:
-" 	if the last character is not a letter/number, then insert \cite{}
-function! Tex_MathCal()
-	let line = getline(line("."))
-	let char = line[col(".")-2]
-
-	if char =~ '[a-zA-Z0-9]'
-		return "\<BS>".'\mathcal{'.toupper(char).'}'
-	else
-		return IMAP_PutTextWithMovement('\cite{<++>}<++>')
-	endif
-endfunction
-" }}}
-" Tex_LeftRight: maps <M-l> in insert mode. {{{
-" Description:
-" This is a polymorphic function, which maps the behaviour of <M-l> in the
-" following way:
-" If the character before typing <M-l> is one of '([{|<q', then do the
-" following:
-" 	1. (<M-l>		\left(<++>\right<++>
-" 	    	similarly for [, |
-" 	   {<M-l>		\left\{<++>\right\}<++>
-" 	2. <<M-l>		\langle<++>\rangle<++>
-" 	3. q<M-l>		\lefteqn{<++>}<++>
-" otherwise insert  \label{<++>}<++>
-function! Tex_LeftRight()
-	let line = getline(line("."))
-	let char = line[col(".")-2]
-	let previous = line[col(".")-3]
-
-	let matchedbrackets = '()[]{}||'
-	if char =~ '(\|\[\|{\||'
-		let add = ''
-		if char =~ '{'
-			let add = "\\"
-		endif
-		let rhs = matchstr(matchedbrackets, char.'\zs.\ze')
-		return "\<BS>".IMAP_PutTextWithMovement('\left'.add.char.'<++>\right'.add.rhs.'<++>')
-	elseif char == '<'
-		return "\<BS>".IMAP_PutTextWithMovement('langle<++>\rangle<++>')
-	elseif char == 'q'
-		return "\<BS>".IMAP_PutTextWithMovement('\lefteqn{<++>}<++>')
-	else
-		return IMAP_PutTextWithMovement('\label{<++>}<++>')
-	endif
-endfunction " }}}
-" Tex_PutLeftRight: maps <M-l> in normal mode {{{
-" Description:
-" Put \left...\right in front of the matched brackets.
-function! Tex_PutLeftRight()
-	let previous = getline(line("."))[col(".") - 2]
-	let char = getline(line("."))[col(".") - 1]
-	if previous == '\'
-		if char == '{'
-			exe "normal ileft\\\<Esc>l%iright\\\<Esc>l%"
-		elseif char == '}'
-			exe "normal iright\\\<Esc>l%ileft\\\<Esc>l%"
-		endif
-	elseif char =~ '\[\|('
-		exe "normal i\\left\<Esc>l%i\\right\<Esc>l%"
-	elseif char =~ '\]\|)'
-		exe "normal i\\right\<Esc>l%i\\left\<Esc>l%"
-	endif
-endfunction " }}}
-
-" Provide <plug>'d mapping for easy user customization. {{{
-inoremap <silent> <Plug>Tex_MathBF      <C-r>=Tex_MathBF()<CR>
-inoremap <silent> <Plug>Tex_MathCal     <C-r>=Tex_MathCal()<CR>
-inoremap <silent> <Plug>Tex_LeftRight   <C-r>=Tex_LeftRight()<CR>
-vnoremap <silent> <Plug>Tex_MathBF		<C-C>`>a}<Esc>`<i\mathbf{<Esc>
-vnoremap <silent> <Plug>Tex_MathCal		<C-C>`>a}<Esc>`<i\mathcal{<Esc>
-nnoremap <silent> <Plug>Tex_LeftRight	:call Tex_PutLeftRight()<CR>
-
-" }}}
-" Tex_SetBracketingMaps: create mappings for the current buffer {{{
-function! <SID>Tex_SetBracketingMaps()
-
-	call Tex_MakeMap('<M-b>', '<Plug>Tex_MathBF', 'i', '<buffer> <silent>')
-	call Tex_MakeMap('<M-c>', '<Plug>Tex_MathCal', 'i', '<buffer> <silent>')
-	call Tex_MakeMap('<M-l>', '<Plug>Tex_LeftRight', 'i', '<buffer> <silent>')
-	call Tex_MakeMap('<M-b>', '<Plug>Tex_MathBF', 'v', '<buffer> <silent>')
-	call Tex_MakeMap('<M-c>', '<Plug>Tex_MathCal', 'v', '<buffer> <silent>')
-	call Tex_MakeMap('<M-l>', '<Plug>Tex_LeftRight', 'n', '<buffer> <silent>')
-
-endfunction
-" }}}
-
-augroup LatexSuite
-	au LatexSuite User LatexSuiteFileType 
-		\ call Tex_Debug('brackets.vim: Catching LatexSuiteFileType event', 'brak') | 
-		\ call <SID>Tex_SetBracketingMaps()
-augroup END
-
-" vim:fdm=marker

vim/.vim/ftplugin/latex-suite/compiler.vim

-"=============================================================================
-" 	     File: compiler.vim
-"      Author: Srinath Avadhanula
-"     Created: Tue Apr 23 05:00 PM 2002 PST
-" 
-"  Description: functions for compiling/viewing/searching latex documents
-"          CVS: $Id: compiler.vim 1102 2010-01-28 23:49:04Z tmaas $
-"=============================================================================
-
-" Tex_SetTeXCompilerTarget: sets the 'target' for the next call to Tex_RunLaTeX() {{{
-function! Tex_SetTeXCompilerTarget(type, target)
-	call Tex_Debug("+Tex_SetTeXCompilerTarget: setting target to [".a:target."] for ".a:type."r", "comp")
-
-	if a:target == ''
-		let target = Tex_GetVarValue('Tex_DefaultTargetFormat')
-		let target = input('Enter the target format for '.a:type.'r: ', target)
-	else
-		let target = a:target
-	endif
-	if target == ''
-		let target = 'dvi'
-	endif
-
-	let targetRule = Tex_GetVarValue('Tex_'.a:type.'Rule_'.target)
-
-	if targetRule != ''
-		if a:type == 'Compile'
-			let &l:makeprg = escape(targetRule, Tex_GetVarValue('Tex_EscapeChars'))
-		elseif a:type == 'View'
-			let s:viewer = targetRule
-		endif
-		let s:target = target
-
-	elseif Tex_GetVarValue('Tex_'.a:type.'RuleComplete_'.target) != ''
-		let s:target = target
-
-	elseif a:type == 'View' && has('macunix')
-		" On the mac, we can have empty view rules, so do not complain when
-		" both Tex_ViewRule_target and Tex_ViewRuleComplete_target are
-		" empty. On other platforms, we will complain... see below.
-		let s:target = target
-
-	else
-		let s:origdir = fnameescape(getcwd())
-		exe 'cd '.fnameescape(expand('%:p:h'))
-		if !Tex_GetVarValue('Tex_UseMakefile') || (glob('makefile*') == '' && glob('Makefile*') == '')
-			if has('gui_running')
-				call confirm(
-					\'No '.a:type.' rule defined for target '.target."\n".
-					\'Please specify a rule in $VIMRUNTIME/ftplugin/tex/texrc'."\n".
-					\'     :help Tex_'.a:type.'Rule_format'."\n".
-					\'for more information',
-					\"&ok", 1, 'Warning')
-			else
-				call input( 
-					\'No '.a:type.' rule defined for target '.target."\n".
-					\'Please specify a rule in $VIMRUNTIME/ftplugin/tex/texrc'."\n".
-					\'     :help Tex_'.a:type.'Rule_format'."\n".
-					\'for more information'
-					\)
-			endif
-		else
-			echomsg 'Assuming target is for makefile'
-			let s:target = target
-		endif
-		exe 'cd '.s:origdir
-	endif
-endfunction 
-
-function! SetTeXTarget(...)
-	if a:0 < 1
-		let target = Tex_GetVarValue('Tex_DefaultTargetFormat')
-		let target = input('Enter the target format for compiler and viewer: ', target)
-	else
-		let target = a:1
-	endif
-	if target == ''
-		let target = 'dvi'
-	endif
-
-	call Tex_SetTeXCompilerTarget('Compile', target)
-	call Tex_SetTeXCompilerTarget('View', target)
-endfunction
-
-com! -nargs=1 TCTarget :call Tex_SetTeXCompilerTarget('Compile', <f-args>)
-com! -nargs=1 TVTarget :call Tex_SetTeXCompilerTarget('View', <f-args>)
-com! -nargs=? TTarget :call SetTeXTarget(<f-args>)
-
-" }}}
-" Tex_CompileLatex: compiles the present file. {{{
-" Description: 
-function! Tex_CompileLatex()
-	if &ft != 'tex'
-		echo "calling Tex_RunLaTeX from a non-tex file"
-		return
-	end
-
-	" close any preview windows left open.
-	pclose!
-
-	let s:origdir = fnameescape(getcwd())
-
-	" Find the main file corresponding to this file. Always cd to the
-	" directory containing the file to avoid problems with the directory
-	" containing spaces.
-	" Latex on linux seems to be unable to handle file names with spaces at
-	" all! Therefore for the moment, do not attempt to handle spaces in the
-	" file name.
-	if exists('b:fragmentFile')
-		let mainfname = expand('%:p:t')
-		call Tex_CD(expand('%:p:h'))
-	else
-		let mainfname = Tex_GetMainFileName(':p:t')
-		call Tex_CD(Tex_GetMainFileName(':p:h'))
-	end
-
-	call Tex_Debug('Tex_CompileLatex: getting mainfname = ['.mainfname.'] from Tex_GetMainFileName', 'comp')
-
-	" if a makefile exists and the user wants to use it, then use that
-	" irrespective of whether *.latexmain exists or not. mainfname is still
-	" extracted from *.latexmain (if possible) log file name depends on the
-	" main file which will be compiled.
-	if Tex_GetVarValue('Tex_UseMakefile') && (glob('makefile') != '' || glob('Makefile') != '')
-		let _makeprg = &l:makeprg
-		call Tex_Debug("Tex_CompileLatex: using the makefile in the current directory", "comp")
-		let &l:makeprg = 'make $*'
-		if exists('s:target')
-			call Tex_Debug('Tex_CompileLatex: execing [make! '.s:target.']', 'comp')
-			exec 'make! '.s:target
-		else
-			call Tex_Debug('Tex_CompileLatex: execing [make!]', 'comp')
-			exec 'make!'
-		endif
-		let &l:makeprg = _makeprg
-	else
-		" If &makeprg has something like "$*.ps", it means that it wants the
-		" file-name without the extension... Therefore remove it.
-		if &makeprg =~ '\$\*\.\w\+'
-			let mainfname = fnamemodify(mainfname, ':r')
-		endif
-		call Tex_Debug('Tex_CompileLatex: execing [make! '.mainfname.']', 'comp')
-		exec 'make! '.mainfname
-	endif
-	redraw!
-
-	exe 'cd '.s:origdir
-endfunction " }}}
-" Tex_RunLaTeX: compilation function {{{
-" this function runs the latex command on the currently open file. often times
-" the file being currently edited is only a fragment being \input'ed into some
-" master tex file. in this case, make a file called mainfile.latexmain in the
-" directory containig the file. in other words, if the current file is
-" ~/thesis/chapter.tex
-" so that doing "latex chapter.tex" doesnt make sense, then make a file called 
-" main.tex.latexmain 
-" in the ~/thesis directory. this will then run "latex main.tex" when
-" Tex_RunLaTeX() is called.
-function! Tex_RunLaTeX()
-	call Tex_Debug('+Tex_RunLaTeX, b:fragmentFile = '.exists('b:fragmentFile'), 'comp')
-
-	let dir = expand("%:p:h").'/'
-	let s:origdir = fnameescape(getcwd())
-	call Tex_CD(expand("%:p:h"))
-
-	let initTarget = s:target
-
-	" first get the dependency chain of this format.
-	call Tex_Debug("Tex_RunLaTeX: compiling to target [".s:target."]", "comp")
-
-	if Tex_GetVarValue('Tex_FormatDependency_'.s:target) != ''
-		let dependency = Tex_GetVarValue('Tex_FormatDependency_'.s:target)
-		if dependency !~ ','.s:target.'$'
-			let dependency = dependency.','.s:target
-		endif
-	else
-		let dependency = s:target
-	endif
-
-	call Tex_Debug('Tex_RunLaTeX: getting dependency chain = ['.dependency.']', 'comp')
-
-	" now compile to the final target format via each dependency.
-	let i = 1
-	while Tex_Strntok(dependency, ',', i) != ''
-		let s:target = Tex_Strntok(dependency, ',', i)
-
-		call Tex_SetTeXCompilerTarget('Compile', s:target)
-		call Tex_Debug('Tex_RunLaTeX: setting target to '.s:target, 'comp')
-
-		if Tex_GetVarValue('Tex_MultipleCompileFormats') =~ '\<'.s:target.'\>'
-			call Tex_Debug("Tex_RunLaTeX: compiling file multiple times via Tex_CompileMultipleTimes", "comp")
-			call Tex_CompileMultipleTimes()
-		else
-			call Tex_Debug("Tex_RunLaTeX: compiling file once via Tex_CompileLatex", "comp")
-			call Tex_CompileLatex()
-		endif
-
-		let errlist = Tex_GetErrorList()
-		call Tex_Debug("Tex_RunLaTeX: errlist = [".errlist."]", "comp")
-
-		" If there are any errors, then break from the rest of the steps
-		if errlist =~  '\v(error|warning)'
-			call Tex_Debug('Tex_RunLaTeX: There were errors in compiling, breaking chain...', 'comp')
-			break
-		endif
-
-		let i = i + 1
-	endwhile
-	
-	let s:target = initTarget
-	let s:origwinnum = winnr()
-	call Tex_SetupErrorWindow()
-
-	exe 'cd '.s:origdir
-	call Tex_Debug("-Tex_RunLaTeX", "comp")
-endfunction
-
-" }}}
-" Tex_ViewLaTeX: opens viewer {{{
-" Description: opens the DVI viewer for the file being currently edited.
-" Again, if the current file is a \input in a master file, see text above
-" Tex_RunLaTeX() to see how to set this information.
-function! Tex_ViewLaTeX()
-	if &ft != 'tex'
-		echo "calling Tex_ViewLaTeX from a non-tex file"
-		return
-	end
-	
-	let s:origdir = fnameescape(getcwd())
-	
-	" If b:fragmentFile is set, it means this file was compiled as a fragment
-	" using Tex_PartCompile, which means that we want to ignore any
-	" *.latexmain or makefile's.
-	if !exists('b:fragmentFile')
-		" cd to the location of the file to avoid having to deal with spaces
-		" in the directory name.
-		let mainfname = Tex_GetMainFileName(':p:t:r')
-		call Tex_CD(Tex_GetMainFileName(':p:h'))
-	else
-		let mainfname = expand("%:p:t:r")
-		call Tex_CD(expand("%:p:h"))
-	endif
-
-	if Tex_GetVarValue('Tex_ViewRuleComplete_'.s:target) != ''
-
-		let execString = Tex_GetVarValue('Tex_ViewRuleComplete_'.s:target)
-		let execString = substitute(execString, '{v:servername}', v:servername, 'g')
-
-	elseif has('win32')
-		" unfortunately, yap does not allow the specification of an external
-		" editor from the command line. that would have really helped ensure
-		" that this particular vim and yap are connected.
-		let execString = 'start '.s:viewer.' "$*.'.s:target.'"'
-
-	elseif (has('macunix') && Tex_GetVarValue('Tex_TreatMacViewerAsUNIX') != 1)
-
-		if strlen(s:viewer)
-			let appOpt = '-a '
-		else
-			let appOpt = ''
-		endif
-		let execString = 'open '.appOpt.s:viewer.' $*.'.s:target
-
-	else
-		" taken from Dimitri Antoniou's tip on vim.sf.net (tip #225).
-		" slight change to actually use the current servername instead of
-		" hardcoding it as xdvi.
-		" Using an option for specifying the editor in the command line
-		" because that seems to not work on older bash'es.
-		if s:target == 'dvi'
-
-			if Tex_GetVarValue('Tex_UseEditorSettingInDVIViewer') == 1 &&
-						\ v:servername != '' &&
-						\ (s:viewer == "xdvi" || s:viewer == "xdvik")
-
-				let execString = s:viewer.' -editor "gvim --servername '.v:servername.
-							\ ' --remote-silent +\%l \%f" $*.dvi'
-
-			elseif Tex_GetVarValue('Tex_UseEditorSettingInDVIViewer') == 1 &&
-						\ s:viewer == "kdvi"
-
-				let execString = 'kdvi --unique $*.dvi'
-
-			else
-
-				let execString = s:viewer.' $*.dvi'
-
-			endif
-
-		else
-
-			let execString = s:viewer.' $*.'.s:target
-
-		endif
-
-		if( Tex_GetVarValue('Tex_ExecuteUNIXViewerInForeground') != 1 )
-			let execString = execString.' &' 
-		endif
-
-	end
-
-	let execString = substitute(execString, '\V$*', mainfname, 'g')
-	call Tex_Debug("Tex_ViewLaTeX: execString = ".execString, "comp")
-
-	exec 'silent! !'.execString
-
-	if !has('gui_running')
-		redraw!
-	endif
-
-	exe 'cd '.s:origdir
-endfunction
-
-" }}}
-" Tex_ForwardSearchLaTeX: searches for current location in dvi file. {{{
-" Description: if the DVI viewer is compatible, then take the viewer to that
-"              position in the dvi file. see docs for Tex_RunLaTeX() to set a
-"              master file if this is an \input'ed file. 
-" Tip: With YAP on Windows, it is possible to do forward and inverse searches
-"      on DVI files. to do forward search, you'll have to compile the file
-"      with the --src-specials option. then set the following as the command
-"      line in the 'view/options/inverse search' dialog box:
-"           gvim --servername LATEX --remote-silent +%l "%f"
-"      For inverse search, if you are reading this, then just pressing \ls
-"      will work.
-function! Tex_ForwardSearchLaTeX()
-	if &ft != 'tex'
-		echo "calling Tex_ForwardSeachLaTeX from a non-tex file"
-		return
-	end
-
-	if Tex_GetVarValue('Tex_ViewRule_'.s:target) == ''
-		return
-	endif
-	let viewer = Tex_GetVarValue('Tex_ViewRule_'.s:target)
-	
-	let s:origdir = fnameescape(getcwd())
-
-	let mainfname = Tex_GetMainFileName(':t')
-	let mainfnameRoot = fnamemodify(Tex_GetMainFileName(), ':t:r')
-	let mainfnameFull = Tex_GetMainFileName(':p:r')
-	" cd to the location of the file to avoid problems with directory name
-	" containing spaces.
-	call Tex_CD(Tex_GetMainFileName(':p:h'))
-	
-	" inverse search tips taken from Dimitri Antoniou's tip and Benji Fisher's
-	" tips on vim.sf.net (vim.sf.net tip #225)
-	if (has('win32') && (viewer == "yap" || viewer == "YAP" || viewer == "Yap"))
-
-		let execString = 'silent! !start '. viewer.' -s '.line('.').expand('%').' '.mainfnameRoot
-
-
-	elseif (has('macunix') && (viewer == "Skim" || viewer == "PDFView" || viewer == "TeXniscope"))
-		" We're on a Mac using a traditional Mac viewer
-
-		if viewer == "Skim"
-
-				let execString = 'silent! !/Applications/Skim.app/Contents/SharedSupport/displayline '.
-					\ line('.').' "'.mainfnameFull.'.'.s:target.'" "'.expand("%:p").'"'
-
-		elseif viewer == "PDFView"
-
-				let execString = 'silent! !/Applications/PDFView.app/Contents/MacOS/gotoline.sh '.
-					\ line('.').' "'.mainfnameFull.'.'.s:target.'" "'.expand("%:p").'"'
-
-		elseif viewer == "TeXniscope"
-
-				let execString = 'silent! !/Applications/TeXniscope.app/Contents/Resources/forward-search.sh '.
-					\ line('.').' "'.expand("%:p").'" "'.mainfnameFull.'.'.s:target.'"'
-
-		endif
-
-	else
-		" We're either UNIX or Mac and using a UNIX-type viewer
-
-		" Check for the special DVI viewers first
-		if (viewer == "xdvi" || viewer == "xdvik" || viewer == "kdvi" )
-
-			if Tex_GetVarValue('Tex_UseEditorSettingInDVIViewer') == 1 &&
-						\ exists('v:servername') &&
-						\ (viewer == "xdvi" || viewer == "xdvik") 
-
-				let execString = 'silent! !'.viewer.' -name xdvi -sourceposition "'.line('.').' '.expand("%").'"'.
-							\ ' -editor "gvim --servername '.v:servername.' --remote-silent +\%l \%f" '.
-							\ mainfnameRoot.'.dvi'
-
-			elseif viewer == "kdvi"
-
-				let execString = 'silent! !kdvi --unique file:'.mainfnameRoot.'.dvi\#src:'.line('.').expand("%")
-
-			elseif (viewer == "xdvi" || viewer == "xdvik" )
-
-				let execString = 'silent! !'.viewer.' -name xdvi -sourceposition "'.line('.').' '.expand("%").'" '.mainfnameRoot.'.dvi'
-
-			endif
-
-		else
-			" We must be using a generic UNIX viewer
-			" syntax is: viewer TARGET_FILE LINE_NUMBER SOURCE_FILE
-
-			let execString = 'silent! !'.viewer.' "'.mainfnameRoot.'.'.s:target.'" '.line('.').' "'.expand('%').'"'
-
-		endif
-
-		" See if we should add &. On Mac (at least in MacVim), it seems
-		" like this should NOT be added...
-		if( Tex_GetVarValue('Tex_ExecuteUNIXViewerInForeground') != 1 )
-			let execString = execString.' &' 
-		endif
-
-	endif
-
-	call Tex_Debug("Tex_ForwardSearchLaTeX: execString = ".execString, "comp")
-	execute execString
-	if !has('gui_running')
-		redraw!
-	endif
-
-	exe 'cd '.s:origdir
-endfunction
-
-" }}}
-
-" ==============================================================================
-" Functions for compiling parts of a file. 
-" ============================================================================== 
-" Tex_PartCompile: compiles selected fragment {{{
-" Description: creates a temporary file from the selected fragment of text
-"       prepending the preamble and \end{document} and then asks Tex_RunLaTeX() to
-"       compile it.
-function! Tex_PartCompile() range
-	call Tex_Debug('+Tex_PartCompile', 'comp')
-
-	" Get a temporary file in the same directory as the file from which
-	" fragment is being extracted. This is to enable the use of relative path
-	" names in the fragment.
-	let tmpfile = Tex_GetTempName(expand('%:p:h'))
-
-	" Remember all the temp files and for each temp file created, remember
-	" where the temp file came from.
-	let s:Tex_NumTempFiles = (exists('s:Tex_NumTempFiles') ? s:Tex_NumTempFiles + 1 : 1)
-	let s:Tex_TempFiles = (exists('s:Tex_TempFiles') ? s:Tex_TempFiles : '')
-		\ . tmpfile."\n"
-	let s:Tex_TempFile_{s:Tex_NumTempFiles} = tmpfile
-	" TODO: For a function Tex_RestoreFragment which restores a temp file to
-	"       its original location.
-	let s:Tex_TempFileOrig_{s:Tex_NumTempFiles} = expand('%:p')
-	let s:Tex_TempFileRange_{s:Tex_NumTempFiles} = a:firstline.','.a:lastline
-
-	" Set up an autocmd to clean up the temp files when Vim exits.
-	if Tex_GetVarValue('Tex_RemoveTempFiles')
-		augroup RemoveTmpFiles
-			au!
-			au VimLeave * :call Tex_RemoveTempFiles()
-		augroup END
-	endif
-
-	" If mainfile exists open it in tiny window and extract preamble there,
-	" otherwise do it from current file
-	let mainfile = Tex_GetMainFileName(":p")
-	exe 'bot 1 split '.escape(mainfile, ' ')
-	exe '1,/\s*\\begin{document}/w '.tmpfile
-	wincmd q
-
-	exe a:firstline.','.a:lastline."w! >> ".tmpfile
-
-	" edit the temporary file
-	exec 'drop '.tmpfile
-
-	" append the \end{document} line.
-	$ put ='\end{document}'
-	w
-	
-	" set this as a fragment file.
-	let b:fragmentFile = 1
-
-	silent! call Tex_RunLaTeX()
-endfunction " }}}
-" Tex_RemoveTempFiles: cleans up temporary files created during part compilation {{{
-" Description: During part compilation, temporary files containing the
-"              visually selected text are created. These files need to be
-"              removed when Vim exits to avoid "file leakage".
-function! Tex_RemoveTempFiles()
-	if !exists('s:Tex_NumTempFiles') || !Tex_GetVarValue('Tex_RemoveTempFiles')
-		return
-	endif
-	let i = 1
-	while i <= s:Tex_NumTempFiles
-		let tmpfile = s:Tex_TempFile_{i}
-		" Remove the tmp file and all other associated files such as the
-		" .log files etc.
-		call Tex_DeleteFile(fnamemodify(tmpfile, ':p:r').'.*')
-		let i = i + 1
-	endwhile
-endfunction " }}}
-
-" ==============================================================================
-" Compiling a file multiple times to resolve references/citations etc.
-" ============================================================================== 
-" Tex_CompileMultipleTimes: The main function {{{
-" Description: compiles a file multiple times to get cross-references right.
-function! Tex_CompileMultipleTimes()
-	" Just extract the root without any extension because we want to construct
-	" the log file names etc from it.
-	let s:origdir = fnameescape(getcwd())
-	let mainFileName_root = Tex_GetMainFileName(':p:t:r')
-	call Tex_CD(Tex_GetMainFileName(':p:h'))
-
-	" First ignore undefined references and the 
-	" "rerun to get cross-references right" message from 
-	" the compiler output.
-	let origlevel = Tex_GetVarValue('Tex_IgnoreLevel')
-	let origpats = Tex_GetVarValue('Tex_IgnoredWarnings')
-
-	let g:Tex_IgnoredWarnings = g:Tex_IgnoredWarnings."\n"
-		\ . 'Reference %.%# undefined'."\n"
-		\ . 'Rerun to get cross-references right'
-	TCLevel 1000
-
-	let idxFileName = mainFileName_root.'.idx'
-	let auxFileName = mainFileName_root.'.aux'
-
-	let runCount = 0
-	let needToRerun = 1
-	while needToRerun == 1 && runCount < 5
-		" assume we need to run only once.
-		let needToRerun = 0
-
-		let idxlinesBefore = Tex_CatFile(idxFileName)
-		let auxlinesBefore = Tex_GetAuxFile(auxFileName)
-
-		" first run latex.
-		echomsg "latex run number : ".(runCount+1)
-		call Tex_Debug("Tex_CompileMultipleTimes: latex run number : ".(runCount+1), "comp") 
-		silent! call Tex_CompileLatex()
-		
-		" If there are errors in any latex compilation step, immediately
-		" return. For now, do not bother with warnings because those might go
-		" away after compiling again or after bibtex is run etc.
-		let errlist = Tex_GetErrorList()
-		call Tex_Debug("Tex_CompileMultipleTimes: errors = [".errlist."]", "comp")
-
-		if errlist =~ 'error'
-			let g:Tex_IgnoredWarnings = origpats
-			exec 'TCLevel '.origlevel
-
-			return
-		endif
-
-		let idxlinesAfter = Tex_CatFile(idxFileName)
-
-		" If .idx file changed, then run makeindex to generate the new .ind
-		" file and remember to rerun latex.
-		if runCount == 0 && glob(idxFileName) != '' && idxlinesBefore != idxlinesAfter
-			echomsg "Running makeindex..."
-			let temp_mp = &mp | let &mp = Tex_GetVarValue('Tex_MakeIndexFlavor')
-			exec 'silent! make '.mainFileName_root
-			let &mp = temp_mp
-
-			let needToRerun = 1
-		endif
-
-		" The first time we see if we need to run bibtex and if the .bbl file
-		" changes, we will rerun latex.
-		if runCount == 0 && Tex_IsPresentInFile('\\bibdata', mainFileName_root.'.aux')
-			let bibFileName = mainFileName_root.'.bbl'
-
-			let biblinesBefore = Tex_CatFile(bibFileName)
-
-			echomsg "Running '".Tex_GetVarValue('Tex_BibtexFlavor')."' ..."
-			let temp_mp = &mp | let &mp = Tex_GetVarValue('Tex_BibtexFlavor')
-			exec 'silent! make '.mainFileName_root
-			let &mp = temp_mp
-
-			let biblinesAfter = Tex_CatFile(bibFileName)
-
-			" If the .bbl file changed after running bibtex, we need to
-			" latex again.
-			if biblinesAfter != biblinesBefore
-				echomsg 'Need to rerun because bibliography file changed...'
-				call Tex_Debug('Tex_CompileMultipleTimes: Need to rerun because bibliography file changed...', 'comp')
-				let needToRerun = 1
-			endif
-		endif
-
-		" check if latex asks us to rerun
-		let auxlinesAfter = Tex_GetAuxFile(auxFileName)
-		if auxlinesAfter != auxlinesBefore
-			echomsg "Need to rerun because the AUX file changed..."
-			call Tex_Debug("Tex_CompileMultipleTimes: Need to rerun to get cross-references right...", 'comp')
-			let needToRerun = 1
-		endif
-
-		let runCount = runCount + 1
-	endwhile
-
-	redraw!
-	call Tex_Debug("Tex_CompileMultipleTimes: Ran latex ".runCount." time(s)", "comp")
-	echomsg "Ran latex ".runCount." time(s)"
-
-	let g:Tex_IgnoredWarnings = origpats
-	exec 'TCLevel '.origlevel
-	" After all compiler calls are done, reparse the .log file for
-	" errors/warnings to handle the situation where the clist might have been
-	" emptied because of bibtex/makeindex being run as the last step.
-	exec 'silent! cfile '.mainFileName_root.'.log'
-
-	exe 'cd '.s:origdir
-endfunction " }}}
-" Tex_GetAuxFile: get the contents of the AUX file {{{
-" Description: get the contents of the AUX file recursively including any
-" @\input'ted AUX files.
-function! Tex_GetAuxFile(auxFile)
-	if !filereadable(a:auxFile)
-		return ''
-	endif
-
-	let auxContents = Tex_CatFile(a:auxFile)
-	let pattern = '@\input{\(.\{-}\)}'
-
-	let auxContents = substitute(auxContents, pattern, '\=Tex_GetAuxFile(submatch(1))', 'g')
-
-	return auxContents
-endfunction " }}}
-
-" ==============================================================================
-" Helper functions for 
-" . viewing the log file in preview mode.
-" . syncing the display between the quickfix window and preview window
-" . going to the correct line _and column_ number from from the quick fix
-"   window.
-" ============================================================================== 
-" Tex_SetupErrorWindow: sets up the cwindow and preview of the .log file {{{
-" Description: 
-function! Tex_SetupErrorWindow()
-	let mainfname = Tex_GetMainFileName()
-
-	let winnum = winnr()
-
-	" close the quickfix window before trying to open it again, otherwise
-	" whether or not we end up in the quickfix window after the :cwindow
-	" command is not fixed.
-	cclose
-	cwindow
-	" create log file name from mainfname
-	let mfnlog = fnamemodify(mainfname, ":t:r").'.log'
-	call Tex_Debug('Tex_SetupErrorWindow: mfnlog = '.mfnlog, 'comp')
-	" if we moved to a different window, then it means we had some errors.
-	if winnum != winnr()
-		if Tex_GetVarValue('Tex_ShowErrorContext')
-			call Tex_UpdatePreviewWindow(mfnlog)
-			exe 'nnoremap <buffer> <silent> j j:call Tex_UpdatePreviewWindow("'.mfnlog.'")<CR>'
-			exe 'nnoremap <buffer> <silent> k k:call Tex_UpdatePreviewWindow("'.mfnlog.'")<CR>'
-			exe 'nnoremap <buffer> <silent> <up> <up>:call Tex_UpdatePreviewWindow("'.mfnlog.'")<CR>'
-			exe 'nnoremap <buffer> <silent> <down> <down>:call Tex_UpdatePreviewWindow("'.mfnlog.'")<CR>'
-		endif
-		exe 'nnoremap <buffer> <silent> <enter> :call Tex_GotoErrorLocation("'.mfnlog.'")<CR>'
-
-		setlocal nowrap
-
-		" resize the window to just fit in with the number of lines.
-		exec ( line('$') < 4 ? line('$') : 4 ).' wincmd _'
-        if Tex_GetVarValue('Tex_GotoError') == 1
- 	        call Tex_GotoErrorLocation(mfnlog)
-        else
-			exec s:origwinnum.' wincmd w'
-        endif
-	endif
-
-endfunction " }}}
-" Tex_PositionPreviewWindow: positions the preview window correctly. {{{
-" Description: 
-" 	The purpose of this function is to count the number of times an error
-" 	occurs on the same line. or in other words, if the current line is
-" 	something like |10 error|, then we want to count the number of
-" 	lines in the quickfix window before this line which also contain lines
-" 	like |10 error|. 
-"
-function! Tex_PositionPreviewWindow(filename)
-
-	if getline('.') !~ '|\d\+ \(error\|warning\)|'
-		if !search('|\d\+ \(error\|warning\)|')
-			call Tex_Debug("not finding error pattern anywhere in quickfix window :".bufname(bufnr('%')),
-						\ 'comp')
-			pclose!
-			return
-		endif
-	endif
-
-	" extract the error pattern (something like 'file.tex|10 error|') on the
-	" current line.
-	let errpat = matchstr(getline('.'), '^\f*|\d\+ \(error\|warning\)|\ze')
-	let errfile = matchstr(getline('.'), '^\f*\ze|\d\+ \(error\|warning\)|')
-	" extract the line number from the error pattern.
-	let linenum = matchstr(getline('.'), '|\zs\d\+\ze \(error\|warning\)|')
-
-	" if we are on an error, then count the number of lines before this in the
-	" quickfix window with an error on the same line.
-	if errpat =~ 'error|$'
-		" our location in the quick fix window.
-		let errline = line('.')
-
-		" goto the beginning of the quickfix window and begin counting the lines
-		" which show an error on the same line.
-		0
-		let numrep = 0
-		while 1
-			" if we are on the same kind of error line, then means we have another
-			" line containing the same error pattern.
-			if getline('.') =~ errpat
-				let numrep = numrep + 1
-				normal! 0
-			endif
-			" if we have reached the original location in the quick fix window,
-			" then break.
-			if line('.') == errline
-				break
-			else
-				" otherwise, search for the next line which contains the same
-				" error pattern again. goto the end of the current line so we
-				" dont count this line again.
-				normal! $
-				call search(errpat, 'W')
-			endif
-		endwhile
-	else
-		let numrep = 1
-	endif
-
-	if getline('.') =~ '|\d\+ warning|'
-		let searchpat = escape(matchstr(getline('.'), '|\d\+ warning|\s*\zs.*'), '\ ')
-	else
-		let searchpat = 'l\.'.linenum
-	endif
-
-	" We first need to be in the scope of the correct file in the .log file.
-	" This is important for example, when a.tex and b.tex both have errors on
-	" line 9 of the file and we want to go to the error of b.tex. Merely
-	" searching forward from the beginning of the log file for l.9 will always
-	" land us on the error in a.tex.
-	if errfile != ''
-		exec 'silent! bot pedit +/(\\(\\f\\|\\[\\|\]\\|\\s\\)*'.errfile.'/ '.a:filename
-	else
-		exec 'bot pedit +0 '.a:filename
-	endif
-	" Goto the preview window
-	" TODO: This is not robust enough. Check that a wincmd j actually takes
-	" us to the preview window.
-	wincmd j
-	" now search forward from this position in the preview window for the
-	" numrep^th error of the current line in the quickfix window.
-	while numrep > 0
-		call search(searchpat, 'W')
-		let numrep = numrep - 1
-	endwhile
-	normal! z.
-
-endfunction " }}}
-" Tex_UpdatePreviewWindow: updates the view of the log file {{{
-" Description: 
-"       This function should be called when focus is in a quickfix window.
-"       It opens the log file in a preview window and makes it display that
-"       part of the log file which corresponds to the error which the user is
-"       currently on in the quickfix window. Control returns to the quickfix
-"       window when the function returns. 
-"
-function! Tex_UpdatePreviewWindow(filename)
-	call Tex_PositionPreviewWindow(a:filename)
-
-	if &previewwindow
-		6 wincmd _
-		wincmd p
-	endif
-endfunction " }}}
-" Tex_GotoErrorLocation: goes to the correct location of error in the tex file {{{
-" Description: 
-"   This function should be called when focus is in a quickfix window. This
-"   function will first open the preview window of the log file (if it is not
-"   already open), position the display of the preview to coincide with the
-"   current error under the cursor and then take the user to the file in
-"   which this error has occured. 
-"
-"   The position is both the correct line number and the column number.
-function! Tex_GotoErrorLocation(filename)
-
-	" first use vim's functionality to take us to the location of the error
-	" accurate to the line (not column). This lets us go to the correct file
-	" without applying any logic.
-	exec "normal! \<enter>"
-	" If the log file is not found, then going to the correct line number is
-	" all we can do.
- 	if glob(a:filename) == ''
-		return
-	endif
-
-	let winnum = winnr()
-	" then come back to the quickfix window
-	wincmd w
-
-	" find out where in the file we had the error.
-	let linenum = matchstr(getline('.'), '|\zs\d\+\ze \(warning\|error\)|')
-	call Tex_PositionPreviewWindow(a:filename)
-
-	if getline('.') =~ 'l.\d\+'
-
-		let brokenline = matchstr(getline('.'), 'l.'.linenum.' \zs.*\ze')
-		" If the line is of the form
-		" 	l.10 ...and then there was some error
-		" it means (most probably) that only part of the erroneous line is
-		" shown. In this case, finding the length of the broken line is not
-		" correct.  Instead goto the beginning of the line and search forward
-		" for the part which is displayed and then go to its end.
-		if brokenline =~ '^\M...'
-			let partline = matchstr(brokenline, '^\M...\m\zs.*')
-			let normcmd = "0/\\V".escape(partline, "\\")."/e+1\<CR>"
-		else
-			let column = strlen(brokenline) + 1
-			let normcmd = column.'|'
-		endif
-
-	elseif getline('.') =~ 'LaTeX Warning: \(Citation\|Reference\) `.*'
-
-		let ref = matchstr(getline('.'), "LaTeX Warning: \\(Citation\\|Reference\\) `\\zs[^']\\+\\ze'")
-		let normcmd = '0/'.ref."\<CR>"
-
-	else
-
-		let normcmd = '0'
-
-	endif
-
-	" go back to the window where we came from.
-	exec winnum.' wincmd w'
-	exec 'silent! '.linenum.' | normal! '.normcmd
-
-	if !Tex_GetVarValue('Tex_ShowErrorContext')
-		pclose!
-	endif
-endfunction " }}}
-" Tex_SetCompilerMaps: sets maps for compiling/viewing/searching {{{
-" Description: 
-function! <SID>Tex_SetCompilerMaps()
-	if exists('b:Tex_doneCompilerMaps')
-		return
-	endif
-	let s:ml = exists('g:mapleader') ? g:mapleader : "\\"
-
-	nnoremap <buffer> <Plug>Tex_Compile :call Tex_RunLaTeX()<cr>
-	vnoremap <buffer> <Plug>Tex_Compile :call Tex_PartCompile()<cr>
-	nnoremap <buffer> <Plug>Tex_View :call Tex_ViewLaTeX()<cr>
-	nnoremap <buffer> <Plug>Tex_ForwardSearch :call Tex_ForwardSearchLaTeX()<cr>
-
-	call Tex_MakeMap(s:ml."ll", "<Plug>Tex_Compile", 'n', '<buffer>')
-	call Tex_MakeMap(s:ml."ll", "<Plug>Tex_Compile", 'v', '<buffer>')
-	call Tex_MakeMap(s:ml."lv", "<Plug>Tex_View", 'n', '<buffer>')
-	call Tex_MakeMap(s:ml."ls", "<Plug>Tex_ForwardSearch", 'n', '<buffer>')
-endfunction 
-" }}}
-
-augroup LatexSuite
-	au LatexSuite User LatexSuiteFileType 
-		\ call Tex_Debug('compiler.vim: Catching LatexSuiteFileType event', 'comp') | 
-		\ call <SID>Tex_SetCompilerMaps()
-augroup END
-
-command! -nargs=0 -range=% TPartCompile :<line1>, <line2> silent! call Tex_PartCompile()
-" Setting b:fragmentFile = 1 makes Tex_CompileLatex consider the present file
-" the _main_ file irrespective of the presence of a .latexmain file.
-command! -nargs=0 TCompileThis let b:fragmentFile = 1
-command! -nargs=0 TCompileMainFile let b:fragmentFile = 0
-
-" vim:fdm=marker:ff=unix:noet:ts=4:sw=4

vim/.vim/ftplugin/latex-suite/custommacros.vim

-"=============================================================================
-" 	     File: custommacros.vim
-"      Author: Mikolaj Machowski
-" 	  Version: 1.0 
-"     Created: Tue Apr 23 05:00 PM 2002 PST
-" 	      CVS: $Id: custommacros.vim 1013 2006-04-29 02:36:23Z srinathava $
-" 
-"  Description: functions for processing custom macros in the
-"               latex-suite/macros directory
-"=============================================================================
-
-let s:path = expand('<sfile>:p:h')
-
-" Set path to macros dir dependent on OS {{{
-if has("unix") || has("macunix")
-	let s:macrodirpath = $HOME."/.vim/ftplugin/latex-suite/macros/"
-elseif has("win32")
-	if exists("$HOME")
-		let s:macrodirpath = $HOME."/vimfiles/ftplugin/latex-suite/macros/"
-	else
-		let s:macrodirpath = $VIM."/vimfiles/ftplugin/latex-suite/macros/"
-	endif
-endif
-
-" }}}
-" SetCustomMacrosMenu: sets up the menu for Macros {{{
-function! <SID>SetCustomMacrosMenu()
-	let flist = Tex_FindInRtp('', 'macros')
-	exe 'amenu '.g:Tex_MacrosMenuLocation.'&New :call <SID>NewMacro("FFFromMMMenu")<CR>'
-	exe 'amenu '.g:Tex_MacrosMenuLocation.'&Redraw :call RedrawMacro()<CR>'
-
-	let i = 1
-	while 1
-		let fname = Tex_Strntok(flist, ',', i)
-		if fname == ''
-			break
-		endif
-		exe "amenu ".g:Tex_MacrosMenuLocation."&Delete.&".i.":<tab>".fname." :call <SID>DeleteMacro('".fname."')<CR>"
-		exe "amenu ".g:Tex_MacrosMenuLocation."&Edit.&".i.":<tab>".fname."   :call <SID>EditMacro('".fname."')<CR>"
-		exe "imenu ".g:Tex_MacrosMenuLocation."&".i.":<tab>".fname." <C-r>=<SID>ReadMacro('".fname."')<CR>"
-		exe "nmenu ".g:Tex_MacrosMenuLocation."&".i.":<tab>".fname." i<C-r>=<SID>ReadMacro('".fname."')<CR>"
-		let i = i + 1
-	endwhile
-endfunction 
-
-if g:Tex_Menus
-	call <SID>SetCustomMacrosMenu()
-endif
-
-" }}}
-" NewMacro: opens new file in macros directory {{{
-function! <SID>NewMacro(...)
-	" Allow for calling :TMacroNew without argument or from menu and prompt
-	" for name.
-	if a:0 > 0
-		let newmacroname = a:1
-	else
-		let newmacroname = input("Name of new macro: ")
-		if newmacroname == ''
-			return
-		endif
-	endif
-
-	if newmacroname == "FFFromMMMenu"
-		" Check if NewMacro was called from menu and prompt for insert macro
-		" name
-		let newmacroname = input("Name of new macro: ")
-		if newmacroname == ''
-			return
-		endif
-	elseif Tex_FindInRtp(newmacroname, 'macros') != ''
-		" If macro with this name already exists, prompt for another name.
-		exe "echomsg 'Macro ".newmacroname." already exists. Try another name.'"
-		let newmacroname = input("Name of new macro: ")
-		if newmacroname == ''
-			return
-		endif
-	endif
-	exec 'split '.Tex_EscapeSpaces(s:macrodirpath.newmacroname)
-	setlocal filetype=tex
-endfunction
-
-" }}}
-" RedrawMacro: refreshes macro menu {{{
-function! RedrawMacro()
-	aunmenu TeX-Suite.Macros
-	call <SID>SetCustomMacrosMenu()
-endfunction
-
-" }}}
-" ChooseMacro: choose a macro file {{{
-" " Description: 
-function! s:ChooseMacro(ask)
-	let filelist = Tex_FindInRtp('', 'macros')
-	let filename = Tex_ChooseFromPrompt(
-				\ a:ask."\n" . 
-				\ Tex_CreatePrompt(filelist, 2, ',') .
-				\ "\nEnter number or filename :",
-				\ filelist, ',')
-endfunction 
-
-" }}}
-" DeleteMacro: deletes macro file {{{
-function! <SID>DeleteMacro(...)
-	if a:0 > 0
-		let filename = a:1
-	else
-		let filename = s:ChooseMacro('Choose a macro file for deletion :')
-	endif
-
-	if !filereadable(s:macrodirpath.filename)
-	" When file is not in local directory decline to remove it.
-		call confirm('This file is not in your local directory: '.filename."\n".
-					\ 'It will not be deleted.' , '&OK', 1)
-
-	else
-		let ch = confirm('Really delete '.filename.' ?', "&Yes\n&No", 2)
-		if ch == 1
-			call delete(s:macrodirpath.filename)
-		endif
-		call RedrawMacro()
-	endif
-endfunction
-
-" }}}
-" EditMacro: edits macro file {{{
-function! <SID>EditMacro(...)
-	if a:0 > 0
-		let filename = a:1
-	else
-		let filename = s:ChooseMacro('Choose a macro file for insertion:')
-	endif
-
-	if filereadable(s:macrodirpath.filename)
-		" If file exists in local directory open it. 
-		exec 'split '.Tex_EscapeSpaces(s:macrodirpath.filename)
-	else
-		" But if file doesn't exist in local dir it probably is in user
-		" restricted area. Instead opening try to copy it to local dir.
-		" Pity VimL doesn't have mkdir() function :)
-		let ch = confirm("You are trying to edit file which is probably read-only.\n".
-					\ "It will be copied to your local LaTeX-Suite macros directory\n".
-					\ "and you will be operating on local copy with suffix -local.\n".
-					\ "It will succeed only if ftplugin/latex-suite/macros dir exists.\n".
-					\ "Do you agree?", "&Yes\n&No", 1)
-		if ch == 1
-			" But there is possibility we already created local modification.
-			" Check it and offer opening this file.
-			if filereadable(s:macrodirpath.filename.'-local')
-				let ch = confirm('Local version of '.filename." already exists.\n".
-					\ 'Do you want to open it or overwrite with original version?',
-					\ "&Open\nOver&write\n&Cancel", 1)
-				if ch == 1
-					exec 'split '.Tex_EscapeSpaces(s:macrodirpath.filename.'-local')
-				elseif ch == 2
-					new
-					exe '0read '.Tex_FindInRtp(filename, 'macros')
-					" This is possible macro was edited before, wipe it out.
-					if bufexists(s:macrodirpath.filename.'-local')
-						exe 'bwipe '.s:macrodirpath.filename.'-local'
-					endif
-					exe 'write! '.s:macrodirpath.filename.'-local'
-				else
-					return
-				endif
-			else
-			" If file doesn't exist, open new file, read in system macro and
-			" save it in local macro dir with suffix -local
-				new
-				exe '0read '.Tex_FindInRtp(filename, 'macros')
-				exe 'write '.s:macrodirpath.filename.'-local'
-			endif
-		endif
-		
-	endif
-	setlocal filetype=tex
-endfunction
-
-" }}}
-" ReadMacro: reads in a macro from a macro file.  {{{
-"            allowing for placement via placeholders.
-function! <SID>ReadMacro(...)
-
-	if a:0 > 0
-		let filename = a:1
-	else
-		let filelist = Tex_FindInRtp('', 'macros')
-		let filename = 
-					\ Tex_ChooseFromPrompt("Choose a macro file:\n" . 
-					\ Tex_CreatePrompt(filelist, 2, ',') . 
-					\ "\nEnter number or name of file :", 
-					\ filelist, ',')
-	endif
-
-	let fname = Tex_FindInRtp(filename, 'macros', ':p')
-
-	let markerString = '<---- Latex Suite End Macro ---->'
-	let _a = @a
-	silent! call append(line('.'), markerString)
-	silent! exec "read ".fname
-	silent! exec "normal! V/^".markerString."$/-1\<CR>\"ax"
-	" This is kind of tricky: At this stage, we are one line after the one we
-	" started from with the marker text on it. We need to
-	" 1. remove the marker and the line.
-	" 2. get focus to the previous line.
-	" 3. not remove anything from the previous line.
-	silent! exec "normal! $v0k$\"_x"
-
-	call Tex_CleanSearchHistory()
-
-	let @a = substitute(@a, '['."\n\r\t ".']*$', '', '')
-	let textWithMovement = IMAP_PutTextWithMovement(@a)
-	let @a = _a
-
-	return textWithMovement
-
-endfunction
-
-" }}}
-" commands for macros {{{
-com! -nargs=? TMacroNew :call <SID>NewMacro(<f-args>)
-
-" This macros had to have 2 versions:
-if v:version >= 602 
-	com! -complete=custom,Tex_CompleteMacroName -nargs=? TMacro
-				\ :let s:retVal = <SID>ReadMacro(<f-args>) <bar> normal! i<C-r>=s:retVal<CR>
-	com! -complete=custom,Tex_CompleteMacroName -nargs=? TMacroEdit
-				\ :call <SID>EditMacro(<f-args>)
-	com! -complete=custom,Tex_CompleteMacroName -nargs=? TMacroDelete
-				\ :call <SID>DeleteMacro(<f-args>)
-
-	" Tex_CompleteMacroName: for completing names in TMacro... commands {{{
-	"	Description: get list of macro names with Tex_FindInRtp(), remove full path
-	"	and return list of names separated with newlines.
-	"
-	function! Tex_CompleteMacroName(A,P,L)
-		" Get name of macros from all runtimepath directories
-		let macronames = Tex_FindInRtp('', 'macros')
-		" Separate names with \n not ,
-		let macronames = substitute(macronames,',','\n','g')
-		return macronames
-	endfunction
-
-	" }}}
-
-else
-	com! -nargs=? TMacro
-		\	:let s:retVal = <SID>ReadMacro(<f-args>) <bar> normal! i<C-r>=s:retVal<CR>
-	com! -nargs=? TMacroEdit   :call <SID>EditMacro(<f-args>)
-	com! -nargs=? TMacroDelete :call <SID>DeleteMacro(<f-args>)
-
-endif
-
-" }}}
-
-" vim:fdm=marker:ff=unix:noet:ts=4:sw=4

vim/.vim/ftplugin/latex-suite/diacritics.vim

-"=============================================================================
-" 	     File: diacritics.vim
-"      Author: Lubomir Host
-"     Created: Tue Apr 23 07:00 PM 2002 PST
-" 
-"  Description: shortcuts for all diacritics. 
-"=============================================================================
-
-if !g:Tex_Diacritics
-	finish
-endif
-
-" \'{a} {{{
-call IMAP ('=a', "\\\'{a}", 'tex')
-call IMAP ('=b', "\\'{b}", 'tex')
-call IMAP ('=c', "\\'{c}", 'tex')
-call IMAP ('=d', "\\'{d}", 'tex')
-call IMAP ('=e', "\\'{e}", 'tex')
-call IMAP ('=f', "\\'{f}", 'tex')
-call IMAP ('=g', "\\'{g}", 'tex')
-call IMAP ('=h', "\\'{h}", 'tex')
-call IMAP ('=i', "\\'{\i}", 'tex')
-call IMAP ('=j', "\\'{j}", 'tex')
-call IMAP ('=k', "\\'{k}", 'tex')
-call IMAP ('=l', "\\'{l}", 'tex')
-call IMAP ('=m', "\\'{m}", 'tex')
-call IMAP ('=n', "\\'{n}", 'tex')
-call IMAP ('=o', "\\'{o}", 'tex')
-call IMAP ('=p', "\\'{p}", 'tex')
-call IMAP ('=q', "\\'{q}", 'tex')
-call IMAP ('=r', "\\'{r}", 'tex')
-call IMAP ('=s', "\\'{s}", 'tex')
-call IMAP ('=t', "\\'{t}", 'tex')
-call IMAP ('=u', "\\'{u}", 'tex')
-call IMAP ('=v', "\\'{v}", 'tex')
-call IMAP ('=w', "\\'{w}", 'tex')
-call IMAP ('=x', "\\'{x}", 'tex')
-call IMAP ('=y', "\\'{y}", 'tex')