Subject: Re: bug#79036: [PATCH] Fix pdb tracking for remote filenames

From: Eli Zaretskii <[email-masked]>
Date: Thu, 17 Jul 2025 17:30:41 +0300

> From: Liu Hui <[email-masked]>
> Date: Thu, 17 Jul 2025 21:30:01 +0800
> Cc: [email-masked], [email-masked], [email-masked]
> 
> On Thu, Jul 17, 2025 at 8:09 PM Eli Zaretskii <[email-masked]> wrote:
> >
> > My question was why cannot we simply call find-file-noselect
> > regardless of whether file-name is local or remote?  And why do we
> > need all those checks with explicit calls to get-file-buffer etc.?
> 
> I have provided an example:
> 
>     >>> from test import f; f()
>     > /tmp/test.py(3)f()
>     -> return 1
>     (Pdb)
> 
> Given above pdb output in the remote python shell, the file-name
> "/tmp/test.py" is local and find-file-noselect will simply open the
> local file. But the file is on the remote system.

Thanks, I see now.

So we need a function called, say, remote-file-name, which, when given
a file name, even an absolute one, will consider it to be on the
remote host indicated by default-directory, and will be equivalent to
expand-file-name if default-directory is a local one, is that right?

Michael, don't we already have such a function?

If we did have such a function, wouldn't it be enough to just call

   (find-file-noselect (remote-file-name file-name))

?  That is, we won't need to call get-file-buffer, nor file-exists-p,
right?  Or am I still missing something?