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

How to let `ivy-partial-or-done' only complete and do not open file or directory? #86

Closed
tumashu opened this issue May 8, 2015 · 12 comments

Comments

@tumashu
Copy link
Contributor

commented May 8, 2015

I want to use TAB to complete directory or file name, but don't open, is it possible?

@abo-abo abo-abo closed this in f2a0966 May 8, 2015

@abo-abo

This comment has been minimized.

Copy link
Owner

commented May 8, 2015

Just bind ivy-partial like this:

(define-key ivy-minibuffer-map (kbd "TAB") 'ivy-partial)
@tumashu

This comment has been minimized.

Copy link
Contributor Author

commented May 8, 2015

Thanks!

@tumashu

This comment has been minimized.

Copy link
Contributor Author

commented May 10, 2015

I try, but feel confusion, following code seed more comfort

(defun eh-ivy-partial-or-done ()
  (interactive)
  (or (ivy-partial)
      (ivy-alt-done)))

(define-key ivy-minibuffer-map (kbd "TAB") 'eh-ivy-partial-or-done)

@tumashu

This comment has been minimized.

Copy link
Contributor Author

commented May 10, 2015

I also find the follow configure is also a comfort tip:

(define-key ivy-minibuffer-map (kbd "<return>") 'ivy-alt-done)
@Ergus

This comment has been minimized.

Copy link
Contributor

commented Sep 8, 2018

Hi, sorry for necropumping this thread, but it is very related

I am trying this:
(define-key ivy-minibuffer-map (kbd "TAB") 'ivy-partial)

and the behaviour is ALMOST what I wanted. BUT the candidates list is not shown if I press tab many times, it requires to press C-j to be shown. Basically I want this to behave like bash or zsh completion because it is more intuitive I think.
My idea is that pressing tab I should get a completion if it is unique else the candidates list, and only open a file (or dired maybe) if I press enter or C-j.

What is missing now it the candidates list with the second tab press, because it does nothing.

I don't want to bother too much, but I don't know if this is the expected behaviour or an issue, maybe it is something I can configure or it requires more complicated work??

Any help please?

@abo-abo

This comment has been minimized.

Copy link
Owner

commented Sep 8, 2018

What is missing now it the candidates list with the second tab press, because it does nothing.

What do you think should happen with the second tab press? The candidates list is already shown and there's nothing further to complete.

If you really see a use case improvement, please open a new issue and describe a detailed scenario of how you think it should work.

@Ergus

This comment has been minimized.

Copy link
Contributor

commented Sep 8, 2018

What happens to me is when looking for a file. The candidates list is not there after a completion and it needs C-j to be shown.

C-x C-f /ho

image

TAB

image

Now TAB here does nothing.

C-j (This is what I thing the second tab should do)

image

@abo-abo

This comment has been minimized.

Copy link
Owner

commented Sep 9, 2018

@Ergus OK, I see now. The intended design of ivy-partial is to produce no other effects except extending your input. So you should not be expecting that function to select a candidate.

Instead, the default biding of TAB is ivy-partial-or-done, which actually does what you want in the described use case.

@Ergus

This comment has been minimized.

Copy link
Contributor

commented Sep 9, 2018

Yes, I know. But what I want is to avoid tab to open a file or dired if the completion is actually in a file or directory. ivy-partial-or-done does what I want, but a wrong extra tab makes too much.
I think that all completions should be bound to tabs (alt or partial) and also to show the list directory; but "done" (open file in emacs or call dired) should be something else like enter.
This is the bash default behaviour that is more familiar for many users and compatible with all the other shells like zsh; but also iPython, and any thing that uses read-line in general.
Is this possible?

@Ergus

This comment has been minimized.

Copy link
Contributor

commented Sep 11, 2018

Hi abo-abo:

If the function ivy--directory-done substitutes the 2 calls to (ivy-done) with an "alias" function (initialized by default to ivy-done); then we can reassign the alias symbol in the configuration but the default behaviour will not change. We can just reassign the alias to nothing and the behaviour will be like bash; or to something else for advanced users.

Does it makes sense?

abo-abo added a commit that referenced this issue Sep 11, 2018
ivy.el (ivy-partial): Can change current dir when completing files
* ivy-test.el (ivy-partial-files): Add test.

Re #86
@abo-abo

This comment has been minimized.

Copy link
Owner

commented Sep 11, 2018

@Ergus Please have a look at the change. If there are more changes required, please open a new issue.

@Ergus

This comment has been minimized.

Copy link
Contributor

commented Sep 12, 2018

Now it is perfect. Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.