Subject: bug#54374: 29.0.50; previous-completion fails at beginning of completions buffer

From: Juri Linkov <[email-masked]>
Date: Sat, 19 Mar 2022 21:13:14 +0200

>> Thanks, this fixed the issue.  And I noticed another one: at the
>> beginning of the buffer previous-completion wraps to the end of the buffer,
>> not to the beginning of the last completion.
>>
>> Also when point at the last completion, next-completion
>> jumps to the end of the buffer instead of wrapping to the
>> first completion.
>
> I cannot replicate this issue in every case, but only if the last option
> has completion annotation.  It should be fixable by checking for these
> kinds of edge-cases, but it might also be better to reconsider if
> next-completion should be using `mouse-face' for navigation, or if a
> special text property might be more elegant?

I agree that `mouse-face' is unsuitable for detecting the completion
boundaries, and it causes other problems: typing RET on the completion prefix
or on the completion suffix/annotation causes the error:

  Debugger entered--Lisp error: (error "No completion here")
    error("No completion here")
    choose-completion(13 nil)
    funcall-interactively(choose-completion 13 nil)
    command-execute(choose-completion)

So a special text property could also help to detect the completion for RET,
if there are no such text properties already.  But I see there is the
text property 'completion--string'.  So maybe it could be extended to cover
prefix and suffix/annotation as well.