comparison src/cmds.c @ 70:131b0175ea99 r20-0b30

Import from CVS: tag r20-0b30
author cvs
date Mon, 13 Aug 2007 09:02:59 +0200
parents 8fc7fe29b841
children 54cc21c15cbb
comparison
equal deleted inserted replaced
69:804d1389bcd6 70:131b0175ea99
39 Lisp_Object Vself_insert_face; 39 Lisp_Object Vself_insert_face;
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 /* t means beep when movement would take point past (point-min) or */
45 /* (point-max) */
46 int signal_error_on_buffer_boundary;
47 44
48 DEFUN ("forward-char", Fforward_char, 0, 2, "_p", /* 45 DEFUN ("forward-char", Fforward_char, 0, 2, "_p", /*
49 Move point right ARG characters (left if ARG negative). 46 Move point right ARG characters (left if ARG negative).
50 On reaching end of buffer, stop and signal error. 47 On reaching end of buffer, stop and signal error.
51 Error signaling is suppressed if `signal-error-on-buffer-boundary' 48 If BUFFER is nil, the current buffer is assumed.
52 is nil. If BUFFER is nil, the current buffer is assumed.
53 */ 49 */
54 (arg, buffer)) 50 (arg, buffer))
55 { 51 {
56 struct buffer *buf = decode_buffer (buffer, 1); 52 struct buffer *buf = decode_buffer (buffer, 1);
57 53
69 Bufpos new_point = BUF_PT (buf) + XINT (arg); 65 Bufpos new_point = BUF_PT (buf) + XINT (arg);
70 66
71 if (new_point < BUF_BEGV (buf)) 67 if (new_point < BUF_BEGV (buf))
72 { 68 {
73 BUF_SET_PT (buf, BUF_BEGV (buf)); 69 BUF_SET_PT (buf, BUF_BEGV (buf));
74 if (signal_error_on_buffer_boundary) 70 Fsignal (Qbeginning_of_buffer, Qnil);
75 Fsignal (Qbeginning_of_buffer, Qnil);
76 else
77 return Qnil;
78 } 71 }
79 if (new_point > BUF_ZV (buf)) 72 if (new_point > BUF_ZV (buf))
80 { 73 {
81 BUF_SET_PT (buf, BUF_ZV (buf)); 74 BUF_SET_PT (buf, BUF_ZV (buf));
82 if (signal_error_on_buffer_boundary) 75 Fsignal (Qend_of_buffer, Qnil);
83 Fsignal (Qend_of_buffer, Qnil);
84 else
85 return Qnil;
86 } 76 }
87 77
88 BUF_SET_PT (buf, new_point); 78 BUF_SET_PT (buf, new_point);
89 } 79 }
90 80
92 } 82 }
93 83
94 DEFUN ("backward-char", Fbackward_char, 0, 2, "_p", /* 84 DEFUN ("backward-char", Fbackward_char, 0, 2, "_p", /*
95 Move point left ARG characters (right if ARG negative). 85 Move point left ARG characters (right if ARG negative).
96 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.
97 Error signaling is suppressed if `signal-error-on-buffer-boundary' 87 If BUFFER is nil, the current buffer is assumed.
98 is nil. If BUFFER is nil, the current buffer is assumed.
99 */ 88 */
100 (arg, buffer)) 89 (arg, buffer))
101 { 90 {
102 if (NILP (arg)) 91 if (NILP (arg))
103 arg = make_int (1); 92 arg = make_int (1);
143 shortage--; 132 shortage--;
144 BUF_SET_PT (buf, pos); 133 BUF_SET_PT (buf, pos);
145 return make_int (negp ? - shortage : shortage); 134 return make_int (negp ? - shortage : shortage);
146 } 135 }
147 136
148 DEFUN ("point-at-bol", Fpoint_at_bol, 0, 2, 0, /*
149 Return the character position of the first character on the current line.
150 With argument N not nil or 1, move forward N - 1 lines first.
151 If scan reaches end of buffer, return that position.
152 This function does not move point.
153 */
154 (arg, buffer))
155 {
156 struct buffer *b = decode_buffer (buffer, 1);
157 register int orig, end;
158
159 XSETBUFFER (buffer, b);
160 if (NILP (arg))
161 arg = make_int (1);
162 else
163 CHECK_INT (arg);
164
165 orig = BUF_PT(b);
166 Fforward_line (make_int (XINT (arg) - 1), buffer);
167 end = BUF_PT(b);
168 BUF_SET_PT(b, orig);
169
170 return make_int (end);
171 }
172
173 DEFUN ("beginning-of-line", Fbeginning_of_line, 0, 2, "_p", /* 137 DEFUN ("beginning-of-line", Fbeginning_of_line, 0, 2, "_p", /*
174 Move point to beginning of current line. 138 Move point to beginning of current line.
175 With argument ARG not nil or 1, move forward ARG - 1 lines first. 139 With argument ARG not nil or 1, move forward ARG - 1 lines first.
176 If scan reaches end of buffer, stop there without error. 140 If scan reaches end of buffer, stop there without error.
177 If BUFFER is nil, the current buffer is assumed. 141 If BUFFER is nil, the current buffer is assumed.
178 */ 142 */
179 (arg, buffer)) 143 (arg, buffer))
180 { 144 {
181 struct buffer *b = decode_buffer (buffer, 1); 145 struct buffer *b = decode_buffer (buffer, 1);
182 146
183 BUF_SET_PT(b, XINT (Fpoint_at_bol(arg, buffer))); 147 XSETBUFFER (buffer, b);
184 return Qnil;
185 }
186
187 DEFUN ("point-at-eol", Fpoint_at_eol, 0, 2, 0, /*
188 Return the character position of the last character on the current line.
189 With argument N not nil or 1, move forward N - 1 lines first.
190 If scan reaches end of buffer, return that position.
191 This function does not move point.
192 */
193 (arg, buffer))
194 {
195 struct buffer *buf = decode_buffer (buffer, 1);
196
197 XSETBUFFER (buffer, buf);
198
199 if (NILP (arg)) 148 if (NILP (arg))
200 arg = make_int (1); 149 arg = make_int (1);
201 else 150 else
202 CHECK_INT (arg); 151 CHECK_INT (arg);
203 152
204 return make_int (find_before_next_newline (buf, BUF_PT (buf), 0, 153 Fforward_line (make_int (XINT (arg) - 1), buffer);
205 XINT (arg) - (XINT (arg) <= 0))); 154 return Qnil;
206 } 155 }
207 156
208 DEFUN ("end-of-line", Fend_of_line, 0, 2, "_p", /* 157 DEFUN ("end-of-line", Fend_of_line, 0, 2, "_p", /*
209 Move point to end of current line. 158 Move point to end of current line.
210 With argument ARG not nil or 1, move forward ARG - 1 lines first. 159 With argument ARG not nil or 1, move forward ARG - 1 lines first.
211 If scan reaches end of buffer, stop there without error. 160 If scan reaches end of buffer, stop there without error.
212 If BUFFER is nil, the current buffer is assumed. 161 If BUFFER is nil, the current buffer is assumed.
213 */ 162 */
214 (arg, buffer)) 163 (arg, buffer))
215 { 164 {
216 struct buffer *b = decode_buffer (buffer, 1); 165 struct buffer *buf = decode_buffer (buffer, 1);
217 166
218 BUF_SET_PT(b, XINT (Fpoint_at_eol (arg, buffer))); 167 XSETBUFFER (buffer, buf);
168
169 if (NILP (arg))
170 arg = make_int (1);
171 else
172 CHECK_INT (arg);
173
174 BUF_SET_PT (buf, find_before_next_newline (buf, BUF_PT (buf), 0,
175 XINT (arg) - (XINT (arg) <= 0)));
219 return Qnil; 176 return Qnil;
220 } 177 }
221 178
222 DEFUN ("delete-char", Fdelete_char, 1, 2, "*p\nP", /* 179 DEFUN ("delete-char", Fdelete_char, 1, 2, "*p\nP", /*
223 Delete the following ARG characters (previous, with negative arg). 180 Delete the following ARG characters (previous, with negative arg).
339 /* This function can GC */ 296 /* This function can GC */
340 /* int hairy = 0; -- unused */ 297 /* int hairy = 0; -- unused */
341 REGISTER enum syntaxcode synt; 298 REGISTER enum syntaxcode synt;
342 REGISTER Emchar c2; 299 REGISTER Emchar c2;
343 Lisp_Object overwrite; 300 Lisp_Object overwrite;
344 Lisp_Object syntax_table; 301 struct Lisp_Char_Table *syntax_table;
345 struct buffer *buf = current_buffer; 302 struct buffer *buf = current_buffer;
346 303
347 overwrite = buf->overwrite_mode; 304 overwrite = buf->overwrite_mode;
348 syntax_table = buf->syntax_table; 305 syntax_table = XCHAR_TABLE (buf->mirror_syntax_table);
349 306
350 #if 0 307 #if 0
351 /* No, this is very bad, it makes undo *always* undo a character at a time 308 /* No, this is very bad, it makes undo *always* undo a character at a time
352 instead of grouping consecutive self-inserts together. Nasty nasty. 309 instead of grouping consecutive self-inserts together. Nasty nasty.
353 */ 310 */
458 DEFSUBR (Fbackward_char); 415 DEFSUBR (Fbackward_char);
459 DEFSUBR (Fforward_line); 416 DEFSUBR (Fforward_line);
460 DEFSUBR (Fbeginning_of_line); 417 DEFSUBR (Fbeginning_of_line);
461 DEFSUBR (Fend_of_line); 418 DEFSUBR (Fend_of_line);
462 419
463 DEFSUBR (Fpoint_at_bol);
464 DEFSUBR (Fpoint_at_eol);
465
466 DEFSUBR (Fdelete_char); 420 DEFSUBR (Fdelete_char);
467 DEFSUBR (Fdelete_backward_char); 421 DEFSUBR (Fdelete_backward_char);
468 422
469 DEFSUBR (Fself_insert_command); 423 DEFSUBR (Fself_insert_command);
470 DEFSUBR (Fself_insert_internal); 424 DEFSUBR (Fself_insert_internal);
488 DEFVAR_LISP ("blink-paren-function", &Vblink_paren_function /* 442 DEFVAR_LISP ("blink-paren-function", &Vblink_paren_function /*
489 Function called, if non-nil, whenever a close parenthesis is inserted. 443 Function called, if non-nil, whenever a close parenthesis is inserted.
490 More precisely, a char with closeparen syntax is self-inserted. 444 More precisely, a char with closeparen syntax is self-inserted.
491 */ ); 445 */ );
492 Vblink_paren_function = Qnil; 446 Vblink_paren_function = Qnil;
493 447 }
494 DEFVAR_BOOL ("signal-error-on-buffer-boundary", &signal_error_on_buffer_boundary /*
495 t means beep when movement would take point past (point-min) or
496 \(point-max).
497 */ );
498 signal_error_on_buffer_boundary = 1;
499 }