I think that won't work for a use case where I often will initiate a connection back to my own machine and I do want the effect of retaining remote file semantics in default-directory?

On Mon, Feb 10, 2025 at 9:19 AM Michael Albinus <michael.albinus@gmx.de> wrote:
Visuwesh <visuweshm@gmail.com> writes:

Hi,

> That reminds me why my :override advice was simpler.  Indeed, I had to
> get rid of that test to ensure that the function would work as intended
> for remote shell buffers.  It never made much sense IMO and I got the
> impression that it is in place as a "let's be absolutely sure" measure.
> I can say that I face no issues with the test omitted thus far. It could
> be a product of me being in control of $PS1 for local and remote shells
> though.

Well. The host part of the URL could be anything, and must not be the
same like the current host name. So perhaps the check could be like
this, "to be absolutely sure":

--8<---------------cut here---------------start------------->8---
  (when-let* ((url (url-generic-parse-url text))
              ((string= (url-type url) "file"))
              ((or (null (url-host url))
                   ;; Use `downcase' to match `url-generic-parse-url' behavior
                   (string= (url-host url)
                            (downcase
                             (or (file-remote-p default-directory 'host)
                                 (system-name)))))))
    (ignore-errors
      (cd-absolute
       (concat (file-remote-p default-directory)
               (url-unhex-string (url-filename url)))))))
--8<---------------cut here---------------end--------------->8---

WDYT?

Best regards, Michael.