annotate src/cmds.c @ 16:0293115a14e9 r19-15b91

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