diff --git a/modules/ui/popup/autoload/popup.el b/modules/ui/popup/autoload/popup.el index 63300a122..ff732a24b 100644 --- a/modules/ui/popup/autoload/popup.el +++ b/modules/ui/popup/autoload/popup.el @@ -97,12 +97,6 @@ and enables `+popup-buffer-mode'." (defun +popup--normalize-alist (alist) "Merge `+popup-default-alist' and `+popup-default-parameters' with ALIST." (when alist - ;; In case ALIST is window state (from `window-state-get'), we map its - ;; entries to display-buffer alist parameters. - (dolist (prop +popup-window-state-alist) - (when-let* ((val (assq (car prop) alist))) - (setf (alist-get (cdr prop) alist) (cdr val)) - (setq alist (delq val alist)))) (let ((alist ; handle defaults (cl-remove-duplicates (append alist +popup-default-alist) @@ -119,9 +113,9 @@ and enables `+popup-buffer-mode'." 'window-width 'window-height))) (setq list (assq-delete-all 'size alist)) - (setcdr (assq param alist) size)) - (setcdr (assq 'window-parameters alist) - parameters) + (setf (alist-get param alist) size)) + (setf (alist-get 'window-parameters alist) + parameters) alist))) @@ -197,6 +191,15 @@ Uses `shrink-window-if-larger-than-buffer'." (unless (= (- (point-max) (point-min)) 0) (shrink-window-if-larger-than-buffer window))) +;;;###autoload +(defun +popup-alist-from-window-state (state) + "Convert window STATE (from `window-state-get') to a `display-buffer' alist." + (let* ((params (alist-get 'parameters state))) + `((side . ,(alist-get 'window-side params)) + (window-width . ,(alist-get 'total-width state)) + (window-height . ,(alist-get 'total-height state)) + (window-parameters ,@params)))) + ;; ;; Hooks @@ -366,7 +369,7 @@ the message buffer in a popup window." (error "No popups to restore")) (cl-loop for (buffer . state) in +popup--last if (buffer-live-p buffer) - do (+popup-buffer buffer state)) + do (+popup-buffer buffer (+popup-alist-from-window-state state))) (setq +popup--last nil) t) diff --git a/modules/ui/popup/config.el b/modules/ui/popup/config.el index d24fd8378..3f7e8382b 100644 --- a/modules/ui/popup/config.el +++ b/modules/ui/popup/config.el @@ -20,13 +20,6 @@ Modifying this has no effect, unless done before ui/popup loads.") (no-other-window . t)) "The default window parameters.") -(defvar +popup-window-state-alist - '((total-width . window-width) - (total-height . window-height) - (parameters . window-parameters)) - "An alist mapping `window-state-get' entries to display-buffer alist entries. -Used by `+popup--normalize-alist'.") - (defvar +popup-margin-width 1 "Size of the margins to give popup windows. Set this to nil to disable margin adjustment.")