[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Sorting Order of Completion Candidates

From: Drew Adams
Subject: RE: Sorting Order of Completion Candidates
Date: Mon, 28 Feb 2011 17:25:46 -0800

> While writing some code to index my notes I have run into a problem.
> I have a carefully crafted list of keywords sorted in order of 
> frequency. (When assigning new keywords I want to consider the most 
> frequent keywords first.) However
> (completing-read "Prompt: " '("a" "c" "b"))  gives me
>  Possible completions are:
>  a
>  b
>  c
> whereas I want
>  Possible completions are:
>  a
>  c
>  b
> If there is no option or hook, if guess I could just modify the 
> *Completions* buffer. Any hints how/where it is set up?

1. Stefan can probably steer you as to how to do what you want with a recent
version of vanilla Emacs.

2. An alternative is to use Icicles.  Then all you need to do is bind
`icicle-sort-comparer' to nil around the call to `completing-read'.  A nil value
means do not sort.  (You can also customize `icicle-sort-comparer' to use any
default sort order you like.)

You can also change sort orders on the fly anytime during completion, and that
includes turning sorting off: hit `C-,' to cycle to the next sort order for the
current completion type.  (One of the sort orders is unsorted (off).)

Sorting is particularly important for Icicles because it affects the order of
candidate cycling.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]