Dale Sedivec writes: Hi Dale, Thanks for the report. > Lately, while in the process of using Magit, I've frequently gotten > "Selecting deleting buffer" errors. > > I have global-auto-revert-mode on. I *suspect* this happens because > *something* kills a buffer between when auto-revert-buffers collects > the list of buffers with (buffer-list) and when auto-revert-buffers > starts its final traversal of buffers in bufs (which starts out as > (buffer-list) in global-auto-revert-mode). > > Around line 795 inside auto-revert-buffers, the code is: > > (with-current-buffer buf > (if (buffer-live-p buf) > ... > ;; Remove dead buffer from `auto-revert-buffer-list'. > (auto-revert-remove-current-buffer))) > > It seems like reversing this so that with-current-buffer is only > called after buffer-live-p is checked might be a good solution to > avoid trying to select a deleted buffer? Something like this. But the final `auto-revert-remove-current-buffer' needs the buffer to be removed as the current one. So it is a bit more complex. I came up with the following patch: