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

From: Eli Zaretskii <[email-masked]>
Date: Thu, 17 Jul 2025 18:45:22 +0300

> From: Michael Albinus <[email-masked]>
> Cc: [email-masked],  [email-masked],  [email-masked]
> Date: Thu, 17 Jul 2025 17:09:13 +0200
> 
> Eli Zaretskii <[email-masked]> writes:
> 
> > I'm missing expand-file-name somewhere (FILE could be not an absolute
> > file name) in the case that FILE is a local file.  Otherwise, yes,
> > thanks.
> 
> I have left it out by intention. expand-file-name has a price on remote
> systems

I meant to call expand-file-name only in the local case.  AFAIU, if
file-remote-p returns non-nil, its argument is already an absolute
file name.  But the alternative:

  (concat (file-remote-p default-directory) file)

will not necessarily produce an absolute file name.

> (defun file-remote-name (file)
>   "Return the remote file name of FILE.
> If FILE is a relative file name, return FILE as it is.
> If FILE is already remote, return FILE as it is.
> If `default-directory' is local, return FILE as it is.
> Otherwise, prepend the remote file name component of `default-directory'
> to FILE."

I would like this to be the equivalent of expand-file-name, so we
could use it instead of expand-file-name when an absolute file name
actually names a remote file.  If we return a relative file name, Lisp
programs will need to call expand-file-name on them, which is not what
we want, IMO.

And I'm not sure I understand what you are trying to say here:

> expand-file-name has a price on remote systems, it should be called
> explicitly by the callee of file-remote-name

(I guess you meant "caller", not "callee".)  If you want to avoid the
price of calling expand-file-name when FILE is already expanded, we
can call expand-file-name only on relative file names and only if
default-directory is local.  Would that solve the problem?