Subject: bug#27631: dired a/*/b

From: Michael Albinus <[email-masked]>
Date: Fri, 14 Jul 2017 11:30:01 +0200

Tino Calancha <[email-masked]> writes:

> Hi Michael,

> i'd like to provide Tramp support for this new Dired feature.
> The implementation is fairly straight: just adds a function
> 'insert-directory-wildcard-in-dir-p' in files.el, and use it in
> 'insert-directory' and Dired.
>
> To get Tramp support i've added a handler
> 'tramp-sh-handle-insert-directory-wildcard-in-dir-p'.
> Is this procedure OK or i am doing something weird?

That's not sufficient, it takes much more for adding a new handler in
Tramp. At least, it must be declared in tramp.el, and it must also be
added to the other backends but tramp-sh.el. 

And you can also not call it directly; Tramp is backwards compatible
with Emacs 24 and 25.

> +(defun insert-directory-wildcard-in-dir-p (dir)
> +  (when (string-match "[*]" (file-name-directory dir))
> +    (let ((regexp "\\`\\([^*]+/\\)\\([^*]*[*].*\\)"))
> +      (string-match regexp dir)
> +      (cons (match-string 1 dir) (match-string 2 dir)))))

Unfortunately, there's no docstring, so it isn't clear to me what you
expect as result. Reading `tramp-sh-handle-insert-directory-wildcard-in-dir-p',
I believe you just want to work over the local part of a remote file
name. So you could do at the beginning:

  ;; DIR could be remote.
  (setq dir (file-local-name dir))

And I don't believe that it is mandatory to call
`insert-directory-wildcard-in-dir-p' in Tramp. All what's needed could be
done outside Tramp file name handlers.
.
> Best regards,
> Tino

Best regards, Michael.