Subject: bug#17139: Race condition in complete-in-region: should we be using pre-command-hook, not post-command-hook?

From: Daniel Colascione <[email-masked]>
Date: Mon, 31 Mar 2014 11:20:21 -0700

On 03/31/2014 05:40 AM, Stefan Monnier wrote:
>> Come to think of it, supplying a function instead of a simple list of
>> strings as the completion table returned from the completion function
>> would probably help too, since then completion-in-region--postch could
>> inspect the first element of the returned list (the completion region
>> start) without having to actually "force the promise" and resolve the
>> whole list after every command.
> 
> Exactly: completion-in-region--postch does not need to know the
> candidates.  If you need a subprocess to get the list of candidates,
> then foo-at-point-function is usually not the right place/time to build
> this list, you should use completion-table-dynamic,
> completion-table-with-cache, or something like that instead.

I've added some recommendations to this effect to the manual.