anchor.diff:  	    case Res of
   		[FunDef] ->
   		    Cs = refac_syntax:function_clauses(FunDef),
  -		    try
  -			find_matching_clause(Cs, Args) of
  +		    try find_matching_clause(Cs, Args) of
   			none -> throw({error, "The function to be inlined has multiple clauses, "
   				       "and Wrangler could not figure out which function clause to inline."});
   			{C, {Subst, MatchExprs}} ->
  -			    {ok, {C,{Subst, MatchExprs}}}
  +			    UsedMacros = collect_used_macros(C),
  +			    CPos = refac_syntax:get_pos(C),
  +			    AppPos = refac_syntax:get_pos(App),
  +			    case check_macro_defs(Fs, UsedMacros,erlang:min(CPos, AppPos), erlang:max(CPos, AppPos)) of
  +				[] ->
  +				    {ok, {C,{Subst, MatchExprs}}};
  +				Ms ->
  +				    MsStr = format(Ms),
  +				    case length(Ms) of 
  +					1 ->
  +					    Str = "Macro "++ MsStr ++" used by the function clause to be inlined is defined/undefined "
  +						"between the function application to be unfolded and the function clause.",
  +					    throw({error, Str});
  +					_ ->
  +					    Str = "Macros: "++ MsStr ++", used by the function clause to be inlined is defined/undefined "
  +						"between the function application to be unfolded and the function clause.",
  +					    throw({error, Str})
  +				    end
  +			    end
   		    catch 
    			throw:E2 -> 
   			    throw(E2)
  
positive.code: do_match_patterns(DefP, AppP, LastClause) when is_list(DefP) andalso is_list(AppP) ->
      case length(DefP)== length(AppP) of 
  	false ->
  	    no_match;
  	true-> case DefP of 
  		   [] ->
  		       [];
  
negative.code:     end.
  
  
  do_inline(Form, Pos, _Clause, App, SubstedBody, RecordDefs) ->
      {S, E} = refac_util:get_range(Form),
      if (S =< Pos) and (Pos =< E) ->
  	   {NewForm, _} = refac_util:stop_tdTP(fun do_inline_1/2, Form, {App, SubstedBody}),
  	    case length(SubstedBody) > 1 of
  		true ->
  		    {NewForm1, _} = refac_util:stop_tdTP(fun remove_begin_end/2, NewForm, SubstedBody),
  		    RecordDefs++[NewForm1];
  		_ -> RecordDefs++[NewForm]
  	    end;
         true ->
  	    [Form]
      end.
  
  do_inline_1(Node, {App, SubstedBody}) ->
  