comparison src/cmds.c @ 20:859a2309aef8 r19-15b93

Import from CVS: tag r19-15b93
author cvs
date Mon, 13 Aug 2007 08:50:05 +0200
parents d95e72db5c07
children 8fc7fe29b841
comparison
equal deleted inserted replaced
19:ac1f612d5250 20:859a2309aef8
40 40
41 /* This is the command that set up Vself_insert_face. */ 41 /* This is the command that set up Vself_insert_face. */
42 Lisp_Object Vself_insert_face_command; 42 Lisp_Object Vself_insert_face_command;
43 43
44 44
45 DEFUN ("forward-char", Fforward_char, Sforward_char, 0, 2, "_p" /* 45 DEFUN ("forward-char", Fforward_char, 0, 2, "_p", /*
46 Move point right ARG characters (left if ARG negative). 46 Move point right ARG characters (left if ARG negative).
47 On reaching end of buffer, stop and signal error. 47 On reaching end of buffer, stop and signal error.
48 If BUFFER is nil, the current buffer is assumed. 48 If BUFFER is nil, the current buffer is assumed.
49 */ ) 49 */
50 (arg, buffer) 50 (arg, buffer))
51 Lisp_Object arg, buffer;
52 { 51 {
53 struct buffer *buf = decode_buffer (buffer, 1); 52 struct buffer *buf = decode_buffer (buffer, 1);
54 53
55 if (NILP (arg)) 54 if (NILP (arg))
56 arg = make_int (1); 55 arg = make_int (1);
80 } 79 }
81 80
82 return Qnil; 81 return Qnil;
83 } 82 }
84 83
85 DEFUN ("backward-char", Fbackward_char, Sbackward_char, 0, 2, "_p" /* 84 DEFUN ("backward-char", Fbackward_char, 0, 2, "_p", /*
86 Move point left ARG characters (right if ARG negative). 85 Move point left ARG characters (right if ARG negative).
87 On attempt to pass beginning or end of buffer, stop and signal error. 86 On attempt to pass beginning or end of buffer, stop and signal error.
88 If BUFFER is nil, the current buffer is assumed. 87 If BUFFER is nil, the current buffer is assumed.
89 */ ) 88 */
90 (arg, buffer) 89 (arg, buffer))
91 Lisp_Object arg, buffer;
92 { 90 {
93 if (NILP (arg)) 91 if (NILP (arg))
94 arg = make_int (1); 92 arg = make_int (1);
95 else 93 else
96 CHECK_INT (arg); 94 CHECK_INT (arg);
97 95
98 XSETINT (arg, - XINT (arg)); 96 XSETINT (arg, - XINT (arg));
99 return Fforward_char (arg, buffer); 97 return Fforward_char (arg, buffer);
100 } 98 }
101 99
102 DEFUN ("forward-line", Fforward_line, Sforward_line, 0, 2, "_p" /* 100 DEFUN ("forward-line", Fforward_line, 0, 2, "_p", /*
103 Move ARG lines forward (backward if ARG is negative). 101 Move ARG lines forward (backward if ARG is negative).
104 Precisely, if point is on line I, move to the start of line I + ARG. 102 Precisely, if point is on line I, move to the start of line I + ARG.
105 If there isn't room, go as far as possible (no error). 103 If there isn't room, go as far as possible (no error).
106 Returns the count of lines left to move. If moving forward, 104 Returns the count of lines left to move. If moving forward,
107 that is ARG - number of lines moved; if backward, ARG + number moved. 105 that is ARG - number of lines moved; if backward, ARG + number moved.
108 With positive ARG, a non-empty line at the end counts as one line 106 With positive ARG, a non-empty line at the end counts as one line
109 successfully moved (for the return value). 107 successfully moved (for the return value).
110 If BUFFER is nil, the current buffer is assumed. 108 If BUFFER is nil, the current buffer is assumed.
111 */ ) 109 */
112 (arg, buffer) 110 (arg, buffer))
113 Lisp_Object arg, buffer;
114 { 111 {
115 struct buffer *buf = decode_buffer (buffer, 1); 112 struct buffer *buf = decode_buffer (buffer, 1);
116 Bufpos pos2 = BUF_PT (buf); 113 Bufpos pos2 = BUF_PT (buf);
117 Bufpos pos; 114 Bufpos pos;
118 int count, shortage, negp; 115 int count, shortage, negp;
135 shortage--; 132 shortage--;
136 BUF_SET_PT (buf, pos); 133 BUF_SET_PT (buf, pos);
137 return make_int (negp ? - shortage : shortage); 134 return make_int (negp ? - shortage : shortage);
138 } 135 }
139 136
140 DEFUN ("point-at-bol", Fpoint_at_bol, Spoint_at_bol, 0, 2, 0 /* 137 DEFUN ("point-at-bol", Fpoint_at_bol, 0, 2, 0, /*
141 Return the character position of the first character on the current line. 138 Return the character position of the first character on the current line.
142 With argument N not nil or 1, move forward N - 1 lines first. 139 With argument N not nil or 1, move forward N - 1 lines first.
143 If scan reaches end of buffer, return that position. 140 If scan reaches end of buffer, return that position.
144 This function does not move point. 141 This function does not move point.
145 */ ) 142 */
146 (arg, buffer) 143 (arg, buffer))
147 Lisp_Object arg, buffer;
148 { 144 {
149 struct buffer *b = decode_buffer (buffer, 1); 145 struct buffer *b = decode_buffer (buffer, 1);
150 register int orig, end; 146 register int orig, end;
151 147
152 XSETBUFFER (buffer, b); 148 XSETBUFFER (buffer, b);
161 BUF_SET_PT(b, orig); 157 BUF_SET_PT(b, orig);
162 158
163 return make_int (end); 159 return make_int (end);
164 } 160 }
165 161
166 DEFUN ("beginning-of-line", Fbeginning_of_line, Sbeginning_of_line, 162 DEFUN ("beginning-of-line", Fbeginning_of_line, 0, 2, "_p", /*
167 0, 2, "_p" /*
168 Move point to beginning of current line. 163 Move point to beginning of current line.
169 With argument ARG not nil or 1, move forward ARG - 1 lines first. 164 With argument ARG not nil or 1, move forward ARG - 1 lines first.
170 If scan reaches end of buffer, stop there without error. 165 If scan reaches end of buffer, stop there without error.
171 If BUFFER is nil, the current buffer is assumed. 166 If BUFFER is nil, the current buffer is assumed.
172 */ ) 167 */
173 (arg, buffer) 168 (arg, buffer))
174 Lisp_Object arg, buffer;
175 { 169 {
176 struct buffer *b = decode_buffer (buffer, 1); 170 struct buffer *b = decode_buffer (buffer, 1);
177 171
178 BUF_SET_PT(b, XINT (Fpoint_at_bol(arg, buffer))); 172 BUF_SET_PT(b, XINT (Fpoint_at_bol(arg, buffer)));
179 return Qnil; 173 return Qnil;
180 } 174 }
181 175
182 DEFUN ("point-at-eol", Fpoint_at_eol, Spoint_at_eol, 0, 2, 0 /* 176 DEFUN ("point-at-eol", Fpoint_at_eol, 0, 2, 0, /*
183 Return the character position of the last character on the current line. 177 Return the character position of the last character on the current line.
184 With argument N not nil or 1, move forward N - 1 lines first. 178 With argument N not nil or 1, move forward N - 1 lines first.
185 If scan reaches end of buffer, return that position. 179 If scan reaches end of buffer, return that position.
186 This function does not move point. 180 This function does not move point.
187 */ ) 181 */
188 (arg, buffer) 182 (arg, buffer))
189 Lisp_Object arg, buffer;
190 { 183 {
191 struct buffer *buf = decode_buffer (buffer, 1); 184 struct buffer *buf = decode_buffer (buffer, 1);
192 185
193 XSETBUFFER (buffer, buf); 186 XSETBUFFER (buffer, buf);
194 187
199 192
200 return make_int (find_before_next_newline (buf, BUF_PT (buf), 0, 193 return make_int (find_before_next_newline (buf, BUF_PT (buf), 0,
201 XINT (arg) - (XINT (arg) <= 0))); 194 XINT (arg) - (XINT (arg) <= 0)));
202 } 195 }
203 196
204 DEFUN ("end-of-line", Fend_of_line, Send_of_line, 197 DEFUN ("end-of-line", Fend_of_line, 0, 2, "_p", /*
205 0, 2, "_p" /*
206 Move point to end of current line. 198 Move point to end of current line.
207 With argument ARG not nil or 1, move forward ARG - 1 lines first. 199 With argument ARG not nil or 1, move forward ARG - 1 lines first.
208 If scan reaches end of buffer, stop there without error. 200 If scan reaches end of buffer, stop there without error.
209 If BUFFER is nil, the current buffer is assumed. 201 If BUFFER is nil, the current buffer is assumed.
210 */ ) 202 */
211 (arg, buffer) 203 (arg, buffer))
212 Lisp_Object arg, buffer;
213 { 204 {
214 struct buffer *b = decode_buffer (buffer, 1); 205 struct buffer *b = decode_buffer (buffer, 1);
215 206
216 BUF_SET_PT(b, XINT (Fpoint_at_eol (arg, buffer))); 207 BUF_SET_PT(b, XINT (Fpoint_at_eol (arg, buffer)));
217 return Qnil; 208 return Qnil;
218 } 209 }
219 210
220 DEFUN ("delete-char", Fdelete_char, Sdelete_char, 1, 2, "*p\nP" /* 211 DEFUN ("delete-char", Fdelete_char, 1, 2, "*p\nP", /*
221 Delete the following ARG characters (previous, with negative arg). 212 Delete the following ARG characters (previous, with negative arg).
222 Optional second arg KILLFLAG non-nil means kill instead (save in kill ring). 213 Optional second arg KILLFLAG non-nil means kill instead (save in kill ring).
223 Interactively, ARG is the prefix arg, and KILLFLAG is set if 214 Interactively, ARG is the prefix arg, and KILLFLAG is set if
224 ARG was explicitly specified. 215 ARG was explicitly specified.
225 */ ) 216 */
226 (arg, killflag) 217 (arg, killflag))
227 Lisp_Object arg, killflag;
228 { 218 {
229 /* This function can GC */ 219 /* This function can GC */
230 Bufpos pos; 220 Bufpos pos;
231 struct buffer *buf = current_buffer; 221 struct buffer *buf = current_buffer;
232 222
255 call1 (Qkill_forward_chars, arg); 245 call1 (Qkill_forward_chars, arg);
256 } 246 }
257 return Qnil; 247 return Qnil;
258 } 248 }
259 249
260 DEFUN ("delete-backward-char", Fdelete_backward_char, Sdelete_backward_char, 250 DEFUN ("delete-backward-char", Fdelete_backward_char, 1, 2, "*p\nP", /*
261 1, 2, "*p\nP" /*
262 Delete the previous ARG characters (following, with negative ARG). 251 Delete the previous ARG characters (following, with negative ARG).
263 Optional second arg KILLFLAG non-nil means kill instead (save in kill ring). 252 Optional second arg KILLFLAG non-nil means kill instead (save in kill ring).
264 Interactively, ARG is the prefix arg, and KILLFLAG is set if 253 Interactively, ARG is the prefix arg, and KILLFLAG is set if
265 ARG was explicitly specified. 254 ARG was explicitly specified.
266 */ ) 255 */
267 (arg, killflag) 256 (arg, killflag))
268 Lisp_Object arg, killflag;
269 { 257 {
270 /* This function can GC */ 258 /* This function can GC */
271 CHECK_INT (arg); 259 CHECK_INT (arg);
272 return Fdelete_char (make_int (-XINT (arg)), killflag); 260 return Fdelete_char (make_int (-XINT (arg)), killflag);
273 } 261 }
274 262
275 static void internal_self_insert (Emchar ch, int noautofill); 263 static void internal_self_insert (Emchar ch, int noautofill);
276 264
277 DEFUN ("self-insert-command", Fself_insert_command, Sself_insert_command, 1, 1, "*p" /* 265 DEFUN ("self-insert-command", Fself_insert_command, 1, 1, "*p", /*
278 Insert the character you type. 266 Insert the character you type.
279 Whichever character you type to run this command is inserted. 267 Whichever character you type to run this command is inserted.
280 */ ) 268 */
281 (arg) 269 (arg))
282 Lisp_Object arg;
283 { 270 {
284 /* This function can GC */ 271 /* This function can GC */
285 int n; 272 int n;
286 Emchar ch; 273 Emchar ch;
287 Lisp_Object c; 274 Lisp_Object c;
434 /* return hairy; */ 421 /* return hairy; */
435 } 422 }
436 423
437 /* (this comes from Mule but is a generally good idea) */ 424 /* (this comes from Mule but is a generally good idea) */
438 425
439 DEFUN ("self-insert-internal", Fself_insert_internal, Sself_insert_internal, 426 DEFUN ("self-insert-internal", Fself_insert_internal, 1, 1, 0, /*
440 1, 1, 0 /*
441 Invoke `self-insert-command' as if CH is entered from keyboard. 427 Invoke `self-insert-command' as if CH is entered from keyboard.
442 */ ) 428 */
443 (ch) 429 (ch))
444 Lisp_Object ch;
445 { 430 {
446 /* This function can GC */ 431 /* This function can GC */
447 CHECK_CHAR_COERCE_INT (ch); 432 CHECK_CHAR_COERCE_INT (ch);
448 internal_self_insert (XCHAR (ch), 0); 433 internal_self_insert (XCHAR (ch), 0);
449 return Qnil; 434 return Qnil;
456 { 441 {
457 defsymbol (&Qkill_forward_chars, "kill-forward-chars"); 442 defsymbol (&Qkill_forward_chars, "kill-forward-chars");
458 defsymbol (&Qself_insert_command, "self-insert-command"); 443 defsymbol (&Qself_insert_command, "self-insert-command");
459 defsymbol (&Qoverwrite_mode_binary, "overwrite-mode-binary"); 444 defsymbol (&Qoverwrite_mode_binary, "overwrite-mode-binary");
460 445
461 defsubr (&Sforward_char); 446 DEFSUBR (Fforward_char);
462 defsubr (&Sbackward_char); 447 DEFSUBR (Fbackward_char);
463 defsubr (&Sforward_line); 448 DEFSUBR (Fforward_line);
464 defsubr (&Sbeginning_of_line); 449 DEFSUBR (Fbeginning_of_line);
465 defsubr (&Send_of_line); 450 DEFSUBR (Fend_of_line);
466 451
467 defsubr (&Spoint_at_bol); 452 DEFSUBR (Fpoint_at_bol);
468 defsubr (&Spoint_at_eol); 453 DEFSUBR (Fpoint_at_eol);
469 454
470 defsubr (&Sdelete_char); 455 DEFSUBR (Fdelete_char);
471 defsubr (&Sdelete_backward_char); 456 DEFSUBR (Fdelete_backward_char);
472 457
473 defsubr (&Sself_insert_command); 458 DEFSUBR (Fself_insert_command);
474 defsubr (&Sself_insert_internal); 459 DEFSUBR (Fself_insert_internal);
475 } 460 }
476 461
477 void 462 void
478 vars_of_cmds (void) 463 vars_of_cmds (void)
479 { 464 {