anchor.diff:      
         
   rename_fun_1(File, OldFunName, Arity, NewFunName, SearchPaths) ->
  -    FAs= get_fa(File, OldFunName, Arity),
  +    FAs= get_fun_arity(File, OldFunName, Arity),
       [{refactoring, {refac_rename_fun, rename_fun_by_name, 
                       [File, F, A, new_name_gen(File, F, A, NewFunName), 
                        SearchPaths, composite_emacs]}, gen_question(rename_fun,{File, F,A})}
  
positive.code: gen_question(gen_fun, {File, F, A, _Expr}) ->
      M=list_to_atom(filename:basename(File, ".erl")),
      lists:flatten(io_lib:format("Do you want to generalise function ~p:~p/~p over the expression(s) highlighted?",
                                  [M,F,A])).
  
  swap_args({ModOrFile, FunName, Arity}, Index1, Index2, SearchPaths) ->
      Files= get_files(ModOrFile, SearchPaths),
  
negative.code:          rename_var/4, 
           swap_args/4,
           fold_expr/4,
           gen_fun/6,
           move_fun/4]).
  
  -include("../include/wrangler.hrl").
  
  move_fun({SrcModOrFile, FunName, Arity}, TgtModOrFile, SearchPaths, GenOrder) ->
      case locate_one_file(SrcModOrFile, SearchPaths) of
          {error, Reason} ->
              wrangler_io:format("Warning: ~p\n", [Reason]),
              [];
          SrcFile ->
              case locate_one_file(TgtModOrFile, SearchPaths) of
                  {error, Reason} ->
                      wrangler_io:format("Warning: ~p\n", [Reason]),
                      [];
                  TgtFile ->
                     move_fun_1({SrcFile, FunName, Arity}, TgtFile, SearchPaths, GenOrder)
              end
      end.
  
  move_fun_1({SrcFile, FunName, Arity}, TgtFile, SearchPaths, GenOrder) ->
      FAs= get_fun_arity(SrcFile, FunName, Arity, GenOrder),
      [{refactoring, {refac_move_fun, move_fun_by_name, [{SrcFile, F, A}, TgtFile, 
                                                         SearchPaths, composite_emacs]},
        gen_question(move_fun, {SrcFile, F, A, TgtFile})} 
       ||{F, A} <-FAs].
          
  gen_fun(ModOrFile, FA, Expr, NewParName, SearchPaths, GenOrder) ->
      Files= get_files(ModOrFile, SearchPaths),
      CmdLists=[gen_fun_1(File, FA, Expr, NewParName, SearchPaths, GenOrder, [])
                ||File<-Files],
      lists:append(CmdLists).
  
  gen_fun_1(File, FA, Expr, NewParName, SearchPaths, GenOrder, Acc) ->
      Refacs=gen_fun_2(File, FA,Expr, NewParName, SearchPaths, GenOrder, Acc),
      case Refacs of 
          [] -> [];
          [R={refactoring, {refac_gen, generalise, [File, F, A |_]}, _Question}|_Rs] ->
              {R,{generator, fun()->
                                     gen_fun_1(File, FA, Expr, NewParName, SearchPaths, GenOrder, [{File, F, A}|Acc])
                             end}}     
      end.
                                  
  gen_fun_2(File, FA,ExprFilter, NewParName, SearchPaths, GenOrder, Acc)->
      FAs= get_fa(File, FA, GenOrder),
      [{refactoring, {refac_gen, generalise, 
                      [File, F, A, Exprs, new_name_gen(File, F, A, Exprs, NewParName),
                       SearchPaths, composite_emacs]}, gen_question(gen_fun,{File,F,A,Exprs})}
       ||{F, A}<-FAs, not lists:member({File, F, A}, Acc),
         Ranges<-[get_exprs(File, F, A, ExprFilter)], Ranges/=[],
         Exprs<-[{range, {File, Ranges}}]].
  
    
  get_exprs(File, FunName, Arity, ExprFilter) ->
      ModName=list_to_atom(filename:basename(File, ".erl")),
      FunDef=api_refac:mfa_to_fun_def({ModName, FunName, Arity}, File),
      ?FULL_TD_TU([?COLLECT(?T("E@"),  
                            api_refac:start_end_loc(E@),
                            api_refac:is_expr(E@) andalso
                            ExprFilter(E@))], FunDef).
   
  fold_expr(CurModOrFile, {ModOrFile, FunName, Arity}, ClauseIndex, SearchPaths) ->
      Files= get_files(CurModOrFile, SearchPaths),
      case locate_one_file(ModOrFile, SearchPaths) of
          {error, Reason} ->
              wrangler_io:format("Warning: ~p\n", [Reason]); 
          TgtFile ->
              ModName=list_to_atom(filename:basename(TgtFile, ".erl")),
              [{F,A}] = get_fun_arity(TgtFile, FunName, Arity),
              CmdLists=[fold_expr_1(File,  ModName, F, A, ClauseIndex, SearchPaths)
                        ||File<-Files],
              lists:append(CmdLists)
      end.
          
  fold_expr_1(File, ModName, FunName, Arity, ClauseIndex, SearchPaths) ->
      [{refactoring, {refac_fold_expression, fold_expr_by_name, 
                      [File, atom_to_list(ModName), atom_to_list(FunName), 
                       integer_to_list(Arity), integer_to_list(ClauseIndex), 
                       SearchPaths, composite_emacs]},
        lists:flatten(io_lib:format("Do you want to fold against function ~p:~p/~p?", 
                                    [ModName,FunName,Arity]))}].
  
  