[Vim-latex-cvs] vimfiles/ftplugin/latex-suite bibtex.vim,1.4,1.5
Brought to you by:
srinathava,
tmaas
|
From: <sri...@us...> - 2003-06-15 08:23:18
|
Update of /cvsroot/vim-latex/vimfiles/ftplugin/latex-suite
In directory sc8-pr-cvs1:/tmp/cvs-serv28548
Modified Files:
bibtex.vim
Log Message:
Changed structure of bibtex.vim to look more ``modular''. Still don't know
if this is a good idea. Might revert to older revision in the future.
Feature: added way to customize the fields which are applied via the
mappings.
Index: bibtex.vim
===================================================================
RCS file: /cvsroot/vim-latex/vimfiles/ftplugin/latex-suite/bibtex.vim,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** bibtex.vim 12 Jan 2003 22:02:36 -0000 1.4
--- bibtex.vim 15 Jun 2003 08:23:14 -0000 1.5
***************
*** 3,8 ****
--- 3,125 ----
" Function: BibT
" Author: Alan G Isaac <ai...@am...>
+ " modified by Srinath Avadhanula <srinath AT fastmail DOT fm>
+ " for latex-suite.
+ " License: Vim Charityware license.
+ " CVS: $Id$
"=============================================================================
+ " 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
***************
*** 10,16 ****
let s:done = 1
! call IMAP ('BBA', "\<C-r>=BibT('article', '', 0)\<CR>", 'bib')
! call IMAP ('BBB', "\<C-r>=BibT('inproceedings', '', 0)\<CR>", 'bib')
! call IMAP ('BAS', "\<C-r>=BibT('', '', 0)\<CR>", 'bib')
" BibT: function to generate a formatted bibtex entry {{{
--- 127,134 ----
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 {{{
***************
*** 20,36 ****
" :call BibT("article","ox") more optional fields (o) and extras (x)
"
function BibT(type, options, prompt)
if a:type != ''
let choosetype = a:type
else
! let choosetype=input("Enter type (type in whole word!):\n".
! \" article\tbooklet\t\tbook\t\tconference\n".
! \" inbook\t\tincollection\tinproceedings\tmanual\n".
! \" msthesis\tmisc\t\tphdthesis\tproceedings\n".
! \" techreport\tunpublished\n\n:"
! \)
if choosetype == ''
let choosetype = 'article'
endif
endif
if a:options != ''
--- 138,186 ----
" :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 != ''
***************
*** 43,250 ****
let extras=""
let retval = ""
- let key='<+key+>'
-
- " characterize entry types
- if choosetype ==? "article"
- let required="atjy"
- let optional1="vnpm"
- let optional2="z" " z is note
- let retval = retval.'@ARTICLE{' . key . ','."\n"
- endif
- if choosetype ==? "book"
- let required="ætqy" " requires author *or* editor
- let optional1="wd"
- let optional2="vnsmz" " w is address, d is edition
- let extras="k" " isbn
- let retval = retval.'@BOOK{' . key . ','."\n"
- endif
- if choosetype ==? "booklet"
- let required="t"
- let optional1="ahy"
- let optional2="wmz" " w is address
- let retval = retval.'@BOOKLET{' . key . ','."\n"
- endif
- if choosetype ==? "inbook"
- let required="ætcpqy"
- let optional1="w" " w is address
- let optional2="vnsudmz" " d is edition
- let extras="k" " isbn
- let retval = retval.'@INBOOK{' . key . ','."\n"
- endif
- if choosetype ==? "incollection"
- let required="atbqy" " b is booktitle
- let optional1="cpw" " w is address, c is chapter
- let optional2="evnsudmz" " d is edition
- let extras="k" " isbn
- let retval = retval.'@INCOLLECTION{' . key . ','."\n"
- endif
- if choosetype ==? "inproceedings"
- let required="atby" " b is booktitle
- let optional1="epwoq" " w is address, q is publisher
- let optional2="vnsmz"
- let extras="k" " isbn
- let retval = retval.'@INPROCEEDINGS{' . key . ','."\n"
- endif
- if choosetype ==? "manual"
- let required="t"
- let optional1="ow"
- let optional2="admyz" " w is address
- let retval = retval.'@MANUAL{' . key . ','."\n"
- endif
- if choosetype ==? "msthesis"
- let required="atry" " r is school
- let optional1="w" " w is address
- let optional2="umz" " u is type, w is address
- let retval = retval.'@MASTERSTHESIS{' . key . ','."\n"
- endif
- if choosetype ==? "misc"
- let required=""
- let optional1="ath"
- let optional2="myz"
- let retval = retval.'@MISC{' . key . ','."\n"
- endif
- if choosetype ==? "phdthesis"
- let required="atry" " r is school
- let optional1="w" " w is address
- let optional2="umz" " u is type
- let retval = retval.'@PHDTHESIS{' . key . ','."\n"
- endif
- if choosetype ==? "proceedings"
- let required="ty"
- let optional1="ewo" " w is address
- let optional2="vnsmqz" " q is publisher
- let retval = retval.'@PROCEEDINGS{' . key . ','."\n"
- endif
- if choosetype ==? "techreport"
- let required="atiy"
- let optional1="unw" " u is type, w is address
- let optional2="mz"
- let retval = retval.'@TECHREPORT{' . key . ','."\n"
- endif
- if choosetype ==? "unpublished"
- let required="atz"
- let optional1="y"
- let optional2="m"
- let retval = retval.'@UNPUBLISHED{' . key . ','."\n"
- endif
" define fields
! let fields = required
! if options =~ 'o'
! let fields = fields . optional1
endif
! if options =~ "O"
! if options !~ 'o'
! let fields = fields . optional1
endif
! let fields = fields . optional2
endif
! if options =~ "x"
let fields = fields . extras
endif
!
! " implement fields
! if fields =~ "[aæ]"
! let author=s:Input("Author(s)? ", a:prompt)
! if author!="" || required =~ "a"
! let retval = retval.'author = {' . author . '},'."\n"
! endif
! endif
! if fields =~ "[eæ]"
! let editor=s:Input("Editor(s)? ", a:prompt)
! if editor!="" || required =~ "e"
! let retval = retval.'editor = {' . editor . '},'."\n"
! endif
! endif
! if fields =~ "y"
! let year=s:Input("Year? ", a:prompt)
! let retval = retval.'year = ' . year . ','."\n"
! endif
! if fields =~ "t"
! let title=s:Input("title? ", a:prompt)
! let retval = retval.'title = {' . title . '},'."\n"
! endif
! if fields =~ "b" " booktitle
! let booktitle=s:Input("booktitle? ", a:prompt)
! let retval = retval.'booktitle = {' . booktitle . '},'."\n"
! endif
! if fields =~ "d" " edition
! let edition=s:Input("edition? (E.g., 2nd) ", a:prompt)
! let retval = retval.'edition = {' . edition . '},'."\n"
! endif
! if fields =~ "c" " chapter
! let chapter=s:Input("chapter? ", a:prompt)
! if chapter !=""
! let retval = retval.'chapter = {' . chapter . '},'."\n"
! endif
! endif
! if fields =~ "j" " journal
! let jrnlkey=s:Input("{Journal Name} (in braces) or journal key? ", a:prompt)
! if jrnlkey != ""
! let retval = retval.'journal = ' . jrnlkey . ','."\n"
! else
! let retval = retval.'journal = {},'."\n"
! endif
! endif
! if fields =~ "v"
! let volume=s:Input("volume? ", a:prompt)
! if volume !=""
! let retval = retval.'volume = ' . volume . ','."\n"
! endif
! endif
! if fields =~ "n"
! let number=s:Input("number? ", a:prompt)
! if number !=""
! let retval = retval.'number = ' . number . ','."\n"
! endif
! endif
! if fields =~ "m"
! let month=s:Input("month? ", a:prompt)
! if month !=""
! let retval = retval.'month = ' . month . ','."\n"
! endif
! endif
! if fields =~ "p"
! let pages=s:Input("pages? ", a:prompt)
! let retval = retval.'pages = {' . pages . '},'."\n"
! endif
! if fields =~ "q"
! let publisher=s:Input("publisher? ", a:prompt)
! let retval = retval.'publisher = {' . publisher . '},'."\n"
! endif
! if fields =~ "w"
! let address=s:Input("address? ", a:prompt)
! let retval = retval.'address = {' . address . '},'."\n"
! endif
! if fields =~ "h"
! let howpublished=s:Input("howpublished? ", a:prompt)
! let retval = retval.'howpublished = {' . howpublished . '},'."\n"
! endif
! if fields =~ "i"
! let institution=s:Input("institution? ", a:prompt)
! let retval = retval.'institution = {' . institution . '},'."\n"
! endif
! if fields =~ "o"
! let organization=s:Input("organization? ", a:prompt)
! let retval = retval.'organization = {' . organization . '},'."\n"
! endif
! if fields =~ "r"
! let school=s:Input("school? ", a:prompt)
! let retval = retval.'school = {' . school . '},'."\n"
! endif
! if fields =~ "s"
! let series=s:Input("series? ", a:prompt)
! let retval = retval.'series = {' . series . '},'."\n"
! endif
! if fields =~ "u"
! let type=s:Input("type? (E.g., Working Paper)", a:prompt)
! let retval = retval.'type = {' . type . '},'."\n"
endif
! if fields =~ "k"
! let isbn=s:Input("isbn? ", a:prompt)
! if isbn !=""
! let retval = retval.'isbn = {' . isbn . '},'."\n"
endif
! endif
let retval = retval.'otherinfo = {<++>}'."\n"
let retval = retval."}<++>"."\n"
--- 193,227 ----
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
let retval = retval.'otherinfo = {<++>}'."\n"
let retval = retval."}<++>"."\n"
|