From a111f4802d850c32a2ef6ff6c2d62cc6c0861b84 Mon Sep 17 00:00:00 2001 From: Eivind Fonn Date: Wed, 10 Feb 2016 20:28:03 +0100 Subject: [PATCH] Don't change scratch major mode if buffer exists --- layers/+distribution/spacemacs-base/funcs.el | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/layers/+distribution/spacemacs-base/funcs.el b/layers/+distribution/spacemacs-base/funcs.el index 985eacca3..52856f2c9 100644 --- a/layers/+distribution/spacemacs-base/funcs.el +++ b/layers/+distribution/spacemacs-base/funcs.el @@ -879,10 +879,12 @@ is nonempty." (defun spacemacs/switch-to-scratch-buffer () "Switch to the `*scratch*' buffer. Create it first if needed." (interactive) - (switch-to-buffer (get-buffer-create "*scratch*")) - (when (and (not (eq major-mode dotspacemacs-scratch-mode)) - (fboundp dotspacemacs-scratch-mode)) - (funcall dotspacemacs-scratch-mode))) + (let ((exists (get-buffer "*scratch*"))) + (switch-to-buffer (get-buffer-create "*scratch*")) + (when (and (not exists) + (not (eq major-mode dotspacemacs-scratch-mode)) + (fboundp dotspacemacs-scratch-mode)) + (funcall dotspacemacs-scratch-mode)))) ;; http://stackoverflow.com/questions/11847547/emacs-regexp-count-occurrences (defun how-many-str (regexp str)