feature/popup: refactor popup cleanup function

This commit is contained in:
Henrik Lissner 2018-02-18 22:59:38 -05:00
parent e3d454d855
commit 3d20763d58
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -14,17 +14,17 @@
"Tries to kill BUFFER, as was requested by a transient timer. If it fails, eg. "Tries to kill BUFFER, as was requested by a transient timer. If it fails, eg.
the buffer is visible, then set another timer and try again later." the buffer is visible, then set another timer and try again later."
(when (buffer-live-p buffer) (when (buffer-live-p buffer)
(let ((kill-buffer-hook (delq '+popup|kill-buffer-hook kill-buffer-hook))) (let ((kill-buffer-hook (remq '+popup|kill-buffer-hook kill-buffer-hook)))
(cond ((eq ttl 0) (cond ((eq ttl 0)
(kill-buffer buffer)) (kill-buffer buffer))
((get-buffer-window buffer) ((get-buffer-window buffer)
(with-current-buffer buffer (with-current-buffer buffer
(setq +popup--timer (setq +popup--timer
(run-at-time ttl nil #'+popup--kill-buffer buffer ttl)))) (run-at-time ttl nil #'+popup--kill-buffer buffer ttl))))
(t ((with-demoted-errors "Error killing transient buffer: %s"
(with-demoted-errors "Error killing transient buffer: %s" (let (confirm-kill-processes)
(when-let* ((process (get-buffer-process (current-buffer)))) (when-let* ((process (get-buffer-process (current-buffer))))
(kill-process process)) (kill-process process)))
(kill-buffer buffer))))))) (kill-buffer buffer)))))))
(defun +popup--init (window &optional alist) (defun +popup--init (window &optional alist)