Subject: bug#29833: icomplete re-build the completion table after each key press

From: Lars Ingebrigtsen <[email-masked]>
Date: Mon, 21 Sep 2020 16:27:38 +0200

Shuguang Sun <[email-masked]> writes:

> I tired to find out the issues and provide patches to minibuffer.el and icomplete.el.
>
> What is the issue?
> 1. The function completion--flush-all-sorted-completions defined in minibuffer.el is
> always called without parameters which make it flush the cached table every
> time.
> 2. The function completion--flush-all-sorted-completions is added to the hook of
> after-change-functions, however, (jit-lock-after-change t) in the hook will trigger
> flush every time
> 3. The local cached table completion-all-sorted-completions is not used actually.
> The minibuffer-completion-table is called in a lot of function which will rebuild the
> table instead of the chached table.

[...]

> The patches try to use the cached table completion-all-sorted-completions-table as
> much as possible, and for filename completion, it caches the list of files in the base
> directory (file-name-directory).

This patch unfortunately got no response when it was posted two years
ago, and it no longer applies cleanly to Emacs 28.

I'm not very familiar with the completion functions, but I think your
changes make conceptual sense, at least.  Perhaps Stefan can provide
some feedback here?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no