From f2fe785a1a44627041433548c4e377867a59d507 Mon Sep 17 00:00:00 2001 From: Jessie Hildebrandt Date: Mon, 20 Jul 2020 20:03:35 -0400 Subject: [PATCH] Add a function for switching to the scratch buffer --- init.el | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/init.el b/init.el index 68b6099..94b4bdc 100644 --- a/init.el +++ b/init.el @@ -48,6 +48,16 @@ ;; Variables/Basic Config. ;;==================== +;; Define an interactive function for switching to the scratch buffer, (re)creating it if not present. +(defun switch-to-scratch-buffer () + "Switch to the scratch buffer, (re)creating it if not present." + (interactive) + (if (get-buffer "*scratch*") + (switch-to-buffer "*scratch*") + (progn + (switch-to-buffer (get-buffer-create "*scratch*")) + (lisp-interaction-mode)))) + ;; Basic variable configuration. (setq-default initial-scratch-message "" ; Remove initial message