          ))))
  
  
-(defun apply-a-refac-cmd(current-file-name cmd args)   
+(defun apply-a-refac-cmd(current-file-name refac_name args)   
   "apply a sub refayctoring of a composite refactorings."
   (interactive) 
-  (setq mod_name (elt cmd 0)) 
-  (setq refac_name (elt cmd 1))  
   (highlight_sels args)
   (setq newargs (get_user_inputs args))
   (org-delete-overlay highlight-region-overlay)
- ;; (message "refac_name: %s" refac_name)
   (setq refac-function-name (car (cdr (assoc refac_name refac-cmd-name-map))))
- ;; (message "new args: %s" newargs)
-;;  (message "command name: %s" refac-function-name)
   (if refac-function-name 
-      (funcall refac-function-name (append newargs (list 'composite_emacs tab-width)))
+      (funcall refac-function-name (append newargs (list tab-width)))
     (erl-spawn
-      (erl-send-rpc wrangler-erl-node 'wrangler_refacs 'try_refactoring 
-                    (list mod_name refac_name (append newargs (list 'composite_emacs tab-width))))
+      (erl-send-rpc wrangler-erl-node 'wrangler_refacs 'try_refac 
+                    (list 'wrangler_refacs refac_name 
+                          (append newargs (list tab-width))))
       (erl-receive(current-file-name)
           ((['rex result]
             (process-result current-file-name result 0 0 t)))
         )))
   )
-   
+
 (defvar refac-cmd-name-map
   '((move_fun_by_name erl-refactor-move-fun-composite)
     (rename_fun_by_name erl-refactor-rename-fun-composite)
     (rename_var  erl-refactor-rename-var-composite)
     (fold_expr_by_name erl-refactor-fold-expr-by-name-composite)
     (generalise_composite  erl-refactor-generalisation-composite)))
- 
- 
+
+
 (defun update-buffers(files)
   "update the buffers for files that have been changed"
   (dolist (f files)

        (column-no         (current-column-no))
	(buffer (current-buffer)))
    (if (buffers-saved)
        (erl-refactor-rename-fun-1 current-file-name line-no column-no name wrangler-search-paths tab-width 'emacs)
      (message "Refactoring aborted."))))

(defun erl-refactor-rename-fun-1 (current-file-name line-no column-no name wrangler-search-paths tab-width editor)
  "Rename an identified function name."
  (setq composite-refac-p (equal editor 'composite_emacs))
  (erl-spawn
    (erl-send-rpc wrangler-erl-node 'emacs_refac 'rename_fun
                  (list current-file-name line-no column-no name 
                        wrangler-search-paths tab-width))
    (erl-receive (line-no column-no current-file-name name composite-refac-p)
        ((['rex ['warning msg]] 
          (progn
            (if (y-or-n-p msg)
                (erl-spawn
                  (erl-send-rpc wrangler-erl-node 'wrangler_refacs 
                                'try_refactoring (list 'refac_rename_fun 'rename_fun_1 
                                                       (list current-file-name line-no column-no name 
                                                             wrangler-search-paths tab-width)))
                  (erl-receive (line-no column-no current-file-name composite-refac-p)
                      ((['rex result]
                        (process-result current-file-name result line-no column-no composite-refac-p)))))

                      (setq instances_to_gen (get_instances_to_gen instances_in_fun buffer highlight-region-overlay)))
                    (erl-spawn
                      (erl-send-rpc wrangler-erl-node 'wrangler_refacs
                                     'try_refac (list 'refac_gen 'gen_fun_1 
                                                            (list 'true current-file-name parname funname arity 
                                                                  defpos exp search-paths tab-width 
                                                                  instances_to_gen editor logmsg)))
