diff options
author | JSDurand <mmemmew@gmail.com> | 2024-02-24 23:00:04 +0800 |
---|---|---|
committer | JSDurand <mmemmew@gmail.com> | 2024-02-24 23:00:04 +0800 |
commit | 40c757436da69d4e1babb1b618175a02ecc237ca (patch) | |
tree | 0c9bf22deec361e3eb53a6dd02c6aef438ffdd33 | |
parent | 00a6d1188f54929ebdd9a9fffb694942ec934a6f (diff) |
basic: Move pdf cleanups to `kill-buffer-hook`
* basic.el (durand-kill-current-buffer): This function used to perform
some clean-ups of the timers set by `pdf-view-mode` that were not
cleaned properly by the mode itself. Now this function does not
perform these cleanups, as this is not the right place for that
task.
(kill-buffer-hook): This hook is designed to perform some clean-ups,
so the pdf-timer-clean-ups are moved to this hook now.
-rw-r--r-- | basic.el | 25 |
1 files changed, 15 insertions, 10 deletions
@@ -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. |