summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCase Duckworth2021-04-19 15:25:04 -0500
committerCase Duckworth2021-04-19 15:25:04 -0500
commitd057fde4ce970b3f08c7ac9c916a760c9ad5ba02 (patch)
tree9c9efdd62142da7a344122f7924484ac3a7b47b1
parentMerge branch 'main' of https://tildegit.org/acdw/emacs (diff)
downloademacs-d057fde4ce970b3f08c7ac9c916a760c9ad5ba02.tar.gz
emacs-d057fde4ce970b3f08c7ac9c916a760c9ad5ba02.zip
Add `acdw/kill-a-buffer' and keybinding
-rw-r--r--init.el3
-rw-r--r--lisp/acdw.el18
2 files changed, 20 insertions, 1 deletions
diff --git a/init.el b/init.el index 554f7e4..a92520b 100644 --- a/init.el +++ b/init.el
@@ -224,7 +224,8 @@
224 "M-/" hippie-expand 224 "M-/" hippie-expand
225 "M-=" count-words 225 "M-=" count-words
226 "C-x C-b" ibuffer 226 "C-x C-b" ibuffer
227 "C-c i" acdw/find-emacs-dotfiles)) 227 "C-c i" acdw/find-emacs-dotfiles
228 "C-x k" acdw/kill-a-buffer))
228 229
229;; Regular modes (`text-mode', `prog-mode', etc.) 230;; Regular modes (`text-mode', `prog-mode', etc.)
230(defun acdw/setup-regular-modes () 231(defun acdw/setup-regular-modes ()
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."
126 (directory-files-recursively 126 (directory-files-recursively
127 user-emacs-directory "\.el$")))) 127 user-emacs-directory "\.el$"))))
128 128
129(defun acdw/kill-a-buffer (&optional prefix)
130 "Kill a buffer based on the following rules:
131
132C-x k => Kill CURRENT buffer and window
133C-u C-x k => Kill OTHER buffer and window
134C-u C-u C-x k => Kill ALL OTHER buffers and windows
135
136Prompt only if there are unsaved changes."
137 (interactive "P")
138 (pcase (or (car prefix) 0)
139 (0 (kill-current-buffer)
140 (unless (one-window-p) (delete-window)))
141 (4 (other-window 1)
142 (kill-current-buffer)
143 (unless (one-window-p) (delete-window)))
144 (16 (mapc 'kill-buffer (delq (current-) (buffer-list)))
145 (delete-other-windows))))
146
129 147
130;; Make `C-z' more useful 148;; Make `C-z' more useful
131(defvar acdw/leader 149(defvar acdw/leader