Refactor doom-popup-p

This commit is contained in:
Henrik Lissner 2017-09-24 20:42:30 +02:00
parent 558a8d973c
commit e6f892b115
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -4,16 +4,15 @@
;;;###autoload ;;;###autoload
(defun doom-popup-p (&optional target) (defun doom-popup-p (&optional target)
"Return TARGET (a window) if TARGET (a window or buffer) is a popup. Uses "Return t if TARGET (a window or buffer) is a popup. Uses current window if
current window if omitted." omitted."
(when-let (target (or target (selected-window))) (when-let (target (or target (selected-window)))
(cond ((bufferp target) (cond ((bufferp target)
(and (buffer-live-p target) (and (buffer-local-value 'doom-popup-mode target)
(buffer-local-value 'doom-popup-mode target))) (not (plist-get (buffer-local-value 'doom-popup-rules target) :fixed))))
((windowp target) ((windowp target)
(and (window-live-p target) (and (window-parameter target 'popup)
(window-parameter target 'popup) (not (doom-popup-property :fixed target)))))))
target)))))
;;;###autoload ;;;###autoload
(defun doom-popup-buffer (buffer plist &optional extend-p) (defun doom-popup-buffer (buffer plist &optional extend-p)
@ -103,8 +102,8 @@ Returns t if popups were restored, nil otherwise."
`selected-window'. The contained buffer is buried, unless it has an :autokill `selected-window'. The contained buffer is buried, unless it has an :autokill
property." property."
(interactive) (interactive)
(when-let (window (doom-popup-p window)) (when (doom-popup-p window)
(delete-window window))) (delete-window (or window (selected-window)))))
;;;###autoload ;;;###autoload
(defun doom/popup-close-all (&optional force-p) (defun doom/popup-close-all (&optional force-p)