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

ivy-completing-read fails when COLLECTION includes lists #1743

plantarum opened this issue Sep 5, 2018 · 2 comments


Copy link

commented Sep 5, 2018

completing-read allows for the COLLECTION value to include lists of strings, in which case, the first string in each list is used as the target:

(completing-read "test" '(("one" "first") "two" "three"))

With this form, "one", "two" and "three" are offered as completion targets.

However, when I use ivy-completing-read:

(ivy-completing-read "test" '(("one" "first") "two" "three"))

this produces an error:

Debugger entered--Lisp error: (wrong-type-argument stringp ("one" "first"))
ivy-string<("three" ("one" "first"))
sort((("one" "first")) ivy-string<)
ivy--reset-state(#s(ivy-state :prompt "test" :collection (("one" "first") "two" "three") :predicate nil :require-match nil :initial-input nil :history nil :preselect nil :keymap nil :update-fn nil :sort t :frame #<frame emacs@onottra672626p 0x3e26680> :window #<window 6 on scratch> :buffer #<buffer scratch> :text nil :action (1 ("o" identity "default") ("i" #f(compiled-function (x) #<bytecode 0x141210d>) "insert") ("w" #f(compiled-function (x) #<bytecode 0x141211d>) "copy")) :unwind nil :re-builder nil :matcher nil :dynamic-collection nil :display-transformer-fn nil :directory "~/" :caller eval-last-sexp :current nil :def nil))
ivy-read("test" (("one" "first") "two" "three") :predicate nil :require-match nil :initial-input nil :preselect nil :def nil :history nil :keymap nil :sort t :dynamic-collection nil :caller nil)
ivy-completing-read("test" (("one" "first") "two" "three"))
eval((ivy-completing-read "test" '(("one" "first") "two" "three")) nil)
funcall-interactively(eval-last-sexp nil)
call-interactively(eval-last-sexp nil nil)

I ran into this using the built-in bibtex.el library, where completion targets include lists of the form: (("Author" "the article author") ("Year" "the year the article was published") ... )

ivy version 20180731.1520, confirmed in 20180905.1250
Emacs version 27.0.50

basil-conto added a commit to basil-conto/swiper that referenced this issue Sep 5, 2018

This comment has been minimized.

Copy link

commented Sep 5, 2018

However, when I use ivy-completing-read:

The same happens with (ivy-read "" '(("a") "b" "c") :sort t).

this produces an error:

This arises when the default sorting function ivy-string< is given heterogeneous arguments, i.e. a string and a cons. I believe this is fixed by #1744.


This comment has been minimized.

Copy link

commented Sep 5, 2018

Thanks for the prompt reply! I tried it out and it and my problem is gone.

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