From c690a853e8d1ac06ce394e001298773caf9e95a2 Mon Sep 17 00:00:00 2001 From: Jeremy Dormitzer Date: Tue, 23 Feb 2021 11:07:23 -0500 Subject: [PATCH] Add binding to switch to most recent buffer --- emacs/.emacs.d/config/init-buffers.el | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/emacs/.emacs.d/config/init-buffers.el b/emacs/.emacs.d/config/init-buffers.el index 9d5a528..c391e89 100644 --- a/emacs/.emacs.d/config/init-buffers.el +++ b/emacs/.emacs.d/config/init-buffers.el @@ -6,7 +6,15 @@ (interactive) (mapc 'kill-buffer (delq (current-buffer) (buffer-list)))) +(defun switch-to-previous-buffer () + "Switch to previously open buffer. +Repeated invocations toggle between the two most recently open buffers." + (interactive) + (switch-to-buffer (other-buffer (current-buffer) 1))) + + (leader-def-key + "TAB" #'switch-to-previous-buffer "b" '(nil :which-key "buffer") "bb" #'switch-to-buffer "bd" #'kill-buffer