Mercurial > emacs
annotate src/casefiddle.c @ 17872:31b2c6763574
(num_nonmacro_input_events):
Renamed from num_nonmacro_input_chars.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 19 May 1997 02:44:57 +0000 |
parents | 380442ed6a1c |
children | ad95aa134d60 |
rev | line source |
---|---|
118 | 1 /* GNU Emacs case conversion functions. |
7307 | 2 Copyright (C) 1985, 1994 Free Software Foundation, Inc. |
118 | 3 |
4 This file is part of GNU Emacs. | |
5 | |
6 GNU Emacs is free software; you can redistribute it and/or modify | |
7 it under the terms of the GNU General Public License as published by | |
12244 | 8 the Free Software Foundation; either version 2, or (at your option) |
118 | 9 any later version. |
10 | |
11 GNU Emacs is distributed in the hope that it will be useful, | |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 GNU General Public License for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
17 along with GNU Emacs; see the file COPYING. If not, write to | |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14063
diff
changeset
|
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14063
diff
changeset
|
19 Boston, MA 02111-1307, USA. */ |
118 | 20 |
21 | |
4696
1fc792473491
Include <config.h> instead of "config.h".
Roland McGrath <roland@gnu.org>
parents:
2822
diff
changeset
|
22 #include <config.h> |
118 | 23 #include "lisp.h" |
24 #include "buffer.h" | |
17816 | 25 #include "charset.h" |
118 | 26 #include "commands.h" |
27 #include "syntax.h" | |
28 | |
29 enum case_action {CASE_UP, CASE_DOWN, CASE_CAPITALIZE, CASE_CAPITALIZE_UP}; | |
17816 | 30 |
31 Lisp_Object Qidentity; | |
118 | 32 |
33 Lisp_Object | |
34 casify_object (flag, obj) | |
35 enum case_action flag; | |
36 Lisp_Object obj; | |
37 { | |
38 register int i, c, len; | |
39 register int inword = flag == CASE_DOWN; | |
17816 | 40 Lisp_Object tem; |
118 | 41 |
15170
0d698228e98c
(casify_region, casify_object):
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
42 /* If the case table is flagged as modified, rescan it. */ |
0d698228e98c
(casify_region, casify_object):
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
43 if (NILP (XCHAR_TABLE (current_buffer->downcase_table)->extras[1])) |
0d698228e98c
(casify_region, casify_object):
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
44 Fset_case_table (current_buffer->downcase_table); |
0d698228e98c
(casify_region, casify_object):
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
45 |
118 | 46 while (1) |
47 { | |
9137
412e94c1dbf2
(casify_object): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9053
diff
changeset
|
48 if (INTEGERP (obj)) |
118 | 49 { |
17816 | 50 tem = Faref (current_buffer->downcase_table, obj); |
51 if (EQ (tem, Qidentity)) | |
52 tem = obj; | |
53 if (inword) | |
54 obj = tem; | |
55 else if (EQ (tem, obj)) | |
118 | 56 { |
17816 | 57 tem = Faref (current_buffer->upcase_table, obj); |
58 if (!EQ (tem, Qidentity)) | |
59 obj = tem; | |
118 | 60 } |
61 return obj; | |
62 } | |
9137
412e94c1dbf2
(casify_object): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9053
diff
changeset
|
63 if (STRINGP (obj)) |
118 | 64 { |
65 obj = Fcopy_sequence (obj); | |
66 len = XSTRING (obj)->size; | |
67 for (i = 0; i < len; i++) | |
68 { | |
69 c = XSTRING (obj)->data[i]; | |
9052
6de22822cf72
(upcase_initials): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
70 if (inword && flag != CASE_CAPITALIZE_UP) |
118 | 71 c = DOWNCASE (c); |
9052
6de22822cf72
(upcase_initials): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
72 else if (!UPPERCASEP (c) |
6de22822cf72
(upcase_initials): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
73 && (!inword || flag != CASE_CAPITALIZE_UP)) |
118 | 74 c = UPCASE1 (c); |
75 XSTRING (obj)->data[i] = c; | |
9052
6de22822cf72
(upcase_initials): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
76 if ((int) flag >= (int) CASE_CAPITALIZE) |
118 | 77 inword = SYNTAX (c) == Sword; |
78 } | |
79 return obj; | |
80 } | |
1926
952f2a18f83d
* callint.c (Fcall_interactively): Pass the correct number of
Jim Blandy <jimb@redhat.com>
parents:
1505
diff
changeset
|
81 obj = wrong_type_argument (Qchar_or_string_p, obj); |
118 | 82 } |
83 } | |
84 | |
85 DEFUN ("upcase", Fupcase, Supcase, 1, 1, 0, | |
86 "Convert argument to upper case and return that.\n\ | |
87 The argument may be a character or string. The result has the same type.\n\ | |
9053
4887fc1a2dda
(Fupcase_initials_region): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9052
diff
changeset
|
88 The argument object is not altered--the value is a copy.\n\ |
4887fc1a2dda
(Fupcase_initials_region): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9052
diff
changeset
|
89 See also `capitalize', `downcase' and `upcase-initials'.") |
118 | 90 (obj) |
91 Lisp_Object obj; | |
92 { | |
93 return casify_object (CASE_UP, obj); | |
94 } | |
95 | |
96 DEFUN ("downcase", Fdowncase, Sdowncase, 1, 1, 0, | |
97 "Convert argument to lower case and return that.\n\ | |
98 The argument may be a character or string. The result has the same type.\n\ | |
9053
4887fc1a2dda
(Fupcase_initials_region): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9052
diff
changeset
|
99 The argument object is not altered--the value is a copy.") |
118 | 100 (obj) |
101 Lisp_Object obj; | |
102 { | |
103 return casify_object (CASE_DOWN, obj); | |
104 } | |
105 | |
106 DEFUN ("capitalize", Fcapitalize, Scapitalize, 1, 1, 0, | |
107 "Convert argument to capitalized form and return that.\n\ | |
108 This means that each word's first character is upper case\n\ | |
109 and the rest is lower case.\n\ | |
110 The argument may be a character or string. The result has the same type.\n\ | |
9053
4887fc1a2dda
(Fupcase_initials_region): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9052
diff
changeset
|
111 The argument object is not altered--the value is a copy.") |
118 | 112 (obj) |
113 Lisp_Object obj; | |
114 { | |
115 return casify_object (CASE_CAPITALIZE, obj); | |
116 } | |
9052
6de22822cf72
(upcase_initials): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
117 |
12089
f7cb17ca1815
(casify_region): Use explicit local vars for start
Karl Heuer <kwzh@gnu.org>
parents:
9299
diff
changeset
|
118 /* Like Fcapitalize but change only the initials. */ |
f7cb17ca1815
(casify_region): Use explicit local vars for start
Karl Heuer <kwzh@gnu.org>
parents:
9299
diff
changeset
|
119 |
9053
4887fc1a2dda
(Fupcase_initials_region): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9052
diff
changeset
|
120 DEFUN ("upcase-initials", Fupcase_initials, Supcase_initials, 1, 1, 0, |
4887fc1a2dda
(Fupcase_initials_region): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9052
diff
changeset
|
121 "Convert the initial of each word in the argument to upper case.\n\ |
4887fc1a2dda
(Fupcase_initials_region): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9052
diff
changeset
|
122 Do not change the other letters of each word.\n\ |
4887fc1a2dda
(Fupcase_initials_region): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9052
diff
changeset
|
123 The argument may be a character or string. The result has the same type.\n\ |
4887fc1a2dda
(Fupcase_initials_region): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9052
diff
changeset
|
124 The argument object is not altered--the value is a copy.") |
4887fc1a2dda
(Fupcase_initials_region): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9052
diff
changeset
|
125 (obj) |
4887fc1a2dda
(Fupcase_initials_region): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9052
diff
changeset
|
126 Lisp_Object obj; |
4887fc1a2dda
(Fupcase_initials_region): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9052
diff
changeset
|
127 { |
4887fc1a2dda
(Fupcase_initials_region): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9052
diff
changeset
|
128 return casify_object (CASE_CAPITALIZE_UP, obj); |
4887fc1a2dda
(Fupcase_initials_region): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9052
diff
changeset
|
129 } |
118 | 130 |
131 /* flag is CASE_UP, CASE_DOWN or CASE_CAPITALIZE or CASE_CAPITALIZE_UP. | |
132 b and e specify range of buffer to operate on. */ | |
133 | |
134 casify_region (flag, b, e) | |
135 enum case_action flag; | |
136 Lisp_Object b, e; | |
137 { | |
138 register int i; | |
139 register int c; | |
140 register int inword = flag == CASE_DOWN; | |
12089
f7cb17ca1815
(casify_region): Use explicit local vars for start
Karl Heuer <kwzh@gnu.org>
parents:
9299
diff
changeset
|
141 int start, end; |
17816 | 142 Lisp_Object ch, downch, val; |
118 | 143 |
144 if (EQ (b, e)) | |
145 /* Not modifying because nothing marked */ | |
146 return; | |
147 | |
15170
0d698228e98c
(casify_region, casify_object):
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
148 /* If the case table is flagged as modified, rescan it. */ |
0d698228e98c
(casify_region, casify_object):
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
149 if (NILP (XCHAR_TABLE (current_buffer->downcase_table)->extras[1])) |
0d698228e98c
(casify_region, casify_object):
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
150 Fset_case_table (current_buffer->downcase_table); |
0d698228e98c
(casify_region, casify_object):
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
151 |
118 | 152 validate_region (&b, &e); |
12089
f7cb17ca1815
(casify_region): Use explicit local vars for start
Karl Heuer <kwzh@gnu.org>
parents:
9299
diff
changeset
|
153 start = XFASTINT (b); |
f7cb17ca1815
(casify_region): Use explicit local vars for start
Karl Heuer <kwzh@gnu.org>
parents:
9299
diff
changeset
|
154 end = XFASTINT (e); |
f7cb17ca1815
(casify_region): Use explicit local vars for start
Karl Heuer <kwzh@gnu.org>
parents:
9299
diff
changeset
|
155 modify_region (current_buffer, start, end); |
f7cb17ca1815
(casify_region): Use explicit local vars for start
Karl Heuer <kwzh@gnu.org>
parents:
9299
diff
changeset
|
156 record_change (start, end - start); |
118 | 157 |
17816 | 158 if (NILP (current_buffer->enable_multibyte_characters)) |
159 { | |
160 for (i = start; i < end; i++) | |
161 { | |
162 c = FETCH_BYTE (i); | |
163 if (inword && flag != CASE_CAPITALIZE_UP) | |
164 c = DOWNCASE (c); | |
165 else if (!UPPERCASEP (c) | |
166 && (!inword || flag != CASE_CAPITALIZE_UP)) | |
167 c = UPCASE1 (c); | |
168 FETCH_BYTE (i) = c; | |
169 if ((int) flag >= (int) CASE_CAPITALIZE) | |
170 inword = SYNTAX (c) == Sword; | |
171 } | |
172 } | |
173 else | |
118 | 174 { |
17816 | 175 Lisp_Object down, up; |
176 int opoint = PT; | |
177 | |
178 down = current_buffer->downcase_table; | |
179 up = current_buffer->upcase_table; | |
180 for (i = start; i < end;) | |
181 { | |
182 c = FETCH_MULTIBYTE_CHAR (i); | |
183 XSETFASTINT (ch, c); | |
184 downch = Faref (down, ch); | |
185 if (EQ (downch, Qidentity)) | |
186 downch = ch; | |
187 if (inword && flag != CASE_CAPITALIZE_UP) | |
188 val = downch; | |
189 else if (EQ (downch, ch) | |
190 && (!inword || flag != CASE_CAPITALIZE_UP)) | |
191 { | |
192 val = Faref (up, ch); | |
193 if (EQ (val, Qidentity)) | |
194 val = ch; | |
195 } | |
196 else | |
197 val = ch; | |
198 if (!EQ (val, ch)) | |
199 { | |
200 int fromlen, tolen, j; | |
201 char workbuf[4], *str; | |
202 | |
203 if (!NATNUMP (val)) | |
204 error ("Inappropriate value found in case table"); | |
205 /* Handle the most likely case */ | |
206 if (c < 0400 && XFASTINT (val) < 0400) | |
207 FETCH_BYTE (i) = XFASTINT (val); | |
208 else if (fromlen = CHAR_STRING (c, workbuf, str), | |
209 tolen = CHAR_STRING (XFASTINT (val), workbuf, str), | |
210 fromlen == tolen) | |
211 { | |
212 for (j = 0; j < tolen; ++j) | |
213 FETCH_BYTE (i + j) = str[j]; | |
214 } | |
215 else | |
216 { | |
217 error ("Can't casify letters that change length"); | |
218 #if 0 /* This is approximately what we'd like to be able to do here */ | |
219 if (tolen < fromlen) | |
220 del_range_1 (i + tolen, i + fromlen, 0); | |
221 else if (tolen > fromlen) | |
222 { | |
223 TEMP_SET_PT (i + fromlen); | |
224 insert_1 (str + fromlen, tolen - fromlen, 1, 0); | |
225 } | |
226 #endif | |
227 } | |
228 } | |
229 if ((int) flag >= (int) CASE_CAPITALIZE) | |
230 inword = SYNTAX (XFASTINT (val)) == Sword; | |
231 INC_POS (i); | |
232 } | |
233 TEMP_SET_PT (opoint); | |
118 | 234 } |
235 | |
12089
f7cb17ca1815
(casify_region): Use explicit local vars for start
Karl Heuer <kwzh@gnu.org>
parents:
9299
diff
changeset
|
236 signal_after_change (start, end - start, end - start); |
118 | 237 } |
238 | |
239 DEFUN ("upcase-region", Fupcase_region, Supcase_region, 2, 2, "r", | |
240 "Convert the region to upper case. In programs, wants two arguments.\n\ | |
241 These arguments specify the starting and ending character numbers of\n\ | |
242 the region to operate on. When used as a command, the text between\n\ | |
243 point and the mark is operated on.\n\ | |
244 See also `capitalize-region'.") | |
14063
ef7d4117c601
(Fupcase_region, Fdowncase_region, Fcapitalize_region,
Erik Naggum <erik@naggum.no>
parents:
12244
diff
changeset
|
245 (beg, end) |
ef7d4117c601
(Fupcase_region, Fdowncase_region, Fcapitalize_region,
Erik Naggum <erik@naggum.no>
parents:
12244
diff
changeset
|
246 Lisp_Object beg, end; |
118 | 247 { |
14063
ef7d4117c601
(Fupcase_region, Fdowncase_region, Fcapitalize_region,
Erik Naggum <erik@naggum.no>
parents:
12244
diff
changeset
|
248 casify_region (CASE_UP, beg, end); |
118 | 249 return Qnil; |
250 } | |
251 | |
252 DEFUN ("downcase-region", Fdowncase_region, Sdowncase_region, 2, 2, "r", | |
253 "Convert the region to lower case. In programs, wants two arguments.\n\ | |
254 These arguments specify the starting and ending character numbers of\n\ | |
255 the region to operate on. When used as a command, the text between\n\ | |
256 point and the mark is operated on.") | |
14063
ef7d4117c601
(Fupcase_region, Fdowncase_region, Fcapitalize_region,
Erik Naggum <erik@naggum.no>
parents:
12244
diff
changeset
|
257 (beg, end) |
ef7d4117c601
(Fupcase_region, Fdowncase_region, Fcapitalize_region,
Erik Naggum <erik@naggum.no>
parents:
12244
diff
changeset
|
258 Lisp_Object beg, end; |
118 | 259 { |
14063
ef7d4117c601
(Fupcase_region, Fdowncase_region, Fcapitalize_region,
Erik Naggum <erik@naggum.no>
parents:
12244
diff
changeset
|
260 casify_region (CASE_DOWN, beg, end); |
118 | 261 return Qnil; |
262 } | |
263 | |
264 DEFUN ("capitalize-region", Fcapitalize_region, Scapitalize_region, 2, 2, "r", | |
265 "Convert the region to capitalized form.\n\ | |
266 Capitalized form means each word's first character is upper case\n\ | |
267 and the rest of it is lower case.\n\ | |
268 In programs, give two arguments, the starting and ending\n\ | |
269 character positions to operate on.") | |
14063
ef7d4117c601
(Fupcase_region, Fdowncase_region, Fcapitalize_region,
Erik Naggum <erik@naggum.no>
parents:
12244
diff
changeset
|
270 (beg, end) |
ef7d4117c601
(Fupcase_region, Fdowncase_region, Fcapitalize_region,
Erik Naggum <erik@naggum.no>
parents:
12244
diff
changeset
|
271 Lisp_Object beg, end; |
118 | 272 { |
14063
ef7d4117c601
(Fupcase_region, Fdowncase_region, Fcapitalize_region,
Erik Naggum <erik@naggum.no>
parents:
12244
diff
changeset
|
273 casify_region (CASE_CAPITALIZE, beg, end); |
118 | 274 return Qnil; |
275 } | |
276 | |
12089
f7cb17ca1815
(casify_region): Use explicit local vars for start
Karl Heuer <kwzh@gnu.org>
parents:
9299
diff
changeset
|
277 /* Like Fcapitalize_region but change only the initials. */ |
f7cb17ca1815
(casify_region): Use explicit local vars for start
Karl Heuer <kwzh@gnu.org>
parents:
9299
diff
changeset
|
278 |
9053
4887fc1a2dda
(Fupcase_initials_region): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9052
diff
changeset
|
279 DEFUN ("upcase-initials-region", Fupcase_initials_region, |
4887fc1a2dda
(Fupcase_initials_region): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9052
diff
changeset
|
280 Supcase_initials_region, 2, 2, "r", |
4887fc1a2dda
(Fupcase_initials_region): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9052
diff
changeset
|
281 "Upcase the initial of each word in the region.\n\ |
4887fc1a2dda
(Fupcase_initials_region): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9052
diff
changeset
|
282 Subsequent letters of each word are not changed.\n\ |
4887fc1a2dda
(Fupcase_initials_region): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9052
diff
changeset
|
283 In programs, give two arguments, the starting and ending\n\ |
4887fc1a2dda
(Fupcase_initials_region): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9052
diff
changeset
|
284 character positions to operate on.") |
14063
ef7d4117c601
(Fupcase_region, Fdowncase_region, Fcapitalize_region,
Erik Naggum <erik@naggum.no>
parents:
12244
diff
changeset
|
285 (beg, end) |
ef7d4117c601
(Fupcase_region, Fdowncase_region, Fcapitalize_region,
Erik Naggum <erik@naggum.no>
parents:
12244
diff
changeset
|
286 Lisp_Object beg, end; |
9053
4887fc1a2dda
(Fupcase_initials_region): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9052
diff
changeset
|
287 { |
14063
ef7d4117c601
(Fupcase_region, Fdowncase_region, Fcapitalize_region,
Erik Naggum <erik@naggum.no>
parents:
12244
diff
changeset
|
288 casify_region (CASE_CAPITALIZE_UP, beg, end); |
9053
4887fc1a2dda
(Fupcase_initials_region): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9052
diff
changeset
|
289 return Qnil; |
4887fc1a2dda
(Fupcase_initials_region): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9052
diff
changeset
|
290 } |
118 | 291 |
292 Lisp_Object | |
6221
c2d29681d218
(operate_on_word): Don't move point; store in *NEWPOINT.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
293 operate_on_word (arg, newpoint) |
118 | 294 Lisp_Object arg; |
6221
c2d29681d218
(operate_on_word): Don't move point; store in *NEWPOINT.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
295 int *newpoint; |
118 | 296 { |
1505
4f138b03e5ab
* casefiddle.c (operate_on_word): Declare end to be an int, not a
Jim Blandy <jimb@redhat.com>
parents:
484
diff
changeset
|
297 Lisp_Object val; |
6221
c2d29681d218
(operate_on_word): Don't move point; store in *NEWPOINT.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
298 int farend; |
12089
f7cb17ca1815
(casify_region): Use explicit local vars for start
Karl Heuer <kwzh@gnu.org>
parents:
9299
diff
changeset
|
299 int iarg; |
118 | 300 |
301 CHECK_NUMBER (arg, 0); | |
12089
f7cb17ca1815
(casify_region): Use explicit local vars for start
Karl Heuer <kwzh@gnu.org>
parents:
9299
diff
changeset
|
302 iarg = XINT (arg); |
16039
855c8d8ba0f0
Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents:
15170
diff
changeset
|
303 farend = scan_words (PT, iarg); |
118 | 304 if (!farend) |
12089
f7cb17ca1815
(casify_region): Use explicit local vars for start
Karl Heuer <kwzh@gnu.org>
parents:
9299
diff
changeset
|
305 farend = iarg > 0 ? ZV : BEGV; |
118 | 306 |
16039
855c8d8ba0f0
Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents:
15170
diff
changeset
|
307 *newpoint = PT > farend ? PT : farend; |
9299
e8c880f2723e
(casify_object, operate_on_word, Fupcase_word, Fdowncase_word,
Karl Heuer <kwzh@gnu.org>
parents:
9137
diff
changeset
|
308 XSETFASTINT (val, farend); |
118 | 309 |
310 return val; | |
311 } | |
312 | |
313 DEFUN ("upcase-word", Fupcase_word, Supcase_word, 1, 1, "p", | |
314 "Convert following word (or ARG words) to upper case, moving over.\n\ | |
315 With negative argument, convert previous words but do not move.\n\ | |
316 See also `capitalize-word'.") | |
317 (arg) | |
318 Lisp_Object arg; | |
319 { | |
6221
c2d29681d218
(operate_on_word): Don't move point; store in *NEWPOINT.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
320 Lisp_Object beg, end; |
c2d29681d218
(operate_on_word): Don't move point; store in *NEWPOINT.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
321 int newpoint; |
16039
855c8d8ba0f0
Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents:
15170
diff
changeset
|
322 XSETFASTINT (beg, PT); |
6221
c2d29681d218
(operate_on_word): Don't move point; store in *NEWPOINT.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
323 end = operate_on_word (arg, &newpoint); |
c2d29681d218
(operate_on_word): Don't move point; store in *NEWPOINT.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
324 casify_region (CASE_UP, beg, end); |
c2d29681d218
(operate_on_word): Don't move point; store in *NEWPOINT.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
325 SET_PT (newpoint); |
118 | 326 return Qnil; |
327 } | |
328 | |
329 DEFUN ("downcase-word", Fdowncase_word, Sdowncase_word, 1, 1, "p", | |
330 "Convert following word (or ARG words) to lower case, moving over.\n\ | |
331 With negative argument, convert previous words but do not move.") | |
332 (arg) | |
333 Lisp_Object arg; | |
334 { | |
6221
c2d29681d218
(operate_on_word): Don't move point; store in *NEWPOINT.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
335 Lisp_Object beg, end; |
c2d29681d218
(operate_on_word): Don't move point; store in *NEWPOINT.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
336 int newpoint; |
16039
855c8d8ba0f0
Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents:
15170
diff
changeset
|
337 XSETFASTINT (beg, PT); |
6221
c2d29681d218
(operate_on_word): Don't move point; store in *NEWPOINT.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
338 end = operate_on_word (arg, &newpoint); |
c2d29681d218
(operate_on_word): Don't move point; store in *NEWPOINT.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
339 casify_region (CASE_DOWN, beg, end); |
c2d29681d218
(operate_on_word): Don't move point; store in *NEWPOINT.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
340 SET_PT (newpoint); |
118 | 341 return Qnil; |
342 } | |
343 | |
344 DEFUN ("capitalize-word", Fcapitalize_word, Scapitalize_word, 1, 1, "p", | |
345 "Capitalize the following word (or ARG words), moving over.\n\ | |
346 This gives the word(s) a first character in upper case\n\ | |
347 and the rest lower case.\n\ | |
348 With negative argument, capitalize previous words but do not move.") | |
349 (arg) | |
350 Lisp_Object arg; | |
351 { | |
6221
c2d29681d218
(operate_on_word): Don't move point; store in *NEWPOINT.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
352 Lisp_Object beg, end; |
c2d29681d218
(operate_on_word): Don't move point; store in *NEWPOINT.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
353 int newpoint; |
16039
855c8d8ba0f0
Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents:
15170
diff
changeset
|
354 XSETFASTINT (beg, PT); |
6221
c2d29681d218
(operate_on_word): Don't move point; store in *NEWPOINT.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
355 end = operate_on_word (arg, &newpoint); |
c2d29681d218
(operate_on_word): Don't move point; store in *NEWPOINT.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
356 casify_region (CASE_CAPITALIZE, beg, end); |
c2d29681d218
(operate_on_word): Don't move point; store in *NEWPOINT.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
357 SET_PT (newpoint); |
118 | 358 return Qnil; |
359 } | |
360 | |
361 syms_of_casefiddle () | |
362 { | |
17816 | 363 Qidentity = intern ("identity"); |
364 staticpro (&Qidentity); | |
118 | 365 defsubr (&Supcase); |
366 defsubr (&Sdowncase); | |
367 defsubr (&Scapitalize); | |
9053
4887fc1a2dda
(Fupcase_initials_region): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9052
diff
changeset
|
368 defsubr (&Supcase_initials); |
118 | 369 defsubr (&Supcase_region); |
370 defsubr (&Sdowncase_region); | |
371 defsubr (&Scapitalize_region); | |
9053
4887fc1a2dda
(Fupcase_initials_region): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9052
diff
changeset
|
372 defsubr (&Supcase_initials_region); |
118 | 373 defsubr (&Supcase_word); |
374 defsubr (&Sdowncase_word); | |
375 defsubr (&Scapitalize_word); | |
376 } | |
377 | |
378 keys_of_casefiddle () | |
379 { | |
380 initial_define_key (control_x_map, Ctl('U'), "upcase-region"); | |
484 | 381 Fput (intern ("upcase-region"), Qdisabled, Qt); |
118 | 382 initial_define_key (control_x_map, Ctl('L'), "downcase-region"); |
484 | 383 Fput (intern ("downcase-region"), Qdisabled, Qt); |
384 | |
118 | 385 initial_define_key (meta_map, 'u', "upcase-word"); |
386 initial_define_key (meta_map, 'l', "downcase-word"); | |
387 initial_define_key (meta_map, 'c', "capitalize-word"); | |
388 } |