From d057fde4ce970b3f08c7ac9c916a760c9ad5ba02 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Mon, 19 Apr 2021 15:25:04 -0500 Subject: Add `acdw/kill-a-buffer' and keybinding --- lisp/acdw.el | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'lisp') diff --git a/lisp/acdw.el b/lisp/acdw.el index 44d15d0..650cb3f 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el @@ -126,6 +126,24 @@ if MAKE-DIRECTORY is non-nil." (directory-files-recursively user-emacs-directory "\.el$")))) +(defun acdw/kill-a-buffer (&optional prefix) + "Kill a buffer based on the following rules: + +C-x k => Kill CURRENT buffer and window +C-u C-x k => Kill OTHER buffer and window +C-u C-u C-x k => Kill ALL OTHER buffers and windows + +Prompt only if there are unsaved changes." + (interactive "P") + (pcase (or (car prefix) 0) + (0 (kill-current-buffer) + (unless (one-window-p) (delete-window))) + (4 (other-window 1) + (kill-current-buffer) + (unless (one-window-p) (delete-window))) + (16 (mapc 'kill-buffer (delq (current-) (buffer-list))) + (delete-other-windows)))) + ;; Make `C-z' more useful (defvar acdw/leader -- cgit 1.4.1-21-gabe81