annotate src/cmds.c @ 98:0d2f883870bc r20-1b1

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