From 323a93b081dcdbc58e99686f76558be1c5e048e0 Mon Sep 17 00:00:00 2001 From: Stefan Schwarz Date: Mon, 5 Aug 2019 11:59:13 +0200 Subject: [PATCH] allow scratch buffer switching --- init.el | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/init.el b/init.el index 766a1ae..3f6f8ee 100644 --- a/init.el +++ b/init.el @@ -174,6 +174,10 @@ "ar" 'ranger "ad" 'dired + ;; Buffers + "b" '(:ignore t :which-key "Buffers") + "bs" 'switch-to-scratch-buffer + ;; Files "ff" 'counsel-find-file "fL" 'counsel-locate @@ -261,6 +265,15 @@ (window-configuration-to-register ?_) (delete-other-windows))))) +(defun switch-to-scratch-buffer (&optional arg) + "Switch to the `*scratch*' buffer, creating it first if needed. +if prefix argument ARG is given, switch to it in an other, possibly new window." + (interactive "P") + (let ((exists (get-buffer "*scratch*"))) + (if arg + (switch-to-buffer-other-window (get-buffer-create "*scratch*")) + (switch-to-buffer (get-buffer-create "*scratch*"))))) + (defun switch-to-last-buffer () "Switch to the last buffer, allowes quick jumping between the last two." (interactive)