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

Import from CVS: tag r19-15b93
author cvs
date Mon, 13 Aug 2007 08:50:05 +0200
parents 0293115a14e9
children 131b0175ea99
comparison
equal deleted inserted replaced
19:ac1f612d5250 20:859a2309aef8
197 return last_known_column; 197 return last_known_column;
198 198
199 return column_at_point (buf, BUF_PT (buf), 1); 199 return column_at_point (buf, BUF_PT (buf), 1);
200 } 200 }
201 201
202 DEFUN ("current-column", Fcurrent_column, Scurrent_column, 0, 1, 0 /* 202 DEFUN ("current-column", Fcurrent_column, 0, 1, 0, /*
203 Return the horizontal position of point. Beginning of line is column 0. 203 Return the horizontal position of point. Beginning of line is column 0.
204 This is calculated by adding together the widths of all the displayed 204 This is calculated by adding together the widths of all the displayed
205 representations of the character between the start of the previous line 205 representations of the character between the start of the previous line
206 and point. (e.g. control characters will have a width of 2 or 4, tabs 206 and point. (e.g. control characters will have a width of 2 or 4, tabs
207 will have a variable width.) 207 will have a variable width.)
208 Ignores finite width of frame, which means that this function may return 208 Ignores finite width of frame, which means that this function may return
209 values greater than (frame-width). 209 values greater than (frame-width).
210 Whether the line is visible (if `selective-display' is t) has no effect; 210 Whether the line is visible (if `selective-display' is t) has no effect;
211 however, ^M is treated as end of line when `selective-display' is t. 211 however, ^M is treated as end of line when `selective-display' is t.
212 If BUFFER is nil, the current buffer is assumed. 212 If BUFFER is nil, the current buffer is assumed.
213 */ ) 213 */
214 (buffer) 214 (buffer))
215 Lisp_Object buffer;
216 { 215 {
217 return (make_int (current_column (decode_buffer (buffer, 0)))); 216 return (make_int (current_column (decode_buffer (buffer, 0))));
218 } 217 }
219 218
220 219
221 DEFUN ("indent-to", Findent_to, Sindent_to, 1, 3, "NIndent to column: " /* 220 DEFUN ("indent-to", Findent_to, 1, 3, "NIndent to column: ", /*
222 Indent from point with tabs and spaces until COLUMN is reached. 221 Indent from point with tabs and spaces until COLUMN is reached.
223 Optional second argument MIN says always do at least MIN spaces 222 Optional second argument MIN says always do at least MIN spaces
224 even if that goes past COLUMN; by default, MIN is zero. 223 even if that goes past COLUMN; by default, MIN is zero.
225 If BUFFER is nil, the current buffer is assumed. 224 If BUFFER is nil, the current buffer is assumed.
226 */ ) 225 */
227 (col, minimum, buffer) 226 (col, minimum, buffer))
228 Lisp_Object col, minimum, buffer;
229 { 227 {
230 /* This function can GC */ 228 /* This function can GC */
231 int mincol; 229 int mincol;
232 int fromcol; 230 int fromcol;
233 struct buffer *buf = decode_buffer (buffer, 0); 231 struct buffer *buf = decode_buffer (buffer, 0);
308 306
309 return col; 307 return col;
310 } 308 }
311 309
312 310
313 DEFUN ("current-indentation", Fcurrent_indentation, Scurrent_indentation, 311 DEFUN ("current-indentation", Fcurrent_indentation, 0, 1, 0, /*
314 0, 1, 0 /*
315 Return the indentation of the current line. 312 Return the indentation of the current line.
316 This is the horizontal position of the character 313 This is the horizontal position of the character
317 following any initial whitespace. 314 following any initial whitespace.
318 */ ) 315 */
319 (buffer) 316 (buffer))
320 Lisp_Object buffer;
321 { 317 {
322 struct buffer *buf = decode_buffer (buffer, 0); 318 struct buffer *buf = decode_buffer (buffer, 0);
323 Bufpos pos = find_next_newline (buf, BUF_PT (buf), -1); 319 Bufpos pos = find_next_newline (buf, BUF_PT (buf), -1);
324 320
325 XSETBUFFER (buffer, buf); 321 XSETBUFFER (buffer, buf);
329 325
330 return make_int (bi_spaces_at_point (buf, bufpos_to_bytind (buf, pos))); 326 return make_int (bi_spaces_at_point (buf, bufpos_to_bytind (buf, pos)));
331 } 327 }
332 328
333 329
334 DEFUN ("move-to-column", Fmove_to_column, Smove_to_column, 1, 3, 0 /* 330 DEFUN ("move-to-column", Fmove_to_column, 1, 3, 0, /*
335 Move point to column COLUMN in the current line. 331 Move point to column COLUMN in the current line.
336 The column of a character is calculated by adding together the widths 332 The column of a character is calculated by adding together the widths
337 as displayed of the previous characters in the line. 333 as displayed of the previous characters in the line.
338 This function ignores line-continuation; 334 This function ignores line-continuation;
339 there is no upper limit on the column number a character can have 335 there is no upper limit on the column number a character can have
344 340
345 A non-nil second (optional) argument FORCE means, if the line 341 A non-nil second (optional) argument FORCE means, if the line
346 is too short to reach column COLUMN then add spaces/tabs to get there, 342 is too short to reach column COLUMN then add spaces/tabs to get there,
347 and if COLUMN is in the middle of a tab character, change it to spaces. 343 and if COLUMN is in the middle of a tab character, change it to spaces.
348 Returns the actual column that it moved to. 344 Returns the actual column that it moved to.
349 */ ) 345 */
350 (column, force, buffer) 346 (column, force, buffer))
351 Lisp_Object column, force, buffer;
352 { 347 {
353 /* This function can GC */ 348 /* This function can GC */
354 Bufpos pos; 349 Bufpos pos;
355 struct buffer *buf = decode_buffer (buffer, 0); 350 struct buffer *buf = decode_buffer (buffer, 0);
356 int col = current_column (buf); 351 int col = current_column (buf);
605 } 600 }
606 601
607 RETURN_NOT_REACHED(0) /* shut up compiler */ 602 RETURN_NOT_REACHED(0) /* shut up compiler */
608 } 603 }
609 604
610 DEFUN ("vertical-motion", Fvertical_motion, Svertical_motion, 1, 2, 0 /* 605 DEFUN ("vertical-motion", Fvertical_motion, 1, 2, 0, /*
611 Move to start of frame line LINES lines down. 606 Move to start of frame line LINES lines down.
612 If LINES is negative, this is moving up. 607 If LINES is negative, this is moving up.
613 608
614 The optional second argument WINDOW specifies the window to use for 609 The optional second argument WINDOW specifies the window to use for
615 parameters such as width, horizontal scrolling, and so on. 610 parameters such as width, horizontal scrolling, and so on.
621 Sets point to position found; this may be start of line 616 Sets point to position found; this may be start of line
622 or just the start of a continuation line. 617 or just the start of a continuation line.
623 Returns number of lines moved; may be closer to zero than LINES 618 Returns number of lines moved; may be closer to zero than LINES
624 if beginning or end of buffer was reached. 619 if beginning or end of buffer was reached.
625 Optional second argument is WINDOW to move in. 620 Optional second argument is WINDOW to move in.
626 */ ) 621 */
627 (lines, window) 622 (lines, window))
628 Lisp_Object lines, window;
629 { 623 {
630 if (NILP (window)) 624 if (NILP (window))
631 window = Fselected_window (Qnil); 625 window = Fselected_window (Qnil);
632 CHECK_WINDOW (window); 626 CHECK_WINDOW (window);
633 { 627 {
649 643
650 644
651 void 645 void
652 syms_of_indent (void) 646 syms_of_indent (void)
653 { 647 {
654 defsubr (&Scurrent_indentation); 648 DEFSUBR (Fcurrent_indentation);
655 defsubr (&Sindent_to); 649 DEFSUBR (Findent_to);
656 defsubr (&Scurrent_column); 650 DEFSUBR (Fcurrent_column);
657 defsubr (&Smove_to_column); 651 DEFSUBR (Fmove_to_column);
658 #if 0 /* #### */ 652 #if 0 /* #### */
659 defsubr (&Scompute_motion); 653 DEFSUBR (Fcompute_motion);
660 #endif 654 #endif
661 defsubr (&Svertical_motion); 655 DEFSUBR (Fvertical_motion);
662 } 656 }
663 657
664 void 658 void
665 vars_of_indent (void) 659 vars_of_indent (void)
666 { 660 {