First time TRAMP completion #145

Closed
hpdeifel opened this Issue Jun 16, 2015 · 8 comments

Projects

None yet

2 participants

@hpdeifel

In a fresh emacs, where I haven't had any TRAMP connections open, remote file-name completion (and host-names and methods) doesn't work until I open at least one file or directory in tramp.

The same is true for emacs -Q, it also doesn't complete methods or host names the first time, BUT I can get filename completion by typing ssh:host:./<TAB> (the ./ is important, without it, it doesn't work).

Requiring TRAMP first seems to fix it (and also immediately provides completion for host names and methods), but I'd rather have it lazily loaded, like regular find-file seems to do it.

@abo-abo abo-abo added a commit that closed this issue Jun 16, 2015
@abo-abo Require TRAMP in time
* ivy.el (ivy-alt-done): Require tramp before use. Store `ivy-last'
  before calling `ivy-read', since each `ivy-read' overwrites
  `ivy-last', and this one overwrites `counsel-find-file' action.

Fixes #145
61bb9e0
@abo-abo abo-abo closed this in 61bb9e0 Jun 16, 2015
@abo-abo
Owner
abo-abo commented Jun 16, 2015

Thanks. Let me know if there's still some annoying stuff left.

@hpdeifel

Ok, that didn't change anything for me and after digging into the code, I'm confused what the logic in ivy-alt-done should do anyway.

  • The tramp specific cond branch (string-match ... never matched for me, since ivy-text does not start with a slash. Entering /ssh:hpd@remote: C-j calls ivy-alt-done with ivy-text being ssh:hpd@remote:.
  • This cond condition also doesn't test ivy-directory and thus matches in every other completion (which may not be intended, but gave me a way to try it out).
  • Entering /ssh:hpd@remote: C-j in some non-filename ivy prompt gives me a list of hostnames, even though I have already typed that hostname in.

Here is the default behaviour in emacs: On first startup, you don't get tramp completion until you enter the first colon. After that, methods and hostnames are completed, but /hostname: TAB doesn't complete files, yet. Only after you enter the first slash after the hostname. So you can get completion for the home directory by typing ./ TAB.

In ivy, without requiring TRAMP, I was unable to get completion at all. Typing a remote file name and C-j always directly finds that file.

When I require tramp first, I get method completion for /, which is useless because typing C-j on a method results in the message byte-code: Host name must not match method "scp". Nothing else works, except curiously for typing exactly /remote:C-j. This defaults to ssh as method and my current login as username and shows me completions for files in the home directory on the remote computer.

@abo-abo
Owner
abo-abo commented Jun 19, 2015

Entering /ssh:hpd@remote: C-j calls ivy-alt-done with ivy-text being ssh:hpd@remote:

You're entering //ssh:hpd@remote: C-j, aren't you? The intent is to enter /ssh:hpd@remote: C-j, without having // switch to the root directory.

@abo-abo
Owner
abo-abo commented Jun 19, 2015

Here is the default behaviour in emacs: On first startup, you don't get tramp completion until you enter the first colon. After that, methods and hostnames are completed, but /hostname: TAB doesn't complete files, yet. Only after you enter the first slash after the hostname. So you can get completion for the home directory by typing ./ TAB.

Here's how I do it, without requiring tramp:

  1. C-x C-f /ssh: C-j: I get the completion list of my remote history. Some of them already with a username.
  2. I select a remote host and immediately get the directory listing for the home directory on the remote host.

That's all there is to it. It's also possible to C-x C-f /ssh:oleh@ C-j to have the user fixed, but choose host.

@abo-abo abo-abo added a commit that referenced this issue Jun 19, 2015
@abo-abo Fix non-file completions ability to enter tramp completion
* ivy.el (ivy-alt-done): Update.

Re #145
46695ac
@hpdeifel

Ah, I see. I did in fact never try to input a single slash, because in my intuition, a tramp file name starts with a / (and not with /some/directory//).

This works very well (after enabling recursive minibuffers), but IMHO doesn't blend in with the rest of the interface. (For example, typing /ssh:startofname C-j throws away startofname, typing /ssh:wholeservername:file C-j also shows the host completion). Also, I usually don't even use the method part in tramp filenames, because ssh is the default anyway. So I really would like to just have to type /remote:C-j to get completion for my files. (Currently this does indeed work with requiring tramp first and typing //remote:C-j).

@abo-abo abo-abo added a commit that referenced this issue Jun 19, 2015
@abo-abo Don't cut off "/ssh:foo" input
* ivy.el (ivy-alt-done): With the example input, offer a completion for
  known remotes with the initial input "foo".

Re #145
581d8c0
@abo-abo
Owner
abo-abo commented Jun 19, 2015

Ah, I see. I did in fact never try to input a single slash, because in my intuition, a tramp file name starts with a / (and not with /some/directory//).

This was the case before, but since // is a destructive operation (brings you to root, you can't go back), I opted for /ssh: instead of //ssh:.

This works very well (after enabling recursive minibuffers)

You mean it doesn't work if the user hasn't enabled recursive minibuffers?

For example, typing /ssh:startofname C-j throws away startofname

Fixed.

typing /ssh:wholeservername:file C-j also shows the host completion

I don't know if a user should go that far without completion. But I'll try to add a work-around anyway.

@abo-abo abo-abo added a commit that referenced this issue Jun 19, 2015
@abo-abo ivy.el (ivy-alt-done): Find file if given a full tramp path
* ivy.el (ivy-alt-done): Add another cond branch for `ivy-text' matching
  a full remote file path.

Re #145
513a77e
@hpdeifel

You mean it doesn't work if the user hasn't enabled recursive minibuffers?

Yes, I need to set enable-recursive-minibuffers to t for the hostname completion to work.

I don't know if a user should go that far without completion. But I'll try to add a work-around anyway.

I think, completion should support the user whenever he needs it and in whatever state it is in. Muscle memory and fast typing can mean that it's sometimes easier to type things out than to complete. Especially when the completion has to be initiated manually and requires a context switch (such as C-j after the method name).

Btw, thanks again for your work. Ivy has never made me want to go back to helm, so far.

@abo-abo
Owner
abo-abo commented Jun 19, 2015

Btw, thanks again for your work. Ivy has never made me want to go back to helm, so far.

Thanks to you too. Most of the improvements here are done through user feedback. Just keep it coming, preferably in many small tractable improvements, rather than few large requests :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment