Subject: Re: bug#76165: [PATCH] ansi-osc-directory-tracker respects Tramp remote files

From: Michael Albinus <[email-masked]>
Date: Mon, 10 Feb 2025 14:55:22 +0100

Visuwesh <[email-masked]> writes:

Hi,

>>>     (concat (file-remote-p default-directory)
>>>             (url-unhex-string (url-filename url)))
>>
>> Looks like, yes :-(
>>
>> Since I don't know how to activate ansi-osc-directory-tracker in a shell
>> (where is it documented?), I couldn't test it. Could you pls advice me?
>
> The documentation is spread over two places:
>
>     1. Docstring of `ansi-osc-directory-tracker' tells how to set up
>        things from the shell side.
>     2. You need to add `comint-osc-process-output' to
>        `comint-output-filter-functions' (as the commentary following
>        comint.el:3998 instructs you to).

I've fixed ansi-osc-directory-tracker as described above, and started a
test as given in the recipe. Testing on a remote host, different from my
local one.

There is the following code in ansi-osc-directory-tracker:

--8<---------------cut here---------------start------------->8---
    (when (and (string= (url-type url) "file")
               (or (null (url-host url))
                   ;; Use `downcase' to match `url-generic-parse-url' behavior
                   (string= (url-host url) (downcase (system-name)))))
      ...
--8<---------------cut here---------------end--------------->8---

But on the remote host, neither (null (url-host url)) nor (string=
(url-host url) (downcase (system-name))) return t; simply because the
host name is not nil or equal to (system-name).

Instead, the following shall be sufficient:

--8<---------------cut here---------------start------------->8---
    (when (string= (url-type url) "file")
      ...
--8<---------------cut here---------------end--------------->8---

Comments?

Best regards, Michael.