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

From: Phil Sainty <[email-masked]>
Date: Wed, 11 Jun 2025 01:51:29 +1200

> From: Phil Sainty <[email-masked]>
>> Is it ok to (eval-when-compile (require 'cl-lib)) in subr.el
>> in order to use cl-defun ?

Eli Zaretskii wrote:
> Can we please avoid that at all costs?

and Stefan Monnier wrote:
> No, it's not.  I mean, maybe there's a way to make it work, but if you
> "just do it", bootstrap will break because `cl-lib` needs `subr.el`.

Righto.  I figured the answers might well be along these lines.

> Much better to refrain from using `cl-defun`, or else move the
> definition to a later file, like `simple.el` or `subr-x.el`.

All good.

On 2025-06-11 00:15, Eli Zaretskii wrote:
> Why do we need cl-defun here, anyway?  How many arguments should these
> functions have?

There's one mandatory argument and four optional ones which
can be mixed and matched without any obvious priority sequence.
Daniel had used cl-defun when he suggested merging my original
two functions into one, and I thought that the use of keyword
args did seem like a nicer API than a regular function.

It could be a regular function, though; I don't think there
was anything *precluding* that.  I'd probably go with this
argument order if we do that:

(string-common-prefix COLLECTION &optional IGNORE-CASE STRING 
REGEXP-LIST PREDICATE)

-Phil