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

Import from CVS: tag r20-0b30
author cvs
date Mon, 13 Aug 2007 09:02:59 +0200
parents 56c54cf7c5b6
children c7528f8e288d
comparison
equal deleted inserted replaced
69:804d1389bcd6 70:131b0175ea99
582 If BUFFER is nil, the current buffer is assumed. 582 If BUFFER is nil, the current buffer is assumed.
583 */ 583 */
584 (buffer)) 584 (buffer))
585 { 585 {
586 struct buffer *b = decode_buffer (buffer, 1); 586 struct buffer *b = decode_buffer (buffer, 1);
587 return BUF_PT (b) == BUF_BEGV (b) ? Qt : Qnil; 587 if (BUF_PT (b) == BUF_BEGV (b))
588 return Qt;
589 return Qnil;
588 } 590 }
589 591
590 DEFUN ("eobp", Feobp, 0, 1, 0, /* 592 DEFUN ("eobp", Feobp, 0, 1, 0, /*
591 Return T if point is at the end of the buffer. 593 Return T if point is at the end of the buffer.
592 If the buffer is narrowed, this means the end of the narrowed part. 594 If the buffer is narrowed, this means the end of the narrowed part.
593 If BUFFER is nil, the current buffer is assumed. 595 If BUFFER is nil, the current buffer is assumed.
594 */ 596 */
595 (buffer)) 597 (buffer))
596 { 598 {
597 struct buffer *b = decode_buffer (buffer, 1); 599 struct buffer *b = decode_buffer (buffer, 1);
598 return BUF_PT (b) == BUF_ZV (b) ? Qt : Qnil; 600 if (BUF_PT (b) == BUF_ZV (b))
601 return Qt;
602 return Qnil;
599 } 603 }
600 604
601 int 605 int
602 beginning_of_line_p (struct buffer *b, Bufpos pt) 606 beginning_of_line_p (struct buffer *b, Bufpos pt)
603 { 607 {
629 if (BUF_PT (b) == BUF_ZV (b) || BUF_FETCH_CHAR (b, BUF_PT (b)) == '\n') 633 if (BUF_PT (b) == BUF_ZV (b) || BUF_FETCH_CHAR (b, BUF_PT (b)) == '\n')
630 return Qt; 634 return Qt;
631 return Qnil; 635 return Qnil;
632 } 636 }
633 637
634 DEFUN ("char-after", Fchar_after, 0, 2, 0, /* 638 DEFUN ("char-after", Fchar_after, 1, 2, 0, /*
635 Return character in BUFFER at position POS. 639 Return character in BUFFER at position POS.
636 POS is an integer or a buffer pointer. 640 POS is an integer or a buffer pointer.
637 If POS is out of range, the value is nil. 641 If POS is out of range, the value is nil.
638 If BUFFER is nil, the current buffer is assumed. 642 If BUFFER is nil, the current buffer is assumed.
639 if POS is nil, the value of point is assumed.
640 */ 643 */
641 (pos, buffer)) 644 (pos, buffer))
642 { 645 {
643 struct buffer *b = decode_buffer (buffer, 1); 646 struct buffer *b = decode_buffer (buffer, 1);
644 Bufpos n = (NILP (pos) ? BUF_PT (b) : 647 Bufpos n = get_buffer_pos_char (b, pos, GB_NO_ERROR_IF_BAD);
645 get_buffer_pos_char (b, pos, GB_NO_ERROR_IF_BAD));
646 648
647 if (n < 0 || n == BUF_ZV (b)) 649 if (n < 0 || n == BUF_ZV (b))
648 return Qnil; 650 return Qnil;
649 return make_char (BUF_FETCH_CHAR (b, n)); 651 return (make_char (BUF_FETCH_CHAR (b, n)));
650 }
651
652 DEFUN ("char-before", Fchar_before, 0, 2, 0, /*
653 Return character in BUFFER before position POS.
654 POS is an integer or a buffer pointer.
655 If POS is out of range, the value is nil.
656 If BUFFER is nil, the current buffer is assumed.
657 if POS is nil, the value of point is assumed.
658 */
659 (pos, buffer))
660 {
661 struct buffer *b = decode_buffer (buffer, 1);
662 Bufpos n = ((NILP (pos) ? BUF_PT (b) :
663 get_buffer_pos_char (b, pos, GB_NO_ERROR_IF_BAD)));
664
665 n--;
666
667 if (n < BUF_BEGV (b))
668 return Qnil;
669 return make_char (BUF_FETCH_CHAR (b, n));
670 } 652 }
671 653
672 654
673 DEFUN ("user-login-name", Fuser_login_name, 0, 1, 0, /* 655 DEFUN ("user-login-name", Fuser_login_name, 0, 1, 0, /*
674 Return the name under which the user logged in, as a string. 656 Return the name under which the user logged in, as a string.
918 size_t emacs_strftime (char *string, size_t max, CONST char *format, 900 size_t emacs_strftime (char *string, size_t max, CONST char *format,
919 CONST struct tm *tm); 901 CONST struct tm *tm);
920 static long difftm (CONST struct tm *a, CONST struct tm *b); 902 static long difftm (CONST struct tm *a, CONST struct tm *b);
921 903
922 904
923 DEFUN ("format-time-string", Fformat_time_string, 1, 2, 0, /* 905 DEFUN ("format-time-string", Fformat_time_string, 2, 2, 0, /*
924 Use FORMAT-STRING to format the time TIME. 906 Use FORMAT-STRING to format the time TIME.
925 TIME is specified as (HIGH LOW . IGNORED) or (HIGH . LOW), as from 907 TIME is specified as (HIGH LOW . IGNORED) or (HIGH . LOW), as from
926 `current-time' and `file-attributes'. If TIME is not specified it 908 `current-time' and `file-attributes'.
927 defaults to the current time.
928 FORMAT-STRING may contain %-sequences to substitute parts of the time. 909 FORMAT-STRING may contain %-sequences to substitute parts of the time.
929 %a is replaced by the abbreviated name of the day of week. 910 %a is replaced by the abbreviated name of the day of week.
930 %A is replaced by the full name of the day of week. 911 %A is replaced by the full name of the day of week.
931 %b is replaced by the abbreviated name of the month. 912 %b is replaced by the abbreviated name of the month.
932 %B is replaced by the full name of the month. 913 %B is replaced by the full name of the month.
1580 DEFUN ("subst-char-in-region", Fsubst_char_in_region, 4, 5, 0, /* 1561 DEFUN ("subst-char-in-region", Fsubst_char_in_region, 4, 5, 0, /*
1581 From START to END, replace FROMCHAR with TOCHAR each time it occurs. 1562 From START to END, replace FROMCHAR with TOCHAR each time it occurs.
1582 If optional arg NOUNDO is non-nil, don't record this change for undo 1563 If optional arg NOUNDO is non-nil, don't record this change for undo
1583 and don't mark the buffer as really changed. 1564 and don't mark the buffer as really changed.
1584 */ 1565 */
1585 (start, end, fromchar, tochar, noundo)) 1566 (start, end, fromchar, tochar, noundo))
1586 { 1567 {
1587 /* This function can GC */ 1568 /* This function can GC */
1588 Bufpos pos, stop; 1569 Bufpos pos, stop;
1589 Emchar fromc, toc; 1570 Emchar fromc, toc;
1590 int mc_count; 1571 int mc_count;
2034 any markers that happen to be located in the regions. (#### BUG: currently 2015 any markers that happen to be located in the regions. (#### BUG: currently
2035 this function always acts as if LEAVE_MARKERS is non-nil.) 2016 this function always acts as if LEAVE_MARKERS is non-nil.)
2036 2017
2037 Transposing beyond buffer boundaries is an error. 2018 Transposing beyond buffer boundaries is an error.
2038 */ 2019 */
2039 (startr1, endr1, startr2, endr2, leave_markers)) 2020 (startr1, endr1, startr2, endr2, leave_markers))
2040 { 2021 {
2041 Bufpos start1, end1, start2, end2; 2022 Bufpos start1, end1, start2, end2;
2042 Charcount len1, len2; 2023 Charcount len1, len2;
2043 Lisp_Object string1, string2; 2024 Lisp_Object string1, string2;
2044 struct buffer *buf = current_buffer; 2025 struct buffer *buf = current_buffer;
2107 DEFSUBR (Fbolp); 2088 DEFSUBR (Fbolp);
2108 DEFSUBR (Feolp); 2089 DEFSUBR (Feolp);
2109 DEFSUBR (Ffollowing_char); 2090 DEFSUBR (Ffollowing_char);
2110 DEFSUBR (Fpreceding_char); 2091 DEFSUBR (Fpreceding_char);
2111 DEFSUBR (Fchar_after); 2092 DEFSUBR (Fchar_after);
2112 DEFSUBR (Fchar_before);
2113 DEFSUBR (Finsert); 2093 DEFSUBR (Finsert);
2114 DEFSUBR (Finsert_string); 2094 DEFSUBR (Finsert_string);
2115 DEFSUBR (Finsert_before_markers); 2095 DEFSUBR (Finsert_before_markers);
2116 DEFSUBR (Finsert_char); 2096 DEFSUBR (Finsert_char);
2117 2097
2173 - \"Motion\" commands do not change whether the region is active or not. 2153 - \"Motion\" commands do not change whether the region is active or not.
2174 2154
2175 set-mark-command (C-SPC) pushes a mark and activates the region. Moving the 2155 set-mark-command (C-SPC) pushes a mark and activates the region. Moving the
2176 cursor with normal motion commands (C-n, C-p, etc) will cause the region 2156 cursor with normal motion commands (C-n, C-p, etc) will cause the region
2177 between point and the recently-pushed mark to be highlighted. It will 2157 between point and the recently-pushed mark to be highlighted. It will
2178 remain highlighted until some non-motion command is executed. 2158 remain highlighted until some non-motion comand is executed.
2179 2159
2180 exchange-point-and-mark (\\[exchange-point-and-mark]) activates the region. So if you mark a 2160 exchange-point-and-mark (\\[exchange-point-and-mark]) activates the region. So if you mark a
2181 region and execute a command that operates on it, you can reactivate the 2161 region and execute a command that operates on it, you can reactivate the
2182 same region with \\[exchange-point-and-mark] (or perhaps \\[exchange-point-and-mark] \\[exchange-point-and-mark]) to operate on it 2162 same region with \\[exchange-point-and-mark] (or perhaps \\[exchange-point-and-mark] \\[exchange-point-and-mark]) to operate on it
2183 again. 2163 again.