anchor.diff:  		 end
   	 end,
       refac_syntax_lib:fold(Fun, ordsets:new(), Node).
  +
  +collect_used_records(Node) ->
  +    Fun = fun(T, S) ->
  +		  case refac_syntax:type(T) of
  +		      record_access ->
  +			  Type = refac_syntax:record_access_type(T),
  +			  case refac_syntax:type(Type) of
  +			      atom -> [refac_syntax:atom_value(Type)|S];
  +			      _ -> S
  +			  end;
  +		      record_expr ->
  +			  Type = refac_syntax:record_expr_type(T),
  +			  case refac_syntax:type(Type) of
  +			      atom -> [refac_syntax:atom_value(Type) |S];
  +			      _ -> S
  +			  end;
  +		       record_index_expr->
  +			  Type = refac_syntax:record_index_expr_type(T),
  +			  case refac_syntax:type(Type) of
  +			      atom -> [refac_syntax:atom_value(Type) |S];
  +			      _ -> S
  +			  end;
  +		      _ -> S		  
  +		  end
  +	  end,
  +    refac_syntax_lib:fold(Fun, ordsets:new(), Node).
  +			  
  +collect_record_defs(Fs, RecordTypes, Loc) ->
  +    [F || F<-Fs, collect_record_defs_1(F, RecordTypes, Loc)].
  +
  +collect_record_defs_1(F, RecordTypes, Loc) ->
  +    Pos = refac_syntax:get_pos(F),
  +    case Pos < Loc of
  +	true ->
  +	    false;
  +	false ->
  +	    case refac_syntax:type(F) of 
  +		attribute ->
  +		    Name = refac_syntax:attribute_name(F),
  +		    case refac_syntax:type(Name) of
  +			atom ->
  +			    case refac_syntax:atom_value(Name) of 
  +				record -> Type = hd(refac_syntax:attribute_arguments(F)),
  +					  case refac_syntax:type(Type) of
  +					      atom -> 
  +						  lists:member(refac_syntax:atom_value(Type), RecordTypes);
  +					      _ -> false
  +					  end;
  +				_ -> false
  +			    end;
  +			_ -> false
  +		    end;
  +		_ -> false
  +	    end
  +    end.
  +  
  +check_macro_defs(_Fs, [], _StartLoc, _EndLoc) -> 
  +    [];
  +check_macro_defs(Fs, UsedMacros, StartLoc, EndLoc) ->
  +    Res =[check_macro_defs_1(F, UsedMacros, StartLoc, EndLoc) || F<-Fs],
  +    lists:usort([M|| {true, Ms}<-Res, M<-Ms]).
  +
  +check_macro_defs_1(F, UsedMacros, StartLoc, EndLoc) ->
  +    Pos = refac_syntax:get_pos(F),
  +    case (Pos =<StartLoc) orelse (Pos>= EndLoc) of 
  +	true ->
  +	     false;
  +	false ->
  +	    case is_attribute(F, define) orelse is_attribute(F, undef) of
  +		true ->
  +		    Args = refac_syntax:attribute_arguments(F),
  +		    MacroHead = refac_util:ghead("refac_unfold_fun_app:check_macro_defs_1", Args),
  +		    MacroHead1 = case refac_syntax:type(MacroHead) of
  +				     application ->
  +					 refac_syntax:application_operator(MacroHead);
  +				     _ ->
  +					 MacroHead
  +				 end,
  +		    Name = case refac_syntax:type(MacroHead1) of 
  +			       atom -> refac_syntax:atom_value(MacroHead1);
  +			       variable ->refac_syntax:variable_name(MacroHead1);
  +			       _ -> '_'
  +			   end,
  +		    case lists:member(Name, UsedMacros) of 
  +			true ->
  +			    {true, [Name]};
  +			false -> false
  +		    end;
  +		_ -> false
  +	    end
  +    end.
  +				
  +	
  +is_attribute(F, Name) ->
  +    (refac_syntax:type(F)==attribute) andalso
  +    (refac_syntax:type(refac_syntax:attribute_name(F))==atom)  andalso 
  +    (refac_syntax:atom_value(refac_syntax:attribute_name(F)) == Name).
  +
  +collect_used_macros(Node) ->
  +    F = fun(T, S) ->
  +		case refac_syntax:type(T) of
  +		    macro ->
  +			Name = refac_syntax:macro_name(T),
  +			case refac_syntax:type(Name) of 
  +			    variable -> [refac_syntax:variable_name(Name)|S];
  +			    atom -> [refac_syntax:atom_value(Name) |S]
  +			end;
  +		    _  -> S
  +		end
  +	end,
  +    lists:usort(refac_syntax_lib:fold(F, [], Node)).
  +	    
  +	
  +format([]) ->	   
  +     "";
  +format([M]) ->
  +    atom_to_list(M);
  +format([M|Ms]) ->
  +    atom_to_list(M) ++ ","++ format(Ms).
  +	
  +	    
  
positive.code: 	no_more_match ->
  	    none;
  	Res ->
  	    SubSt = [{P1, P2} || {P1, P2} <-Res],
  	    MatchExprs = [ M|| M<-Res, not (is_tuple(M))],
  	    {C, {SubSt, MatchExprs}}
      end.
  
  find_matching_clause_1(C, AppPs, LastClause) ->
  
negative.code: 					Ann = refac_syntax:get_ann(DefP),
  					case lists:keysearch(def,1,Ann) of 
  					    {value, {def, DefinePos}} ->
  						[{DefP, DefinePos, AppP}];
  					         %% this should not happen;
  					    _ -> [refac_syntax:match_expr(DefP, AppP)]
  					end
  