comparison src/syntax.c @ 446:1ccc32a20af4 r21-2-38

Import from CVS: tag r21-2-38
author cvs
date Mon, 13 Aug 2007 11:37:21 +0200
parents 576fb035e263
children 223736d75acb
comparison
equal deleted inserted replaced
445:34f3776fcf0e 446:1ccc32a20af4
441 } 441 }
442 442
443 return from; 443 return from;
444 } 444 }
445 445
446 DEFUN ("forward-word", Fforward_word, 1, 2, "_p", /* 446 DEFUN ("forward-word", Fforward_word, 0, 2, "_p", /*
447 Move point forward COUNT words (backward if COUNT is negative). 447 Move point forward COUNT words (backward if COUNT is negative).
448 Normally returns t. 448 Normally t is returned, but if an edge of the buffer is reached,
449 If an edge of the buffer is reached, point is left there 449 point is left there and nil is returned.
450 and nil is returned. 450
451 451 COUNT defaults to 1, and BUFFER defaults to the current buffer.
452 Optional argument BUFFER defaults to the current buffer.
453 */ 452 */
454 (count, buffer)) 453 (count, buffer))
455 { 454 {
456 Bufpos val; 455 Bufpos val;
457 struct buffer *buf = decode_buffer (buffer, 0); 456 struct buffer *buf = decode_buffer (buffer, 0);
458 CHECK_INT (count); 457 EMACS_INT n;
459 458
460 if (!(val = scan_words (buf, BUF_PT (buf), XINT (count)))) 459 if (NILP (count))
461 { 460 n = 1;
462 BUF_SET_PT (buf, XINT (count) > 0 ? BUF_ZV (buf) : BUF_BEGV (buf)); 461 else
462 {
463 CHECK_INT (count);
464 n = XINT (count);
465 }
466
467 val = scan_words (buf, BUF_PT (buf), n);
468 if (val)
469 {
470 BUF_SET_PT (buf, val);
471 return Qt;
472 }
473 else
474 {
475 BUF_SET_PT (buf, n > 0 ? BUF_ZV (buf) : BUF_BEGV (buf));
463 return Qnil; 476 return Qnil;
464 } 477 }
465 BUF_SET_PT (buf, val);
466 return Qt;
467 } 478 }
468 479
469 static void scan_sexps_forward (struct buffer *buf, 480 static void scan_sexps_forward (struct buffer *buf,
470 struct lisp_parse_state *, 481 struct lisp_parse_state *,
471 Bufpos from, Bufpos end, 482 Bufpos from, Bufpos end,
646 above, which is part of Fforward_comment() in FSF). Attempts to port 657 above, which is part of Fforward_comment() in FSF). Attempts to port
647 that logic made this function break, so I'm leaving it out. If anyone 658 that logic made this function break, so I'm leaving it out. If anyone
648 ever complains about this function not working properly, take a look 659 ever complains about this function not working properly, take a look
649 at those changes. --ben */ 660 at those changes. --ben */
650 661
651 DEFUN ("forward-comment", Fforward_comment, 1, 2, 0, /* 662 DEFUN ("forward-comment", Fforward_comment, 0, 2, 0, /*
652 Move forward across up to COUNT comments, or backwards if COUNT is negative. 663 Move forward across up to COUNT comments, or backwards if COUNT is negative.
653 Stop scanning if we find something other than a comment or whitespace. 664 Stop scanning if we find something other than a comment or whitespace.
654 Set point to where scanning stops. 665 Set point to where scanning stops.
655 If COUNT comments are found as expected, with nothing except whitespace 666 If COUNT comments are found as expected, with nothing except whitespace
656 between them, return t; otherwise return nil. 667 between them, return t; otherwise return nil.
657 Point is set in either case. 668 Point is set in either case.
658 Optional argument BUFFER defaults to the current buffer. 669 COUNT defaults to 1, and BUFFER defaults to the current buffer.
659 */ 670 */
660 (count, buffer)) 671 (count, buffer))
661 { 672 {
662 Bufpos from; 673 Bufpos from;
663 Bufpos stop; 674 Bufpos stop;
665 enum syntaxcode code; 676 enum syntaxcode code;
666 EMACS_INT n; 677 EMACS_INT n;
667 struct buffer *buf = decode_buffer (buffer, 0); 678 struct buffer *buf = decode_buffer (buffer, 0);
668 Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table); 679 Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table);
669 680
670 CHECK_INT (count); 681 if (NILP (count))
671 n = XINT (count); 682 n = 1;
683 else
684 {
685 CHECK_INT (count);
686 n = XINT (count);
687 }
672 688
673 from = BUF_PT (buf); 689 from = BUF_PT (buf);
674 690
675 while (n > 0) 691 while (n > 0)
676 { 692 {