Subject: Re: bug#34343: [PATCH] Make project--find-regexp-in-files work with remote files

From: Michael Albinus <[email-masked]>
Date: Fri, 27 Dec 2019 18:57:31 +0100

Dmitry Gutov <[email-masked]> writes:

Hi Dmitry,

>> The patch looks reasonable to me. Since I don't use project-files, I
>> can't say whether this works correctly.
>
> Unless it's a religious position, you can test it with:
>
>   M-x project-find-regexp
>
> or
>
>   M-x dired-do-find-regexp (also bound to 'A' in Dired)
>
> (the latter since one of my yesterday's commits).

No religious barrier here :-)

> For now, I've done some testing myself. It prepended 'remote-id'
> twice, now fixed.

I've tested with the emacs-27 branch, and it seems to work.

> Things I've noticed:
>
> - (mapcar #'file-local-name files) takes like ~2 seconds when FILES
>   only has ~3000 elements. The same code completes instantly on a
>  local machine. Shouldn't it be the same?

file-local-name uses internally file-remote-p, which calls
expand-file-name if the connection is already established. Not needed in
case of local names.

Could you pls test the appended patch, whether it improves performance?

Best regards, Michael.

diff --git a/lisp/tramp.el b/lisp/tramp.el
index 0dbbfa59..a25b2715 100644
--- a/lisp/tramp.el
+++ b/lisp/tramp.el
 ;; This file is part of GNU Emacs.
@@ -3361,10 +3361,12 @@ User is always nil."
       (let* ((v (tramp-dissect-file-name filename))
 	     (p (tramp-get-connection-process v))
 	     (c (and (process-live-p p)
-		     (tramp-get-connection-property p "connected" nil))))
-	;; We expand the file name only, if there is already a connection.
+		     (tramp-get-connection-property p "connected" nil)))
+	     (e (and c (not (eq identification 'localname)))))
+	;; We expand the file name only, if there is already a
+	;; connection, and IDENTIFICATION is not `localname'.
 	(with-parsed-tramp-file-name
-	    (if c (expand-file-name filename) filename) nil
+	    (if e (expand-file-name filename) filename) nil
 	  (and (or (not connected) c)
 	       (cond
 		((eq identification 'method) method)