diff options
| author | Michael Albinus | 2014-09-07 13:02:33 +0200 |
|---|---|---|
| committer | Michael Albinus | 2014-09-07 13:02:33 +0200 |
| commit | d3cb31cbdfa38a19e9517bf817f106ee82d62986 (patch) | |
| tree | 92ac160e127c2f171b6031b5ea7e02a683b29a6c | |
| parent | 6726de52639e8c5612dd314504cb6196a0d09648 (diff) | |
| download | emacs-d3cb31cbdfa38a19e9517bf817f106ee82d62986.tar.gz emacs-d3cb31cbdfa38a19e9517bf817f106ee82d62986.zip | |
* strings.texi (Text Comparison): Describe `string-collate-equalp'
and `string-collate-lessp'.
| -rw-r--r-- | doc/lispref/ChangeLog | 5 | ||||
| -rw-r--r-- | doc/lispref/strings.texi | 97 |
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 @@ | |||
| 1 | 2014-09-07 Michael Albinus <michael.albinus@gmx.de> | ||
| 2 | |||
| 3 | * strings.texi (Text Comparison): Describe `string-collate-equalp' | ||
| 4 | and `string-collate-lessp'. | ||
| 5 | |||
| 1 | 2014-09-06 Leo Liu <sdl.web@gmail.com> | 6 | 2014-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 | ||
| 462 | This function returns @code{t} if @var{string1} and @var{string2} are | ||
| 463 | equal with respect to collation rules. A collation rule is not only | ||
| 464 | determined by the lexicographic order of the characters contained in | ||
| 465 | @var{string1} and @var{string2}, but also further rules about | ||
| 466 | relations between these characters. Usually, it is defined by the | ||
| 467 | @var{locale} environment Emacs is running with. | ||
| 468 | |||
| 469 | For example, characters with different coding points but | ||
| 470 | the same meaning might be considered as equal, like different grave | ||
| 471 | accent 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 | |||
| 480 | The optional argument @var{locale}, a string, overrides the setting of | ||
| 481 | your current locale identifier for collation. The value is system | ||
| 482 | dependent; a @var{locale} "en_US.UTF-8" is applicable on POSIX | ||
| 483 | systems, while it would be, e.g., "enu_USA.1252" on MS-Windows | ||
| 484 | systems. | ||
| 485 | |||
| 486 | If @var{IGNORE-CASE} is non-nil, characters are converted to lower-case | ||
| 487 | before comparing them. | ||
| 488 | |||
| 489 | To emulate Unicode-compliant collation on MS-Windows systems, | ||
| 490 | bind @code{w32-collate-ignore-punctuation} to a non-nil value, since | ||
| 491 | the codeset part of the locale cannot be "UTF-8" on MS-Windows. | ||
| 492 | |||
| 493 | If your system does not support a locale environment, this function | ||
| 494 | behaves like @code{string-equal}. | ||
| 495 | |||
| 496 | Do NOT use this function to compare file names for equality, only | ||
| 497 | for sorting them. | ||
| 498 | @end defun | ||
| 499 | |||
| 500 | @defun string-prefix-p string1 string2 &optional ignore-case | ||
| 501 | This 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 | ||
| 503 | the optional argument @var{ignore-case} is non-@code{nil}, the | ||
| 504 | comparison ignores case differences. | ||
| 505 | @end defun | ||
| 506 | |||
| 507 | @defun string-suffix-p suffix string &optional ignore-case | ||
| 508 | This 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 | ||
| 510 | optional argument @var{ignore-case} is non-@code{nil}, the comparison | ||
| 511 | ignores 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 | ||
| 573 | This function returns @code{t} if @var{string1} is less than | ||
| 574 | @var{string2} in collation order. A collation order is not only | ||
| 575 | determined by the lexicographic order of the characters contained in | ||
| 576 | @var{string1} and @var{string2}, but also further rules about | ||
| 577 | relations between these characters. Usually, it is defined by the | ||
| 578 | @var{locale} environment Emacs is running with. | ||
| 579 | |||
| 580 | For example, punctuation and whitespace characters might be considered | ||
| 581 | less 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 | |||
| 590 | The optional argument @var{locale}, a string, overrides the setting of | ||
| 591 | your current locale identifier for collation. The value is system | ||
| 592 | dependent; a @var{locale} "en_US.UTF-8" is applicable on POSIX | ||
| 593 | systems, while it would be, e.g., "enu_USA.1252" on MS-Windows | ||
| 594 | systems. The @var{locale} "POSIX" lets @code{string-collate-lessp} | ||
| 595 | behave 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 | |||
| 605 | If @var{IGNORE-CASE} is non-nil, characters are converted to lower-case | ||
| 606 | before comparing them. | ||
| 607 | |||
| 608 | To emulate Unicode-compliant collation on MS-Windows systems, | ||
| 609 | bind @code{w32-collate-ignore-punctuation} to a non-nil value, since | ||
| 610 | the codeset part of the locale cannot be "UTF-8" on MS-Windows. | ||
| 611 | |||
| 612 | If your system does not support a locale environment, this function | ||
| 613 | behaves 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 |
| 520 | This function returns non-@code{nil} if @var{string1} is a prefix of | 617 | This 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 |