Juri Linkov writes: >> Patch which fixes this attached. > > Thanks for fixing the multi-line case. Could you please > add a test in minibuffer-tests.el. Maybe easier is > to replace '("aa" "ab" "ac") with '("aa" "a\nb" "ac"). > Or a new test would be better, I don't know. Sure. New test is easier since "a\nb" sorts before "aa", so adding the newline changes the test results. >> It simply adds an additional loop around forward-line which runs >> until we leave the completion at point. > > Alternatively without a loop maybe simpler would be just to move > to the end of the current completion before calling forward-line? I was unsure whether that would work correctly in all cases. But it seems to pass tests, so let's just try it. If it does break, the bug report will give us some new test cases :) >> BTW, I think we should have some helper functions for "get start of >> completion candidate or point-min" and "get end of completion candidate >> or point-max", or possibly "move to start of candidate" and "move to end >> of candidate"; it's pretty hard to get right. > > Completely agreed. We need more helper functions for all 4 functions: > previous-completion, next-completion, previous-line-completion, > next-line-completion. Cool, I made two helpers in the latest version of my patch. Using only in next-line-completion for now, but we can use it more in the other completion function. > BTW, do you think that these parts below are not needed anymore > since you implemented a hidden placeholder at the top > in case of no header? Yes, I think all the code for 'first-completion can be removed. Updated patch for next-line-completion: