From a77a967299fb7fac4cff240aa9d63c5d799b89bd Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 12 Jun 2018 14:13:12 +0200 Subject: [PATCH] Fix elusive 'already at top-level' error I have hunted this bug on and off for nearly a year now. It would kill processes randomly, move the point suddenly, and quit the active minibuffer without warning. The only clue it'd leave behind is an announcement in the minibuffer: "Already at top-level". Thanks to @UndeadKernel for the last piece of the puzzle! Fixes #436 --- modules/ui/popup/autoload.el | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/modules/ui/popup/autoload.el b/modules/ui/popup/autoload.el index 0f87e9cf6..b1fc35021 100644 --- a/modules/ui/popup/autoload.el +++ b/modules/ui/popup/autoload.el @@ -90,17 +90,18 @@ 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 kill-buffer-hook))) - (cond ((eq ttl 0) - (kill-buffer buffer)) - ((get-buffer-window buffer) + (cond ((get-buffer-window buffer) (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" (let (confirm-kill-processes) - (when-let* ((process (get-buffer-process (current-buffer)))) - (kill-process process))) - (kill-buffer buffer))))))) + (when-let* ((process (get-buffer-process buffer))) + (kill-process process)) + (let (kill-buffer-hook kill-buffer-query-functions) + (kill-buffer buffer))))))))) (defun +popup--init (window &optional alist) "Initializes a popup window. Run any time a popup is opened. It sets the