Karsten Hopp 0e7303
To: vim-dev@vim.org
Karsten Hopp 0e7303
Subject: patch 7.1.040
Karsten Hopp 0e7303
Fcc: outbox
Karsten Hopp 0e7303
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 0e7303
Mime-Version: 1.0
Karsten Hopp 0e7303
Content-Type: text/plain; charset=ISO-8859-1
Karsten Hopp 0e7303
Content-Transfer-Encoding: 8bit
Karsten Hopp 0e7303
------------
Karsten Hopp 0e7303
Karsten Hopp 0e7303
Patch 7.1.040
Karsten Hopp 0e7303
Problem:    ":match" only supports three matches.
Karsten Hopp 0e7303
Solution:   Add functions clearmatches(), getmatches(), matchadd(),
Karsten Hopp 0e7303
	    matchdelete() and setmatches().  Changed the data structures for
Karsten Hopp 0e7303
	    this.  A small bug in syntax.c is fixed, so newly created
Karsten Hopp 0e7303
	    highlight groups can have their name resolved correctly from their
Karsten Hopp 0e7303
	    ID.  (Martin Toft)
Karsten Hopp 0e7303
Files:	    runtime/doc/eval.txt, runtime/doc/pattern.txt,
Karsten Hopp 0e7303
	    runtime/doc/usr_41.txt, src/eval.c, src/ex_docmd.c,
Karsten Hopp 0e7303
	    src/proto/window.pro, src/screen.c, src/structs.h, src/syntax.c,
Karsten Hopp 0e7303
	    src/testdir/Makefile, src/testdir/test63.in,
Karsten Hopp 0e7303
	    src/testdir/test63.ok, src/window.c
Karsten Hopp 0e7303
Karsten Hopp 0e7303
Karsten Hopp 0e7303
*** ../vim-7.1.039/runtime/doc/eval.txt	Tue Jul 17 16:31:15 2007
Karsten Hopp 0e7303
--- runtime/doc/eval.txt	Wed Jul 25 21:05:56 2007
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 1,4 ****
Karsten Hopp 0e7303
! *eval.txt*      For Vim version 7.1.  Last change: 2007 Jul 11
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
  		  VIM REFERENCE MANUAL    by Bram Moolenaar
Karsten Hopp 0e7303
--- 1,4 ----
Karsten Hopp 0e7303
! *eval.txt*      For Vim version 7.1.  Last change: 2007 Jul 25
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
  		  VIM REFERENCE MANUAL    by Bram Moolenaar
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 1557,1562 ****
Karsten Hopp 0e7303
--- 1557,1563 ----
Karsten Hopp 0e7303
  changenr()			Number  current change number
Karsten Hopp 0e7303
  char2nr( {expr})		Number	ASCII value of first char in {expr}
Karsten Hopp 0e7303
  cindent( {lnum})		Number	C indent for line {lnum}
Karsten Hopp 0e7303
+ clearmatches()			None	clear all matches
Karsten Hopp 0e7303
  col( {expr})			Number	column nr of cursor or mark
Karsten Hopp 0e7303
  complete({startcol}, {matches})	String  set Insert mode completion
Karsten Hopp 0e7303
  complete_add( {expr})		Number	add completion match
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 1622,1627 ****
Karsten Hopp 0e7303
--- 1623,1629 ----
Karsten Hopp 0e7303
  getline( {lnum})		String	line {lnum} of current buffer
Karsten Hopp 0e7303
  getline( {lnum}, {end})		List	lines {lnum} to {end} of current buffer
Karsten Hopp 0e7303
  getloclist({nr})		List	list of location list items
Karsten Hopp 0e7303
+ getmatches()			List	list of current matches
Karsten Hopp 0e7303
  getpos( {expr})			List	position of cursor, mark, etc.
Karsten Hopp 0e7303
  getqflist()			List	list of quickfix items
Karsten Hopp 0e7303
  getreg( [{regname} [, 1]])	String	contents of register
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 1676,1682 ****
Karsten Hopp 0e7303
--- 1678,1687 ----
Karsten Hopp 0e7303
  				String	check for mappings matching {name}
Karsten Hopp 0e7303
  match( {expr}, {pat}[, {start}[, {count}]])
Karsten Hopp 0e7303
  				Number	position where {pat} matches in {expr}
Karsten Hopp 0e7303
+ matchadd( {group}, {pattern}[, {priority}[, {id}]])
Karsten Hopp 0e7303
+ 				Number	highlight {pattern} with {group}
Karsten Hopp 0e7303
  matcharg( {nr})			List	arguments of |:match|
Karsten Hopp 0e7303
+ matchdelete( {id})		Number	delete match identified by {id}
Karsten Hopp 0e7303
  matchend( {expr}, {pat}[, {start}[, {count}]])
Karsten Hopp 0e7303
  				Number	position where {pat} ends in {expr}
Karsten Hopp 0e7303
  matchlist( {expr}, {pat}[, {start}[, {count}]])
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 1731,1736 ****
Karsten Hopp 0e7303
--- 1736,1742 ----
Karsten Hopp 0e7303
  setline( {lnum}, {line})	Number	set line {lnum} to {line}
Karsten Hopp 0e7303
  setloclist( {nr}, {list}[, {action}])
Karsten Hopp 0e7303
  				Number	modify location list using {list}
Karsten Hopp 0e7303
+ setmatches( {list})		Number	restore a list of matches
Karsten Hopp 0e7303
  setpos( {expr}, {list})		none	set the {expr} position to {list}
Karsten Hopp 0e7303
  setqflist( {list}[, {action}])	Number	modify quickfix list using {list}
Karsten Hopp 0e7303
  setreg( {n}, {v}[, {opt}])	Number	set register to value and type
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 2012,2017 ****
Karsten Hopp 0e7303
--- 2018,2027 ----
Karsten Hopp 0e7303
  		feature, -1 is returned.
Karsten Hopp 0e7303
  		See |C-indenting|.
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
+ clearmatches()						*clearmatches()*
Karsten Hopp 0e7303
+ 		Clears all matches previously defined by |matchadd()| and the
Karsten Hopp 0e7303
+ 		|:match| commands.
Karsten Hopp 0e7303
+ 
Karsten Hopp 0e7303
  							*col()*
Karsten Hopp 0e7303
  col({expr})	The result is a Number, which is the byte index of the column
Karsten Hopp 0e7303
  		position given with {expr}.  The accepted positions are:
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 2918,2923 ****
Karsten Hopp 0e7303
--- 2928,2955 ----
Karsten Hopp 0e7303
  		returned.  For an invalid window number {nr}, an empty list is
Karsten Hopp 0e7303
  		returned. Otherwise, same as getqflist().
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
+ getmatches()						*getmatches()*
Karsten Hopp 0e7303
+ 		Returns a |List| with all matches previously defined by
Karsten Hopp 0e7303
+ 		|matchadd()| and the |:match| commands.  |getmatches()| is
Karsten Hopp 0e7303
+ 		useful in combination with |setmatches()|, as |setmatches()|
Karsten Hopp 0e7303
+ 		can restore a list of matches saved by |getmatches()|.
Karsten Hopp 0e7303
+ 		Example: >
Karsten Hopp 0e7303
+ 			:echo getmatches()
Karsten Hopp 0e7303
+ <			[{'group': 'MyGroup1', 'pattern': 'TODO',
Karsten Hopp 0e7303
+ 			'priority': 10, 'id': 1}, {'group': 'MyGroup2',
Karsten Hopp 0e7303
+ 			'pattern': 'FIXME', 'priority': 10, 'id': 2}] >
Karsten Hopp 0e7303
+ 			:let m = getmatches()
Karsten Hopp 0e7303
+ 			:call clearmatches()
Karsten Hopp 0e7303
+ 			:echo getmatches()
Karsten Hopp 0e7303
+ <			[] >
Karsten Hopp 0e7303
+ 			:call setmatches(m)
Karsten Hopp 0e7303
+ 			:echo getmatches()
Karsten Hopp 0e7303
+ <			[{'group': 'MyGroup1', 'pattern': 'TODO',
Karsten Hopp 0e7303
+ 			'priority': 10, 'id': 1}, {'group': 'MyGroup2',
Karsten Hopp 0e7303
+ 			'pattern': 'FIXME', 'priority': 10, 'id': 2}] >
Karsten Hopp 0e7303
+ 			:unlet m
Karsten Hopp 0e7303
+ <
Karsten Hopp 0e7303
+ 
Karsten Hopp 0e7303
  getqflist()						*getqflist()*
Karsten Hopp 0e7303
  		Returns a list with all the current quickfix errors.  Each
Karsten Hopp 0e7303
  		list item is a dictionary with these entries:
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 3622,3627 ****
Karsten Hopp 0e7303
--- 3654,3697 ----
Karsten Hopp 0e7303
  		the pattern.  'smartcase' is NOT used.  The matching is always
Karsten Hopp 0e7303
  		done like 'magic' is set and 'cpoptions' is empty.
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
+ 					*matchadd()* *E798* *E799* *E801*
Karsten Hopp 0e7303
+ matchadd({group}, {pattern}[, {priority}[, {id}]])
Karsten Hopp 0e7303
+ 		Defines a pattern to be highlighted in the current window (a
Karsten Hopp 0e7303
+ 		"match").  It will be highlighted with {group}.  Returns an
Karsten Hopp 0e7303
+ 		identification number (ID), which can be used to delete the
Karsten Hopp 0e7303
+ 		match using |matchdelete()|.
Karsten Hopp 0e7303
+ 
Karsten Hopp 0e7303
+ 		The optional {priority} argument assigns a priority to the
Karsten Hopp 0e7303
+ 		match.  A match with a high priority will have its
Karsten Hopp 0e7303
+ 		highlighting overrule that of a match with a lower priority.
Karsten Hopp 0e7303
+ 		A priority is specified as an integer (negative numbers are no
Karsten Hopp 0e7303
+ 		exception).  If the {priority} argument is not specified, the
Karsten Hopp 0e7303
+ 		default priority is 10.  The priority of 'hlsearch' is zero,
Karsten Hopp 0e7303
+ 		hence all matches with a priority greater than zero will
Karsten Hopp 0e7303
+ 		overrule it.  Syntax highlighting (see 'syntax') is a separate
Karsten Hopp 0e7303
+ 		mechanism, and regardless of the chosen priority a match will
Karsten Hopp 0e7303
+ 		always overrule syntax highlighting.
Karsten Hopp 0e7303
+ 
Karsten Hopp 0e7303
+ 		The optional {id} argument allows the request for a specific
Karsten Hopp 0e7303
+ 		match ID.  If a specified ID is already taken, an error
Karsten Hopp 0e7303
+ 		message will appear and the match will not be added.  An ID
Karsten Hopp 0e7303
+ 		is specified as a positive integer (zero excluded).  IDs 1, 2
Karsten Hopp 0e7303
+ 		and 3 are reserved for |:match|, |:2match| and |:3match|,
Karsten Hopp 0e7303
+ 		respectively.  If the {id} argument is not specified,
Karsten Hopp 0e7303
+ 		|matchadd()| automatically chooses a free ID.
Karsten Hopp 0e7303
+ 
Karsten Hopp 0e7303
+ 		The number of matches is not limited, as it is the case with
Karsten Hopp 0e7303
+ 		the |:match| commands.
Karsten Hopp 0e7303
+ 
Karsten Hopp 0e7303
+ 		Example: >
Karsten Hopp 0e7303
+ 			:highlight MyGroup ctermbg=green guibg=green
Karsten Hopp 0e7303
+ 			:let m = matchadd("MyGroup", "TODO")
Karsten Hopp 0e7303
+ <		Deletion of the pattern: >
Karsten Hopp 0e7303
+ 			:call matchdelete(m)
Karsten Hopp 0e7303
+ 
Karsten Hopp 0e7303
+ <		A list of matches defined by |matchadd()| and |:match| are
Karsten Hopp 0e7303
+ 		available from |getmatches()|.  All matches can be deleted in
Karsten Hopp 0e7303
+ 		one operation by |clearmatches()|.
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
  matcharg({nr})							*matcharg()*
Karsten Hopp 0e7303
  		Selects the {nr} match item, as set with a |:match|,
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 3631,3638 ****
Karsten Hopp 0e7303
  			The pattern used.
Karsten Hopp 0e7303
  		When {nr} is not 1, 2 or 3 returns an empty |List|.
Karsten Hopp 0e7303
  		When there is no match item set returns ['', ''].
Karsten Hopp 0e7303
! 		This is usef to save and restore a |:match|.
Karsten Hopp 0e7303
! 
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
  matchend({expr}, {pat}[, {start}[, {count}]])			*matchend()*
Karsten Hopp 0e7303
  		Same as match(), but return the index of first character after
Karsten Hopp 0e7303
--- 3701,3715 ----
Karsten Hopp 0e7303
  			The pattern used.
Karsten Hopp 0e7303
  		When {nr} is not 1, 2 or 3 returns an empty |List|.
Karsten Hopp 0e7303
  		When there is no match item set returns ['', ''].
Karsten Hopp 0e7303
! 		This is useful to save and restore a |:match|.
Karsten Hopp 0e7303
! 		Highlighting matches using the |:match| commands are limited
Karsten Hopp 0e7303
! 		to three matches. |matchadd()| does not have this limitation.
Karsten Hopp 0e7303
! 
Karsten Hopp 0e7303
! matchdelete({id})			       *matchdelete()* *E802* *E803*
Karsten Hopp 0e7303
! 		Deletes a match with ID {id} previously defined by |matchadd()|
Karsten Hopp 0e7303
! 		or one of the |:match| commands.  Returns 0 if succesfull,
Karsten Hopp 0e7303
! 		otherwise -1.  See example for |matchadd()|.  All matches can
Karsten Hopp 0e7303
! 		be deleted in one operation by |clearmatches()|.
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
  matchend({expr}, {pat}[, {start}[, {count}]])			*matchend()*
Karsten Hopp 0e7303
  		Same as match(), but return the index of first character after
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 4385,4391 ****
Karsten Hopp 0e7303
  		When {nr} is zero the current window is used. For a location
Karsten Hopp 0e7303
  		list window, the displayed location list is modified.  For an
Karsten Hopp 0e7303
  		invalid window number {nr}, -1 is returned.
Karsten Hopp 0e7303
! 		Otherwise, same as setqflist().
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
  							*setpos()*
Karsten Hopp 0e7303
  setpos({expr}, {list})
Karsten Hopp 0e7303
--- 4462,4474 ----
Karsten Hopp 0e7303
  		When {nr} is zero the current window is used. For a location
Karsten Hopp 0e7303
  		list window, the displayed location list is modified.  For an
Karsten Hopp 0e7303
  		invalid window number {nr}, -1 is returned.
Karsten Hopp 0e7303
! 		Otherwise, same as |setqflist()|.
Karsten Hopp 0e7303
! 		Also see |location-list|.
Karsten Hopp 0e7303
! 
Karsten Hopp 0e7303
! setmatches({list})					*setmatches()*
Karsten Hopp 0e7303
! 		Restores a list of matches saved by |getmatches()|.  Returns 0
Karsten Hopp 0e7303
! 		if succesfull, otherwise -1.  All current matches are cleared
Karsten Hopp 0e7303
! 		before the list is restored.  See example for |getmatches()|.
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
  							*setpos()*
Karsten Hopp 0e7303
  setpos({expr}, {list})
Karsten Hopp 0e7303
*** ../vim-7.1.039/runtime/doc/pattern.txt	Sat May 12 16:57:31 2007
Karsten Hopp 0e7303
--- runtime/doc/pattern.txt	Tue Jul 24 15:47:01 2007
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 1212,1218 ****
Karsten Hopp 0e7303
  		{group} must exist at the moment this command is executed.
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
  		The {group} highlighting still applies when a character is
Karsten Hopp 0e7303
! 		to be highlighted for 'hlsearch'.
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
  		Note that highlighting the last used search pattern with
Karsten Hopp 0e7303
  		'hlsearch' is used in all windows, while the pattern defined
Karsten Hopp 0e7303
--- 1212,1221 ----
Karsten Hopp 0e7303
  		{group} must exist at the moment this command is executed.
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
  		The {group} highlighting still applies when a character is
Karsten Hopp 0e7303
! 		to be highlighted for 'hlsearch', as the highlighting for
Karsten Hopp 0e7303
! 		matches is given higher priority than that of 'hlsearch'.
Karsten Hopp 0e7303
! 		Syntax highlighting (see 'syntax') is also overruled by
Karsten Hopp 0e7303
! 		matches.
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
  		Note that highlighting the last used search pattern with
Karsten Hopp 0e7303
  		'hlsearch' is used in all windows, while the pattern defined
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 1226,1233 ****
Karsten Hopp 0e7303
  		display you may get unexpected results.  That is because Vim
Karsten Hopp 0e7303
  		looks for a match in the line where redrawing starts.
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
! 		Also see |matcharg()|, it returns the highlight group and
Karsten Hopp 0e7303
! 		pattern of a previous :match command.
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
  		Another example, which highlights all characters in virtual
Karsten Hopp 0e7303
  		column 72 and more: >
Karsten Hopp 0e7303
--- 1229,1243 ----
Karsten Hopp 0e7303
  		display you may get unexpected results.  That is because Vim
Karsten Hopp 0e7303
  		looks for a match in the line where redrawing starts.
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
! 		Also see |matcharg()|and |getmatches()|. The former returns
Karsten Hopp 0e7303
! 		the highlight group and pattern of a previous |:match|
Karsten Hopp 0e7303
! 		command.  The latter returns a list with highlight groups and
Karsten Hopp 0e7303
! 		patterns defined by both |matchadd()| and |:match|.
Karsten Hopp 0e7303
! 
Karsten Hopp 0e7303
! 		Highlighting matches using |:match| are limited to three
Karsten Hopp 0e7303
! 		matches (aside from |:match|, |:2match| and |:3match|are
Karsten Hopp 0e7303
! 		available). |matchadd()| does not have this limitation and in
Karsten Hopp 0e7303
! 		addition makes it possible to prioritize matches.
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
  		Another example, which highlights all characters in virtual
Karsten Hopp 0e7303
  		column 72 and more: >
Karsten Hopp 0e7303
*** ../vim-7.1.039/runtime/doc/usr_41.txt	Sat May 12 15:54:55 2007
Karsten Hopp 0e7303
--- runtime/doc/usr_41.txt	Tue Jul 24 15:47:01 2007
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 763,775 ****
Karsten Hopp 0e7303
--- 763,784 ----
Karsten Hopp 0e7303
  	foldtextresult()	get the text displayed for a closed fold
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
  Syntax and highlighting:
Karsten Hopp 0e7303
+ 	clearmatches()		clear all matches defined by |matchadd()| and
Karsten Hopp 0e7303
+ 				the |:match| commands
Karsten Hopp 0e7303
+ 	getmatches()		get all matches defined by |matchadd()| and
Karsten Hopp 0e7303
+ 				the |:match| commands
Karsten Hopp 0e7303
  	hlexists()		check if a highlight group exists
Karsten Hopp 0e7303
  	hlID()			get ID of a highlight group
Karsten Hopp 0e7303
  	synID()			get syntax ID at a specific position
Karsten Hopp 0e7303
  	synIDattr()		get a specific attribute of a syntax ID
Karsten Hopp 0e7303
  	synIDtrans()		get translated syntax ID
Karsten Hopp 0e7303
  	diff_hlID()		get highlight ID for diff mode at a position
Karsten Hopp 0e7303
+ 	matchadd()		define a pattern to highlight (a "match")
Karsten Hopp 0e7303
  	matcharg()		get info about |:match| arguments
Karsten Hopp 0e7303
+ 	matchdelete()		delete a match defined by |matchadd()| or a
Karsten Hopp 0e7303
+ 				|:match| command
Karsten Hopp 0e7303
+ 	setmatches()		restore a list of matches saved by
Karsten Hopp 0e7303
+ 				|getmatches()|
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
  Spelling:
Karsten Hopp 0e7303
  	spellbadword()		locate badly spelled word at or after cursor
Karsten Hopp 0e7303
*** ../vim-7.1.039/src/eval.c	Tue Jul 24 14:32:44 2007
Karsten Hopp 0e7303
--- src/eval.c	Tue Jul 24 20:40:52 2007
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 475,480 ****
Karsten Hopp 0e7303
--- 475,481 ----
Karsten Hopp 0e7303
  static void f_changenr __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 0e7303
  static void f_char2nr __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 0e7303
  static void f_cindent __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 0e7303
+ static void f_clearmatches __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 0e7303
  static void f_col __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 0e7303
  #if defined(FEAT_INS_EXPAND)
Karsten Hopp 0e7303
  static void f_complete __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 529,534 ****
Karsten Hopp 0e7303
--- 530,536 ----
Karsten Hopp 0e7303
  static void f_getftime __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 0e7303
  static void f_getftype __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 0e7303
  static void f_getline __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 0e7303
+ static void f_getmatches __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 0e7303
  static void f_getpos __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 0e7303
  static void f_getqflist __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 0e7303
  static void f_getreg __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 577,583 ****
Karsten Hopp 0e7303
--- 579,587 ----
Karsten Hopp 0e7303
  static void f_maparg __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 0e7303
  static void f_mapcheck __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 0e7303
  static void f_match __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 0e7303
+ static void f_matchadd __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 0e7303
  static void f_matcharg __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 0e7303
+ static void f_matchdelete __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 0e7303
  static void f_matchend __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 0e7303
  static void f_matchlist __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 0e7303
  static void f_matchstr __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 618,623 ****
Karsten Hopp 0e7303
--- 622,628 ----
Karsten Hopp 0e7303
  static void f_setcmdpos __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 0e7303
  static void f_setline __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 0e7303
  static void f_setloclist __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 0e7303
+ static void f_setmatches __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 0e7303
  static void f_setpos __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 0e7303
  static void f_setqflist __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 0e7303
  static void f_setreg __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 7046,7051 ****
Karsten Hopp 0e7303
--- 7051,7057 ----
Karsten Hopp 0e7303
      {"changenr",	0, 0, f_changenr},
Karsten Hopp 0e7303
      {"char2nr",		1, 1, f_char2nr},
Karsten Hopp 0e7303
      {"cindent",		1, 1, f_cindent},
Karsten Hopp 0e7303
+     {"clearmatches",	0, 0, f_clearmatches},
Karsten Hopp 0e7303
      {"col",		1, 1, f_col},
Karsten Hopp 0e7303
  #if defined(FEAT_INS_EXPAND)
Karsten Hopp 0e7303
      {"complete",	2, 2, f_complete},
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 7102,7107 ****
Karsten Hopp 0e7303
--- 7108,7114 ----
Karsten Hopp 0e7303
      {"getftype",	1, 1, f_getftype},
Karsten Hopp 0e7303
      {"getline",		1, 2, f_getline},
Karsten Hopp 0e7303
      {"getloclist",	1, 1, f_getqflist},
Karsten Hopp 0e7303
+     {"getmatches",  	0, 0, f_getmatches},
Karsten Hopp 0e7303
      {"getpos",		1, 1, f_getpos},
Karsten Hopp 0e7303
      {"getqflist",	0, 0, f_getqflist},
Karsten Hopp 0e7303
      {"getreg",		0, 2, f_getreg},
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 7152,7158 ****
Karsten Hopp 0e7303
--- 7159,7167 ----
Karsten Hopp 0e7303
      {"maparg",		1, 3, f_maparg},
Karsten Hopp 0e7303
      {"mapcheck",	1, 3, f_mapcheck},
Karsten Hopp 0e7303
      {"match",		2, 4, f_match},
Karsten Hopp 0e7303
+     {"matchadd",	2, 4, f_matchadd},
Karsten Hopp 0e7303
      {"matcharg",	1, 1, f_matcharg},
Karsten Hopp 0e7303
+     {"matchdelete",	1, 1, f_matchdelete},
Karsten Hopp 0e7303
      {"matchend",	2, 4, f_matchend},
Karsten Hopp 0e7303
      {"matchlist",	2, 4, f_matchlist},
Karsten Hopp 0e7303
      {"matchstr",	2, 4, f_matchstr},
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 7193,7198 ****
Karsten Hopp 0e7303
--- 7202,7208 ----
Karsten Hopp 0e7303
      {"setcmdpos",	1, 1, f_setcmdpos},
Karsten Hopp 0e7303
      {"setline",		2, 2, f_setline},
Karsten Hopp 0e7303
      {"setloclist",	2, 3, f_setloclist},
Karsten Hopp 0e7303
+     {"setmatches",	1, 1, f_setmatches},
Karsten Hopp 0e7303
      {"setpos",		2, 2, f_setpos},
Karsten Hopp 0e7303
      {"setqflist",	1, 2, f_setqflist},
Karsten Hopp 0e7303
      {"setreg",		2, 3, f_setreg},
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 8243,8248 ****
Karsten Hopp 0e7303
--- 8253,8272 ----
Karsten Hopp 0e7303
  }
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
  /*
Karsten Hopp 0e7303
+  * "clearmatches()" function
Karsten Hopp 0e7303
+  */
Karsten Hopp 0e7303
+ /*ARGSUSED*/
Karsten Hopp 0e7303
+     static void
Karsten Hopp 0e7303
+ f_clearmatches(argvars, rettv)
Karsten Hopp 0e7303
+     typval_T	*argvars;
Karsten Hopp 0e7303
+     typval_T	*rettv;
Karsten Hopp 0e7303
+ {
Karsten Hopp 0e7303
+ #ifdef FEAT_SEARCH_EXTRA
Karsten Hopp 0e7303
+     clear_matches(curwin);
Karsten Hopp 0e7303
+ #endif
Karsten Hopp 0e7303
+ }
Karsten Hopp 0e7303
+ 
Karsten Hopp 0e7303
+ /*
Karsten Hopp 0e7303
   * "col(string)" function
Karsten Hopp 0e7303
   */
Karsten Hopp 0e7303
      static void
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 10278,10283 ****
Karsten Hopp 0e7303
--- 10302,10341 ----
Karsten Hopp 0e7303
  }
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
  /*
Karsten Hopp 0e7303
+  * "getmatches()" function
Karsten Hopp 0e7303
+  */
Karsten Hopp 0e7303
+ /*ARGSUSED*/
Karsten Hopp 0e7303
+     static void
Karsten Hopp 0e7303
+ f_getmatches(argvars, rettv)
Karsten Hopp 0e7303
+     typval_T	*argvars;
Karsten Hopp 0e7303
+     typval_T	*rettv;
Karsten Hopp 0e7303
+ {
Karsten Hopp 0e7303
+ #ifdef FEAT_SEARCH_EXTRA
Karsten Hopp 0e7303
+     dict_T	*dict;
Karsten Hopp 0e7303
+     matchitem_T	*cur = curwin->w_match_head;
Karsten Hopp 0e7303
+ 
Karsten Hopp 0e7303
+     rettv->vval.v_number = 0;
Karsten Hopp 0e7303
+ 
Karsten Hopp 0e7303
+     if (rettv_list_alloc(rettv) == OK)
Karsten Hopp 0e7303
+     {
Karsten Hopp 0e7303
+ 	while (cur != NULL)
Karsten Hopp 0e7303
+ 	{
Karsten Hopp 0e7303
+ 	    dict = dict_alloc();
Karsten Hopp 0e7303
+ 	    if (dict == NULL)
Karsten Hopp 0e7303
+ 		return;
Karsten Hopp 0e7303
+ 	    ++dict->dv_refcount;
Karsten Hopp 0e7303
+ 	    dict_add_nr_str(dict, "group", 0L, syn_id2name(cur->hlg_id));
Karsten Hopp 0e7303
+ 	    dict_add_nr_str(dict, "pattern", 0L, cur->pattern);
Karsten Hopp 0e7303
+ 	    dict_add_nr_str(dict, "priority", (long)cur->priority, NULL);
Karsten Hopp 0e7303
+ 	    dict_add_nr_str(dict, "id", (long)cur->id, NULL);
Karsten Hopp 0e7303
+ 	    list_append_dict(rettv->vval.v_list, dict);
Karsten Hopp 0e7303
+ 	    cur = cur->next;
Karsten Hopp 0e7303
+ 	}
Karsten Hopp 0e7303
+     }
Karsten Hopp 0e7303
+ #endif
Karsten Hopp 0e7303
+ }
Karsten Hopp 0e7303
+ 
Karsten Hopp 0e7303
+ /*
Karsten Hopp 0e7303
   * "getpos(string)" function
Karsten Hopp 0e7303
   */
Karsten Hopp 0e7303
      static void
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 12448,12453 ****
Karsten Hopp 0e7303
--- 12506,12547 ----
Karsten Hopp 0e7303
  }
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
  /*
Karsten Hopp 0e7303
+  * "matchadd()" function
Karsten Hopp 0e7303
+  */
Karsten Hopp 0e7303
+     static void
Karsten Hopp 0e7303
+ f_matchadd(argvars, rettv)
Karsten Hopp 0e7303
+     typval_T	*argvars;
Karsten Hopp 0e7303
+     typval_T	*rettv;
Karsten Hopp 0e7303
+ {
Karsten Hopp 0e7303
+ #ifdef FEAT_SEARCH_EXTRA
Karsten Hopp 0e7303
+     char_u	buf[NUMBUFLEN];
Karsten Hopp 0e7303
+     char_u	*grp = get_tv_string_buf_chk(&argvars[0], buf);	/* group */
Karsten Hopp 0e7303
+     char_u	*pat = get_tv_string_buf_chk(&argvars[1], buf);	/* pattern */
Karsten Hopp 0e7303
+     int		prio = 10;	/* default priority */
Karsten Hopp 0e7303
+     int		id = -1;
Karsten Hopp 0e7303
+     int		error = FALSE;
Karsten Hopp 0e7303
+ 
Karsten Hopp 0e7303
+     rettv->vval.v_number = -1;
Karsten Hopp 0e7303
+ 
Karsten Hopp 0e7303
+     if (grp == NULL || pat == NULL)
Karsten Hopp 0e7303
+ 	return;
Karsten Hopp 0e7303
+     if (argvars[2].v_type != VAR_UNKNOWN)
Karsten Hopp 0e7303
+ 	prio = get_tv_number_chk(&argvars[2], &error);
Karsten Hopp 0e7303
+     if (argvars[3].v_type != VAR_UNKNOWN)
Karsten Hopp 0e7303
+ 	id = get_tv_number_chk(&argvars[3], &error);
Karsten Hopp 0e7303
+     if (error == TRUE)
Karsten Hopp 0e7303
+ 	return;
Karsten Hopp 0e7303
+     if (id >= 1 && id <= 3)
Karsten Hopp 0e7303
+     {
Karsten Hopp 0e7303
+ 	EMSGN("E798: ID is reserved for \":match\": %ld", id);
Karsten Hopp 0e7303
+ 	return;
Karsten Hopp 0e7303
+     }
Karsten Hopp 0e7303
+ 
Karsten Hopp 0e7303
+     rettv->vval.v_number = match_add(curwin, grp, pat, prio, id);
Karsten Hopp 0e7303
+ #endif
Karsten Hopp 0e7303
+ }
Karsten Hopp 0e7303
+ 
Karsten Hopp 0e7303
+ /*
Karsten Hopp 0e7303
   * "matcharg()" function
Karsten Hopp 0e7303
   */
Karsten Hopp 0e7303
      static void
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 12458,12477 ****
Karsten Hopp 0e7303
      if (rettv_list_alloc(rettv) == OK)
Karsten Hopp 0e7303
      {
Karsten Hopp 0e7303
  #ifdef FEAT_SEARCH_EXTRA
Karsten Hopp 0e7303
! 	int	mi = get_tv_number(&argvars[0]);
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
! 	if (mi >= 1 && mi <= 3)
Karsten Hopp 0e7303
  	{
Karsten Hopp 0e7303
! 	    list_append_string(rettv->vval.v_list,
Karsten Hopp 0e7303
! 				 syn_id2name(curwin->w_match_id[mi - 1]), -1);
Karsten Hopp 0e7303
! 	    list_append_string(rettv->vval.v_list,
Karsten Hopp 0e7303
! 					     curwin->w_match_pat[mi - 1], -1);
Karsten Hopp 0e7303
  	}
Karsten Hopp 0e7303
  #endif
Karsten Hopp 0e7303
      }
Karsten Hopp 0e7303
  }
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
  /*
Karsten Hopp 0e7303
   * "matchend()" function
Karsten Hopp 0e7303
   */
Karsten Hopp 0e7303
      static void
Karsten Hopp 0e7303
--- 12552,12593 ----
Karsten Hopp 0e7303
      if (rettv_list_alloc(rettv) == OK)
Karsten Hopp 0e7303
      {
Karsten Hopp 0e7303
  #ifdef FEAT_SEARCH_EXTRA
Karsten Hopp 0e7303
! 	int	    id = get_tv_number(&argvars[0]);
Karsten Hopp 0e7303
! 	matchitem_T *m;
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
! 	if (id >= 1 && id <= 3)
Karsten Hopp 0e7303
  	{
Karsten Hopp 0e7303
! 	    if ((m = (matchitem_T *)get_match(curwin, id)) != NULL)
Karsten Hopp 0e7303
! 	    {
Karsten Hopp 0e7303
! 		list_append_string(rettv->vval.v_list,
Karsten Hopp 0e7303
! 						syn_id2name(m->hlg_id), -1);
Karsten Hopp 0e7303
! 		list_append_string(rettv->vval.v_list, m->pattern, -1);
Karsten Hopp 0e7303
! 	    }
Karsten Hopp 0e7303
! 	    else
Karsten Hopp 0e7303
! 	    {
Karsten Hopp 0e7303
! 		list_append_string(rettv->vval.v_list, NUL, -1);
Karsten Hopp 0e7303
! 		list_append_string(rettv->vval.v_list, NUL, -1);
Karsten Hopp 0e7303
! 	    }
Karsten Hopp 0e7303
  	}
Karsten Hopp 0e7303
  #endif
Karsten Hopp 0e7303
      }
Karsten Hopp 0e7303
  }
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
  /*
Karsten Hopp 0e7303
+  * "matchdelete()" function
Karsten Hopp 0e7303
+  */
Karsten Hopp 0e7303
+     static void
Karsten Hopp 0e7303
+ f_matchdelete(argvars, rettv)
Karsten Hopp 0e7303
+     typval_T	*argvars;
Karsten Hopp 0e7303
+     typval_T	*rettv;
Karsten Hopp 0e7303
+ {
Karsten Hopp 0e7303
+ #ifdef FEAT_SEARCH_EXTRA
Karsten Hopp 0e7303
+     rettv->vval.v_number = match_delete(curwin,
Karsten Hopp 0e7303
+ 				       (int)get_tv_number(&argvars[0]), TRUE);
Karsten Hopp 0e7303
+ #endif
Karsten Hopp 0e7303
+ }
Karsten Hopp 0e7303
+ 
Karsten Hopp 0e7303
+ /*
Karsten Hopp 0e7303
   * "matchend()" function
Karsten Hopp 0e7303
   */
Karsten Hopp 0e7303
      static void
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 14506,14511 ****
Karsten Hopp 0e7303
--- 14622,14687 ----
Karsten Hopp 0e7303
      win = find_win_by_nr(&argvars[0], NULL);
Karsten Hopp 0e7303
      if (win != NULL)
Karsten Hopp 0e7303
  	set_qf_ll_list(win, &argvars[1], &argvars[2], rettv);
Karsten Hopp 0e7303
+ }
Karsten Hopp 0e7303
+ 
Karsten Hopp 0e7303
+ /*
Karsten Hopp 0e7303
+  * "setmatches()" function
Karsten Hopp 0e7303
+  */
Karsten Hopp 0e7303
+     static void
Karsten Hopp 0e7303
+ f_setmatches(argvars, rettv)
Karsten Hopp 0e7303
+     typval_T	*argvars;
Karsten Hopp 0e7303
+     typval_T	*rettv;
Karsten Hopp 0e7303
+ {
Karsten Hopp 0e7303
+ #ifdef FEAT_SEARCH_EXTRA
Karsten Hopp 0e7303
+     list_T	*l;
Karsten Hopp 0e7303
+     listitem_T	*li;
Karsten Hopp 0e7303
+     dict_T	*d;
Karsten Hopp 0e7303
+ 
Karsten Hopp 0e7303
+     rettv->vval.v_number = -1;
Karsten Hopp 0e7303
+     if (argvars[0].v_type != VAR_LIST)
Karsten Hopp 0e7303
+     {
Karsten Hopp 0e7303
+ 	EMSG(_(e_listreq));
Karsten Hopp 0e7303
+ 	return;
Karsten Hopp 0e7303
+     }
Karsten Hopp 0e7303
+     if ((l = argvars[0].vval.v_list) != NULL)
Karsten Hopp 0e7303
+     {
Karsten Hopp 0e7303
+ 
Karsten Hopp 0e7303
+ 	/* To some extent make sure that we are dealing with a list from
Karsten Hopp 0e7303
+ 	 * "getmatches()". */
Karsten Hopp 0e7303
+ 	li = l->lv_first;
Karsten Hopp 0e7303
+ 	while (li != NULL)
Karsten Hopp 0e7303
+ 	{
Karsten Hopp 0e7303
+ 	    if (li->li_tv.v_type != VAR_DICT
Karsten Hopp 0e7303
+ 		    || (d = li->li_tv.vval.v_dict) == NULL)
Karsten Hopp 0e7303
+ 	    {
Karsten Hopp 0e7303
+ 		EMSG(_(e_invarg));
Karsten Hopp 0e7303
+ 		return;
Karsten Hopp 0e7303
+ 	    }
Karsten Hopp 0e7303
+ 	    if (!(dict_find(d, (char_u *)"group", -1) != NULL
Karsten Hopp 0e7303
+ 			&& dict_find(d, (char_u *)"pattern", -1) != NULL
Karsten Hopp 0e7303
+ 			&& dict_find(d, (char_u *)"priority", -1) != NULL
Karsten Hopp 0e7303
+ 			&& dict_find(d, (char_u *)"id", -1) != NULL))
Karsten Hopp 0e7303
+ 	    {
Karsten Hopp 0e7303
+ 		EMSG(_(e_invarg));
Karsten Hopp 0e7303
+ 		return;
Karsten Hopp 0e7303
+ 	    }
Karsten Hopp 0e7303
+ 	    li = li->li_next;
Karsten Hopp 0e7303
+ 	}
Karsten Hopp 0e7303
+ 
Karsten Hopp 0e7303
+ 	clear_matches(curwin);
Karsten Hopp 0e7303
+ 	li = l->lv_first;
Karsten Hopp 0e7303
+ 	while (li != NULL)
Karsten Hopp 0e7303
+ 	{
Karsten Hopp 0e7303
+ 	    d = li->li_tv.vval.v_dict;
Karsten Hopp 0e7303
+ 	    match_add(curwin, get_dict_string(d, (char_u *)"group", FALSE),
Karsten Hopp 0e7303
+ 		    get_dict_string(d, (char_u *)"pattern", FALSE),
Karsten Hopp 0e7303
+ 		    (int)get_dict_number(d, (char_u *)"priority"),
Karsten Hopp 0e7303
+ 		    (int)get_dict_number(d, (char_u *)"id"));
Karsten Hopp 0e7303
+ 	    li = li->li_next;
Karsten Hopp 0e7303
+ 	}
Karsten Hopp 0e7303
+ 	rettv->vval.v_number = 0;
Karsten Hopp 0e7303
+     }
Karsten Hopp 0e7303
+ #endif
Karsten Hopp 0e7303
  }
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
  /*
Karsten Hopp 0e7303
*** ../vim-7.1.039/src/ex_docmd.c	Tue Jul 24 14:32:44 2007
Karsten Hopp 0e7303
--- src/ex_docmd.c	Tue Jul 24 15:47:01 2007
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 10817,10828 ****
Karsten Hopp 0e7303
      exarg_T	*eap;
Karsten Hopp 0e7303
  {
Karsten Hopp 0e7303
      char_u	*p;
Karsten Hopp 0e7303
      char_u	*end;
Karsten Hopp 0e7303
      int		c;
Karsten Hopp 0e7303
!     int		mi;
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
      if (eap->line2 <= 3)
Karsten Hopp 0e7303
! 	mi = eap->line2 - 1;
Karsten Hopp 0e7303
      else
Karsten Hopp 0e7303
      {
Karsten Hopp 0e7303
  	EMSG(e_invcmd);
Karsten Hopp 0e7303
--- 10817,10829 ----
Karsten Hopp 0e7303
      exarg_T	*eap;
Karsten Hopp 0e7303
  {
Karsten Hopp 0e7303
      char_u	*p;
Karsten Hopp 0e7303
+     char_u	*g;
Karsten Hopp 0e7303
      char_u	*end;
Karsten Hopp 0e7303
      int		c;
Karsten Hopp 0e7303
!     int		id;
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
      if (eap->line2 <= 3)
Karsten Hopp 0e7303
! 	id = eap->line2;
Karsten Hopp 0e7303
      else
Karsten Hopp 0e7303
      {
Karsten Hopp 0e7303
  	EMSG(e_invcmd);
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 10831,10843 ****
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
      /* First clear any old pattern. */
Karsten Hopp 0e7303
      if (!eap->skip)
Karsten Hopp 0e7303
!     {
Karsten Hopp 0e7303
! 	vim_free(curwin->w_match[mi].regprog);
Karsten Hopp 0e7303
! 	curwin->w_match[mi].regprog = NULL;
Karsten Hopp 0e7303
! 	vim_free(curwin->w_match_pat[mi]);
Karsten Hopp 0e7303
! 	curwin->w_match_pat[mi] = NULL;
Karsten Hopp 0e7303
! 	redraw_later(SOME_VALID);	/* always need a redraw */
Karsten Hopp 0e7303
!     }
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
      if (ends_excmd(*eap->arg))
Karsten Hopp 0e7303
  	end = eap->arg;
Karsten Hopp 0e7303
--- 10832,10838 ----
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
      /* First clear any old pattern. */
Karsten Hopp 0e7303
      if (!eap->skip)
Karsten Hopp 0e7303
! 	match_delete(curwin, id, FALSE);
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
      if (ends_excmd(*eap->arg))
Karsten Hopp 0e7303
  	end = eap->arg;
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 10848,10862 ****
Karsten Hopp 0e7303
      {
Karsten Hopp 0e7303
  	p = skiptowhite(eap->arg);
Karsten Hopp 0e7303
  	if (!eap->skip)
Karsten Hopp 0e7303
! 	{
Karsten Hopp 0e7303
! 	    curwin->w_match_id[mi] = syn_namen2id(eap->arg,
Karsten Hopp 0e7303
! 							 (int)(p - eap->arg));
Karsten Hopp 0e7303
! 	    if (curwin->w_match_id[mi] == 0)
Karsten Hopp 0e7303
! 	    {
Karsten Hopp 0e7303
! 		EMSG2(_(e_nogroup), eap->arg);
Karsten Hopp 0e7303
! 		return;
Karsten Hopp 0e7303
! 	    }
Karsten Hopp 0e7303
! 	}
Karsten Hopp 0e7303
  	p = skipwhite(p);
Karsten Hopp 0e7303
  	if (*p == NUL)
Karsten Hopp 0e7303
  	{
Karsten Hopp 0e7303
--- 10843,10849 ----
Karsten Hopp 0e7303
      {
Karsten Hopp 0e7303
  	p = skiptowhite(eap->arg);
Karsten Hopp 0e7303
  	if (!eap->skip)
Karsten Hopp 0e7303
! 	    g = vim_strnsave(eap->arg, (int)(p - eap->arg));
Karsten Hopp 0e7303
  	p = skipwhite(p);
Karsten Hopp 0e7303
  	if (*p == NUL)
Karsten Hopp 0e7303
  	{
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 10880,10893 ****
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
  	    c = *end;
Karsten Hopp 0e7303
  	    *end = NUL;
Karsten Hopp 0e7303
! 	    curwin->w_match[mi].regprog = vim_regcomp(p + 1, RE_MAGIC);
Karsten Hopp 0e7303
! 	    if (curwin->w_match[mi].regprog == NULL)
Karsten Hopp 0e7303
! 	    {
Karsten Hopp 0e7303
! 		EMSG2(_(e_invarg2), p);
Karsten Hopp 0e7303
! 		*end = c;
Karsten Hopp 0e7303
! 		return;
Karsten Hopp 0e7303
! 	    }
Karsten Hopp 0e7303
! 	    curwin->w_match_pat[mi] = vim_strsave(p + 1);
Karsten Hopp 0e7303
  	    *end = c;
Karsten Hopp 0e7303
  	}
Karsten Hopp 0e7303
      }
Karsten Hopp 0e7303
--- 10867,10874 ----
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
  	    c = *end;
Karsten Hopp 0e7303
  	    *end = NUL;
Karsten Hopp 0e7303
! 	    match_add(curwin, g, p + 1, 10, id);
Karsten Hopp 0e7303
! 	    vim_free(g);
Karsten Hopp 0e7303
  	    *end = c;
Karsten Hopp 0e7303
  	}
Karsten Hopp 0e7303
      }
Karsten Hopp 0e7303
*** ../vim-7.1.039/src/proto/window.pro	Sat May  5 19:52:36 2007
Karsten Hopp 0e7303
--- src/proto/window.pro	Tue Jul 24 16:38:19 2007
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 59,62 ****
Karsten Hopp 0e7303
--- 59,66 ----
Karsten Hopp 0e7303
  int only_one_window __ARGS((void));
Karsten Hopp 0e7303
  void check_lnums __ARGS((int do_curwin));
Karsten Hopp 0e7303
  int win_hasvertsplit __ARGS((void));
Karsten Hopp 0e7303
+ int match_add __ARGS((win_T *wp, char_u *grp, char_u *pat, int prio, int id));
Karsten Hopp 0e7303
+ int match_delete __ARGS((win_T *wp, int id, int perr));
Karsten Hopp 0e7303
+ void clear_matches __ARGS((win_T *wp));
Karsten Hopp 0e7303
+ matchitem_T *get_match __ARGS((win_T *wp, int id));
Karsten Hopp 0e7303
  /* vim: set ft=c : */
Karsten Hopp 0e7303
*** ../vim-7.1.039/src/screen.c	Tue Jun 19 17:49:12 2007
Karsten Hopp 0e7303
--- src/screen.c	Thu Jul 26 21:55:40 2007
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 100,126 ****
Karsten Hopp 0e7303
  static int	screen_cur_row, screen_cur_col;	/* last known cursor position */
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
  #ifdef FEAT_SEARCH_EXTRA
Karsten Hopp 0e7303
- /*
Karsten Hopp 0e7303
-  * Struct used for highlighting 'hlsearch' matches for the last use search
Karsten Hopp 0e7303
-  * pattern or a ":match" item.
Karsten Hopp 0e7303
-  * For 'hlsearch' there is one pattern for all windows.  For ":match" there is
Karsten Hopp 0e7303
-  * a different pattern for each window.
Karsten Hopp 0e7303
-  */
Karsten Hopp 0e7303
- typedef struct
Karsten Hopp 0e7303
- {
Karsten Hopp 0e7303
-     regmmatch_T	rm;	/* points to the regexp program; contains last found
Karsten Hopp 0e7303
- 			   match (may continue in next line) */
Karsten Hopp 0e7303
-     buf_T	*buf;	/* the buffer to search for a match */
Karsten Hopp 0e7303
-     linenr_T	lnum;	/* the line to search for a match */
Karsten Hopp 0e7303
-     int		attr;	/* attributes to be used for a match */
Karsten Hopp 0e7303
-     int		attr_cur; /* attributes currently active in win_line() */
Karsten Hopp 0e7303
-     linenr_T	first_lnum;	/* first lnum to search for multi-line pat */
Karsten Hopp 0e7303
-     colnr_T	startcol; /* in win_line() points to char where HL starts */
Karsten Hopp 0e7303
-     colnr_T	endcol;	 /* in win_line() points to char where HL ends */
Karsten Hopp 0e7303
- } match_T;
Karsten Hopp 0e7303
- 
Karsten Hopp 0e7303
  static match_T search_hl;	/* used for 'hlsearch' highlight matching */
Karsten Hopp 0e7303
- static match_T match_hl[3];	/* used for ":match" highlight matching */
Karsten Hopp 0e7303
  #endif
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
  #ifdef FEAT_FOLDING
Karsten Hopp 0e7303
--- 100,106 ----
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 155,160 ****
Karsten Hopp 0e7303
--- 135,141 ----
Karsten Hopp 0e7303
  static void redraw_custum_statusline __ARGS((win_T *wp));
Karsten Hopp 0e7303
  #endif
Karsten Hopp 0e7303
  #ifdef FEAT_SEARCH_EXTRA
Karsten Hopp 0e7303
+ #define SEARCH_HL_PRIORITY 0
Karsten Hopp 0e7303
  static void start_search_hl __ARGS((void));
Karsten Hopp 0e7303
  static void end_search_hl __ARGS((void));
Karsten Hopp 0e7303
  static void prepare_search_hl __ARGS((win_T *wp, linenr_T lnum));
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 787,792 ****
Karsten Hopp 0e7303
--- 768,774 ----
Karsten Hopp 0e7303
  					   w_topline got smaller a bit */
Karsten Hopp 0e7303
  #endif
Karsten Hopp 0e7303
  #ifdef FEAT_SEARCH_EXTRA
Karsten Hopp 0e7303
+     matchitem_T *cur;		/* points to the match list */
Karsten Hopp 0e7303
      int		top_to_mod = FALSE;    /* redraw above mod_top */
Karsten Hopp 0e7303
  #endif
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 848,865 ****
Karsten Hopp 0e7303
  #endif
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
  #ifdef FEAT_SEARCH_EXTRA
Karsten Hopp 0e7303
!     /* Setup for ":match" and 'hlsearch' highlighting.  Disable any previous
Karsten Hopp 0e7303
       * match */
Karsten Hopp 0e7303
!     for (i = 0; i < 3; ++i)
Karsten Hopp 0e7303
      {
Karsten Hopp 0e7303
! 	match_hl[i].rm = wp->w_match[i];
Karsten Hopp 0e7303
! 	if (wp->w_match_id[i] == 0)
Karsten Hopp 0e7303
! 	    match_hl[i].attr = 0;
Karsten Hopp 0e7303
  	else
Karsten Hopp 0e7303
! 	    match_hl[i].attr = syn_id2attr(wp->w_match_id[i]);
Karsten Hopp 0e7303
! 	match_hl[i].buf = buf;
Karsten Hopp 0e7303
! 	match_hl[i].lnum = 0;
Karsten Hopp 0e7303
! 	match_hl[i].first_lnum = 0;
Karsten Hopp 0e7303
      }
Karsten Hopp 0e7303
      search_hl.buf = buf;
Karsten Hopp 0e7303
      search_hl.lnum = 0;
Karsten Hopp 0e7303
--- 830,849 ----
Karsten Hopp 0e7303
  #endif
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
  #ifdef FEAT_SEARCH_EXTRA
Karsten Hopp 0e7303
!     /* Setup for match and 'hlsearch' highlighting.  Disable any previous
Karsten Hopp 0e7303
       * match */
Karsten Hopp 0e7303
!     cur = wp->w_match_head;
Karsten Hopp 0e7303
!     while (cur != NULL)
Karsten Hopp 0e7303
      {
Karsten Hopp 0e7303
! 	cur->hl.rm = cur->match;
Karsten Hopp 0e7303
! 	if (cur->hlg_id == 0)
Karsten Hopp 0e7303
! 	    cur->hl.attr = 0;
Karsten Hopp 0e7303
  	else
Karsten Hopp 0e7303
! 	    cur->hl.attr = syn_id2attr(cur->hlg_id);
Karsten Hopp 0e7303
! 	cur->hl.buf = buf;
Karsten Hopp 0e7303
! 	cur->hl.lnum = 0;
Karsten Hopp 0e7303
! 	cur->hl.first_lnum = 0;
Karsten Hopp 0e7303
! 	cur = cur->next;
Karsten Hopp 0e7303
      }
Karsten Hopp 0e7303
      search_hl.buf = buf;
Karsten Hopp 0e7303
      search_hl.lnum = 0;
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 923,941 ****
Karsten Hopp 0e7303
  	     * change in one line may make the Search highlighting in a
Karsten Hopp 0e7303
  	     * previous line invalid.  Simple solution: redraw all visible
Karsten Hopp 0e7303
  	     * lines above the change.
Karsten Hopp 0e7303
! 	     * Same for a ":match" pattern.
Karsten Hopp 0e7303
  	     */
Karsten Hopp 0e7303
  	    if (search_hl.rm.regprog != NULL
Karsten Hopp 0e7303
  					&& re_multiline(search_hl.rm.regprog))
Karsten Hopp 0e7303
  		top_to_mod = TRUE;
Karsten Hopp 0e7303
  	    else
Karsten Hopp 0e7303
! 		for (i = 0; i < 3; ++i)
Karsten Hopp 0e7303
! 		    if (match_hl[i].rm.regprog != NULL
Karsten Hopp 0e7303
! 				      && re_multiline(match_hl[i].rm.regprog))
Karsten Hopp 0e7303
  		    {
Karsten Hopp 0e7303
  			top_to_mod = TRUE;
Karsten Hopp 0e7303
  			break;
Karsten Hopp 0e7303
  		    }
Karsten Hopp 0e7303
  #endif
Karsten Hopp 0e7303
  	}
Karsten Hopp 0e7303
  #ifdef FEAT_FOLDING
Karsten Hopp 0e7303
--- 907,931 ----
Karsten Hopp 0e7303
  	     * change in one line may make the Search highlighting in a
Karsten Hopp 0e7303
  	     * previous line invalid.  Simple solution: redraw all visible
Karsten Hopp 0e7303
  	     * lines above the change.
Karsten Hopp 0e7303
! 	     * Same for a match pattern.
Karsten Hopp 0e7303
  	     */
Karsten Hopp 0e7303
  	    if (search_hl.rm.regprog != NULL
Karsten Hopp 0e7303
  					&& re_multiline(search_hl.rm.regprog))
Karsten Hopp 0e7303
  		top_to_mod = TRUE;
Karsten Hopp 0e7303
  	    else
Karsten Hopp 0e7303
! 	    {
Karsten Hopp 0e7303
! 		cur = wp->w_match_head;
Karsten Hopp 0e7303
! 		while (cur != NULL)
Karsten Hopp 0e7303
! 		{
Karsten Hopp 0e7303
! 		    if (cur->match.regprog != NULL
Karsten Hopp 0e7303
! 					   && re_multiline(cur->match.regprog))
Karsten Hopp 0e7303
  		    {
Karsten Hopp 0e7303
  			top_to_mod = TRUE;
Karsten Hopp 0e7303
  			break;
Karsten Hopp 0e7303
  		    }
Karsten Hopp 0e7303
+ 		    cur = cur->next;
Karsten Hopp 0e7303
+ 		}
Karsten Hopp 0e7303
+ 	    }
Karsten Hopp 0e7303
  #endif
Karsten Hopp 0e7303
  	}
Karsten Hopp 0e7303
  #ifdef FEAT_FOLDING
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 2626,2635 ****
Karsten Hopp 0e7303
      int		line_attr = 0;		/* atrribute for the whole line */
Karsten Hopp 0e7303
  #endif
Karsten Hopp 0e7303
  #ifdef FEAT_SEARCH_EXTRA
Karsten Hopp 0e7303
!     match_T	*shl;			/* points to search_hl or match_hl */
Karsten Hopp 0e7303
! #endif
Karsten Hopp 0e7303
! #if defined(FEAT_SEARCH_EXTRA) || defined(FEAT_MBYTE)
Karsten Hopp 0e7303
!     int		i;
Karsten Hopp 0e7303
  #endif
Karsten Hopp 0e7303
  #ifdef FEAT_ARABIC
Karsten Hopp 0e7303
      int		prev_c = 0;		/* previous Arabic character */
Karsten Hopp 0e7303
--- 2634,2646 ----
Karsten Hopp 0e7303
      int		line_attr = 0;		/* atrribute for the whole line */
Karsten Hopp 0e7303
  #endif
Karsten Hopp 0e7303
  #ifdef FEAT_SEARCH_EXTRA
Karsten Hopp 0e7303
!     matchitem_T *cur;			/* points to the match list */
Karsten Hopp 0e7303
!     match_T	*shl;			/* points to search_hl or a match */
Karsten Hopp 0e7303
!     int		shl_flag;		/* flag to indicate whether search_hl
Karsten Hopp 0e7303
! 					   has been processed or not */
Karsten Hopp 0e7303
!     int		prevcol_hl_flag;	/* flag to indicate whether prevcol
Karsten Hopp 0e7303
! 					   equals startcol of search_hl or one
Karsten Hopp 0e7303
! 					   of the matches */
Karsten Hopp 0e7303
  #endif
Karsten Hopp 0e7303
  #ifdef FEAT_ARABIC
Karsten Hopp 0e7303
      int		prev_c = 0;		/* previous Arabic character */
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 3074,3085 ****
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
  #ifdef FEAT_SEARCH_EXTRA
Karsten Hopp 0e7303
      /*
Karsten Hopp 0e7303
!      * Handle highlighting the last used search pattern and ":match".
Karsten Hopp 0e7303
!      * Do this for both search_hl and match_hl[3].
Karsten Hopp 0e7303
       */
Karsten Hopp 0e7303
!     for (i = 3; i >= 0; --i)
Karsten Hopp 0e7303
      {
Karsten Hopp 0e7303
! 	shl = (i == 3) ? &search_hl : &match_hl[i];
Karsten Hopp 0e7303
  	shl->startcol = MAXCOL;
Karsten Hopp 0e7303
  	shl->endcol = MAXCOL;
Karsten Hopp 0e7303
  	shl->attr_cur = 0;
Karsten Hopp 0e7303
--- 3085,3104 ----
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
  #ifdef FEAT_SEARCH_EXTRA
Karsten Hopp 0e7303
      /*
Karsten Hopp 0e7303
!      * Handle highlighting the last used search pattern and matches.
Karsten Hopp 0e7303
!      * Do this for both search_hl and the match list.
Karsten Hopp 0e7303
       */
Karsten Hopp 0e7303
!     cur = wp->w_match_head;
Karsten Hopp 0e7303
!     shl_flag = FALSE;
Karsten Hopp 0e7303
!     while (cur != NULL || shl_flag == FALSE)
Karsten Hopp 0e7303
      {
Karsten Hopp 0e7303
! 	if (shl_flag == FALSE)
Karsten Hopp 0e7303
! 	{
Karsten Hopp 0e7303
! 	    shl = &search_hl;
Karsten Hopp 0e7303
! 	    shl_flag = TRUE;
Karsten Hopp 0e7303
! 	}
Karsten Hopp 0e7303
! 	else
Karsten Hopp 0e7303
! 	    shl = &cur->hl;
Karsten Hopp 0e7303
  	shl->startcol = MAXCOL;
Karsten Hopp 0e7303
  	shl->endcol = MAXCOL;
Karsten Hopp 0e7303
  	shl->attr_cur = 0;
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 3122,3127 ****
Karsten Hopp 0e7303
--- 3141,3148 ----
Karsten Hopp 0e7303
  		area_highlighting = TRUE;
Karsten Hopp 0e7303
  	    }
Karsten Hopp 0e7303
  	}
Karsten Hopp 0e7303
+ 	if (shl != &search_hl && cur != NULL)
Karsten Hopp 0e7303
+ 	    cur = cur->next;
Karsten Hopp 0e7303
      }
Karsten Hopp 0e7303
  #endif
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 3388,3400 ****
Karsten Hopp 0e7303
  		 * After end, check for start/end of next match.
Karsten Hopp 0e7303
  		 * When another match, have to check for start again.
Karsten Hopp 0e7303
  		 * Watch out for matching an empty string!
Karsten Hopp 0e7303
! 		 * Do this first for search_hl, then for match_hl, so that
Karsten Hopp 0e7303
! 		 * ":match" overrules 'hlsearch'.
Karsten Hopp 0e7303
  		 */
Karsten Hopp 0e7303
  		v = (long)(ptr - line);
Karsten Hopp 0e7303
! 		for (i = 3; i >= 0; --i)
Karsten Hopp 0e7303
! 		{
Karsten Hopp 0e7303
! 		    shl = (i == 3) ? &search_hl : &match_hl[i];
Karsten Hopp 0e7303
  		    while (shl->rm.regprog != NULL)
Karsten Hopp 0e7303
  		    {
Karsten Hopp 0e7303
  			if (shl->startcol != MAXCOL
Karsten Hopp 0e7303
--- 3409,3432 ----
Karsten Hopp 0e7303
  		 * After end, check for start/end of next match.
Karsten Hopp 0e7303
  		 * When another match, have to check for start again.
Karsten Hopp 0e7303
  		 * Watch out for matching an empty string!
Karsten Hopp 0e7303
! 		 * Do this for 'search_hl' and the match list (ordered by
Karsten Hopp 0e7303
! 		 * priority).
Karsten Hopp 0e7303
  		 */
Karsten Hopp 0e7303
  		v = (long)(ptr - line);
Karsten Hopp 0e7303
! 		cur = wp->w_match_head;
Karsten Hopp 0e7303
! 		shl_flag = FALSE;
Karsten Hopp 0e7303
! 		while (cur != NULL || shl_flag == FALSE)
Karsten Hopp 0e7303
! 		{
Karsten Hopp 0e7303
! 		    if (shl_flag == FALSE
Karsten Hopp 0e7303
! 			    && ((cur != NULL
Karsten Hopp 0e7303
! 				    && cur->priority > SEARCH_HL_PRIORITY)
Karsten Hopp 0e7303
! 				|| cur == NULL))
Karsten Hopp 0e7303
! 		    {
Karsten Hopp 0e7303
! 			shl = &search_hl;
Karsten Hopp 0e7303
! 			shl_flag = TRUE;
Karsten Hopp 0e7303
! 		    }
Karsten Hopp 0e7303
! 		    else
Karsten Hopp 0e7303
! 			shl = &cur->hl;
Karsten Hopp 0e7303
  		    while (shl->rm.regprog != NULL)
Karsten Hopp 0e7303
  		    {
Karsten Hopp 0e7303
  			if (shl->startcol != MAXCOL
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 3442,3458 ****
Karsten Hopp 0e7303
  			}
Karsten Hopp 0e7303
  			break;
Karsten Hopp 0e7303
  		    }
Karsten Hopp 0e7303
  		}
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
! 		/* ":match" highlighting overrules 'hlsearch' */
Karsten Hopp 0e7303
! 		for (i = 0; i <= 3; ++i)
Karsten Hopp 0e7303
! 		    if (i == 3)
Karsten Hopp 0e7303
! 			search_attr = search_hl.attr_cur;
Karsten Hopp 0e7303
! 		    else if (match_hl[i].attr_cur != 0)
Karsten Hopp 0e7303
  		    {
Karsten Hopp 0e7303
! 			search_attr = match_hl[i].attr_cur;
Karsten Hopp 0e7303
! 			break;
Karsten Hopp 0e7303
  		    }
Karsten Hopp 0e7303
  	    }
Karsten Hopp 0e7303
  #endif
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
--- 3474,3505 ----
Karsten Hopp 0e7303
  			}
Karsten Hopp 0e7303
  			break;
Karsten Hopp 0e7303
  		    }
Karsten Hopp 0e7303
+ 		    if (shl != &search_hl && cur != NULL)
Karsten Hopp 0e7303
+ 			cur = cur->next;
Karsten Hopp 0e7303
  		}
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
! 		/* Use attributes from match with highest priority among
Karsten Hopp 0e7303
! 		 * 'search_hl' and the match list. */
Karsten Hopp 0e7303
! 		search_attr = search_hl.attr_cur;
Karsten Hopp 0e7303
! 		cur = wp->w_match_head;
Karsten Hopp 0e7303
! 		shl_flag = FALSE;
Karsten Hopp 0e7303
! 		while (cur != NULL || shl_flag == FALSE)
Karsten Hopp 0e7303
! 		{
Karsten Hopp 0e7303
! 		    if (shl_flag == FALSE
Karsten Hopp 0e7303
! 			    && ((cur != NULL
Karsten Hopp 0e7303
! 				    && cur->priority > SEARCH_HL_PRIORITY)
Karsten Hopp 0e7303
! 				|| cur == NULL))
Karsten Hopp 0e7303
  		    {
Karsten Hopp 0e7303
! 			shl = &search_hl;
Karsten Hopp 0e7303
! 			shl_flag = TRUE;
Karsten Hopp 0e7303
  		    }
Karsten Hopp 0e7303
+ 		    else
Karsten Hopp 0e7303
+ 			shl = &cur->hl;
Karsten Hopp 0e7303
+ 		    if (shl->attr_cur != 0)
Karsten Hopp 0e7303
+ 			search_attr = shl->attr_cur;
Karsten Hopp 0e7303
+ 		    if (shl != &search_hl && cur != NULL)
Karsten Hopp 0e7303
+ 			cur = cur->next;
Karsten Hopp 0e7303
+ 		}
Karsten Hopp 0e7303
  	    }
Karsten Hopp 0e7303
  #endif
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 3613,3618 ****
Karsten Hopp 0e7303
--- 3660,3667 ----
Karsten Hopp 0e7303
  			 * Draw it as a space with a composing char. */
Karsten Hopp 0e7303
  			if (utf_iscomposing(mb_c))
Karsten Hopp 0e7303
  			{
Karsten Hopp 0e7303
+ 			    int i;
Karsten Hopp 0e7303
+ 
Karsten Hopp 0e7303
  			    for (i = Screen_mco - 1; i > 0; --i)
Karsten Hopp 0e7303
  				u8cc[i] = u8cc[i - 1];
Karsten Hopp 0e7303
  			    u8cc[0] = mb_c;
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 4256,4269 ****
Karsten Hopp 0e7303
  	     * highlight match at end of line. If it's beyond the last
Karsten Hopp 0e7303
  	     * char on the screen, just overwrite that one (tricky!)  Not
Karsten Hopp 0e7303
  	     * needed when a '$' was displayed for 'list'. */
Karsten Hopp 0e7303
  	    if (lcs_eol == lcs_eol_one
Karsten Hopp 0e7303
  		    && ((area_attr != 0 && vcol == fromcol && c == NUL)
Karsten Hopp 0e7303
  #ifdef FEAT_SEARCH_EXTRA
Karsten Hopp 0e7303
  			/* highlight 'hlsearch' match at end of line */
Karsten Hopp 0e7303
! 			|| ((prevcol == (long)search_hl.startcol
Karsten Hopp 0e7303
! 				|| prevcol == (long)match_hl[0].startcol
Karsten Hopp 0e7303
! 				|| prevcol == (long)match_hl[1].startcol
Karsten Hopp 0e7303
! 				|| prevcol == (long)match_hl[2].startcol)
Karsten Hopp 0e7303
  # if defined(LINE_ATTR)
Karsten Hopp 0e7303
  			    && did_line_attr <= 1
Karsten Hopp 0e7303
  # endif
Karsten Hopp 0e7303
--- 4305,4333 ----
Karsten Hopp 0e7303
  	     * highlight match at end of line. If it's beyond the last
Karsten Hopp 0e7303
  	     * char on the screen, just overwrite that one (tricky!)  Not
Karsten Hopp 0e7303
  	     * needed when a '$' was displayed for 'list'. */
Karsten Hopp 0e7303
+ #ifdef FEAT_SEARCH_EXTRA
Karsten Hopp 0e7303
+ 	    prevcol_hl_flag = FALSE;
Karsten Hopp 0e7303
+ 	    if (prevcol == (long)search_hl.startcol)
Karsten Hopp 0e7303
+ 		prevcol_hl_flag = TRUE;
Karsten Hopp 0e7303
+ 	    else
Karsten Hopp 0e7303
+ 	    {
Karsten Hopp 0e7303
+ 		cur = wp->w_match_head;
Karsten Hopp 0e7303
+ 		while (cur != NULL)
Karsten Hopp 0e7303
+ 		{
Karsten Hopp 0e7303
+ 		    if (prevcol == (long)cur->hl.startcol)
Karsten Hopp 0e7303
+ 		    {
Karsten Hopp 0e7303
+ 			prevcol_hl_flag = TRUE;
Karsten Hopp 0e7303
+ 			break;
Karsten Hopp 0e7303
+ 		    }
Karsten Hopp 0e7303
+ 		    cur = cur->next;
Karsten Hopp 0e7303
+ 		}
Karsten Hopp 0e7303
+ 	    }
Karsten Hopp 0e7303
+ #endif
Karsten Hopp 0e7303
  	    if (lcs_eol == lcs_eol_one
Karsten Hopp 0e7303
  		    && ((area_attr != 0 && vcol == fromcol && c == NUL)
Karsten Hopp 0e7303
  #ifdef FEAT_SEARCH_EXTRA
Karsten Hopp 0e7303
  			/* highlight 'hlsearch' match at end of line */
Karsten Hopp 0e7303
! 			|| (prevcol_hl_flag == TRUE
Karsten Hopp 0e7303
  # if defined(LINE_ATTR)
Karsten Hopp 0e7303
  			    && did_line_attr <= 1
Karsten Hopp 0e7303
  # endif
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 4304,4318 ****
Karsten Hopp 0e7303
  #ifdef FEAT_SEARCH_EXTRA
Karsten Hopp 0e7303
  		if (area_attr == 0)
Karsten Hopp 0e7303
  		{
Karsten Hopp 0e7303
! 		    for (i = 0; i <= 3; ++i)
Karsten Hopp 0e7303
! 		    {
Karsten Hopp 0e7303
! 			if (i == 3)
Karsten Hopp 0e7303
! 			    char_attr = search_hl.attr;
Karsten Hopp 0e7303
! 			else if ((ptr - line) - 1 == (long)match_hl[i].startcol)
Karsten Hopp 0e7303
  			{
Karsten Hopp 0e7303
! 			    char_attr = match_hl[i].attr;
Karsten Hopp 0e7303
! 			    break;
Karsten Hopp 0e7303
  			}
Karsten Hopp 0e7303
  		    }
Karsten Hopp 0e7303
  		}
Karsten Hopp 0e7303
  #endif
Karsten Hopp 0e7303
--- 4368,4394 ----
Karsten Hopp 0e7303
  #ifdef FEAT_SEARCH_EXTRA
Karsten Hopp 0e7303
  		if (area_attr == 0)
Karsten Hopp 0e7303
  		{
Karsten Hopp 0e7303
! 		    /* Use attributes from match with highest priority among
Karsten Hopp 0e7303
! 		     * 'search_hl' and the match list. */
Karsten Hopp 0e7303
! 		    char_attr = search_hl.attr;
Karsten Hopp 0e7303
! 		    cur = wp->w_match_head;
Karsten Hopp 0e7303
! 		    shl_flag = FALSE;
Karsten Hopp 0e7303
! 		    while (cur != NULL || shl_flag == FALSE)
Karsten Hopp 0e7303
! 		    {
Karsten Hopp 0e7303
! 			if (shl_flag == FALSE
Karsten Hopp 0e7303
! 				&& ((cur != NULL
Karsten Hopp 0e7303
! 					&& cur->priority > SEARCH_HL_PRIORITY)
Karsten Hopp 0e7303
! 				    || cur == NULL))
Karsten Hopp 0e7303
  			{
Karsten Hopp 0e7303
! 			    shl = &search_hl;
Karsten Hopp 0e7303
! 			    shl_flag = TRUE;
Karsten Hopp 0e7303
  			}
Karsten Hopp 0e7303
+ 			else
Karsten Hopp 0e7303
+ 			    shl = &cur->hl;
Karsten Hopp 0e7303
+ 			if ((ptr - line) - 1 == (long)shl->startcol)
Karsten Hopp 0e7303
+ 			    char_attr = shl->attr;
Karsten Hopp 0e7303
+ 			if (shl != &search_hl && cur != NULL)
Karsten Hopp 0e7303
+ 			    cur = cur->next;
Karsten Hopp 0e7303
  		    }
Karsten Hopp 0e7303
  		}
Karsten Hopp 0e7303
  #endif
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 4462,4467 ****
Karsten Hopp 0e7303
--- 4538,4545 ----
Karsten Hopp 0e7303
  	    {
Karsten Hopp 0e7303
  		if (mb_utf8)
Karsten Hopp 0e7303
  		{
Karsten Hopp 0e7303
+ 		    int i;
Karsten Hopp 0e7303
+ 
Karsten Hopp 0e7303
  		    ScreenLinesUC[off] = mb_c;
Karsten Hopp 0e7303
  		    if ((c & 0xff) == 0)
Karsten Hopp 0e7303
  			ScreenLines[off] = 0x80;   /* avoid storing zero */
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 6320,6326 ****
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
  #ifdef FEAT_SEARCH_EXTRA
Karsten Hopp 0e7303
  /*
Karsten Hopp 0e7303
!  * Prepare for 'searchhl' highlighting.
Karsten Hopp 0e7303
   */
Karsten Hopp 0e7303
      static void
Karsten Hopp 0e7303
  start_search_hl()
Karsten Hopp 0e7303
--- 6398,6404 ----
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
  #ifdef FEAT_SEARCH_EXTRA
Karsten Hopp 0e7303
  /*
Karsten Hopp 0e7303
!  * Prepare for 'hlsearch' highlighting.
Karsten Hopp 0e7303
   */
Karsten Hopp 0e7303
      static void
Karsten Hopp 0e7303
  start_search_hl()
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 6333,6339 ****
Karsten Hopp 0e7303
  }
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
  /*
Karsten Hopp 0e7303
!  * Clean up for 'searchhl' highlighting.
Karsten Hopp 0e7303
   */
Karsten Hopp 0e7303
      static void
Karsten Hopp 0e7303
  end_search_hl()
Karsten Hopp 0e7303
--- 6411,6417 ----
Karsten Hopp 0e7303
  }
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
  /*
Karsten Hopp 0e7303
!  * Clean up for 'hlsearch' highlighting.
Karsten Hopp 0e7303
   */
Karsten Hopp 0e7303
      static void
Karsten Hopp 0e7303
  end_search_hl()
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 6353,6370 ****
Karsten Hopp 0e7303
      win_T	*wp;
Karsten Hopp 0e7303
      linenr_T	lnum;
Karsten Hopp 0e7303
  {
Karsten Hopp 0e7303
!     match_T	*shl;		/* points to search_hl or match_hl */
Karsten Hopp 0e7303
      int		n;
Karsten Hopp 0e7303
-     int		i;
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
      /*
Karsten Hopp 0e7303
       * When using a multi-line pattern, start searching at the top
Karsten Hopp 0e7303
       * of the window or just after a closed fold.
Karsten Hopp 0e7303
!      * Do this both for search_hl and match_hl[3].
Karsten Hopp 0e7303
       */
Karsten Hopp 0e7303
!     for (i = 3; i >= 0; --i)
Karsten Hopp 0e7303
      {
Karsten Hopp 0e7303
! 	shl = (i == 3) ? &search_hl : &match_hl[i];
Karsten Hopp 0e7303
  	if (shl->rm.regprog != NULL
Karsten Hopp 0e7303
  		&& shl->lnum == 0
Karsten Hopp 0e7303
  		&& re_multiline(shl->rm.regprog))
Karsten Hopp 0e7303
--- 6431,6458 ----
Karsten Hopp 0e7303
      win_T	*wp;
Karsten Hopp 0e7303
      linenr_T	lnum;
Karsten Hopp 0e7303
  {
Karsten Hopp 0e7303
!     matchitem_T *cur;		/* points to the match list */
Karsten Hopp 0e7303
!     match_T	*shl;		/* points to search_hl or a match */
Karsten Hopp 0e7303
!     int		shl_flag;	/* flag to indicate whether search_hl
Karsten Hopp 0e7303
! 				   has been processed or not */
Karsten Hopp 0e7303
      int		n;
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
      /*
Karsten Hopp 0e7303
       * When using a multi-line pattern, start searching at the top
Karsten Hopp 0e7303
       * of the window or just after a closed fold.
Karsten Hopp 0e7303
!      * Do this both for search_hl and the match list.
Karsten Hopp 0e7303
       */
Karsten Hopp 0e7303
!     cur = wp->w_match_head;
Karsten Hopp 0e7303
!     shl_flag = FALSE;
Karsten Hopp 0e7303
!     while (cur != NULL || shl_flag == FALSE)
Karsten Hopp 0e7303
      {
Karsten Hopp 0e7303
! 	if (shl_flag == FALSE)
Karsten Hopp 0e7303
! 	{
Karsten Hopp 0e7303
! 	    shl = &search_hl;
Karsten Hopp 0e7303
! 	    shl_flag = TRUE;
Karsten Hopp 0e7303
! 	}
Karsten Hopp 0e7303
! 	else
Karsten Hopp 0e7303
! 	    shl = &cur->hl;
Karsten Hopp 0e7303
  	if (shl->rm.regprog != NULL
Karsten Hopp 0e7303
  		&& shl->lnum == 0
Karsten Hopp 0e7303
  		&& re_multiline(shl->rm.regprog))
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 6399,6409 ****
Karsten Hopp 0e7303
  		}
Karsten Hopp 0e7303
  	    }
Karsten Hopp 0e7303
  	}
Karsten Hopp 0e7303
      }
Karsten Hopp 0e7303
  }
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
  /*
Karsten Hopp 0e7303
!  * Search for a next 'searchl' or ":match" match.
Karsten Hopp 0e7303
   * Uses shl->buf.
Karsten Hopp 0e7303
   * Sets shl->lnum and shl->rm contents.
Karsten Hopp 0e7303
   * Note: Assumes a previous match is always before "lnum", unless
Karsten Hopp 0e7303
--- 6487,6499 ----
Karsten Hopp 0e7303
  		}
Karsten Hopp 0e7303
  	    }
Karsten Hopp 0e7303
  	}
Karsten Hopp 0e7303
+ 	if (shl != &search_hl && cur != NULL)
Karsten Hopp 0e7303
+ 	    cur = cur->next;
Karsten Hopp 0e7303
      }
Karsten Hopp 0e7303
  }
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
  /*
Karsten Hopp 0e7303
!  * Search for a next 'hlsearch' or match.
Karsten Hopp 0e7303
   * Uses shl->buf.
Karsten Hopp 0e7303
   * Sets shl->lnum and shl->rm contents.
Karsten Hopp 0e7303
   * Note: Assumes a previous match is always before "lnum", unless
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 6413,6419 ****
Karsten Hopp 0e7303
      static void
Karsten Hopp 0e7303
  next_search_hl(win, shl, lnum, mincol)
Karsten Hopp 0e7303
      win_T	*win;
Karsten Hopp 0e7303
!     match_T	*shl;		/* points to search_hl or match_hl */
Karsten Hopp 0e7303
      linenr_T	lnum;
Karsten Hopp 0e7303
      colnr_T	mincol;		/* minimal column for a match */
Karsten Hopp 0e7303
  {
Karsten Hopp 0e7303
--- 6503,6509 ----
Karsten Hopp 0e7303
      static void
Karsten Hopp 0e7303
  next_search_hl(win, shl, lnum, mincol)
Karsten Hopp 0e7303
      win_T	*win;
Karsten Hopp 0e7303
!     match_T	*shl;		/* points to search_hl or a match */
Karsten Hopp 0e7303
      linenr_T	lnum;
Karsten Hopp 0e7303
      colnr_T	mincol;		/* minimal column for a match */
Karsten Hopp 0e7303
  {
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 6481,6487 ****
Karsten Hopp 0e7303
  	    /* Error while handling regexp: stop using this regexp. */
Karsten Hopp 0e7303
  	    if (shl == &search_hl)
Karsten Hopp 0e7303
  	    {
Karsten Hopp 0e7303
! 		/* don't free the regprog in match_hl[], it's a copy */
Karsten Hopp 0e7303
  		vim_free(shl->rm.regprog);
Karsten Hopp 0e7303
  		no_hlsearch = TRUE;
Karsten Hopp 0e7303
  	    }
Karsten Hopp 0e7303
--- 6571,6577 ----
Karsten Hopp 0e7303
  	    /* Error while handling regexp: stop using this regexp. */
Karsten Hopp 0e7303
  	    if (shl == &search_hl)
Karsten Hopp 0e7303
  	    {
Karsten Hopp 0e7303
! 		/* don't free regprog in the match list, it's a copy */
Karsten Hopp 0e7303
  		vim_free(shl->rm.regprog);
Karsten Hopp 0e7303
  		no_hlsearch = TRUE;
Karsten Hopp 0e7303
  	    }
Karsten Hopp 0e7303
*** ../vim-7.1.039/src/structs.h	Thu May 10 20:32:30 2007
Karsten Hopp 0e7303
--- src/structs.h	Wed Jul 25 21:08:46 2007
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 1694,1699 ****
Karsten Hopp 0e7303
--- 1694,1734 ----
Karsten Hopp 0e7303
  #define FR_COL	2	/* frame with a column of windows */
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
  /*
Karsten Hopp 0e7303
+  * Struct used for highlighting 'hlsearch' matches, matches defined by
Karsten Hopp 0e7303
+  * ":match" and matches defined by match functions.
Karsten Hopp 0e7303
+  * For 'hlsearch' there is one pattern for all windows.  For ":match" and the
Karsten Hopp 0e7303
+  * match functions there is a different pattern for each window.
Karsten Hopp 0e7303
+  */
Karsten Hopp 0e7303
+ typedef struct
Karsten Hopp 0e7303
+ {
Karsten Hopp 0e7303
+     regmmatch_T	rm;	/* points to the regexp program; contains last found
Karsten Hopp 0e7303
+ 			   match (may continue in next line) */
Karsten Hopp 0e7303
+     buf_T	*buf;	/* the buffer to search for a match */
Karsten Hopp 0e7303
+     linenr_T	lnum;	/* the line to search for a match */
Karsten Hopp 0e7303
+     int		attr;	/* attributes to be used for a match */
Karsten Hopp 0e7303
+     int		attr_cur; /* attributes currently active in win_line() */
Karsten Hopp 0e7303
+     linenr_T	first_lnum;	/* first lnum to search for multi-line pat */
Karsten Hopp 0e7303
+     colnr_T	startcol; /* in win_line() points to char where HL starts */
Karsten Hopp 0e7303
+     colnr_T	endcol;	 /* in win_line() points to char where HL ends */
Karsten Hopp 0e7303
+ } match_T;
Karsten Hopp 0e7303
+ 
Karsten Hopp 0e7303
+ /*
Karsten Hopp 0e7303
+  * matchitem_T provides a linked list for storing match items for ":match" and
Karsten Hopp 0e7303
+  * the match functions.
Karsten Hopp 0e7303
+  */
Karsten Hopp 0e7303
+ typedef struct matchitem matchitem_T;
Karsten Hopp 0e7303
+ struct matchitem
Karsten Hopp 0e7303
+ {
Karsten Hopp 0e7303
+     matchitem_T	*next;
Karsten Hopp 0e7303
+     int		id;	    /* match ID */
Karsten Hopp 0e7303
+     int		priority;   /* match priority */
Karsten Hopp 0e7303
+     char_u	*pattern;   /* pattern to highlight */
Karsten Hopp 0e7303
+     int		hlg_id;	    /* highlight group ID */
Karsten Hopp 0e7303
+     regmmatch_T	match;	    /* regexp program for pattern */
Karsten Hopp 0e7303
+     match_T	hl;	    /* struct for doing the actual highlighting */
Karsten Hopp 0e7303
+ };
Karsten Hopp 0e7303
+ 
Karsten Hopp 0e7303
+ /*
Karsten Hopp 0e7303
   * Structure which contains all information that belongs to a window
Karsten Hopp 0e7303
   *
Karsten Hopp 0e7303
   * All row numbers are relative to the start of the window, except w_winrow.
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 1934,1942 ****
Karsten Hopp 0e7303
  #endif
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
  #ifdef FEAT_SEARCH_EXTRA
Karsten Hopp 0e7303
!     regmmatch_T	w_match[3];	    /* regexp programs for ":match" */
Karsten Hopp 0e7303
!     char_u	*(w_match_pat[3]);  /* patterns for ":match" */
Karsten Hopp 0e7303
!     int		w_match_id[3];	    /* highlight IDs for ":match" */
Karsten Hopp 0e7303
  #endif
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
      /*
Karsten Hopp 0e7303
--- 1969,1976 ----
Karsten Hopp 0e7303
  #endif
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
  #ifdef FEAT_SEARCH_EXTRA
Karsten Hopp 0e7303
!     matchitem_T	*w_match_head;		/* head of match list */
Karsten Hopp 0e7303
!     int		w_next_match_id;	/* next match ID */
Karsten Hopp 0e7303
  #endif
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
      /*
Karsten Hopp 0e7303
*** ../vim-7.1.039/src/syntax.c	Tue Jul 24 14:32:44 2007
Karsten Hopp 0e7303
--- src/syntax.c	Tue Jul 24 15:47:01 2007
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 8504,8510 ****
Karsten Hopp 0e7303
  syn_id2name(id)
Karsten Hopp 0e7303
      int		id;
Karsten Hopp 0e7303
  {
Karsten Hopp 0e7303
!     if (id <= 0 || id >= highlight_ga.ga_len)
Karsten Hopp 0e7303
  	return (char_u *)"";
Karsten Hopp 0e7303
      return HL_TABLE()[id - 1].sg_name;
Karsten Hopp 0e7303
  }
Karsten Hopp 0e7303
--- 8504,8510 ----
Karsten Hopp 0e7303
  syn_id2name(id)
Karsten Hopp 0e7303
      int		id;
Karsten Hopp 0e7303
  {
Karsten Hopp 0e7303
!     if (id <= 0 || id > highlight_ga.ga_len)
Karsten Hopp 0e7303
  	return (char_u *)"";
Karsten Hopp 0e7303
      return HL_TABLE()[id - 1].sg_name;
Karsten Hopp 0e7303
  }
Karsten Hopp 0e7303
*** ../vim-7.1.039/src/testdir/Makefile	Sun Apr 30 20:48:47 2006
Karsten Hopp 0e7303
--- src/testdir/Makefile	Tue Jul 24 15:34:33 2007
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 1,5 ****
Karsten Hopp 0e7303
  #
Karsten Hopp 0e7303
! # Makefile to run al tests for Vim
Karsten Hopp 0e7303
  #
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
  VIMPROG = ../vim
Karsten Hopp 0e7303
--- 1,5 ----
Karsten Hopp 0e7303
  #
Karsten Hopp 0e7303
! # Makefile to run all tests for Vim
Karsten Hopp 0e7303
  #
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
  VIMPROG = ../vim
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 15,21 ****
Karsten Hopp 0e7303
  		test43.out test44.out test45.out test46.out test47.out \
Karsten Hopp 0e7303
  		test48.out test49.out test51.out test52.out test53.out \
Karsten Hopp 0e7303
  		test54.out test55.out test56.out test57.out test58.out \
Karsten Hopp 0e7303
! 		test59.out test60.out test61.out test62.out
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
  SCRIPTS_GUI = test16.out
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
--- 15,21 ----
Karsten Hopp 0e7303
  		test43.out test44.out test45.out test46.out test47.out \
Karsten Hopp 0e7303
  		test48.out test49.out test51.out test52.out test53.out \
Karsten Hopp 0e7303
  		test54.out test55.out test56.out test57.out test58.out \
Karsten Hopp 0e7303
! 		test59.out test60.out test61.out test62.out test63.out
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
  SCRIPTS_GUI = test16.out
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
*** ../vim-7.1.039/src/testdir/test63.in	Tue Jul 24 16:45:02 2007
Karsten Hopp 0e7303
--- src/testdir/test63.in	Tue Jul 24 15:32:30 2007
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 0 ****
Karsten Hopp 0e7303
--- 1,157 ----
Karsten Hopp 0e7303
+ Test for ":match", ":2match", ":3match", "clearmatches()", "getmatches()",
Karsten Hopp 0e7303
+ "matchadd()", "matcharg()", "matchdelete()", and "setmatches()".
Karsten Hopp 0e7303
+ 
Karsten Hopp 0e7303
+ STARTTEST
Karsten Hopp 0e7303
+ :so small.vim
Karsten Hopp 0e7303
+ :" --- Check that "matcharg()" returns the correct group and pattern if a match
Karsten Hopp 0e7303
+ :" --- is defined.
Karsten Hopp 0e7303
+ :let @r = "*** Test 1: "
Karsten Hopp 0e7303
+ :highlight MyGroup1 ctermbg=red
Karsten Hopp 0e7303
+ :highlight MyGroup2 ctermbg=green
Karsten Hopp 0e7303
+ :highlight MyGroup3 ctermbg=blue
Karsten Hopp 0e7303
+ :match MyGroup1 /TODO/
Karsten Hopp 0e7303
+ :2match MyGroup2 /FIXME/
Karsten Hopp 0e7303
+ :3match MyGroup3 /XXX/
Karsten Hopp 0e7303
+ :if matcharg(1) == ['MyGroup1', 'TODO'] && matcharg(2) == ['MyGroup2', 'FIXME'] && matcharg(3) == ['MyGroup3', 'XXX']
Karsten Hopp 0e7303
+ :  let @r .= "OK\n"
Karsten Hopp 0e7303
+ :else
Karsten Hopp 0e7303
+ :  let @r .= "FAILED\n"
Karsten Hopp 0e7303
+ :endif
Karsten Hopp 0e7303
+ :" --- Check that "matcharg()" returns an empty list if the argument is not 1,
Karsten Hopp 0e7303
+ :" --- 2 or 3 (only 0 and 4 are tested).
Karsten Hopp 0e7303
+ :let @r .= "*** Test 2: "
Karsten Hopp 0e7303
+ :if matcharg(0) == [] && matcharg(4) == []
Karsten Hopp 0e7303
+ :  let @r .= "OK\n"
Karsten Hopp 0e7303
+ :else
Karsten Hopp 0e7303
+ :  let @r .= "FAILED\n"
Karsten Hopp 0e7303
+ :endif
Karsten Hopp 0e7303
+ :" --- Check that "matcharg()" returns ['', ''] if a match is not defined.
Karsten Hopp 0e7303
+ :let @r .= "*** Test 3: "
Karsten Hopp 0e7303
+ :match
Karsten Hopp 0e7303
+ :2match
Karsten Hopp 0e7303
+ :3match
Karsten Hopp 0e7303
+ :if matcharg(1) == ['', ''] && matcharg(2) == ['', ''] && matcharg(3) == ['', '']
Karsten Hopp 0e7303
+ :  let @r .= "OK\n"
Karsten Hopp 0e7303
+ :else
Karsten Hopp 0e7303
+ :  let @r .= "FAILED\n"
Karsten Hopp 0e7303
+ :endif
Karsten Hopp 0e7303
+ :" --- Check that "matchadd()" and "getmatches()" agree on added matches and
Karsten Hopp 0e7303
+ :" --- that default values apply.
Karsten Hopp 0e7303
+ :let @r .= "*** Test 4: "
Karsten Hopp 0e7303
+ :let m1 = matchadd("MyGroup1", "TODO")
Karsten Hopp 0e7303
+ :let m2 = matchadd("MyGroup2", "FIXME", 42)
Karsten Hopp 0e7303
+ :let m3 = matchadd("MyGroup3", "XXX", 60, 17)
Karsten Hopp 0e7303
+ :if getmatches() == [{'group': 'MyGroup1', 'pattern': 'TODO', 'priority': 10, 'id': 4}, {'group': 'MyGroup2', 'pattern': 'FIXME', 'priority': 42, 'id': 5}, {'group': 'MyGroup3', 'pattern': 'XXX', 'priority': 60, 'id': 17}]
Karsten Hopp 0e7303
+ :  let @r .= "OK\n"
Karsten Hopp 0e7303
+ :else
Karsten Hopp 0e7303
+ :  let @r .= "FAILED\n"
Karsten Hopp 0e7303
+ :endif
Karsten Hopp 0e7303
+ :" --- Check that "matchdelete()" deletes the matches defined in the previous
Karsten Hopp 0e7303
+ :" --- test correctly.
Karsten Hopp 0e7303
+ :let @r .= "*** Test 5: "
Karsten Hopp 0e7303
+ :call matchdelete(m1)
Karsten Hopp 0e7303
+ :call matchdelete(m2)
Karsten Hopp 0e7303
+ :call matchdelete(m3)
Karsten Hopp 0e7303
+ :unlet m1
Karsten Hopp 0e7303
+ :unlet m2
Karsten Hopp 0e7303
+ :unlet m3
Karsten Hopp 0e7303
+ :if getmatches() == []
Karsten Hopp 0e7303
+ :  let @r .= "OK\n"
Karsten Hopp 0e7303
+ :else
Karsten Hopp 0e7303
+ :  let @r .= "FAILED\n"
Karsten Hopp 0e7303
+ :endif
Karsten Hopp 0e7303
+ :" --- Check that "matchdelete()" returns 0 if succesfull and otherwise -1.
Karsten Hopp 0e7303
+ :let @r .= "*** Test 6: "
Karsten Hopp 0e7303
+ :let m = matchadd("MyGroup1", "TODO")
Karsten Hopp 0e7303
+ :let r1 = matchdelete(m)
Karsten Hopp 0e7303
+ :let r2 = matchdelete(42)
Karsten Hopp 0e7303
+ :if r1 == 0 && r2 == -1
Karsten Hopp 0e7303
+ :  let @r .= "OK\n"
Karsten Hopp 0e7303
+ :else
Karsten Hopp 0e7303
+ :  let @r .= "FAILED\n"
Karsten Hopp 0e7303
+ :endif
Karsten Hopp 0e7303
+ :unlet m
Karsten Hopp 0e7303
+ :unlet r1
Karsten Hopp 0e7303
+ :unlet r2
Karsten Hopp 0e7303
+ :" --- Check that "clearmatches()" clears all matches defined by ":match" and
Karsten Hopp 0e7303
+ :" --- "matchadd()".
Karsten Hopp 0e7303
+ :let @r .= "*** Test 7: "
Karsten Hopp 0e7303
+ :let m1 = matchadd("MyGroup1", "TODO")
Karsten Hopp 0e7303
+ :let m2 = matchadd("MyGroup2", "FIXME", 42)
Karsten Hopp 0e7303
+ :let m3 = matchadd("MyGroup3", "XXX", 60, 17)
Karsten Hopp 0e7303
+ :match MyGroup1 /COFFEE/
Karsten Hopp 0e7303
+ :2match MyGroup2 /HUMPPA/
Karsten Hopp 0e7303
+ :3match MyGroup3 /VIM/
Karsten Hopp 0e7303
+ :call clearmatches()
Karsten Hopp 0e7303
+ :if getmatches() == []
Karsten Hopp 0e7303
+ :  let @r .= "OK\n"
Karsten Hopp 0e7303
+ :else
Karsten Hopp 0e7303
+ :  let @r .= "FAILED\n"
Karsten Hopp 0e7303
+ :endif
Karsten Hopp 0e7303
+ :unlet m1
Karsten Hopp 0e7303
+ :unlet m2
Karsten Hopp 0e7303
+ :unlet m3
Karsten Hopp 0e7303
+ :" --- Check that "setmatches()" restores a list of matches saved by
Karsten Hopp 0e7303
+ :" --- "getmatches()" without changes. (Matches with equal priority must also
Karsten Hopp 0e7303
+ :" --- remain in the same order.)
Karsten Hopp 0e7303
+ :let @r .= "*** Test 8: "
Karsten Hopp 0e7303
+ :let m1 = matchadd("MyGroup1", "TODO")
Karsten Hopp 0e7303
+ :let m2 = matchadd("MyGroup2", "FIXME", 42)
Karsten Hopp 0e7303
+ :let m3 = matchadd("MyGroup3", "XXX", 60, 17)
Karsten Hopp 0e7303
+ :match MyGroup1 /COFFEE/
Karsten Hopp 0e7303
+ :2match MyGroup2 /HUMPPA/
Karsten Hopp 0e7303
+ :3match MyGroup3 /VIM/
Karsten Hopp 0e7303
+ :let ml = getmatches()
Karsten Hopp 0e7303
+ :call clearmatches()
Karsten Hopp 0e7303
+ :call setmatches(ml)
Karsten Hopp 0e7303
+ :if getmatches() == ml
Karsten Hopp 0e7303
+ :  let @r .= "OK\n"
Karsten Hopp 0e7303
+ :else
Karsten Hopp 0e7303
+ :  let @r .= "FAILED\n"
Karsten Hopp 0e7303
+ :endif
Karsten Hopp 0e7303
+ :call clearmatches()
Karsten Hopp 0e7303
+ :unlet m1
Karsten Hopp 0e7303
+ :unlet m2
Karsten Hopp 0e7303
+ :unlet m3
Karsten Hopp 0e7303
+ :unlet ml
Karsten Hopp 0e7303
+ :" --- Check that "setmatches()" will not add two matches with the same ID. The
Karsten Hopp 0e7303
+ :" --- expected behaviour (for now) is to add the first match but not the
Karsten Hopp 0e7303
+ :" --- second and to return 0 (even though it is a matter of debate whether
Karsten Hopp 0e7303
+ :" --- this can be considered succesfull behaviour).
Karsten Hopp 0e7303
+ :let @r .= "*** Test 9: "
Karsten Hopp 0e7303
+ :let r1 = setmatches([{'group': 'MyGroup1', 'pattern': 'TODO', 'priority': 10, 'id': 1}, {'group': 'MyGroup2', 'pattern': 'FIXME', 'priority': 10, 'id': 1}])
Karsten Hopp 0e7303
+ :if getmatches() == [{'group': 'MyGroup1', 'pattern': 'TODO', 'priority': 10, 'id': 1}] && r1 == 0
Karsten Hopp 0e7303
+ :  let @r .= "OK\n"
Karsten Hopp 0e7303
+ :else
Karsten Hopp 0e7303
+ :  let @r .= "FAILED\n"
Karsten Hopp 0e7303
+ :endif
Karsten Hopp 0e7303
+ :call clearmatches()
Karsten Hopp 0e7303
+ :unlet r1
Karsten Hopp 0e7303
+ :" --- Check that "setmatches()" returns 0 if succesfull and otherwise -1.
Karsten Hopp 0e7303
+ :" --- (A range of valid and invalid input values are tried out to generate the
Karsten Hopp 0e7303
+ :" --- return values.)
Karsten Hopp 0e7303
+ :let @r .= "*** Test 10: "
Karsten Hopp 0e7303
+ :let rs1 = setmatches([])
Karsten Hopp 0e7303
+ :let rs2 = setmatches([{'group': 'MyGroup1', 'pattern': 'TODO', 'priority': 10, 'id': 1}])
Karsten Hopp 0e7303
+ :call clearmatches()
Karsten Hopp 0e7303
+ :let rf1 = setmatches(0)
Karsten Hopp 0e7303
+ :let rf2 = setmatches([0])
Karsten Hopp 0e7303
+ :let rf3 = setmatches([{'wrong key': 'wrong value'}])
Karsten Hopp 0e7303
+ :if rs1 == 0 && rs2 == 0 && rf1 == -1 && rf2 == -1 && rf3 == -1
Karsten Hopp 0e7303
+ :  let @r .= "OK\n"
Karsten Hopp 0e7303
+ :else
Karsten Hopp 0e7303
+ :  let @r .= "FAILED\n"
Karsten Hopp 0e7303
+ :endif
Karsten Hopp 0e7303
+ :unlet rs1
Karsten Hopp 0e7303
+ :unlet rs2
Karsten Hopp 0e7303
+ :unlet rf1
Karsten Hopp 0e7303
+ :unlet rf2
Karsten Hopp 0e7303
+ :unlet rf3
Karsten Hopp 0e7303
+ :highlight clear MyGroup1
Karsten Hopp 0e7303
+ :highlight clear MyGroup2
Karsten Hopp 0e7303
+ :highlight clear MyGroup3
Karsten Hopp 0e7303
+ G"rp
Karsten Hopp 0e7303
+ :/^Results/,$wq! test.out
Karsten Hopp 0e7303
+ ENDTEST
Karsten Hopp 0e7303
+ 
Karsten Hopp 0e7303
+ Results of test63:
Karsten Hopp 0e7303
*** ../vim-7.1.039/src/testdir/test63.ok	Tue Jul 24 16:45:02 2007
Karsten Hopp 0e7303
--- src/testdir/test63.ok	Tue Jul 24 15:32:30 2007
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 0 ****
Karsten Hopp 0e7303
--- 1,11 ----
Karsten Hopp 0e7303
+ Results of test63:
Karsten Hopp 0e7303
+ *** Test 1: OK
Karsten Hopp 0e7303
+ *** Test 2: OK
Karsten Hopp 0e7303
+ *** Test 3: OK
Karsten Hopp 0e7303
+ *** Test 4: OK
Karsten Hopp 0e7303
+ *** Test 5: OK
Karsten Hopp 0e7303
+ *** Test 6: OK
Karsten Hopp 0e7303
+ *** Test 7: OK
Karsten Hopp 0e7303
+ *** Test 8: OK
Karsten Hopp 0e7303
+ *** Test 9: OK
Karsten Hopp 0e7303
+ *** Test 10: OK
Karsten Hopp 0e7303
*** ../vim-7.1.039/src/window.c	Thu May 10 18:42:26 2007
Karsten Hopp 0e7303
--- src/window.c	Tue Jul 24 20:38:58 2007
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 75,80 ****
Karsten Hopp 0e7303
--- 75,81 ----
Karsten Hopp 0e7303
  static win_T *restore_snapshot_rec __ARGS((frame_T *sn, frame_T *fr));
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
  #endif /* FEAT_WINDOWS */
Karsten Hopp 0e7303
+ 
Karsten Hopp 0e7303
  static win_T *win_alloc __ARGS((win_T *after));
Karsten Hopp 0e7303
  static void win_new_height __ARGS((win_T *, int));
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 4128,4133 ****
Karsten Hopp 0e7303
--- 4129,4138 ----
Karsten Hopp 0e7303
  #ifdef FEAT_AUTOCMD
Karsten Hopp 0e7303
  	--autocmd_block;
Karsten Hopp 0e7303
  #endif
Karsten Hopp 0e7303
+ #ifdef FEAT_SEARCH_EXTRA
Karsten Hopp 0e7303
+ 	newwin->w_match_head = NULL;
Karsten Hopp 0e7303
+ 	newwin->w_next_match_id = 4;
Karsten Hopp 0e7303
+ #endif
Karsten Hopp 0e7303
      }
Karsten Hopp 0e7303
      return newwin;
Karsten Hopp 0e7303
  }
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 4185,4195 ****
Karsten Hopp 0e7303
  	vim_free(wp->w_tagstack[i].tagname);
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
      vim_free(wp->w_localdir);
Karsten Hopp 0e7303
  #ifdef FEAT_SEARCH_EXTRA
Karsten Hopp 0e7303
!     vim_free(wp->w_match[0].regprog);
Karsten Hopp 0e7303
!     vim_free(wp->w_match[1].regprog);
Karsten Hopp 0e7303
!     vim_free(wp->w_match[2].regprog);
Karsten Hopp 0e7303
  #endif
Karsten Hopp 0e7303
  #ifdef FEAT_JUMPLIST
Karsten Hopp 0e7303
      free_jumplist(wp);
Karsten Hopp 0e7303
  #endif
Karsten Hopp 0e7303
--- 4190,4200 ----
Karsten Hopp 0e7303
  	vim_free(wp->w_tagstack[i].tagname);
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
      vim_free(wp->w_localdir);
Karsten Hopp 0e7303
+ 
Karsten Hopp 0e7303
  #ifdef FEAT_SEARCH_EXTRA
Karsten Hopp 0e7303
!     clear_matches(wp);
Karsten Hopp 0e7303
  #endif
Karsten Hopp 0e7303
+ 
Karsten Hopp 0e7303
  #ifdef FEAT_JUMPLIST
Karsten Hopp 0e7303
      free_jumplist(wp);
Karsten Hopp 0e7303
  #endif
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 6172,6176 ****
Karsten Hopp 0e7303
--- 6177,6351 ----
Karsten Hopp 0e7303
  		return TRUE;
Karsten Hopp 0e7303
  
Karsten Hopp 0e7303
      return FALSE;
Karsten Hopp 0e7303
+ }
Karsten Hopp 0e7303
+ #endif
Karsten Hopp 0e7303
+ 
Karsten Hopp 0e7303
+ #if defined(FEAT_SEARCH_EXTRA) || defined(PROTO)
Karsten Hopp 0e7303
+ /*
Karsten Hopp 0e7303
+  * Add match to the match list of window 'wp'.  The pattern 'pat' will be
Karsten Hopp 0e7303
+  * highligted with the group 'grp' with priority 'prio'.
Karsten Hopp 0e7303
+  * Optionally, a desired ID 'id' can be specified (greater than or equal to 1).
Karsten Hopp 0e7303
+  * If no particular ID is desired, -1 must be specified for 'id'.
Karsten Hopp 0e7303
+  * Return ID of added match, -1 on failure.
Karsten Hopp 0e7303
+  */
Karsten Hopp 0e7303
+     int
Karsten Hopp 0e7303
+ match_add(wp, grp, pat, prio, id)
Karsten Hopp 0e7303
+     win_T	*wp;
Karsten Hopp 0e7303
+     char_u	*grp;
Karsten Hopp 0e7303
+     char_u	*pat;
Karsten Hopp 0e7303
+     int		prio;
Karsten Hopp 0e7303
+     int		id;
Karsten Hopp 0e7303
+ {
Karsten Hopp 0e7303
+     matchitem_T *cur;
Karsten Hopp 0e7303
+     matchitem_T *prev;
Karsten Hopp 0e7303
+     matchitem_T *m;
Karsten Hopp 0e7303
+     int		hlg_id;
Karsten Hopp 0e7303
+     regmmatch_T match;
Karsten Hopp 0e7303
+ 
Karsten Hopp 0e7303
+     if (*grp == NUL || *pat == NUL)
Karsten Hopp 0e7303
+ 	return -1;
Karsten Hopp 0e7303
+     if (id < -1 || id == 0)
Karsten Hopp 0e7303
+     {
Karsten Hopp 0e7303
+ 	EMSGN("E799: Invalid ID: %ld (must be greater than or equal to 1)", id);
Karsten Hopp 0e7303
+ 	return -1;
Karsten Hopp 0e7303
+     }
Karsten Hopp 0e7303
+     if (id != -1)
Karsten Hopp 0e7303
+     {
Karsten Hopp 0e7303
+ 	cur = wp->w_match_head;
Karsten Hopp 0e7303
+ 	while (cur != NULL)
Karsten Hopp 0e7303
+ 	{
Karsten Hopp 0e7303
+ 	    if (cur->id == id)
Karsten Hopp 0e7303
+ 	    {
Karsten Hopp 0e7303
+ 		EMSGN("E801: ID already taken: %ld", id);
Karsten Hopp 0e7303
+ 		return -1;
Karsten Hopp 0e7303
+ 	    }
Karsten Hopp 0e7303
+ 	    cur = cur->next;
Karsten Hopp 0e7303
+ 	}
Karsten Hopp 0e7303
+     }
Karsten Hopp 0e7303
+     if ((hlg_id = syn_namen2id(grp, STRLEN(grp))) == 0)
Karsten Hopp 0e7303
+     {
Karsten Hopp 0e7303
+ 	EMSG2(_(e_nogroup), grp);
Karsten Hopp 0e7303
+ 	return -1;
Karsten Hopp 0e7303
+     }
Karsten Hopp 0e7303
+     if ((match.regprog = vim_regcomp(pat, RE_MAGIC)) == NULL)
Karsten Hopp 0e7303
+     {
Karsten Hopp 0e7303
+ 	EMSG2(_(e_invarg2), pat);
Karsten Hopp 0e7303
+ 	return -1;
Karsten Hopp 0e7303
+     }
Karsten Hopp 0e7303
+ 
Karsten Hopp 0e7303
+     /* Find available match ID. */
Karsten Hopp 0e7303
+     while (id == -1)
Karsten Hopp 0e7303
+     {
Karsten Hopp 0e7303
+ 	cur = wp->w_match_head;
Karsten Hopp 0e7303
+ 	while (cur != NULL && cur->id != wp->w_next_match_id)
Karsten Hopp 0e7303
+ 	    cur = cur->next;
Karsten Hopp 0e7303
+ 	if (cur == NULL)
Karsten Hopp 0e7303
+ 	    id = wp->w_next_match_id;
Karsten Hopp 0e7303
+ 	wp->w_next_match_id++;
Karsten Hopp 0e7303
+     }
Karsten Hopp 0e7303
+ 
Karsten Hopp 0e7303
+     /* Build new match. */
Karsten Hopp 0e7303
+     m = (matchitem_T *)alloc(sizeof(matchitem_T));
Karsten Hopp 0e7303
+     m->id = id;
Karsten Hopp 0e7303
+     m->priority = prio;
Karsten Hopp 0e7303
+     m->pattern = vim_strsave(pat);
Karsten Hopp 0e7303
+     m->hlg_id = hlg_id;
Karsten Hopp 0e7303
+     m->match.regprog = match.regprog;
Karsten Hopp 0e7303
+ 
Karsten Hopp 0e7303
+     /* Insert new match.  The match list is in ascending order with regard to
Karsten Hopp 0e7303
+      * the match priorities. */
Karsten Hopp 0e7303
+     cur = wp->w_match_head;
Karsten Hopp 0e7303
+     prev = cur;
Karsten Hopp 0e7303
+     while (cur != NULL && prio >= cur->priority)
Karsten Hopp 0e7303
+     {
Karsten Hopp 0e7303
+ 	prev = cur;
Karsten Hopp 0e7303
+ 	cur = cur->next;
Karsten Hopp 0e7303
+     }
Karsten Hopp 0e7303
+     if (cur == prev)
Karsten Hopp 0e7303
+ 	wp->w_match_head = m;
Karsten Hopp 0e7303
+     else
Karsten Hopp 0e7303
+ 	prev->next = m;
Karsten Hopp 0e7303
+     m->next = cur;
Karsten Hopp 0e7303
+ 
Karsten Hopp 0e7303
+     redraw_later(SOME_VALID);
Karsten Hopp 0e7303
+     return id;
Karsten Hopp 0e7303
+ }
Karsten Hopp 0e7303
+ 
Karsten Hopp 0e7303
+ /*
Karsten Hopp 0e7303
+  * Delete match with ID 'id' in the match list of window 'wp'.
Karsten Hopp 0e7303
+  * Print error messages if 'perr' is TRUE.
Karsten Hopp 0e7303
+  */
Karsten Hopp 0e7303
+     int
Karsten Hopp 0e7303
+ match_delete(wp, id, perr)
Karsten Hopp 0e7303
+     win_T	*wp;
Karsten Hopp 0e7303
+     int		id;
Karsten Hopp 0e7303
+     int		perr;
Karsten Hopp 0e7303
+ {
Karsten Hopp 0e7303
+     matchitem_T *cur = wp->w_match_head;
Karsten Hopp 0e7303
+     matchitem_T *prev = cur;
Karsten Hopp 0e7303
+ 
Karsten Hopp 0e7303
+     if (id < 1)
Karsten Hopp 0e7303
+     {
Karsten Hopp 0e7303
+ 	if (perr == TRUE)
Karsten Hopp 0e7303
+ 	    EMSGN("E802: Invalid ID: %ld (must be greater than or equal to 1)",
Karsten Hopp 0e7303
+ 									  id);
Karsten Hopp 0e7303
+ 	return -1;
Karsten Hopp 0e7303
+     }
Karsten Hopp 0e7303
+     while (cur != NULL && cur->id != id)
Karsten Hopp 0e7303
+     {
Karsten Hopp 0e7303
+ 	prev = cur;
Karsten Hopp 0e7303
+ 	cur = cur->next;
Karsten Hopp 0e7303
+     }
Karsten Hopp 0e7303
+     if (cur == NULL)
Karsten Hopp 0e7303
+     {
Karsten Hopp 0e7303
+ 	if (perr == TRUE)
Karsten Hopp 0e7303
+ 	    EMSGN("E803: ID not found: %ld", id);
Karsten Hopp 0e7303
+ 	return -1;
Karsten Hopp 0e7303
+     }
Karsten Hopp 0e7303
+     if (cur == prev)
Karsten Hopp 0e7303
+ 	wp->w_match_head = cur->next;
Karsten Hopp 0e7303
+     else
Karsten Hopp 0e7303
+ 	prev->next = cur->next;
Karsten Hopp 0e7303
+     vim_free(cur->match.regprog);
Karsten Hopp 0e7303
+     vim_free(cur->pattern);
Karsten Hopp 0e7303
+     vim_free(cur);
Karsten Hopp 0e7303
+     redraw_later(SOME_VALID);
Karsten Hopp 0e7303
+     return 0;
Karsten Hopp 0e7303
+ }
Karsten Hopp 0e7303
+ 
Karsten Hopp 0e7303
+ /*
Karsten Hopp 0e7303
+  * Delete all matches in the match list of window 'wp'.
Karsten Hopp 0e7303
+  */
Karsten Hopp 0e7303
+     void
Karsten Hopp 0e7303
+ clear_matches(wp)
Karsten Hopp 0e7303
+     win_T	*wp;
Karsten Hopp 0e7303
+ {
Karsten Hopp 0e7303
+     matchitem_T *m;
Karsten Hopp 0e7303
+ 
Karsten Hopp 0e7303
+     while (wp->w_match_head != NULL)
Karsten Hopp 0e7303
+     {
Karsten Hopp 0e7303
+ 	m = wp->w_match_head->next;
Karsten Hopp 0e7303
+ 	vim_free(wp->w_match_head->match.regprog);
Karsten Hopp 0e7303
+ 	vim_free(wp->w_match_head->pattern);
Karsten Hopp 0e7303
+ 	vim_free(wp->w_match_head);
Karsten Hopp 0e7303
+ 	wp->w_match_head = m;
Karsten Hopp 0e7303
+     }
Karsten Hopp 0e7303
+     redraw_later(SOME_VALID);
Karsten Hopp 0e7303
+ }
Karsten Hopp 0e7303
+ 
Karsten Hopp 0e7303
+ /*
Karsten Hopp 0e7303
+  * Get match from ID 'id' in window 'wp'.
Karsten Hopp 0e7303
+  * Return NULL if match not found.
Karsten Hopp 0e7303
+  */
Karsten Hopp 0e7303
+     matchitem_T *
Karsten Hopp 0e7303
+ get_match(wp, id)
Karsten Hopp 0e7303
+     win_T	*wp;
Karsten Hopp 0e7303
+     int		id;
Karsten Hopp 0e7303
+ {
Karsten Hopp 0e7303
+     matchitem_T *cur = wp->w_match_head;
Karsten Hopp 0e7303
+ 
Karsten Hopp 0e7303
+     while (cur != NULL && cur->id != id)
Karsten Hopp 0e7303
+ 	cur = cur->next;
Karsten Hopp 0e7303
+     return cur;
Karsten Hopp 0e7303
  }
Karsten Hopp 0e7303
  #endif
Karsten Hopp 0e7303
*** ../vim-7.1.039/src/version.c	Wed Jul 25 22:55:22 2007
Karsten Hopp 0e7303
--- src/version.c	Thu Jul 26 22:50:54 2007
Karsten Hopp 0e7303
***************
Karsten Hopp 0e7303
*** 668,669 ****
Karsten Hopp 0e7303
--- 668,671 ----
Karsten Hopp 0e7303
  {   /* Add new patch number below this line */
Karsten Hopp 0e7303
+ /**/
Karsten Hopp 0e7303
+     40,
Karsten Hopp 0e7303
  /**/
Karsten Hopp 0e7303
Karsten Hopp 0e7303
-- 
Karsten Hopp 0e7303
It is hard to understand how a cemetery raised its burial
Karsten Hopp 0e7303
cost and blamed it on the cost of living.
Karsten Hopp 0e7303
Karsten Hopp 0e7303
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 0e7303
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 0e7303
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp 0e7303
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///