ui/popup: prevent infinite loop when killing popup buffers
This commit is contained in:
parent
d0188b827a
commit
6ac04e5a6d
1 changed files with 19 additions and 18 deletions
|
@ -13,18 +13,13 @@
|
|||
(defun +popup--kill-buffer (buffer ttl)
|
||||
"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."
|
||||
(when (buffer-live-p buffer)
|
||||
(let ((inhibit-quit t)
|
||||
(kill-buffer-hook (remq '+popup-kill-buffer-hook-h kill-buffer-hook)))
|
||||
(cond ((get-buffer-window buffer t)
|
||||
(let ((inhibit-quit t))
|
||||
(cond ((not (buffer-live-p buffer)))
|
||||
((not (get-buffer-window buffer t))
|
||||
(with-demoted-errors "Error killing transient buffer: %s"
|
||||
(with-current-buffer buffer
|
||||
(setq +popup--timer
|
||||
(run-at-time ttl nil #'+popup--kill-buffer buffer ttl))))
|
||||
((eq ttl 0)
|
||||
(kill-buffer buffer))
|
||||
((with-demoted-errors "Error killing transient buffer: %s"
|
||||
(with-current-buffer buffer
|
||||
(let (confirm-kill-processes)
|
||||
(let ((kill-buffer-hook (remq '+popup-kill-buffer-hook-h kill-buffer-hook))
|
||||
confirm-kill-processes)
|
||||
(when-let (process (get-buffer-process buffer))
|
||||
(kill-process process))
|
||||
(let (kill-buffer-query-functions)
|
||||
|
@ -32,7 +27,13 @@ the buffer is visible, then set another timer and try again later."
|
|||
;; `top-level'. This causes jumpiness when the popup
|
||||
;; manager tries to clean it up.
|
||||
(cl-letf (((symbol-function #'top-level) #'ignore))
|
||||
(kill-buffer buffer)))))))))))
|
||||
(kill-buffer buffer)))))))
|
||||
((let ((ttl (if (= ttl 0)
|
||||
(or (plist-get +popup-defaults :ttl) 3)
|
||||
ttl)))
|
||||
(with-current-buffer buffer
|
||||
(setq +popup--timer
|
||||
(run-at-time ttl nil #'+popup--kill-buffer buffer ttl))))))))
|
||||
|
||||
(defun +popup--delete-window (window)
|
||||
"Do housekeeping before destroying a popup window.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue