summaryrefslogtreecommitdiff
path: root/basic.el
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2021-01-16 02:14:59 +0800
committerJSDurand <mmemmew@gmail.com>2021-01-16 02:14:59 +0800
commit66e440458db37f91903ce8d0c19867f010f7a1a2 (patch)
tree2b1da596b9a3db99d82cd644a1bf0ed2e73b52ed /basic.el
parent3a91e9674feeace4ce7acebdb024e93c95c89308 (diff)
My customized kill-buffer behaviour
This can facilitate killing both the buffer and its window, when there are multiple windows. It is bound to s-k now, which was bound to `kill-current-buffer' by default.
Diffstat (limited to 'basic.el')
-rw-r--r--basic.el20
1 files changed, 20 insertions, 0 deletions
diff --git a/basic.el b/basic.el
index 256052c..c8619d4 100644
--- a/basic.el
+++ b/basic.el
@@ -123,6 +123,26 @@
(display-buffer-at-bottom)
(window-height . 0.2))))
+;;; Custom kill buffer function
+
+;;;###autoload
+(defun durand-kill-current-buffer (&optional arg)
+ "Kill the current buffer.
+
+If the optional ARG is non-nil, and if there are more than one
+window, then also delete the selected window."
+ (interactive "P")
+ (cond
+ ((window-minibuffer-p (selected-window))
+ ;; this is the same as calling `abort-recursive-edit'.
+ (throw 'exit t))
+ (t (kill-buffer (current-buffer))))
+ (cond
+ ((and arg (not (one-window-p t)))
+ (delete-window (selected-window)))))
+
+(define-key global-map (vector ?\s-k) #'durand-kill-current-buffer)
+
;;; auto-fill for texts
(set 'adaptive-fill-mode t)