Stefan Kangas writes: > Spencer Baugh via "Bug reports for GNU Emacs, the Swiss army knife of > text editors" writes: > >> Nope, no user-facing behavior changes. In fact, this probably shouldn't >> be user-customizable at all, since it's an internal optimization with >> essentially no cost. So I've changed this into a defvar >> completions--insert-lazily. > > SGTM, but I have a question: > > What happens on very large displays? Is 200 always going to be enough > completions? I imagine some users will be doing unusual things like > having the completion buffer take up their whole 42" 5K monitor. > > So should this perhaps be calculated dynamically based on the geometry > of the window, somehow? Yes, good point, it definitely should be calculated dynamically. The easiest way to do this correctly is to insert completion candidates until we have at least frame-height lines in the *Completions* buffer. Then no matter how the window gets resized afterwards (and it will indeed be resized, by fit-window-to-buffer) there will be enough completion candidates that the displayed part of the window is full. I've done this in the attached patch. In the process, I realized that this optimization doesn't help completions-format=vertical without a lot of effort, since that fills the entire first column before continuing to the second column. That's fine, the optimization works for other values of completions-format, and I can straightforwardly extend the optimization to completions-format=vertical in later changes. I've also updated NEWS to be more clear about the lack of user-facing behavior changes. BTW, the current implementation uses throw and catch to interrupt the process of inserting completions when enough have been inserted. This opens up the possibility of further optimization later: instead of throwing the symbol "truncated" as I do now, I could throw a function, a continuation which could be called to continue inserting the completions from where I left off. That would avoid duplicating some work, and therefore make things even faster.