summaryrefslogtreecommitdiff
path: root/doc/lispref/strings.texi
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2016-02-21 15:32:45 +1100
committerLars Ingebrigtsen <larsi@gnus.org>2016-02-21 15:32:45 +1100
commit71783e90a46ca913ea2c334cdc8cb24cd74055f8 (patch)
tree3c35b883caea4392789d6c991a08bb74475407ad /doc/lispref/strings.texi
parent1ba50a0d8cbef6686ecf752583832e7bbb9137ef (diff)
downloademacs-71783e90a46ca913ea2c334cdc8cb24cd74055f8.tar.gz
Add the string-numeric-lessp function
* doc/lispref/strings.texi (Text Comparison): Document `string-numerical-lessp'. * src/fns.c (Fstring_numeric_lessp): New function. (gather_number_from_string): Helper function for that function. * test/src/fns-tests.el (fns-tests-string-numeric-lessp): Add tests.
Diffstat (limited to 'doc/lispref/strings.texi')
-rw-r--r--doc/lispref/strings.texi13
1 files changed, 13 insertions, 0 deletions
diff --git a/doc/lispref/strings.texi b/doc/lispref/strings.texi
index 9d6613c522c..a3efbf2f223 100644
--- a/doc/lispref/strings.texi
+++ b/doc/lispref/strings.texi
@@ -633,6 +633,19 @@ If your system does not support a locale environment, this function
behaves like @code{string-lessp}.
@end defun
+@defun string-numerical-lessp strin1 string2
+This function behaves like @code{string-lessp} for stretches of
+consecutive non-numerical characters, but compares sequences of
+numerical characters as if they comprised a base-ten number, and then
+compares the numbers. So @samp{foo2.png} is ``smaller'' than
+@samp{foo12.png} according to this predicate, even if @samp{12} is
+lexicographically ``smaller'' than @samp{2}.
+
+If one string has a number in a position in the string, and the other
+doesn't, then lexicograpic comparison is done at that point, so
+@samp{foo.png} is ``smaller'' than @samp{foo2.png}.
+@end defun
+
@defun string-prefix-p string1 string2 &optional ignore-case
This function returns non-@code{nil} if @var{string1} is a prefix of
@var{string2}; i.e., if @var{string2} starts with @var{string1}. If