Recently, when using Ivy and calling completing-read
,
my output is being sorted (instead of showing up in the order passed in).
How can I prevent sorting the input to completing-read
when using Ivy?
Recently, when using Ivy and calling completing-read
,
my output is being sorted (instead of showing up in the order passed in).
How can I prevent sorting the input to completing-read
when using Ivy?
You need your completion-table to tell the completion-UI not to perform sorting (typically because the completion-table already arranges for its own sorting to take place).
See C-h f completion-metadata
. Here's an example:
(let* ((presorted-completions ...)
(completion-table
(lambda (string pred action)
(if (eq action 'metadata)
'(metadata (display-sort-function . identity)
(cycle-sort-function . identity))
(complete-with-action
action presorted-completions string pred))))
(completing-read "Prompt" completion-table))
Sorting can be disabled by setting (ivy-sort-functions-alist nil)
, in the scope you're using completing-read
(so as not to change defaults everywhere).
See this complete example.
ivy-sort-functions-alist
to nil
, only the the entries corresponding to the callers of completing-read
.
– Basil
Jun 02 '18 at 17:29
ivy
from being used, is there a general way to handle this so ivy keeps working? – ideasman42 Jun 03 '18 at 06:16ivy-sort-functions-alist
. See also https://github.com/abo-abo/swiper/issues/1611. – Basil Jun 17 '18 at 17:57