]> git.eshelyaron.com Git - emacs.git/commitdiff
Preserve point in Dired windows under 'dired-auto-revert-buffer'
authorEli Zaretskii <eliz@gnu.org>
Sat, 10 Jun 2017 08:22:50 +0000 (11:22 +0300)
committerEli Zaretskii <eliz@gnu.org>
Sat, 10 Jun 2017 08:22:50 +0000 (11:22 +0300)
* 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)

lisp/dired.el

index 8396652d50b2e50b40d1084243524c0b9172195c..909735a3b54e3dbde926b8972651a5af63ad5459 100644 (file)
@@ -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 ()