                                         (cons pkg nil))
                                       (ros-find-executables ros-run-temp-var))
                               nil nil nil nil ros-run-temp-var)))
-  (let ((name (format "*rosrun:%s/%s" pkg exec)))
-    (if (rosemacs/contains-running-process name)
-        (warn "Rosrun buffer %s already exists: not creating a new one." name)
-      (let ((buf (get-buffer-create name))) 
-        (apply #'start-process name buf "rosrun" pkg exec args)
-        (save-excursion
-          (set-buffer buf)
-          (view-buffer-other-window buf)
-          (ros-run-mode 1))
-        buf))))
+  (let* ((name (format "*rosrun:%s/%s" pkg exec))
+         (buf (get-buffer-create name)))
+    (save-excursion
+      (set-buffer buf)
+      (setq ros-run-pkg pkg
+            ros-run-executable exec
+            ros-run-args args))
+    (rosrun/restart buf)
+    ))
+
+(defun rosrun/restart (buf)
+  (if (rosemacs/contains-running-process buf)
+      (warn "Rosrun buffer %s already exists: not creating a new one." (buffer-name buf))
+    (progn
+      (save-excursion
+        (set-buffer buf)
+        (ros-run-mode 1)
+        (apply 'start-process (buffer-name buf) buf "rosrun" ros-run-pkg ros-run-executable ros-run-args))
+      (display-buffer buf))))
+
+(defun rosrun/restart-current ()
+  (interactive)
+  (rosrun/restart (current-buffer)))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; roslaunch

q kills the buffer and process."
  :init-value nil
  :lighter " ros-run"
  :keymap ros-topic-echo-keymap
  (message "ros-run mode: k to stop, q to quit"))

(defun rosemacs/contains-running-process (name)
  (let ((buf (get-buffer name)))

      (re-search-forward "^\\(.*\\)$")
      (match-string 1))))

(defvar ros-run-keymap (make-sparse-keymap))
(define-key ros-run-keymap "k" 'rosemacs/interrupt-process)
(define-key ros-run-keymap "q" 'rosemacs/kill-process-buffer)
(define-key ros-run-keymap "r" 'rosrun/restart-current)

(define-minor-mode ros-run-mode
  "Mode used for rosrun

