Mercurial > emacs
comparison lispref/strings.texi @ 49600:23a1cea22d13
Trailing whitespace deleted.
author | Juanma Barranquero <lekktu@gmail.com> |
---|---|
date | Tue, 04 Feb 2003 14:56:31 +0000 |
parents | 4e9db7a710f8 |
children | 337c29aec7ce d7ddb3e565de |
comparison
equal
deleted
inserted
replaced
49599:5ade352e8d1c | 49600:23a1cea22d13 |
---|---|
1 @c -*-texinfo-*- | 1 @c -*-texinfo-*- |
2 @c This is part of the GNU Emacs Lisp Reference Manual. | 2 @c This is part of the GNU Emacs Lisp Reference Manual. |
3 @c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1998, 1999 | 3 @c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1998, 1999 |
4 @c Free Software Foundation, Inc. | 4 @c Free Software Foundation, Inc. |
5 @c See the file elisp.texi for copying conditions. | 5 @c See the file elisp.texi for copying conditions. |
6 @setfilename ../info/strings | 6 @setfilename ../info/strings |
7 @node Strings and Characters, Lists, Numbers, Top | 7 @node Strings and Characters, Lists, Numbers, Top |
8 @comment node-name, next, previous, up | 8 @comment node-name, next, previous, up |
9 @chapter Strings and Characters | 9 @chapter Strings and Characters |
156 from the string @code{"abcdefg"}. The index 3 marks the character | 156 from the string @code{"abcdefg"}. The index 3 marks the character |
157 position up to which the substring is copied. The character whose index | 157 position up to which the substring is copied. The character whose index |
158 is 3 is actually the fourth character in the string. | 158 is 3 is actually the fourth character in the string. |
159 | 159 |
160 A negative number counts from the end of the string, so that @minus{}1 | 160 A negative number counts from the end of the string, so that @minus{}1 |
161 signifies the index of the last character of the string. For example: | 161 signifies the index of the last character of the string. For example: |
162 | 162 |
163 @example | 163 @example |
164 @group | 164 @group |
165 (substring "abcdefg" -3 -1) | 165 (substring "abcdefg" -3 -1) |
166 @result{} "ef" | 166 @result{} "ef" |
408 (string< "abc" "") | 408 (string< "abc" "") |
409 @result{} nil | 409 @result{} nil |
410 (string< "abc" "ab") | 410 (string< "abc" "ab") |
411 @result{} nil | 411 @result{} nil |
412 (string< "" "") | 412 (string< "" "") |
413 @result{} nil | 413 @result{} nil |
414 @end group | 414 @end group |
415 @end example | 415 @end example |
416 @end defun | 416 @end defun |
417 | 417 |
418 @defun string-lessp string1 string2 | 418 @defun string-lessp string1 string2 |
595 formatting feature described here; they differ from @code{format} only | 595 formatting feature described here; they differ from @code{format} only |
596 in how they use the result of formatting. | 596 in how they use the result of formatting. |
597 | 597 |
598 @defun format string &rest objects | 598 @defun format string &rest objects |
599 This function returns a new string that is made by copying | 599 This function returns a new string that is made by copying |
600 @var{string} and then replacing any format specification | 600 @var{string} and then replacing any format specification |
601 in the copy with encodings of the corresponding @var{objects}. The | 601 in the copy with encodings of the corresponding @var{objects}. The |
602 arguments @var{objects} are the computed values to be formatted. | 602 arguments @var{objects} are the computed values to be formatted. |
603 | 603 |
604 The characters in @var{string}, other than the format specifications, | 604 The characters in @var{string}, other than the format specifications, |
605 are copied directly into the output; starting in Emacs 21, if they have | 605 are copied directly into the output; starting in Emacs 21, if they have |
705 @result{} "The name of this buffer is strings.texi." | 705 @result{} "The name of this buffer is strings.texi." |
706 | 706 |
707 (format "The buffer object prints as %s." (current-buffer)) | 707 (format "The buffer object prints as %s." (current-buffer)) |
708 @result{} "The buffer object prints as strings.texi." | 708 @result{} "The buffer object prints as strings.texi." |
709 | 709 |
710 (format "The octal value of %d is %o, | 710 (format "The octal value of %d is %o, |
711 and the hex value is %x." 18 18 18) | 711 and the hex value is %x." 18 18 18) |
712 @result{} "The octal value of 18 is 22, | 712 @result{} "The octal value of 18 is 22, |
713 and the hex value is 12." | 713 and the hex value is 12." |
714 @end group | 714 @end group |
715 @end example | 715 @end example |
716 | 716 |
717 @cindex numeric prefix | 717 @cindex numeric prefix |
743 of 7. In the first case, the string inserted in place of @samp{%7s} has | 743 of 7. In the first case, the string inserted in place of @samp{%7s} has |
744 only 3 letters, so 4 blank spaces are inserted for padding. In the | 744 only 3 letters, so 4 blank spaces are inserted for padding. In the |
745 second case, the string @code{"specification"} is 13 letters wide but is | 745 second case, the string @code{"specification"} is 13 letters wide but is |
746 not truncated. In the third case, the padding is on the right. | 746 not truncated. In the third case, the padding is on the right. |
747 | 747 |
748 @smallexample | 748 @smallexample |
749 @group | 749 @group |
750 (format "The word `%7s' actually has %d letters in it." | 750 (format "The word `%7s' actually has %d letters in it." |
751 "foo" (length "foo")) | 751 "foo" (length "foo")) |
752 @result{} "The word ` foo' actually has 3 letters in it." | 752 @result{} "The word ` foo' actually has 3 letters in it." |
753 @end group | 753 @end group |
754 | 754 |
755 @group | 755 @group |
756 (format "The word `%7s' actually has %d letters in it." | 756 (format "The word `%7s' actually has %d letters in it." |
757 "specification" (length "specification")) | 757 "specification" (length "specification")) |
758 @result{} "The word `specification' actually has 13 letters in it." | 758 @result{} "The word `specification' actually has 13 letters in it." |
759 @end group | 759 @end group |
760 | 760 |
761 @group | 761 @group |
762 (format "The word `%-7s' actually has %d letters in it." | 762 (format "The word `%-7s' actually has %d letters in it." |
763 "foo" (length "foo")) | 763 "foo" (length "foo")) |
764 @result{} "The word `foo ' actually has 3 letters in it." | 764 @result{} "The word `foo ' actually has 3 letters in it." |
765 @end group | 765 @end group |
766 @end smallexample | 766 @end smallexample |
767 | 767 |
768 @node Case Conversion | 768 @node Case Conversion |
769 @comment node-name, next, previous, up | 769 @comment node-name, next, previous, up |
770 @section Case Conversion in Lisp | 770 @section Case Conversion in Lisp |
771 @cindex upper case | 771 @cindex upper case |
772 @cindex lower case | 772 @cindex lower case |
773 @cindex character case | 773 @cindex character case |
774 @cindex case conversion in Lisp | 774 @cindex case conversion in Lisp |
775 | 775 |
776 The character case functions change the case of single characters or | 776 The character case functions change the case of single characters or |
777 of the contents of strings. The functions normally convert only | 777 of the contents of strings. The functions normally convert only |
778 alphabetic characters (the letters @samp{A} through @samp{Z} and | 778 alphabetic characters (the letters @samp{A} through @samp{Z} and |