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

From: Stefan Monnier <[email-masked]>
Date: Sun, 01 Jun 2025 18:19:31 -0400

> Seems to do the job, thanks.  Maybe Troy could try this for a while
> and report back.

Yes, I'd like to hear confirmation that it fixes the concrete case that
Try was interested in.

> Btw, maybe I don't understand what 'finished' means in the documentation
> of :exit-function, but it's somewhat confusing:
>
>                     ‘finished’ if text is now complete, ‘sole’ if the
>           text cannot be further completed but completion is not
>           finished, or ‘exact’ if the text is a valid completion but may
>           be further completed.

Yes, I'm not sure how to write that (or even if those choices are
relevant).

IIRC `sole` is used for example when completing `/h` to `/home/` where
we expect that further completion will take place because we're
expecting an actual file.  `exact` is similar but when completing `M-x
dif` to `M-x diff`, where maybe this is the final completion but maybe
the user will continue to, say, `M-x diff-refine-hunk`.

In contrast `finished` is when the recently inserted completion seems to
be really "final".
In selection UIs, `M-x diff` would also be `finished`, since the user
presumably chose explicitly that entry instead of `diff-refine-hunk`.

> What we want here is to "edit" the completion before it is passed to
> the function that inserts it into the buffer.  The description of
> :exit-function doesn't make it clear at what point in the completion
> process will the function be called -- is that only when the user
> "exits the completion", i.e. under the same conditions that
> minibuffer-exit-hook is called (when completing in the minibuffer)?

For `finished` yes: the expectation is that user "exits" the completion.
This can be more or less difficult to formalize in the UI depending on
the UI.  E.g. for `completion-at-point` there is often no clear user
action that marks the "end" of a completion "session".

For `exact` and `sole`, on the other hand, the expectation is that the
completion session may not be over yet.

        Stefan