Subject: bug#78489: 30.1.50; Using etags, Ada and xref-find-definitions doesn't find definitions

From: Stefan Monnier <[email-masked]>
Date: Tue, 27 May 2025 10:00:29 -0400

>> procedure Hello_World is
>>    procedure Display_Message is
>>    begin
>>       Put_Line ("Hello, World!");
>>    end Display_Message;
>> begin  -- Hello_World
>>    Display_Message/p
>> end Hello_World;
>> --8<---------------cut here---------------end--------------->8---
>> 
>> As you can see above the "/p" suffix is added into the buffer as part
>> of the completion.  This is not valid syntax.  I must therefore delete
>> "/p" before adding the final semicolon.  This is what my suggested fix
>> was attempting to address...preventing the insertion of the invalid
>> suffix into the buffer.
>
> "M-x completion-at-point" is a separate command, so this is basically
> a separate issue, unrelated to our switch to Xref.  Trying this
> command in Emacs 24.4, I see that it inserts "Display_Message/p" in
> that version as well.  While I agree with you that it isn't
> user-friendly to insert the "/p" part, I'm not sure the fix should be
> in etags-tags-completion-table, because that function is called (via
> tags-completion-table-function) in more than just this scenario, and
> we could break some of those other scenarios.
>
> Maybe Ada source files should have their own specialized value for
> completion-at-point-functions?
>
> Stefan, WDYT?

I haven't had time to look closely, but IIUC those `/p` aren't
reallypart of the completed names but only some meta-info about their
nature, so it sounds like a job for `:annotation-function` (in
`completion-at-point-function`) or `annotation-function` (in the
completion table's metadata).

        Sefan