Subject: Re: bug#53053: 28.0.90; Tramp completion bug of path /sudo::~/

From: Michael Albinus <[email-masked]>
Date: Thu, 17 Feb 2022 10:43:29 +0100

Stefan Monnier <[email-masked]> writes:

Hi,

> So maybe the "right fix" is to change Tramp's handling of
> `substitute-in-file-name` such that
> "/sudo::~" returns "/sudo:root@<host>:~" instead of
> "/sudo:root@<host>:~/",
> but in the mean time I installed the patch below which should avoid
> this problem at least in the original recipe.  You can still bump into
> side effects of the underlying problem, of course.

In tramp-handle-substitute-in-file-name, there is the code

--8<---------------cut here---------------start------------->8---
      ;; "/m:h:~" does not work for completion.  We use "/m:h:~/".
      (if (and (stringp localname) (string-equal "~" localname))
	  (concat filename "/")
	filename))))
--8<---------------cut here---------------end--------------->8---

The ChangeLog does not give a reasoning. So I've removed this, and
testing with Emacs 28.0.50 shows proper behavior now with the recipe.

I've pushed it to master. The patch from Stefan could be reverted I
believe, unless it is also good for something else.

The Tramp change will also appear in Tramp 2.5.2.2, which is the
upcoming version on GNU ELPA. Later, it will be merged into Emacs 28.2.

>         Stefan

Best regards, Michael.