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 83262b7..e8ec188 100644 --- a/init.el +++ b/init.el | |||
@@ -238,7 +238,8 @@ | |||
238 | "M-/" hippie-expand | 238 | "M-/" hippie-expand |
239 | "M-=" count-words | 239 | "M-=" count-words |
240 | "C-x C-b" ibuffer | 240 | "C-x C-b" ibuffer |
241 | "C-c i" acdw/find-emacs-dotfiles)) | 241 | "C-c i" acdw/find-emacs-dotfiles |
242 | "C-x k" acdw/kill-a-buffer)) | ||
242 | 243 | ||
243 | ;; Regular modes (`text-mode', `prog-mode', etc.) | 244 | ;; Regular modes (`text-mode', `prog-mode', etc.) |
244 | (defun acdw/setup-regular-modes () | 245 | (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 |