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 #20 received at 78719 <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: Daniel Mendler <mail <at> daniel-mendler.de>, Phil Sainty <psainty <at> orcon.net.nz>
Cc: Eli Zaretskii <eliz <at> gnu.org>,
 "78719 <at> debbugs.gnu.org" <78719 <at> debbugs.gnu.org>,
 Stefan Monnier <monnier <at> iro.umontreal.ca>, "juri <at> linkov.net" <juri <at> linkov.net>
Subject: RE: [External] : Re: 30.1; [PATCH] Add functions
 `string-common-prefix' and `string-try-completion'
Date: Sun, 8 Jun 2025 23:30:59 +0000
> >> What is the purpose of having a separate function
> >> `string-try-completion'?
> >
> > The purpose was just to keep `string-common-prefix' as simple as
> > possible without people then needing to go back to `try-completion'
> > if they wanted the more complicated features.
> 
> Okay, but for more features people can always fall back to
> `try-completion'. What I find problematic are the dynamic variables
> `completion-regexp-list' and `completion-ignore-case'. They should
> rather be passed as arguments, such that the function is self-contained
> and decoupled from the completion variables.
> 
> >> (cl-defun string-common-prefix (strings &key prefix ignore-case
> >> regexps predicate))
> >
> > Yes, offhand that seems fine as well.
> >
> > I don't think I have a preference.
> 
> If this works for you, I think it is better to go with a single function
> instead of adding multiple new variants of rarely used functions.

This all sounds good to me.
___

FWIW (very minor) -

I agree it's good to have a function that always returns a
string, and "" is the right thing to return for that.  But
for testing purposes, i.e., if you want to do something
different when there's no common prefix, you have to test
using `string-empty-p'.  If nil were returned, you could
just test with `null'/`not'.





This bug report was last modified 5 days ago.

Previous Next


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