anchor.diff:  do_search_candidate_exprs_2(AnnAST, ExpList) ->
       Len = length(ExpList),
       LastExp = lists:last(ExpList),
  -    HasExportExp = case refac_syntax:type(LastExp) of 
  -		      variable -> true;
  -		       tuple -> lists:all(fun(E) -> refac_syntax:type(E) == variable end, 
  -					  refac_syntax:tuple_elements(LastExp));
  -		       _  -> false
  +    HasExportExp = case refac_syntax:type(LastExp) of
  +		       variable -> true;
  +		       tuple -> 
  +			   lists:all(fun (E) -> refac_syntax:type(E) == variable end,
  +				     refac_syntax:tuple_elements(LastExp));
  +		       _ -> false
   		   end,
  -    
  -    Fun = fun(T, S) ->
  -		  case refac_syntax:type(T) of 
  +    Fun = fun (T, S) ->
  +		  case refac_syntax:type(T) of
   		      clause ->
   			  Exprs = refac_syntax:clause_body(T),
  -			  SubExprs = sublists(Exprs, Len),
  -			  CandidateExprs1 = 
  -			      lists:map(fun(E) -> case ExpList =/= E of 
  -   						      true ->case expr_unification(ExpList, E) of 
  -   								 {true,Subst} -> {StartLoc1, _EndLoc1} = refac_util:get_range(hd(E)),
  -   										 {_StartLoc2, EndLoc2} = refac_util:get_range(lists:last(E)),
  -   										 {{StartLoc1, EndLoc2}, Subst};
  -   								 _ ->
  -								     false
  -   							     end;
  -   						      _ -> false
  -   						  end							       
  -   					end, SubExprs),
  - 			  CandidateExprs2 = 
  -			      case HasExportExp of 
  -				  true ->
  -				      SubExprs1 = sublists(Exprs, Len-1),
  -				      lists:map(fun(E) -> case hd(ExpList) =/= hd(E) of 
  -							      true -> VarsToExport = vars_to_export_1(Exprs, E),
  -								      Res =  expr_unification(lists:sublist(ExpList, Len-1), E),
  -								      case Res of 
  -									  {true, Subst} ->
  -									      case reorder_vars_to_export(LastExp, VarsToExport, Subst) of 
  -										  {true, VarsToExport1} ->
  -										      {StartLoc1, _EndLoc1} = refac_util:get_range(hd(E)),
  -										      {_StartLoc2, EndLoc2} = refac_util:get_range(lists:last(E)),
  -										      {{StartLoc1, EndLoc2}, Subst, VarsToExport1};
  -										  _ -> false
  -									      end;
  -									  _ -> false
  -								      end;
  -							      _ -> false
  -							  end
  -						end, SubExprs1);
  -				  _ -> []
  -			      end,
  -			  S ++ lists:filter(fun(C) -> C =/= false end, CandidateExprs1++CandidateExprs2);
  +			  CandidateExprs= get_candidate_exprs(ExpList, Len, LastExp, HasExportExp, Exprs),
  +			  S ++ CandidateExprs;
   		      block_expr ->
   			  Exprs = refac_syntax:block_expr_body(T),
  -			  SubExprs = sublists(Exprs, Len),
  -			  CandidateExprs = lists:map(fun(E) -> case ExpList =/= E of 
  -								   true ->case expr_unification(ExpList, E) of 
  -									      {true, Subst} -> {StartLoc1, _EndLoc1} = refac_util:get_range(hd(E)),
  -											       {_StartLoc2, EndLoc2} = refac_util:get_range(lists:last(E)),
  -											       {{StartLoc1, EndLoc2}, Subst};
  -									      _ -> false
  -									  end;
  -								   _ -> false
  -							       end
  -						     end, SubExprs),
  -			  S ++ lists:filter(fun(C) -> C =/= false end, CandidateExprs);
  -		      _  -> S
  +			  CandidateExprs= get_candidate_exprs(ExpList, Len, LastExp, HasExportExp, Exprs),
  +			  S ++ CandidateExprs;
  +		      try_expr ->
  +			  Exprs = refac_syntax:try_expr_body(T),
  +			  CandidateExprs= get_candidate_exprs(ExpList, Len, LastExp, HasExportExp, Exprs),
  +			  S ++ CandidateExprs;
  +		      _ -> S
   		  end
   	  end,
  -     refac_syntax_lib:fold(Fun,[], AnnAST).
  -    
  +    refac_syntax_lib:fold(Fun, [], AnnAST).
  +
  +get_candidate_exprs(ExpList, Len, LastExp, HasExportExp, Exprs) ->
  +    SubExprs = sublists(Exprs, Len),
  +    Fun0 = fun (E) ->
  +		   case ExpList =/= E of
  +		       true ->
  +			   case expr_unification(ExpList, E) of
  +			       {true, Subst} ->
  +				   {SLoc1, _ELoc1} = refac_util:get_range(hd(E)),
  +				   {_SLoc2, ELoc2} = refac_util:get_range(lists:last(E)),
  +				   {{SLoc1, ELoc2}, Subst};
  +			       _ ->
  +				   false
  +			   end;
  +		       _ -> false
  +		   end
  +	   end,
  +    CandidateExprs1 = lists:map(Fun0, SubExprs),
  +    CandidateExprs2 =
  +	case HasExportExp of
  +	    true ->
  +		SubExprs1 = sublists(Exprs, Len - 1),
  +		Fun = fun (E) ->
  +			      case hd(ExpList) =/= hd(E) of
  +				  true ->
  +				      VarsToExport = vars_to_export_1(Exprs, E),
  +				      Res = expr_unification(lists:sublist(ExpList, Len - 1), E),
  +				      case Res of
  +					  {true, Subst} ->
  +					      case reorder_vars_to_export(LastExp, VarsToExport, Subst) of
  +						  {true, VarsToExport1} ->
  +						      {StartLoc1, _EndLoc1} = refac_util:get_range(hd(E)),
  +						      {_StartLoc2, EndLoc2} = refac_util:get_range(lists:last(E)),
  +						      {{StartLoc1, EndLoc2}, Subst, VarsToExport1};
  +						  _ -> false
  +					      end;
  +					  _ -> false
  +				      end;
  +				  _ -> false
  +			      end
  +		      end,
  +		lists:map(Fun, SubExprs1);
  +	  _ -> []
  +	end,
  +    lists:filter(fun (C) -> C =/= false end, CandidateExprs1 ++ CandidateExprs2).
  +
   
   -spec(expr_unification/2::(syntaxTree(), syntaxTree()) ->
   	     {true, [{atom(), syntaxTree()}]} | false).
   expr_unification(Exp1, Exp2) ->
  -    Res1 = case {is_list(Exp1), is_list(Exp2)} of 
  -	       {true, true} ->   %% both are list of expressions
  -		   case length(Exp1) == length(Exp2) of
  -		       true -> Res = lists:map(fun({E1,E2}) ->			      
  -						       expr_unification(E1,E2)						
  -					       end, lists:zip(Exp1, Exp2)),
  -			       Unifiable = lists:all(fun(E) -> case E of 
  -								   {true, _} -> true;
  -								   _ -> false
  -							       end
  -						     end, Res),
  -			       Substs = lists:usort(lists:flatmap(fun(E) -> case E of 
  -										{true,S} -> S;
  -										_ -> []
  -									    end
  -								  end,Res)),
  -			       case Unifiable of 
  -				   true -> {true, Substs};
  -				   _ -> false
  -			       end;
  -		       _ -> false
  -		   end;
  -	       {false, false} ->  %% both are single expressions.
  -		   T1 = refac_syntax:type(Exp1),
  -		   T2 = refac_syntax:type(Exp2),
  -		   case T1 == T2 of 
  -		       true -> 
  -			   case T1 of 
  -			       variable -> 
  -				   case lists:keysearch(category, 1, refac_syntax:get_ann(Exp1)) of 
  -				       {value, {category, macro_name}} ->
  -					   case lists:keysearch(category, 1, refac_syntax:get_ann(Exp2)) of 
  -					       {value, {category, macro_name}} ->
  -						   case refac_syntax:variable_name(Exp1) == refac_syntax:variable_name(Exp2) of 
  -						       true ->
  -							   {true, []};
  -					       _ ->false
  -						   end;
  -					       _ -> false
  -					   end;
  -				       _ -> {true, [{refac_syntax:variable_name(Exp1), set_default_ann(Exp2)}]} 
  -				   end;
  -			       atom -> case refac_syntax:atom_value(Exp1) == refac_syntax:atom_value(Exp2) of 
  -					   true -> {true, []};
  -					   _ -> false
  -				       end;
  -			       operator -> case refac_syntax:atom_value(Exp1) == refac_syntax:atom_value(Exp2) of
  -					       true -> {true, []};
  -					       _ -> false
  -					   end;
  -			       char -> case refac_syntax:char_value(Exp1) == refac_syntax:char_value(Exp2) of 
  -					   true -> {true, []};
  -					   _ -> false
  -				       end;
  -			       integer -> case refac_syntax:integer_value(Exp1) ==refac_syntax:integer_value(Exp2) of 
  -					      true -> {true, []};
  -					      _ -> false
  -					  end;
  -			       string -> case refac_syntax:string_value(Exp1) == refac_syntax:string_value(Exp2) of 
  -					     true -> {true, []};
  -					     _ -> false
  -					 end;
  -			       float -> case refac_syntax:float_value(Exp1) == refac_syntax:float_value(Exp2) of 
  -					    true -> {true, []}
  -					end;
  -			       underscore -> {true, []};
  -			       nil -> {true, []};
  -			       _ -> 
  -				   SubTrees1 = erl_syntax:subtrees(Exp1),
  -				   SubTrees2 = erl_syntax:subtrees(Exp2),
  -				   case length(SubTrees1) == length(SubTrees2) of 
  -				       true -> 
  -					   expr_unification(SubTrees1, SubTrees2);				    
  -				       _ -> false
  -				   end 
  -			   end;
  -		       _ -> case T1 of  
  -				variable -> case variable_replaceable(Exp2) of 
  -						false -> false;  
  -						true -> 
  -						    case lists:keysearch(category, 1, refac_syntax:get_ann(Exp2)) of 
  -							{value, {category, application_op}} ->
  -							    case lists:keysearch(fun_def, 1, refac_syntax:get_ann(Exp2)) of 
  -								{value, {fun_def, {_M, _N, A, _P1, _P2}}} ->
  -								    {true, [{refac_syntax:variable_name(Exp1), 
  -									     set_default_ann(refac_syntax:implicit_fun(Exp2, refac_syntax:integer(A)))}]};
  -								_ -> %% this is the function name part of a M:F. 
  -								    {true, [{refac_syntax:variable_name(Exp1), set_default_ann(Exp2)}]}
  -							    end;
  -							_ -> {true, [{refac_syntax:variable_name(Exp1), set_default_ann(Exp2)}]}
  -						    end
  -					    end;
  -				_ -> false
  -			    end
  -		   end;
  -	       {true, false} -> %% Exp1 is a list, but Exp2 is not.
  -		   false;
  -	       {false, true} ->  %% Exp1 is a single expression, but Exp2 is not.
  -		   false      %% an actual parameter cannot be a list of expressions.
  -	   end,
  -    case Res1 of 
  +    case expr_unification_1(Exp1, Exp2) of
   	{true, Subst} ->
  -	    Subst1 = lists:usort(lists:map(fun({E1,E2}) -> 
  -						   {E1, refac_prettypr:format(E2)} end, Subst)),
  -	    Len1 = length(lists:usort(lists:map(fun({E1,_E2}) -> E1 end, Subst1))),
  -	    case Len1 == length(Subst1) of 
  +	    Subst1 = lists:usort([{E1, refac_prettypr:format(E2)} || {E1, E2} <- Subst]),
  +	    Subst2 = lists:usort([E1 || {E1, _E2} <- Subst1]),
  +	    case length(Subst2) == length(Subst1) of
   		true -> {true, Subst};
   		_ -> false
   	    end;
   	_ -> false
       end.
  +
  +expr_unification_1(Exp1, Exp2) ->
  +    case {is_list(Exp1), is_list(Exp2)} of
  +	{true, true} ->   %% both are list of expressions
  +	    case length(Exp1) == length(Exp2) of
  +		true ->
  +		    Res = [expr_unification(E1, E2) || {E1, E2} <- lists:zip(Exp1, Exp2)],
  +		    Unifiable = not lists:member(false, [false || false <- Res]),
  +		    case Unifiable of
  +			true ->
  +			    {true, lists:usort(lists:append([S || {true, S} <- Res]))};
  +			_ -> false
  +		    end;
  +		_ -> false
  +	    end;
  +      {false, false} ->  %% both are single expressions.
  +	    T1 = refac_syntax:type(Exp1),
  +	    T2 = refac_syntax:type(Exp2),
  +	    case T1 == T2 of
  +		true -> erpr_unification_2(Exp1, Exp2, T1);
  +		_ -> expr_unification_3(Exp1, Exp2, T1)
  +	  end;
  +	{true, false} -> %% Exp1 is a list, but Exp2 is not.
  +	    false;
  +	{false, true} ->  %% Exp1 is a single expression, but Exp2 is not.
  +	    false      %% an actual parameter cannot be a list of expressions.
  +    end.
  +
  +erpr_unification_2(Exp1, Exp2, Type) ->
  +    case Type of
  +	variable ->
  +	    Exp1Ann = refac_syntax:get_ann(Exp1),
  +	    Exp2Ann = refac_syntax:get_ann(Exp2),
  +	    Exp1Name = refac_syntax:variable_name(Exp1),
  +	    Exp2Name = refac_syntax:variable_name(Exp2),
  +	    case lists:keysearch(category, 1, Exp1Ann) of
  +		{value, {category, macro_name}} ->
  +		    case lists:keysearch(category, 1, Exp2Ann) of
  +			{value, {category, macro_name}} ->
  +			    case Exp1Name of 
  +				Exp2Name ->{true, []};
  +				_ -> false
  +			    end;
  +			_ -> false
  +		    end;
  +		_ -> {true, [{Exp1Name, set_default_ann(Exp2)}]}
  +	    end;
  +	atom -> 
  +	    case refac_syntax:atom_value(Exp1) == refac_syntax:atom_value(Exp2) of
  +	    	true -> {true, []};
  +		_ -> false
  +	    end;
  +	operator -> 
  +	    case refac_syntax:operator_name(Exp1) == refac_syntax:operator_name(Exp2) of
  +		true -> {true, []};
  +		_ -> false
  +	    end;
  +	char -> 
  +	    case refac_syntax:char_value(Exp1) == refac_syntax:char_value(Exp2) of
  +		true -> {true, []};
  +		_ -> false
  +	    end;
  +	integer -> 
  +	    case refac_syntax:integer_value(Exp1) == refac_syntax:integer_value(Exp2) of
  +		true -> {true, []};
  +		_ -> false
  +	    end;
  +	string -> 
  +	    case refac_syntax:string_value(Exp1) == refac_syntax:string_value(Exp2) of
  +		true -> {true, []};
  +		_ -> false
  +	    end;
  +	float -> 
  +	    case refac_syntax:float_value(Exp1) == refac_syntax:float_value(Exp2) of
  +		true -> {true, []}
  +	    end;
  +	underscore -> {true, []};
  +	nil -> {true, []};
  +	_ ->
  +	    SubTrees1 = erl_syntax:subtrees(Exp1),
  +	    SubTrees2 = erl_syntax:subtrees(Exp2),
  +	    case length(SubTrees1) == length(SubTrees2) of
  +		true ->
  +		    expr_unification(SubTrees1, SubTrees2);
  +		_ -> false
  +	    end
  +    end.
  +
  +
  +expr_unification_3(Exp1, Exp2, variable) ->
  +    case variable_replaceable(Exp2) of
  +	false -> 
  +	    false;
  +	true ->
  +	    Exp2Ann = refac_syntax:get_ann(Exp2),
  +	    Exp1Name = refac_syntax:variable_name(Exp1),
  +	    case lists:keysearch(category, 1, Exp2Ann) of
  +		{value, {category, application_op}} ->
  +		    case lists:keysearch(fun_def, 1,Exp2Ann) of
  +			{value, {fun_def, {_M, _N, A, _P1, _P2}}} ->
  +			    {true, [{Exp1Name, set_default_ann(
  +						 refac_syntax:implicit_fun(
  +						   Exp2, refac_syntax:integer(A)))}]};
  +			_ -> %% this is the function name part of a M:F. 
  +			    {true, [{Exp1Name, set_default_ann(Exp2)}]}
  +		    end;
  +		_ -> 
  +		    {true, [{Exp1Name, set_default_ann(Exp2)}]}
  +	    end
  +    end;
  +expr_unification_3(_Exp1, _Exp2, _Type) -> false.
   
   
   variable_replaceable(Exp) ->
  
positive.code: %% =============================================================================================   
  
  make_fun_call({FunDefMod, CurrentMod}, FunName, Pats, Subst) -> 
      Pars = lists:map(fun(P) -> case refac_syntax:type(P) of 
  				   variable -> PName = refac_syntax:variable_name(P), 
  					       case lists:keysearch(PName, 1, Subst) of 
  						   {value, {PName, Par}} -> Par;
  						   _ -> refac_syntax:atom(undefined)
  					       end;
  				   underscore -> 
  				       refac_syntax:atom(undefined);
  				   _  -> P
  			       end
  		     end, Pats),
      Op = case FunDefMod == CurrentMod of 
  	     true -> refac_syntax:atom(FunName);
  	     _ -> refac_syntax:module_qualifier(refac_syntax:atom(FunDefMod), refac_syntax:atom(FunName))
  	 end,
      FunCall = refac_syntax:application(Op, Pars),
      FunCall.
  
  make_match_expr({FunDefMod, CurrentMod}, FunName, Pats, Subst, VarsToExport) ->
      FunCall = make_fun_call({FunDefMod, CurrentMod},FunName, Pats, Subst),
  
negative.code: 			  StartLine1 >= StartLine],
  	    {ok, Regions};
  	{error, _Reason} ->
  	    %% THIS SHOULD NOT HAPPEN.
  	    throw({error, "You have not selected a function definition."}) 
      end.
  
  
  