 
 (defvar projectile-enable-caching)
 ;;;###autoload
-(defun doom/open-scratch-buffer (&optional arg project-p)
+(defun doom/open-scratch-buffer (&optional arg project-p same-window-p)
   "Pop up a persistent scratch buffer.
 
-If passed the prefix ARG, switch to it in the current window.
+If passed the prefix ARG, do not restore the last scratch buffer.
 If PROJECT-P is non-nil, open a persistent scratch buffer associated with the
   current project."
   (interactive "P")
   (let (projectile-enable-caching)
     (funcall
-     (if arg
+     (if same-window-p
          #'switch-to-buffer
        #'pop-to-buffer)
      (doom-scratch-buffer
+      arg
       (cond ((eq doom-scratch-initial-major-mode t)
              (unless (or buffer-read-only
                          (derived-mode-p 'special-mode)

             t)))))

;;;###autoload
(defun doom-scratch-buffer (&optional mode directory project-name)
  "Return a scratchpad buffer in major MODE."
  (let* ((buffer-name (if project-name
                          (format "*doom:scratch (%s)*" project-name)

        (or buffer (get-buffer-create buffer-name))
      (setq default-directory directory)
      (setq-local so-long--inhibited t)
      (if dont-restore-p
          (erase-buffer)
        (unless buffer
          (doom--load-persistent-scratch-buffer project-name)
          (when (and (eq major-mode 'fundamental-mode)
                     (functionp mode))
            (funcall mode))))
      (cl-pushnew (current-buffer) doom-scratch-buffers)
      (add-transient-hook! 'doom-switch-buffer-hook (doom-persist-scratch-buffers-h))
      (add-transient-hook! 'doom-switch-window-hook (doom-persist-scratch-buffers-h))
