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

From: Phil Sainty <[email-masked]>
Date: Tue, 10 Jun 2025 21:30:04 +1200

On 2025-06-09 22:56, Daniel Mendler wrote:

> Stefan Monnier <[email-masked]> writes:
> > 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.
> 
> Yes, I think it makes sense to only offer the simplest
> function without additional features, since the goal is a
> simpler API after all to obtain common prefixes.
> 
> (defun string-common-prefix (strings &key ignore-case))
> 
> If additional completion features are needed, we can refer
> the user to `try-completion' in the docstring or the manual.

We essentially get that extra functionality for free, so I see
no reason not to leverage that by supporting it in the new
function.

My original two-function approach was to provide that 'simplest'
function while also ensuring that the extra features were still
available without callers having to account for the various
non-string return values from `try-completion'.  So I don't like
the idea of `try-completion' being the only option for someone
who wants to use the extra features.

I'm happy to go with the single function approach, as the
cl-defun approach keeps the API simple in the simple case, but
I think the extra keywords should be supported.  I'm happy to
implement that.

Is it ok to (eval-when-compile (require 'cl-lib)) in subr.el
in order to use cl-defun ?

-Phil