From e5dbfa00325ffeac69dc7128959d41479184abc4 Mon Sep 17 00:00:00 2001 From: Fabien Dubosson Date: Sun, 11 Oct 2015 18:17:00 +0200 Subject: [PATCH] Add switch-to-scratch-buffer function and bind it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change add a `switch-to-scratch-buffer` function allowing to – you guessed it – switch to the `*scratch*` buffer, taking care of creating it if necessary. The function is bind to `SPC b s`, `b` as it concerns buffers, and `s` for `scratch`. --- doc/DOCUMENTATION.org | 1 + layers/+distribution/spacemacs-base/funcs.el | 5 +++++ layers/+distribution/spacemacs-base/keybindings.el | 1 + 3 files changed, 7 insertions(+) diff --git a/doc/DOCUMENTATION.org b/doc/DOCUMENTATION.org index 17d51e3c2..5dab148be 100644 --- a/doc/DOCUMENTATION.org +++ b/doc/DOCUMENTATION.org @@ -1558,6 +1558,7 @@ Buffer manipulation commands (start with ~b~): | ~SPC b p~ | switch to previous buffer avoiding special buffers | | ~SPC b P~ | copy clipboard and replace buffer (useful when pasting from a browser) | | ~SPC b R~ | revert the current buffer (reload from disk) | +| ~SPC b s~ | switch to the =*scratch*= buffer (create it if needed) | | ~SPC b w~ | toggle read-only (writable state) | | ~SPC b Y~ | copy whole buffer to clipboard (useful when copying to a browser) | | ~z f~ | Make current function or comments visible in buffer as much as possible | diff --git a/layers/+distribution/spacemacs-base/funcs.el b/layers/+distribution/spacemacs-base/funcs.el index 008e88e33..b354f8107 100644 --- a/layers/+distribution/spacemacs-base/funcs.el +++ b/layers/+distribution/spacemacs-base/funcs.el @@ -905,3 +905,8 @@ is nonempty." (cond ((listp val) val) ((stringp val) (< 0 (length val))) (t)))) + +(defun spacemacs/switch-to-scratch-buffer () + "Switch to the `*scratch*' buffer. Create it first if needed." + (interactive) + (switch-to-buffer (get-buffer-create "*scratch*"))) diff --git a/layers/+distribution/spacemacs-base/keybindings.el b/layers/+distribution/spacemacs-base/keybindings.el index 4f7fd5e32..a4e198727 100644 --- a/layers/+distribution/spacemacs-base/keybindings.el +++ b/layers/+distribution/spacemacs-base/keybindings.el @@ -76,6 +76,7 @@ "bn" 'spacemacs/next-useful-buffer "bp" 'spacemacs/previous-useful-buffer "bR" 'spacemacs/safe-revert-buffer + "bs" 'spacemacs/switch-to-scratch-buffer "bY" 'spacemacs/copy-whole-buffer-to-clipboard "bw" 'read-only-mode) ;; Cycling settings -----------------------------------------------------------