From c6ecba08dd2b0e48a5e4db9959c693f14af382cc Mon Sep 17 00:00:00 2001 From: Phil Sainty Date: Sun, 29 Jun 2025 14:28:51 +1200 Subject: [PATCH] fixup! Subsume `string-try-completion' into `string-common-prefix' --- doc/lispref/strings.texi | 28 +++++++++++++++------------- lisp/subr.el | 14 ++++++++------ 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/doc/lispref/strings.texi b/doc/lispref/strings.texi index 54a170d258d..ba2f56b91b5 100644 --- a/doc/lispref/strings.texi +++ b/doc/lispref/strings.texi @@ -261,12 +261,6 @@ contains exactly one string, it returns that string. @result{} "foo" @end example -This is similar to @code{try-completion} (@pxref{Basic Completion}), -except that it always returns a string. - -@var{collection} may be a list of strings or any other value supported -by @code{try-completion}. - If @var{ignore-case} is non-@code{nil}, letter case is ignored when matching the substrings, but no guarantee is made about the letter-case of the return value, except that it comes from one of the members of @@ -288,9 +282,9 @@ are ignored. @result{} "foo" @end example -If @var{regexp-list} is non-@code{nil}, it is used as -@code{completion-regexp-list}, and any members of @var{collection} which -do not match all of the regular expressions in this list are ignored. +If @var{regexp-list} is non-@code{nil}, any members of @var{collection} +which do not match all of the regular expressions in this list are +ignored. @example (string-common-prefix '("foobar" "foozot" "gazonk") "f" nil '("z")) @@ -299,10 +293,18 @@ do not match all of the regular expressions in this list are ignored. If @var{predicate} is non-@code{nil}, it must be a function to which each member of @var{collection} will be passed, and any members for -which @var{predicate} returns @code{nil} are ignored. See -@code{try-completion} (@pxref{Basic Completion}) for details of how the -@var{predicate} argument is used for different types of -@var{collection}. +which @var{predicate} returns @code{nil} are ignored. When +@var{collection} is a list of strings, the function receives a single +string argument. + +@var{collection} may be a list of strings or any other value supported +by @code{try-completion} (@pxref{Basic Completion}). The requirements +for a @var{predicate} function vary depending on the @var{collection} +type; refer to @code{try-completion} for details of using different +@var{collection} types. + +This function is similar to @code{try-completion}, but always returns a +string. @end defun @defun concat &rest sequences diff --git a/lisp/subr.el b/lisp/subr.el index f84fb125a8f..60ea8ca4148 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -6019,18 +6019,20 @@ the longest common prefix for the remaining members. If STRING is non-nil, this is the minimum required prefix, and any members of COLLECTION which do not start with STRING are ignored. -If REGEXP-LIST is non-nil, it is used as `completion-regexp-list', -and any members of COLLECTION which do not match all of the regular -expressions in this list are ignored. +If REGEXP-LIST is non-nil, any members of COLLECTION which do not match +all of the regular expressions in this list are ignored. If PREDICATE is non-nil, it must be a function to which each member of COLLECTION will be passed, and any members for which PREDICATE returns -nil are ignored. See `try-completion' for more details. +nil are ignored. When COLLECTION is a list of strings, the function +receives a single string argument. COLLECTION may be a list of strings or any other value supported by -`try-completion'. +`try-completion'. The requirements for a PREDICATE function vary +depending on the COLLECTION type; refer to `try-completion' for details +of using different COLLECTION types. -This function is similar to `try-completion', but always returning a +This function is similar to `try-completion', but always returns a string." ;; Note that `try-completion' is not affected by `completion-styles'. (let* ((completion-ignore-case ignore-case)