aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2014-09-07 13:02:33 +0200
committerMichael Albinus2014-09-07 13:02:33 +0200
commitd3cb31cbdfa38a19e9517bf817f106ee82d62986 (patch)
tree92ac160e127c2f171b6031b5ea7e02a683b29a6c
parent6726de52639e8c5612dd314504cb6196a0d09648 (diff)
downloademacs-d3cb31cbdfa38a19e9517bf817f106ee82d62986.tar.gz
emacs-d3cb31cbdfa38a19e9517bf817f106ee82d62986.zip
* strings.texi (Text Comparison): Describe `string-collate-equalp'
and `string-collate-lessp'.
-rw-r--r--doc/lispref/ChangeLog5
-rw-r--r--doc/lispref/strings.texi97
2 files changed, 102 insertions, 0 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog
index 7b375a7a819..185e5045be7 100644
--- a/doc/lispref/ChangeLog
+++ b/doc/lispref/ChangeLog
@@ -1,3 +1,8 @@
12014-09-07 Michael Albinus <michael.albinus@gmx.de>
2
3 * strings.texi (Text Comparison): Describe `string-collate-equalp'
4 and `string-collate-lessp'.
5
12014-09-06 Leo Liu <sdl.web@gmail.com> 62014-09-06 Leo Liu <sdl.web@gmail.com>
2 7
3 * control.texi (Pattern matching case statement): Document vector 8 * control.texi (Pattern matching case statement): Document vector
diff --git a/doc/lispref/strings.texi b/doc/lispref/strings.texi
index e6b00f06f79..5e0148b75a9 100644
--- a/doc/lispref/strings.texi
+++ b/doc/lispref/strings.texi
@@ -458,6 +458,59 @@ Representations}.
458@code{string-equal} is another name for @code{string=}. 458@code{string-equal} is another name for @code{string=}.
459@end defun 459@end defun
460 460
461@defun string-collate-equalp string1 string2 &optional locale ignore-case
462This function returns @code{t} if @var{string1} and @var{string2} are
463equal with respect to collation rules. A collation rule is not only
464determined by the lexicographic order of the characters contained in
465@var{string1} and @var{string2}, but also further rules about
466relations between these characters. Usually, it is defined by the
467@var{locale} environment Emacs is running with.
468
469For example, characters with different coding points but
470the same meaning might be considered as equal, like different grave
471accent Unicode characters:
472
473@example
474@group
475(string-collate-equalp (string ?\uFF40) (string ?\u1FEF))
476 @result{} t
477@end group
478@end example
479
480The optional argument @var{locale}, a string, overrides the setting of
481your current locale identifier for collation. The value is system
482dependent; a @var{locale} "en_US.UTF-8" is applicable on POSIX
483systems, while it would be, e.g., "enu_USA.1252" on MS-Windows
484systems.
485
486If @var{IGNORE-CASE} is non-nil, characters are converted to lower-case
487before comparing them.
488
489To emulate Unicode-compliant collation on MS-Windows systems,
490bind @code{w32-collate-ignore-punctuation} to a non-nil value, since
491the codeset part of the locale cannot be "UTF-8" on MS-Windows.
492
493If your system does not support a locale environment, this function
494behaves like @code{string-equal}.
495
496Do NOT use this function to compare file names for equality, only
497for sorting them.
498@end defun
499
500@defun string-prefix-p string1 string2 &optional ignore-case
501This function returns non-@code{nil} if @var{string1} is a prefix of
502@var{string2}; i.e., if @var{string2} starts with @var{string1}. If
503the optional argument @var{ignore-case} is non-@code{nil}, the
504comparison ignores case differences.
505@end defun
506
507@defun string-suffix-p suffix string &optional ignore-case
508This function returns non-@code{nil} if @var{suffix} is a suffix of
509@var{string}; i.e., if @var{string} ends with @var{suffix}. If the
510optional argument @var{ignore-case} is non-@code{nil}, the comparison
511ignores case differences.
512@end defun
513
461@cindex lexical comparison 514@cindex lexical comparison
462@defun string< string1 string2 515@defun string< string1 string2
463@c (findex string< causes problems for permuted index!!) 516@c (findex string< causes problems for permuted index!!)
@@ -516,6 +569,50 @@ are used.
516@code{string-lessp} is another name for @code{string<}. 569@code{string-lessp} is another name for @code{string<}.
517@end defun 570@end defun
518 571
572@defun string-collate-lessp string1 string2 &optional locale ignore-case
573This function returns @code{t} if @var{string1} is less than
574@var{string2} in collation order. A collation order is not only
575determined by the lexicographic order of the characters contained in
576@var{string1} and @var{string2}, but also further rules about
577relations between these characters. Usually, it is defined by the
578@var{locale} environment Emacs is running with.
579
580For example, punctuation and whitespace characters might be considered
581less significant for @ref{Sorting,,sorting}.
582
583@example
584@group
585(sort '("11" "12" "1 1" "1 2" "1.1" "1.2") 'string-collate-lessp)
586 @result{} ("11" "1 1" "1.1" "12" "1 2" "1.2")
587@end group
588@end example
589
590The optional argument @var{locale}, a string, overrides the setting of
591your current locale identifier for collation. The value is system
592dependent; a @var{locale} "en_US.UTF-8" is applicable on POSIX
593systems, while it would be, e.g., "enu_USA.1252" on MS-Windows
594systems. The @var{locale} "POSIX" lets @code{string-collate-lessp}
595behave like @code{string-lessp}:
596
597@example
598@group
599(sort '("11" "12" "1 1" "1 2" "1.1" "1.2")
600 (lambda (s1 s2) (string-collate-lessp s1 s2 "POSIX")))
601 @result{} ("1 1" "1 2" "1.1" "1.2" "11" "12")
602@end group
603@end example
604
605If @var{IGNORE-CASE} is non-nil, characters are converted to lower-case
606before comparing them.
607
608To emulate Unicode-compliant collation on MS-Windows systems,
609bind @code{w32-collate-ignore-punctuation} to a non-nil value, since
610the codeset part of the locale cannot be "UTF-8" on MS-Windows.
611
612If your system does not support a locale environment, this function
613behaves like @code{string-lessp}.
614@end defun
615
519@defun string-prefix-p string1 string2 &optional ignore-case 616@defun string-prefix-p string1 string2 &optional ignore-case
520This function returns non-@code{nil} if @var{string1} is a prefix of 617This function returns non-@code{nil} if @var{string1} is a prefix of
521@var{string2}; i.e., if @var{string2} starts with @var{string1}. If 618@var{string2}; i.e., if @var{string2} starts with @var{string1}. If