Don’t err in pip-frame-remove-buffer if there is no PIP frame

This is useful e.g. to prevent the error when a PIP frame with a
temporarily displayed buffer is deleted before the buffer timer
attempts to remove the buffer.
This commit is contained in:
Milan Zamazal 2022-08-02 21:14:04 +02:00
parent e8b16420f8
commit 8c396a11f5

View File

@ -175,14 +175,15 @@ If the buffer is not present in the PIP frame, do nothing."
(interactive (list (completing-read "Remove PIP buffer: " (interactive (list (completing-read "Remove PIP buffer: "
(mapcar #'buffer-name (pip-frame--buffers)) (mapcar #'buffer-name (pip-frame--buffers))
nil t))) nil t)))
(let* ((windows (window-list (pip-frame--get-frame))) (if-let ((frame (pip-frame--get-frame t))
(buffer (get-buffer buffer-or-name)) (windows (window-list frame))
(windows-to-delete (cl-remove buffer windows (buffer (get-buffer buffer-or-name))
:key #'window-buffer (windows-to-delete (cl-remove buffer windows
:test-not #'eq))) :key #'window-buffer
(if (= (length windows-to-delete) (length windows)) :test-not #'eq)))
(pip-frame-delete-frame) (if (= (length windows-to-delete) (length windows))
(seq-do #'delete-window windows-to-delete)))) (pip-frame-delete-frame)
(seq-do #'delete-window windows-to-delete))))
(defun pip-frame--move (x y) (defun pip-frame--move (x y)
(let ((frame (pip-frame--get-frame))) (let ((frame (pip-frame--get-frame)))