aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorEli Zaretskii2018-04-28 10:27:53 +0300
committerEli Zaretskii2018-04-28 10:27:53 +0300
commita7a3918a16c85f89d797d48b09e751ab30e0f032 (patch)
treea48809d67e91a60cbdb622f6a4145c8081d4bb1c /doc
parentc6e6503900534d939dd94b812563c27f22c49b7d (diff)
downloademacs-a7a3918a16c85f89d797d48b09e751ab30e0f032.tar.gz
emacs-a7a3918a16c85f89d797d48b09e751ab30e0f032.zip
Fix documentation and tests for 'string-distance'
* src/fns.c (Fstring_distance): Doc fix. * doc/lispref/strings.texi (Text Comparison): Document 'string-distance'. * etc/NEWS: Fix wording and mark as documented in the manuals. * test/src/fns-tests.el (test-string-distance): Move from subr-tests.el and rename.
Diffstat (limited to 'doc')
-rw-r--r--doc/lispref/strings.texi22
1 files changed, 22 insertions, 0 deletions
diff --git a/doc/lispref/strings.texi b/doc/lispref/strings.texi
index 8a9e27d00ec..70ba1aa613e 100644
--- a/doc/lispref/strings.texi
+++ b/doc/lispref/strings.texi
@@ -673,6 +673,28 @@ of the two strings. The sign is negative if @var{string1} (or its
673specified portion) is less. 673specified portion) is less.
674@end defun 674@end defun
675 675
676@cindex Levenshtein distance
677@cindex distance between strings
678@cindex edit distance between strings
679@defun string-distance string1 string2 &optional bytecompare
680This function returns the @dfn{Levenshtein distance} between the
681source string @var{string1} and the target string @var{string2}. The
682Levenshtein distance is the number of single-character
683changes---deletions, insertions, or replacements---required to
684transform the source string into the target string; it is one possible
685definition of the @dfn{edit distance} between strings.
686
687Letter-case of the strings is significant for the computed distance,
688but their text properties are ignored. If the optional argument
689@var{bytecompare} is non-@code{nil}, the function calculates the
690distance in terms of bytes instead of characters. The byte-wise
691comparison uses the internal Emacs representation of characters, so it
692will produce inaccurate results for multibyte strings that include raw
693bytes (@pxref{Text Representations}); make the strings unibyte by
694encoding them (@pxref{Explicit Encoding}) if you need accurate results
695with raw bytes.
696@end defun
697
676@defun assoc-string key alist &optional case-fold 698@defun assoc-string key alist &optional case-fold
677This function works like @code{assoc}, except that @var{key} must be a 699This function works like @code{assoc}, except that @var{key} must be a
678string or symbol, and comparison is done using @code{compare-strings}. 700string or symbol, and comparison is done using @code{compare-strings}.