Extract popup fitting into doom-popup-fit-to-buffer
This commit is contained in:
parent
55f584646b
commit
5358488300
1 changed files with 12 additions and 6 deletions
|
@ -39,6 +39,16 @@ this popup, just the specified properties. Returns the new popup window."
|
||||||
(prog1 (selected-window)
|
(prog1 (selected-window)
|
||||||
(set-window-dedicated-p nil t)))
|
(set-window-dedicated-p nil t)))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun doom-popup-fit-to-buffer (&optional window max-size)
|
||||||
|
"Fit WINDOW to the size of its content."
|
||||||
|
(let ((plist (doom-popup-properties window)))
|
||||||
|
(unless (string-empty-p (buffer-string))
|
||||||
|
(let* ((window-size (doom-popup-size window))
|
||||||
|
(max-size (or max-size (doom-popup-property :size window)))
|
||||||
|
(size (if (floatp max-size) (truncate (* max-size window-size)) window-size)))
|
||||||
|
(fit-window-to-buffer window size nil size)))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun doom-popup-file (file &optional plist extend-p)
|
(defun doom-popup-file (file &optional plist extend-p)
|
||||||
"Display FILE in a shackle popup, with PLIST rules. See `shackle-rules' for
|
"Display FILE in a shackle popup, with PLIST rules. See `shackle-rules' for
|
||||||
|
@ -386,12 +396,8 @@ and setting `doom-popup-rules' within it. Returns the window."
|
||||||
(unless (eq plist t)
|
(unless (eq plist t)
|
||||||
(setq-local doom-popup-rules plist))
|
(setq-local doom-popup-rules plist))
|
||||||
(doom-popup-mode +1)
|
(doom-popup-mode +1)
|
||||||
(when (and (plist-get plist :autofit)
|
(when (plist-get plist :autofit)
|
||||||
(not (string-empty-p (buffer-string))))
|
(doom-popup-fit-to-buffer window)))
|
||||||
(let* ((window-size (doom-popup-size window))
|
|
||||||
(max-size (or (plist-get plist :size) shackle-default-size))
|
|
||||||
(size (if (floatp max-size) (truncate (* max-size window-size)) window-size)))
|
|
||||||
(fit-window-to-buffer window size nil size))))
|
|
||||||
window))
|
window))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue