annotate src/casefiddle.c @ 5864:750fab17b299

Make #'parse-integer Lisp-visible, extend it, allowing non-ASCII digits. src/ChangeLog addition: 2015-02-25 Aidan Kehoe <kehoea@parhasard.net> * lread.c (read_atom): Use the new calling convention for parse_integer(). * lisp.h: Change the declaration of parse_integer (). * number.h (bignum_set_emacs_int, make_bignum_emacs_uint): New #defines, used in data.c. * lread.c (read_integer): Ditto. * lread.c (read1): Ditto. * data.c (find_highest_value): New. * data.c (fill_ichar_array): New. * data.c (build_fixnum_to_char_map): New. * data.c (Fset_digit_fixnum_map): New. * data.c (Fdigit_char_p): Moved from cl-extra.el. * data.c (Fdigit_char): Moved from cl-extra.el. * data.c (parse_integer): Moved from lread.c. * data.c (Fparse_integer): Made available to Lisp. * data.c (syms_of_data): Make the new subrs available. * data.c (vars_of_data): Make the new vars available. Expose parse_integer to Lisp, make it follow the Common Lisp API (with some extensions, to allow us to support non ASCII digit characters). lisp/ChangeLog addition: 2015-02-25 Aidan Kehoe <kehoea@parhasard.net> * cl-extra.el (digit-char-p): Moved to data.c. * cl-extra.el (digit-char): Moved to data.c. tests/ChangeLog addition: 2015-02-25 Aidan Kehoe <kehoea@parhasard.net> * automated/lisp-tests.el: parse_integer(), used in #'read, now signals invalid-argument rather than invalid-read-syntax, check for that. * automated/lisp-tests.el: Check #'parse-integer now it's available to Lisp, check #'digit-char, #'digit-char-p and the congruence in behaviour, check the XEmacs-specific RADIX-TABLE argument behaviour.
author Aidan Kehoe <kehoea@parhasard.net>
date Wed, 25 Feb 2015 11:47:12 +0000
parents 56144c8593a8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 /* XEmacs case conversion functions.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 Copyright (C) 1985, 1992, 1993, 1994, 1997, 1998 Free Software Foundation, Inc.
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
3 Copyright (C) 2002 Ben Wing.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5 This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4910
diff changeset
7 XEmacs is free software: you can redistribute it and/or modify it
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4910
diff changeset
9 Free Software Foundation, either version 3 of the License, or (at your
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4910
diff changeset
10 option) any later version.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4910
diff changeset
18 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 /* Synched up with: FSF 19.34, but substantially rewritten by Martin. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 #include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 #include "lisp.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 #include "buffer.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 #include "insdel.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 #include "syntax.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28
4910
6bc1f3f6cf0d Make canoncase visible to Lisp; use it with chars in internal_equalp.
Aidan Kehoe <kehoea@parhasard.net>
parents: 2367
diff changeset
29 enum case_action {CASE_UP, CASE_DOWN, CASE_CAPITALIZE, CASE_CAPITALIZE_UP,
6bc1f3f6cf0d Make canoncase visible to Lisp; use it with chars in internal_equalp.
Aidan Kehoe <kehoea@parhasard.net>
parents: 2367
diff changeset
30 CASE_CANONICALIZE};
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 static Lisp_Object
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
33 casify_object (enum case_action flag, Lisp_Object string_or_char,
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
34 Lisp_Object buffer)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 struct buffer *buf = decode_buffer (buffer, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 retry:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
40 if (CHAR_OR_CHAR_INTP (string_or_char))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 {
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
42 Ichar c;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
43 CHECK_CHAR_COERCE_INT (string_or_char);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
44 c = XCHAR (string_or_char);
4910
6bc1f3f6cf0d Make canoncase visible to Lisp; use it with chars in internal_equalp.
Aidan Kehoe <kehoea@parhasard.net>
parents: 2367
diff changeset
45 if (flag == CASE_DOWN)
6bc1f3f6cf0d Make canoncase visible to Lisp; use it with chars in internal_equalp.
Aidan Kehoe <kehoea@parhasard.net>
parents: 2367
diff changeset
46 {
6bc1f3f6cf0d Make canoncase visible to Lisp; use it with chars in internal_equalp.
Aidan Kehoe <kehoea@parhasard.net>
parents: 2367
diff changeset
47 c = DOWNCASE (buf, c);
6bc1f3f6cf0d Make canoncase visible to Lisp; use it with chars in internal_equalp.
Aidan Kehoe <kehoea@parhasard.net>
parents: 2367
diff changeset
48 }
6bc1f3f6cf0d Make canoncase visible to Lisp; use it with chars in internal_equalp.
Aidan Kehoe <kehoea@parhasard.net>
parents: 2367
diff changeset
49 else if (flag == CASE_UP)
6bc1f3f6cf0d Make canoncase visible to Lisp; use it with chars in internal_equalp.
Aidan Kehoe <kehoea@parhasard.net>
parents: 2367
diff changeset
50 {
6bc1f3f6cf0d Make canoncase visible to Lisp; use it with chars in internal_equalp.
Aidan Kehoe <kehoea@parhasard.net>
parents: 2367
diff changeset
51 c = UPCASE (buf, c);
6bc1f3f6cf0d Make canoncase visible to Lisp; use it with chars in internal_equalp.
Aidan Kehoe <kehoea@parhasard.net>
parents: 2367
diff changeset
52 }
6bc1f3f6cf0d Make canoncase visible to Lisp; use it with chars in internal_equalp.
Aidan Kehoe <kehoea@parhasard.net>
parents: 2367
diff changeset
53 else
6bc1f3f6cf0d Make canoncase visible to Lisp; use it with chars in internal_equalp.
Aidan Kehoe <kehoea@parhasard.net>
parents: 2367
diff changeset
54 {
6bc1f3f6cf0d Make canoncase visible to Lisp; use it with chars in internal_equalp.
Aidan Kehoe <kehoea@parhasard.net>
parents: 2367
diff changeset
55 c = CANONCASE (buf, c);
6bc1f3f6cf0d Make canoncase visible to Lisp; use it with chars in internal_equalp.
Aidan Kehoe <kehoea@parhasard.net>
parents: 2367
diff changeset
56 }
6bc1f3f6cf0d Make canoncase visible to Lisp; use it with chars in internal_equalp.
Aidan Kehoe <kehoea@parhasard.net>
parents: 2367
diff changeset
57
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 return make_char (c);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
61 if (STRINGP (string_or_char))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 {
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
63 Lisp_Object syntax_table = buf->mirror_syntax_table;
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
64 Ibyte *storage =
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 867
diff changeset
65 alloca_ibytes (XSTRING_LENGTH (string_or_char) * MAX_ICHAR_LEN);
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
66 Ibyte *newp = storage;
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
67 Ibyte *oldp = XSTRING_DATA (string_or_char);
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
68 Ibyte *endp = oldp + XSTRING_LENGTH (string_or_char);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 int wordp = 0, wordp_prev;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
71 while (oldp < endp)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 {
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
73 Ichar c = itext_ichar (oldp);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 switch (flag)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 case CASE_UP:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 c = UPCASE (buf, c);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 case CASE_DOWN:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 c = DOWNCASE (buf, c);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 break;
4910
6bc1f3f6cf0d Make canoncase visible to Lisp; use it with chars in internal_equalp.
Aidan Kehoe <kehoea@parhasard.net>
parents: 2367
diff changeset
82 case CASE_CANONICALIZE:
6bc1f3f6cf0d Make canoncase visible to Lisp; use it with chars in internal_equalp.
Aidan Kehoe <kehoea@parhasard.net>
parents: 2367
diff changeset
83 c = CANONCASE (buf, c);
6bc1f3f6cf0d Make canoncase visible to Lisp; use it with chars in internal_equalp.
Aidan Kehoe <kehoea@parhasard.net>
parents: 2367
diff changeset
84 break;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 case CASE_CAPITALIZE:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 case CASE_CAPITALIZE_UP:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 wordp_prev = wordp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 wordp = WORD_SYNTAX_P (syntax_table, c);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 if (!wordp) break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 if (wordp_prev)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 if (flag == CASE_CAPITALIZE)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 c = DOWNCASE (buf, c);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 c = UPCASE (buf, c);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
100 newp += set_itext_ichar (newp, c);
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
101 INC_IBYTEPTR (oldp);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 return make_string (storage, newp - storage);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
107 string_or_char = wrong_type_argument (Qchar_or_string_p, string_or_char);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 goto retry;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 DEFUN ("upcase", Fupcase, 1, 2, 0, /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
112 Convert STRING-OR-CHAR to upper case and return that.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
113 STRING-OR-CHAR may be a character or string. The result has the same type.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
114 STRING-OR-CHAR is not altered--the value is a copy.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 See also `capitalize', `downcase' and `upcase-initials'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 Optional second arg BUFFER specifies which buffer's case tables to use,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 and defaults to the current buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
119 (string_or_char, buffer))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
121 return casify_object (CASE_UP, string_or_char, buffer);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 DEFUN ("downcase", Fdowncase, 1, 2, 0, /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
125 Convert STRING-OR-CHAR to lower case and return that.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
126 STRING-OR-CHAR may be a character or string. The result has the same type.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
127 STRING-OR-CHAR is not altered--the value is a copy.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 Optional second arg BUFFER specifies which buffer's case tables to use,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 and defaults to the current buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
131 (string_or_char, buffer))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
133 return casify_object (CASE_DOWN, string_or_char, buffer);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135
4910
6bc1f3f6cf0d Make canoncase visible to Lisp; use it with chars in internal_equalp.
Aidan Kehoe <kehoea@parhasard.net>
parents: 2367
diff changeset
136 DEFUN ("canoncase", Fcanoncase, 1, 2, 0, /*
6bc1f3f6cf0d Make canoncase visible to Lisp; use it with chars in internal_equalp.
Aidan Kehoe <kehoea@parhasard.net>
parents: 2367
diff changeset
137 Convert STRING-OR-CHAR to its canonical lowercase form and return that.
6bc1f3f6cf0d Make canoncase visible to Lisp; use it with chars in internal_equalp.
Aidan Kehoe <kehoea@parhasard.net>
parents: 2367
diff changeset
138
6bc1f3f6cf0d Make canoncase visible to Lisp; use it with chars in internal_equalp.
Aidan Kehoe <kehoea@parhasard.net>
parents: 2367
diff changeset
139 STRING-OR-CHAR may be a character or string. The result has the same type.
6bc1f3f6cf0d Make canoncase visible to Lisp; use it with chars in internal_equalp.
Aidan Kehoe <kehoea@parhasard.net>
parents: 2367
diff changeset
140 STRING-OR-CHAR is not altered--the value is a copy.
6bc1f3f6cf0d Make canoncase visible to Lisp; use it with chars in internal_equalp.
Aidan Kehoe <kehoea@parhasard.net>
parents: 2367
diff changeset
141
6bc1f3f6cf0d Make canoncase visible to Lisp; use it with chars in internal_equalp.
Aidan Kehoe <kehoea@parhasard.net>
parents: 2367
diff changeset
142 Optional second arg BUFFER specifies which buffer's case tables to use,
6bc1f3f6cf0d Make canoncase visible to Lisp; use it with chars in internal_equalp.
Aidan Kehoe <kehoea@parhasard.net>
parents: 2367
diff changeset
143 and defaults to the current buffer.
6bc1f3f6cf0d Make canoncase visible to Lisp; use it with chars in internal_equalp.
Aidan Kehoe <kehoea@parhasard.net>
parents: 2367
diff changeset
144
6bc1f3f6cf0d Make canoncase visible to Lisp; use it with chars in internal_equalp.
Aidan Kehoe <kehoea@parhasard.net>
parents: 2367
diff changeset
145 For any N characters that are equivalent in case-insensitive searching,
6bc1f3f6cf0d Make canoncase visible to Lisp; use it with chars in internal_equalp.
Aidan Kehoe <kehoea@parhasard.net>
parents: 2367
diff changeset
146 their canonical lowercase character will be the same.
6bc1f3f6cf0d Make canoncase visible to Lisp; use it with chars in internal_equalp.
Aidan Kehoe <kehoea@parhasard.net>
parents: 2367
diff changeset
147 */
6bc1f3f6cf0d Make canoncase visible to Lisp; use it with chars in internal_equalp.
Aidan Kehoe <kehoea@parhasard.net>
parents: 2367
diff changeset
148 (string_or_char, buffer))
6bc1f3f6cf0d Make canoncase visible to Lisp; use it with chars in internal_equalp.
Aidan Kehoe <kehoea@parhasard.net>
parents: 2367
diff changeset
149 {
6bc1f3f6cf0d Make canoncase visible to Lisp; use it with chars in internal_equalp.
Aidan Kehoe <kehoea@parhasard.net>
parents: 2367
diff changeset
150 return casify_object (CASE_CANONICALIZE, string_or_char, buffer);
6bc1f3f6cf0d Make canoncase visible to Lisp; use it with chars in internal_equalp.
Aidan Kehoe <kehoea@parhasard.net>
parents: 2367
diff changeset
151 }
6bc1f3f6cf0d Make canoncase visible to Lisp; use it with chars in internal_equalp.
Aidan Kehoe <kehoea@parhasard.net>
parents: 2367
diff changeset
152
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 DEFUN ("capitalize", Fcapitalize, 1, 2, 0, /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
154 Convert STRING-OR-CHAR to capitalized form and return that.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 This means that each word's first character is upper case
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 and the rest is lower case.
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
157 STRING-OR-CHAR may be a character or string. The result has the same type.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
158 STRING-OR-CHAR is not altered--the value is a copy.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 Optional second arg BUFFER specifies which buffer's case tables to use,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 and defaults to the current buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
162 (string_or_char, buffer))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
164 return casify_object (CASE_CAPITALIZE, string_or_char, buffer);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 /* Like Fcapitalize but change only the initial characters. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 DEFUN ("upcase-initials", Fupcase_initials, 1, 2, 0, /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
170 Convert the initial of each word in STRING-OR-CHAR to upper case.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 Do not change the other letters of each word.
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
172 STRING-OR-CHAR may be a character or string. The result has the same type.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
173 STRING-OR-CHAR is not altered--the value is a copy.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 Optional second arg BUFFER specifies which buffer's case tables to use,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 and defaults to the current buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
177 (string_or_char, buffer))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
179 return casify_object (CASE_CAPITALIZE_UP, string_or_char, buffer);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 /* flag is CASE_UP, CASE_DOWN or CASE_CAPITALIZE or CASE_CAPITALIZE_UP.
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
183 START and END specify range of buffer to operate on. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 static void
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
186 casify_region_internal (enum case_action flag, Lisp_Object start,
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
187 Lisp_Object end, struct buffer *buf)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 /* This function can GC */
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 444
diff changeset
190 Charbpos pos, s, e;
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 771
diff changeset
191 Lisp_Object syntax_table = buf->mirror_syntax_table;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 int mccount;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 int wordp = 0, wordp_prev;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
195 if (EQ (start, end))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 /* Not modifying because nothing marked */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
199 get_buffer_range_char (buf, start, end, &s, &e, 0);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
200
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
201 mccount = begin_multiple_change (buf, s, e);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
202 record_change (buf, s, e - s);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
204 for (pos = s; pos < e; pos++)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 {
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
206 Ichar oldc = BUF_FETCH_CHAR (buf, pos);
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
207 Ichar c = oldc;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 switch (flag)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 case CASE_UP:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 c = UPCASE (buf, oldc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 case CASE_DOWN:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 c = DOWNCASE (buf, oldc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 case CASE_CAPITALIZE:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 case CASE_CAPITALIZE_UP:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 /* !!#### need to revalidate the start and end pointers in case
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 the buffer was changed */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 wordp_prev = wordp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 wordp = WORD_SYNTAX_P (syntax_table, c);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 if (!wordp) continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 if (wordp_prev)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 if (flag == CASE_CAPITALIZE)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 c = DOWNCASE (buf, c);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 c = UPCASE (buf, c);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 if (oldc == c) continue;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
235 buffer_replace_char (buf, pos, c, 1, (pos == s));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 BUF_MODIFF (buf)++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239 end_multiple_change (buf, mccount);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 static Lisp_Object
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
243 casify_region (enum case_action flag, Lisp_Object start, Lisp_Object end,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244 Lisp_Object buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
246 casify_region_internal (flag, start, end, decode_buffer (buffer, 1));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 DEFUN ("upcase-region", Fupcase_region, 2, 3, "r", /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 Convert the region to upper case. In programs, wants two arguments.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 These arguments specify the starting and ending character numbers of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 the region to operate on. When used as a command, the text between
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 point and the mark is operated on.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 See also `capitalize-region'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 Optional third arg BUFFER defaults to the current buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
258 (start, end, buffer))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 /* This function can GC */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
261 return casify_region (CASE_UP, start, end, buffer);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 DEFUN ("downcase-region", Fdowncase_region, 2, 3, "r", /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 Convert the region to lower case. In programs, wants two arguments.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 These arguments specify the starting and ending character numbers of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 the region to operate on. When used as a command, the text between
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 point and the mark is operated on.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 Optional third arg BUFFER defaults to the current buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
271 (start, end, buffer))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 /* This function can GC */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
274 return casify_region (CASE_DOWN, start, end, buffer);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 DEFUN ("capitalize-region", Fcapitalize_region, 2, 3, "r", /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 Convert the region to capitalized form.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 Capitalized form means each word's first character is upper case
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 and the rest of it is lower case.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 In programs, give two arguments, the starting and ending
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 character positions to operate on.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 Optional third arg BUFFER defaults to the current buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
285 (start, end, buffer))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 /* This function can GC */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
288 return casify_region (CASE_CAPITALIZE, start, end, buffer);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 /* Like Fcapitalize_region but change only the initials. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293 DEFUN ("upcase-initials-region", Fupcase_initials_region, 2, 3, "r", /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 Upcase the initial of each word in the region.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 Subsequent letters of each word are not changed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296 In programs, give two arguments, the starting and ending
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297 character positions to operate on.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 Optional third arg BUFFER defaults to the current buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
300 (start, end, buffer))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
302 return casify_region (CASE_CAPITALIZE_UP, start, end, buffer);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 static Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 casify_word (enum case_action flag, Lisp_Object arg, Lisp_Object buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 {
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 444
diff changeset
309 Charbpos farend;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 struct buffer *buf = decode_buffer (buffer, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
312 CHECK_FIXNUM (arg);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
314 farend = scan_words (buf, BUF_PT (buf), XFIXNUM (arg));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 if (!farend)
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
316 farend = XFIXNUM (arg) > 0 ? BUF_ZV (buf) : BUF_BEGV (buf);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
318 casify_region_internal (flag, make_fixnum (BUF_PT (buf)), make_fixnum (farend), buf);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 BUF_SET_PT (buf, max (BUF_PT (buf), farend));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323 DEFUN ("upcase-word", Fupcase_word, 1, 2, "p", /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
324 Convert following word (or COUNT words) to upper case, moving over.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 With negative argument, convert previous words but do not move.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326 See also `capitalize-word'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 Optional second arg BUFFER defaults to the current buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
329 (count, buffer))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 /* This function can GC */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
332 return casify_word (CASE_UP, count, buffer);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335 DEFUN ("downcase-word", Fdowncase_word, 1, 2, "p", /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
336 Convert following word (or COUNT words) to lower case, moving over.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 With negative argument, convert previous words but do not move.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338 Optional second arg BUFFER defaults to the current buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
340 (count, buffer))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342 /* This function can GC */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
343 return casify_word (CASE_DOWN, count, buffer);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346 DEFUN ("capitalize-word", Fcapitalize_word, 1, 2, "p", /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
347 Capitalize the following word (or COUNT words), moving over.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 This gives the word(s) a first character in upper case
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 and the rest lower case.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 With negative argument, capitalize previous words but do not move.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 Optional second arg BUFFER defaults to the current buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
353 (count, buffer))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 /* This function can GC */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
356 return casify_word (CASE_CAPITALIZE, count, buffer);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361 syms_of_casefiddle (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363 DEFSUBR (Fupcase);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364 DEFSUBR (Fdowncase);
4910
6bc1f3f6cf0d Make canoncase visible to Lisp; use it with chars in internal_equalp.
Aidan Kehoe <kehoea@parhasard.net>
parents: 2367
diff changeset
365 DEFSUBR (Fcanoncase);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 DEFSUBR (Fcapitalize);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 DEFSUBR (Fupcase_initials);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368 DEFSUBR (Fupcase_region);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 DEFSUBR (Fdowncase_region);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 DEFSUBR (Fcapitalize_region);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 DEFSUBR (Fupcase_initials_region);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372 DEFSUBR (Fupcase_word);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373 DEFSUBR (Fdowncase_word);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 DEFSUBR (Fcapitalize_word);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 }