   (progn
     (kasumi-remove-all-dive-overlay)
     (if (not DEBUG)
-        (let ((prev (current-buffer)))
+        (save-current-buffer
           (progn
-            (switch-to-buffer (process-buffer shiranui-process))
-            (erase-buffer)
-            (switch-to-buffer prev))))
-    ))
+            (set-buffer (process-buffer shiranui-process))
+            (erase-buffer))))))
 
 (defun kasumi-select-explore-sub ()
   (interactive)

(defconst DEBUG nil)
(defun kasumi-debug-print (str &optional force)
  (if (or DEBUG force)
      (let ((prev (current-buffer)))
        (progn
          (switch-to-buffer (process-buffer shiranui-process))
          (goto-char (point-max))
          (insert str)
          (insert "\n")
          (switch-to-buffer prev)))))


;; need newline end of string?

    )
  ))

(defun kasumi-select-highlight ()
  (interactive)
  (kasumi-select-clear)
  (if mark-active
      (progn
        (kasumi-select-highlight-sub (region-beginning) (region-end)
                                     explore-data (length explore-data))
    )))

(defun kasumi-select-highlight-sub (from to data index)
  (if (not (null data))
      (let* ((head  (car data))
             (hfrom (nth 0 head))
             (hto   (nth 1 head))
             (value (nth 2 head))
             (tail (cdr data)))
        (if (<= from hfrom hto to)
            (save-current-buffer
              (set-buffer (process-buffer shiranui-process))
              (goto-char (point-min))
              (kasumi-put-dive-highlight (line-beginning-position index)
                                         (line-beginning-position (+ index 1)))))
        (kasumi-select-highlight-sub from to tail (- index 1)))))

(defun kasumi-select-clear ()
  (interactive)
  (save-current-buffer
    (set-buffer (process-buffer shiranui-process))
    (kasumi-remove-all-dive-overlay)))

(defun kasumi-move-hook ()
  (or executing-kbd-macro
      (input-pending-p)
      (progn
        (kasumi-select-highlight)
        )))
(defun kasumi-lift-sub (from to)
  (kasumi-send-command kasumi-command-lift
                       (format "%d %d"
