summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--basic.el25
1 files changed, 15 insertions, 10 deletions
diff --git a/basic.el b/basic.el
index 31ed1c0..03a075e 100644
--- a/basic.el
+++ b/basic.el
@@ -257,11 +257,21 @@ 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))
+ ((window-minibuffer-p (selected-window)) (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)
+
+;;; Custom kill-buffer-hook
+
+(defun durand-kill-buffer-hook ()
+ "Some cleanups that are run before killing buffers."
+ (cond
((derived-mode-p 'pdf-view-mode)
- ;; We also want to kill the associated timer, if any.
(mapc
(lambda (timer)
(cond
@@ -279,14 +289,9 @@ window, then also delete the selected window."
(listp (timer--args timer))
(memq (current-buffer) (timer--args timer)))
(setq timer-list (delq timer timer-list)))))
- timer-list)
- (kill-buffer (current-buffer)))
- (t (kill-buffer (current-buffer))))
- (cond
- ((and arg (not (one-window-p t)))
- (delete-window (selected-window)))))
+ timer-list))))
-(define-key global-map (vector ?\s-k) #'durand-kill-current-buffer)
+(add-hook 'kill-buffer-hook #'durand-kill-buffer-hook)
;;; zap-up-to-char and zap-to-char are both useful.