From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Michael Albinus Newsgroups: gmane.emacs.devel Subject: Re: tramp-interactive: a small helper module Date: Tue, 07 Feb 2023 18:39:15 +0100 Message-ID: <87ilgdnzng.fsf@gmx.de> References: <875ycdpt29.fsf@gmx.de> Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20791"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: emacs-devel To: Pedro Andres Aranda Gutierrez Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Feb 07 18:40:21 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pPRx6-0005CA-TP for ged-emacs-devel@m.gmane-mx.org; Tue, 07 Feb 2023 18:40:20 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pPRwC-0006eb-1U; Tue, 07 Feb 2023 12:39:24 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pPRwB-0006eT-3W for emacs-devel@gnu.org; Tue, 07 Feb 2023 12:39:23 -0500 Original-Received: from mout.gmx.net ([212.227.17.22]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pPRw9-0004Si-97 for emacs-devel@gnu.org; Tue, 07 Feb 2023 12:39:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1675791555; bh=La9aCMu5E0Z1Gp/n9OBZ5wlZYKJEkBL6c5/52Sff5N4=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date; b=AjXJSOIcNMnpmu/DciFGUf6Tajq8sdgbjjIH5YcN2ucAZt2rK3GuIRvoIQV3kSYLA 4DVOxCO7hM1y3xG2BXEdax6YJJlV4E0ygcv5oUgV8VS1uFg8n0yyuZr0i5FbByhzFf rTjLdBtochUWshCpGmWoR7psKKwopN7hNyn1+727E2bD79vqYeuxCFrnZe6J+9bryR 77ZrTxT1IRZ+LZ+Bw2o9dX7VwNAqex0qZP3JQnyaRH50VO4uRfcBVTSdA4gZWz0+bZ Ot4J3FW9yQzKxrj3xbGnE7RI0URvG3KK1y8QJrvcydBVKHI0aZN2n7JBQ05hnuPp39 j8yTyn+MACxWQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Original-Received: from gandalf.gmx.de ([185.89.39.22]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MDywu-1pHmRL3EbE-009waD; Tue, 07 Feb 2023 18:39:15 +0100 In-Reply-To: (Pedro Andres Aranda Gutierrez's message of "Tue, 7 Feb 2023 17:07:24 +0100") X-Provags-ID: V03:K1:aeUfL+RUgxPgibkerzFS4CQZMk1oLmTcY7UVzht1DCRpj4Aypng Oo58jWSlq/hlA1VI6eU+q3wo9yd3VBfKyT0Wz/Nk5sSmGZjfDxCgCio8pSkQDoetulj1dI+ /8u0ls3mw7A4OoDKdrfiiXLVvVhvplLgfVN+I6jgE1+6S5yvHhF1P/T0jAI4oN8Q8i1Qd9/ +baKCnOm36R7e+oFeXXwg== UI-OutboundReport: notjunk:1;M01:P0:Pc+GfcXOtG4=;sYWuywYykSYAj93I0Sbp8bgrT6Y tx3gBPMbQwzKs+0QJUOz+qDuL8IZIGuwDtY11N1jijOG2gSRuoz0Yf9V7vSO/iHZH3ozY863s Z0rs0rOP1WQlAxmsRM4Lh1B6HTbbOtsqvyn+uIFLiZHlH5G6qtAP3WLxDor0FegE+la4KryPV wmazLU1dqbAGAafcaUY9VQlROo9nR9QuZccCU3P7uMZXvGpeWW+9akAqAWxxqgXhhYkC/wDjF MNcayl/HxoZ5eFnBp0oal5DKDwf3vrGL/w/Bufwcwe/xY4Nma2Fx8rdeEmkpN9yLw5JSnh10I FKF8zIMgUp+zO3d3S5yVCsa+ogLOaj6f3vqBzRv4TG0cnsHBIpZXArYkQj1vBujuiA2QIObP3 cn+IgAKOyBhi1dOxVId4kjwDxWtI38pm6ZgVBqV1pI/eIDpZGbx9/2Kq5iIXciufBlrD4CuYc B3vBpipqqMNermpx85Ks9DJa+Z13/+sQyg35JYCwDA/oa2F9/WmS+of9sgbLP+rLQXkgnCXc1 2cP6kdMQyTXYtlh1Twnk94crsxFnvGj2Gzp97Chp/gjI0NTOf2O8jjpXamK5hX3J8pC1VULHQ oD8gzd5erSI/2S4phIWlfg4qupqddo1ie7/L6oTfhGsUGAcg70jyRIyfFQbMtsHPpylIV7Tqq EnrcsqiTk3G7edKlD5xYy1/9Nf+yaLsxB7UojYlwOUtuLfSrYnHcoPiHmbT6bc4YOEacQJH00 rlkTfJw6ZhBTi9rAdnWVfbAnl5wS9Yy0tOF71oD0YUkULfm3nJsbQP98rJqNNi3fXqhvGpld Received-SPF: pass client-ip=212.227.17.22; envelope-from=michael.albinus@gmx.de; helo=mout.gmx.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:303039 Archived-At: Pedro Andres Aranda Gutierrez writes: > Hi Michael Hi Pedro, > But in a couple of words. I have a list of users I use in VMs and > remote machines: > -my linux user and 'student' are the two most often used. > So when prompted 'user' the default value is the user, but if I type > 's' I get student autocompleted > With the host you have the same, I default to 'localhost' for VMs but > also have a host called osm12.local (and others). > If I put them in the host list I'll be able to press 'o' and > have Emacs autocomplete to osm12.local. > Regarding the port number the default for SSH is 22, right? But I can > also input the port number for port translated VMs. I understand the scenario. But I still don't understand why you don't configure Tramp's existing file name completion. First, I assume you use always "ssh" as method. In this case I recommend an alternative Tramp file name syntax called `simplified'. Add the following in your .emacs: =2D-8<---------------cut here---------------start------------->8--- (require 'tramp) (setq tramp-default-method "ssh") (tramp-change-syntax 'simplified) =2D-8<---------------cut here---------------end--------------->8--- =46rom now on, you don't need to write "/method:user@host:/path". Instead,= you simply write "/user@host:/path" for a remote file name. Secondly, tell Tramp which users and hosts you are interested in. By default, Tramp scans all config files to determine possible users and hosts. But you can give Tramp an own completion function, like this: =2D-8<---------------cut here---------------start------------->8--- (setq tramp-completion-use-auth-sources nil) (defun my-tramp-completion (&rest args) `((,(user-login-name) "localhost") ("student" "localhost") (,(user-login-name) "osm12.local" ("student" "osm12.local")))) (tramp-set-completion-function "ssh" '((my-tramp-completion ""))) =2D-8<---------------cut here---------------end--------------->8--- And now, you can do "C-x C-f /alb TAB" and it expands to "/albinus@", which is my user name. A second TAB shows you the possible completions =2D-8<---------------cut here---------------start------------->8--- 2 possible completions: albinus@localhost: albinus@osm12.local: =2D-8<---------------cut here---------------end--------------->8--- And if you start with "C-x C-f /loc TAB", it expands already to "/localhos= t:". It doesn't matter how you define your `my-tramp-completion' function. I've shown you a fixed list, but the function could also create the list dynamically. If you need ports, you shall add them to the host names, like ("student" "localhost#2222") Play with this :-) Evertything is explained in the Tramp manual. Best regards, Michael.