Don't change scratch major mode if buffer exists

This commit is contained in:
Eivind Fonn 2016-02-10 20:28:03 +01:00
parent de7eb40337
commit a111f4802d
1 changed files with 6 additions and 4 deletions

View File

@ -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)