Jika saya mengerti pertanyaannya, inilah fungsi yang melakukan apa yang Anda inginkan:
(defun maybe-delete-frame-buffer (frame)
"When a dedicated FRAME is deleted, also kill its buffer.
A dedicated frame contains a single window whose buffer is not
displayed anywhere else."
(let ((windows (window-list frame)))
(when (eq 1 (length windows))
(let ((buffer (window-buffer (car windows))))
(when (eq 1 (length (get-buffer-window-list buffer nil t)))
(kill-buffer buffer))))))
Anda dapat menambahkannya sebagai pengait yang dipanggil setiap kali bingkai ditutup menggunakan:
(add-to-list 'delete-frame-functions #'maybe-delete-frame-buffer)