Popup library: minor refactor & appease byte-compiler

This commit is contained in:
Henrik Lissner 2017-10-05 02:11:04 +02:00
parent f1d5c3d3db
commit eefcf7803f
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -42,12 +42,21 @@ this popup, just the specified properties. Returns the new popup window."
;;;###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)))))
(size (+ 2 (if (floatp max-size) (truncate (* max-size window-size)) window-size))))
(fit-window-to-buffer window size nil size))))
;;;###autoload
(defun doom-popup-move (direction)
"Move a popup window to another side of the frame, in DIRECTION, which can be
one of the following: 'left 'right 'above 'below"
(when (doom-popup-p)
(let ((buffer (current-buffer))
(doom-popup-inhibit-autokill t))
(doom/popup-close)
(doom-popup-buffer buffer `(:align ,direction) 'extend))))
;;;###autoload
(defun doom-popup-file (file &optional plist extend-p)
@ -275,16 +284,6 @@ without leaving any trace behind (muahaha)."
(with-selected-window window
(doom-popup-mode -1))))
;;;###autoload
(defun doom-popup-move (direction)
"Move a popup window to another side of the frame, in DIRECTION, which can be
one of the following: 'left 'right 'above 'below"
(when (doom-popup-p)
(let ((buffer (current-buffer))
(doom-popup-inhibit-autokill t))
(doom/popup-close)
(doom-popup-buffer buffer `(:align ,direction) 'extend))))
;;;###autoload
(defun doom/popup-move-top () "See `doom-popup-move'." (interactive) (doom-popup-move 'above))
;;;###autoload