"Leave only (1) this buffer from all the indirect ones sharing the same base and (2) the base buffer itself."
(defun my-kill-other-indirect-bufs ()
"Kill all indirect buffers other than the current buffer."
(dolist (buf (buffer-list))
(when (and (buffer-base-buffer buf) (not (eq (current-buffer) buf)))
If you use Icicles then the commands that provide completion for buffer names let you use
C-x i - and
C-x i + to remove and keep only, respectively, indirect buffers.
This is one of a set of on-the-fly filtering keys for buffer-name candidates. You can add to or remove from this set by customizing option
For example, you could add a key that filters to show only indirect buffers other than the current one, and then you could use multi-command
icicle-kill-buffer (bound to
C-x k in Icicle mode, by default) to kill all such buffers.
You would just add an entry such as this to
Key: C-x I
my-remove-buffer-cands-for-other-indirect would be, e.g.:
(defun my-remove-buffer-cands-for-other-indirect ()
"Remove buffer-name candidates for indirect buffers except current."
(lambda (buf) (or (eq (current-buffer) (get-buffer buf))
(not (buffer-base-buffer (get-buffer buf))))))
That filters buffer-name completion candidates to allow only the current buffer and non-indirect buffers.