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?
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.
Sign up to join this communityYou 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))
ivy
from being used, is there a general way to handle this so ivy keeps working?
Jun 3, 2018 at 6:16
ivy-sort-functions-alist
. See also github.com/abo-abo/swiper/issues/1611.
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
.