M-x ibuffer
- Select a buffer
- Kill that buffer
After the buffer is killed, the ibuffer buffer re-appears, but it still shows the buffer name killed in step 3.
Is it possible to have ibuffer auto-refresh the list of buffers?
M-x ibuffer
After the buffer is killed, the ibuffer buffer re-appears, but it still shows the buffer name killed in step 3.
Is it possible to have ibuffer auto-refresh the list of buffers?
Running the command ibuffer-auto-mode
in an Ibuffer buffer makes it refresh the display after each interactive command.
There doesn't appear to be a direct way of activating it automatically. You can put this in your init file:
(add-hook 'ibuffer-mode-hook (lambda () (ibuffer-auto-mode 1)))
The right way to do it is to introduce support in ibuffer
for auto-revert-mode
. This can be achieved by defining buffer-stale-function
for those those buffers.
Arguably, since buffer-menu
supports that feature, it'd be good to have it upstream for ibuffer
too, but that doesn't seem to be the case for now.
Anyway, here's a way to do it:
(defun my-ibuffer-stale-p (&optional noconfirm)
;; let's reuse the variable that's used for 'ibuffer-auto-mode
(frame-or-buffer-changed-p 'ibuffer-auto-buffers-changed))
(defun my-ibuffer-auto-revert-setup ()
(set (make-local-variable 'buffer-stale-function)
'my-ibuffer-stale-p)
(set (make-local-variable 'auto-revert-verbose) nil)
(auto-revert-mode 1))
(add-hook 'ibuffer-mode-hook 'my-ibuffer-auto-revert-setup)
Note: in general, one would need to define a value for revert-buffer-function
, but ibuffer
already does that (it's set to ibuffer-update
)