annotate man/lispref/strings.texi @ 284:558f606b08ae r21-0b40

Import from CVS: tag r21-0b40
author cvs
date Mon, 13 Aug 2007 10:34:13 +0200
parents 7df0dd720c89
children 54f7aa390f4f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 @c -*-texinfo-*-
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 @c This is part of the XEmacs Lisp Reference Manual.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 @c Copyright (C) 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 @c See the file lispref.texi for copying conditions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 @setfilename ../../info/strings.info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 @node Strings and Characters, Lists, Numbers, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 @chapter Strings and Characters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 @cindex strings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 @cindex character arrays
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 @cindex characters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 @cindex bytes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 A string in XEmacs Lisp is an array that contains an ordered sequence
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 of characters. Strings are used as names of symbols, buffers, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 files, to send messages to users, to hold text being copied between
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 buffers, and for many other purposes. Because strings are so important,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 XEmacs Lisp has many functions expressly for manipulating them. XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 Lisp programs use strings more often than individual characters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 * Basics: String Basics. Basic properties of strings and characters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 * Predicates for Strings:: Testing whether an object is a string or char.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 * Creating Strings:: Functions to allocate new strings.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 * Predicates for Characters:: Testing whether an object is a character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 * Character Codes:: Each character has an equivalent integer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 * Text Comparison:: Comparing characters or strings.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 * String Conversion:: Converting characters or strings and vice versa.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 * Modifying Strings:: Changing characters in a string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 * String Properties:: Additional information attached to strings.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 * Formatting Strings:: @code{format}: XEmacs's analog of @code{printf}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 * Character Case:: Case conversion functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 * Case Tables:: Customizing case conversion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 * Char Tables:: Mapping from characters to Lisp objects.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 @node String Basics
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 @section String and Character Basics
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 Strings in XEmacs Lisp are arrays that contain an ordered sequence of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 characters. Characters are their own primitive object type in XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 20. However, in XEmacs 19, characters are represented in XEmacs Lisp as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 integers; whether an integer was intended as a character or not is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 determined only by how it is used. @xref{Character Type}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 The length of a string (like any array) is fixed and independent of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 the string contents, and cannot be altered. Strings in Lisp are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 @emph{not} terminated by a distinguished character code. (By contrast,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 strings in C are terminated by a character with @sc{ASCII} code 0.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 This means that any character, including the null character (@sc{ASCII}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 code 0), is a valid element of a string.@refill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 Since strings are considered arrays, you can operate on them with the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 general array functions. (@xref{Sequences Arrays Vectors}.) For
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 example, you can access or change individual characters in a string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 using the functions @code{aref} and @code{aset} (@pxref{Array
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 Functions}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 Strings use an efficient representation for storing the characters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 in them, and thus take up much less memory than a vector of the same
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 length.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 Sometimes you will see strings used to hold key sequences. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 exists for backward compatibility with Emacs 18, but should @emph{not}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 be used in new code, since many key chords can't be represented at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 all and others (in particular meta key chords) are confused with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 accented characters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 @ignore @c Not accurate any more
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 Each character in a string is stored in a single byte. Therefore,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 numbers not in the range 0 to 255 are truncated when stored into a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 string. This means that a string takes up much less memory than a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 vector of the same length.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 Sometimes key sequences are represented as strings. When a string is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 a key sequence, string elements in the range 128 to 255 represent meta
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 characters (which are extremely large integers) rather than keyboard
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 events in the range 128 to 255.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 Strings cannot hold characters that have the hyper, super or alt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 modifiers; they can hold @sc{ASCII} control characters, but no other
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 control characters. They do not distinguish case in @sc{ASCII} control
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 characters. @xref{Character Type}, for more information about
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 representation of meta and other modifiers for keyboard input
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 characters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 @end ignore
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 Strings are useful for holding regular expressions. You can also
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 match regular expressions against strings (@pxref{Regexp Search}). The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 functions @code{match-string} (@pxref{Simple Match Data}) and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 @code{replace-match} (@pxref{Replacing Match}) are useful for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 decomposing and modifying strings based on regular expression matching.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 Like a buffer, a string can contain extents in it. These extents are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 created when a function such as @code{buffer-substring} is called on a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 region with duplicable extents in it. When the string is inserted into
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 a buffer, the extents are inserted along with it. @xref{Duplicable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 Extents}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 @xref{Text}, for information about functions that display strings or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 copy them into buffers. @xref{Character Type}, and @ref{String Type},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 for information about the syntax of characters and strings.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 @node Predicates for Strings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 @section The Predicates for Strings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 For more information about general sequence and array predicates,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 see @ref{Sequences Arrays Vectors}, and @ref{Arrays}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 @defun stringp object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 This function returns @code{t} if @var{object} is a string, @code{nil}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 otherwise.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 @defun char-or-string-p object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 This function returns @code{t} if @var{object} is a string or a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 character, @code{nil} otherwise.
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 110
diff changeset
117
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 110
diff changeset
118 In XEmacs addition, this function also returns @code{t} if @var{object}
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 110
diff changeset
119 is an integer that can be represented as a character. This is because
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 110
diff changeset
120 of compatibility with previous XEmacs and should not be depended on.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 @node Creating Strings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 @section Creating Strings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 The following functions create strings, either from scratch, or by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 putting strings together, or by taking them apart.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 110
diff changeset
129 @defun string &rest characters
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 280
diff changeset
130 This function returns a new string made up of @var{characters}.
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 110
diff changeset
131
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 110
diff changeset
132 @example
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 110
diff changeset
133 (string ?X ?E ?m ?a ?c ?s)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 110
diff changeset
134 @result{} "XEmacs"
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 110
diff changeset
135 (string)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 110
diff changeset
136 @result{} ""
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 110
diff changeset
137 @end example
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 110
diff changeset
138
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 110
diff changeset
139 Analogous functions operating on other data types include @code{list},
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 110
diff changeset
140 @code{cons} (@pxref{Building Lists}), @code{vector} (@pxref{Vectors})
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 110
diff changeset
141 and @code{bit-vector} (@pxref{Bit Vectors}). This function has not been
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 110
diff changeset
142 available in XEmacs prior to 21.0 and FSF Emacs prior to 20.3.
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 110
diff changeset
143 @end defun
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 110
diff changeset
144
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 @defun make-string count character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 This function returns a string made up of @var{count} repetitions of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 @var{character}. If @var{count} is negative, an error is signaled.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (make-string 5 ?x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 @result{} "xxxxx"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (make-string 0 ?x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 @result{} ""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 Other functions to compare with this one include @code{char-to-string}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (@pxref{String Conversion}), @code{make-vector} (@pxref{Vectors}), and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 @code{make-list} (@pxref{Building Lists}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 @defun substring string start &optional end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 This function returns a new string which consists of those characters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 from @var{string} in the range from (and including) the character at the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 index @var{start} up to (but excluding) the character at the index
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 @var{end}. The first character is at index zero.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (substring "abcdefg" 0 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 @result{} "abc"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 Here the index for @samp{a} is 0, the index for @samp{b} is 1, and the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 index for @samp{c} is 2. Thus, three letters, @samp{abc}, are copied
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 from the string @code{"abcdefg"}. The index 3 marks the character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 position up to which the substring is copied. The character whose index
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 is 3 is actually the fourth character in the string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 A negative number counts from the end of the string, so that @minus{}1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 signifies the index of the last character of the string. For example:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (substring "abcdefg" -3 -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 @result{} "ef"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 In this example, the index for @samp{e} is @minus{}3, the index for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 @samp{f} is @minus{}2, and the index for @samp{g} is @minus{}1.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 Therefore, @samp{e} and @samp{f} are included, and @samp{g} is excluded.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 When @code{nil} is used as an index, it stands for the length of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 string. Thus,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (substring "abcdefg" -3 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 @result{} "efg"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 Omitting the argument @var{end} is equivalent to specifying @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 It follows that @code{(substring @var{string} 0)} returns a copy of all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 of @var{string}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (substring "abcdefg" 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 @result{} "abcdefg"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 But we recommend @code{copy-sequence} for this purpose (@pxref{Sequence
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 Functions}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 If the characters copied from @var{string} have duplicable extents or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 text properties, those are copied into the new string also.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 @xref{Duplicable Extents}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 A @code{wrong-type-argument} error is signaled if either @var{start} or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 @var{end} is not an integer or @code{nil}. An @code{args-out-of-range}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 error is signaled if @var{start} indicates a character following
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 @var{end}, or if either integer is out of range for @var{string}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 Contrast this function with @code{buffer-substring} (@pxref{Buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 Contents}), which returns a string containing a portion of the text in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 the current buffer. The beginning of a string is at index 0, but the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 beginning of a buffer is at index 1.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 @defun concat &rest sequences
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 @cindex copying strings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 @cindex concatenating strings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 This function returns a new string consisting of the characters in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 arguments passed to it (along with their text properties, if any). The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 arguments may be strings, lists of numbers, or vectors of numbers; they
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 are not themselves changed. If @code{concat} receives no arguments, it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 returns an empty string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (concat "abc" "-def")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 @result{} "abc-def"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (concat "abc" (list 120 (+ 256 121)) [122])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 @result{} "abcxyz"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 ;; @r{@code{nil} is an empty sequence.}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (concat "abc" nil "-def")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 @result{} "abc-def"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (concat "The " "quick brown " "fox.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 @result{} "The quick brown fox."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (concat)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 @result{} ""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 The second example above shows how characters stored in strings are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 taken modulo 256. In other words, each character in the string is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 stored in one byte.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 The @code{concat} function always constructs a new string that is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 not @code{eq} to any existing string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 When an argument is an integer (not a sequence of integers), it is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 converted to a string of digits making up the decimal printed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 representation of the integer. @strong{Don't use this feature; we plan
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 to eliminate it. If you already use this feature, change your programs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 now!} The proper way to convert an integer to a decimal number in this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 way is with @code{format} (@pxref{Formatting Strings}) or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 @code{number-to-string} (@pxref{String Conversion}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (concat 137)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 @result{} "137"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (concat 54 321)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 @result{} "54321"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 For information about other concatenation functions, see the description
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 of @code{mapconcat} in @ref{Mapping Functions}, @code{vconcat} in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 @ref{Vectors}, @code{bvconcat} in @ref{Bit Vectors}, and @code{append}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 in @ref{Building Lists}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 @node Predicates for Characters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 @section The Predicates for Characters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 @defun characterp object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 This function returns @code{t} if @var{object} is a character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 Some functions that work on integers (e.g. the comparison functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 <, <=, =, /=, etc. and the arithmetic functions +, -, *, etc.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 accept characters and implicitly convert them into integers. In
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 general, functions that work on characters also accept char-ints and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 implicitly convert them into characters. WARNING: Neither of these
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 behaviors is very desirable, and they are maintained for backward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 compatibility with old E-Lisp programs that confounded characters and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 integers willy-nilly. These behaviors may change in the future; therefore,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 do not rely on them. Instead, convert the characters explicitly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 using @code{char-int}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 @defun integer-or-char-p object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 This function returns @code{t} if @var{object} is an integer or character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 @node Character Codes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 @section Character Codes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 @defun char-int ch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 This function converts a character into an equivalent integer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 The resulting integer will always be non-negative. The integers in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 the range 0 - 255 map to characters as follows:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 @table @asis
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 @item 0 - 31
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 Control set 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 @item 32 - 127
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 @sc{ASCII}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 @item 128 - 159
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 Control set 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 @item 160 - 255
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 Right half of ISO-8859-1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 If support for @sc{MULE} does not exist, these are the only valid
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 character values. When @sc{MULE} support exists, the values assigned to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 other characters may vary depending on the particular version of XEmacs,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 the order in which character sets were loaded, etc., and you should not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 depend on them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 @defun int-char integer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 This function converts an integer into the equivalent character. Not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 all integers correspond to valid characters; use @code{char-int-p} to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 determine whether this is the case. If the integer cannot be converted,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 @code{nil} is returned.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 @defun char-int-p object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 This function returns @code{t} if @var{object} is an integer that can be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 converted into a character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 @defun char-or-char-int-p object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 This function returns @code{t} if @var{object} is a character or an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 integer that can be converted into one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 @need 2000
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 @node Text Comparison
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 @section Comparison of Characters and Strings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 @cindex string equality
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 @defun char-equal character1 character2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 This function returns @code{t} if the arguments represent the same
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 character, @code{nil} otherwise. This function ignores differences
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 in case if @code{case-fold-search} is non-@code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (char-equal ?x ?x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 @result{} t
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
368 (let ((case-fold-search t))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
369 (char-equal ?x ?X))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 @result{} t
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
371 (let ((case-fold-search nil))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
372 (char-equal ?x ?X))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
373 @result{} nil
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
374 @end example
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
375 @end defun
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
376
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
377 @defun char= character1 character2
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
378 This function returns @code{t} if the arguments represent the same
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
379 character, @code{nil} otherwise. Case is significant.
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
380
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
381 @example
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
382 (char= ?x ?x)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
383 @result{} t
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
384 (char= ?x ?X)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
385 @result{} nil
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
386 (let ((case-fold-search t))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
387 (char-equal ?x ?X))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
388 @result{} nil
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
389 (let ((case-fold-search nil))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
390 (char-equal ?x ?X))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 70
diff changeset
391 @result{} nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 @defun string= string1 string2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 This function returns @code{t} if the characters of the two strings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 match exactly; case is significant.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (string= "abc" "abc")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 @result{} t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (string= "abc" "ABC")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 @result{} nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 (string= "ab" "ABC")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 @result{} nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 @ignore @c `equal' in XEmacs does not compare text properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 The function @code{string=} ignores the text properties of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 two strings. To compare strings in a way that compares their text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 properties also, use @code{equal} (@pxref{Equality Predicates}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 @end ignore
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 @defun string-equal string1 string2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 @code{string-equal} is another name for @code{string=}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 @cindex lexical comparison
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 @defun string< string1 string2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 @c (findex string< causes problems for permuted index!!)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 This function compares two strings a character at a time. First it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 scans both the strings at once to find the first pair of corresponding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 characters that do not match. If the lesser character of those two is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 the character from @var{string1}, then @var{string1} is less, and this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 function returns @code{t}. If the lesser character is the one from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 @var{string2}, then @var{string1} is greater, and this function returns
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 @code{nil}. If the two strings match entirely, the value is @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 Pairs of characters are compared by their @sc{ASCII} codes. Keep in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 mind that lower case letters have higher numeric values in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 @sc{ASCII} character set than their upper case counterparts; numbers and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 many punctuation characters have a lower numeric value than upper case
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 letters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (string< "abc" "abd")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 @result{} t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (string< "abd" "abc")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 @result{} nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (string< "123" "abc")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 @result{} t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 When the strings have different lengths, and they match up to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 length of @var{string1}, then the result is @code{t}. If they match up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 to the length of @var{string2}, the result is @code{nil}. A string of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 no characters is less than any other string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (string< "" "abc")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 @result{} t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (string< "ab" "abc")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 @result{} t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (string< "abc" "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 @result{} nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (string< "abc" "ab")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 @result{} nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (string< "" "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 @result{} nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 @defun string-lessp string1 string2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 @code{string-lessp} is another name for @code{string<}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 See also @code{compare-buffer-substrings} in @ref{Comparing Text}, for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 a way to compare text in buffers. The function @code{string-match},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 which matches a regular expression against a string, can be used
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 for a kind of string comparison; see @ref{Regexp Search}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 @node String Conversion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 @section Conversion of Characters and Strings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 @cindex conversion of strings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 This section describes functions for conversions between characters,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 strings and integers. @code{format} and @code{prin1-to-string}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (@pxref{Output Functions}) can also convert Lisp objects into strings.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 @code{read-from-string} (@pxref{Input Functions}) can ``convert'' a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 string representation of a Lisp object into an object.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 @xref{Documentation}, for functions that produce textual descriptions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 of text characters and general input events
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 (@code{single-key-description} and @code{text-char-description}). These
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 functions are used primarily for making help messages.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 @defun char-to-string character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 @cindex character to string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 This function returns a new string with a length of one character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 The value of @var{character}, modulo 256, is used to initialize the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 element of the string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 This function is similar to @code{make-string} with an integer argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 of 1. (@xref{Creating Strings}.) This conversion can also be done with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 @code{format} using the @samp{%c} format specification.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (@xref{Formatting Strings}.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (char-to-string ?x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 @result{} "x"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (char-to-string (+ 256 ?x))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 @result{} "x"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (make-string 1 ?x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 @result{} "x"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 @defun string-to-char string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 @cindex string to character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 This function returns the first character in @var{string}. If the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 string is empty, the function returns 0. (Under XEmacs 19, the value is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 also 0 when the first character of @var{string} is the null character,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 @sc{ASCII} code 0.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 (string-to-char "ABC")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 @result{} ?A ;; @r{Under XEmacs 20.}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 @result{} 65 ;; @r{Under XEmacs 19.}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 (string-to-char "xyz")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 @result{} ?x ;; @r{Under XEmacs 20.}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 @result{} 120 ;; @r{Under XEmacs 19.}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 (string-to-char "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 @result{} 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 (string-to-char "\000")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 @result{} ?\^@ ;; @r{Under XEmacs 20.}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 @result{} 0 ;; @r{Under XEmacs 20.}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 This function may be eliminated in the future if it does not seem useful
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 enough to retain.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 @defun number-to-string number
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 @cindex integer to string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 @cindex integer to decimal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 This function returns a string consisting of the printed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 representation of @var{number}, which may be an integer or a floating
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 point number. The value starts with a sign if the argument is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 negative.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 (number-to-string 256)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 @result{} "256"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 (number-to-string -23)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 @result{} "-23"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 (number-to-string -23.5)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 @result{} "-23.5"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 @cindex int-to-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 @code{int-to-string} is a semi-obsolete alias for this function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 See also the function @code{format} in @ref{Formatting Strings}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 110
diff changeset
561 @defun string-to-number string &optional base
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 @cindex string to number
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 This function returns the numeric value of the characters in
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 110
diff changeset
564 @var{string}, read in @var{base}. It skips spaces and tabs at the
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 beginning of @var{string}, then reads as much of @var{string} as it can
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 interpret as a number. (On some systems it ignores other whitespace at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 the beginning, not just spaces and tabs.) If the first character after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 the ignored whitespace is not a digit or a minus sign, this function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 returns 0.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 110
diff changeset
571 If @var{base} is not specified, it defaults to ten. With @var{base}
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 110
diff changeset
572 other than ten, only integers can be read.
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 110
diff changeset
573
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 (string-to-number "256")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 @result{} 256
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 (string-to-number "25 is a perfect square.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 @result{} 25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (string-to-number "X256")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 @result{} 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (string-to-number "-4.5")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 @result{} -4.5
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 110
diff changeset
583 (string-to-number "ffff" 16)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 110
diff changeset
584 @result{} 65535
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 @findex string-to-int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 @code{string-to-int} is an obsolete alias for this function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 @node Modifying Strings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 @section Modifying Strings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 @cindex strings, modifying
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 You can modify a string using the general array-modifying primitives.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 @xref{Arrays}. The function @code{aset} modifies a single character;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 the function @code{fillarray} sets all characters in the string to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 a specified character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 Each string has a tick counter that starts out at zero (when the string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 is created) and is incremented each time a change is made to that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 @defun string-modified-tick string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 This function returns the tick counter for @samp{string}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 @node String Properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 @section String Properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 @cindex string properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 @cindex properties of strings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 Similar to symbols, extents, faces, and glyphs, you can attach
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 additional information to strings in the form of @dfn{string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 properties}. These differ from text properties, which are logically
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 attached to particular characters in the string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 To attach a property to a string, use @code{put}. To retrieve a property
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 from a string, use @code{get}. You can also use @code{remprop} to remove
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 a property from a string and @code{object-props} to retrieve a list of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 all the properties in a string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 @node Formatting Strings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 @section Formatting Strings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 @cindex formatting strings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 @cindex strings, formatting them
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 @dfn{Formatting} means constructing a string by substitution of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 computed values at various places in a constant string. This string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 controls how the other values are printed as well as where they appear;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 it is called a @dfn{format string}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 Formatting is often useful for computing messages to be displayed. In
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 fact, the functions @code{message} and @code{error} provide the same
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 formatting feature described here; they differ from @code{format} only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 in how they use the result of formatting.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 @defun format string &rest objects
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 This function returns a new string that is made by copying
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 @var{string} and then replacing any format specification
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 in the copy with encodings of the corresponding @var{objects}. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 arguments @var{objects} are the computed values to be formatted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 @cindex @samp{%} in format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 @cindex format specification
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 A format specification is a sequence of characters beginning with a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 @samp{%}. Thus, if there is a @samp{%d} in @var{string}, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 @code{format} function replaces it with the printed representation of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 one of the values to be formatted (one of the arguments @var{objects}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 For example:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 (format "The value of fill-column is %d." fill-column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 @result{} "The value of fill-column is 72."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 If @var{string} contains more than one format specification, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 format specifications correspond with successive values from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 @var{objects}. Thus, the first format specification in @var{string}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 uses the first such value, the second format specification uses the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 second such value, and so on. Any extra format specifications (those
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 for which there are no corresponding values) cause unpredictable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 behavior. Any extra values to be formatted are ignored.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 Certain format specifications require values of particular types.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 However, no error is signaled if the value actually supplied fails to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 have the expected type. Instead, the output is likely to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 meaningless.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 Here is a table of valid format specifications:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 @table @samp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 @item %s
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 Replace the specification with the printed representation of the object,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 made without quoting. Thus, strings are represented by their contents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 alone, with no @samp{"} characters, and symbols appear without @samp{\}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 characters. This is equivalent to printing the object with @code{princ}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 If there is no corresponding object, the empty string is used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 @item %S
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 Replace the specification with the printed representation of the object,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 made with quoting. Thus, strings are enclosed in @samp{"} characters,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 and @samp{\} characters appear where necessary before special characters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 This is equivalent to printing the object with @code{prin1}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 If there is no corresponding object, the empty string is used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 @item %o
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 @cindex integer to octal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 Replace the specification with the base-eight representation of an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 integer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 @item %d
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 @itemx %i
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 Replace the specification with the base-ten representation of an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 integer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 @item %x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 @cindex integer to hexadecimal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 Replace the specification with the base-sixteen representation of an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 integer, using lowercase letters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 @item %X
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 @cindex integer to hexadecimal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 Replace the specification with the base-sixteen representation of an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 integer, using uppercase letters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 @item %c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 Replace the specification with the character which is the value given.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 @item %e
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 Replace the specification with the exponential notation for a floating
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 point number (e.g. @samp{7.85200e+03}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 @item %f
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 Replace the specification with the decimal-point notation for a floating
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 point number.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 @item %g
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 Replace the specification with notation for a floating point number,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 using a ``pretty format''. Either exponential notation or decimal-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 notation will be used (usually whichever is shorter), and trailing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 zeroes are removed from the fractional part.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 @item %%
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 A single @samp{%} is placed in the string. This format specification is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 unusual in that it does not use a value. For example, @code{(format "%%
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 %d" 30)} returns @code{"% 30"}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 Any other format character results in an @samp{Invalid format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 operation} error.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 Here are several examples:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 (format "The name of this buffer is %s." (buffer-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 @result{} "The name of this buffer is strings.texi."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 (format "The buffer object prints as %s." (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 @result{} "The buffer object prints as #<buffer strings.texi>."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 (format "The octal value of %d is %o,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 and the hex value is %x." 18 18 18)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 @result{} "The octal value of 18 is 22,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 and the hex value is 12."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 There are many additional flags and specifications that can occur
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 between the @samp{%} and the format character, in the following order:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 @enumerate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 An optional repositioning specification, which is a positive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 integer followed by a @samp{$}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 Zero or more of the optional flag characters @samp{-}, @samp{+},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 @samp{ }, @samp{0}, and @samp{#}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 @item
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 110
diff changeset
768 An asterisk (@samp{*}, meaning that the field width is now assumed to
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 110
diff changeset
769 have been specified as an argument.
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 110
diff changeset
770
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 110
diff changeset
771 @item
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 An optional minimum field width.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 An optional precision, preceded by a @samp{.} character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 @end enumerate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 @cindex repositioning format arguments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 @cindex multilingual string formatting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 A @dfn{repositioning} specification changes which argument to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 @code{format} is used by the current and all following format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 specifications. Normally the first specification uses the first
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 argument, the second specification uses the second argument, etc. Using
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 a repositioning specification, you can change this. By placing a number
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 @var{N} followed by a @samp{$} between the @samp{%} and the format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 character, you cause the specification to use the @var{N}th argument.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 The next specification will use the @var{N}+1'th argument, etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 For example:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 (format "Can't find file `%s' in directory `%s'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 "ignatius.c" "loyola/")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 @result{} "Can't find file `ignatius.c' in directory `loyola/'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 (format "In directory `%2$s', the file `%1$s' was not found."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 "ignatius.c" "loyola/")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 @result{} "In directory `loyola/', the file `ignatius.c' was not found."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 (format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 "The numbers %d and %d are %1$x and %x in hex and %1$o and %o in octal."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 37 12)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 @result{} "The numbers 37 and 12 are 25 and c in hex and 45 and 14 in octal."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 As you can see, this lets you reprocess arguments more than once or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 reword a format specification (thereby moving the arguments around)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 without having to actually reorder the arguments. This is especially
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 useful in translating messages from one language to another: Different
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 languages use different word orders, and this sometimes entails changing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 the order of the arguments. By using repositioning specifications,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 this can be accomplished without having to embed knowledge of particular
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 languages into the location in the program's code where the message is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 displayed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 @cindex numeric prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 @cindex field width
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 @cindex padding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 All the specification characters allow an optional numeric prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 between the @samp{%} and the character, and following any repositioning
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 specification or flag. The optional numeric prefix defines the minimum
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 width for the object. If the printed representation of the object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 contains fewer characters than this, then it is padded. The padding is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 normally on the left, but will be on the right if the @samp{-} flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 character is given. The padding character is normally a space, but if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 the @samp{0} flag character is given, zeros are used for padding.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 (format "%06d is padded on the left with zeros" 123)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 @result{} "000123 is padded on the left with zeros"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 (format "%-6d is padded on the right" 123)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 @result{} "123 is padded on the right"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 @code{format} never truncates an object's printed representation, no
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 matter what width you specify. Thus, you can use a numeric prefix to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 specify a minimum spacing between columns with no risk of losing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 information.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 In the following three examples, @samp{%7s} specifies a minimum width
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 of 7. In the first case, the string inserted in place of @samp{%7s} has
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 only 3 letters, so 4 blank spaces are inserted for padding. In the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 second case, the string @code{"specification"} is 13 letters wide but is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 not truncated. In the third case, the padding is on the right.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 @smallexample
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 (format "The word `%7s' actually has %d letters in it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 "foo" (length "foo"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 @result{} "The word ` foo' actually has 3 letters in it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 (format "The word `%7s' actually has %d letters in it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 "specification" (length "specification"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 @result{} "The word `specification' actually has 13 letters in it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 (format "The word `%-7s' actually has %d letters in it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 "foo" (length "foo"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 @result{} "The word `foo ' actually has 3 letters in it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 @end smallexample
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 @cindex format precision
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 @cindex precision of formatted numbers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 After any minimum field width, a precision may be specified by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 preceding it with a @samp{.} character. The precision specifies the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 minimum number of digits to appear in @samp{%d}, @samp{%i}, @samp{%o},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 @samp{%x}, and @samp{%X} conversions (the number is padded on the left
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 with zeroes as necessary); the number of digits printed after the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 decimal point for @samp{%f}, @samp{%e}, and @samp{%E} conversions; the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 number of significant digits printed in @samp{%g} and @samp{%G}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 conversions; and the maximum number of non-padding characters printed in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 @samp{%s} and @samp{%S} conversions. The default precision for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 floating-point conversions is six.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 The other flag characters have the following meanings:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 @itemize @bullet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 The @samp{ } flag means prefix non-negative numbers with a space.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 The @samp{+} flag means prefix non-negative numbers with a plus sign.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 The @samp{#} flag means print numbers in an alternate, more verbose
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 format: octal numbers begin with zero; hex numbers begin with a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 @samp{0x} or @samp{0X}; a decimal point is printed in @samp{%f},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 @samp{%e}, and @samp{%E} conversions even if no numbers are printed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 after it; and trailing zeroes are not omitted in @samp{%g} and @samp{%G}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 conversions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 @end itemize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 @node Character Case
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 @section Character Case
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 @cindex upper case
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 @cindex lower case
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 @cindex character case
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 The character case functions change the case of single characters or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 of the contents of strings. The functions convert only alphabetic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 characters (the letters @samp{A} through @samp{Z} and @samp{a} through
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 @samp{z}); other characters are not altered. The functions do not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 modify the strings that are passed to them as arguments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 The examples below use the characters @samp{X} and @samp{x} which have
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 @sc{ASCII} codes 88 and 120 respectively.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 @defun downcase string-or-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 This function converts a character or a string to lower case.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 When the argument to @code{downcase} is a string, the function creates
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 and returns a new string in which each letter in the argument that is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 upper case is converted to lower case. When the argument to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 @code{downcase} is a character, @code{downcase} returns the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 corresponding lower case character. (This value is actually an integer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 under XEmacs 19.) If the original character is lower case, or is not a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 letter, then the value equals the original character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 (downcase "The cat in the hat")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 @result{} "the cat in the hat"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 (downcase ?X)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 @result{} ?x ;; @r{Under XEmacs 20.}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 @result{} 120 ;; @r{Under XEmacs 19.}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 @defun upcase string-or-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 This function converts a character or a string to upper case.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 When the argument to @code{upcase} is a string, the function creates
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 and returns a new string in which each letter in the argument that is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 lower case is converted to upper case.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 When the argument to @code{upcase} is a character, @code{upcase} returns
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 the corresponding upper case character. (This value is actually an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 integer under XEmacs 19.) If the original character is upper case, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 is not a letter, then the value equals the original character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 (upcase "The cat in the hat")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 @result{} "THE CAT IN THE HAT"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 (upcase ?x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 @result{} ?X ;; @r{Under XEmacs 20.}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 @result{} 88 ;; @r{Under XEmacs 19.}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 @defun capitalize string-or-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 @cindex capitalization
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 This function capitalizes strings or characters. If
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 @var{string-or-char} is a string, the function creates and returns a new
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 string, whose contents are a copy of @var{string-or-char} in which each
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 word has been capitalized. This means that the first character of each
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 word is converted to upper case, and the rest are converted to lower
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 case.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 The definition of a word is any sequence of consecutive characters that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 are assigned to the word constituent syntax class in the current syntax
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 table (@xref{Syntax Class Table}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 When the argument to @code{capitalize} is a character, @code{capitalize}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 has the same result as @code{upcase}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 (capitalize "The cat in the hat")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 @result{} "The Cat In The Hat"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 (capitalize "THE 77TH-HATTED CAT")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 @result{} "The 77th-Hatted Cat"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 (capitalize ?x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 @result{} ?X ;; @r{Under XEmacs 20.}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 @result{} 88 ;; @r{Under XEmacs 19.}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 @node Case Tables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 @section The Case Table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 You can customize case conversion by installing a special @dfn{case
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994 table}. A case table specifies the mapping between upper case and lower
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 case letters. It affects both the string and character case conversion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996 functions (see the previous section) and those that apply to text in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 buffer (@pxref{Case Changes}). You need a case table if you are using a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 language which has letters other than the standard @sc{ASCII} letters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000 A case table is a list of this form:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 (@var{downcase} @var{upcase} @var{canonicalize} @var{equivalences})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007 where each element is either @code{nil} or a string of length 256. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008 element @var{downcase} says how to map each character to its lower-case
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 equivalent. The element @var{upcase} maps each character to its
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 upper-case equivalent. If lower and upper case characters are in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 one-to-one correspondence, use @code{nil} for @var{upcase}; then XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 deduces the upcase table from @var{downcase}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 For some languages, upper and lower case letters are not in one-to-one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 correspondence. There may be two different lower case letters with the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 same upper case equivalent. In these cases, you need to specify the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 maps for both directions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 The element @var{canonicalize} maps each character to a canonical
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 equivalent; any two characters that are related by case-conversion have
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 the same canonical equivalent character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 The element @var{equivalences} is a map that cyclicly permutes each
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 equivalence class (of characters with the same canonical equivalent).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 (For ordinary @sc{ASCII}, this would map @samp{a} into @samp{A} and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 @samp{A} into @samp{a}, and likewise for each set of equivalent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027 characters.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 When you construct a case table, you can provide @code{nil} for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 @var{canonicalize}; then Emacs fills in this string from @var{upcase}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 and @var{downcase}. You can also provide @code{nil} for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032 @var{equivalences}; then Emacs fills in this string from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 @var{canonicalize}. In a case table that is actually in use, those
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 components are non-@code{nil}. Do not try to specify @var{equivalences}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 without also specifying @var{canonicalize}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 Each buffer has a case table. XEmacs also has a @dfn{standard case
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 table} which is copied into each buffer when you create the buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039 Changing the standard case table doesn't affect any existing buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041 Here are the functions for working with case tables:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 @defun case-table-p object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044 This predicate returns non-@code{nil} if @var{object} is a valid case
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 table.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048 @defun set-standard-case-table table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049 This function makes @var{table} the standard case table, so that it will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050 apply to any buffers created subsequently.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 @defun standard-case-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 This returns the standard case table.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057 @defun current-case-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058 This function returns the current buffer's case table.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061 @defun set-case-table table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 This sets the current buffer's case table to @var{table}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065 The following three functions are convenient subroutines for packages
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066 that define non-@sc{ASCII} character sets. They modify a string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067 @var{downcase-table} provided as an argument; this should be a string to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1068 be used as the @var{downcase} part of a case table. They also modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069 the standard syntax table. @xref{Syntax Tables}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1070
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071 @defun set-case-syntax-pair uc lc downcase-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072 This function specifies a pair of corresponding letters, one upper case
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073 and one lower case.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076 @defun set-case-syntax-delims l r downcase-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077 This function makes characters @var{l} and @var{r} a matching pair of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078 case-invariant delimiters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1079 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081 @defun set-case-syntax char syntax downcase-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082 This function makes @var{char} case-invariant, with syntax
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083 @var{syntax}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086 @deffn Command describe-buffer-case-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087 This command displays a description of the contents of the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088 buffer's case table.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091 @cindex ISO Latin 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092 @pindex iso-syntax
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1093 You can load the library @file{iso-syntax} to set up the standard syntax
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094 table and define a case table for the 8-bit ISO Latin 1 character set.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096 @node Char Tables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097 @section The Char Table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099 A char table is a table that maps characters (or ranges of characters)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100 to values. Char tables are specialized for characters, only allowing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101 particular sorts of ranges to be assigned values. Although this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102 loses in generality, it makes for extremely fast (constant-time)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1103 lookups, and thus is feasible for applications that do an extremely
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1104 large number of lookups (e.g. scanning a buffer for a character in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1105 a particular syntax, where a lookup in the syntax table must occur
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1106 once per character).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1107
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108 Note that char tables as a primitive type, and all of the functions in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109 this section, exist only in XEmacs 20. In XEmacs 19, char tables are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1110 generally implemented using a vector of 256 elements.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112 When @sc{MULE} support exists, the types of ranges that can be assigned
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1113 values are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1114
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1115 @itemize @bullet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1116 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1117 all characters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1118 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1119 an entire charset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1120 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1121 a single row in a two-octet charset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1123 a single character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1124 @end itemize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1125
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1126 When @sc{MULE} support is not present, the types of ranges that can be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127 assigned values are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129 @itemize @bullet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131 all characters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133 a single character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134 @end itemize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136 @defun char-table-p object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137 This function returns non-@code{nil} if @var{object} is a char table.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1141 * Char Table Types:: Char tables have different uses.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1142 * Working With Char Tables:: Creating and working with char tables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1143 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1145 @node Char Table Types
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146 @subsection Char Table Types
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148 Each char table type is used for a different purpose and allows different
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149 sorts of values. The different char table types are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1150
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1151 @table @code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152 @item category
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153 Used for category tables, which specify the regexp categories
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154 that a character is in. The valid values are @code{nil} or a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155 bit vector of 95 elements. Higher-level Lisp functions are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156 provided for working with category tables. Currently categories
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1157 and category tables only exist when @sc{MULE} support is present.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158 @item char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159 A generalized char table, for mapping from one character to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160 another. Used for case tables, syntax matching tables,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161 @code{keyboard-translate-table}, etc. The valid values are characters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162 @item generic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163 An even more generalized char table, for mapping from a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164 character to anything.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165 @item display
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166 Used for display tables, which specify how a particular character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167 is to appear when displayed. #### Not yet implemented.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168 @item syntax
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169 Used for syntax tables, which specify the syntax of a particular
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1170 character. Higher-level Lisp functions are provided for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171 working with syntax tables. The valid values are integers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174 @defun char-table-type table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175 This function returns the type of char table @var{table}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1176 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1178 @defun char-table-type-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1179 This function returns a list of the recognized char table types.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1180 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1181
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1182 @defun valid-char-table-type-p type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1183 This function returns @code{t} if @var{type} if a recognized char table type.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1185
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1186 @node Working With Char Tables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1187 @subsection Working With Char Tables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1188
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1189 @defun make-char-table type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1190 This function makes a new, empty char table of type @var{type}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1191 @var{type} should be a symbol, one of @code{char}, @code{category},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1192 @code{display}, @code{generic}, or @code{syntax}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1194
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195 @defun put-char-table range val table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196 This function sets the value for chars in @var{range} to be @var{val} in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197 @var{table}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1198
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1199 @var{range} specifies one or more characters to be affected and should be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1200 one of the following:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1201
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1202 @itemize @bullet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1203 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1204 @code{t} (all characters are affected)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1205 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1206 A charset (only allowed when @sc{MULE} support is present)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1207 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1208 A vector of two elements: a two-octet charset and a row number
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1209 (only allowed when @sc{MULE} support is present)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1210 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1211 A single character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1212 @end itemize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1213
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1214 @var{val} must be a value appropriate for the type of @var{table}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1215 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1216
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1217 @defun get-char-table ch table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1218 This function finds the value for char @var{ch} in @var{table}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1219 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1220
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1221 @defun get-range-char-table range table &optional multi
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1222 This function finds the value for a range in @var{table}. If there is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1223 more than one value, @var{multi} is returned (defaults to @code{nil}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1224 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1225
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1226 @defun reset-char-table table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1227 This function resets a char table to its default state.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1229
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1230 @defun map-char-table function table &optional range
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231 This function maps @var{function} over entries in @var{table}, calling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1232 it with two args, each key and value in the table.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1233
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234 @var{range} specifies a subrange to map over and is in the same format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235 as the @var{range} argument to @code{put-range-table}. If omitted or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1236 @code{t}, it defaults to the entire table.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1239 @defun valid-char-table-value-p value char-table-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1240 This function returns non-@code{nil} if @var{value} is a valid value for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241 @var{char-table-type}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1242 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1243
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1244 @defun check-valid-char-table-value value char-table-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245 This function signals an error if @var{value} is not a valid value for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1246 @var{char-table-type}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1247 @end defun