Preserve window state when toggling popups
e.g. size
This commit is contained in:
parent
d8fa5f39ad
commit
af045213e3
2 changed files with 15 additions and 3 deletions
|
@ -97,6 +97,12 @@ and enables `+popup-buffer-mode'."
|
||||||
(defun +popup--normalize-alist (alist)
|
(defun +popup--normalize-alist (alist)
|
||||||
"Merge `+popup-default-alist' and `+popup-default-parameters' with ALIST."
|
"Merge `+popup-default-alist' and `+popup-default-parameters' with ALIST."
|
||||||
(when 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
|
(let ((alist ; handle defaults
|
||||||
(cl-remove-duplicates
|
(cl-remove-duplicates
|
||||||
(append alist +popup-default-alist)
|
(append alist +popup-default-alist)
|
||||||
|
@ -359,9 +365,8 @@ the message buffer in a popup window."
|
||||||
(unless +popup--last
|
(unless +popup--last
|
||||||
(error "No popups to restore"))
|
(error "No popups to restore"))
|
||||||
(cl-loop for (buffer . state) in +popup--last
|
(cl-loop for (buffer . state) in +popup--last
|
||||||
if (and (buffer-live-p buffer)
|
if (buffer-live-p buffer)
|
||||||
(display-buffer buffer))
|
do (+popup-buffer buffer state))
|
||||||
do (window-state-put state it))
|
|
||||||
(setq +popup--last nil)
|
(setq +popup--last nil)
|
||||||
t)
|
t)
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,13 @@ Modifying this has no effect, unless done before ui/popup loads.")
|
||||||
(no-other-window . t))
|
(no-other-window . t))
|
||||||
"The default window parameters.")
|
"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
|
(defvar +popup-margin-width 1
|
||||||
"Size of the margins to give popup windows. Set this to nil to disable margin
|
"Size of the margins to give popup windows. Set this to nil to disable margin
|
||||||
adjustment.")
|
adjustment.")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue