anchor.diff:  %% OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
   %% ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   %%% =====================================================================
  -%% Refactoring: Move a function definition from one module to another.
  +%% Refactoring: Move a function definition, or a collection of functions, from one module to another.
   %%
   %% Author contact: hl@kent.ac.uk, sjt@kent.ac.uk
   %% 
  
positive.code:     {Forms111, Forms112}= lists:splitwith(fun(F) -> 
  						  refac_syntax:type(F)==comment 
  					  end, lists:reverse(Forms11)),
      lists:reverse(Forms112)++Export ++ lists:reverse(Forms111) ++ Forms12.
      
     
  %%=========================================================================
  %% Refacotoring in the current module. 
  %%========================================================================
  process_a_form_in_original_mod(FileName,Form, {ModName, FunName, Arity}, TargetModName, SearchPaths, TabWidth, Pid) ->
      case refac_syntax:type(Form) of 
  	function -> 
  	    As = refac_syntax:get_ann(Form),
  	    case lists:keysearch(fun_def,1, As) of 
  		{value, {fun_def, {ModName, FunName, Arity, _, _}}} ->
  		    {[], false};
  		_ ->
  		    {Form1, C}=add_change_module_qualifier(FileName, Form, {ModName, FunName, Arity}, 
  							   TargetModName, SearchPaths, TabWidth, Pid),
  		    {[Form1],C}
  	    end;		    
  	attribute -> Name = refac_syntax:attribute_name(Form),
  		     case refac_syntax:type(Name) of 
  			 atom ->case refac_syntax:atom_value(Name) of
  				    export -> [L] = refac_syntax:attribute_arguments(Form),
  					      Es = refac_syntax:list_elements(L),
  					      Es1 =[E  || E<-Es, 
  							  {refac_syntax:atom_value(refac_syntax:arity_qualifier_body(E)),
  							   refac_syntax:integer_value(refac_syntax:arity_qualifier_argument(E))}
  							      =/={FunName, Arity}],
  					      case length(Es1) == 0 of
  						  true -> 
  						      {[],false} ;
  						  false -> 
  						      case length(Es1) == length(Es) of 
  							  true -> {[Form], false};
  							  _ -> {[copy_pos_attrs(Form,refac_syntax:attribute(Name,[refac_syntax:list(Es1)]))], true}
  						      end
  					      end;
  				    spec -> FA = hd(refac_syntax:attribute_arguments(Form)),
  					    case refac_syntax:type(FA) of
  						tuple ->
  						    case refac_syntax:tuple_elements(FA) of 
  							[_M1, F1, A1] ->case {refac_syntax:atom_value(F1), refac_syntax:integer_value(A1)} of
  									    {FunName, Arity} -> {[],true};
  									    _ -> {[Form], false}
  									    end;
  							[F1, A1] ->case {refac_syntax:atom_value(F1), refac_syntax:integer_value(A1)} of
  								       {FunName, Arity} -> {[],true};
  								       _ -> {[Form],false}
  								   end;
  							_ -> {[Form],false}
  						    end;
  						_ ->{[Form], false}
  					    end;
  				    _  -> {[Form], false}
  				end;
  			 _  -> {[Form], false}
  		     end;
  	_-> {[Form], false}
      end.
  
  %%============================================================================
  %% Refactoring in the target module.
  %%============================================================================
  process_a_form_in_target_module(FileName, Form, {ModName, FunName, Arity}, TargetModName, SearchPaths, TabWidth, Pid) ->
      case refac_syntax:type(Form) of
  	function -> [remove_module_qualifier(FileName, Form, {ModName, FunName, Arity}, TargetModName, SearchPaths, TabWidth, Pid)];
  	attribute -> Name = refac_syntax:attribute_name(Form),
  		     case refac_syntax:type(Name) of
  			 atom -> case refac_syntax:atom_value(Name) of
  				     import ->
  					 [H, L] = refac_syntax:attribute_arguments(Form),
  					 case refac_syntax:atom_value(H) of 
  					     ModName ->
  						 Es = refac_syntax:list_elements(L),
  						 Es1 = [E || E <- Es,
  							     {refac_syntax:atom_value(refac_syntax:arity_qualifier_body(E)),
  							      refac_syntax:integer_value(refac_syntax:arity_qualifier_argument(E))}
  								 =/= {FunName, Arity}],
  						 case length(Es1) == 0 of
  						     true -> [];
  						     _ -> [copy_pos_attrs(Form,refac_syntax:attribute(Name, [H, refac_syntax:list(Es1)]))]
  						 end;
  					     _ -> [Form]
  					 end;
  				     _ -> [Form]
  				 end;
  			 _ -> [Form]
  		     end;
  	_ -> [Form]
      end.
  
  %%============================================================================
  %% Add/remove module qualifier.
  %%============================================================================
  remove_module_qualifier(FileName, Form, {ModName, FunName, Arity}, TargetModName, SearchPaths, TabWidth, Pid) ->
      element(1, ast_traverse_api:full_tdTP(fun do_remove_module_qualifier/2, Form,
  					  {FileName, {ModName, FunName, Arity},
  					   TargetModName, SearchPaths, TabWidth, Pid})).
    
  
  do_remove_module_qualifier(Node, {FileName, {ModName, FunName, Arity}, TargetModName, SearchPaths, TabWidth, Pid}) ->
      case refac_syntax:type(Node) of
        application ->
  	  Op = refac_syntax:application_operator(Node),
  	  Args = refac_syntax:application_arguments(Node),
  	  case application_info(Node) of
  	    {{none, FunName}, Arity} -> {Node, true};
  	    {{ModName, FunName}, Arity} ->
  		case refac_syntax:type(Op) of
  		  tuple -> {rename_fun_in_tuple_op(Node, Op, Args, TargetModName), true};
  		  _ ->
  		      Op1 = copy_pos_attrs(Op, refac_syntax:atom(FunName)),
  		      Node1 = copy_pos_attrs(Node, refac_syntax:application(Op1, Args)),
  		      {Node1, true}
  		end;
  	    {{Mod1, Fun1}, Ari1} ->
  		case lists:keysearch({Mod1, Fun1, Ari1}, 1, refac_misc:apply_style_funs()) of
  		  {value, _} ->
  		      transform_apply_style_calls(FileName, Node, {ModName, FunName, Arity}, TargetModName, SearchPaths, TabWidth);
  		  false -> {Node, false}
  		end
  	  end;
        implicit_fun -> process_implicit_fun(Node, ModName, FunName, Arity, TargetModName);
        tuple -> do_rename_fun_in_tuples(Node, {FileName, SearchPaths, ModName, FunName, TargetModName, Arity, Pid, TabWidth});
        _ -> {Node, false}
      end.
  
  process_implicit_fun(Node, ModName, FunName, Arity, TargetModName) ->
      Name = refac_syntax:implicit_fun_name(Node),
      case refac_syntax:type(Name) of
        arity_qualifier ->
  	  {Node, false};
        module_qualifier ->
  	    Mod = refac_syntax:module_qualifier_argument(Name),
  	    Body = refac_syntax:module_qualifier_body(Name),
  	    case refac_syntax:type(Mod) of
  	    atom ->
  		case refac_syntax:atom_value(Mod) of
  		  ModName ->
  		      B = refac_syntax:arity_qualifier_body(Body),
  		      A = refac_syntax:arity_qualifier_argument(Body),
  		      case {refac_syntax:type(B), refac_syntax:type(A)} of
  			{atom, integer} ->
  			    case
  			      {refac_syntax:atom_value(B), refac_syntax:integer_value(A)}
  				of
  			      {FunName, Arity} ->
  				  {copy_pos_attrs(Node,
  					 refac_syntax:implicit_fun(copy_pos_attrs(Name,
  					  refac_syntax:module_qualifier(copy_pos_attrs(Mod,
  					  refac_syntax:atom(TargetModName)), Body)))), true};
  			      _ -> {Node, false}
  			    end;
  			_ -> {Node, false}
  		      end;
  		  _ -> {Node, false}
  		end;
  	      _ ->{Node, false}
  	  end
      end.
  add_change_module_qualifier(FileName, Form, {ModName, FunName, Arity}, TargetModName, SearchPaths, TabWidth, Pid) ->
      ast_traverse_api:full_tdTP(fun do_add_change_module_qualifier/2,
  			       Form, {FileName, {ModName, FunName, Arity}, TargetModName, SearchPaths, TabWidth, Pid}).
  
  do_add_change_module_qualifier(Node, {FileName, {ModName, FunName, Arity}, TargetModName, SearchPaths, TabWidth, Pid}) ->
      MakeApp = fun (Node1, Operator1, Arguments1, TargetModName1, FunName1) ->
  		      Operator2 = copy_pos_attrs(Operator1, refac_syntax:module_qualifier(refac_syntax:atom(TargetModName1),
  											  refac_syntax:atom(FunName1))),
  		      Node2 = copy_pos_attrs(Node1, refac_syntax:application(Operator2, Arguments1)),
  		      {Node2, true}
  	      end,
      case refac_syntax:type(Node) of
        application ->
  	  Operator = refac_syntax:application_operator(Node),
  
negative.code: move_fun(FName, Line, Col, TargetModorFileName, SearchPaths, TabWidth) ->
      move_fun(FName, Line, Col, TargetModorFileName, SearchPaths, TabWidth, emacs).
  
  -spec(move_fun_1/7::(filename(),integer(),integer(), string(),boolean(), [dir()], integer())->
  	     {ok, [filename()]} | {error, string()}).
  move_fun_1(FName, Line, Col, TargetModorFileName, CheckCond, SearchPaths, TabWidth) ->
      move_fun_1(FName, Line, Col, TargetModorFileName, CheckCond, SearchPaths, TabWidth, emacs).
  
  
  -spec(move_fun_eclipse/6::(filename(),integer(),integer(), string(),[dir()], integer())
  