From 4d862d77709f3f4c99fbe21ab89e47b78eda4476 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 28 Jul 2021 15:16:20 -0400 Subject: [PATCH] fix(popup): org-edit-src breaks if forcibly killed Invoke org-edit-src and an edit buffer is displayed for the src block at point. If that popup is killed incorrectly, it leaves the original org buffer (specifically, the src block you were editing) in a half-broken state; forever waiting for you to finish editing that block. This can happen when the edit window is a popup window and you switch workspaces (which temporarily deletes popup windows), so clean up those popups properly before switching. --- modules/ui/popup/+hacks.el | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/modules/ui/popup/+hacks.el b/modules/ui/popup/+hacks.el index 2052236cd..5e6f02b02 100644 --- a/modules/ui/popup/+hacks.el +++ b/modules/ui/popup/+hacks.el @@ -303,6 +303,15 @@ Ugh, such an ugly hack." (apply orig-fn args)) (apply orig-fn args))) + (defadvice! +popup--org-edit-src-exit-a (orig-fn &rest args) + "If you switch workspaces or the src window is recreated..." + :around #'org-edit-src-exit + (let* ((window (selected-window)) + (popup-p (+popup-window-p window))) + (prog1 (apply orig-fn args) + (when (and popup-p (window-live-p window)) + (delete-window window))))) + ;; Ensure todo, agenda, and other minor popups are delegated to the popup system. (defadvice! +popup--org-pop-to-buffer-a (orig-fn buf &optional norecord) "Use `pop-to-buffer' instead of `switch-to-buffer' to open buffer.'"