Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First time TRAMP completion #145

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

First time TRAMP completion #145

hpdeifel opened this issue Jun 16, 2015 · 8 comments

Comments

@hpdeifel
Copy link

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
Copy link
Owner

abo-abo commented Jun 16, 2015

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

@hpdeifel
Copy link
Author

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
Copy link
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
Copy link
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 added a commit that referenced this issue Jun 19, 2015
@hpdeifel
Copy link
Author

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 added a commit that referenced this issue Jun 19, 2015
* ivy.el (ivy-alt-done): With the example input, offer a completion for
  known remotes with the initial input "foo".

Re #145
@abo-abo
Copy link
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 added a commit that referenced this issue Jun 19, 2015
* ivy.el (ivy-alt-done): Add another cond branch for `ivy-text' matching
  a full remote file path.

Re #145
@hpdeifel
Copy link
Author

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
Copy link
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants