annotate src/cmds.c @ 242:fc816b73a05f

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