From: Eli Zaretskii Date: Sat, 10 Jun 2017 08:22:50 +0000 (+0300) Subject: Preserve point in Dired windows under 'dired-auto-revert-buffer' X-Git-Tag: emacs-26.0.90~521^2~139 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=6b4b13eb3868e861df8e52e491214376134baf63;p=emacs.git Preserve point in Dired windows under 'dired-auto-revert-buffer' * lisp/dired.el (dired-find-file): When dired-auto-revert-buffer is non-nil, bind switch-to-buffer-preserve-window-point to nil while calling find-file. (Bug#27243) --- diff --git a/lisp/dired.el b/lisp/dired.el index 8396652d50b..909735a3b54 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -2126,7 +2126,16 @@ directory in another window." (interactive) ;; Bind `find-file-run-dired' so that the command works on directories ;; too, independent of the user's setting. - (let ((find-file-run-dired t)) + (let ((find-file-run-dired t) + ;; This binding prevents problems with preserving point in + ;; windows displaying Dired buffers, because reverting a Dired + ;; buffer empties it, which changes the places where the + ;; markers used by switch-to-buffer-preserve-window-point + ;; point. + (switch-to-buffer-preserve-window-point + (if dired-auto-revert-buffer + nil + switch-to-buffer-preserve-window-point))) (find-file (dired-get-file-for-visit)))) (defun dired-find-alternate-file ()