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.

Drew
  • 75,699
  • 9
  • 109
  • 225
Arktik
  • 932
  • 4
  • 15
  • 1
    For vertico see `vertico-sort-function`, for completing-read see the answer [here](https://emacs.stackexchange.com/a/8177/26163). – dalanicolai Mar 10 '23 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 Mar 10 '23 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 Mar 10 '23 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. https://imgur.com/a/G9wyfvL – RichieHH Aug 05 '23 at 03:40

1 Answers1

2

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

(let ((vertico-sort-function nil))
  (completing-read "Prompt: " (reverse (org-babel-src-block-names))))
Arktik
  • 932
  • 4
  • 15