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?
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.
Sign up to join this communityM-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)))
ibuffer
, the selection is lost.
Jun 23, 2017 at 18:10
(setq ibuffer-mode-hook '(ibuffer-auto-mode))
should also do the trick if there's nothing else being done.
ibuffer-auto-mode
shows up a lot on my profiler (windows) so I ended up disabling it.
Apr 22, 2021 at 16:45
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
)
auto-revert-mode
uses timers, and ibuffer-auto-mode
uses post-command-hook
, so there's an obvious difference; but offhand I couldn't say if one was preferable to the other.
ibuffer
buffers behave like others when it comes to refreshing outdated content feels cleaner to me. Also, I generally dislike abusing post-command-hook
that way: it's really overkill when you happen to do something completely unrelated in the buffer. Finally, if some kind of keystroke is required for content to be refreshed, it might as well be g
, which is the explicit way of updating content. But granted, it's probably a philosophical issue :)
Reverting buffer `*Ibuffer*'.
The message is intrusive because it keeps interrupting me when I am working in the minibuffer. The message appears whether the ibuffer
buffer is visible or not.