Mercurial > hg > xemacs-beta
comparison src/casefiddle.c @ 20:859a2309aef8 r19-15b93
Import from CVS: tag r19-15b93
author | cvs |
---|---|
date | Mon, 13 Aug 2007 08:50:05 +0200 |
parents | 376386a54a3c |
children | 131b0175ea99 |
comparison
equal
deleted
inserted
replaced
19:ac1f612d5250 | 20:859a2309aef8 |
---|---|
73 } | 73 } |
74 obj = wrong_type_argument (Qchar_or_string_p, obj); | 74 obj = wrong_type_argument (Qchar_or_string_p, obj); |
75 } | 75 } |
76 } | 76 } |
77 | 77 |
78 DEFUN ("upcase", Fupcase, Supcase, 1, 2, 0 /* | 78 DEFUN ("upcase", Fupcase, 1, 2, 0, /* |
79 Convert argument to upper case and return that. | 79 Convert argument to upper case and return that. |
80 The argument may be a character or string. The result has the same type. | 80 The argument may be a character or string. The result has the same type. |
81 The argument object is not altered--the value is a copy. | 81 The argument object is not altered--the value is a copy. |
82 See also `capitalize', `downcase' and `upcase-initials'. | 82 See also `capitalize', `downcase' and `upcase-initials'. |
83 Optional second arg BUFFER specifies which buffer's case tables to use, | 83 Optional second arg BUFFER specifies which buffer's case tables to use, |
84 and defaults to the current buffer. | 84 and defaults to the current buffer. |
85 */ ) | 85 */ |
86 (obj, buffer) | 86 (obj, buffer)) |
87 Lisp_Object obj, buffer; | |
88 { | 87 { |
89 return casify_object (decode_buffer (buffer, 0), CASE_UP, obj); | 88 return casify_object (decode_buffer (buffer, 0), CASE_UP, obj); |
90 } | 89 } |
91 | 90 |
92 DEFUN ("downcase", Fdowncase, Sdowncase, 1, 2, 0 /* | 91 DEFUN ("downcase", Fdowncase, 1, 2, 0, /* |
93 Convert argument to lower case and return that. | 92 Convert argument to lower case and return that. |
94 The argument may be a character or string. The result has the same type. | 93 The argument may be a character or string. The result has the same type. |
95 The argument object is not altered--the value is a copy. | 94 The argument object is not altered--the value is a copy. |
96 Optional second arg BUFFER specifies which buffer's case tables to use, | 95 Optional second arg BUFFER specifies which buffer's case tables to use, |
97 and defaults to the current buffer. | 96 and defaults to the current buffer. |
98 */ ) | 97 */ |
99 (obj, buffer) | 98 (obj, buffer)) |
100 Lisp_Object obj, buffer; | |
101 { | 99 { |
102 return casify_object (decode_buffer (buffer, 0), CASE_DOWN, obj); | 100 return casify_object (decode_buffer (buffer, 0), CASE_DOWN, obj); |
103 } | 101 } |
104 | 102 |
105 DEFUN ("capitalize", Fcapitalize, Scapitalize, 1, 2, 0 /* | 103 DEFUN ("capitalize", Fcapitalize, 1, 2, 0, /* |
106 Convert argument to capitalized form and return that. | 104 Convert argument to capitalized form and return that. |
107 This means that each word's first character is upper case | 105 This means that each word's first character is upper case |
108 and the rest is lower case. | 106 and the rest is lower case. |
109 The argument may be a character or string. The result has the same type. | 107 The argument may be a character or string. The result has the same type. |
110 The argument object is not altered--the value is a copy. | 108 The argument object is not altered--the value is a copy. |
111 Optional second arg BUFFER specifies which buffer's case tables to use, | 109 Optional second arg BUFFER specifies which buffer's case tables to use, |
112 and defaults to the current buffer. | 110 and defaults to the current buffer. |
113 */ ) | 111 */ |
114 (obj, buffer) | 112 (obj, buffer)) |
115 Lisp_Object obj, buffer; | |
116 { | 113 { |
117 return casify_object (decode_buffer (buffer, 0), CASE_CAPITALIZE, obj); | 114 return casify_object (decode_buffer (buffer, 0), CASE_CAPITALIZE, obj); |
118 } | 115 } |
119 | 116 |
120 /* Like Fcapitalize but change only the initials. */ | 117 /* Like Fcapitalize but change only the initials. */ |
121 | 118 |
122 DEFUN ("upcase-initials", Fupcase_initials, Supcase_initials, 1, 2, 0 /* | 119 DEFUN ("upcase-initials", Fupcase_initials, 1, 2, 0, /* |
123 Convert the initial of each word in the argument to upper case. | 120 Convert the initial of each word in the argument to upper case. |
124 Do not change the other letters of each word. | 121 Do not change the other letters of each word. |
125 The argument may be a character or string. The result has the same type. | 122 The argument may be a character or string. The result has the same type. |
126 The argument object is not altered--the value is a copy. | 123 The argument object is not altered--the value is a copy. |
127 Optional second arg BUFFER specifies which buffer's case tables to use, | 124 Optional second arg BUFFER specifies which buffer's case tables to use, |
128 and defaults to the current buffer. | 125 and defaults to the current buffer. |
129 */ ) | 126 */ |
130 (obj, buffer) | 127 (obj, buffer)) |
131 Lisp_Object obj, buffer; | |
132 { | 128 { |
133 return casify_object (decode_buffer (buffer, 0), CASE_CAPITALIZE_UP, obj); | 129 return casify_object (decode_buffer (buffer, 0), CASE_CAPITALIZE_UP, obj); |
134 } | 130 } |
135 | 131 |
136 /* flag is CASE_UP, CASE_DOWN or CASE_CAPITALIZE or CASE_CAPITALIZE_UP. | 132 /* flag is CASE_UP, CASE_DOWN or CASE_CAPITALIZE or CASE_CAPITALIZE_UP. |
174 inword = WORD_SYNTAX_P (syntax_table, c); | 170 inword = WORD_SYNTAX_P (syntax_table, c); |
175 } | 171 } |
176 end_multiple_change (buf, mccount); | 172 end_multiple_change (buf, mccount); |
177 } | 173 } |
178 | 174 |
179 DEFUN ("upcase-region", Fupcase_region, Supcase_region, 2, 3, "r" /* | 175 DEFUN ("upcase-region", Fupcase_region, 2, 3, "r", /* |
180 Convert the region to upper case. In programs, wants two arguments. | 176 Convert the region to upper case. In programs, wants two arguments. |
181 These arguments specify the starting and ending character numbers of | 177 These arguments specify the starting and ending character numbers of |
182 the region to operate on. When used as a command, the text between | 178 the region to operate on. When used as a command, the text between |
183 point and the mark is operated on. | 179 point and the mark is operated on. |
184 See also `capitalize-region'. | 180 See also `capitalize-region'. |
185 Optional third arg BUFFER defaults to the current buffer. | 181 Optional third arg BUFFER defaults to the current buffer. |
186 */ ) | 182 */ |
187 (b, e, buffer) | 183 (b, e, buffer)) |
188 Lisp_Object b, e, buffer; | |
189 { | 184 { |
190 /* This function can GC */ | 185 /* This function can GC */ |
191 casify_region (decode_buffer (buffer, 1), CASE_UP, b, e); | 186 casify_region (decode_buffer (buffer, 1), CASE_UP, b, e); |
192 return Qnil; | 187 return Qnil; |
193 } | 188 } |
194 | 189 |
195 DEFUN ("downcase-region", Fdowncase_region, Sdowncase_region, 2, 3, "r" /* | 190 DEFUN ("downcase-region", Fdowncase_region, 2, 3, "r", /* |
196 Convert the region to lower case. In programs, wants two arguments. | 191 Convert the region to lower case. In programs, wants two arguments. |
197 These arguments specify the starting and ending character numbers of | 192 These arguments specify the starting and ending character numbers of |
198 the region to operate on. When used as a command, the text between | 193 the region to operate on. When used as a command, the text between |
199 point and the mark is operated on. | 194 point and the mark is operated on. |
200 Optional third arg BUFFER defaults to the current buffer. | 195 Optional third arg BUFFER defaults to the current buffer. |
201 */ ) | 196 */ |
202 (b, e, buffer) | 197 (b, e, buffer)) |
203 Lisp_Object b, e, buffer; | |
204 { | 198 { |
205 /* This function can GC */ | 199 /* This function can GC */ |
206 casify_region (decode_buffer (buffer, 1), CASE_DOWN, b, e); | 200 casify_region (decode_buffer (buffer, 1), CASE_DOWN, b, e); |
207 return Qnil; | 201 return Qnil; |
208 } | 202 } |
209 | 203 |
210 DEFUN ("capitalize-region", Fcapitalize_region, Scapitalize_region, 2, 3, "r" /* | 204 DEFUN ("capitalize-region", Fcapitalize_region, 2, 3, "r", /* |
211 Convert the region to capitalized form. | 205 Convert the region to capitalized form. |
212 Capitalized form means each word's first character is upper case | 206 Capitalized form means each word's first character is upper case |
213 and the rest of it is lower case. | 207 and the rest of it is lower case. |
214 In programs, give two arguments, the starting and ending | 208 In programs, give two arguments, the starting and ending |
215 character positions to operate on. | 209 character positions to operate on. |
216 Optional third arg BUFFER defaults to the current buffer. | 210 Optional third arg BUFFER defaults to the current buffer. |
217 */ ) | 211 */ |
218 (b, e, buffer) | 212 (b, e, buffer)) |
219 Lisp_Object b, e, buffer; | |
220 { | 213 { |
221 /* This function can GC */ | 214 /* This function can GC */ |
222 casify_region (decode_buffer (buffer, 1), CASE_CAPITALIZE, b, e); | 215 casify_region (decode_buffer (buffer, 1), CASE_CAPITALIZE, b, e); |
223 return Qnil; | 216 return Qnil; |
224 } | 217 } |
225 | 218 |
226 /* Like Fcapitalize_region but change only the initials. */ | 219 /* Like Fcapitalize_region but change only the initials. */ |
227 | 220 |
228 DEFUN ("upcase-initials-region", Fupcase_initials_region, | 221 DEFUN ("upcase-initials-region", Fupcase_initials_region, 2, 3, "r", /* |
229 Supcase_initials_region, 2, 3, "r" /* | |
230 Upcase the initial of each word in the region. | 222 Upcase the initial of each word in the region. |
231 Subsequent letters of each word are not changed. | 223 Subsequent letters of each word are not changed. |
232 In programs, give two arguments, the starting and ending | 224 In programs, give two arguments, the starting and ending |
233 character positions to operate on. | 225 character positions to operate on. |
234 Optional third arg BUFFER defaults to the current buffer. | 226 Optional third arg BUFFER defaults to the current buffer. |
235 */ ) | 227 */ |
236 (b, e, buffer) | 228 (b, e, buffer)) |
237 Lisp_Object b, e, buffer; | |
238 { | 229 { |
239 casify_region (decode_buffer (buffer, 1), CASE_CAPITALIZE_UP, b, e); | 230 casify_region (decode_buffer (buffer, 1), CASE_CAPITALIZE_UP, b, e); |
240 return Qnil; | 231 return Qnil; |
241 } | 232 } |
242 | 233 |
253 | 244 |
254 *newpoint = ((BUF_PT (buf) > farend) ? BUF_PT (buf) : farend); | 245 *newpoint = ((BUF_PT (buf) > farend) ? BUF_PT (buf) : farend); |
255 return (make_int (farend)); | 246 return (make_int (farend)); |
256 } | 247 } |
257 | 248 |
258 DEFUN ("upcase-word", Fupcase_word, Supcase_word, 1, 2, "p" /* | 249 DEFUN ("upcase-word", Fupcase_word, 1, 2, "p", /* |
259 Convert following word (or ARG words) to upper case, moving over. | 250 Convert following word (or ARG words) to upper case, moving over. |
260 With negative argument, convert previous words but do not move. | 251 With negative argument, convert previous words but do not move. |
261 See also `capitalize-word'. | 252 See also `capitalize-word'. |
262 Optional second arg BUFFER defaults to the current buffer. | 253 Optional second arg BUFFER defaults to the current buffer. |
263 */ ) | 254 */ |
264 (arg, buffer) | 255 (arg, buffer)) |
265 Lisp_Object arg, buffer; | |
266 { | 256 { |
267 /* This function can GC */ | 257 /* This function can GC */ |
268 Lisp_Object beg, end; | 258 Lisp_Object beg, end; |
269 Bufpos newpoint; | 259 Bufpos newpoint; |
270 struct buffer *buf = decode_buffer (buffer, 1); | 260 struct buffer *buf = decode_buffer (buffer, 1); |
274 casify_region (buf, CASE_UP, beg, end); | 264 casify_region (buf, CASE_UP, beg, end); |
275 BUF_SET_PT (buf, newpoint); | 265 BUF_SET_PT (buf, newpoint); |
276 return Qnil; | 266 return Qnil; |
277 } | 267 } |
278 | 268 |
279 DEFUN ("downcase-word", Fdowncase_word, Sdowncase_word, 1, 2, "p" /* | 269 DEFUN ("downcase-word", Fdowncase_word, 1, 2, "p", /* |
280 Convert following word (or ARG words) to lower case, moving over. | 270 Convert following word (or ARG words) to lower case, moving over. |
281 With negative argument, convert previous words but do not move. | 271 With negative argument, convert previous words but do not move. |
282 Optional second arg BUFFER defaults to the current buffer. | 272 Optional second arg BUFFER defaults to the current buffer. |
283 */ ) | 273 */ |
284 (arg, buffer) | 274 (arg, buffer)) |
285 Lisp_Object arg, buffer; | |
286 { | 275 { |
287 /* This function can GC */ | 276 /* This function can GC */ |
288 Lisp_Object beg, end; | 277 Lisp_Object beg, end; |
289 Bufpos newpoint; | 278 Bufpos newpoint; |
290 struct buffer *buf = decode_buffer (buffer, 1); | 279 struct buffer *buf = decode_buffer (buffer, 1); |
294 casify_region (buf, CASE_DOWN, beg, end); | 283 casify_region (buf, CASE_DOWN, beg, end); |
295 BUF_SET_PT (buf, newpoint); | 284 BUF_SET_PT (buf, newpoint); |
296 return Qnil; | 285 return Qnil; |
297 } | 286 } |
298 | 287 |
299 DEFUN ("capitalize-word", Fcapitalize_word, Scapitalize_word, 1, 2, "p" /* | 288 DEFUN ("capitalize-word", Fcapitalize_word, 1, 2, "p", /* |
300 Capitalize the following word (or ARG words), moving over. | 289 Capitalize the following word (or ARG words), moving over. |
301 This gives the word(s) a first character in upper case | 290 This gives the word(s) a first character in upper case |
302 and the rest lower case. | 291 and the rest lower case. |
303 With negative argument, capitalize previous words but do not move. | 292 With negative argument, capitalize previous words but do not move. |
304 Optional second arg BUFFER defaults to the current buffer. | 293 Optional second arg BUFFER defaults to the current buffer. |
305 */ ) | 294 */ |
306 (arg, buffer) | 295 (arg, buffer)) |
307 Lisp_Object arg, buffer; | |
308 { | 296 { |
309 /* This function can GC */ | 297 /* This function can GC */ |
310 Lisp_Object beg, end; | 298 Lisp_Object beg, end; |
311 Bufpos newpoint; | 299 Bufpos newpoint; |
312 struct buffer *buf = decode_buffer (buffer, 1); | 300 struct buffer *buf = decode_buffer (buffer, 1); |
320 | 308 |
321 | 309 |
322 void | 310 void |
323 syms_of_casefiddle (void) | 311 syms_of_casefiddle (void) |
324 { | 312 { |
325 defsubr (&Supcase); | 313 DEFSUBR (Fupcase); |
326 defsubr (&Sdowncase); | 314 DEFSUBR (Fdowncase); |
327 defsubr (&Scapitalize); | 315 DEFSUBR (Fcapitalize); |
328 defsubr (&Supcase_initials); | 316 DEFSUBR (Fupcase_initials); |
329 defsubr (&Supcase_region); | 317 DEFSUBR (Fupcase_region); |
330 defsubr (&Sdowncase_region); | 318 DEFSUBR (Fdowncase_region); |
331 defsubr (&Scapitalize_region); | 319 DEFSUBR (Fcapitalize_region); |
332 defsubr (&Supcase_initials_region); | 320 DEFSUBR (Fupcase_initials_region); |
333 defsubr (&Supcase_word); | 321 DEFSUBR (Fupcase_word); |
334 defsubr (&Sdowncase_word); | 322 DEFSUBR (Fdowncase_word); |
335 defsubr (&Scapitalize_word); | 323 DEFSUBR (Fcapitalize_word); |
336 } | 324 } |