Updated runtime files.
diff --git a/runtime/syntax/2html.vim b/runtime/syntax/2html.vim
index 22ce731..d37ca1a 100644
--- a/runtime/syntax/2html.vim
+++ b/runtime/syntax/2html.vim
@@ -1,6 +1,6 @@
 " Vim syntax support file
 " Maintainer: Ben Fritz <fritzophrenic@gmail.com>
-" Last Change: 2010 Sep 04
+" Last Change: 2011 Jan 06
 "
 " Additional contributors:
 "
@@ -124,7 +124,18 @@
   let l:style_name = a:style_name . (a:diff_style_name == '' ? '' : ' ') . a:diff_style_name
 
   " Replace the reserved html characters
-  let formatted = substitute(substitute(substitute(substitute(substitute(formatted, '&', '\&amp;', 'g'), '<', '\&lt;', 'g'), '>', '\&gt;', 'g'), '"', '\&quot;', 'g'), "\x0c", '<hr class="PAGE-BREAK">', 'g')
+  let formatted = substitute(formatted, '&', '\&amp;',  'g')
+  let formatted = substitute(formatted, '<', '\&lt;',   'g')
+  let formatted = substitute(formatted, '>', '\&gt;',   'g')
+  let formatted = substitute(formatted, '"', '\&quot;', 'g')
+  " TODO: Use &apos; for "'"?
+
+  " Replace a "form feed" character with HTML to do a page break
+  let formatted = substitute(formatted, "\x0c", '<hr class="PAGE-BREAK">', 'g')
+
+  " Mangle modelines so Vim doesn't try to use HTML text as a modeline if
+  " editing this file in the future
+  let formatted = substitute(formatted, '\v(\s+%(vim?|ex)):', '\1\&#0058;', 'g')
 
   " Replace double spaces, leading spaces, and trailing spaces if needed
   if ' ' != s:HtmlSpace
@@ -558,9 +569,6 @@
       " level, so subtract 2 from index of first non-dash after the dashes
       " in order to get the fold level of the current fold
       let s:level = match(foldtextresult(s:lnum), '+-*\zs[^-]') - 2
-      if s:level+1 > s:foldcolumn
-	let s:foldcolumn = s:level+1
-      endif
       " store fold info for later use
       let s:newfold = {'firstline': s:lnum, 'lastline': foldclosedend(s:lnum), 'level': s:level,'type': "closed-fold"}
       call add(s:allfolds, s:newfold)
@@ -590,9 +598,6 @@
       " level, so subtract 2 from index of first non-dash after the dashes
       " in order to get the fold level of the current fold
       let s:level = match(foldtextresult(s:lnum), '+-*\zs[^-]') - 2
-      if s:level+1 > s:foldcolumn
-	let s:foldcolumn = s:level+1
-      endif
       let s:newfold = {'firstline': s:lnum, 'lastline': foldclosedend(s:lnum), 'level': s:level,'type': "closed-fold"}
       " only add the fold if we don't already have it
       if empty(s:allfolds) || index(s:allfolds, s:newfold) == -1
@@ -622,6 +627,48 @@
 
   " close all folds again so we can get the fold text as we go
   silent! %foldclose!
+
+  for afold in s:allfolds
+    let removed = 0
+    if exists("g:html_start_line") && exists("g:html_end_line")
+      if afold.firstline < g:html_start_line
+	if afold.lastline < g:html_end_line && afold.lastline > g:html_start_line
+	  " if a fold starts before the range to convert but stops within the
+	  " range, we need to include it. Make it start on the first converted
+	  " line.
+	  let afold.firstline = g:html_start_line
+	else
+	  " if the fold lies outside the range or the start and stop enclose
+	  " the entire range, don't bother parsing it
+	  call remove(s:allfolds, index(s:allfolds, afold))
+	  let removed = 1
+	endif
+      elseif afold.firstline > g:html_end_line
+	" If the entire fold lies outside the range we need to remove it.
+	call remove(s:allfolds, index(s:allfolds, afold))
+	let removed = 1
+      endif
+    elseif exists("g:html_start_line")
+      if afold.firstline < g:html_start_line
+	" if there is no last line, but there is a first line, the end of the
+	" fold will always lie within the region of interest, so keep it
+	let afold.firstline = g:html_start_line
+      endif
+    elseif exists("g:html_end_line")
+      " if there is no first line we default to the first line in the buffer so
+      " the fold start will always be included if the fold itself is included.
+      " If however the entire fold lies outside the range we need to remove it.
+      if afold.firstline > g:html_end_line
+	call remove(s:allfolds, index(s:allfolds, afold))
+	let removed = 1
+      endif
+    endif
+    if !removed
+      if afold.level+1 > s:foldcolumn
+	let s:foldcolumn = afold.level+1
+      endif
+    endif
+  endfor
 endif
 
 " Now loop over all lines in the original text to convert to html.
@@ -669,6 +716,13 @@
 
 let s:foldId = 0
 
+if !s:settings.expand_tabs
+  " If keeping tabs, add them to printable characters so we keep them when
+  " formatting text (strtrans() doesn't replace printable chars)
+  let s:old_isprint = &isprint
+  setlocal isprint+=9
+endif
+
 while s:lnum <= s:end
 
   " If there are filler lines for diff mode, show these above the line.
@@ -747,7 +801,7 @@
 	call remove(s:foldstack, 0)
       endwhile
 
-      " Now insert an opening any new folds that start on this line
+      " Now insert an opening for any new folds that start on this line
       let s:firstfold = 1
       while !empty(s:allfolds) && get(s:allfolds,0).firstline == s:lnum
 	let s:foldId = s:foldId + 1
@@ -884,30 +938,32 @@
       endif
 
       if s:settings.ignore_conceal || !s:concealinfo[0]
-	" Expand tabs
+	" Expand tabs if needed
 	let s:expandedtab = strpart(s:line, s:startcol - 1, s:col - s:startcol)
-	let s:offset = 0
-	let s:idx = stridx(s:expandedtab, "\t")
-	while s:idx >= 0
-	  if has("multi_byte_encoding")
-	    if s:startcol + s:idx == 1
-	      let s:i = &ts
-	    else
-	      if s:idx == 0
-		let s:prevc = matchstr(s:line, '.\%' . (s:startcol + s:idx + s:offset) . 'c')
-	      else
-		let s:prevc = matchstr(s:expandedtab, '.\%' . (s:idx + 1) . 'c')
-	      endif
-	      let s:vcol = virtcol([s:lnum, s:startcol + s:idx + s:offset - len(s:prevc)])
-	      let s:i = &ts - (s:vcol % &ts)
-	    endif
-	    let s:offset -= s:i - 1
-	  else
-	    let s:i = &ts - ((s:idx + s:startcol - 1) % &ts)
-	  endif
-	  let s:expandedtab = substitute(s:expandedtab, '\t', repeat(' ', s:i), '')
+	if s:settings.expand_tabs
+	  let s:offset = 0
 	  let s:idx = stridx(s:expandedtab, "\t")
-	endwhile
+	  while s:idx >= 0
+	    if has("multi_byte_encoding")
+	      if s:startcol + s:idx == 1
+		let s:i = &ts
+	      else
+		if s:idx == 0
+		  let s:prevc = matchstr(s:line, '.\%' . (s:startcol + s:idx + s:offset) . 'c')
+		else
+		  let s:prevc = matchstr(s:expandedtab, '.\%' . (s:idx + 1) . 'c')
+		endif
+		let s:vcol = virtcol([s:lnum, s:startcol + s:idx + s:offset - len(s:prevc)])
+		let s:i = &ts - (s:vcol % &ts)
+	      endif
+	      let s:offset -= s:i - 1
+	    else
+	      let s:i = &ts - ((s:idx + s:startcol - 1) % &ts)
+	    endif
+	    let s:expandedtab = substitute(s:expandedtab, '\t', repeat(' ', s:i), '')
+	    let s:idx = stridx(s:expandedtab, "\t")
+	  endwhile
+	end
 
 	" get the highlight group name to use
 	let s:id = synIDtrans(s:id)
@@ -1073,7 +1129,7 @@
 " Cleanup
 %s:\s\+$::e
 
-" Restore old settings
+" Restore old settings (new window first)
 let &l:foldenable = s:old_fen
 let &l:foldmethod = s:old_fdm
 let &report = s:old_report
@@ -1083,11 +1139,20 @@
 let &magic = s:old_magic
 let @/ = s:old_search
 let &more = s:old_more
+
+" switch to original window to restore those settings
 exe s:orgwin . "wincmd w"
+
+if !s:settings.expand_tabs
+  let &l:isprint = s:old_isprint
+endif
 let &l:stl = s:origwin_stl
 let &l:et = s:old_et
 let &l:scrollbind = s:old_bind
+
+" and back to the new window again to end there
 exe s:newwin . "wincmd w"
+
 let &l:stl = s:newwin_stl
 exec 'resize' s:old_winheight
 let &l:winfixheight = s:old_winfixheight
@@ -1098,6 +1163,7 @@
 unlet s:htmlfont
 unlet s:old_et s:old_paste s:old_icon s:old_report s:old_title s:old_search
 unlet s:old_magic s:old_more s:old_fdm s:old_fen s:old_winheight
+unlet! s:old_isprint
 unlet s:whatterm s:idlist s:lnum s:end s:margin s:fgc s:bgc s:old_winfixheight
 unlet! s:col s:id s:attr s:len s:line s:new s:expandedtab s:concealinfo
 unlet! s:orgwin s:newwin s:orgbufnr s:idx s:i s:offset s:ls s:origwin_stl
diff --git a/runtime/syntax/xquery.vim b/runtime/syntax/xquery.vim
index dcb2685..129a283 100644
--- a/runtime/syntax/xquery.vim
+++ b/runtime/syntax/xquery.vim
@@ -1,10 +1,11 @@
 " Vim syntax file
 " Language:	XQuery
-" Author:	Jean-Marc Vanel <http://jmvanel.free.fr/>
-" Last Change:	mar jui 12 18:04:05 CEST 2005
+" Author: René Neumann <necoro@necoro.eu>
+" Author: Steve Spigarelli <http://spig.net/>
+" Original Author:	Jean-Marc Vanel <http://jmvanel.free.fr/>
+" Last Change:	December 11, 2010
 " Filenames:	*.xq
 " URL:		http://jmvanel.free.fr/vim/xquery.vim
-" $Id: xquery.vim,v 1.1 2005/07/18 21:44:56 vimboss Exp $
 
 " REFERENCES:
 "   [1] http://www.w3.org/TR/xquery/
@@ -14,22 +15,26 @@
     finish
 endif
 
+" - is allowed in keywords
+setlocal iskeyword+=-
+
 runtime syntax/xml.vim
 
 syn case match
 
 " From XQuery grammar:
-syn	keyword	xqueryStatement ancestor ancestor-or-self and as ascending at attribute base-uri by case cast castable child collation construction declare default descendant descendant-or-self descending div document element else empty encoding eq every except external following following-sibling for function ge greatest gt idiv if import in inherit-namespaces instance intersect is le least let lt mod module namespace ne no of or order ordered ordering parent preceding preceding-sibling preserve return satisfies schema self some stable strip then to treat typeswitch union unordered validate variable version where xmlspace xquery yes
+syn keyword xqStatement ancestor ancestor-or-self and as ascending at attribute base-uri boundary-space by case cast castable child collation construction declare default descendant descendant-or-self descending div document element else empty encoding eq every except external following following-sibling for function ge greatest gt idiv if import in inherit-namespaces instance intersect is le least let lt mod module namespace ne no of or order ordered ordering parent preceding preceding-sibling preserve return satisfies schema self some stable strip then to treat typeswitch union unordered validate variable version where xmlspace xquery yes
 
 " TODO contains clashes with vim keyword
-syn	keyword	xqueryFunction abs adjust-date-to-timezone adjust-date-to-timezone adjust-dateTime-to-timezone adjust-dateTime-to-timezone adjust-time-to-timezone adjust-time-to-timezone avg base-uri base-uri boolean ceiling codepoint-equal codepoints-to-string collection collection compare concat count current-date current-dateTime current-time data dateTime day-from-date day-from-dateTime days-from-duration deep-equal deep-equal default-collation distinct-values distinct-values doc doc-available document-uri empty ends-with ends-with error error error error escape-uri exactly-one exists false floor hours-from-dateTime hours-from-duration hours-from-time id id idref idref implicit-timezone in-scope-prefixes index-of index-of insert-before lang lang last local-name local-name local-name-from-QName lower-case matches matches max max min min minutes-from-dateTime minutes-from-duration minutes-from-time month-from-date month-from-dateTime months-from-duration name name namespace-uri namespace-uri namespace-uri-for-prefix namespace-uri-from-QName nilled node-name normalize-space normalize-space normalize-unicode normalize-unicode not number number one-or-more position prefix-from-QName QName remove replace replace resolve-QName resolve-uri resolve-uri reverse root root round round-half-to-even round-half-to-even seconds-from-dateTime seconds-from-duration seconds-from-time starts-with starts-with static-base-uri string string string-join string-length string-length string-to-codepoints subsequence subsequence substring substring substring-after substring-after substring-before substring-before sum sum timezone-from-date timezone-from-dateTime timezone-from-time tokenize tokenize trace translate true unordered upper-case year-from-date year-from-dateTime years-from-duration zero-or-one
+syn	keyword	xqFunction abs adjust-date-to-timezone adjust-date-to-timezone adjust-dateTime-to-timezone adjust-dateTime-to-timezone adjust-time-to-timezone adjust-time-to-timezone avg base-uri base-uri boolean ceiling codepoint-equal codepoints-to-string collection collection compare concat count current-date current-dateTime current-time data dateTime day-from-date day-from-dateTime days-from-duration deep-equal deep-equal default-collation distinct-values distinct-values doc doc-available document-uri empty ends-with ends-with error error error error escape-uri exactly-one exists false floor hours-from-dateTime hours-from-duration hours-from-time id id idref idref implicit-timezone in-scope-prefixes index-of index-of insert-before lang lang last local-name local-name local-name-from-QName lower-case matches matches max max min min minutes-from-dateTime minutes-from-duration minutes-from-time month-from-date month-from-dateTime months-from-duration name name namespace-uri namespace-uri namespace-uri-for-prefix namespace-uri-from-QName nilled node-name normalize-space normalize-space normalize-unicode normalize-unicode not number number one-or-more position prefix-from-QName QName remove replace replace resolve-QName resolve-uri resolve-uri reverse root root round round-half-to-even round-half-to-even seconds-from-dateTime seconds-from-duration seconds-from-time starts-with starts-with static-base-uri string string string-join string-length string-length string-to-codepoints subsequence subsequence substring substring substring-after substring-after substring-before substring-before sum sum timezone-from-date timezone-from-dateTime timezone-from-time tokenize tokenize trace translate true unordered upper-case year-from-date year-from-dateTime years-from-duration zero-or-one
 
-syn	keyword	xqueryOperator add-dayTimeDuration-to-date add-dayTimeDuration-to-dateTime add-dayTimeDuration-to-time add-dayTimeDurations add-yearMonthDuration-to-date add-yearMonthDuration-to-dateTime add-yearMonthDurations base64Binary-equal boolean-equal boolean-greater-than boolean-less-than concatenate date-equal date-greater-than date-less-than dateTime-equal dateTime-greater-than dateTime-less-than dayTimeDuration-equal dayTimeDuration-greater-than dayTimeDuration-less-than divide-dayTimeDuration divide-dayTimeDuration-by-dayTimeDuration divide-yearMonthDuration divide-yearMonthDuration-by-yearMonthDuration except gDay-equal gMonth-equal gMonthDay-equal gYear-equal gYearMonth-equal hexBinary-equal intersect is-same-node multiply-dayTimeDuration multiply-yearMonthDuration node-after node-before NOTATION-equal numeric-add numeric-divide numeric-equal numeric-greater-than numeric-integer-divide numeric-less-than numeric-mod numeric-multiply numeric-subtract numeric-unary-minus numeric-unary-plus QName-equal subtract-dates-yielding-dayTimeDuration subtract-dateTimes-yielding-dayTimeDuration subtract-dayTimeDuration-from-date subtract-dayTimeDuration-from-dateTime subtract-dayTimeDuration-from-time subtract-dayTimeDurations subtract-times subtract-yearMonthDuration-from-date subtract-yearMonthDuration-from-dateTime subtract-yearMonthDurations time-equal time-greater-than time-less-than to union yearMonthDuration-equal yearMonthDuration-greater-than yearMonthDuration-less-than
+syn keyword xqOperator add-dayTimeDuration-to-date add-dayTimeDuration-to-dateTime add-dayTimeDuration-to-time add-dayTimeDurations add-yearMonthDuration-to-date add-yearMonthDuration-to-dateTime add-yearMonthDurations base64Binary-equal boolean-equal boolean-greater-than boolean-less-than concatenate date-equal date-greater-than date-less-than dateTime-equal dateTime-greater-than dateTime-less-than dayTimeDuration-equal dayTimeDuration-greater-than dayTimeDuration-less-than divide-dayTimeDuration divide-dayTimeDuration-by-dayTimeDuration divide-yearMonthDuration divide-yearMonthDuration-by-yearMonthDuration except gDay-equal gMonth-equal gMonthDay-equal gYear-equal gYearMonth-equal hexBinary-equal intersect is-same-node multiply-dayTimeDuration multiply-yearMonthDuration node-after node-before NOTATION-equal numeric-add numeric-divide numeric-equal numeric-greater-than numeric-integer-divide numeric-less-than numeric-mod numeric-multiply numeric-subtract numeric-unary-minus numeric-unary-plus QName-equal subtract-dates-yielding-dayTimeDuration subtract-dateTimes-yielding-dayTimeDuration subtract-dayTimeDuration-from-date subtract-dayTimeDuration-from-dateTime subtract-dayTimeDuration-from-time subtract-dayTimeDurations subtract-times subtract-yearMonthDuration-from-date subtract-yearMonthDuration-from-dateTime subtract-yearMonthDurations time-equal time-greater-than time-less-than to union yearMonthDuration-equal yearMonthDuration-greater-than yearMonthDuration-less-than
 
-syn	match	xqueryType "xs:\(\|Datatype\|primitive\|string\|boolean\|float\|double\|decimal\|duration\|dateTime\|time\|date\|gYearMonth\|gYear\|gMonthDay\|gDay\|gMonth\|hexBinary\|base64Binary\|anyURI\|QName\|NOTATION\|\|normalizedString\|token\|language\|IDREFS\|ENTITIES\|NMTOKEN\|NMTOKENS\|Name\|NCName\|ID\|IDREF\|ENTITY\|integer\|nonPositiveInteger\|negativeInteger\|long\|int\|short\|byte\|nonNegativeInteger\|unsignedLong\|unsignedInt\|unsignedShort\|unsignedByte\|positiveInteger\)"
+syn match xqType "xs:\(\|Datatype\|primitive\|string\|boolean\|float\|double\|decimal\|duration\|dateTime\|time\|date\|gYearMonth\|gYear\|gMonthDay\|gDay\|gMonth\|hexBinary\|base64Binary\|anyURI\|QName\|NOTATION\|\|normalizedString\|token\|language\|IDREFS\|ENTITIES\|NMTOKEN\|NMTOKENS\|Name\|NCName\|ID\|IDREF\|ENTITY\|integer\|nonPositiveInteger\|negativeInteger\|long\|int\|short\|byte\|nonNegativeInteger\|unsignedLong\|unsignedInt\|unsignedShort\|unsignedByte\|positiveInteger\)"
+
 
 " From XPath grammar:
-syn	keyword	xqueryXPath some every in in satisfies if then else to div idiv mod union intersect except instance of treat castable cast eq ne lt le gt ge is child descendant attribute self descendant-or-self following-sibling following namespace parent ancestor preceding-sibling preceding ancestor-or-self void item node document-node text comment processing-instruction attribute schema-attribute schema-element
+syn keyword xqXPath some every in in satisfies if then else to div idiv mod union intersect except instance of treat castable cast eq ne lt le gt ge is child descendant attribute self descendant-or-self following-sibling following namespace parent ancestor preceding-sibling preceding ancestor-or-self void item node document-node text comment processing-instruction attribute schema-attribute schema-element
 
 " eXist extensions
 syn	match xqExist "&="
@@ -37,44 +42,41 @@
 " XQdoc
 syn	match	XQdoc contained "@\(param\|return\|author\)\>" 
 
-highlight def link	xqueryStatement	Statement
-highlight def link	xqueryFunction	Function
-highlight def link	xqueryOperator	Operator
-highlight def link	xqueryType		Type
-highlight def link	xqueryXPath		Operator
-highlight def link	XQdoc			Special
-highlight def link	xqExist			Operator
+" floating point number, with dot, optional exponent
+syn match xqFloat   "\d\+\.\d*\(e[-+]\=\d\+\)\=[fl]\="
+" floating point number, starting with a dot, optional exponent
+syn match xqFloat   "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>"
+" floating point number, without dot, with exponent
+syn match xqFloat   "\d\+e[-+]\=\d\+[fl]\=\>"
+syn match xqNumber  "0x\x\+\(u\=l\{0,2}\|ll\=u\)\>"
+syn match xqNumber  "\<\d\+\>"
 
+syn region xqString  start=+"+ end=+"+
+syn region xqComment start='(:' excludenl end=':)' contains=XQdoc
 
-"floating point number, with dot, optional exponent
-syn match	cFloat		"\d\+\.\d*\(e[-+]\=\d\+\)\=[fl]\="
-"floating point number, starting with a dot, optional exponent
-syn match	cFloat		"\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>"
-"floating point number, without dot, with exponent
-syn match	cFloat		"\d\+e[-+]\=\d\+[fl]\=\>"
-syn match	cNumber		"0x\x\+\(u\=l\{0,2}\|ll\=u\)\>"
-syn match	cNumber		 "\<\d\+\>"
-highlight def link	cNumber	Number
-highlight def link	cFloat	Number
-
-syn region	xqComment	start='(:' excludenl end=':)' contains=XQdoc
-highlight def link	xqComment	Comment
-" syntax match	xqVariable	"$\w\+"
-syntax match	xqVariable	+$\<[a-zA-Z:_][-.0-9a-zA-Z0-9:_]*\>+
-highlight def link	xqVariable	Identifier
-
-" Redefine the default XML highlighting:
-highlight def link	xmlTag		Structure
-highlight def link	xmlTagName	Structure
-highlight def link	xmlEndTag	Structure
-
-syntax match	xqSeparator	",\|;"
-highlight link	xqSeparator	Operator
-
-syn region	xqCode	transparent contained start='{' excludenl end='}' contains=xmlRegionBis,xqComment,xqueryStatement,xmlString,xqSeparator,cNumber,xqVariable keepend extend
+syn match xqVariable "$\<[a-zA-Z:_][-.0-9a-zA-Z0-9:_]*\>"
+syn match xqSeparator ",\|;"
+syn region xqCode transparent contained start='{' excludenl end='}' contains=xqFunction,xqCode,xmlRegionBis,xqComment,xqStatement,xmlString,xqSeparator,xqNumber,xqVariable,xqString keepend extend
 
 syn region xmlRegionBis start=+<\z([^ /!?<>"']\+\)+ skip=+<!--\_.\{-}-->+ end=+</\z1\_\s\{-}>+ end=+/>+ fold contains=xmlTag,xmlEndTag,xmlCdata,xmlRegionBis,xmlComment,xmlEntity,xmlProcessing,xqCode keepend extend
 
-syn region	List	transparent start='(' excludenl end=')' contains=xqCode,xmlRegion,xqComment,xqSeparator,xqueryStatement,xqVariable,xqueryType  keepend extend
+hi def link xqNumber    Number
+hi def link xqFloat     Number
+hi def link xqString    String
+hi def link xqVariable  Identifier
+hi def link xqComment   Comment
+hi def link xqSeparator Operator
+hi def link xqStatement Statement
+hi def link xqFunction  Function
+hi def link xqOperator  Operator
+hi def link xqType      Type
+hi def link xqXPath     Operator
+hi def link XQdoc       Special
+hi def link xqExist     Operator
 
+" override the xml highlighting
+"hi link xmlTag      Structure
+"hi link xmlTagName  Structure
+"hi link xmlEndTag   Structure
 
+let b:current_syntax = "xquery"