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

require-match and empty input #909

Closed
Bad-ptr opened this Issue Mar 3, 2017 · 7 comments

Comments

Projects
None yet
3 participants
@Bad-ptr
Contributor

Bad-ptr commented Mar 3, 2017

Testcase:

(completing-read "Test: " () nil t)

With ivy enabled I can only abort with C-g, or C-u C-j. (more precisely I can not exit from minibuffer with exit-minibuffer and empty input)
With ivy disabled I can press RET and get "" result.
The emacs manual says:

However, empty input is always permitted, regardless of the value of require-match; in that case, completing-read returns the first element of default, if it is a list; "", if default is nil; or default.

Well I'm understand that this is a very rare case, but I'd like if ivy will be as much consistent with the standard completing-read as it is possible.
I have a code where I bind a key to the mb-local-map which allows me to exit(it calls exit-minibuffer) and restart completing-read with a different collection. Initially it may be empty collection. This works with standard completing-read, but not with ivy.

@spluque

This comment has been minimized.

spluque commented Mar 12, 2017

I came across this post while looking for a way to tell ivy to complete the null string "" for filename completion in the minibuffer. If I understand correctly from here, ivy does not allow for it?

@abo-abo

This comment has been minimized.

Owner

abo-abo commented Mar 12, 2017

If I understand correctly from here, ivy does not allow for it?

This is allowed with C-M-j (ivy-immdiate-done), also bound to C-u C-j.
It allows to return any string, including the empty one, ignoring whether the string is in the collection or not.

@abo-abo abo-abo closed this in 1ac1cc1 Mar 12, 2017

@abo-abo

This comment has been minimized.

Owner

abo-abo commented Mar 12, 2017

@Bad-ptr I added a check for the null collection. Should be enough, I think. Thanks.

@spluque

This comment has been minimized.

spluque commented Mar 12, 2017

When using filename or directory completion, it seems impossible to even get to a null string; when I delete everything in the minibuffer, the null string is not in the candidates, so I see either the tramp methods or some directory

@abo-abo

This comment has been minimized.

Owner

abo-abo commented Mar 12, 2017

@spluque that's how it's supposed to work; you can still use C-M-j.

@spluque

This comment has been minimized.

spluque commented Mar 22, 2017

Sorry to insist @abo-abo , but when I do that (C-M-j) I don't get the null completion, but the current directory which is what is shown as soon as I request the filename or directory completion with e.g. C-x C-f which I've bound to counsel-find-file. What am I missing? Thanks for this great library.

@abo-abo

This comment has been minimized.

Owner

abo-abo commented Mar 22, 2017

@spluque Please open a new issue describing specifically what you want to achieve in general (like create a file), not just the small detail of getting an empty string.

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