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

From: Daniel Mendler <mail <at> daniel-mendler.de>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Phil Sainty <psainty <at> orcon.net.nz>, eliz <at> gnu.org, 78719 <at> debbugs.gnu.org,
 drew.adams <at> oracle.com, juri <at> linkov.net
Subject: Re: bug#78719: 30.1; [PATCH] Add functions `string-common-prefix'
 and `string-try-completion'
Date: Mon, 09 Jun 2025 12:56:42 +0200
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

>> I think it is confusing if the function respects the
>> `completion-regexp-list' and `completion-ignore-case' dynamic
>> variables,
>
> Strong agreement, here.  It's arguably already a problem to use those
> dynbound variables in `try-completion`, so it's even worse here for
> a function which wants to be unrelated to completion.

Yes, exactly. I always wondered why these variables are dynamic, since I
think of them as additional arguments to `try-completion' and
`all-completions'. Historical reasons? Would it make sense to change
their calling convention, or do you feel that such a change would be too
intrusive? Probably it is not worth the effort. But in any case, we
should avoid the mistake for the new function in the string namespace.

>> and if we end up with three functions
>> `try-completion', `string-try-completion', and
>> `completions-try-completion'.
>>
>> Why not only provide a single function `string-expand-prefix' with
>> additional keyword or optional arguments:
>>
>> (cl-defun string-common-prefix (strings &key ignore-case regexps predicate))
>
> The "try completion" part of the name sounds like it's motivated by the
> historical accident of how we got to it, so if we want to help those
> who're not familiar with (or thinking about) completion, a name like
> `string-common-prefix` sounds better, indeed.

+1

> 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.

>         Stefan




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.