Subject: Re: bug#54885: 29.0.50; Tramp completion support for top-level sshconfig include

From: Michael Albinus <[email-masked]>
Date: Wed, 13 Apr 2022 09:13:59 +0200

Bartosz Kaczyński <[email-masked]> writes:

Hi Bartosz,

> Hi, I noticed that TRAMP hostname complation doesn't support my
> top-level sshconfig like below:
>
> tree ~/.ssh/conf.d/
> /home/bk/.ssh/conf.d/
> ├── domainX
> ├── domainY
> └── personal
>
> My ~/.ssh/config contains only one line
>
> Include conf.d/*
>
> and it's work perfectly from the shell by Emacs can't parse this
> Include directive. It would be very useful enhancement if the built-in
> completion frameworks (I use icomplete with vertical mode) can handle
> that structure which I first saw on counsel-tramp package(1).
>
> 1. https://github.com/masasam/emacs-counsel-tramp#support-for-top-level-sshconfig-include

Tramp doesn't handle sshconfig includes. However, you can emulate it
yourself with the following snippet in your .emacs (untested):

--8<---------------cut here---------------start------------->8---
(defvar my-tramp-completion-function-alist-ssh nil)

(dolist (file (directory-files "~/.ssh/conf.d/" 'full directory-files-no-dot-files-regexp))
  (add-to-list 'my-tramp-completion-function-alist-ssh
	       `(tramp-parse-sconfig ,file)))

(tramp-set-completion-function "scp" tramp-completion-function-alist-ssh)
(tramp-set-completion-function "ssh" tramp-completion-function-alist-ssh)
--8<---------------cut here---------------end--------------->8---

Best regards, Michael.