From 66e440458db37f91903ce8d0c19867f010f7a1a2 Mon Sep 17 00:00:00 2001 From: JSDurand Date: Sat, 16 Jan 2021 02:14:59 +0800 Subject: 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. --- basic.el | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) 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) -- cgit v1.2.3-18-g5258