anchor.diff:  %% @spec fold_expression(FileName::filename(), Line::integer(), Col::integer())-> term()
   %% =============================================================================================        
   
  --spec(fold_expr_by_loc/5::(filename(), integer(), integer(), [dir()], integer())->
  -			 {ok, [{integer(), integer(), integer(), integer(), syntaxTree(), {filename(), atom(), syntaxTree(), integer()}}]}
  +-spec(fold_expr_by_loc/4::
  +      (filename(), integer(), integer(), [dir()]) -> {ok, [{integer(), integer(), integer(), integer(), syntaxTree(), {filename(), atom(), syntaxTree(), integer()}}]}
   							 | {error, string()}).
   
  -fold_expr_by_loc(FileName, Line, Col, SearchPaths, TabWidth) ->
  -    fold_expression(FileName, Line, Col, SearchPaths, TabWidth, emacs).
  -
  --spec(fold_expr_by_loc_eclipse/5::(filename(), integer(), integer(), [dir()], integer()) -> {ok,  {syntaxTree(),
  +fold_expr_by_loc(FileName, Line, Col, SearchPaths) ->
  +    fold_expression(FileName, Line, Col, SearchPaths, emacs).
  +
  +-spec(fold_expr_by_loc_eclipse/4::(filename(), integer(), integer(), [dir()]) -> {ok,  {syntaxTree(),
   										  [{{{integer(), integer()}, {integer(), integer()}}, syntaxTree()}]}}
   										     | {error, string()}).
   
  -fold_expr_by_loc_eclipse(FileName, Line, Col, SearchPaths, TabWidth) ->
  -    fold_expression(FileName, Line, Col, SearchPaths, TabWidth, eclipse).
  -
  -fold_expression(FileName, Line, Col, SearchPaths, TabWidth, Editor) ->
  -    ?wrangler_io("\nCMD: ~p:fold_expression(~p, ~p,~p,~p).\n", [?MODULE, FileName, Line, Col, TabWidth]),
  -    {ok, {AnnAST, Info}} =refac_util:parse_annotate_file(FileName,true, SearchPaths, TabWidth),
  +fold_expr_by_loc_eclipse(FileName, Line, Col, SearchPaths) ->
  +    fold_expression(FileName, Line, Col, SearchPaths, eclipse).
  +
  +fold_expression(FileName, Line, Col, SearchPaths, Editor) ->
  +    ?wrangler_io("\nCMD: ~p:fold_expression(~p, ~p,~p).\n", [?MODULE, FileName, Line, Col]),
  +    {ok, {AnnAST, Info}} = refac_util:parse_annotate_file(FileName, true, SearchPaths),
       {value, {module, CurrentModName}} = lists:keysearch(module, 1, Info),
  -    case pos_to_fun_clause(AnnAST, {Line, Col}) of 
  -	{ok, {Mod, FunName, _Arity, FunClauseDef, ClauseIndex}} ->
  -	    case side_condition_analysis(FunClauseDef) of 
  -		ok ->			    
  -		    Candidates = search_candidate_exprs(AnnAST, {Mod, Mod}, FunName, FunClauseDef),
  -		    case Candidates of 
  -			[] -> {error, "No expressions that are suitable for folding against the selected function have been found!"};	
  -			_ -> case Editor of 
  -				 emacs ->Regions = lists:map(fun({{{StartLine, StartCol}, {EndLine, EndCol}},NewExp}) ->
  -								     {StartLine, StartCol, EndLine,EndCol, NewExp, {FileName, CurrentModName, FunClauseDef, ClauseIndex}} end, 
  -							     Candidates),
  -					 {ok, Regions};
  -				 eclipse ->  {ok, {FunClauseDef, Candidates}}
  -			     end			      
  -		    end;				 
  -		{error, Reason} -> {error, Reason}
  -	    end;
  -	{error, _} ->
  -	    {error, "You have not selected a function definition."}
  -    end.
  -
  -
  --spec(fold_expr_by_name/7::(filename(), string(), string(), string(), string(), [dir()], integer()) ->
  +    case pos_to_fun_clause(AnnAST, {Line, Col}) of
  +      {ok, {Mod, FunName, _Arity, FunClauseDef, ClauseIndex}} ->
  +	  case side_condition_analysis(FunClauseDef) of
  +	    ok ->
  +		Candidates = search_candidate_exprs(AnnAST, {Mod, Mod}, FunName, FunClauseDef),
  +		case Candidates of
  +		  [] -> {error, "No expressions that are suitable for folding against the selected function have been found!"};
  +		  _ -> case Editor of
  +			 emacs -> Regions = lists:map(fun ({{{StartLine, StartCol}, {EndLine, EndCol}}, NewExp}) ->
  +							      FunClauseDef1 = term_to_list(FunClauseDef),
  +							      {StartLine, StartCol, EndLine, EndCol, NewExp,
  +							       {FileName, CurrentModName, FunClauseDef1, ClauseIndex}}
  +						      end,
  +						      Candidates),
  +				  {ok, Regions};
  +			 eclipse -> {ok, {FunClauseDef, Candidates}}
  +		       end
  +		end;
  +	    {error, Reason} -> {error, Reason}
  +	  end;
  +      {error, _} ->
  +	  {error, "You have not selected a function definition."}
  +    end.
  +
  +
  +-spec(fold_expr_by_name/6::(filename(), string(), string(), string(), string(), [dir()]) ->
   	     {ok, [{integer(), integer(), integer(), integer(), syntaxTree(), {filename(), atom(), syntaxTree(), integer()}}]}
   		 | {error, string()}).
   
  -fold_expr_by_name(FileName, ModName, FunName, Arity, ClauseIndex, SearchPaths, TabWidth) ->
  -    case ModName of 
  -	[] -> {error, "Invalid module name!"};
  -	_  -> case FunName of 
  -		  [] -> {error, "Invalid function name!"};
  -		  _ -> case (Arity==[]) orelse (list_to_integer(Arity) <0) of   
  -			   true -> {error, "Invalid arity!"};
  -			   _ -> case (ClauseIndex==[]) orelse (list_to_integer(ClauseIndex) <1) of 
  -				    true -> {error, "Invalid function clause index!"};
  -				    _ ->				
  -					fold_expr_by_name(FileName, list_to_atom(ModName), list_to_atom(FunName), 
  -							  list_to_integer(Arity), list_to_integer(ClauseIndex), SearchPaths,  TabWidth, emacs)
  -				end
  -		       end
  -	      end
  +fold_expr_by_name(FileName, ModName, FunName, Arity, ClauseIndex, SearchPaths) ->
  +    case ModName of
  +      [] -> {error, "Invalid module name!"};
  +      _ -> case FunName of
  +	     [] -> {error, "Invalid function name!"};
  +	     _ -> case Arity == [] orelse list_to_integer(Arity) < 0 of
  +		    true -> {error, "Invalid arity!"};
  +		    _ -> case ClauseIndex == [] orelse list_to_integer(ClauseIndex) < 1 of
  +			   true -> {error, "Invalid function clause index!"};
  +			   _ ->
  +			       fold_expr_by_name(FileName, list_to_atom(ModName), list_to_atom(FunName),
  +						 list_to_integer(Arity), list_to_integer(ClauseIndex), SearchPaths, emacs)
  +			 end
  +		  end
  +	   end
       end.
    
  --spec(fold_expr_by_name_eclipse/7::(filename(), string(), string(), string(), string(), [dir()], integer()) ->
  +-spec(fold_expr_by_name_eclipse/6::(filename(), string(), string(), string(), string(), [dir()]) ->
   	     {ok, [{{{integer(), integer()}, {integer(), integer()}}, syntaxTree()}]} 
   		 | {error, string()}).
   
  -fold_expr_by_name_eclipse(FileName, ModName, FunName, Arity, ClauseIndex, SearchPaths, TabWidth) ->
  -	case ModName of 
  -		[] -> {error, "Invalid module name!"};
  -		_  -> case FunName of 
  -				  [] -> {error, "Invalid function name!"};
  -				  _ -> case (Arity==[]) orelse (list_to_integer(Arity) <0) of   
  -						   true -> {error, "Invalid arity!"};
  -						   _ -> case (ClauseIndex==[]) orelse (list_to_integer(ClauseIndex) <1) of 
  -									true -> {error, "Invalid function clause index!"};
  -									_ ->				
  -										fold_expr_by_name(FileName, list_to_atom(ModName), list_to_atom(FunName), 
  -														  list_to_integer(Arity), list_to_integer(ClauseIndex), SearchPaths, TabWidth,  eclipse)
  -								end
  -					   end
  -			  end
  +fold_expr_by_name_eclipse(FileName, ModName, FunName, Arity, ClauseIndex, SearchPaths) ->
  +    case ModName of
  +      [] -> {error, "Invalid module name!"};
  +      _ -> case FunName of
  +	     [] -> {error, "Invalid function name!"};
  +	     _ -> case Arity == [] orelse list_to_integer(Arity) < 0 of
  +		    true -> {error, "Invalid arity!"};
  +		    _ -> case ClauseIndex == [] orelse list_to_integer(ClauseIndex) < 1 of
  +			   true -> {error, "Invalid function clause index!"};
  +			   _ ->
  +			       fold_expr_by_name(FileName, list_to_atom(ModName), list_to_atom(FunName),
  +						 list_to_integer(Arity), list_to_integer(ClauseIndex), SearchPaths, eclipse)
  +			 end
  +		  end
  +	   end
       end.
      
   
  -fold_expr_by_name(FileName, ModName, FunName, Arity, ClauseIndex, SearchPaths, TabWidth,  Editor) ->
  -    ?wrangler_io("\nCMD: ~p:fold_expression(~p,~p,~p,~p,~p,~p).\n", [?MODULE, FileName, ModName, FunName, Arity, ClauseIndex, TabWidth]),
  -    {ok, {AnnAST, Info}} = refac_util:parse_annotate_file(FileName, true, SearchPaths, TabWidth),
  +fold_expr_by_name(FileName, ModName, FunName, Arity, ClauseIndex, SearchPaths, Editor) ->
  +    ?wrangler_io("\nCMD: ~p:fold_expression(~p,~p,~p,~p,~p).\n", [?MODULE, FileName, ModName, FunName, Arity, ClauseIndex]),
  +    {ok, {AnnAST, Info}} = refac_util:parse_annotate_file(FileName, true, SearchPaths),
       {value, {module, CurrentModName}} = lists:keysearch(module, 1, Info),
       Files = refac_util:expand_files(SearchPaths, ".erl"),
       FileNames = lists:filter(fun (F) -> list_to_atom(filename:basename(F, ".erl")) == ModName end, Files),
  
positive.code:     end.
  
  
  -spec(cursor_at_fun_clause/5::(filename(), integer(), integer(), [dir()], integer()) ->
  	     true |false).
  cursor_at_fun_clause(FileName, Line, Col, SearchPaths, TabWidth) ->    
      {ok, {AnnAST, _Info}} =refac_util:parse_annotate_file(FileName,true, SearchPaths, TabWidth),
      case pos_to_fun_clause(AnnAST, {Line, Col}) of 
  	{ok, {_Mod, _FunName, _Arity, _FunClauseDef, _ClauseIndex}} -> true;
  	_  -> false
  
negative.code:     
      
  
  -spec(fold_expression_1/8::(filename(), integer(), integer(), integer(), integer(), syntaxTree(), {filename(),atom(), syntaxTree(), integer()}, [dir()]) ->
  	     {ok, [{integer(), integer(), integer(), integer(), syntaxTree(), {filename(), atom(), syntaxTree(), integer()}}]}).
  
  fold_expression_1(FileName, StartLine, StartCol, EndLine, EndCol, NewExp1, {FunDefFileName, FunDefMod, FunClauseDef1, ClauseIndex}, SearchPaths) ->
      NewExp = list_to_term(NewExp1),
      FunClauseDef = list_to_term(FunClauseDef1),
      {ok, {AnnAST, Info}} = refac_util:parse_annotate_file(FileName, true, SearchPaths),
      {value, {module, CurrentMod}} = lists:keysearch(module, 1, Info),
      FunCall = case refac_syntax:type(NewExp) of
  		application -> NewExp;
  		match_expr -> refac_syntax:match_expr_body(NewExp)
  	      end,
      Op = refac_syntax:application_operator(FunCall),
      FunName = case refac_syntax:type(Op) of
  		atom -> refac_syntax:atom_value(Op);
  		module_qualifier ->
  		    refac_syntax:atom_value(refac_syntax:module_qualifier_body(Op))
  	      end,
      Arity = length(refac_syntax:application_arguments(FunCall)),
      Body = refac_syntax:clause_body(FunClauseDef),
      {AnnAST1, _} = refac_util:stop_tdTP(fun do_replace_expr_with_fun_call/2, AnnAST, {Body, NewExp, {{StartLine, StartCol}, {EndLine, EndCol}}}),
      refac_util:write_refactored_files([{{FileName, FileName}, AnnAST1}]),
      {ok, {AnnAST2, _Info2}} = refac_util:parse_annotate_file(FileName, true, SearchPaths),
      {ok, {AnnAST3, _Info3}} = refac_util:parse_annotate_file(FunDefFileName, true, SearchPaths),
      case get_fun_clause_def(AnnAST3, FunName, Arity, ClauseIndex) of
        {ok, {_Mod, _FunName, _Arity, FunClauseDef2}} ->
  	  Candidates = search_candidate_exprs(AnnAST2, {FunDefMod, CurrentMod}, FunName, FunClauseDef2),
  	  FunClauseDef3 = term_to_list(FunClauseDef2),
  	  Regions = [{StartLine1, StartCol1, EndLine1, EndCol1, term_to_list(FunCall1), {FunDefFileName, FunDefMod, FunClauseDef3, ClauseIndex}}
  		     || {{{StartLine1, StartCol1}, {EndLine1, EndCol1}}, FunCall1} <- Candidates,
  			StartLine1 >= StartLine],
  	  {ok, Regions};
        {error, _Reason} ->
  	  {error, "You have not selected a function definition."}  %% THIS SHOULD NOT HAPPEN.
      end.
    
  
  
  -spec(fold_expression_2_eclipse/6::(filename(), atom(),integer(), integer(), integer(), [dir()]) -> 
  	     {ok, [{integer(), integer(), integer(), integer(), syntaxTree(), {syntaxTree(), integer()}}]}
               | {error, string()}).
  fold_expression_2_eclipse(FileName, FunName, Arity, ClauseIndex, StartLine, SearchPaths ) ->
      {ok, {AnnAST2, _Info1}} = refac_util:parse_annotate_file(FileName,true, SearchPaths),
      case get_fun_clause_def(AnnAST2, FunName, Arity, ClauseIndex) of 
  	{ok, {Mod, _FunName, _Arity, FunClauseDef1}} ->
  	    Candidates = search_candidate_exprs(AnnAST2, {Mod, Mod}, FunName, FunClauseDef1),
  