diff options
-rw-r--r-- | init.el | 3 | ||||
-rw-r--r-- | lisp/acdw.el | 18 |
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 | |||
132 | C-x k => Kill CURRENT buffer and window | ||
133 | C-u C-x k => Kill OTHER buffer and window | ||
134 | C-u C-u C-x k => Kill ALL OTHER buffers and windows | ||
135 | |||
136 | Prompt 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 |