annotate src/casefiddle.c @ 183:e121b013d1f0 r20-3b18

Import from CVS: tag r20-3b18
author cvs
date Mon, 13 Aug 2007 09:54:23 +0200
parents 85ec50267440
children 3d6bfa290dbd
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 /* XEmacs case conversion functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 Copyright (C) 1985, 1992, 1993, 1994 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 under the terms of the GNU General Public License as published by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 Free Software Foundation; either version 2, or (at your option) any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 along with XEmacs; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 Boston, MA 02111-1307, USA. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
21 /* Synched up with: FSF 19.34. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 #include <config.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 #include "lisp.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 #include "buffer.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 #include "commands.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 #include "insdel.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 #include "syntax.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 enum case_action {CASE_UP, CASE_DOWN, CASE_CAPITALIZE, CASE_CAPITALIZE_UP};
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 static Lisp_Object
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
34 casify_object (enum case_action flag, Lisp_Object obj, Lisp_Object buffer)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 {
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
36 struct buffer *buf = decode_buffer (buffer, 0);
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
37 REGISTER int inword = (flag == CASE_DOWN);
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
38 struct Lisp_Char_Table *syntax_table = XCHAR_TABLE (buf->mirror_syntax_table);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 while (1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 if (CHAR_OR_CHAR_INTP (obj))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 {
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
44 Emchar c;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 CHECK_CHAR_COERCE_INT (obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 c = XCHAR (obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 if (IN_TRT_TABLE_DOMAIN (c))
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
48 obj = make_char (inword ? DOWNCASE (buf, c) : UPCASE1 (buf, c));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 return obj;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 if (STRINGP (obj))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 {
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
53 Charcount i;
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
54 Charcount len = string_char_length (XSTRING (obj));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 obj = Fcopy_sequence (obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 for (i = 0; i < len; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 {
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
58 Emchar c = string_char (XSTRING (obj), i);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 if (inword)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 c = DOWNCASE (buf, c);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 else if (!UPPERCASEP (buf, c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 && (!inword || flag != CASE_CAPITALIZE_UP))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 c = UPCASE1 (buf, c);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 set_string_char (XSTRING (obj), i, c);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 if ((int) flag >= (int) CASE_CAPITALIZE)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 inword = WORD_SYNTAX_P (syntax_table, c);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 return obj;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 obj = wrong_type_argument (Qchar_or_string_p, obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
74 DEFUN ("upcase", Fupcase, 1, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 Convert argument to upper case and return that.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 The argument may be a character or string. The result has the same type.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 The argument object is not altered--the value is a copy.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 See also `capitalize', `downcase' and `upcase-initials'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 Optional second arg BUFFER specifies which buffer's case tables to use,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 and defaults to the current buffer.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
81 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
82 (obj, buffer))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 {
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
84 return casify_object (CASE_UP, obj, buffer);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
87 DEFUN ("downcase", Fdowncase, 1, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 Convert argument to lower case and return that.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 The argument may be a character or string. The result has the same type.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 The argument object is not altered--the value is a copy.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 Optional second arg BUFFER specifies which buffer's case tables to use,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 and defaults to the current buffer.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
93 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
94 (obj, buffer))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 {
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
96 return casify_object (CASE_DOWN, obj, buffer);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
99 DEFUN ("capitalize", Fcapitalize, 1, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 Convert argument to capitalized form and return that.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 This means that each word's first character is upper case
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 and the rest is lower case.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 The argument may be a character or string. The result has the same type.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 The argument object is not altered--the value is a copy.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 Optional second arg BUFFER specifies which buffer's case tables to use,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 and defaults to the current buffer.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
107 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
108 (obj, buffer))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 {
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
110 return casify_object (CASE_CAPITALIZE, obj, buffer);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 /* Like Fcapitalize but change only the initials. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
115 DEFUN ("upcase-initials", Fupcase_initials, 1, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 Convert the initial of each word in the argument to upper case.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 Do not change the other letters of each word.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 The argument may be a character or string. The result has the same type.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 The argument object is not altered--the value is a copy.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 Optional second arg BUFFER specifies which buffer's case tables to use,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 and defaults to the current buffer.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
122 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
123 (obj, buffer))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 {
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
125 return casify_object (CASE_CAPITALIZE_UP, obj, buffer);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 /* flag is CASE_UP, CASE_DOWN or CASE_CAPITALIZE or CASE_CAPITALIZE_UP.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 b and e specify range of buffer to operate on. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 static void
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
132 casify_region_internal (enum case_action flag, Lisp_Object b, Lisp_Object e,
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
133 struct buffer *buf)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 /* This function can GC */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 REGISTER Bufpos i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 Bufpos start, end;
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
138 REGISTER int inword = (flag == CASE_DOWN);
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
139 struct Lisp_Char_Table *syntax_table = XCHAR_TABLE (buf->mirror_syntax_table);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 int mccount;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 if (EQ (b, e))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 /* Not modifying because nothing marked */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 get_buffer_range_char (buf, b, e, &start, &end, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 mccount = begin_multiple_change (buf, start, end);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 record_change (buf, start, end - start);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 for (i = start; i < end; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 {
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
153 Emchar c = BUF_FETCH_CHAR (buf, i);
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
154 Emchar oldc = c;
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
155
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 if (inword && flag != CASE_CAPITALIZE_UP)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 c = DOWNCASE (buf, c);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 else if (!UPPERCASEP (buf, c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 && (!inword || flag != CASE_CAPITALIZE_UP))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 c = UPCASE1 (buf, c);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
162 if (oldc != c)
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
163 {
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
164 buffer_replace_char (buf, i, c, 1, (i == start));
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
165 BUF_MODIFF (buf)++;
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
166 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 /* !!#### need to revalidate the start and end pointers in case
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 the buffer was changed */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 if ((int) flag >= (int) CASE_CAPITALIZE)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 inword = WORD_SYNTAX_P (syntax_table, c);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 end_multiple_change (buf, mccount);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
175 INLINE Lisp_Object
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
176 casify_region (enum case_action flag, Lisp_Object b, Lisp_Object e,
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
177 Lisp_Object buffer)
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
178 {
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
179 casify_region_internal (flag, b, e, decode_buffer (buffer, 1));
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
180 return Qnil;
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
181 }
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
182
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
183 DEFUN ("upcase-region", Fupcase_region, 2, 3, "r", /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 Convert the region to upper case. In programs, wants two arguments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 These arguments specify the starting and ending character numbers of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 the region to operate on. When used as a command, the text between
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 point and the mark is operated on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 See also `capitalize-region'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 Optional third arg BUFFER defaults to the current buffer.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
190 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
191 (b, e, buffer))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 /* This function can GC */
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
194 return casify_region (CASE_UP, b, e, buffer);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
197 DEFUN ("downcase-region", Fdowncase_region, 2, 3, "r", /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 Convert the region to lower case. In programs, wants two arguments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 These arguments specify the starting and ending character numbers of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 the region to operate on. When used as a command, the text between
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 point and the mark is operated on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 Optional third arg BUFFER defaults to the current buffer.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
203 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
204 (b, e, buffer))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 /* This function can GC */
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
207 return casify_region (CASE_DOWN, b, e, buffer);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
210 DEFUN ("capitalize-region", Fcapitalize_region, 2, 3, "r", /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 Convert the region to capitalized form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 Capitalized form means each word's first character is upper case
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 and the rest of it is lower case.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 In programs, give two arguments, the starting and ending
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 character positions to operate on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 Optional third arg BUFFER defaults to the current buffer.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
217 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
218 (b, e, buffer))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 /* This function can GC */
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
221 return casify_region (CASE_CAPITALIZE, b, e, buffer);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 /* Like Fcapitalize_region but change only the initials. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
226 DEFUN ("upcase-initials-region", Fupcase_initials_region, 2, 3, "r", /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 Upcase the initial of each word in the region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 Subsequent letters of each word are not changed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 In programs, give two arguments, the starting and ending
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 character positions to operate on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 Optional third arg BUFFER defaults to the current buffer.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
232 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
233 (b, e, buffer))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 {
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
235 return casify_region (CASE_CAPITALIZE_UP, b, e, buffer);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 static Lisp_Object
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
240 casify_word (enum case_action flag, Lisp_Object arg, Lisp_Object buffer)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 Bufpos farend;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
243 struct buffer *buf = decode_buffer (buffer, 1);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 CHECK_INT (arg);
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
246
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 farend = scan_words (buf, BUF_PT (buf), XINT (arg));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 if (!farend)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 farend = XINT (arg) > 0 ? BUF_ZV (buf) : BUF_BEGV (buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
251 casify_region_internal (flag, make_int (BUF_PT (buf)), make_int (farend), buf);
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
252 BUF_SET_PT (buf, max (BUF_PT (buf), farend));
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
253 return Qnil;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
256 DEFUN ("upcase-word", Fupcase_word, 1, 2, "p", /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 Convert following word (or ARG words) to upper case, moving over.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 With negative argument, convert previous words but do not move.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 See also `capitalize-word'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 Optional second arg BUFFER defaults to the current buffer.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
261 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
262 (arg, buffer))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 /* This function can GC */
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
265 return casify_word (CASE_UP, arg, buffer);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
268 DEFUN ("downcase-word", Fdowncase_word, 1, 2, "p", /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 Convert following word (or ARG words) to lower case, moving over.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 With negative argument, convert previous words but do not move.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 Optional second arg BUFFER defaults to the current buffer.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
272 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
273 (arg, buffer))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 /* This function can GC */
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
276 return casify_word (CASE_DOWN, arg, buffer);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
279 DEFUN ("capitalize-word", Fcapitalize_word, 1, 2, "p", /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 Capitalize the following word (or ARG words), moving over.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 This gives the word(s) a first character in upper case
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 and the rest lower case.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 With negative argument, capitalize previous words but do not move.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 Optional second arg BUFFER defaults to the current buffer.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
285 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
286 (arg, buffer))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 /* This function can GC */
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
289 return casify_word (CASE_CAPITALIZE, arg, buffer);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 syms_of_casefiddle (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 {
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
296 DEFSUBR (Fupcase);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
297 DEFSUBR (Fdowncase);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
298 DEFSUBR (Fcapitalize);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
299 DEFSUBR (Fupcase_initials);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
300 DEFSUBR (Fupcase_region);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
301 DEFSUBR (Fdowncase_region);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
302 DEFSUBR (Fcapitalize_region);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
303 DEFSUBR (Fupcase_initials_region);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
304 DEFSUBR (Fupcase_word);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
305 DEFSUBR (Fdowncase_word);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
306 DEFSUBR (Fcapitalize_word);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 }