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

From: Eli Zaretskii <[email-masked]>
Date: Sat, 05 Jul 2025 17:26:16 +0300

> Date: Sun, 06 Jul 2025 02:04:27 +1200
> From: Phil Sainty <[email-masked]>
> Cc: Eli Zaretskii <[email-masked]>, [email-masked],
>  [email-masked], [email-masked], [email-masked]
> 
> I'm not talking about the complexity of the functionality, but rather
> the complexity of *using* the function.
> 
> I'm arguing that if you're not trying to write completion code, it's
> horrible to have to write (and read) this:
> 
>    (let* ((completion-ignore-case nil)
>           (completion-regexp-list regexp-list)
>           (prefix (try-completion "" collection)))
>      (if (stringp prefix)
>          prefix
>        (if (eq t prefix)
>            
>          ""))))
> 
> when it can simply be:
> 
>    (string-common-prefix collection nil nil regexp-list)

I don't find the above horrible at all.  And it would be even easier
to read if rewritten as follows:

   (let* ((completion-ignore-case nil)
          (prefix (try-completion (or string "") collection)))
     (cond
       ((stringp prefix)
         prefix)
       ((eq t prefix)
         string)
       (t "")))

Why is the above "horrible" or not easy to read and understand?

I did agree that a dedicated API for finding the common prefix of a
set of strings would be better, but it should be not harder to use
than the above.