On Sun, 04 Jun 2017 16:45:05 -0700 Antoine Levitt wrote: > Tested on git master, the bug is not present on 25. > > Recipe from emacs -Q: > > (setq dired-auto-revert-buffer t) > > open dired, open a folder, C-x b back to the previous dired buffer, open > the same folder again, see point jump back to the beginning of buffer. > > I'm not sure why, since dired-auto-revert-buffer just seems to call > revert-buffer, which does not jump point. I think I see why this happens. I assume when you opened "the same folder again" you pressed RET on the line in the Dired listing. That calls dired-find-file, which calls find-file, which first calls find-file-noselect (to see if it's a live buffer), which calls (via run-hook-with-args-until-success) dired-noselect, which calls (via dired-internal-noselect) revert-buffer (since dired-auto-revert-buffer is t), which calls dired-revert, which saves point (via dired-save-positions) but then erases the buffer and inserts it anew -- and this is the problem, because now continuing in find-file, it calls switch-to-buffer (since it's a live buffer that you're revisiting), which sets window-point by consulting window-prev-buffers. Prior to the invocation of erase-buffer, window-prev-buffers contained this entry for the buffer being reverted ("test" in my test case): (# # #) which shows window-point on the first file name in the Dired listing, but after erase-buffer it's now this: (# # #) Since dired-revert restored the saved point (232) but does not return it to the caller, switch-to-buffer does not have this information, but only what window-prev-buffers shows, which is now 1. So that's what it sets window-point to. One way to fix this is to make dired-restore-positions restore not only point but also window-point. The attached patch does this. Steve Berman