Subject: 25.0.92; dired-goto-file in `find-dired' buffers

From: Tino Calancha <[email-masked]>
Date: Tue, 22 Mar 2016 20:22:51 +0900 (JST)

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.

In GNU Emacs 25.0.92.1 (x86_64-pc-linux-gnu, GTK+ Version 2.24.30)
  of 2016-03-22 built on calancha-pc
Repository revision: dbfbedd3d0f3afcfb811eae0e1a7b1c33fb27735

diff --git a/lisp/dired.el b/lisp/dired.el
index 24b128f..3c66a8e 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -2746,7 +2746,20 @@ dired-goto-file
 				(dired-goto-subdir dir)))
 		     (dired-goto-file-1 (file-name-nondirectory file)
 					file
-					(dired-subdir-max)))))))
+					(dired-subdir-max))))
+		 ;; Handle Dired buffers from `find-dired' commands.  The
+		 ;; filename includes '/' if the file belongs to a subdir
+		 ;; of `default-directory'.
+		 (save-excursion
+		   (let ((name-len   (length file))
+				 (defdir-len (length (expand-file-name default-directory))))
+			 (goto-char (point-min))
+			 (and (not (cdr dired-subdir-alist))
+				  (> name-len defdir-len)
+				  (dired-goto-file-1 (substring file defdir-len)
+									 file
+									 (point-max))))))))
+
     ;; Return buffer position, if found.
     (if found
 	(goto-char found))))