Subject: bug#78719: 30.1; [PATCH] Add functions `string-common-prefix' and `string-try-completion'

From: Stefan Monnier <[email-masked]>
Date: Mon, 09 Jun 2025 06:48:11 -0400

> I think it is confusing if the function respects the
> `completion-regexp-list' and `completion-ignore-case' dynamic
> variables,

Strong agreement, here.  It's arguably already a problem to use those
dynbound variables in `try-completion`, so it's even worse here for
a function which wants to be unrelated to completion.

> and if we end up with three functions
> `try-completion', `string-try-completion', and
> `completions-try-completion'.
>
> Why not only provide a single function `string-expand-prefix' with
> additional keyword or optional arguments:
>
> (cl-defun string-common-prefix (strings &key ignore-case regexps predicate))

The "try completion" part of the name sounds like it's motivated by the
historical accident of how we got to it, so if we want to help those
who're not familiar with (or thinking about) completion, a name like
`string-common-prefix` sounds better, indeed.

Do we have reasons to believe callers will want/need those `&key`
arguments?  My gut tells me we don't need the `predicate` and
`regexps` options.

> (cl-defun string-common-prefix (strings &key prefix ignore-case regexps predicate))

At this point, you might as well call `try-completion`.

        Stefan