anchor.diff:  
   subst_check(Expr1, SubSt) ->
       BVs = refac_util:get_bound_vars(Expr1),
  +    F = fun ({E1, E2}) ->
  +		case refac_syntax:type(E1) of
  +		    variable ->
  +			case is_macro_name(E1) of
  +			    true ->
  +				false;
  +			    _ -> 
  +				{value, {def, DefPos}} = lists:keysearch(def, 1, refac_syntax:get_ann(E1)),
  +				%% local vars should have the same substitute.
  +				not lists:any(fun ({E11, E21}) ->
  +						      refac_syntax:type(E11) == variable 
  +							  andalso
  +							    {value, {def, DefPos}} == lists:keysearch(def, 1, refac_syntax:get_ann(E11))
  +							  andalso
  +							  refac_prettypr:format(reset_attrs(E2))
  +							  =/= refac_prettypr:format(reset_attrs(E21))
  +					      end, SubSt)
  +			end;
  +		    _ ->
  +			%% the expression to be replaced should not contain local variables.
  +			BVs -- refac_util:get_free_vars(E1) == BVs
  +		end
  +	end,
       case BVs of
         [] ->
   	  true;
  -      _ -> lists:all(fun ({E1, E2}) ->
  -			     case refac_syntax:type(E1) of
  -			       variable ->
  -				   case is_macro_name(E1) of
  -				     true ->
  -					 false;
  -				     _ -> {value, {def, DefPos}} = lists:keysearch(def, 1, refac_syntax:get_ann(E1)),
  -					  %% local vars should have the same substitute.
  -					  not lists:any(fun ({E11, E21}) ->
  -								refac_syntax:type(E11) == variable andalso
  -								  {value, {def, DefPos}} == lists:keysearch(def, 1, refac_syntax:get_ann(E11)) andalso
  -								    refac_prettypr:format(reset_attrs(E2))
  -								      =/= refac_prettypr:format(reset_attrs(E21))
  -							end, SubSt)
  -				   end;
  -			       _ ->
  -				   %% the expression to be replaced should not contain local variables.
  -				   BVs -- refac_util:get_free_vars(E1) == BVs
  -			     end
  -		     end, SubSt)
  +      _ -> lists:all(F,SubSt)
       end.
       
   reset_attrs(Node) ->
  -    refac_util:full_buTP(fun (T, _Others) -> 
  -				 refac_syntax:remove_comments(refac_syntax:set_ann(T, [])) end, 
  +    refac_util:full_buTP(fun (T, _Others) ->
  +				 T1 =refac_syntax:set_ann(T, []),
  +				 refac_syntax:remove_comments(T1)
  +			 end, 
   			 Node, {}).
   
      
  
positive.code:    
      
  generalise_expr_1(Exprs, Subst, ExportVars) when is_list(Exprs)->
      {E, NewExportVars} = generalise_expr_2(refac_syntax:block_expr(Exprs), Subst, refac_util:get_free_vars(Exprs), ExportVars),
      {refac_syntax:block_expr_body(E), NewExportVars};
  generalise_expr_1(Expr, Subst, ExportVars) ->
      {E, NewExportVars}=generalise_expr_2(Expr, Subst, refac_util:get_free_vars(Expr), ExportVars),
      {[E], NewExportVars}.
    
  generalise_expr_2(Expr, Subst, ExprFreeVars, {ExportVars1, ExportVars2}) ->
      case lists:all(fun(S) -> S==[] end, Subst) of 
  	true -> {Expr, ExportVars1};
  	_ ->
  	    Pid = start_counter_process(sets:from_list(collect_vars(Expr))),
  	    ExportVars3 = [E || E<-ExportVars2, refac_syntax:type(E) =/= variable],
  	    {Expr1, _}= refac_util:stop_tdTP(fun do_replace_expr_with_var_1/2, Expr, {Subst, ExprFreeVars, Pid, ExportVars3}),
  	    NewVarsToExport = get_new_export_vars(Pid),
  	    stop_counter_process(Pid),
  	    VarsToExport = refac_util:remove_duplicates(ExportVars1++[refac_syntax:variable_name(E)||E<-ExportVars2, 
  						     refac_syntax:type(E)==variable]++NewVarsToExport),
  	    {Expr1, VarsToExport}						  
      end.
  
  
negative.code: %% how about expressions has side effects?
  variable_replaceable(Exp) ->
      case lists:keysearch(category, 1, refac_syntax:get_ann(Exp)) of
  	{value, {category, record_field}} -> false;
  	{value, {category, record_type}} -> false;
  	{value, {category, guard_expression}} -> false;
  	{value, {category, macro_name}} -> false;
  	{value, {category, pattern}} ->
  	    case refac_syntax:is_literal(Exp) orelse
  		refac_syntax:type(Exp) == variable
  	    of
  		true ->
  		    true;
  		_ -> false
  	    end;
        _ -> 
  	    T = refac_syntax:type(Exp),
  	    not lists:member(T, [match_expr, operator]) andalso
  		refac_util:get_var_exports(Exp) == []
      end.
  
  
  