 (define-key ros-run-keymap "k" 'rosemacs/terminate-process)
 (define-key ros-run-keymap "q" 'rosemacs/kill-process-buffer)
 (define-key ros-run-keymap "r" 'rosrun/restart-current)
+(define-key ros-run-keymap "x" 'rosrun/kill-and-restart)
 
 (define-minor-mode ros-run-mode
   "Mode used for rosrun

        )
      )))

(defun rosemacs/relaunch-current-process ()
  (interactive)
  (rosemacs/relaunch (current-buffer)))

(defun rosrun/restart-current ()
  (interactive)
  (rosrun/restart (current-buffer)))

(defun rosemacs/kill-process-buffer ()
  (interactive)
  (let ((process (get-buffer-process (current-buffer))))
    (if process
        (progn
          (when (eq (process-status process) 'run)
            (interrupt-process))
      ;; Give it time to shutdown cleanly
          (set-process-sentinel process '(lambda (proc event)
                                           (let ((buf (process-buffer proc)))
                                             (message "Killing %s in response to process event %s" buf event)
                                             (kill-buffer buf)))))
      (kill-buffer (current-buffer)))))

(defun rosrun/kill-and-restart ()
  (interactive)
  (let ((process (get-buffer-process (current-buffer))))
    (if (and process (eq (process-status process) 'run))
        (progn
          (set-process-sentinel process '(lambda (proc event)
                                           (let ((buf (process-buffer proc)))
                                             (message "%s has terminated; restarting" ros-run-executable)
                                             (rosrun/restart))))
          (rosemacs/terminate-process process))
      (error "Buffer does not contain a running process"))))


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; roslaunch
