I found a function, that will kill all buffers except the current buffer that's open.
(defun kill-other-buffers () "Kill all buffers but the current one. Doesn't mess with special buffers." (interactive) (when (y-or-n-p "Are you sure you want to kill all buffers but the current one? ") (seq-each #'kill-buffer (delete (current-buffer) (seq-filter #'buffer-file-name (buffer-list))))))
It works great. However, when I have two windows open with a different buffer in each window, I noticed it kills the visible buffer in the other window too, except for the buffer where the cursor currently in is.
I studied the manuals of Emacs, in order to detect the open buffers that are visible in all windows. But I found not one. So I'm wondering if anyone have a good suggestion for this?