From 8c61f7ef2c0810837fcb4a4dbd2cc21ea61760e4 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Sun, 18 Aug 2024 14:35:04 +0000 Subject: [PATCH] Transfer surrogate minibuffers to the next workspace on delete (#74) Othewise, we won't be able to delete the frame (frames with surrogate minibuffers cannot be deleted). * exwm-workspace.el (exwm-workspace-delete): Transfer surrogate minibuffers to the next workspace before attempting to delete a workspace (part of #64). (exwm-workspace--prompt-delete): Use `exwm-workspace-delete' instead of directly calling `delete-frame'. --- exwm-workspace.el | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/exwm-workspace.el b/exwm-workspace.el index 9337dc0..c86051c 100644 --- a/exwm-workspace.el +++ b/exwm-workspace.el @@ -258,9 +258,9 @@ Show PROMPT to the user if non-nil." (if (eq frame exwm-workspace--current) ;; Abort the recursive minibuffer if deleting the current workspace. (progn - (exwm--defer 0 #'delete-frame frame) + (exwm--defer 0 #'exwm-workspace-delete frame) (abort-recursive-edit)) - (delete-frame frame) + (exwm-workspace-delete frame) (exwm-workspace--update-switch-history) (goto-history-element (min minibuffer-history-position (exwm-workspace--count))))))) @@ -824,6 +824,11 @@ INDEX must not exceed the current number of workspaces." (exwm-workspace--workspace-from-frame-or-index frame-or-index) exwm-workspace--current))) + ;; Transfer over any surrogate minibuffers before trying to delete the workspace. + (let ((minibuf (minibuffer-window frame)) + (newminibuf (minibuffer-window (exwm-workspace--get-next-workspace frame)))) + (dolist (f (filtered-frame-list (lambda (f) (eq (frame-parameter f 'minibuffer) minibuf)))) + (set-frame-parameter f 'minibuffer newminibuf))) (delete-frame frame)))) (defun exwm-workspace--set-desktop (id)