anchor.diff:      end.
   
   
  --spec(fold_expression_1/5::(filename(), atom(), integer(), [dir()], integer()) -> {syntaxTree(), moduleInfo()} | {error, string()}).
  +-spec(fold_expression_1/5::(filename(), atom(), integer(), [dir()], integer()) -> 
  +	     {syntaxTree(), moduleInfo()} | {error, string()}).
   fold_expression_1(FileName, FunName, Arity, SearchPaths, TabWidth) ->
       {ok, {AnnAST, Info}} =refac_util:parse_annotate_file(FileName,true, SearchPaths, TabWidth),
       {value, {module, ModName}} = lists:keysearch(module, 1, Info),
  
positive.code: %% Replace an expression/expression sequence with a function call/match expression whose right-hand side is the function call.
  %% ==========================================================================================================================
   
  
  do_replace_expr_with_fun_call(Tree, {Expr, {Range, NewExp}})->
      case length(Expr) of 
  	1 -> do_replace_expr_with_fun_call_1(Tree, {Range, NewExp});
  	_  -> do_replace_expr_with_fun_call_2(Tree, {Range, NewExp})
      end.
  						   
  
  
  do_replace_expr_with_fun_call_1(Tree, {Range, NewExp}) ->
      case refac_util:get_range(Tree) of 
   	Range ->
  	     {NewExp, true};
   	_  -> {Tree, false}
       end.
   	
  do_replace_expr_with_fun_call_2(Tree, {{StartLoc, EndLoc}, NewExp}) ->
        case refac_syntax:type(Tree) of
  	clause ->
  	    Exprs = refac_syntax:clause_body(Tree),
  	    {Exprs1, Exprs2} = lists:splitwith(fun(E) -> element(1,refac_util:get_range(E)) =/= StartLoc end, Exprs),
  	    {NewBody, Modified} = case Exprs2 of 
  				      [] -> {Exprs, false};
  				      _ -> {_Exprs21, Exprs22} = lists:splitwith(fun(E) -> element(2, refac_util:get_range(E)) =/= EndLoc end, Exprs),
  					   case Exprs22 of 
  					       [] -> {Exprs, false};  %% THIS SHOULD NOT HAPPEN.
  					       _ -> {Exprs1++[NewExp|tl(Exprs22)], true}
  					   end
  				  end,
  	    Pats = refac_syntax:clause_patterns(Tree),
  	    G = refac_syntax:clause_guard(Tree),
  	    {refac_syntax:copy_pos(Tree, refac_syntax:copy_attrs(Tree, refac_syntax:clause(Pats, G, NewBody))), Modified};
  	block_expr ->
  	    Exprs = refac_syntax:block_expr_body(Tree),
  	    {Exprs1, Exprs2} = lists:splitwith(fun(E) -> element(1,refac_util:get_range(E)) =/= StartLoc end, Exprs),
  	    {NewBody, Modified} = case Exprs2 of 
  				      [] -> {Exprs, false};
  				      _ -> {_Exprs21, Exprs22} = lists:splitwith(fun(E) -> element(2, refac_util:get_range(E)) =/= EndLoc end, Exprs),
  					   case Exprs22 of 
  					       [] -> {Exprs, false};  %% THIS SHOULD NOT HAPPEN.
  					       _ -> {Exprs1++[NewExp|tl(Exprs22)], true}
  					   end
  				  end,
  	    {refac_syntax:copy_pos(Tree, refac_syntax:copy_attrs(Tree, refac_syntax:block_expr(NewBody))), Modified};	 
  	_  -> {Tree, false}
      end.
      
  
  %% =============================================================================================
  %% Search expression/expression sequence with are instances of of the selected function clause.
  
negative.code: %% =============================================================================================   
  
  make_fun_call({FunDefMod, CurrentMod}, FunName, Pats, Subst) -> 
      Fun = 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,
      Pars = lists:map(Fun, Pats),
      Op = case FunDefMod == CurrentMod of 
  	     true -> refac_syntax:atom(FunName);
  	     _ -> refac_syntax:module_qualifier(
  		    refac_syntax:atom(FunDefMod), refac_syntax:atom(FunName))
  	 end,
      refac_syntax:application(Op, Pars).
    
  
  make_match_expr({FunDefMod, CurrentMod}, FunName, Pats, Subst, VarsToExport) ->
      FunCall = make_fun_call({FunDefMod, CurrentMod},FunName, Pats, Subst),
  