 (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

(define-key ros-launch-keymap "k" 'rosemacs/interrupt-process)
(define-key ros-launch-keymap "q" 'rosemacs/kill-process-buffer)
(define-key ros-launch-keymap "r" 'rosemacs/relaunch-current-process)




        )
      )))

(defun rosemacs/kill-and-relaunch ()
  "Interrupt the current roslaunch process, and when it has terminated, relaunch."
  (interactive)
  (let ((process (get-buffer-process (current-buffer))))
    (if (and process (eq (process-status process) 'run))
        (progn
          (interrupt-process)
          (set-process-sentinel process
                                '(lambda (proc event)
                                   (message "Roslaunch has terminated; relaunching")
                                   (rosemacs/relaunch (process-buffer proc))
                                   )))
      (error "Buffer doesn't contain a running process"))))


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