         (when only-buffer-window-p
           (kill-buffer buffer)
           (unless (doom-real-buffer-p)
-            (doom--cycle-real-buffers -1))))))
-  t)
+            (doom--cycle-real-buffers -1))))
+      (eq (current-buffer) buffer))))
 
 ;;;###autoload
 (defun doom-kill-buffer-and-windows (buffer)

               (--any? (string-match-p it (buffer-name buffer))
                       (-filter 'stringp doom-buffers-unreal-alist)))))))

(defun doom--kill-buffers (buffers &optional filter-func)
  (let ((buffers (if filter-func (-filter filter-func buffers) buffers))
        (affected 0))
    (mapc (lambda (b) (when (kill-buffer b) (incf affected))) buffers)
    (unless (doom-real-buffer-p)
      (doom--cycle-real-buffers -1))
    (message "Killed %s buffers" affected)))

;;;###autoload
(defun doom/next-buffer ()
  "Switch to the next real buffer, skipping special buffers. See

checks before killing processes. If there are no buffers with matching
major-modes, the process gets killed.")

;;;###autoload
(defun doom-narrow-buffer (beg end &optional clone-p)
  "Restrict editing in this buffer to the current region, indirectly. With BANG,
clone the buffer and hard-narrow the selection. If mark isn't active, then widen
the buffer (if narrowed).

Inspired from http://demonastery.org/2013/04/emacs-evil-narrow-region/"
  (interactive "r")
  (if (region-active-p)
    (progn
      (deactivate-mark)
      (when clone-p
        (let ((old-buf (current-buffer)))
          (switch-to-buffer (clone-indirect-buffer nil nil))
          (setq doom-buffer--narrowed-origin old-buf)))
      (narrow-to-region beg end))
    (if doom-buffer--narrowed-origin
      (progn
        (kill-this-buffer)
        (switch-to-buffer doom-buffer--narrowed-origin)
        (setq doom-buffer--narrowed-origin nil))
      (widen))))

;;;###autoload (autoload 'doom:buffer-narrow "core/autoload/buffers" nil t)
(after! evil
  (evil-define-operator doom:buffer-narrow (&optional beg end bang)
    (interactive "<r><!>")
    (doom-narrow-buffer beg end bang)))


;; Buffer Life and Death ;;;;;;;;;;;;;;;
