aboutsummaryrefslogtreecommitdiffstats
path: root/doc/lispref
diff options
context:
space:
mode:
Diffstat (limited to 'doc/lispref')
-rw-r--r--doc/lispref/minibuf.texi3
-rw-r--r--doc/lispref/strings.texi37
2 files changed, 40 insertions, 0 deletions
diff --git a/doc/lispref/minibuf.texi b/doc/lispref/minibuf.texi
index 9d73aa89b2d..066bfc79718 100644
--- a/doc/lispref/minibuf.texi
+++ b/doc/lispref/minibuf.texi
@@ -965,6 +965,9 @@ too short). Both of those begin with the string @samp{foobar}.
965 @result{} "foobar" 965 @result{} "foobar"
966@end group 966@end group
967@end smallexample 967@end smallexample
968
969 See also the function @code{string-common-prefix} in
970@ref{Creating Strings}.
968@end defun 971@end defun
969 972
970@defun all-completions string collection &optional predicate 973@defun all-completions string collection &optional predicate
diff --git a/doc/lispref/strings.texi b/doc/lispref/strings.texi
index 44be529d562..caa29747ff5 100644
--- a/doc/lispref/strings.texi
+++ b/doc/lispref/strings.texi
@@ -248,6 +248,43 @@ equivalent to 0. Thus, @w{@code{(substring-no-properties
248properties removed. 248properties removed.
249@end defun 249@end defun
250 250
251@cindex common prefix of a collection of strings
252@cindex string completion
253@defun string-common-prefix strings &optional ignore-case
254This function returns the longest initial substring common to all
255members of @var{strings}. It returns an empty string if there is no
256common prefix or if @var{strings} is @code{nil}. If @var{strings}
257contains exactly one string, it returns that string.
258
259@example
260(string-common-prefix '("foobar" "foozot"))
261 @result{} "foo"
262(string-common-prefix '("foobar" "foozot" "gazonk"))
263 @result{} ""
264(string-common-prefix '("foobar"))
265 @result{} "foobar"
266@end example
267
268If @var{ignore-case} is non-@code{nil}, letter case is ignored when
269matching the substrings, but no guarantee is made about the letter-case
270of the return value, except that it comes from one of the members of
271@var{strings}.
272
273@var{strings} may be a list of strings or any other collection type
274supported by @code{try-completion} and @code{all-completions}
275(@pxref{Basic Completion}). This function is similar to
276@code{try-completion}, but always returns a string. The filtering
277features of the completion functions (by string prefix, regular
278expression, and predicate function) are available using
279@code{all-completions}:
280
281@example
282(string-common-prefix (all-completions
283 "foo" '("foobar" "foobaz" "gazonk")))
284 @result{} "fooba"
285@end example
286@end defun
287
251@defun concat &rest sequences 288@defun concat &rest sequences
252@cindex copying strings 289@cindex copying strings
253@cindex concatenating strings 290@cindex concatenating strings