annotate src/cmds.c @ 387:f892a9d0bb8d

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