 
 (defun smartwin--match-buffer (buffer-or-name)
   "Judge whether to use smartwin to show BUFFER-OR-NAME."
-  (let ((buffer (if (stringp buffer-or-name)
-                    (get-buffer buffer-or-name)
-                  buffer-or-name)))
+  (let ((buffer (get-buffer buffer-or-name)))
     (if buffer
         (let ((name (buffer-name buffer))
               (mode (buffer-local-value 'major-mode buffer)))

            (setq smartwin-previous-buffer nil))

          (if (buffer-live-p smartwin-previous-buffer)
              (message (concat "[smartwin] "
                               (buffer-name smartwin-previous-buffer)))))

      ;; (remove-hook 'kill-emacs-hook 'smartwin-hide)
      (setq display-buffer-alist (delete pair display-buffer-alist))

(defun smartwin--get-smart-window ()
  "Find smart window among all live windows.
If found, return the window, else return nil."
  (let ((root-tree (car (window-tree (selected-frame)))))
    (if (and (listp root-tree) (car root-tree))
        (let ((bottom-window (car (last root-tree))))
          (if (smartwin--smart-window-p bottom-window)
              bottom-window
            nil))
      nil)))

(defun smartwin--get-befitting-window ()
  "Try to get an existing befitting bottom window as smart window."
