Index: /issm/trunk/externalpackages/vim/addons/vim/indent/matlab.vim
===================================================================
--- /issm/trunk/externalpackages/vim/addons/vim/indent/matlab.vim	(revision 7178)
+++ /issm/trunk/externalpackages/vim/addons/vim/indent/matlab.vim	(revision 7179)
@@ -2,5 +2,5 @@
 " Language:	Matlab
 " Maintainer:	Fabrice Guy <fabrice.guy at gmail dot com>
-" Last Change:	2008 Oct 15 
+" Last Change:	2009 Nov 23 - Added support for if/end block on the same line
 
 " Only load this indent file when no other was loaded.
@@ -9,5 +9,5 @@
 endif
 let b:did_indent = 1
-let s:onlySubfunctionExists = 0
+let s:functionWithoutEndStatement = 0
 
 setlocal indentexpr=GetMatlabIndent()
@@ -63,10 +63,10 @@
   let curind = indent(plnum)
   if s:IsMatlabContinuationLine(v:lnum - 1) 
-    let curind = curind + &softtabstop
+    let curind = curind + &sw
   endif
   " Add a 'shiftwidth' after classdef, properties, switch, methods, events,
-  " function, if, while, for, otherwise, case, tic, try, catch, else, elseif
-  if getline(plnum) =~ '^\s*\(classdef\|properties\|switch\|methods\|events\|function\|if\|while\|for\|otherwise\|case\|tic\|try\|catch\|else\|elseif\)\>'
-    let curind = curind + &softtabstop
+  " function, if, while, for, otherwise, case, try, catch, else, elseif
+  if getline(plnum) =~ '^\s*\(classdef\|properties\|switch\|methods\|events\|function\|if\|while\|for\|otherwise\|case\|try\|catch\|else\|elseif\)\>'
+    let curind = curind + &sw
     " In Matlab we have different kind of functions
     " - the main function (the function with the same name than the filename)
@@ -74,40 +74,50 @@
     " - the functions defined in methods (for classes)
     " - subfunctions
-    " For the moment the main function (located line 1) doesn't produce any indentation in the
-    " code (default behavior in the Matlab editor) and the other kind of
-    " functions indent the code
+    " Principles for the indentation :
+    " - all the function keywords are indented (corresponding to the
+    "   'indent all functions' in the Matlab Editor)
+    " - if we have only subfonctions (ie if the main function doesn't have
+    "   any mayching end), then each function is dedented
     if getline(plnum)  =~ '^\s*\function\>'
-      " If it is the main function
-      if plnum == 1
+      let pplnum = plnum - 1
+      while pplnum > 1 && (getline(pplnum) =~ '^\s*%')
+	let pplnum = pplnum - 1
+      endwhile
+      " If it is the main function, determine if function has a matching end
+      " or not
+      if pplnum <= 1 
 	" look for a matching end : 
-	" - if we find a matching end everything is fine
-	" - if not, then all other functions are subfunctions
+	" - if we find a matching end everything is fine : end of functions
+	"   will be dedented when 'end' is reached
+	" - if not, then all other functions are subfunctions : 'function'
+	"   keyword has to be dedended
+	let old_lnum = v:lnum
+	let motion = plnum . "gg"
+	execute "normal" . motion
 	normal %
 	if getline(line('.')) =~ '^\s*end'
-	  let s:onlySubfunctionExists = 0
+	  let s:functionWithoutEndStatement = 0
 	else
-	  let s:onlySubfunctionExists = 1
+	  let s:functionWithoutEndStatement = 1
 	endif
 	normal %
-	let curind = curind - &softtabstop
-      else
-	" it is a subfunction without matching end : dedent
-	if s:onlySubfunctionExists
-	  let curind = curind - &softtabstop
-	endif
+	let motion = old_lnum . "gg"
+	execute "normal" . motion
       endif
+    endif
+    " if the for-end block (or while-end) is on the same line : dedent
+    if getline(plnum)  =~ '\<end[,;]*\s*\(%.*\)\?$'
+      let curind = curind - &sw 
     endif
   endif
 
-  " Subtract a 'shiftwidth' on a else, elseif, end, catch, otherwise, case,
-  " toc
-  if getline(v:lnum) =~ '^\s*\(else\|elseif\|end\|catch\|otherwise\|case\|toc\)\>'
-    let curind = curind - &softtabstop
+  " Subtract a 'shiftwidth' on a else, elseif, end, catch, otherwise, case
+  if getline(v:lnum) =~ '^\s*\(else\|elseif\|end\|catch\|otherwise\|case\)\>'
+    let curind = curind - &sw
   endif
   " No indentation in a subfunction
-  if getline(v:lnum)  =~ '^\s*\function\>' && s:onlySubfunctionExists
-    let curind = curind - &softtabstop
+  if getline(v:lnum)  =~ '^\s*\function\>' && s:functionWithoutEndStatement
+    let curind = curind - &sw
   endif
-
   " First case after a switch : indent
   if getline(v:lnum) =~ '^\s*case'
@@ -116,5 +126,5 @@
     endwhile
     if getline(plnum) =~ '^\s*switch'
-      let curind = indent(plnum) + &softtabstop
+      let curind = indent(plnum) + &sw
     endif
   endif
@@ -125,6 +135,6 @@
     if getline(v:lnum) =~ '^\s*end'
       normal %
-      if getline(line('.')) =~ "switch"
-	let curind = curind - &softtabstop
+      if getline(line('.')) =~ '^\s*switch'
+	let curind = curind - &sw
       endif
       normal %
Index: /issm/trunk/externalpackages/vim/addons/vim/syntax/matlab.vim
===================================================================
--- /issm/trunk/externalpackages/vim/addons/vim/syntax/matlab.vim	(revision 7178)
+++ /issm/trunk/externalpackages/vim/addons/vim/syntax/matlab.vim	(revision 7179)
@@ -5,4 +5,6 @@
 " Last Change:	2008 Oct 16 : added try/catch/rethrow and class statements
 " 		2008 Oct 28 : added highlighting for most of Matlab functions
+" 		2009 Nov 23 : added 'todo' keyword in the matlabTodo keywords 
+" 		(for doxygen support)
 
 " For version 5.x: Clear all syntax items
@@ -15,6 +17,6 @@
 
 syn keyword matlabStatement		return function
-syn keyword matlabConditional		switch case else elseif end if otherwise for while
-syn keyword matlabRepeat		do break continue
+syn keyword matlabConditional		switch case else elseif end if otherwise break continue
+syn keyword matlabRepeat		do for while
 syn keyword matlabStorageClass		classdef methods properties events persistent global
 syn keyword matlabExceptions		try catch rethrow throw
@@ -54,5 +56,5 @@
 
 syn match matlabComment			"%.*$"	contains=matlabTodo,matlabTab
-syn region matlabBlockComment        start=+%{+    end=+%}+
+syn region matlabBlockComment        start=+%{+    end=+%}+ contains=matlabBlockComment
 
 
@@ -306,7 +308,4 @@
 
 
-syn match matlabError	"-\=\<\d\+\.\d\+\.[^*/\\^]"
-syn match matlabError	"-\=\<\d\+\.\d\+[eEdD][-+]\=\d\+\.\([^*/\\^]\)"
-
 " Define the default highlighting.
 " For version 5.7 and earlier: only when not done already
@@ -332,5 +331,4 @@
   HiLink matlabFloat			Float
   HiLink matlabConstant			Constant
-  HiLink matlabError			Error
   HiLink matlabImplicit			matlabStatement
   HiLink matlabStatement		Statement
