       ad-do-it)))
 
 (defadvice switch-to-buffer (around smartwin-switch-to-buffer)
-  "When a bffer should be show in smart window, chage window to smart window."
+  "When a bffer should be shown in smart window, chage window to smart window."
   (let ((buffer-or-name (ad-get-arg 0)))
     (if (smartwin-match-buffer buffer-or-name)
         (let ((smart-win (smartwin-get-smart-win)))
           (with-selected-window smart-win
             ad-do-it)
-          (select-window smart-win)
-          (smartwin-enlarge-window smart-win))
+          (select-window smart-win))
       (let ((window (selected-window)))
         (if (smartwin-smart-window-p window)
-            (progn
-              (switch-to-buffer-other-window buffer-or-name)
-              (minimize-window window))
+            (switch-to-buffer-other-window buffer-or-name)
           ad-do-it)))))
 
 (defadvice switch-to-buffer-other-window

        (if smartwin-mode
            (progn
              (push pair display-buffer-alist)
              ;;(ad-activate 'switch-to-buffer)
              ;;(ad-activate 'switch-to-buffer-other-window)
              ;;(ad-activate 'windmove-do-window-select)
              ;;(ad-activate 'evil-window-move-very-top)
              ;;(ad-activate 'evil-window-move-far-left)

    (if (smartwin-smart-window-p window)
        (smartwin-hide))))

(defadvice kill-buffer (around smartwin-kill-buffer)
  "When run `kill-buffer' in smart window, find right buffer to show.
If no buffer can be showed in smart window, hide it."
  (let ((buffer (ad-get-arg 0))
        window)
    (if (not buffer)
        (setq buffer (current-buffer)))
    (setq window (get-buffer-window buffer))
    ad-do-it
    (if (smartwin-smart-window-p window)
        (progn
          (setq buffer
                (catch 'break
                  (dolist (b (window-prev-buffers window))
                    (if (smartwin-match-buffer b)
                        (throw 'break b)))
                  (throw 'break nil)))
          (if buffer
              (set-window-buffer winodw buffer)
            (smartwin-hide t))))))

(defadvice select-window (after smartwin-select-window)
  "Enlarge or shringe smart window when select window."
