1

What variable or additional mode controls the order of candidates in vertico? I think by default it shows most recently used first. Is it possible to force it to show the candidates in the same order as in the list given to it.

So, in an org buffer with named source code blocks, I would like the candidates to be listed in the same order as in the file.

This works fine:

(ido-completing-read "Prompt: " (reverse (org-babel-src-block-names)))

This changes the order. Since I use vertico it opens up a vertico window.

(completing-read "Prompt: " (reverse (org-babel-src-block-names)))

I am using Doom Emacs. But I assume there should be a general variable that controls this behaviour.

I've tried deleting savehist file. Didn't help.

4
  • 1
    For vertico see vertico-sort-function, for completing-read see the answer here. Commented Mar 10, 2023 at 14:17
  • 1
    Thank you very much. I don't know why my mind was stuck on the word "order" and I was just looking for "vertico" and "order". Setting the function to nil within let statement did the job!
    – Arktik
    Commented Mar 10, 2023 at 15:34
  • The question is apparently about vertico, and it sounds like the answer is about vertico-sort-function. Maybe post that answer here? (The Q and A for completing-read is a duplicate, as @dalanicolai pointed out.)
    – Drew
    Commented Mar 10, 2023 at 17:45
  • So, how do I ensure it shows "last used". eg when I do consult-buffer I dont see the last file I opened at the top of files section when I restart emacs. imgur.com/a/G9wyfvL
    – RichieHH
    Commented Aug 5, 2023 at 3:40

1 Answer 1

2

As per @Drew's comment above, the answer is:

(let ((vertico-sort-function nil))
  (completing-read "Prompt: " (reverse (org-babel-src-block-names))))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.