     (if (and pub-start sub-start)
         (let ((new-published-topics (rosemacs/get-topics pub-start sub-start ros-num-publishers)))
           (setq ros-subscribed-topics (rosemacs/get-topics sub-start (point-max) ros-num-subscribers))
-          (destructuring-bind (added deleted) (rosemacs-list-diffs ros-topics new-published-topics)
-            (lwarn '(rosemacs) :debug "added topics : %s" added)
-            (dolist (topic added)
-              (add-ros-topic topic))
-            (dolist (topic deleted)
-              (remove-ros-topic topic))))
+          (let ((new-topics (sort* (remove-duplicates (vconcat new-published-topics ros-subscribed-topics)
+                                                      :test 'equal)
+                                   'string<)))
+            (destructuring-bind (added deleted) (rosemacs-list-diffs ros-topics (append  new-topics nil))
+              (lwarn '(rosemacs) :debug "added topics : %s" added)
+              (dolist (topic added)
+                (add-ros-topic topic))
+              (dolist (topic deleted)
+                (remove-ros-topic topic)))))
       (lwarn '(rosemacs) :debug "rostopic output did not look as expected; could just be that the master is not up.")))
   (lwarn '(rosemacs) :debug "Done parsing rostopic list")
   (setq ros-all-topics 



(defun update-ros-topic-buffer-helper ()
  (set-buffer ros-topic-buffer)
  (let ((old-stamp (rosemacs/get-stamp-string)))
    (erase-buffer)

  (interactive)
  (interrupt-process))

(defun rosemacs/terminate-process ()
  (interactive)
  (signal-process (get-buffer-process (current-buffer)) 'SIGTERM)
  )

(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)))))

(defvar ros-topic-echo-keymap (make-sparse-keymap))
(define-key ros-topic-echo-keymap "k" 'rosemacs/terminate-process)
(define-key ros-topic-echo-keymap "q" 'rosemacs/kill-process-buffer)

(define-minor-mode ros-topic-echo-mode 
