updated for version 7.0072
diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt
index d1de9db..8c078ee 100644
--- a/runtime/doc/syntax.txt
+++ b/runtime/doc/syntax.txt
@@ -1,4 +1,4 @@
-*syntax.txt*	For Vim version 7.0aa.  Last change: 2005 Apr 01
+*syntax.txt*	For Vim version 7.0aa.  Last change: 2005 May 18
 
 
 		  VIM REFERENCE MANUAL	  by Bram Moolenaar
@@ -1579,6 +1579,14 @@
   mv_finance	 mv_logic	mv_powseries
 
 
+MATHEMATICA			*mma.vim* *mma-syntax* *mathematica-syntax*
+
+Empty *.m files will automatically be presumed to be Matlab files unless you
+have the following in your .vimrc: >
+
+	let filetype_m = "mma"
+
+
 MOO						*moo.vim* *moo-syntax*
 
 If you use C-style comments inside expressions and find it mangles your
diff --git a/runtime/doc/todo.txt b/runtime/doc/todo.txt
index 9645fe5..4af8d96 100644
--- a/runtime/doc/todo.txt
+++ b/runtime/doc/todo.txt
@@ -1,4 +1,4 @@
-*todo.txt*      For Vim version 7.0aa.  Last change: 2005 Apr 24
+*todo.txt*      For Vim version 7.0aa.  Last change: 2005 May 18
 
 
 		  VIM REFERENCE MANUAL	  by Bram Moolenaar
@@ -30,33 +30,46 @@
 							*known-bugs*
 -------------------- Known bugs and current work -----------------------
 
-This doesn't work: "a[var1:var2]".  Requires space before/after ':'.  Can this
-be fixed?  Otherwise document it.
-
-regmatch(): "regstack" could start with a fixed block of data for speed.
-"backpos" is never freed. (Alexei Alexandrov)
-
-Starting without any buffers, set nocp, ":b <Tab>" gives error message.
-(Ciaran McCressh for Aron Griffis)
-
 Problem with 'insertmode'. (Georg Dahn, 2005 April 9, expl. April 14)
 Problem with CTRL-V pasting more than one line. (Georg Dahn, 2005 April 11)
 
 Patch for setqflist() (Yegappan Lakshmanan, 2005 April 11)
 
+":help \=<Tab>" doesn't find "sub-replace-\=".
+
 In an errorfile expand "~/" to home directory. (Arnout Engelen)
 
 Patch for 2html.vim to disable folding (Michael Schaap, 2005 April 12)
 
 Win32: Alt-F10 no longer working? (Bill McCarthy, April 18)
 
+Patch for if_python to make exit work better with threads. (ugo)
+
 With "wa" in 'formatoptions', backspace at start-of-line doesn't work.  It
 should delete the space at the end of the previous line. (Alan Isaac)
 
+GTK GUI: Running a script that does :vsp and :quit, causing the left scrollbar
+to appear and disappear, causes resizing. (gvcolors.vim from Charles Campbell,
+2005 April 25)
+
+Problem with ":mksession" for "vim -o "+argdel *" prog1 prog2 prog3"
+(Bill McCarthy, 2005 April 26)
+
+getreg('=') returns the result of evaluating the expression.  How to get the
+expression itself, so that it can be restored? (David Fishburn)  Perhaps use
+getreg('=', 1).  Also make setreg('=') work then.
+
+Win32: With the taskbar at the top of the screen, scrolling doesn't redraw
+properly. (Sergey Khorev, 2005 April 27)
+
 Mac unicode patch (Da Woon Jung):
 - selecting proportional font breaks display
 - UTF-8 text causes display problems.  Font replacement causes this.
 
+When 'shortmess' is empty and 'keymap' set to accents, in Insert mode CTRL-N
+may cause the hit-enter prompt.  Typing 'a then doesn't result in the accented
+character. (Ilya Dogolazky)
+
 autoload:
 - Add a Vim script in $VIMRUNTIME/tools that takes a file with a list of
   script names and a help file and produces a script that can be sourced to
@@ -74,9 +87,17 @@
     Add has("balloon_multiline")
 
 setline() should accept a List.
+
+smsg() uses IObuff.  The checks for the result not fitting are complicated,
+find another solution.  Add vsnprintf() and snprintf() functions?
+    http://www.ijs.si/software/snprintf/
+
 Add ":[range]sort" command.  Sort on specified field, using a regexp?  Remove
 duplicates?
 
+Patch to alternate fold highlighting.  (Anthony Iano-Fletcher, 2005 May 12)
+More levels?
+
 Awaiting response:
 -   Patch for mch_FullName() also in Vim 6.3?  os_mswin.c
 -   Win32: tearoff menu window should have a scrollbar when it's taller than
@@ -90,6 +111,8 @@
 
 -   Add SPELLCHECKER, with support for many languages.
     - Use "engspchk" from Charles Campbell for ideas.
+    - Is it worth trying the trie structure (see code from Olaf Seibert, 2005
+      May 9)
     - Spell checking code todo's:
 	- Implement user and project word lists.  Commands to add words and to
 	  mark words as wrong.
@@ -265,6 +288,9 @@
 
 Adjust src/main.aap for installing manpages like in Makefile.
 
+Also generate the .pdb file that can be used to generate a useful crash report
+on MS-Windows. (George Reilly)
+
 Add strtol() to avoid the problems with leading zero causing octal conversion.
 
 Try new POSIX tests, made after my comments. (Geoff Clare, 2005 April 7)
@@ -323,8 +349,6 @@
 
 Awaiting updated patches:
     --- awaiting updated patch ---
-    8   Add GTK 2.3 file dialog support.  Patch by Grahame Bowland, 2004 Mar
-	15, but it doesn't use "initdir" or "dflt". (will update patch)
     8   Add ":n" to fnamemodify(): normalize path, remove "../" when possible.
 	Aric Blumer has a patch for this.
 	He will update the patch for 6.3.
@@ -2104,6 +2128,7 @@
     changing the buffer name.
 8   Add ScriptReadCmd event: used to load remote Vim scripts, e.g.
     "vim -u http://mach/path/vimrc".
+7   Add TagJump event: do something after jumping to a tag.
 8   Use another option than 'updatetime' for the CursorHold event.  The two
     things are unrelated for the user (but the implementation is more
     difficult).
@@ -2786,7 +2811,7 @@
 7   From xvim: Allow a newline in search patterns (also for :s, can delete
     newline).  Add BOW, EOW, NEWL, NLORANY, NLBUTANY, magic 'n' and 'r', etc.
     [not in xvim:] Add option to switch on matches crossing ONE line boundary.
-7   Add ":iselect", a combination of ":ilist" and ":tselect". (Aaron)
+7   Add ":iselect", a combination of ":ilist" and ":tselect". (Aaron) (Zellner)
     Also ":dselect".
 
 
@@ -3334,8 +3359,6 @@
     changes all together instead of for each command (e.g. for the rot13
     macro).
 -   Add command like "[I" that also shows the tree of included files.
--   Add command like ":ts" that shows the output of "[I" and asks for a match
-    to jump to. (Zellner)
 -   ":set sm^L" results in ":set s", because short names of options are also
     expanded.  Is there a better way to do this?
 -   Add ":@!" command, to ":@" like what ":source!" is to ":source".
diff --git a/runtime/doc/various.txt b/runtime/doc/various.txt
index 0a6097e..3ec22c2 100644
--- a/runtime/doc/various.txt
+++ b/runtime/doc/various.txt
@@ -400,13 +400,13 @@
 :redi[r] @{a-zA-Z}	Redirect messages to register {a-z}.  Append to the
 			contents of the register if its name is given
 			uppercase {A-Z}.  {not in Vi}
-:redi[r] @{a-z}>	Append messages to register {a-z}. {not in Vi}
+:redi[r] @{a-z}>>	Append messages to register {a-z}. {not in Vi}
 
 :redi[r] @*		Redirect messages to the clipboard. {not in Vi}
-:redi[r] @*>		Append messages to the clipboard. {not in Vi}
+:redi[r] @*>>		Append messages to the clipboard. {not in Vi}
 
 :redi[r] @"		Redirect messages to the unnamed register. {not in Vi}
-:redi[r] @">		Append messages to the unnamed register. {not in Vi}
+:redi[r] @">>		Append messages to the unnamed register. {not in Vi}
 
 :redi[r] => {var}	Redirect messages to a variable.  If the variable
 			doesn't exist, then it is created.  If the variable
diff --git a/runtime/doc/version7.txt b/runtime/doc/version7.txt
index 4de0375..9322567 100644
--- a/runtime/doc/version7.txt
+++ b/runtime/doc/version7.txt
@@ -1,4 +1,4 @@
-*version7.txt*  For Vim version 7.0aa.  Last change: 2005 Apr 24
+*version7.txt*  For Vim version 7.0aa.  Last change: 2005 May 18
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -619,6 +619,9 @@
 
 Added the "%s" item to 'errorformat'. (Yegappan Lakshmanan)
 
+GTK GUI: use the GTK file dialog when it's available.  Mix from patches by
+Grahame Bowland and Evan Webb.
+
 ==============================================================================
 COMPILE TIME CHANGES					*compile-changes-7*
 
@@ -1059,4 +1062,10 @@
 When in diff mode and making a change that causes the "changed" highlighting
 to disappear or reappear, it was still highlighted in another window.
 
+When a ":next" command fails because the user selects "Abort" at the ATTENTION
+prompt the argument index was advanced anyway.
+
+When "~" is in 'iskeyword' the "gd" doesn't work, it's used for the previous
+substitute pattern.  Put "\V" in the pattern to avoid that.
+
  vim:tw=78:ts=8:ft=help:norl:
diff --git a/runtime/filetype.vim b/runtime/filetype.vim
index 21bcd7e..4d561f2 100644
--- a/runtime/filetype.vim
+++ b/runtime/filetype.vim
@@ -1,7 +1,7 @@
 " Vim support file to detect file types
 "
 " Maintainer:	Bram Moolenaar <Bram@vim.org>
-" Last Change:	2005 Apr 13
+" Last Change:	2005 May 18
 
 " Listen very carefully, I will say this only once
 if exists("did_load_filetypes")
@@ -822,7 +822,11 @@
     endif
     let n = n + 1
   endwhile
-  setf matlab
+  if exists("g:filetype_m")
+    exe "setf " . g:filetype_m
+  else
+    setf matlab
+  endif
 endfun
 
 " Maya Extension Language
@@ -1435,8 +1439,14 @@
 au BufNewFile,BufRead .slrnrc			setf slrnrc
 au BufNewFile,BufRead *.score			setf slrnsc
 
-" Smalltalk
-au BufNewFile,BufRead *.st,*.cls		setf st
+" Smalltalk (and TeX)
+au BufNewFile,BufRead *.st			setf st
+au BufNewFile,BufRead *.cls
+	\ if getline(1) =~ '^%' |
+	\  setf tex |
+	\ else |
+	\  setf st |
+	\ endif
 
 " Smarty templates
 au BufNewFile,BufRead *.tpl			setf smarty
diff --git a/runtime/indent/mma.vim b/runtime/indent/mma.vim
new file mode 100644
index 0000000..703e7da
--- /dev/null
+++ b/runtime/indent/mma.vim
@@ -0,0 +1,75 @@
+" Vim indent file
+" Language:     Mathematica
+" Author:       steve layland <layland@wolfram.com>
+" Last Change:  Sat May  10 18:56:22 CDT 2005
+" Source:       http://vim.sourceforge.net/scripts/script.php?script_id=1274
+"               http://members.wolfram.com/layland/vim/indent/mma.vim
+"
+" NOTE:
+" Empty .m files will automatically be presumed to be Matlab files
+" unless you have the following in your .vimrc:
+"
+"       let filetype_m="mma"
+"
+" Credits:
+" o steve hacked this out of a random indent file in the Vim 6.1 
+"   distribution that he no longer remembers...sh.vim?  Thanks!
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+    finish
+endif
+let b:did_indent = 1
+
+setlocal indentexpr=GetMmaIndent()
+setlocal indentkeys+=0[,0],0(,0)
+setlocal nosi "turn off smart indent so we don't over analyze } blocks
+
+if exists("*GetMmaIndent")
+    finish
+endif
+
+function GetMmaIndent()
+   
+    " Hit the start of the file, use zero indent.
+    if v:lnum == 0
+        return 0
+    endif
+
+     " Find a non-blank line above the current line.
+    let lnum = prevnonblank(v:lnum - 1)
+   
+    " use indenting as a base 
+    let ind = indent(v:lnum)
+    let lnum = v:lnum
+    
+    " if previous line has an unmatched bracket, or ( indent.
+    " doesn't do multiple parens/blocks/etc...
+    
+    " also, indent only if this line if this line isn't starting a new
+    " block... TODO - fix this with indentkeys?
+    if getline(v:lnum-1) =~ '\\\@<!\%(\[[^\]]*\|([^)]*\|{[^}]*\)$' && getline(v:lnum) !~ '\s\+[\[({]'
+        let ind = ind+&sw
+    endif
+
+    " if this line had unmatched closing block, 
+    " indent to the matching opening block
+    if getline(v:lnum) =~ '[^[]*]\s*$'
+        " move to the closing bracket
+        call search(']','bW')
+        " and find it's partner's indent
+        let ind = indent(searchpair('\[','',']','bWn'))
+    " same for ( blocks
+    elseif getline(v:lnum) =~ '[^(]*)$'
+        call search(')','bW')
+        let ind = indent(searchpair('(','',')','bWn'))
+
+    " and finally, close { blocks if si ain't already set
+    elseif getline(v:lnum) =~ '[^{]*}'
+        call search('}','bW')
+        let ind = indent(searchpair('{','','}','bWn'))
+    endif
+
+    return ind
+endfunction
+
diff --git a/runtime/plugin/gzip.vim b/runtime/plugin/gzip.vim
index 0e9d0f5..0eebc5c 100644
--- a/runtime/plugin/gzip.vim
+++ b/runtime/plugin/gzip.vim
@@ -1,6 +1,6 @@
 " Vim plugin for editing compressed files.
 " Maintainer: Bram Moolenaar <Bram@vim.org>
-" Last Change: 2005 Mar 24
+" Last Change: 2005 May 18
 
 " Exit quickly when:
 " - this plugin was already loaded
@@ -48,12 +48,41 @@
   exe "return s:have_" . name
 endfun
 
+" Set b:gzip_comp_arg to the gzip argument to be used for compression, based on
+" the flags in the compressed file.
+" The only compression methods that can be detected are max speed (-1) and max
+" compression (-9).
+fun s:set_compression(line)
+  " get the Compression Method
+  let l:cm = char2nr(a:line[2])
+  " if it's 8 (DEFLATE), we can check for the compression level
+  if l:cm == 8
+    " get the eXtra FLags
+    let l:xfl = char2nr(a:line[8])
+    " max compression
+    if l:xfl == 2
+      let b:gzip_comp_arg = "-9"
+    " min compression
+    elseif l:xfl == 4
+      let b:gzip_comp_arg = "-1"
+    endif
+  endif
+endfun
+
+
 " After reading compressed file: Uncompress text in buffer with "cmd"
 fun s:read(cmd)
   " don't do anything if the cmd is not supported
   if !s:check(a:cmd)
     return
   endif
+
+  " for gzip check current compression level and set b:gzip_comp_arg.
+  silent! unlet b:gzip_comp_arg
+  if a:cmd[0] == 'g'
+    call s:set_compression(getline(1))
+  endif
+
   " make 'patchmode' empty, we don't want a copy of the written file
   let pm_save = &pm
   set pm=
@@ -121,7 +150,11 @@
     let nm = resolve(expand("<afile>"))
     let nmt = s:tempname(nm)
     if rename(nm, nmt) == 0
-      call system(a:cmd . " " . nmt)
+      if exists("b:gzip_comp_arg")
+	call system(a:cmd . " " . b:gzip_comp_arg . " " . nmt)
+      else
+	call system(a:cmd . " " . nmt)
+      endif
       call rename(nmt . "." . expand("<afile>:e"), nm)
     endif
   endif
@@ -131,8 +164,15 @@
 fun s:appre(cmd)
   " don't do anything if the cmd is not supported
   if s:check(a:cmd)
-    " Rename to a weird name to avoid the risk of overwriting another file
     let nm = expand("<afile>")
+
+    " for gzip check current compression level and set b:gzip_comp_arg.
+    silent! unlet b:gzip_comp_arg
+    if a:cmd[0] == 'g'
+      call s:set_compression(readfile(nm, "b", 1)[0])
+    endif
+
+    " Rename to a weird name to avoid the risk of overwriting another file
     let nmt = expand("<afile>:p:h") . "/X~=@l9q5"
     let nmte = nmt . "." . expand("<afile>:e")
     if rename(nm, nmte) == 0
diff --git a/runtime/syntax/mma.vim b/runtime/syntax/mma.vim
index 6eb8d66..e948b0a 100644
--- a/runtime/syntax/mma.vim
+++ b/runtime/syntax/mma.vim
@@ -1,41 +1,229 @@
 " Vim syntax file
 " Language:     Mathematica
-" Maintainer:   Wolfgang Waltenberger <wwalten@ben.tuwien.ac.at>
-" Last Change:  Thu 26 Apr 2001 13:20:03 CEST
+" Maintainer:   steve layland <layland@wolfram.com>
+" Last Change:  Tue May 10 18:31:00 CDT 2005
+" Source:       http://vim.sourceforge.net/scripts/script.php?script_id=1273
+"               http://members.wri.com/layland/vim/syntax/mma.vim
+"
+" NOTE:
+" Empty .m files will automatically be presumed as Matlab files
+" unless you have the following in your .vimrc:
+"
+"       let filetype_m="mma"
+"
+" I also recommend setting the default 'Comment' hilighting to something
+" other than the color used for 'Function', since both are plentiful in
+" most mathematica files, and they are often the same color (when using 
+" background=dark).  I use
+"
+"   hi Comment ctermfg=darkcyan
+"   
+" darkgreen also looks good on my terminal.
+"
+" Credits:
+" o  Original Mathematica syntax version written by
+"    Wolfgang Waltenberger <wwalten@ben.tuwien.ac.at>
+" o  Some ideas like the CommentStar,CommentTitle were adapted
+"    from the Java vim syntax file by Claudio Fleiner.  Thanks!
+" o  Everything else written by steve <layland@wolfram.com>
+"
+" TODO:
+"   folding
+"   fix nesting
+"   finish populating popular symbols
 
 if version < 600
 	syntax clear
 elseif exists("b:current_syntax")
-	finish
+    finish
 endif
 
-syn match mmaError "\*)"
-syn match mmaFixme "FIXME"
-syn region mmaComment start=+(\*+ end=+\*)+ skipempty contains=mmaFixme
-syn match mmaMessage "\a*::\a*"
-syn region mmaString start=+'+    end=+'+
-syn region mmaString start=+"+    end=+"+
-syn region mmaString start=+\\\"+ end=+\"+
-syn region mmaString start=+\"+   end=+\"+
+" Group Definitions:
+syntax cluster mmaNotes contains=mmaTodo,mmaFixme
+syntax cluster mmaComments contains=mmaComment,mmaFunctionComment,mmaItem,mmaFunctionTitle,mmaCommentStar
+syntax cluster mmaCommentStrings contains=mmaLooseQuote,mmaCommentString,mmaUnicode
+syntax cluster mmaStrings contains=@mmaCommentStrings,mmaString
+syntax cluster mmaTop contains=mmaOperator,mmaGenericFunction,mmaPureFunction,mmaVariable
 
-syn match mmaVariable "$\a*"
+" Variables:
+"   Dollar sign variables
+syntax match mmaVariable "$\a\+\d*"
+"   Preceding contexts
+syntax match mmaVariable "`\=\a\+\d*`"
 
-syn match mmaPattern "[A-Za-z01-9`]*_\{1,3}"
-syn match mmaPattern "[A-Za-z01-9`]*_\{1,3}\(Integer\|Real\|Pattern\|Symbol\)"
-syn match mmaPattern "[A-Za-z01-9`]*_\{1,3}\(Rational\|Complex\|Head\)"
-syn match mmaPattern "[A-Za-z01-9`]*_\{1,3}?[A-Za-z01-9`]*"
+" Numbers:
+syntax match mmaNumber "\<\%(\d\+\.\=\d*\|\d*\.\=\d\+\)\>"
+syntax match mmaNumber "`\d\+\>"
 
-" prefix/infix/postfix notations
-syn match mmaGenericFunction "[A-Za-z01-9`]*\s*\(\[\|@\)"he=e-1
-syn match mmaGenericFunction "[A-Za-z01-9`]*\s*\(/@\|@@\)"he=e-2
-syn match mmaGenericFunction "\~\s*[A-Za-z01-9`]*\s*\~"hs=s+1,he=e-1
-syn match mmaGenericFunction "//\s*[A-Za-z01-9`]*"hs=s+2
-syn match mmaOperator "/;"
+" Predefined Constants:
+"   to list all predefined Symbols would be too insane...
+"   it's probably smarter to define a select few, and get the rest from
+"   context if absolutely necessary.
+"   TODO - populate this with other often used Symbols
 
-syn match mmaPureFunction "#\d*"
-syn match mmaPureFunction "&"
+" standard fixed symbols:
+syntax keyword mmaVariable True False None Automatic All Null C General
 
-syn match mmaUnicode "\\\[[a-zA-Z01-9]*\]"
+" mathematical constants:
+syntax keyword mmaVariable Pi I E Infinity ComplexInfinity Indeterminate GoldenRatio EulerGamma Degree Catalan Khinchin Glaisher 
+
+" stream data / atomic heads:
+syntax keyword mmaVariable Byte Character Expression Number Real String Word EndOfFile Integer Symbol
+
+" sets:
+syntax keyword mmaVariable Integers Complexes Reals Booleans Rationals
+
+" character classes:
+syntax keyword mmaPattern DigitCharacter LetterCharacter WhitespaceCharacter WordCharacter EndOfString StartOfString EndOfLine StartOfLine WordBoundary
+
+" SelectionMove directions/units:
+syntax keyword mmaVariable Next Previous After Before Character Word Expression TextLine CellContents Cell CellGroup EvaluationCell ButtonCell GeneratedCell Notebook
+syntax keyword mmaVariable CellTags CellStyle CellLabel
+
+" TableForm positions:
+syntax keyword mmaVariable Above Below Left Right
+
+" colors:
+syntax keyword mmaVariable Black Blue Brown Cyan Gray Green Magenta Orange Pink Purple Red White Yellow
+
+" function attributes
+syntax keyword mmaVariable Protected Listable OneIdentity Orderless Flat Constant NumericFunction Locked ReadProtected HoldFirst HoldRest HoldAll HoldAllComplete SequenceHold NHoldFirst NHoldRest NHoldAll Temporary Stub 
+
+" Strings:
+"   "string"
+"   'string' is not accepted (until literal strings are supported!)
+syntax region mmaString start=+\\\@<!"+ skip=+\\\@<!\\\%(\\\\\)*"+ end=+"+
+syntax region mmaCommentString oneline start=+\\\@<!"+ skip=+\\\@<!\\\%(\\\\\)*"+ end=+"+ contained
+
+" Function Usage Messages:
+"   "SymbolName::item"
+syntax match mmaMessage "$\=\a\+\d*::\a\+\d*"
+
+" Pure Functions:
+syntax match mmaPureFunction "#\%(#\|\d\+\)\="
+syntax match mmaPureFunction "&"
+
+" Named Functions:
+" Since everything is pretty much a function, get this straight 
+" from context
+syntax match mmaGenericFunction "[A-Za-z0-9`]\+\s*\%([@[]\|/:\|/\=/@\)\@=" contains=mmaOperator
+syntax match mmaGenericFunction "\~\s*[^~]\+\s*\~"hs=s+1,he=e-1 contains=mmaOperator,mmaBoring
+syntax match mmaGenericFunction "//\s*[A-Za-z0-9`]\+"hs=s+2 contains=mmaOperator
+ 
+" Comment Keywords:
+syntax keyword mmaTodo TODO NOTE HEY contained
+syntax match mmaTodo "X\{3,}" contained
+syntax keyword mmaFixme FIX[ME] FIXTHIS BROKEN contained
+" yay pirates...
+syntax match mmaFixme "\%(Y\=A\+R\+G\+\|GRR\+\|CR\+A\+P\+\)\%(!\+\)\=" contained
+syntax match mmaemPHAsis "\(_\+\)[ a-zA-Z0-9]\+\1" contained
+
+" Comment Sections:
+"   this:
+"   :that:
+syntax match mmaItem "\%(^[( |*\t]*\)\@<=\%(:\+\|\a\)[a-zA-Z0-9 ]\+:" contained contains=@mmaNotes
+
+" Actual Mathematica Comments:
+"   (* *)
+"   allow nesting (* (* *) *) even though the frontend
+"   won't always like it.
+syntax region mmaComment start=+(\*+ end=+\*)+ skipempty contains=@mmaNotes,mmaItem,@mmaCommentStrings,mmaemPHAsis,mmaComment
+
+" Function Comments:
+"   just like a normal comment except the first sentance is Special ala Java
+"   (** *)
+"   TODO - fix this for nesting, or not...
+syntax region mmaFunctionComment start="(\*\*\+" end="\*\+)" contains=@mmaNotes,mmaItem,mmaFunctionTitle,@mmaCommentStrings,mmaemPHAsis,mmaComment
+syntax region mmaFunctionTitle contained matchgroup=mmaFunctionComment start="\%((\*\*[ *]*\)" matchgroup=mmaFunctionTitle keepend end=".[.!-]\=\s*$" end="[.!-][ \t\r<&]"me=e-1 end="\%(\*\+)\)\@=" contained contains=@mmaNotes,mmaItem,mmaCommentStar
+
+" catch remaining (**********)'s
+syntax match mmaComment "(\*\*\+)"
+" catch preceding *
+syntax match mmaCommentStar "^\s*\*\+" contained
+
+" Patterns:
+"   Each pattern marker below can be Blank[] (_), BlankSequence[] (__)
+"   or BlankNullSequence[] (___).  Most examples below can also be 
+"   combined, for example Pattern tests with Default values.
+"   
+"   _Head                   Anonymous patterns
+"   name_Head 
+"   name:(_Head|_Head2)     Named patterns
+"    
+"   _Head : val
+"   name:_Head:val          Default values
+"
+"   _Head?testQ, 
+"   _Head?(test[#]&)        Pattern tests
+"
+"   name_Head/;test[name]   Conditionals
+"   
+"   _Head:.                 Predefined Default
+"
+"   .. ...                  Pattern Repeat
+   
+syntax match mmaPatternError "\%(_\{4,}\|)\s*&\s*)\@!\)" contained
+
+"pattern name:
+syntax match mmaPattern "[A-Za-z0-9`]\+\s*:\+[=>]\@!" contains=mmaOperator
+"pattern default:
+syntax match mmaPattern ": *[^ ,]\+[\], ]\@=" contains=@mmaCommentStrings,@mmaTop,mmaOperator
+"pattern head/test:
+syntax match mmaPattern "[A-Za-z0-9`]*_\+\%(\a\+\)\=\%(?([^)]\+)\|?[^\]},]\+\)\=" contains=@mmaTop,@mmaCommentStrings,mmaPatternError
+
+" Operators:
+"   /: ^= ^:=   UpValue
+"   /;          Conditional
+"   := =        DownValue
+"   == === ||
+"   != =!= &&   Logic
+"   >= <= < >
+"   += -= *=
+"   /= ++ --    Math
+"   ^* 
+"   -> :>       Rules
+"   @@ @@@      Apply
+"   /@ //@      Map
+"   /. //.      Replace
+"   // @        Function application
+"   <> ~~       String/Pattern join
+"   ~           infix operator
+"   . :         Pattern operators
+syntax match mmaOperator "\%(@\{1,3}\|//[.@]\=\)"
+syntax match mmaOperator "\%(/[;:@.]\=\|\^\=:\==\)"
+syntax match mmaOperator "\%([-:=]\=>\|<=\=\)"
+"syntax match mmaOperator "\%(++\=\|--\=\|[/+-*]=\|[^*]\)"
+syntax match mmaOperator "[*+=^.:?-]"
+syntax match mmaOperator "\%(\~\~\=\)"
+syntax match mmaOperator "\%(=\{2,3}\|=\=!=\|||\=\|&&\|!\)" contains=ALLBUT,mmaPureFunction
+
+  
+" Special Characters:
+"   \[Name]     named character
+"   \ooo        octal
+"   \.xx        2 digit hex
+"   \:xxxx      4 digit hex (multibyte unicode)
+syntax match mmaUnicode "\\\[\w\+\d*\]"
+syntax match mmaUnicode "\\\%(\x\{3}\|\.\x\{2}\|:\x\{4}\)"
+
+" Syntax Errors:
+syntax match mmaError "\*)" containedin=ALLBUT,@mmaComments,@mmaStrings
+syntax match mmaError "\%([&:|+*/?~-]\{3,}\|[.=]\{4,}\|_\@<=\.\{2,}\|`\{2,}\)" containedin=ALLBUT,@mmaComments,@mmaStrings
+
+" Punctuation:
+" things that shouldn't really be highlighted, or highlighted 
+" in they're own group if you _really_ want. :)
+"  ( ) { }
+" TODO - use Delimiter group?
+syntax match mmaBoring "[(){}]" contained
+
+" Function Arguments:
+"   anything between brackets []
+"   TODO - make good folds for this.
+"syntax region mmaArgument start="\[" end="]" containedin=ALLBUT,@mmaComments,@mmaCommentStrings transparent fold
+"syntax sync fromstart
+"set foldmethod=syntax
+"set foldminlines=10
 
 if version >= 508 || !exists("did_mma_syn_inits")
 	if version < 508
@@ -45,17 +233,33 @@
 		command -nargs=+ HiLink hi def link <args>
 	endif
 
-	HiLink mmaOperator	   Operator
-	HiLink mmaVariable	   Identifier
-	HiLink mmaString	   String
-	HiLink mmaUnicode	   String
-	HiLink mmaMessage	   Identifier
-	HiLink mmaPattern	   Identifier
-	HiLink mmaGenericFunction  Function
-	HiLink mmaError		   Error
-	HiLink mmaFixme		   Error
-	HiLink mmaComment	   Comment
-	HiLink mmaPureFunction	   Operator
+    " NOTE - the following links are not guaranteed to 
+    " look good under all colorschemes.  You might need to 
+    " :so $VIMRUNTIME/syntax/hitest.vim and tweak these to
+    " look good in yours
+
+    HiLink mmaComment           Comment
+    HiLink mmaCommentStar       Comment
+    HiLink mmaFunctionComment   Comment
+    HiLink mmaLooseQuote        Comment
+	HiLink mmaGenericFunction   Function
+	HiLink mmaOperator          Operator
+    HiLink mmaPatternOp         Operator
+	HiLink mmaPureFunction      Operator
+	HiLink mmaVariable          Identifier
+	HiLink mmaString            String
+    HiLink mmaCommentString     String
+	HiLink mmaUnicode           String
+	HiLink mmaMessage           Type
+    HiLink mmaNumber            Type
+	HiLink mmaPattern           Type
+	HiLink mmaError             Error
+	HiLink mmaFixme             Error
+    HiLink mmaPatternError      Error
+    HiLink mmaTodo              Todo
+    HiLink mmaemPHAsis          Special
+    HiLink mmaFunctionTitle     Special
+    HiLink mmaItem              Preproc
 
 	delcommand HiLink
 endif