annotate src/cmds.c @ 97:498bf5da1c90

Added tag r20-0final for changeset dbb370e3c29e
author cvs
date Mon, 13 Aug 2007 09:12:43 +0200
parents 54cc21c15cbb
children 0d2f883870bc
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 /* Simple built-in editing commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 Copyright (C) 1985, 1992, 1993, 1994, 1995 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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 /* Synched up with: Mule 2.0, FSF 19.30. */
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 #include "commands.h"
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 "syntax.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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 Lisp_Object Qkill_forward_chars;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 Lisp_Object Qself_insert_command;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 Lisp_Object Vblink_paren_function;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 /* A possible value for a buffer's overwrite-mode variable. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 Lisp_Object Qoverwrite_mode_binary;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 /* Non-nil means put this face on the next self-inserting character. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 Lisp_Object Vself_insert_face;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 /* This is the command that set up Vself_insert_face. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 Lisp_Object Vself_insert_face_command;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 18
diff changeset
45 DEFUN ("forward-char", Fforward_char, 0, 2, "_p", /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 Move point right ARG characters (left if ARG negative).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 On reaching end of buffer, stop and signal error.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
48 If BUFFER is nil, the current buffer is assumed.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 18
diff changeset
49 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 18
diff changeset
50 (arg, buffer))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 struct buffer *buf = decode_buffer (buffer, 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 if (NILP (arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 arg = make_int (1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 CHECK_INT (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 /* This used to just set point to point + XINT (arg), and then check
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 to see if it was within boundaries. But now that SET_PT can
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 potentially do a lot of stuff (calling entering and exiting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 hooks, etcetera), that's not a good approach. So we validate the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 proposed position, then set point. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 Bufpos new_point = BUF_PT (buf) + XINT (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 if (new_point < BUF_BEGV (buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 BUF_SET_PT (buf, BUF_BEGV (buf));
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
70 Fsignal (Qbeginning_of_buffer, Qnil);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 if (new_point > BUF_ZV (buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 BUF_SET_PT (buf, BUF_ZV (buf));
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
75 Fsignal (Qend_of_buffer, Qnil);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 BUF_SET_PT (buf, new_point);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 18
diff changeset
84 DEFUN ("backward-char", Fbackward_char, 0, 2, "_p", /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 Move point left ARG characters (right if ARG negative).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 On attempt to pass beginning or end of buffer, stop and signal error.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
87 If BUFFER is nil, the current buffer is assumed.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 18
diff changeset
88 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 18
diff changeset
89 (arg, buffer))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 if (NILP (arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 arg = make_int (1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 CHECK_INT (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 XSETINT (arg, - XINT (arg));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 return Fforward_char (arg, buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 18
diff changeset
100 DEFUN ("forward-line", Fforward_line, 0, 2, "_p", /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 Move ARG lines forward (backward if ARG is negative).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 Precisely, if point is on line I, move to the start of line I + ARG.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 If there isn't room, go as far as possible (no error).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 Returns the count of lines left to move. If moving forward,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 that is ARG - number of lines moved; if backward, ARG + number moved.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 With positive ARG, a non-empty line at the end counts as one line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 successfully moved (for the return value).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 If BUFFER is nil, the current buffer is assumed.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 18
diff changeset
109 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 18
diff changeset
110 (arg, 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 struct buffer *buf = decode_buffer (buffer, 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 Bufpos pos2 = BUF_PT (buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 Bufpos pos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 int count, shortage, negp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 if (NILP (arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 count = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 CHECK_INT (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 count = XINT (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 negp = count <= 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 pos = scan_buffer (buf, '\n', pos2, 0, count - negp, &shortage, 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 if (shortage > 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 && (negp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 || (BUF_ZV (buf) > BUF_BEGV (buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 && pos != pos2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 && BUF_FETCH_CHAR (buf, pos - 1) != '\n')))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 shortage--;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 BUF_SET_PT (buf, pos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 return make_int (negp ? - shortage : shortage);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
137 DEFUN ("point-at-bol", Fpoint_at_bol, 0, 2, 0, /*
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
138 Return the character position of the first character on the current line.
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
139 With argument N not nil or 1, move forward N - 1 lines first.
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
140 If scan reaches end of buffer, return that position.
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
141 This function does not move point.
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
142 */
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
143 (arg, buffer))
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
144 {
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
145 struct buffer *b = decode_buffer (buffer, 1);
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
146 register int orig, end;
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
147
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
148 XSETBUFFER (buffer, b);
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
149 if (NILP (arg))
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
150 arg = make_int (1);
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
151 else
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
152 CHECK_INT (arg);
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
153
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
154 orig = BUF_PT(b);
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
155 Fforward_line (make_int (XINT (arg) - 1), buffer);
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
156 end = BUF_PT(b);
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
157 BUF_SET_PT(b, orig);
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
158
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
159 return make_int (end);
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
160 }
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
161
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 18
diff changeset
162 DEFUN ("beginning-of-line", Fbeginning_of_line, 0, 2, "_p", /*
8
4b173ad71786 Import from CVS: tag r19-15b5
cvs
parents: 6
diff changeset
163 Move point to beginning of current line.
4b173ad71786 Import from CVS: tag r19-15b5
cvs
parents: 6
diff changeset
164 With argument ARG not nil or 1, move forward ARG - 1 lines first.
4b173ad71786 Import from CVS: tag r19-15b5
cvs
parents: 6
diff changeset
165 If scan reaches end of buffer, stop there without error.
4b173ad71786 Import from CVS: tag r19-15b5
cvs
parents: 6
diff changeset
166 If BUFFER is nil, the current buffer is assumed.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 18
diff changeset
167 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 18
diff changeset
168 (arg, buffer))
8
4b173ad71786 Import from CVS: tag r19-15b5
cvs
parents: 6
diff changeset
169 {
4b173ad71786 Import from CVS: tag r19-15b5
cvs
parents: 6
diff changeset
170 struct buffer *b = decode_buffer (buffer, 1);
4b173ad71786 Import from CVS: tag r19-15b5
cvs
parents: 6
diff changeset
171
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
172 BUF_SET_PT(b, XINT (Fpoint_at_bol(arg, buffer)));
8
4b173ad71786 Import from CVS: tag r19-15b5
cvs
parents: 6
diff changeset
173 return Qnil;
4b173ad71786 Import from CVS: tag r19-15b5
cvs
parents: 6
diff changeset
174 }
4b173ad71786 Import from CVS: tag r19-15b5
cvs
parents: 6
diff changeset
175
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
176 DEFUN ("point-at-eol", Fpoint_at_eol, 0, 2, 0, /*
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
177 Return the character position of the last character on the current line.
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
178 With argument N not nil or 1, move forward N - 1 lines first.
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
179 If scan reaches end of buffer, return that position.
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
180 This function does not move point.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 18
diff changeset
181 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 18
diff changeset
182 (arg, buffer))
8
4b173ad71786 Import from CVS: tag r19-15b5
cvs
parents: 6
diff changeset
183 {
4b173ad71786 Import from CVS: tag r19-15b5
cvs
parents: 6
diff changeset
184 struct buffer *buf = decode_buffer (buffer, 1);
4b173ad71786 Import from CVS: tag r19-15b5
cvs
parents: 6
diff changeset
185
4b173ad71786 Import from CVS: tag r19-15b5
cvs
parents: 6
diff changeset
186 XSETBUFFER (buffer, buf);
4b173ad71786 Import from CVS: tag r19-15b5
cvs
parents: 6
diff changeset
187
4b173ad71786 Import from CVS: tag r19-15b5
cvs
parents: 6
diff changeset
188 if (NILP (arg))
4b173ad71786 Import from CVS: tag r19-15b5
cvs
parents: 6
diff changeset
189 arg = make_int (1);
4b173ad71786 Import from CVS: tag r19-15b5
cvs
parents: 6
diff changeset
190 else
4b173ad71786 Import from CVS: tag r19-15b5
cvs
parents: 6
diff changeset
191 CHECK_INT (arg);
4b173ad71786 Import from CVS: tag r19-15b5
cvs
parents: 6
diff changeset
192
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
193 return make_int (find_before_next_newline (buf, BUF_PT (buf), 0,
8
4b173ad71786 Import from CVS: tag r19-15b5
cvs
parents: 6
diff changeset
194 XINT (arg) - (XINT (arg) <= 0)));
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
195 }
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
196
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
197 DEFUN ("end-of-line", Fend_of_line, 0, 2, "_p", /*
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
198 Move point to end of current line.
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
199 With argument ARG not nil or 1, move forward ARG - 1 lines first.
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
200 If scan reaches end of buffer, stop there without error.
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
201 If BUFFER is nil, the current buffer is assumed.
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
202 */
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
203 (arg, buffer))
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
204 {
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
205 struct buffer *b = decode_buffer (buffer, 1);
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
206
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
207 BUF_SET_PT(b, XINT (Fpoint_at_eol (arg, buffer)));
6
27bc7f280385 Import from CVS: tag r19-15b4
cvs
parents: 0
diff changeset
208 return Qnil;
27bc7f280385 Import from CVS: tag r19-15b4
cvs
parents: 0
diff changeset
209 }
27bc7f280385 Import from CVS: tag r19-15b4
cvs
parents: 0
diff changeset
210
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 18
diff changeset
211 DEFUN ("delete-char", Fdelete_char, 1, 2, "*p\nP", /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 Delete the following ARG characters (previous, with negative arg).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 Optional second arg KILLFLAG non-nil means kill instead (save in kill ring).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 Interactively, ARG is the prefix arg, and KILLFLAG is set if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 ARG was explicitly specified.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 18
diff changeset
216 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 18
diff changeset
217 (arg, killflag))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 /* This function can GC */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 Bufpos pos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 struct buffer *buf = current_buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 CHECK_INT (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 pos = BUF_PT (buf) + XINT (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 if (NILP (killflag))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 if (XINT (arg) < 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 if (pos < BUF_BEGV (buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 signal_error (Qbeginning_of_buffer, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 buffer_delete_range (buf, pos, BUF_PT (buf), 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 if (pos > BUF_ZV (buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 signal_error (Qend_of_buffer, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 buffer_delete_range (buf, BUF_PT (buf), pos, 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 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 call1 (Qkill_forward_chars, arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 18
diff changeset
250 DEFUN ("delete-backward-char", Fdelete_backward_char, 1, 2, "*p\nP", /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 Delete the previous ARG characters (following, with negative ARG).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 Optional second arg KILLFLAG non-nil means kill instead (save in kill ring).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 Interactively, ARG is the prefix arg, and KILLFLAG is set if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 ARG was explicitly specified.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 18
diff changeset
255 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 18
diff changeset
256 (arg, killflag))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 /* This function can GC */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 CHECK_INT (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 return Fdelete_char (make_int (-XINT (arg)), killflag);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 static void internal_self_insert (Emchar ch, int noautofill);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 18
diff changeset
265 DEFUN ("self-insert-command", Fself_insert_command, 1, 1, "*p", /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 Insert the character you type.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 Whichever character you type to run this command is inserted.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 18
diff changeset
268 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 18
diff changeset
269 (arg))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 /* This function can GC */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 int n;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 Emchar ch;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 Lisp_Object c;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 CHECK_INT (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 if (CHAR_OR_CHAR_INTP (Vlast_command_char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 c = Vlast_command_char;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 c = Fevent_to_character (Vlast_command_event, Qnil, Qnil, Qt);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 if (NILP (c))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 signal_simple_error ("last typed character has no ASCII equivalent",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 Fcopy_event (Vlast_command_event, Qnil));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 CHECK_CHAR_COERCE_INT (c);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 n = XINT (arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 ch = XCHAR (c);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 #if 0 /* FSFmacs */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 /* #### This optimization won't work because of differences in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 how the start-open and end-open properties default for text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 properties. See internal_self_insert(). */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 if (n >= 2 && NILP (current_buffer->overwrite_mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 n -= 2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 /* The first one might want to expand an abbrev. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 internal_self_insert (c, 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 /* The bulk of the copies of this char can be inserted simply.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 We don't have to handle a user-specified face specially
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 because it will get inherited from the first char inserted. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 Finsert_char (make_char (c), make_int (n), Qt, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 /* The last one might want to auto-fill. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 internal_self_insert (c, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 #endif /* 0 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 while (n > 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 n--;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 internal_self_insert (ch, (n != 0));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 /* Insert character C1. If NOAUTOFILL is nonzero, don't do autofill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 even if it is enabled.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 FSF:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 If this insertion is suitable for direct output (completely simple),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 return 0. A value of 1 indicates this *might* not have been simple.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 A value of 2 means this did things that call for an undo boundary. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 internal_self_insert (Emchar c1, int noautofill)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 /* This function can GC */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 /* int hairy = 0; -- unused */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 REGISTER enum syntaxcode synt;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 REGISTER Emchar c2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 Lisp_Object overwrite;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
333 struct Lisp_Char_Table *syntax_table;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 struct buffer *buf = current_buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 overwrite = buf->overwrite_mode;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
337 syntax_table = XCHAR_TABLE (buf->mirror_syntax_table);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 #if 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 /* No, this is very bad, it makes undo *always* undo a character at a time
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 instead of grouping consecutive self-inserts together. Nasty nasty.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 if (!NILP (Vbefore_change_functions) || !NILP (Vafter_change_functions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 || !NILP (Vbefore_change_function) || !NILP (Vafter_change_function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 hairy = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 if (!NILP (overwrite)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 && BUF_PT (buf) < BUF_ZV (buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 && (EQ (overwrite, Qoverwrite_mode_binary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 || (c1 != '\n' && BUF_FETCH_CHAR (buf, BUF_PT (buf)) != '\n'))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 && (EQ (overwrite, Qoverwrite_mode_binary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 || BUF_FETCH_CHAR (buf, BUF_PT (buf)) != '\t'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 || XINT (buf->tab_width) <= 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 || XINT (buf->tab_width) > 20
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 || !((current_column (buf) + 1) % XINT (buf->tab_width))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 buffer_delete_range (buf, BUF_PT (buf), BUF_PT (buf) + 1, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 /* hairy = 2; */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 if (!NILP (buf->abbrev_mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 && !WORD_SYNTAX_P (syntax_table, c1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 && NILP (buf->read_only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 && BUF_PT (buf) > BUF_BEGV (buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 c2 = BUF_FETCH_CHAR (buf, BUF_PT (buf) - 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 if (WORD_SYNTAX_P (syntax_table, c2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 /* int modiff = BUF_MODIFF (current_buffer); */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 Fexpand_abbrev ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 /* We can't trust the value of Fexpand_abbrev,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 but if Fexpand_abbrev changed the buffer,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 assume it expanded something. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 /* if (BUF_MODIFF (buf) != modiff)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 hairy = 2; */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 if ((c1 == ' ' || c1 == '\n')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 && !noautofill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 && !NILP (buf->auto_fill_function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 buffer_insert_emacs_char (buf, c1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 if (c1 == '\n')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 /* After inserting a newline, move to previous line and fill */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 /* that. Must have the newline in place already so filling and */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 /* justification, if any, know where the end is going to be. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 BUF_SET_PT (buf, BUF_PT (buf) - 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 call0 (buf->auto_fill_function);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 if (c1 == '\n')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 BUF_SET_PT (buf, BUF_PT (buf) + 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 /* hairy = 2; */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 buffer_insert_emacs_char (buf, c1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 /* If previous command specified a face to use, use it. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 if (!NILP (Vself_insert_face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 && EQ (Vlast_command, Vself_insert_face_command))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 Lisp_Object before, after;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 XSETINT (before, BUF_PT (buf) - 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 XSETINT (after, BUF_PT (buf));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 Fput_text_property (before, after, Qface, Vself_insert_face, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 Fput_text_property (before, after, Qstart_open, Qt, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 Fput_text_property (before, after, Qend_open, Qnil, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 /* #### FSFmacs properties are normally closed ("sticky") on the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 end but not the beginning. It's the opposite for us. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 Vself_insert_face = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 synt = SYNTAX (syntax_table, c1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 if ((synt == Sclose || synt == Smath)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 && !NILP (Vblink_paren_function) && INTERACTIVE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 && !noautofill)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 call0 (Vblink_paren_function);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 /* hairy = 2; */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 /* return hairy; */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 /* (this comes from Mule but is a generally good idea) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 18
diff changeset
426 DEFUN ("self-insert-internal", Fself_insert_internal, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 Invoke `self-insert-command' as if CH is entered from keyboard.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 18
diff changeset
428 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 18
diff changeset
429 (ch))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 /* This function can GC */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 CHECK_CHAR_COERCE_INT (ch);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 internal_self_insert (XCHAR (ch), 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 /* module initialization */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 syms_of_cmds (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 defsymbol (&Qkill_forward_chars, "kill-forward-chars");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 defsymbol (&Qself_insert_command, "self-insert-command");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 defsymbol (&Qoverwrite_mode_binary, "overwrite-mode-binary");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 18
diff changeset
446 DEFSUBR (Fforward_char);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 18
diff changeset
447 DEFSUBR (Fbackward_char);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 18
diff changeset
448 DEFSUBR (Fforward_line);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 18
diff changeset
449 DEFSUBR (Fbeginning_of_line);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 18
diff changeset
450 DEFSUBR (Fend_of_line);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
452 DEFSUBR (Fpoint_at_bol);
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
453 DEFSUBR (Fpoint_at_eol);
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
454
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 18
diff changeset
455 DEFSUBR (Fdelete_char);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 18
diff changeset
456 DEFSUBR (Fdelete_backward_char);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 18
diff changeset
458 DEFSUBR (Fself_insert_command);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 18
diff changeset
459 DEFSUBR (Fself_insert_internal);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 vars_of_cmds (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 DEFVAR_LISP ("self-insert-face", &Vself_insert_face /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 If non-nil, set the face of the next self-inserting character to this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 See also `self-insert-face-command'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 Vself_insert_face = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 DEFVAR_LISP ("self-insert-face-command", &Vself_insert_face_command /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 This is the command that set up `self-insert-face'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 If `last-command' does not equal this value, we ignore `self-insert-face'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 Vself_insert_face_command = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 DEFVAR_LISP ("blink-paren-function", &Vblink_paren_function /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 Function called, if non-nil, whenever a close parenthesis is inserted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 More precisely, a char with closeparen syntax is self-inserted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 Vblink_paren_function = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 }