 		      (['rex ['error rsn]]
 		       (message "Refactoring failed: %s" rsn))
 		      (['rex ['ok modified]]
-		       (with-current-buffer buffer (revert-buffer nil t t))
+		       (dolist (f modified)
+			 (let ((buff (get-file-buffer f)))
+			   (if buff
+			       (with-current-buffer buff (revert-buffer nil t t))
+			     ;;(message-box (format "modified unopened file: %s" f))))))
+			     nil)))
+		       (with-current-buffer buffer
+			 (goto-char (get-position line-no column-no)))
 		       (message "Refactoring succeeded!")))))
 	     (message "Refactoring aborted!")))
 	   (['rex ['ok modified]]
+	    (dolist (f modified)
+ 	      (let ((buff (get-file-buffer f)))
+ 		(if buff
+ 		    (with-current-buffer buff (revert-buffer nil t t))
+ 		  ;;(message-box (format "modified unopened file: %s" f))))))
+ 		  nil)))
 	    (with-current-buffer buffer
-	       (dolist (f modified)
-		 (let ((buffer (get-file-buffer f)))
-		   (if buffer (with-current-buffer buffer (revert-buffer nil t t))
-		     ;;(message-box (format "modified unopened file: %s" f))))))
-		     nil))))
-	       (message "Refactoring succeeded!")))))))))
+	      (goto-char (get-position line-no column-no)))
+	    (message "Refactoring succeeded!")))))))))
 
 
 (defun erl-refactor-register-pid(node name start end)

	(erl-spawn
	  (erl-send-rpc node 'wrangler_distel 'new_macro
			(list current-file-name start-line-no start-col-no end-line-no (- end-col-no 1) name erlang-refac-search-paths))
	  (erl-receive (buffer)
	      ((['rex ['badrpc rsn]]
		(message "Refactoring failed: %S" rsn))
	       (['rex ['error rsn]]
		(message "Refactoring failed: %s" rsn))
	       (['rex ['ok str]]
		(with-current-buffer buffer (revert-buffer nil t t))
		(message "Refactoring succeeded!")))))))))

(defun erl-refactor-fold-against-macro(node)

      (if changed (message-box (format "there are modified buffers: %s" changed))
    (erl-spawn
      (erl-send-rpc node 'wrangler_distel 'rename_fun (list current-file-name line-no column-no name erlang-refac-search-paths))
      (erl-receive (buffer line-no column-no)
	  ((['rex ['badrpc rsn]]
	    (message "Refactoring failed: %S" rsn))
	   (['rex ['error rsn]]
	    (message "Refactoring failed: %s" rsn))
	   (['rex ['ok modified]]
	     (dolist (f modified)
 	      (let ((buff (get-file-buffer f)))
 		(if buff
 		    (with-current-buffer buff (revert-buffer nil t t))
 		  ;;(message-box (format "modified unopened file: %s" f))))))
 		  nil)))
	     (with-current-buffer buffer
	       (goto-char (get-position line-no column-no)))
	     (message "Refactoring succeeded!")
	    ))))))))



