GNU bug report logs - #78719
30.1; [PATCH] Add functions `string-common-prefix' and `string-try-completion'

Previous Next

Package: emacs;

Reported by: Phil Sainty <psainty <at> orcon.net.nz>

Date: Sun, 8 Jun 2025 12:05:01 UTC

Severity: normal

Tags: patch

Found in version 30.1

Full log


Message #74 received at 78719 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Phil Sainty <psainty <at> orcon.net.nz>
Cc: mail <at> daniel-mendler.de, juri <at> linkov.net, monnier <at> iro.umontreal.ca,
 drew.adams <at> oracle.com, 78719 <at> debbugs.gnu.org
Subject: Re: bug#78719: 30.1; [PATCH] Add functions `string-common-prefix'
 and `string-try-completion'
Date: Sat, 05 Jul 2025 17:26:16 +0300
> Date: Sun, 06 Jul 2025 02:04:27 +1200
> From: Phil Sainty <psainty <at> orcon.net.nz>
> Cc: Eli Zaretskii <eliz <at> gnu.org>, monnier <at> iro.umontreal.ca,
>  78719 <at> debbugs.gnu.org, drew.adams <at> oracle.com, juri <at> linkov.net
> 
> 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.




This bug report was last modified 57 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.