From 5b11ac7267b9976e80c4e2f46ad718375e8af63e Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 31 Mar 2025 17:25:44 -0400 Subject: [PATCH] feat(popup): +popup/raise: use visible popup if none selected This command would formerly raise the focused window into a regular window, erroring out if that window isn't a popup. Now, if the focused window isn't a popup, any (single) visible popup in the current frame will be targeted, and if multiple popups are visible, you'll be prompted to select one. --- modules/ui/popup/autoload/popup.el | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/modules/ui/popup/autoload/popup.el b/modules/ui/popup/autoload/popup.el index c4aa72280..278255630 100644 --- a/modules/ui/popup/autoload/popup.el +++ b/modules/ui/popup/autoload/popup.el @@ -428,15 +428,34 @@ If no popups are available, display the *Messages* buffer in a popup window." ;;;###autoload (defun +popup/raise (window &optional arg) - "Raise the current popup window into a regular window and -return it. If prefix ARG, raise the current popup into a new -window and return that window." + "Raise a popup WINDOW into a regular window, then select it. + +When called interactively, the selected popup window will be raised. If the +selected window isn't a popup, any sole, visible popup window in the active +frame will be raised. If there are multiple visible popups, then the user will +be prompted to select one. + +If prefix ARG, the popup is raised into `other-window' instead." (interactive - (list (selected-window) current-prefix-arg)) + (list + (let ((win (selected-window))) + (if (+popup-window-p win) + win + (if-let* ((popups + (cl-loop for w in (+popup-windows) + collect (cons (buffer-name (window-buffer w)) w)))) + (if (cdr popups) + (or (cdr (assoc (completing-read + "Select window: " (mapcar #'car popups)) + popups)) + (user-error "Aborted")) + (cdar popups)) + (user-error "No popup windows to raise")))) + current-prefix-arg)) (cl-check-type window window) (unless (+popup-window-p window) (user-error "Cannot raise a non-popup window")) - (let ((buffer (current-buffer)) + (let ((buffer (window-buffer window)) (+popup--inhibit-transient t) +popup--remember-last) (+popup/close window 'force)