Mercurial > emacs
annotate src/casefiddle.c @ 89770:c0e5e49686a6
Add map #x00A6 <-> #xFFE4 to translation tables japanese-ucs-*-map.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Tue, 27 Jan 2004 23:52:31 +0000 |
parents | 2f877ed80fa6 |
children | 68c22ea6027c |
rev | line source |
---|---|
118 | 1 /* GNU Emacs case conversion functions. |
20708 | 2 Copyright (C) 1985, 1994, 1997 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" | |
88351
aac41b50c875
Include "character.h" instead of "charset.h".
Kenichi Handa <handa@m17n.org>
parents:
40656
diff
changeset
|
25 #include "character.h" |
118 | 26 #include "commands.h" |
27 #include "syntax.h" | |
26839 | 28 #include "composite.h" |
39748
42b7a798ff79
Include keymap.h.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
34969
diff
changeset
|
29 #include "keymap.h" |
118 | 30 |
31 enum case_action {CASE_UP, CASE_DOWN, CASE_CAPITALIZE, CASE_CAPITALIZE_UP}; | |
17816 | 32 |
33 Lisp_Object Qidentity; | |
118 | 34 |
35 Lisp_Object | |
36 casify_object (flag, obj) | |
37 enum case_action flag; | |
38 Lisp_Object obj; | |
39 { | |
89017
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
40 register int c, c1; |
118 | 41 register int inword = flag == CASE_DOWN; |
42 | |
15170
0d698228e98c
(casify_region, casify_object):
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
43 /* 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
|
44 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
|
45 Fset_case_table (current_buffer->downcase_table); |
0d698228e98c
(casify_region, casify_object):
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
46 |
118 | 47 while (1) |
48 { | |
9137
412e94c1dbf2
(casify_object): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9053
diff
changeset
|
49 if (INTEGERP (obj)) |
118 | 50 { |
22506
2107e25fa56f
(casify_object): Cope with modifier bits in character.
Karl Heuer <kwzh@gnu.org>
parents:
21514
diff
changeset
|
51 int flagbits = (CHAR_ALT | CHAR_SUPER | CHAR_HYPER |
2107e25fa56f
(casify_object): Cope with modifier bits in character.
Karl Heuer <kwzh@gnu.org>
parents:
21514
diff
changeset
|
52 | CHAR_SHIFT | CHAR_CTL | CHAR_META); |
2107e25fa56f
(casify_object): Cope with modifier bits in character.
Karl Heuer <kwzh@gnu.org>
parents:
21514
diff
changeset
|
53 int flags = XINT (obj) & flagbits; |
89017
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
54 int multibyte = ! NILP (current_buffer->enable_multibyte_characters); |
22506
2107e25fa56f
(casify_object): Cope with modifier bits in character.
Karl Heuer <kwzh@gnu.org>
parents:
21514
diff
changeset
|
55 |
89017
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
56 c1 = XFASTINT (obj) & ~flagbits; |
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
57 if (! multibyte) |
89056
496be2b262c6
(casify_object): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89017
diff
changeset
|
58 MAKE_CHAR_MULTIBYTE (c1); |
89017
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
59 c = DOWNCASE (c1); |
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
60 if (inword || c == c1) |
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
61 { |
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
62 if (! inword) |
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
63 c = UPCASE1 (c1); |
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
64 if (! multibyte) |
89056
496be2b262c6
(casify_object): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
89017
diff
changeset
|
65 MAKE_CHAR_UNIBYTE (c); |
22506
2107e25fa56f
(casify_object): Cope with modifier bits in character.
Karl Heuer <kwzh@gnu.org>
parents:
21514
diff
changeset
|
66 XSETFASTINT (obj, c | flags); |
18136
015e9e4a90ed
(casify_object): Fix bug on handling a character
Kenichi Handa <handa@m17n.org>
parents:
18005
diff
changeset
|
67 } |
118 | 68 return obj; |
69 } | |
20611
e351676e5044
(casify_object): Scan string by bytes and chars.
Richard M. Stallman <rms@gnu.org>
parents:
20543
diff
changeset
|
70 |
9137
412e94c1dbf2
(casify_object): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9053
diff
changeset
|
71 if (STRINGP (obj)) |
118 | 72 { |
20611
e351676e5044
(casify_object): Scan string by bytes and chars.
Richard M. Stallman <rms@gnu.org>
parents:
20543
diff
changeset
|
73 int multibyte = STRING_MULTIBYTE (obj); |
89017
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
74 int i, i_byte, len; |
89483 | 75 int size = SCHARS (obj); |
18005
ad95aa134d60
(casify_object): Handle multibyte characters.
Kenichi Handa <handa@m17n.org>
parents:
17816
diff
changeset
|
76 |
118 | 77 obj = Fcopy_sequence (obj); |
89017
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
78 for (i = i_byte = 0; i < size; i++, i_byte += len) |
118 | 79 { |
89017
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
80 if (multibyte) |
89483 | 81 c = STRING_CHAR_AND_LENGTH (SDATA (obj) + i_byte, 0, len); |
89017
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
82 else |
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
83 { |
89483 | 84 c = SREF (obj, i_byte); |
89017
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
85 len = 1; |
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
86 MAKE_CHAR_MULTIBYTE (c); |
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
87 } |
89483 | 88 c1 = c; |
9052
6de22822cf72
(upcase_initials): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
89 if (inword && flag != CASE_CAPITALIZE_UP) |
118 | 90 c = DOWNCASE (c); |
9052
6de22822cf72
(upcase_initials): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
91 else if (!UPPERCASEP (c) |
6de22822cf72
(upcase_initials): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
92 && (!inword || flag != CASE_CAPITALIZE_UP)) |
89017
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
93 c = UPCASE1 (c1); |
9052
6de22822cf72
(upcase_initials): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
94 if ((int) flag >= (int) CASE_CAPITALIZE) |
89483 | 95 inword = (SYNTAX (c) == Sword); |
89017
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
96 if (c != c1) |
18005
ad95aa134d60
(casify_object): Handle multibyte characters.
Kenichi Handa <handa@m17n.org>
parents:
17816
diff
changeset
|
97 { |
89017
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
98 if (! multibyte) |
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
99 { |
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
100 MAKE_CHAR_UNIBYTE (c); |
89483 | 101 SSET (obj, i_byte, c); |
89017
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
102 } |
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
103 else if (ASCII_CHAR_P (c1) && ASCII_CHAR_P (c)) |
89483 | 104 SSET (obj, i_byte, c); |
89017
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
105 else |
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
106 { |
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
107 Faset (obj, make_number (i), make_number (c)); |
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
108 i_byte += CHAR_BYTES (c) - len; |
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
109 } |
18005
ad95aa134d60
(casify_object): Handle multibyte characters.
Kenichi Handa <handa@m17n.org>
parents:
17816
diff
changeset
|
110 } |
ad95aa134d60
(casify_object): Handle multibyte characters.
Kenichi Handa <handa@m17n.org>
parents:
17816
diff
changeset
|
111 } |
118 | 112 return obj; |
113 } | |
1926
952f2a18f83d
* callint.c (Fcall_interactively): Pass the correct number of
Jim Blandy <jimb@redhat.com>
parents:
1505
diff
changeset
|
114 obj = wrong_type_argument (Qchar_or_string_p, obj); |
118 | 115 } |
116 } | |
117 | |
118 DEFUN ("upcase", Fupcase, Supcase, 1, 1, 0, | |
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
119 doc: /* Convert argument to upper case and return that. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
120 The argument may be a character or string. The result has the same type. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
121 The argument object is not altered--the value is a copy. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
122 See also `capitalize', `downcase' and `upcase-initials'. */) |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
123 (obj) |
118 | 124 Lisp_Object obj; |
125 { | |
126 return casify_object (CASE_UP, obj); | |
127 } | |
128 | |
129 DEFUN ("downcase", Fdowncase, Sdowncase, 1, 1, 0, | |
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
130 doc: /* Convert argument to lower case and return that. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
131 The argument may be a character or string. The result has the same type. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
132 The argument object is not altered--the value is a copy. */) |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
133 (obj) |
118 | 134 Lisp_Object obj; |
135 { | |
136 return casify_object (CASE_DOWN, obj); | |
137 } | |
138 | |
139 DEFUN ("capitalize", Fcapitalize, Scapitalize, 1, 1, 0, | |
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
140 doc: /* Convert argument to capitalized form and return that. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
141 This means that each word's first character is upper case |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
142 and the rest is lower case. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
143 The argument may be a character or string. The result has the same type. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
144 The argument object is not altered--the value is a copy. */) |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
145 (obj) |
118 | 146 Lisp_Object obj; |
147 { | |
148 return casify_object (CASE_CAPITALIZE, obj); | |
149 } | |
9052
6de22822cf72
(upcase_initials): New function.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
150 |
12089
f7cb17ca1815
(casify_region): Use explicit local vars for start
Karl Heuer <kwzh@gnu.org>
parents:
9299
diff
changeset
|
151 /* 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
|
152 |
9053
4887fc1a2dda
(Fupcase_initials_region): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9052
diff
changeset
|
153 DEFUN ("upcase-initials", Fupcase_initials, Supcase_initials, 1, 1, 0, |
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
154 doc: /* Convert the initial of each word in the argument to upper case. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
155 Do not change the other letters of each word. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
156 The argument may be a character or string. The result has the same type. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
157 The argument object is not altered--the value is a copy. */) |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
158 (obj) |
9053
4887fc1a2dda
(Fupcase_initials_region): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9052
diff
changeset
|
159 Lisp_Object obj; |
4887fc1a2dda
(Fupcase_initials_region): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9052
diff
changeset
|
160 { |
4887fc1a2dda
(Fupcase_initials_region): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9052
diff
changeset
|
161 return casify_object (CASE_CAPITALIZE_UP, obj); |
4887fc1a2dda
(Fupcase_initials_region): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9052
diff
changeset
|
162 } |
118 | 163 |
164 /* flag is CASE_UP, CASE_DOWN or CASE_CAPITALIZE or CASE_CAPITALIZE_UP. | |
165 b and e specify range of buffer to operate on. */ | |
166 | |
21514 | 167 void |
118 | 168 casify_region (flag, b, e) |
169 enum case_action flag; | |
170 Lisp_Object b, e; | |
171 { | |
172 register int c; | |
173 register int inword = flag == CASE_DOWN; | |
18005
ad95aa134d60
(casify_object): Handle multibyte characters.
Kenichi Handa <handa@m17n.org>
parents:
17816
diff
changeset
|
174 register int multibyte = !NILP (current_buffer->enable_multibyte_characters); |
12089
f7cb17ca1815
(casify_region): Use explicit local vars for start
Karl Heuer <kwzh@gnu.org>
parents:
9299
diff
changeset
|
175 int start, end; |
20543
4dbda4b7c66f
(casify_region): Scan in bytes and chars.
Richard M. Stallman <rms@gnu.org>
parents:
18613
diff
changeset
|
176 int start_byte, end_byte; |
26839 | 177 int changed = 0; |
89017
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
178 int opoint = PT; |
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
179 int opoint_byte = PT_BYTE; |
118 | 180 |
181 if (EQ (b, e)) | |
182 /* Not modifying because nothing marked */ | |
183 return; | |
184 | |
15170
0d698228e98c
(casify_region, casify_object):
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
185 /* 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
|
186 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
|
187 Fset_case_table (current_buffer->downcase_table); |
0d698228e98c
(casify_region, casify_object):
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
188 |
118 | 189 validate_region (&b, &e); |
12089
f7cb17ca1815
(casify_region): Use explicit local vars for start
Karl Heuer <kwzh@gnu.org>
parents:
9299
diff
changeset
|
190 start = XFASTINT (b); |
f7cb17ca1815
(casify_region): Use explicit local vars for start
Karl Heuer <kwzh@gnu.org>
parents:
9299
diff
changeset
|
191 end = XFASTINT (e); |
f7cb17ca1815
(casify_region): Use explicit local vars for start
Karl Heuer <kwzh@gnu.org>
parents:
9299
diff
changeset
|
192 modify_region (current_buffer, start, end); |
f7cb17ca1815
(casify_region): Use explicit local vars for start
Karl Heuer <kwzh@gnu.org>
parents:
9299
diff
changeset
|
193 record_change (start, end - start); |
20543
4dbda4b7c66f
(casify_region): Scan in bytes and chars.
Richard M. Stallman <rms@gnu.org>
parents:
18613
diff
changeset
|
194 start_byte = CHAR_TO_BYTE (start); |
4dbda4b7c66f
(casify_region): Scan in bytes and chars.
Richard M. Stallman <rms@gnu.org>
parents:
18613
diff
changeset
|
195 end_byte = CHAR_TO_BYTE (end); |
118 | 196 |
89017
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
197 while (start < end) |
17816 | 198 { |
89017
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
199 int c2, len; |
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
200 |
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
201 if (multibyte) |
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
202 { |
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
203 c = FETCH_MULTIBYTE_CHAR (start_byte); |
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
204 len = CHAR_BYTES (c); |
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
205 } |
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
206 else |
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
207 { |
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
208 c = FETCH_BYTE (start_byte); |
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
209 MAKE_CHAR_MULTIBYTE (c); |
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
210 len = 1; |
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
211 } |
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
212 c2 = c; |
18005
ad95aa134d60
(casify_object): Handle multibyte characters.
Kenichi Handa <handa@m17n.org>
parents:
17816
diff
changeset
|
213 if (inword && flag != CASE_CAPITALIZE_UP) |
ad95aa134d60
(casify_object): Handle multibyte characters.
Kenichi Handa <handa@m17n.org>
parents:
17816
diff
changeset
|
214 c = DOWNCASE (c); |
ad95aa134d60
(casify_object): Handle multibyte characters.
Kenichi Handa <handa@m17n.org>
parents:
17816
diff
changeset
|
215 else if (!UPPERCASEP (c) |
ad95aa134d60
(casify_object): Handle multibyte characters.
Kenichi Handa <handa@m17n.org>
parents:
17816
diff
changeset
|
216 && (!inword || flag != CASE_CAPITALIZE_UP)) |
ad95aa134d60
(casify_object): Handle multibyte characters.
Kenichi Handa <handa@m17n.org>
parents:
17816
diff
changeset
|
217 c = UPCASE1 (c); |
ad95aa134d60
(casify_object): Handle multibyte characters.
Kenichi Handa <handa@m17n.org>
parents:
17816
diff
changeset
|
218 if ((int) flag >= (int) CASE_CAPITALIZE) |
89483 | 219 inword = ((SYNTAX (c) == Sword) && (inword || !SYNTAX_PREFIX (c))); |
89017
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
220 if (c != c2) |
17816 | 221 { |
89017
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
222 changed = 1; |
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
223 if (! multibyte) |
17816 | 224 { |
89017
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
225 MAKE_CHAR_UNIBYTE (c); |
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
226 FETCH_BYTE (start_byte) = c; |
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
227 } |
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
228 else if (ASCII_CHAR_P (c2) && ASCII_CHAR_P (c)) |
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
229 FETCH_BYTE (start_byte) = c; |
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
230 else if (len == CHAR_BYTES (c)) |
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
231 { |
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
232 int j; |
26839 | 233 unsigned char str[MAX_MULTIBYTE_LENGTH]; |
17816 | 234 |
89017
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
235 CHAR_STRING (c, str); |
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
236 for (j = 0; j < len; ++j) |
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
237 FETCH_BYTE (start_byte + j) = str[j]; |
17816 | 238 } |
89017
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
239 else |
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
240 { |
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
241 TEMP_SET_PT_BOTH (start, start_byte); |
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
242 del_range_2 (start, start_byte, start + 1, start_byte + len, 0); |
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
243 insert_char (c); |
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
244 len = CHAR_BYTES (c); |
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
245 } |
17816 | 246 } |
89017
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
247 start++; |
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
248 start_byte += len; |
118 | 249 } |
250 | |
89483 | 251 if (PT != opoint) |
252 TEMP_SET_PT_BOTH (opoint, opoint_byte); | |
253 | |
26839 | 254 if (changed) |
255 { | |
89017
6a9e0cb7368b
(casify_object): Simplified. Handle the case that
Kenichi Handa <handa@m17n.org>
parents:
88426
diff
changeset
|
256 start = XFASTINT (b); |
26839 | 257 signal_after_change (start, end - start, end - start); |
258 update_compositions (start, end, CHECK_ALL); | |
259 } | |
118 | 260 } |
261 | |
262 DEFUN ("upcase-region", Fupcase_region, Supcase_region, 2, 2, "r", | |
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
263 doc: /* Convert the region to upper case. In programs, wants two arguments. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
264 These arguments specify the starting and ending character numbers of |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
265 the region to operate on. When used as a command, the text between |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
266 point and the mark is operated on. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
267 See also `capitalize-region'. */) |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
268 (beg, end) |
14063
ef7d4117c601
(Fupcase_region, Fdowncase_region, Fcapitalize_region,
Erik Naggum <erik@naggum.no>
parents:
12244
diff
changeset
|
269 Lisp_Object beg, end; |
118 | 270 { |
14063
ef7d4117c601
(Fupcase_region, Fdowncase_region, Fcapitalize_region,
Erik Naggum <erik@naggum.no>
parents:
12244
diff
changeset
|
271 casify_region (CASE_UP, beg, end); |
118 | 272 return Qnil; |
273 } | |
274 | |
275 DEFUN ("downcase-region", Fdowncase_region, Sdowncase_region, 2, 2, "r", | |
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
276 doc: /* Convert the region to lower case. In programs, wants two arguments. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
277 These arguments specify the starting and ending character numbers of |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
278 the region to operate on. When used as a command, the text between |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
279 point and the mark is operated on. */) |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
280 (beg, end) |
14063
ef7d4117c601
(Fupcase_region, Fdowncase_region, Fcapitalize_region,
Erik Naggum <erik@naggum.no>
parents:
12244
diff
changeset
|
281 Lisp_Object beg, end; |
118 | 282 { |
14063
ef7d4117c601
(Fupcase_region, Fdowncase_region, Fcapitalize_region,
Erik Naggum <erik@naggum.no>
parents:
12244
diff
changeset
|
283 casify_region (CASE_DOWN, beg, end); |
118 | 284 return Qnil; |
285 } | |
286 | |
287 DEFUN ("capitalize-region", Fcapitalize_region, Scapitalize_region, 2, 2, "r", | |
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
288 doc: /* Convert the region to capitalized form. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
289 Capitalized form means each word's first character is upper case |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
290 and the rest of it is lower case. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
291 In programs, give two arguments, the starting and ending |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
292 character positions to operate on. */) |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
293 (beg, end) |
14063
ef7d4117c601
(Fupcase_region, Fdowncase_region, Fcapitalize_region,
Erik Naggum <erik@naggum.no>
parents:
12244
diff
changeset
|
294 Lisp_Object beg, end; |
118 | 295 { |
14063
ef7d4117c601
(Fupcase_region, Fdowncase_region, Fcapitalize_region,
Erik Naggum <erik@naggum.no>
parents:
12244
diff
changeset
|
296 casify_region (CASE_CAPITALIZE, beg, end); |
118 | 297 return Qnil; |
298 } | |
299 | |
12089
f7cb17ca1815
(casify_region): Use explicit local vars for start
Karl Heuer <kwzh@gnu.org>
parents:
9299
diff
changeset
|
300 /* 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
|
301 |
9053
4887fc1a2dda
(Fupcase_initials_region): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9052
diff
changeset
|
302 DEFUN ("upcase-initials-region", Fupcase_initials_region, |
4887fc1a2dda
(Fupcase_initials_region): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9052
diff
changeset
|
303 Supcase_initials_region, 2, 2, "r", |
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
304 doc: /* Upcase the initial of each word in the region. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
305 Subsequent letters of each word are not changed. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
306 In programs, give two arguments, the starting and ending |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
307 character positions to operate on. */) |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
308 (beg, end) |
14063
ef7d4117c601
(Fupcase_region, Fdowncase_region, Fcapitalize_region,
Erik Naggum <erik@naggum.no>
parents:
12244
diff
changeset
|
309 Lisp_Object beg, end; |
9053
4887fc1a2dda
(Fupcase_initials_region): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9052
diff
changeset
|
310 { |
14063
ef7d4117c601
(Fupcase_region, Fdowncase_region, Fcapitalize_region,
Erik Naggum <erik@naggum.no>
parents:
12244
diff
changeset
|
311 casify_region (CASE_CAPITALIZE_UP, beg, end); |
9053
4887fc1a2dda
(Fupcase_initials_region): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9052
diff
changeset
|
312 return Qnil; |
4887fc1a2dda
(Fupcase_initials_region): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9052
diff
changeset
|
313 } |
118 | 314 |
315 Lisp_Object | |
6221
c2d29681d218
(operate_on_word): Don't move point; store in *NEWPOINT.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
316 operate_on_word (arg, newpoint) |
118 | 317 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
|
318 int *newpoint; |
118 | 319 { |
1505
4f138b03e5ab
* casefiddle.c (operate_on_word): Declare end to be an int, not a
Jim Blandy <jimb@redhat.com>
parents:
484
diff
changeset
|
320 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
|
321 int farend; |
12089
f7cb17ca1815
(casify_region): Use explicit local vars for start
Karl Heuer <kwzh@gnu.org>
parents:
9299
diff
changeset
|
322 int iarg; |
118 | 323 |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40103
diff
changeset
|
324 CHECK_NUMBER (arg); |
12089
f7cb17ca1815
(casify_region): Use explicit local vars for start
Karl Heuer <kwzh@gnu.org>
parents:
9299
diff
changeset
|
325 iarg = XINT (arg); |
16039
855c8d8ba0f0
Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents:
15170
diff
changeset
|
326 farend = scan_words (PT, iarg); |
118 | 327 if (!farend) |
12089
f7cb17ca1815
(casify_region): Use explicit local vars for start
Karl Heuer <kwzh@gnu.org>
parents:
9299
diff
changeset
|
328 farend = iarg > 0 ? ZV : BEGV; |
118 | 329 |
16039
855c8d8ba0f0
Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents:
15170
diff
changeset
|
330 *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
|
331 XSETFASTINT (val, farend); |
118 | 332 |
333 return val; | |
334 } | |
335 | |
336 DEFUN ("upcase-word", Fupcase_word, Supcase_word, 1, 1, "p", | |
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
337 doc: /* Convert following word (or ARG words) to upper case, moving over. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
338 With negative argument, convert previous words but do not move. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
339 See also `capitalize-word'. */) |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
340 (arg) |
118 | 341 Lisp_Object arg; |
342 { | |
6221
c2d29681d218
(operate_on_word): Don't move point; store in *NEWPOINT.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
343 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
|
344 int newpoint; |
16039
855c8d8ba0f0
Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents:
15170
diff
changeset
|
345 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
|
346 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
|
347 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
|
348 SET_PT (newpoint); |
118 | 349 return Qnil; |
350 } | |
351 | |
352 DEFUN ("downcase-word", Fdowncase_word, Sdowncase_word, 1, 1, "p", | |
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
353 doc: /* Convert following word (or ARG words) to lower case, moving over. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
354 With negative argument, convert previous words but do not move. */) |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
355 (arg) |
118 | 356 Lisp_Object arg; |
357 { | |
6221
c2d29681d218
(operate_on_word): Don't move point; store in *NEWPOINT.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
358 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
|
359 int newpoint; |
16039
855c8d8ba0f0
Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents:
15170
diff
changeset
|
360 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
|
361 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
|
362 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
|
363 SET_PT (newpoint); |
118 | 364 return Qnil; |
365 } | |
366 | |
367 DEFUN ("capitalize-word", Fcapitalize_word, Scapitalize_word, 1, 1, "p", | |
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
368 doc: /* Capitalize the following word (or ARG words), moving over. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
369 This gives the word(s) a first character in upper case |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
370 and the rest lower case. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
371 With negative argument, capitalize previous words but do not move. */) |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39748
diff
changeset
|
372 (arg) |
118 | 373 Lisp_Object arg; |
374 { | |
6221
c2d29681d218
(operate_on_word): Don't move point; store in *NEWPOINT.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
375 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
|
376 int newpoint; |
16039
855c8d8ba0f0
Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents:
15170
diff
changeset
|
377 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
|
378 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
|
379 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
|
380 SET_PT (newpoint); |
118 | 381 return Qnil; |
382 } | |
383 | |
21514 | 384 void |
118 | 385 syms_of_casefiddle () |
386 { | |
17816 | 387 Qidentity = intern ("identity"); |
388 staticpro (&Qidentity); | |
118 | 389 defsubr (&Supcase); |
390 defsubr (&Sdowncase); | |
391 defsubr (&Scapitalize); | |
9053
4887fc1a2dda
(Fupcase_initials_region): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9052
diff
changeset
|
392 defsubr (&Supcase_initials); |
118 | 393 defsubr (&Supcase_region); |
394 defsubr (&Sdowncase_region); | |
395 defsubr (&Scapitalize_region); | |
9053
4887fc1a2dda
(Fupcase_initials_region): New function.
Richard M. Stallman <rms@gnu.org>
parents:
9052
diff
changeset
|
396 defsubr (&Supcase_initials_region); |
118 | 397 defsubr (&Supcase_word); |
398 defsubr (&Sdowncase_word); | |
399 defsubr (&Scapitalize_word); | |
400 } | |
401 | |
21514 | 402 void |
118 | 403 keys_of_casefiddle () |
404 { | |
405 initial_define_key (control_x_map, Ctl('U'), "upcase-region"); | |
484 | 406 Fput (intern ("upcase-region"), Qdisabled, Qt); |
118 | 407 initial_define_key (control_x_map, Ctl('L'), "downcase-region"); |
484 | 408 Fput (intern ("downcase-region"), Qdisabled, Qt); |
409 | |
118 | 410 initial_define_key (meta_map, 'u', "upcase-word"); |
411 initial_define_key (meta_map, 'l', "downcase-word"); | |
412 initial_define_key (meta_map, 'c', "capitalize-word"); | |
413 } |