anchor.diff:  		      fun(T) ->
   			      element(2, T)<Start
   		      end, Toks),
  -	    lists:takewhile(fun(T)->
  -				    element(2, T)=<End
  -			    end, Toks1)
  -    end.
  +	    Toks2=lists:takewhile(fun(T)->
  +                                          element(2, T)=<End
  +                                  end, Toks1),
  +            get_delimitor(FileName)++Toks2
  +    end.
  +
  +
  +get_start_end_loc_with_comment(Node) when is_list(Node) ->
  +    E1 = hd(Node),
  +    En = lists:last(Node),
  +    {S, _E} = get_start_end_loc_with_comment(E1),
  +    {_S, E} = get_start_end_loc_with_comment(En),
  +    {S, E};
  +
  +get_start_end_loc_with_comment(Node) ->
  +    {Start, End} = refac_util:get_start_end_loc(Node),
  +    PreCs = refac_syntax:get_precomments(Node),
  +    PostCs = refac_syntax:get_postcomments(Node),
  +    Start1 = case PreCs of
  +                 [] ->
  +                     Start;
  +                 _ ->
  +                     refac_syntax:get_pos(hd(PreCs))
  +             end,
  +    End1 = case PostCs of
  +               [] ->
  +                   End;
  +               _ ->
  +                   LastC = refac_syntax:comment_text(lists:last(PostCs)),
  +                   {L, C}=refac_syntax:get_pos(lists:last(PostCs)),
  +                   {L, C+length(LastC)-1}
  +           end,
  +    {Start1, End1}.
  +
  +
  +
  +get_delimitor(FileName) ->        
  +    case refac_util:file_format(FileName) of
  +        dos ->
  +            [{whitespace, {0,0}, '\r'},
  +             {whitespace, {0,0}, '\n'},
  +             {whitespace, {0,0}, '\r'},
  +             {whitespace, {0,0}, '\n'}];
  +        mac -> 
  +            [{whitespace, {0,0}, '\r'},
  +            {whitespace, {0,0}, '\r'}];
  +        _ -> 
  +            [{whitespace, {0,0}, '\n'},
  +             {whitespace, {0,0}, '\n'}]
  +    end.
  
positive.code: 	false -> ok
      end.
  
  do_fun_extraction(AnnAST, ExpList, NewFunName, ParNames, VarsToExport, {EncFunName, EncFunArity, EncFunPos}) ->
      NewFunName1 = refac_syntax:atom(NewFunName),
      Pars = [refac_syntax:variable(P) || P <- ParNames],
      LastExprExportVars = [V || {V, _Pos} <- refac_util:get_var_exports(lists:last(ExpList))],
  
negative.code:     FunPos = refac_syntax:get_pos(Fun),
      {FrVars, BdVars} = get_free_bd_vars(ExpList),
      VarsToExport = vars_to_export(Fun, End, BdVars),
      AnnAST1 = do_fun_extraction(FileName, AnnAST, ExpList, NewFunName, FrVars, VarsToExport, {FunName, FunArity, FunPos}),
      case Editor of
  	emacs ->
  	    Res = [{{FileName, FileName}, AnnAST1}],
  