 
   (advice-add #'persp-asave-on-exit :around #'+workspaces*autosave-real-buffers)
 
+  (defun +workspaces|ensure-main-workspace (&rest _)
+    "Ensure the main workspace exists and the nil workspace is never active."
+    (when persp-mode
+      (let (persp-before-switch-functions)
+        ;; The default perspective persp-mode creates (`persp-nil-name') is
+        ;; special and doesn't represent a real persp object, so buffers can't
+        ;; really be assigned to it, among other quirks. We create a *real* main
+        ;; workspace to fill this role.
+        (unless (persp-get-by-name +workspaces-main)
+          (persp-add-new +workspaces-main))
+        ;; Switch to it if we're in the nil perspective
+        (dolist (frame (frame-list))
+          (when (string= (safe-persp-name (get-current-persp frame)) persp-nil-name)
+            (persp-frame-switch +workspaces-main frame)
+            ;; Fix #319: the warnings buffer gets swallowed by creating
+            ;; `+workspaces-main', so we display it manually, if it exists.
+            (when-let (warnings (get-buffer "*Warnings*"))
+              (save-excursion
+                (display-buffer-in-side-window
+                 warnings '((window-height . shrink-window-if-larger-than-buffer))))))))))
+  (add-hook 'persp-mode-hook #'+workspaces|ensure-main-workspace)
+  (add-hook 'persp-after-load-state-functions #'+workspaces|ensure-main-workspace)
+
   (defun +workspaces|init-persp-mode ()
     (cond (persp-mode
            ;; `uniquify' breaks persp-mode. It renames old buffers, which causes


  (defun +workspaces*evil-alternate-buffer (&optional window)
    "Make `evil-alternate-buffer' ignore buffers outside the current workspace."
    (let* ((prev-buffers (cl-remove-if-not #'persp-contain-buffer-p (window-prev-buffers)
                                           :key #'car))
           (head (car prev-buffers)))
      (if (eq (car head) (window-buffer window))
          (cadr prev-buffers)

  (defun +workspaces|init ()
    ;; Remove default buffer predicate so persp-mode can put in its own
    (delq! 'buffer-predicate default-frame-alist 'assq)
    (require 'persp-mode)
    (if (daemonp)
        (add-hook 'after-make-frame-functions #'persp-mode-start-and-remove-from-make-frame-hook)
      (persp-mode +1)))
  (unless noninteractive
    (add-hook 'doom-init-modules-hook #'+workspaces|init))
  :config
  (setq persp-autokill-buffer-on-remove 'kill-weak
        persp-nil-hidden t
