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

View file

@ -879,10 +879,12 @@ is nonempty."
(defun spacemacs/switch-to-scratch-buffer () (defun spacemacs/switch-to-scratch-buffer ()
"Switch to the `*scratch*' buffer. Create it first if needed." "Switch to the `*scratch*' buffer. Create it first if needed."
(interactive) (interactive)
(switch-to-buffer (get-buffer-create "*scratch*")) (let ((exists (get-buffer "*scratch*")))
(when (and (not (eq major-mode dotspacemacs-scratch-mode)) (switch-to-buffer (get-buffer-create "*scratch*"))
(fboundp dotspacemacs-scratch-mode)) (when (and (not exists)
(funcall dotspacemacs-scratch-mode))) (not (eq major-mode dotspacemacs-scratch-mode))
(fboundp dotspacemacs-scratch-mode))
(funcall dotspacemacs-scratch-mode))))
;; http://stackoverflow.com/questions/11847547/emacs-regexp-count-occurrences ;; http://stackoverflow.com/questions/11847547/emacs-regexp-count-occurrences
(defun how-many-str (regexp str) (defun how-many-str (regexp str)