Subject: Re: bug#23089: 25.0.92; dired-goto-file in `find-dired' buffers

From: Eli Zaretskii <[email-masked]>
Date: Fri, 25 Mar 2016 11:39:15 +0300

> Date: Tue, 22 Mar 2016 20:22:51 +0900 (JST)
> From: Tino Calancha <[email-masked]>
> 
> Dired buffers output from `find-dired' commands, usually contains
> filename including '/'.  Command `dired-goto-file' fails
> on those files.
> 
> ; emacs-lisp: 
> emacs -Q $emacs-lisp
> M-x find-name-dired RET *.el RET
> j language/thai-word.el RET
> 
> ;It cannot find the file.

Thanks for the report and the patch.  Does the alternative patch below
look correct, and does it give good results?

diff --git a/lisp/dired.el b/lisp/dired.el
index ef22d45..5741872 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -2736,9 +2736,18 @@ dired-goto-file
 		 (save-excursion
 		   (goto-char (point-min))
 		   (dired-goto-file-1 file file (point-max)))
-		 ;; Otherwise, look for it as a relative name.  The
-		 ;; hair is to get the result of `dired-goto-subdir'
-		 ;; without calling it if we don't have any subdirs.
+                 ;; Next, look for it as a relative name with leading
+                 ;; subdirectories.  (This happens in Dired buffers
+                 ;; created by find-dired, for example.)
+                 (save-excursion
+                   (goto-char (point-min))
+                   (dired-goto-file-1 (file-relative-name file
+                                                          default-directory)
+                                      file (point-max)))
+		 ;; Otherwise, look for it as a relative name, a base
+		 ;; name only.  The hair is to get the result of
+		 ;; `dired-goto-subdir' without calling it if we don't
+		 ;; have any subdirs.
 		 (save-excursion
 		   (when (if (string= dir (expand-file-name default-directory))
 			     (goto-char (point-min))