Subject: Re: bug#57385: 28.1.91; project-find-regexp fails over tramp

From: Dmitry Gutov <[email-masked]>
Date: Sat, 27 Aug 2022 01:12:37 +0300

On 26.08.2022 18:08, Michael Albinus wrote:
> Dmitry Gutov <[email-masked]> writes:
> 
> Hi Dmitry,
> 
>>> Dmitry, I tested project-find-regexp over Tramp with a "mundane"
>>> system
>>> and it failed regardless.  It seems I figured out why.  Shell-file-name
>>> (in xref-matches-in-files) seems to get its value from the local
>>> machine, not from the remote one.  Therefore, it can't possibly start
>>> the grep process remotely.  Any on how to fix this?
>>
>> Right.
>>
>> Michael, do you perhaps have a suggestion how xref-matches-in-files
>> could use connection-local values for shell-file-name and
>> shell-command-switch (when available) without losing compatibility
>> with Emacs 26.1?
> 
> Hmm, the usual recommendation is to take
> with-connection-local-variables, like
> 
> (with-connection-local-variables
>    (xref--process-file-region (point-min)
>                               (point-max)
>                               shell-file-name
>                               output
>                               nil
>                               shell-command-switch
>                               command))
> 
> Unfortunately, the macro exists since Emacs 27 only, so you need to test
> its availablility, and to use progn instead if it doesn't exist.

OK, I have just pushed a fix in commit 6edff5ac33 which will hopefully 
fit the requirements.

Andre, please test.

> There is another trap, Tramp sets already the connection-local variable
> shell-file-name to "/bin/sh". The user must overwrite this (or Tramp
> must be pimped up to take whatever the user declares as "remote-shell").

Perhaps that's the value which is needed in this particular scenario? 
E.g., no bash installed on that system.