unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* tramp-interactive: a small helper module
@ 2023-02-05 10:07 Pedro Andres Aranda Gutierrez
  2023-02-07 12:18 ` Michael Albinus
  0 siblings, 1 reply; 5+ messages in thread
From: Pedro Andres Aranda Gutierrez @ 2023-02-05 10:07 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 572 bytes --]

Hi,

May I announce a small Emacs module I have written to make TRAMP a bit more
comfortable.
It's called tramp-interactive and you can find it in

https://github.com/paaguti/tramp-interactive

Comments welcome. @tramp developers, if you find it interesting/useful
let's find a way to include this in Emacs ;-)

Thx, /PA
-- 
Fragen sind nicht da um beantwortet zu werden,
Fragen sind da um gestellt zu werden
Georg Kreisler

Headaches with a Juju log:
unit-basic-16: 09:17:36 WARNING juju.worker.uniter.operation we should run
a leader-deposed hook here, but we can't yet

[-- Attachment #2: Type: text/html, Size: 983 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: tramp-interactive: a small helper module
  2023-02-05 10:07 tramp-interactive: a small helper module Pedro Andres Aranda Gutierrez
@ 2023-02-07 12:18 ` Michael Albinus
  2023-02-07 16:07   ` Pedro Andres Aranda Gutierrez
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Albinus @ 2023-02-07 12:18 UTC (permalink / raw)
  To: Pedro Andres Aranda Gutierrez; +Cc: emacs-devel

Pedro Andres Aranda Gutierrez <paaguti@gmail.com> writes:

> Hi,

Hi Pedro,

> May I announce a small Emacs module I have written to make TRAMP a bit
> more comfortable.
> It's called tramp-interactive and you can find it in
>
> https://github.com/paaguti/tramp-interactive
>
> Comments welcome. @tramp developers, if you find it interesting/useful
> let's find a way to include this in Emacs ;-)

Thank you for your contribution. I've played a little bit with it, and
honestly, I don't understand what I shall do when I'm prompted for user,
host and port. And the package doesn't contain any description what it is
good for, and what's the intended use case.

As test, I have applied naïvely

--8<---------------cut here---------------start------------->8---
# emacs -Q -l tramp -l ~/Downloads/tramp-interactive.el 
C-x T l
user (nil): RET
port: 22 RET
Remote file: file:/ssh:@localhost: RET RET
File not found and directory write-protected
--8<---------------cut here---------------end--------------->8---

Could you please explain it? And also explain, what's the additional
benefit of this package, compared with user and host name completion in
the minibuffer we have already?

> Thx, /PA

Best regards, Michael.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: tramp-interactive: a small helper module
  2023-02-07 12:18 ` Michael Albinus
@ 2023-02-07 16:07   ` Pedro Andres Aranda Gutierrez
  2023-02-07 17:39     ` Michael Albinus
  0 siblings, 1 reply; 5+ messages in thread
From: Pedro Andres Aranda Gutierrez @ 2023-02-07 16:07 UTC (permalink / raw)
  To: Michael Albinus; +Cc: emacs-devel


[-- Attachment #1.1: Type: text/plain, Size: 2757 bytes --]

Hi Michael

thanks a lot for taking a look at it. The main this is that I was tired of
having to write everything (add to all that in my Spanish keyboard, # is
typed in through a modifier key) when I access remote files (which I do on
a daily basis).
I'll explain all the things you mention in the README let and let you know.

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'
<tab> 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' <tab> 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'm attaching a small screencast. I feel more comfortable when I have
defaults in the auto-completion. Just my own little quirks
;-) /PA

On Tue, 7 Feb 2023 at 13:18, Michael Albinus <michael.albinus@gmx.de> wrote:

> Pedro Andres Aranda Gutierrez <paaguti@gmail.com> writes:
>
> > Hi,
>
> Hi Pedro,
>
> > May I announce a small Emacs module I have written to make TRAMP a bit
> > more comfortable.
> > It's called tramp-interactive and you can find it in
> >
> > https://github.com/paaguti/tramp-interactive
> >
> > Comments welcome. @tramp developers, if you find it interesting/useful
> > let's find a way to include this in Emacs ;-)
>
> Thank you for your contribution. I've played a little bit with it, and
> honestly, I don't understand what I shall do when I'm prompted for user,
> host and port. And the package doesn't contain any description what it is
> good for, and what's the intended use case.
>
> As test, I have applied naïvely
>
> --8<---------------cut here---------------start------------->8---
> # emacs -Q -l tramp -l ~/Downloads/tramp-interactive.el
> C-x T l
> user (nil): RET
> port: 22 RET
> Remote file: file:/ssh:@localhost: RET RET
> File not found and directory write-protected
> --8<---------------cut here---------------end--------------->8---
>
> Could you please explain it? And also explain, what's the additional
> benefit of this package, compared with user and host name completion in
> the minibuffer we have already?
>
> > Thx, /PA
>
> Best regards, Michael.
>


-- 
Fragen sind nicht da um beantwortet zu werden,
Fragen sind da um gestellt zu werden
Georg Kreisler

Headaches with a Juju log:
unit-basic-16: 09:17:36 WARNING juju.worker.uniter.operation we should run
a leader-deposed hook here, but we can't yet

[-- Attachment #1.2: Type: text/html, Size: 3730 bytes --]

[-- Attachment #2: Screencast from 07-02-23 16:59:18.webm --]
[-- Type: video/webm, Size: 248271 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: tramp-interactive: a small helper module
  2023-02-07 16:07   ` Pedro Andres Aranda Gutierrez
@ 2023-02-07 17:39     ` Michael Albinus
  2023-02-08  6:22       ` Pedro Andres Aranda Gutierrez
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Albinus @ 2023-02-07 17:39 UTC (permalink / raw)
  To: Pedro Andres Aranda Gutierrez; +Cc: emacs-devel

Pedro Andres Aranda Gutierrez <paaguti@gmail.com> 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' <tab> 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' <tab> 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:

--8<---------------cut here---------------start------------->8---
(require 'tramp)
(setq tramp-default-method "ssh")
(tramp-change-syntax 'simplified)
--8<---------------cut here---------------end--------------->8---

From 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:

--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 "")))
--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

--8<---------------cut here---------------start------------->8---
2 possible completions:
albinus@localhost:
albinus@osm12.local:
--8<---------------cut here---------------end--------------->8---

And if you start with "C-x C-f /loc TAB", it expands already to "/localhost:".

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.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: tramp-interactive: a small helper module
  2023-02-07 17:39     ` Michael Albinus
@ 2023-02-08  6:22       ` Pedro Andres Aranda Gutierrez
  0 siblings, 0 replies; 5+ messages in thread
From: Pedro Andres Aranda Gutierrez @ 2023-02-08  6:22 UTC (permalink / raw)
  To: Michael Albinus; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 3754 bytes --]

Hi Michael,

Yes, I did all and it wasn't comfortable enough for me. I tend to make an
'Internet-free cure' in the summer and when I returned,
I had parts of my emacs configuration I didn't remember what exactly they
did (tramp config among them).
I had been experimenting with the flexibility of (interactive) before the
break and I decided to go that way (instead of RTFM,
I'm an engineer by education ;-) ), because I find it clean and cool. And I
came up with this way of doing things...

But I'll give the 'canonical' tramp configuration a chance, don't worry,
/PA

On Tue, 7 Feb 2023 at 18:39, Michael Albinus <michael.albinus@gmx.de> wrote:

> Pedro Andres Aranda Gutierrez <paaguti@gmail.com> 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' <tab> 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' <tab> 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:
>
> --8<---------------cut here---------------start------------->8---
> (require 'tramp)
> (setq tramp-default-method "ssh")
> (tramp-change-syntax 'simplified)
> --8<---------------cut here---------------end--------------->8---
>
> From 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:
>
> --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 "")))
> --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
>
> --8<---------------cut here---------------start------------->8---
> 2 possible completions:
> albinus@localhost:
> albinus@osm12.local:
> --8<---------------cut here---------------end--------------->8---
>
> And if you start with "C-x C-f /loc TAB", it expands already to
> "/localhost:".
>
> 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.
>


-- 
Fragen sind nicht da um beantwortet zu werden,
Fragen sind da um gestellt zu werden
Georg Kreisler

Headaches with a Juju log:
unit-basic-16: 09:17:36 WARNING juju.worker.uniter.operation we should run
a leader-deposed hook here, but we can't yet

[-- Attachment #2: Type: text/html, Size: 5007 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-02-08  6:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-05 10:07 tramp-interactive: a small helper module Pedro Andres Aranda Gutierrez
2023-02-07 12:18 ` Michael Albinus
2023-02-07 16:07   ` Pedro Andres Aranda Gutierrez
2023-02-07 17:39     ` Michael Albinus
2023-02-08  6:22       ` Pedro Andres Aranda Gutierrez

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).