Mercurial > hg > xemacs-beta
comparison src/editfns.c @ 153:25f70ba0133c r20-3b3
Import from CVS: tag r20-3b3
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:38:25 +0200 |
parents | 59463afc5666 |
children | 28f395d8dc7a |
comparison
equal
deleted
inserted
replaced
152:4c132ee2d62b | 153:25f70ba0133c |
---|---|
222 Beginning of buffer is position (point-min). | 222 Beginning of buffer is position (point-min). |
223 If BUFFER is nil, the current buffer is assumed. | 223 If BUFFER is nil, the current buffer is assumed. |
224 */ | 224 */ |
225 (buffer)) | 225 (buffer)) |
226 { | 226 { |
227 return make_int (BUF_PT (decode_buffer (buffer, 1))); | 227 struct buffer *b = decode_buffer (buffer, 1); |
228 return make_int (BUF_PT (b)); | |
228 } | 229 } |
229 | 230 |
230 DEFUN ("point-marker", Fpoint_marker, 0, 2, 0, /* | 231 DEFUN ("point-marker", Fpoint_marker, 0, 2, 0, /* |
231 Return value of point, as a marker object. | 232 Return value of point, as a marker object. |
232 This marker is a copy; you may modify it with reckless abandon. | 233 This marker is a copy; you may modify it with reckless abandon. |
311 else | 312 else |
312 return m; | 313 return m; |
313 } | 314 } |
314 | 315 |
315 DEFUN ("region-beginning", Fregion_beginning, 0, 1, 0, /* | 316 DEFUN ("region-beginning", Fregion_beginning, 0, 1, 0, /* |
316 Return position of beginning of region, as an integer. | 317 Return position of beginning of region in BUFFER, as an integer. |
317 If BUFFER is nil, the current buffer is assumed. | 318 If BUFFER is nil, the current buffer is assumed. |
318 */ | 319 */ |
319 (buffer)) | 320 (buffer)) |
320 { | 321 { |
321 return (region_limit (1, decode_buffer (buffer, 1))); | 322 return region_limit (1, decode_buffer (buffer, 1)); |
322 } | 323 } |
323 | 324 |
324 DEFUN ("region-end", Fregion_end, 0, 1, 0, /* | 325 DEFUN ("region-end", Fregion_end, 0, 1, 0, /* |
325 Return position of end of region, as an integer. | 326 Return position of end of region in BUFFER, as an integer. |
326 If BUFFER is nil, the current buffer is assumed. | 327 If BUFFER is nil, the current buffer is assumed. |
327 */ | 328 */ |
328 (buffer)) | 329 (buffer)) |
329 { | 330 { |
330 return region_limit (0, decode_buffer (buffer, 1)); | 331 return region_limit (0, decode_buffer (buffer, 1)); |
494 If BUFFER is nil, the current buffer is assumed. | 495 If BUFFER is nil, the current buffer is assumed. |
495 */ | 496 */ |
496 (buffer)) | 497 (buffer)) |
497 { | 498 { |
498 struct buffer *b = decode_buffer (buffer, 1); | 499 struct buffer *b = decode_buffer (buffer, 1); |
499 return (make_int (BUF_SIZE (b))); | 500 return make_int (BUF_SIZE (b)); |
500 } | 501 } |
501 | 502 |
502 DEFUN ("point-min", Fpoint_min, 0, 1, 0, /* | 503 DEFUN ("point-min", Fpoint_min, 0, 1, 0, /* |
503 Return the minimum permissible value of point in BUFFER. | 504 Return the minimum permissible value of point in BUFFER. |
504 This is 1, unless narrowing (a buffer restriction) is in effect. | 505 This is 1, unless narrowing (a buffer restriction) is in effect. |
505 If BUFFER is nil, the current buffer is assumed. | 506 If BUFFER is nil, the current buffer is assumed. |
506 */ | 507 */ |
507 (buffer)) | 508 (buffer)) |
508 { | 509 { |
509 struct buffer *b = decode_buffer (buffer, 1); | 510 struct buffer *b = decode_buffer (buffer, 1); |
510 return (make_int (BUF_BEGV (b))); | 511 return make_int (BUF_BEGV (b)); |
511 } | 512 } |
512 | 513 |
513 DEFUN ("point-min-marker", Fpoint_min_marker, 0, 1, 0, /* | 514 DEFUN ("point-min-marker", Fpoint_min_marker, 0, 1, 0, /* |
514 Return a marker to the minimum permissible value of point in BUFFER. | 515 Return a marker to the minimum permissible value of point in BUFFER. |
515 This is the beginning, unless narrowing (a buffer restriction) is in effect. | 516 This is the beginning, unless narrowing (a buffer restriction) is in effect. |
527 is in effect, in which case it is less. | 528 is in effect, in which case it is less. |
528 If BUFFER is nil, the current buffer is assumed. | 529 If BUFFER is nil, the current buffer is assumed. |
529 */ | 530 */ |
530 (buffer)) | 531 (buffer)) |
531 { | 532 { |
532 return make_int (BUF_ZV (decode_buffer (buffer,1))); | 533 struct buffer *b = decode_buffer (buffer, 1); |
534 return make_int (BUF_ZV (b)); | |
533 } | 535 } |
534 | 536 |
535 DEFUN ("point-max-marker", Fpoint_max_marker, 0, 1, 0, /* | 537 DEFUN ("point-max-marker", Fpoint_max_marker, 0, 1, 0, /* |
536 Return a marker to the maximum permissible value of point BUFFER. | 538 Return a marker to the maximum permissible value of point BUFFER. |
537 This is (1+ (buffer-size)), unless narrowing (a buffer restriction) | 539 This is (1+ (buffer-size)), unless narrowing (a buffer restriction) |
551 */ | 553 */ |
552 (buffer)) | 554 (buffer)) |
553 { | 555 { |
554 struct buffer *b = decode_buffer (buffer, 1); | 556 struct buffer *b = decode_buffer (buffer, 1); |
555 if (BUF_PT (b) >= BUF_ZV (b)) | 557 if (BUF_PT (b) >= BUF_ZV (b)) |
556 return (Qzero); /* #### Gag me! */ | 558 return Qzero; /* #### Gag me! */ |
557 else | 559 else |
558 return (make_char (BUF_FETCH_CHAR (b, BUF_PT (b)))); | 560 return make_char (BUF_FETCH_CHAR (b, BUF_PT (b))); |
559 } | 561 } |
560 | 562 |
561 DEFUN ("preceding-char", Fpreceding_char, 0, 1, 0, /* | 563 DEFUN ("preceding-char", Fpreceding_char, 0, 1, 0, /* |
562 Return the character preceding point. | 564 Return the character preceding point. |
563 At the beginning of the buffer or accessible region, return 0. | 565 At the beginning of the buffer or accessible region, return 0. |
565 */ | 567 */ |
566 (buffer)) | 568 (buffer)) |
567 { | 569 { |
568 struct buffer *b = decode_buffer (buffer, 1); | 570 struct buffer *b = decode_buffer (buffer, 1); |
569 if (BUF_PT (b) <= BUF_BEGV (b)) | 571 if (BUF_PT (b) <= BUF_BEGV (b)) |
570 return (Qzero); /* #### Gag me! */ | 572 return Qzero; /* #### Gag me! */ |
571 else | 573 else |
572 return (make_char (BUF_FETCH_CHAR (b, BUF_PT (b) - 1))); | 574 return make_char (BUF_FETCH_CHAR (b, BUF_PT (b) - 1)); |
573 } | 575 } |
574 | 576 |
575 DEFUN ("bobp", Fbobp, 0, 1, 0, /* | 577 DEFUN ("bobp", Fbobp, 0, 1, 0, /* |
576 Return T if point is at the beginning of the buffer. | 578 Return T if point is at the beginning of the buffer. |
577 If the buffer is narrowed, this means the beginning of the narrowed part. | 579 If the buffer is narrowed, this means the beginning of the narrowed part. |
721 (The DVX libraries override the Djgpp libraries here.) */ | 723 (The DVX libraries override the Djgpp libraries here.) */ |
722 Lisp_Object tem = build_string (pw ? pw->pw_name : "root");/* no gettext */ | 724 Lisp_Object tem = build_string (pw ? pw->pw_name : "root");/* no gettext */ |
723 #else | 725 #else |
724 Lisp_Object tem = build_string (pw ? pw->pw_name : "unknown");/* no gettext */ | 726 Lisp_Object tem = build_string (pw ? pw->pw_name : "unknown");/* no gettext */ |
725 #endif | 727 #endif |
726 return (tem); | 728 return tem; |
727 } | 729 } |
728 | 730 |
729 DEFUN ("user-uid", Fuser_uid, 0, 0, 0, /* | 731 DEFUN ("user-uid", Fuser_uid, 0, 0, 0, /* |
730 Return the effective uid of Emacs, as an integer. | 732 Return the effective uid of Emacs, as an integer. |
731 */ | 733 */ |
801 #endif /* AMPERSAND_FULL_NAME */ | 803 #endif /* AMPERSAND_FULL_NAME */ |
802 | 804 |
803 p = getenv ("NAME"); | 805 p = getenv ("NAME"); |
804 if (p) | 806 if (p) |
805 tem = build_string (p); | 807 tem = build_string (p); |
806 return (tem); | 808 return tem; |
807 } | 809 } |
808 | 810 |
809 DEFUN ("system-name", Fsystem_name, 0, 0, 0, /* | 811 DEFUN ("system-name", Fsystem_name, 0, 0, 0, /* |
810 Return the name of the machine you are running on, as a string. | 812 Return the name of the machine you are running on, as a string. |
811 */ | 813 */ |
812 ()) | 814 ()) |
813 { | 815 { |
814 return (Fcopy_sequence (Vsystem_name)); | 816 return Fcopy_sequence (Vsystem_name); |
815 } | 817 } |
816 | 818 |
817 /* For the benefit of callers who don't want to include lisp.h. | 819 /* For the benefit of callers who don't want to include lisp.h. |
818 Caller must free! */ | 820 Caller must free! */ |
819 char * | 821 char * |
1369 If a string has non-null string-extent-data, new extents will be created. | 1371 If a string has non-null string-extent-data, new extents will be created. |
1370 BUFFER defaults to the current buffer. | 1372 BUFFER defaults to the current buffer. |
1371 */ | 1373 */ |
1372 (string, buffer)) | 1374 (string, buffer)) |
1373 { | 1375 { |
1374 struct buffer *buf = decode_buffer (buffer, 1); | 1376 struct buffer *b = decode_buffer (buffer, 1); |
1375 CHECK_STRING (string); | 1377 CHECK_STRING (string); |
1376 buffer_insert_lisp_string (buf, string); | 1378 buffer_insert_lisp_string (b, string); |
1377 zmacs_region_stays = 0; | 1379 zmacs_region_stays = 0; |
1378 return Qnil; | 1380 return Qnil; |
1379 } | 1381 } |
1380 | 1382 |
1381 /* Third argument in FSF is INHERIT: | 1383 /* Third argument in FSF is INHERIT: |
1403 REGISTER int slen; | 1405 REGISTER int slen; |
1404 REGISTER int i, j; | 1406 REGISTER int i, j; |
1405 REGISTER Bytecount n; | 1407 REGISTER Bytecount n; |
1406 REGISTER Bytecount charlen; | 1408 REGISTER Bytecount charlen; |
1407 Bufbyte str[MAX_EMCHAR_LEN]; | 1409 Bufbyte str[MAX_EMCHAR_LEN]; |
1408 struct buffer *buf = decode_buffer (buffer, 1); | 1410 struct buffer *b = decode_buffer (buffer, 1); |
1409 int cou; | 1411 int cou; |
1410 | 1412 |
1411 CHECK_CHAR_COERCE_INT (chr); | 1413 CHECK_CHAR_COERCE_INT (chr); |
1412 if (NILP (count)) | 1414 if (NILP (count)) |
1413 cou = 1; | 1415 cou = 1; |
1428 for (j = 0; j < charlen; j++) | 1430 for (j = 0; j < charlen; j++) |
1429 string[i + j] = str[j]; | 1431 string[i + j] = str[j]; |
1430 slen = i; | 1432 slen = i; |
1431 while (n >= slen) | 1433 while (n >= slen) |
1432 { | 1434 { |
1433 buffer_insert_raw_string (buf, string, slen); | 1435 buffer_insert_raw_string (b, string, slen); |
1434 n -= slen; | 1436 n -= slen; |
1435 } | 1437 } |
1436 if (n > 0) | 1438 if (n > 0) |
1437 #if 0 /* FSFmacs bogosity */ | 1439 #if 0 /* FSFmacs bogosity */ |
1438 { | 1440 { |
1440 insert_and_inherit (string, n); | 1442 insert_and_inherit (string, n); |
1441 else | 1443 else |
1442 insert (string, n); | 1444 insert (string, n); |
1443 } | 1445 } |
1444 #else | 1446 #else |
1445 buffer_insert_raw_string (buf, string, n); | 1447 buffer_insert_raw_string (b, string, n); |
1446 #endif | 1448 #endif |
1447 | 1449 |
1448 zmacs_region_stays = 0; | 1450 zmacs_region_stays = 0; |
1449 return Qnil; | 1451 return Qnil; |
1450 } | 1452 } |
1934 If BUFFER is nil, the current buffer is assumed. | 1936 If BUFFER is nil, the current buffer is assumed. |
1935 */ | 1937 */ |
1936 (c1, c2, buffer)) | 1938 (c1, c2, buffer)) |
1937 { | 1939 { |
1938 Emchar x1, x2; | 1940 Emchar x1, x2; |
1939 struct buffer *buf = decode_buffer (buffer, 1); | 1941 struct buffer *b = decode_buffer (buffer, 1); |
1940 | 1942 |
1941 CHECK_CHAR_COERCE_INT (c1); | 1943 CHECK_CHAR_COERCE_INT (c1); |
1942 CHECK_CHAR_COERCE_INT (c2); | 1944 CHECK_CHAR_COERCE_INT (c2); |
1943 x1 = XCHAR (c1); | 1945 x1 = XCHAR (c1); |
1944 x2 = XCHAR (c2); | 1946 x2 = XCHAR (c2); |
1945 | 1947 |
1946 if (!NILP (buf->case_fold_search) | 1948 return (!NILP (b->case_fold_search) |
1947 ? DOWNCASE (buf, x1) == DOWNCASE (buf, x2) | 1949 ? DOWNCASE (b, x1) == DOWNCASE (b, x2) |
1948 : x1 == x2) | 1950 : x1 == x2) |
1949 return Qt; | 1951 ? Qt : Qnil; |
1950 return Qnil; | |
1951 } | 1952 } |
1952 | 1953 |
1953 DEFUN ("char=", Fchar_Equal, 2, 3, 0, /* | 1954 DEFUN ("char=", Fchar_Equal, 2, 3, 0, /* |
1954 Return t if two characters match, case is significant. | 1955 Return t if two characters match, case is significant. |
1955 Both arguments must be characters (i.e. NOT integers). | 1956 Both arguments must be characters (i.e. NOT integers). |
1956 The optional buffer argument is for symmetry and is ignored. | 1957 The optional buffer argument is for symmetry and is ignored. |
1957 */ | 1958 */ |
1958 (c1, c2, buffer)) | 1959 (c1, c2, buffer)) |
1959 { | 1960 { |
1960 Emchar x1, x2; | |
1961 | |
1962 CHECK_CHAR_COERCE_INT (c1); | 1961 CHECK_CHAR_COERCE_INT (c1); |
1963 CHECK_CHAR_COERCE_INT (c2); | 1962 CHECK_CHAR_COERCE_INT (c2); |
1964 x1 = XCHAR (c1); | 1963 |
1965 x2 = XCHAR (c2); | 1964 return XCHAR(c1) == XCHAR(c2) ? Qt : Qnil; |
1966 | |
1967 return x1 == x2 ? Qt : Qnil; | |
1968 } | 1965 } |
1969 | 1966 |
1970 #if 0 /* Undebugged FSFmacs code */ | 1967 #if 0 /* Undebugged FSFmacs code */ |
1971 /* Transpose the markers in two regions of the current buffer, and | 1968 /* Transpose the markers in two regions of the current buffer, and |
1972 adjust the ones between them if necessary (i.e.: if the regions | 1969 adjust the ones between them if necessary (i.e.: if the regions |
2028 set_marker_position (marker, mpos); | 2025 set_marker_position (marker, mpos); |
2029 } | 2026 } |
2030 } | 2027 } |
2031 } | 2028 } |
2032 | 2029 |
2033 #endif | 2030 #endif /* 0 */ |
2034 | 2031 |
2035 DEFUN ("transpose-regions", Ftranspose_regions, 4, 5, 0, /* | 2032 DEFUN ("transpose-regions", Ftranspose_regions, 4, 5, 0, /* |
2036 Transpose region START1 to END1 with START2 to END2. | 2033 Transpose region START1 to END1 with START2 to END2. |
2037 The regions may not be overlapping, because the size of the buffer is | 2034 The regions may not be overlapping, because the size of the buffer is |
2038 never changed in a transposition. | 2035 never changed in a transposition. |