(defun dired-find-file ()
"In Dired, visit the file or directory named on this line."
(interactive)
+ (dired--find-file #'find-file (dired-get-file-for-visit)))
+
+(defun dired--find-file (find-file-function file)
+ "Call FIND-FILE-FUNCTION on FILE, but bind some relevant variables."
;; 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)
(if dired-auto-revert-buffer
nil
switch-to-buffer-preserve-window-point)))
- (find-file (dired-get-file-for-visit))))
+ (funcall find-file-function file)))
(defun dired-find-alternate-file ()
"In Dired, visit file or directory on current line via `find-alternate-file'.
(select-window window)
(funcall find-dir-func file)))
(select-window window)
- (funcall find-file-func (file-name-sans-versions file t)))))
+ (dired--find-file find-file-func (file-name-sans-versions file t)))))
(defun dired-mouse-find-file-other-window (event)
"In Dired, visit the file or directory name you click on in another window."
(defun dired-find-file-other-window ()
"In Dired, visit this file or directory in another window."
(interactive)
- (find-file-other-window (dired-get-file-for-visit)))
+ (dired--find-file #'find-file-other-window (dired-get-file-for-visit)))
(defun dired-display-file ()
"In Dired, display this file or directory in another window."