annotate src/cmds.c @ 298:70ad99077275 r21-0b47

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