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

completing-read argument DEF as a symbol breaks #1526

Closed
yannvanhalewyn opened this issue Apr 8, 2018 · 3 comments

Comments

@yannvanhalewyn
Copy link

commented Apr 8, 2018

There's a difference between the default behavior of completing-read, and ivy-completing-read when de DEF argument is a symbol. It seems to lose the suggestions collection, and will not return said value upon "RET" with empty input.

(completing-read "Q: " '(one two) nil nil nil nil 'one)
;; => no suggestions and empty "" on RET
(completing-read-default "Q: " '(one two) nil nil nil nil 'one)
;; => Shows suggestions on tab and expected default value on RET

I've looked through open and closed issues and found some other issues about completing read, but not about this case so I opened a new one.

I couldn't find any specification of expected type in the default completing-read documentation, correct me if I'm wrong.

Tested on master #da4236c with make plain.

My personal issue with this was with clj-refactor when adding missing libspec has multiple options, see line: https://github.com/clojure-emacs/clj-refactor.el/blob/ab081b26b92f6a1c7ebe8fb7ff9803d46b07ae84/clj-refactor.el#L2182

EDIT: I had submitted issue by accident with the return key, finished specifying.

@yannvanhalewyn

This comment has been minimized.

Copy link
Author

commented Apr 8, 2018

Not same, but related to #1208 and #1209

@basil-conto

This comment has been minimized.

Copy link
Collaborator

commented Apr 8, 2018

when de DEF argument is a symbol

Note that vanilla completing-read returns DEF on empty input regardless of its type. For example,

(progn
  (push ?\C-m unread-command-events)
  (completing-read-default "" '("a" "b" "c") nil nil nil nil (current-buffer)))

returns a buffer object.

@yannvanhalewyn

This comment has been minimized.

Copy link
Author

commented Apr 8, 2018

True! And with ivy enabled that returns an empty string, and has no completions. What especially matters in this issue IMO is the completions part.

nxtr added a commit to nxtr/swiper that referenced this issue Aug 25, 2018
ivy.el (ivy-immediate-done): Exit with empty input
* Use prefix arg and ivy-immediate-done to let the user explicitly exit
  with empty input, i.e. the caller default.
* Fix `completing-read' compat
* ivy-test.el: Add relevant positive tests
* ivy.el (ivy-alt-done): Update docstring

Related to abo-abo#1170
Fixes  abo-abo#1526
nxtr added a commit to nxtr/swiper that referenced this issue Nov 19, 2018
ivy.el (ivy-completing-read): Add compatibility for non-string defaults
* Fix compat with `completing-read' to return the first element of
  default, if it is a list; "", if default is nil; or default
* ivy-test.el: Add relevant positive tests

Fixes  abo-abo#1526

@abo-abo abo-abo closed this in 268bd08 Nov 19, 2018

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