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

Import from CVS: tag r19-15b93
author cvs
date Mon, 13 Aug 2007 08:50:05 +0200
parents 9ee227acff29
children e04119814345
comparison
equal deleted inserted replaced
19:ac1f612d5250 20:859a2309aef8
166 if (p) 166 if (p)
167 Vuser_full_name = build_string ((char *) p); 167 Vuser_full_name = build_string ((char *) p);
168 #endif /* 0 */ 168 #endif /* 0 */
169 } 169 }
170 170
171 DEFUN ("char-to-string", Fchar_to_string, Schar_to_string, 1, 1, 0 /* 171 DEFUN ("char-to-string", Fchar_to_string, 1, 1, 0, /*
172 Convert arg CH to a one-character string containing that character. 172 Convert arg CH to a one-character string containing that character.
173 */ ) 173 */
174 (ch) 174 (ch))
175 Lisp_Object ch;
176 { 175 {
177 Bytecount len; 176 Bytecount len;
178 Bufbyte str[MAX_EMCHAR_LEN]; 177 Bufbyte str[MAX_EMCHAR_LEN];
179 178
180 if (EVENTP (ch)) 179 if (EVENTP (ch))
191 190
192 len = set_charptr_emchar (str, XCHAR (ch)); 191 len = set_charptr_emchar (str, XCHAR (ch));
193 return make_string (str, len); 192 return make_string (str, len);
194 } 193 }
195 194
196 DEFUN ("string-to-char", Fstring_to_char, Sstring_to_char, 1, 1, 0 /* 195 DEFUN ("string-to-char", Fstring_to_char, 1, 1, 0, /*
197 Convert arg STRING to a character, the first character of that string. 196 Convert arg STRING to a character, the first character of that string.
198 */ ) 197 */
199 (str) 198 (str))
200 Lisp_Object str;
201 { 199 {
202 struct Lisp_String *p; 200 struct Lisp_String *p;
203 CHECK_STRING (str); 201 CHECK_STRING (str);
204 202
205 p = XSTRING (str); 203 p = XSTRING (str);
219 mark = Fmake_marker (); 217 mark = Fmake_marker ();
220 Fset_marker (mark, make_int (val), buffer); 218 Fset_marker (mark, make_int (val), buffer);
221 return mark; 219 return mark;
222 } 220 }
223 221
224 DEFUN ("point", Fpoint, Spoint, 0, 1, 0 /* 222 DEFUN ("point", Fpoint, 0, 1, 0, /*
225 Return value of point, as an integer. 223 Return value of point, as an integer.
226 Beginning of buffer is position (point-min). 224 Beginning of buffer is position (point-min).
227 If BUFFER is nil, the current buffer is assumed. 225 If BUFFER is nil, the current buffer is assumed.
228 */ ) 226 */
229 (buffer) 227 (buffer))
230 Lisp_Object buffer;
231 { 228 {
232 struct buffer *b = decode_buffer (buffer, 1); 229 struct buffer *b = decode_buffer (buffer, 1);
233 return (make_int (BUF_PT (b))); 230 return (make_int (BUF_PT (b)));
234 } 231 }
235 232
236 DEFUN ("point-marker", Fpoint_marker, Spoint_marker, 0, 2, 0 /* 233 DEFUN ("point-marker", Fpoint_marker, 0, 2, 0, /*
237 Return value of point, as a marker object. 234 Return value of point, as a marker object.
238 This marker is a copy; you may modify it with reckless abandon. 235 This marker is a copy; you may modify it with reckless abandon.
239 If optional argument DONT-COPY-P is non-nil, then it returns the real 236 If optional argument DONT-COPY-P is non-nil, then it returns the real
240 point-marker; modifying the position of this marker will move point. 237 point-marker; modifying the position of this marker will move point.
241 It is illegal to change the buffer of it, or make it point nowhere. 238 It is illegal to change the buffer of it, or make it point nowhere.
242 If BUFFER is nil, the current buffer is assumed. 239 If BUFFER is nil, the current buffer is assumed.
243 */ ) 240 */
244 (dont_copy_p, buffer) 241 (dont_copy_p, buffer))
245 Lisp_Object dont_copy_p, buffer;
246 { 242 {
247 struct buffer *b = decode_buffer (buffer, 1); 243 struct buffer *b = decode_buffer (buffer, 1);
248 if (NILP (dont_copy_p)) 244 if (NILP (dont_copy_p))
249 return Fcopy_marker (b->point_marker, Qnil); 245 return Fcopy_marker (b->point_marker, Qnil);
250 return b->point_marker; 246 return b->point_marker;
284 * 280 *
285 * Jamie thinks he's wrong, but we'll leave this in for now. 281 * Jamie thinks he's wrong, but we'll leave this in for now.
286 */ 282 */
287 int atomic_extent_goto_char_p; 283 int atomic_extent_goto_char_p;
288 284
289 DEFUN ("goto-char", Fgoto_char, Sgoto_char, 1, 2, "NGoto char: " /* 285 DEFUN ("goto-char", Fgoto_char, 1, 2, "NGoto char: ", /*
290 Set point to POSITION, a number or marker. 286 Set point to POSITION, a number or marker.
291 Beginning of buffer is position (point-min), end is (point-max). 287 Beginning of buffer is position (point-min), end is (point-max).
292 If BUFFER is nil, the current buffer is assumed. 288 If BUFFER is nil, the current buffer is assumed.
293 Return value of POSITION, as an integer. 289 Return value of POSITION, as an integer.
294 */ ) 290 */
295 (position, buffer) 291 (position, buffer))
296 Lisp_Object position, buffer;
297 { 292 {
298 struct buffer *b = decode_buffer (buffer, 1); 293 struct buffer *b = decode_buffer (buffer, 1);
299 Bufpos n = get_buffer_pos_char (b, position, GB_COERCE_RANGE); 294 Bufpos n = get_buffer_pos_char (b, position, GB_COERCE_RANGE);
300 BUF_SET_PT (b, n); 295 BUF_SET_PT (b, n);
301 atomic_extent_goto_char_p = 1; 296 atomic_extent_goto_char_p = 1;
318 return (make_int (BUF_PT (b))); 313 return (make_int (BUF_PT (b)));
319 else 314 else
320 return (m); 315 return (m);
321 } 316 }
322 317
323 DEFUN ("region-beginning", Fregion_beginning, Sregion_beginning, 0, 1, 0 /* 318 DEFUN ("region-beginning", Fregion_beginning, 0, 1, 0, /*
324 Return position of beginning of region, as an integer. 319 Return position of beginning of region, as an integer.
325 If BUFFER is nil, the current buffer is assumed. 320 If BUFFER is nil, the current buffer is assumed.
326 */ ) 321 */
327 (buffer) 322 (buffer))
328 Lisp_Object buffer;
329 { 323 {
330 return (region_limit (1, decode_buffer (buffer, 1))); 324 return (region_limit (1, decode_buffer (buffer, 1)));
331 } 325 }
332 326
333 DEFUN ("region-end", Fregion_end, Sregion_end, 0, 1, 0 /* 327 DEFUN ("region-end", Fregion_end, 0, 1, 0, /*
334 Return position of end of region, as an integer. 328 Return position of end of region, as an integer.
335 If BUFFER is nil, the current buffer is assumed. 329 If BUFFER is nil, the current buffer is assumed.
336 */ ) 330 */
337 (buffer) 331 (buffer))
338 Lisp_Object buffer;
339 { 332 {
340 return (region_limit (0, decode_buffer (buffer, 1))); 333 return (region_limit (0, decode_buffer (buffer, 1)));
341 } 334 }
342 335
343 /* Whether to use lispm-style active-regions */ 336 /* Whether to use lispm-style active-regions */
377 return call0 (Qzmacs_region_buffer); 370 return call0 (Qzmacs_region_buffer);
378 else 371 else
379 return Qnil; 372 return Qnil;
380 } 373 }
381 374
382 DEFUN ("mark-marker", Fmark_marker, Smark_marker, 0, 2, 0 /* 375 DEFUN ("mark-marker", Fmark_marker, 0, 2, 0, /*
383 Return this buffer's mark, as a marker object. 376 Return this buffer's mark, as a marker object.
384 If `zmacs-regions' is true, then this returns nil unless the region is 377 If `zmacs-regions' is true, then this returns nil unless the region is
385 currently in the active (highlighted) state. If optional argument FORCE 378 currently in the active (highlighted) state. If optional argument FORCE
386 is t, this returns the mark (if there is one) regardless of the zmacs-region 379 is t, this returns the mark (if there is one) regardless of the zmacs-region
387 state. You should *generally* not use the mark unless the region is active, 380 state. You should *generally* not use the mark unless the region is active,
388 if the user has expressed a preference for the zmacs-region model. 381 if the user has expressed a preference for the zmacs-region model.
389 Watch out! Moving this marker changes the mark position. 382 Watch out! Moving this marker changes the mark position.
390 If you set the marker not to point anywhere, the buffer will have no mark. 383 If you set the marker not to point anywhere, the buffer will have no mark.
391 If BUFFER is nil, the current buffer is assumed. 384 If BUFFER is nil, the current buffer is assumed.
392 */ ) 385 */
393 (force, buffer) 386 (force, buffer))
394 Lisp_Object force, buffer;
395 { 387 {
396 struct buffer *b = decode_buffer (buffer, 1); 388 struct buffer *b = decode_buffer (buffer, 1);
397 if (! zmacs_regions || zmacs_region_active_p || !NILP (force)) 389 if (! zmacs_regions || zmacs_region_active_p || !NILP (force))
398 return b->mark; 390 return b->mark;
399 return Qnil; 391 return Qnil;
482 free_cons (XCONS (XCDR (info))); 474 free_cons (XCONS (XCDR (info)));
483 free_cons (XCONS (info)); 475 free_cons (XCONS (info));
484 return Qnil; 476 return Qnil;
485 } 477 }
486 478
487 DEFUN ("save-excursion", Fsave_excursion, Ssave_excursion, 0, UNEVALLED, 0 /* 479 DEFUN ("save-excursion", Fsave_excursion, 0, UNEVALLED, 0, /*
488 Save point, mark, and current buffer; execute BODY; restore those things. 480 Save point, mark, and current buffer; execute BODY; restore those things.
489 Executes BODY just like `progn'. 481 Executes BODY just like `progn'.
490 The values of point, mark and the current buffer are restored 482 The values of point, mark and the current buffer are restored
491 even in case of abnormal exit (throw or error). 483 even in case of abnormal exit (throw or error).
492 */ ) 484 */
493 (args) 485 (args))
494 Lisp_Object args;
495 { 486 {
496 /* This function can GC */ 487 /* This function can GC */
497 int speccount = specpdl_depth (); 488 int speccount = specpdl_depth ();
498 489
499 record_unwind_protect (save_excursion_restore, save_excursion_save ()); 490 record_unwind_protect (save_excursion_restore, save_excursion_save ());
500 491
501 return unbind_to (speccount, Fprogn (args)); 492 return unbind_to (speccount, Fprogn (args));
502 } 493 }
503 494
504 DEFUN ("buffer-size", Fbufsize, Sbufsize, 0, 1, 0 /* 495 DEFUN ("buffer-size", Fbufsize, 0, 1, 0, /*
505 Return the number of characters in BUFFER. 496 Return the number of characters in BUFFER.
506 If BUFFER is nil, the current buffer is assumed. 497 If BUFFER is nil, the current buffer is assumed.
507 */ ) 498 */
508 (buffer) 499 (buffer))
509 Lisp_Object buffer;
510 { 500 {
511 struct buffer *b = decode_buffer (buffer, 1); 501 struct buffer *b = decode_buffer (buffer, 1);
512 return (make_int (BUF_SIZE (b))); 502 return (make_int (BUF_SIZE (b)));
513 } 503 }
514 504
515 DEFUN ("point-min", Fpoint_min, Spoint_min, 0, 1, 0 /* 505 DEFUN ("point-min", Fpoint_min, 0, 1, 0, /*
516 Return the minimum permissible value of point in BUFFER. 506 Return the minimum permissible value of point in BUFFER.
517 This is 1, unless narrowing (a buffer restriction) is in effect. 507 This is 1, unless narrowing (a buffer restriction) is in effect.
518 If BUFFER is nil, the current buffer is assumed. 508 If BUFFER is nil, the current buffer is assumed.
519 */ ) 509 */
520 (buffer) 510 (buffer))
521 Lisp_Object buffer;
522 { 511 {
523 struct buffer *b = decode_buffer (buffer, 1); 512 struct buffer *b = decode_buffer (buffer, 1);
524 return (make_int (BUF_BEGV (b))); 513 return (make_int (BUF_BEGV (b)));
525 } 514 }
526 515
527 DEFUN ("point-min-marker", Fpoint_min_marker, Spoint_min_marker, 0, 1, 0 /* 516 DEFUN ("point-min-marker", Fpoint_min_marker, 0, 1, 0, /*
528 Return a marker to the minimum permissible value of point in BUFFER. 517 Return a marker to the minimum permissible value of point in BUFFER.
529 This is the beginning, unless narrowing (a buffer restriction) is in effect. 518 This is the beginning, unless narrowing (a buffer restriction) is in effect.
530 If BUFFER is nil, the current buffer is assumed. 519 If BUFFER is nil, the current buffer is assumed.
531 */ ) 520 */
532 (buffer) 521 (buffer))
533 Lisp_Object buffer;
534 { 522 {
535 struct buffer *b = decode_buffer (buffer, 1); 523 struct buffer *b = decode_buffer (buffer, 1);
536 return buildmark (BUF_BEGV (b), make_buffer (b)); 524 return buildmark (BUF_BEGV (b), make_buffer (b));
537 } 525 }
538 526
539 DEFUN ("point-max", Fpoint_max, Spoint_max, 0, 1, 0 /* 527 DEFUN ("point-max", Fpoint_max, 0, 1, 0, /*
540 Return the maximum permissible value of point in BUFFER. 528 Return the maximum permissible value of point in BUFFER.
541 This is (1+ (buffer-size)), unless narrowing (a buffer restriction) 529 This is (1+ (buffer-size)), unless narrowing (a buffer restriction)
542 is in effect, in which case it is less. 530 is in effect, in which case it is less.
543 If BUFFER is nil, the current buffer is assumed. 531 If BUFFER is nil, the current buffer is assumed.
544 */ ) 532 */
545 (buffer) 533 (buffer))
546 Lisp_Object buffer;
547 { 534 {
548 struct buffer *b = decode_buffer (buffer, 1); 535 struct buffer *b = decode_buffer (buffer, 1);
549 return (make_int (BUF_ZV (b))); 536 return (make_int (BUF_ZV (b)));
550 } 537 }
551 538
552 DEFUN ("point-max-marker", Fpoint_max_marker, Spoint_max_marker, 0, 1, 0 /* 539 DEFUN ("point-max-marker", Fpoint_max_marker, 0, 1, 0, /*
553 Return a marker to the maximum permissible value of point BUFFER. 540 Return a marker to the maximum permissible value of point BUFFER.
554 This is (1+ (buffer-size)), unless narrowing (a buffer restriction) 541 This is (1+ (buffer-size)), unless narrowing (a buffer restriction)
555 is in effect, in which case it is less. 542 is in effect, in which case it is less.
556 If BUFFER is nil, the current buffer is assumed. 543 If BUFFER is nil, the current buffer is assumed.
557 */ ) 544 */
558 (buffer) 545 (buffer))
559 Lisp_Object buffer;
560 { 546 {
561 struct buffer *b = decode_buffer (buffer, 1); 547 struct buffer *b = decode_buffer (buffer, 1);
562 return buildmark (BUF_ZV (b), make_buffer (b)); 548 return buildmark (BUF_ZV (b), make_buffer (b));
563 } 549 }
564 550
565 DEFUN ("following-char", Ffollowing_char, Sfollowing_char, 0, 1, 0 /* 551 DEFUN ("following-char", Ffollowing_char, 0, 1, 0, /*
566 Return the character following point, as a number. 552 Return the character following point, as a number.
567 At the end of the buffer or accessible region, return 0. 553 At the end of the buffer or accessible region, return 0.
568 If BUFFER is nil, the current buffer is assumed. 554 If BUFFER is nil, the current buffer is assumed.
569 */ ) 555 */
570 (buffer) 556 (buffer))
571 Lisp_Object buffer;
572 { 557 {
573 struct buffer *b = decode_buffer (buffer, 1); 558 struct buffer *b = decode_buffer (buffer, 1);
574 if (BUF_PT (b) >= BUF_ZV (b)) 559 if (BUF_PT (b) >= BUF_ZV (b))
575 return (Qzero); /* #### Gag me! */ 560 return (Qzero); /* #### Gag me! */
576 else 561 else
577 return (make_char (BUF_FETCH_CHAR (b, BUF_PT (b)))); 562 return (make_char (BUF_FETCH_CHAR (b, BUF_PT (b))));
578 } 563 }
579 564
580 DEFUN ("preceding-char", Fpreceding_char, Spreceding_char, 0, 1, 0 /* 565 DEFUN ("preceding-char", Fpreceding_char, 0, 1, 0, /*
581 Return the character preceding point, as a number. 566 Return the character preceding point, as a number.
582 At the beginning of the buffer or accessible region, return 0. 567 At the beginning of the buffer or accessible region, return 0.
583 If BUFFER is nil, the current buffer is assumed. 568 If BUFFER is nil, the current buffer is assumed.
584 */ ) 569 */
585 (buffer) 570 (buffer))
586 Lisp_Object buffer;
587 { 571 {
588 struct buffer *b = decode_buffer (buffer, 1); 572 struct buffer *b = decode_buffer (buffer, 1);
589 if (BUF_PT (b) <= BUF_BEGV (b)) 573 if (BUF_PT (b) <= BUF_BEGV (b))
590 return (Qzero); /* #### Gag me! */ 574 return (Qzero); /* #### Gag me! */
591 else 575 else
592 return (make_char (BUF_FETCH_CHAR (b, BUF_PT (b) - 1))); 576 return (make_char (BUF_FETCH_CHAR (b, BUF_PT (b) - 1)));
593 } 577 }
594 578
595 DEFUN ("bobp", Fbobp, Sbobp, 0, 1, 0 /* 579 DEFUN ("bobp", Fbobp, 0, 1, 0, /*
596 Return T if point is at the beginning of the buffer. 580 Return T if point is at the beginning of the buffer.
597 If the buffer is narrowed, this means the beginning of the narrowed part. 581 If the buffer is narrowed, this means the beginning of the narrowed part.
598 If BUFFER is nil, the current buffer is assumed. 582 If BUFFER is nil, the current buffer is assumed.
599 */ ) 583 */
600 (buffer) 584 (buffer))
601 Lisp_Object buffer;
602 { 585 {
603 struct buffer *b = decode_buffer (buffer, 1); 586 struct buffer *b = decode_buffer (buffer, 1);
604 return BUF_PT (b) == BUF_BEGV (b) ? Qt : Qnil; 587 return BUF_PT (b) == BUF_BEGV (b) ? Qt : Qnil;
605 } 588 }
606 589
607 DEFUN ("eobp", Feobp, Seobp, 0, 1, 0 /* 590 DEFUN ("eobp", Feobp, 0, 1, 0, /*
608 Return T if point is at the end of the buffer. 591 Return T if point is at the end of the buffer.
609 If the buffer is narrowed, this means the end of the narrowed part. 592 If the buffer is narrowed, this means the end of the narrowed part.
610 If BUFFER is nil, the current buffer is assumed. 593 If BUFFER is nil, the current buffer is assumed.
611 */ ) 594 */
612 (buffer) 595 (buffer))
613 Lisp_Object buffer;
614 { 596 {
615 struct buffer *b = decode_buffer (buffer, 1); 597 struct buffer *b = decode_buffer (buffer, 1);
616 return BUF_PT (b) == BUF_ZV (b) ? Qt : Qnil; 598 return BUF_PT (b) == BUF_ZV (b) ? Qt : Qnil;
617 } 599 }
618 600
623 return 1; 605 return 1;
624 return BUF_FETCH_CHAR (b, pt - 1) == '\n'; 606 return BUF_FETCH_CHAR (b, pt - 1) == '\n';
625 } 607 }
626 608
627 609
628 DEFUN ("bolp", Fbolp, Sbolp, 0, 1, 0 /* 610 DEFUN ("bolp", Fbolp, 0, 1, 0, /*
629 Return T if point is at the beginning of a line. 611 Return T if point is at the beginning of a line.
630 If BUFFER is nil, the current buffer is assumed. 612 If BUFFER is nil, the current buffer is assumed.
631 */ ) 613 */
632 (buffer) 614 (buffer))
633 Lisp_Object buffer;
634 { 615 {
635 struct buffer *b = decode_buffer (buffer, 1); 616 struct buffer *b = decode_buffer (buffer, 1);
636 617
637 return beginning_of_line_p (b, BUF_PT (b)) ? Qt : Qnil; 618 return beginning_of_line_p (b, BUF_PT (b)) ? Qt : Qnil;
638 } 619 }
639 620
640 DEFUN ("eolp", Feolp, Seolp, 0, 1, 0 /* 621 DEFUN ("eolp", Feolp, 0, 1, 0, /*
641 Return T if point is at the end of a line. 622 Return T if point is at the end of a line.
642 `End of a line' includes point being at the end of the buffer. 623 `End of a line' includes point being at the end of the buffer.
643 If BUFFER is nil, the current buffer is assumed. 624 If BUFFER is nil, the current buffer is assumed.
644 */ ) 625 */
645 (buffer) 626 (buffer))
646 Lisp_Object buffer;
647 { 627 {
648 struct buffer *b = decode_buffer (buffer, 1); 628 struct buffer *b = decode_buffer (buffer, 1);
649 if (BUF_PT (b) == BUF_ZV (b) || BUF_FETCH_CHAR (b, BUF_PT (b)) == '\n') 629 if (BUF_PT (b) == BUF_ZV (b) || BUF_FETCH_CHAR (b, BUF_PT (b)) == '\n')
650 return Qt; 630 return Qt;
651 return Qnil; 631 return Qnil;
652 } 632 }
653 633
654 DEFUN ("char-after", Fchar_after, Schar_after, 1, 2, 0 /* 634 DEFUN ("char-after", Fchar_after, 1, 2, 0, /*
655 Return character in BUFFER at position POS. 635 Return character in BUFFER at position POS.
656 POS is an integer or a buffer pointer. 636 POS is an integer or a buffer pointer.
657 If POS is out of range, the value is nil. 637 If POS is out of range, the value is nil.
658 If BUFFER is nil, the current buffer is assumed. 638 If BUFFER is nil, the current buffer is assumed.
659 */ ) 639 */
660 (pos, buffer) 640 (pos, buffer))
661 Lisp_Object pos, buffer;
662 { 641 {
663 struct buffer *b = decode_buffer (buffer, 1); 642 struct buffer *b = decode_buffer (buffer, 1);
664 Bufpos n = get_buffer_pos_char (b, pos, GB_NO_ERROR_IF_BAD); 643 Bufpos n = get_buffer_pos_char (b, pos, GB_NO_ERROR_IF_BAD);
665 644
666 if (n < 0 || n == BUF_ZV (b)) 645 if (n < 0 || n == BUF_ZV (b))
667 return Qnil; 646 return Qnil;
668 return (make_char (BUF_FETCH_CHAR (b, n))); 647 return (make_char (BUF_FETCH_CHAR (b, n)));
669 } 648 }
670 649
671 650
672 DEFUN ("user-login-name", Fuser_login_name, Suser_login_name, 0, 1, 0 /* 651 DEFUN ("user-login-name", Fuser_login_name, 0, 1, 0, /*
673 Return the name under which the user logged in, as a string. 652 Return the name under which the user logged in, as a string.
674 This is based on the effective uid, not the real uid. 653 This is based on the effective uid, not the real uid.
675 Also, if the environment variable LOGNAME or USER is set, 654 Also, if the environment variable LOGNAME or USER is set,
676 that determines the value of this function. 655 that determines the value of this function.
677 If the optional argument UID is present, then environment variables are 656 If the optional argument UID is present, then environment variables are
678 ignored and this function returns the login name for that UID, or nil. 657 ignored and this function returns the login name for that UID, or nil.
679 */ ) 658 */
680 (uid) 659 (uid))
681 Lisp_Object uid;
682 { 660 {
683 struct passwd *pw = NULL; 661 struct passwd *pw = NULL;
684 662
685 if (!NILP (uid)) 663 if (!NILP (uid))
686 { 664 {
707 } 685 }
708 /* #### - I believe this should return nil instead of "unknown" when pw==0 */ 686 /* #### - I believe this should return nil instead of "unknown" when pw==0 */
709 return (pw ? build_string (pw->pw_name) : Qnil); 687 return (pw ? build_string (pw->pw_name) : Qnil);
710 } 688 }
711 689
712 DEFUN ("user-real-login-name", Fuser_real_login_name, Suser_real_login_name, 690 DEFUN ("user-real-login-name", Fuser_real_login_name, 0, 0, 0, /*
713 0, 0, 0 /*
714 Return the name of the user's real uid, as a string. 691 Return the name of the user's real uid, as a string.
715 This ignores the environment variables LOGNAME and USER, so it differs from 692 This ignores the environment variables LOGNAME and USER, so it differs from
716 `user-login-name' when running under `su'. 693 `user-login-name' when running under `su'.
717 */ ) 694 */
718 () 695 ())
719 { 696 {
720 struct passwd *pw = (struct passwd *) getpwuid (getuid ()); 697 struct passwd *pw = (struct passwd *) getpwuid (getuid ());
721 /* #### - I believe this should return nil instead of "unknown" when pw==0 */ 698 /* #### - I believe this should return nil instead of "unknown" when pw==0 */
722 699
723 #ifdef MSDOS 700 #ifdef MSDOS
729 Lisp_Object tem = build_string (pw ? pw->pw_name : "unknown");/* no gettext */ 706 Lisp_Object tem = build_string (pw ? pw->pw_name : "unknown");/* no gettext */
730 #endif 707 #endif
731 return (tem); 708 return (tem);
732 } 709 }
733 710
734 DEFUN ("user-uid", Fuser_uid, Suser_uid, 0, 0, 0 /* 711 DEFUN ("user-uid", Fuser_uid, 0, 0, 0, /*
735 Return the effective uid of Emacs, as an integer. 712 Return the effective uid of Emacs, as an integer.
736 */ ) 713 */
737 () 714 ())
738 { 715 {
739 return make_int (geteuid ()); 716 return make_int (geteuid ());
740 } 717 }
741 718
742 DEFUN ("user-real-uid", Fuser_real_uid, Suser_real_uid, 0, 0, 0 /* 719 DEFUN ("user-real-uid", Fuser_real_uid, 0, 0, 0, /*
743 Return the real uid of Emacs, as an integer. 720 Return the real uid of Emacs, as an integer.
744 */ ) 721 */
745 () 722 ())
746 { 723 {
747 return make_int (getuid ()); 724 return make_int (getuid ());
748 } 725 }
749 726
750 DEFUN ("user-full-name", Fuser_full_name, Suser_full_name, 0, 1, 0 /* 727 DEFUN ("user-full-name", Fuser_full_name, 0, 1, 0, /*
751 Return the full name of the user logged in, as a string. 728 Return the full name of the user logged in, as a string.
752 If the optional argument USER is given, then the full name for that 729 If the optional argument USER is given, then the full name for that
753 user is returned, or nil. USER may be either a login name or a uid. 730 user is returned, or nil. USER may be either a login name or a uid.
754 */ ) 731 */
755 (user) 732 (user))
756 Lisp_Object user;
757 { 733 {
758 Lisp_Object uname = (STRINGP (user) ? user : Fuser_login_name (user)); 734 Lisp_Object uname = (STRINGP (user) ? user : Fuser_login_name (user));
759 struct passwd *pw = NULL; 735 struct passwd *pw = NULL;
760 Lisp_Object tem; 736 Lisp_Object tem;
761 char *p, *q; 737 char *p, *q;
810 if (p) 786 if (p)
811 tem = build_string (p); 787 tem = build_string (p);
812 return (tem); 788 return (tem);
813 } 789 }
814 790
815 DEFUN ("system-name", Fsystem_name, Ssystem_name, 0, 0, 0 /* 791 DEFUN ("system-name", Fsystem_name, 0, 0, 0, /*
816 Return the name of the machine you are running on, as a string. 792 Return the name of the machine you are running on, as a string.
817 */ ) 793 */
818 () 794 ())
819 { 795 {
820 return (Fcopy_sequence (Vsystem_name)); 796 return (Fcopy_sequence (Vsystem_name));
821 } 797 }
822 798
823 /* For the benefit of callers who don't want to include lisp.h. 799 /* For the benefit of callers who don't want to include lisp.h.
826 get_system_name (void) 802 get_system_name (void)
827 { 803 {
828 return xstrdup ((char *) XSTRING_DATA (Vsystem_name)); 804 return xstrdup ((char *) XSTRING_DATA (Vsystem_name));
829 } 805 }
830 806
831 DEFUN ("emacs-pid", Femacs_pid, Semacs_pid, 0, 0, 0 /* 807 DEFUN ("emacs-pid", Femacs_pid, 0, 0, 0, /*
832 Return the process ID of Emacs, as an integer. 808 Return the process ID of Emacs, as an integer.
833 */ ) 809 */
834 () 810 ())
835 { 811 {
836 return make_int (getpid ()); 812 return make_int (getpid ());
837 } 813 }
838 814
839 DEFUN ("current-time", Fcurrent_time, Scurrent_time, 0, 0, 0 /* 815 DEFUN ("current-time", Fcurrent_time, 0, 0, 0, /*
840 Return the current time, as the number of seconds since 1970-01-01 00:00:00. 816 Return the current time, as the number of seconds since 1970-01-01 00:00:00.
841 The time is returned as a list of three integers. The first has the 817 The time is returned as a list of three integers. The first has the
842 most significant 16 bits of the seconds, while the second has the 818 most significant 16 bits of the seconds, while the second has the
843 least significant 16 bits. The third integer gives the microsecond 819 least significant 16 bits. The third integer gives the microsecond
844 count. 820 count.
845 821
846 The microsecond count is zero on systems that do not provide 822 The microsecond count is zero on systems that do not provide
847 resolution finer than a second. 823 resolution finer than a second.
848 */ ) 824 */
849 () 825 ())
850 { 826 {
851 EMACS_TIME t; 827 EMACS_TIME t;
852 Lisp_Object result[3]; 828 Lisp_Object result[3];
853 829
854 EMACS_GET_TIME (t); 830 EMACS_GET_TIME (t);
857 XSETINT (result[2], EMACS_USECS (t)); 833 XSETINT (result[2], EMACS_USECS (t));
858 834
859 return Flist (3, result); 835 return Flist (3, result);
860 } 836 }
861 837
862 DEFUN ("current-process-time", Fcurrent_process_time, Scurrent_process_time, 838 DEFUN ("current-process-time", Fcurrent_process_time, 0, 0, 0, /*
863 0, 0, 0 /*
864 Return the amount of time used by this XEmacs process so far. 839 Return the amount of time used by this XEmacs process so far.
865 The return value is a list of three floating-point numbers, expressing 840 The return value is a list of three floating-point numbers, expressing
866 the user, system, and real times used by the process. The user time 841 the user, system, and real times used by the process. The user time
867 measures the time actually spent by the CPU executing the code in this 842 measures the time actually spent by the CPU executing the code in this
868 process. The system time measures time spent by the CPU executing kernel 843 process. The system time measures time spent by the CPU executing kernel
880 the process, and the system time will be 0. 855 the process, and the system time will be 0.
881 856
882 Some systems do not allow the real and processor times to be distinguished. 857 Some systems do not allow the real and processor times to be distinguished.
883 In this case, the user and real times will be the same and the system 858 In this case, the user and real times will be the same and the system
884 time will be 0. 859 time will be 0.
885 */ ) 860 */
886 () 861 ())
887 { 862 {
888 double user, sys, real; 863 double user, sys, real;
889 864
890 get_process_times (&user, &sys, &real); 865 get_process_times (&user, &sys, &real);
891 return list3 (make_float (user), make_float (sys), make_float (real)); 866 return list3 (make_float (user), make_float (sys), make_float (real));
921 size_t emacs_strftime (char *string, size_t max, CONST char *format, 896 size_t emacs_strftime (char *string, size_t max, CONST char *format,
922 CONST struct tm *tm); 897 CONST struct tm *tm);
923 static long difftm (CONST struct tm *a, CONST struct tm *b); 898 static long difftm (CONST struct tm *a, CONST struct tm *b);
924 899
925 900
926 DEFUN ("format-time-string", Fformat_time_string, Sformat_time_string, 901 DEFUN ("format-time-string", Fformat_time_string, 2, 2, 0, /*
927 2, 2, 0 /*
928 Use FORMAT-STRING to format the time TIME. 902 Use FORMAT-STRING to format the time TIME.
929 TIME is specified as (HIGH LOW . IGNORED) or (HIGH . LOW), as from 903 TIME is specified as (HIGH LOW . IGNORED) or (HIGH . LOW), as from
930 `current-time' and `file-attributes'. 904 `current-time' and `file-attributes'.
931 FORMAT-STRING may contain %-sequences to substitute parts of the time. 905 FORMAT-STRING may contain %-sequences to substitute parts of the time.
932 %a is replaced by the abbreviated name of the day of week. 906 %a is replaced by the abbreviated name of the day of week.
964 938
965 The number of options reflects the `strftime' function. 939 The number of options reflects the `strftime' function.
966 940
967 BUG: If the charset used by the current locale is not ISO 8859-1, the 941 BUG: If the charset used by the current locale is not ISO 8859-1, the
968 characters appearing in the day and month names may be incorrect. 942 characters appearing in the day and month names may be incorrect.
969 */ ) 943 */
970 (format_string, _time) 944 (format_string, _time))
971 Lisp_Object format_string, _time;
972 { 945 {
973 time_t value; 946 time_t value;
974 int size; 947 int size;
975 948
976 CHECK_STRING (format_string); 949 CHECK_STRING (format_string);
993 /* If buffer was too small, make it bigger. */ 966 /* If buffer was too small, make it bigger. */
994 size *= 2; 967 size *= 2;
995 } 968 }
996 } 969 }
997 970
998 DEFUN ("decode-time", Fdecode_time, Sdecode_time, 0, 1, 0 /* 971 DEFUN ("decode-time", Fdecode_time, 0, 1, 0, /*
999 Decode a time value as (SEC MINUTE HOUR DAY MONTH YEAR DOW DST ZONE). 972 Decode a time value as (SEC MINUTE HOUR DAY MONTH YEAR DOW DST ZONE).
1000 The optional SPECIFIED-TIME should be a list of (HIGH LOW . IGNORED) 973 The optional SPECIFIED-TIME should be a list of (HIGH LOW . IGNORED)
1001 or (HIGH . LOW), as from `current-time' and `file-attributes', or `nil' 974 or (HIGH . LOW), as from `current-time' and `file-attributes', or `nil'
1002 to use the current time. The list has the following nine members: 975 to use the current time. The list has the following nine members:
1003 SEC is an integer between 0 and 60; SEC is 60 for a leap second, which 976 SEC is an integer between 0 and 60; SEC is 60 for a leap second, which
1006 MONTH is an integer between 1 and 12. YEAR is an integer indicating the 979 MONTH is an integer between 1 and 12. YEAR is an integer indicating the
1007 four-digit year. DOW is the day of week, an integer between 0 and 6, where 980 four-digit year. DOW is the day of week, an integer between 0 and 6, where
1008 0 is Sunday. DST is t if daylight savings time is effect, otherwise nil. 981 0 is Sunday. DST is t if daylight savings time is effect, otherwise nil.
1009 ZONE is an integer indicating the number of seconds east of Greenwich. 982 ZONE is an integer indicating the number of seconds east of Greenwich.
1010 \(Note that Common Lisp has different meanings for DOW and ZONE.) 983 \(Note that Common Lisp has different meanings for DOW and ZONE.)
1011 */ ) 984 */
1012 (specified_time) 985 (specified_time))
1013 Lisp_Object specified_time;
1014 { 986 {
1015 time_t time_spec; 987 time_t time_spec;
1016 struct tm save_tm; 988 struct tm save_tm;
1017 struct tm *decoded_time; 989 struct tm *decoded_time;
1018 Lisp_Object list_args[9]; 990 Lisp_Object list_args[9];
1040 return Flist (9, list_args); 1012 return Flist (9, list_args);
1041 } 1013 }
1042 1014
1043 static void set_time_zone_rule (char *tzstring); 1015 static void set_time_zone_rule (char *tzstring);
1044 1016
1045 DEFUN ("encode-time", Fencode_time, Sencode_time, 6, MANY, 0 /* 1017 DEFUN ("encode-time", Fencode_time, 6, MANY, 0, /*
1046 Convert SECOND, MINUTE, HOUR, DAY, MONTH, YEAR and ZONE to internal time. 1018 Convert SECOND, MINUTE, HOUR, DAY, MONTH, YEAR and ZONE to internal time.
1047 This is the reverse operation of `decode-time', which see. 1019 This is the reverse operation of `decode-time', which see.
1048 ZONE defaults to the current time zone rule. This can 1020 ZONE defaults to the current time zone rule. This can
1049 be a string (as from `set-time-zone-rule'), or it can be a list 1021 be a string (as from `set-time-zone-rule'), or it can be a list
1050 (as from `current-time-zone') or an integer (as from `decode-time') 1022 (as from `current-time-zone') or an integer (as from `decode-time')
1057 1029
1058 Out-of-range values for SEC, MINUTE, HOUR, DAY, or MONTH are allowed; 1030 Out-of-range values for SEC, MINUTE, HOUR, DAY, or MONTH are allowed;
1059 for example, a DAY of 0 means the day preceding the given month. 1031 for example, a DAY of 0 means the day preceding the given month.
1060 Year numbers less than 100 are treated just like other year numbers. 1032 Year numbers less than 100 are treated just like other year numbers.
1061 If you want them to stand for years in this century, you must do that yourself 1033 If you want them to stand for years in this century, you must do that yourself
1062 */ ) 1034 */
1063 (nargs, args) 1035 (int nargs, Lisp_Object *args))
1064 int nargs;
1065 Lisp_Object *args;
1066 { 1036 {
1067 time_t _time; 1037 time_t _time;
1068 struct tm tm; 1038 struct tm tm;
1069 Lisp_Object zone = (nargs > 6) ? args[nargs - 1] : Qnil; 1039 Lisp_Object zone = (nargs > 6) ? args[nargs - 1] : Qnil;
1070 1040
1124 error ("Specified time is not representable"); 1094 error ("Specified time is not representable");
1125 1095
1126 return wasteful_word_to_lisp (_time); 1096 return wasteful_word_to_lisp (_time);
1127 } 1097 }
1128 1098
1129 DEFUN ("current-time-string", Fcurrent_time_string, Scurrent_time_string, 1099 DEFUN ("current-time-string", Fcurrent_time_string, 0, 1, 0, /*
1130 0, 1, 0 /*
1131 Return the current time, as a human-readable string. 1100 Return the current time, as a human-readable string.
1132 Programs can use this function to decode a time, 1101 Programs can use this function to decode a time,
1133 since the number of columns in each field is fixed. 1102 since the number of columns in each field is fixed.
1134 The format is `Sun Sep 16 01:03:52 1973'. 1103 The format is `Sun Sep 16 01:03:52 1973'.
1135 If an argument is given, it specifies a time to format 1104 If an argument is given, it specifies a time to format
1137 (HIGH . LOW) 1106 (HIGH . LOW)
1138 or the form: 1107 or the form:
1139 (HIGH LOW . IGNORED). 1108 (HIGH LOW . IGNORED).
1140 Thus, you can use times obtained from `current-time' 1109 Thus, you can use times obtained from `current-time'
1141 and from `file-attributes'. 1110 and from `file-attributes'.
1142 */ ) 1111 */
1143 (specified_time) 1112 (specified_time))
1144 Lisp_Object specified_time;
1145 { 1113 {
1146 time_t value; 1114 time_t value;
1147 char buf[30]; 1115 char buf[30];
1148 char *tem; 1116 char *tem;
1149 1117
1179 return (60*(60*(24*days + (a->tm_hour - b->tm_hour)) 1147 return (60*(60*(24*days + (a->tm_hour - b->tm_hour))
1180 + (a->tm_min - b->tm_min)) 1148 + (a->tm_min - b->tm_min))
1181 + (a->tm_sec - b->tm_sec)); 1149 + (a->tm_sec - b->tm_sec));
1182 } 1150 }
1183 1151
1184 DEFUN ("current-time-zone", Fcurrent_time_zone, Scurrent_time_zone, 0, 1, 0 /* 1152 DEFUN ("current-time-zone", Fcurrent_time_zone, 0, 1, 0, /*
1185 Return the offset and name for the local time zone. 1153 Return the offset and name for the local time zone.
1186 This returns a list of the form (OFFSET NAME). 1154 This returns a list of the form (OFFSET NAME).
1187 OFFSET is an integer number of seconds ahead of UTC (east of Greenwich). 1155 OFFSET is an integer number of seconds ahead of UTC (east of Greenwich).
1188 A negative value means west of Greenwich. 1156 A negative value means west of Greenwich.
1189 NAME is a string giving the name of the time zone. 1157 NAME is a string giving the name of the time zone.
1196 and from `file-attributes'. 1164 and from `file-attributes'.
1197 1165
1198 Some operating systems cannot provide all this information to Emacs; 1166 Some operating systems cannot provide all this information to Emacs;
1199 in this case, `current-time-zone' returns a list containing nil for 1167 in this case, `current-time-zone' returns a list containing nil for
1200 the data it can't find. 1168 the data it can't find.
1201 */ ) 1169 */
1202 (specified_time) 1170 (specified_time))
1203 Lisp_Object specified_time;
1204 { 1171 {
1205 time_t value; 1172 time_t value;
1206 struct tm *t; 1173 struct tm *t;
1207 1174
1208 if (lisp_to_time (specified_time, &value) 1175 if (lisp_to_time (specified_time, &value)
1270 #ifdef LOCALTIME_CACHE 1237 #ifdef LOCALTIME_CACHE
1271 tzset (); 1238 tzset ();
1272 #endif 1239 #endif
1273 } 1240 }
1274 1241
1275 DEFUN ("set-time-zone-rule", Fset_time_zone_rule, Sset_time_zone_rule, 1242 DEFUN ("set-time-zone-rule", Fset_time_zone_rule, 1, 1, 0, /*
1276 1, 1, 0 /*
1277 Set the local time zone using TZ, a string specifying a time zone rule. 1243 Set the local time zone using TZ, a string specifying a time zone rule.
1278 If TZ is nil, use implementation-defined default time zone information. 1244 If TZ is nil, use implementation-defined default time zone information.
1279 */ ) 1245 */
1280 (tz) 1246 (tz))
1281 Lisp_Object tz;
1282 { 1247 {
1283 char *tzstring; 1248 char *tzstring;
1284 1249
1285 if (NILP (tz)) 1250 if (NILP (tz))
1286 tzstring = 0; 1251 tzstring = 0;
1327 /* Callers passing one argument to Finsert need not gcpro the 1292 /* Callers passing one argument to Finsert need not gcpro the
1328 argument "array", since the only element of the array will 1293 argument "array", since the only element of the array will
1329 not be used after calling insert_emacs_char or insert_lisp_string, 1294 not be used after calling insert_emacs_char or insert_lisp_string,
1330 so we don't care if it gets trashed. */ 1295 so we don't care if it gets trashed. */
1331 1296
1332 DEFUN ("insert", Finsert, Sinsert, 0, MANY, 0 /* 1297 DEFUN ("insert", Finsert, 0, MANY, 0, /*
1333 Insert the arguments, either strings or characters, at point. 1298 Insert the arguments, either strings or characters, at point.
1334 Point moves forward so that it ends up after the inserted text. 1299 Point moves forward so that it ends up after the inserted text.
1335 Any other markers at the point of insertion remain before the text. 1300 Any other markers at the point of insertion remain before the text.
1336 If a string has non-null string-extent-data, new extents will be created. 1301 If a string has non-null string-extent-data, new extents will be created.
1337 */ ) 1302 */
1338 (nargs, args) 1303 (int nargs, Lisp_Object *args))
1339 int nargs;
1340 Lisp_Object *args;
1341 { 1304 {
1342 /* This function can GC */ 1305 /* This function can GC */
1343 REGISTER int argnum; 1306 REGISTER int argnum;
1344 1307
1345 for (argnum = 0; argnum < nargs; argnum++) 1308 for (argnum = 0; argnum < nargs; argnum++)
1348 } 1311 }
1349 1312
1350 return Qnil; 1313 return Qnil;
1351 } 1314 }
1352 1315
1353 DEFUN ("insert-before-markers", Finsert_before_markers, Sinsert_before_markers, 0, MANY, 0 /* 1316 DEFUN ("insert-before-markers", Finsert_before_markers, 0, MANY, 0, /*
1354 Insert strings or characters at point, relocating markers after the text. 1317 Insert strings or characters at point, relocating markers after the text.
1355 Point moves forward so that it ends up after the inserted text. 1318 Point moves forward so that it ends up after the inserted text.
1356 Any other markers at the point of insertion also end up after the text. 1319 Any other markers at the point of insertion also end up after the text.
1357 */ ) 1320 */
1358 (nargs, args) 1321 (int nargs, Lisp_Object *args))
1359 int nargs;
1360 Lisp_Object *args;
1361 { 1322 {
1362 /* This function can GC */ 1323 /* This function can GC */
1363 REGISTER int argnum; 1324 REGISTER int argnum;
1364 REGISTER Lisp_Object tem; 1325 REGISTER Lisp_Object tem;
1365 1326
1386 } 1347 }
1387 zmacs_region_stays = 0; 1348 zmacs_region_stays = 0;
1388 return Qnil; 1349 return Qnil;
1389 } 1350 }
1390 1351
1391 DEFUN ("insert-string", Finsert_string, Sinsert_string, 1, 2, 0 /* 1352 DEFUN ("insert-string", Finsert_string, 1, 2, 0, /*
1392 Insert STRING into BUFFER at BUFFER's point. 1353 Insert STRING into BUFFER at BUFFER's point.
1393 Point moves forward so that it ends up after the inserted text. 1354 Point moves forward so that it ends up after the inserted text.
1394 Any other markers at the point of insertion remain before the text. 1355 Any other markers at the point of insertion remain before the text.
1395 If a string has non-null string-extent-data, new extents will be created. 1356 If a string has non-null string-extent-data, new extents will be created.
1396 BUFFER defaults to the current buffer. 1357 BUFFER defaults to the current buffer.
1397 */ ) 1358 */
1398 (string, buffer) 1359 (string, buffer))
1399 Lisp_Object string, buffer;
1400 { 1360 {
1401 struct buffer *buf = decode_buffer (buffer, 1); 1361 struct buffer *buf = decode_buffer (buffer, 1);
1402 CHECK_STRING (string); 1362 CHECK_STRING (string);
1403 buffer_insert_lisp_string (buf, string); 1363 buffer_insert_lisp_string (buf, string);
1404 zmacs_region_stays = 0; 1364 zmacs_region_stays = 0;
1411 from adjoining text, if those properties are sticky." 1371 from adjoining text, if those properties are sticky."
1412 1372
1413 Jamie thinks this is bogus. */ 1373 Jamie thinks this is bogus. */
1414 1374
1415 1375
1416 DEFUN ("insert-char", Finsert_char, Sinsert_char, 1, 4, 0 /* 1376 DEFUN ("insert-char", Finsert_char, 1, 4, 0, /*
1417 Insert COUNT (second arg) copies of CHR (first arg). 1377 Insert COUNT (second arg) copies of CHR (first arg).
1418 Point and all markers are affected as in the function `insert'. 1378 Point and all markers are affected as in the function `insert'.
1419 COUNT defaults to 1 if omitted. 1379 COUNT defaults to 1 if omitted.
1420 The optional third arg IGNORED is INHERIT under FSF Emacs. 1380 The optional third arg IGNORED is INHERIT under FSF Emacs.
1421 This is highly bogus, however, and XEmacs always behaves as if 1381 This is highly bogus, however, and XEmacs always behaves as if
1422 `t' were passed to INHERIT. 1382 `t' were passed to INHERIT.
1423 The optional fourth arg BUFFER specifies the buffer to insert the 1383 The optional fourth arg BUFFER specifies the buffer to insert the
1424 text into. If BUFFER is nil, the current buffer is assumed. 1384 text into. If BUFFER is nil, the current buffer is assumed.
1425 */ ) 1385 */
1426 (chr, count, ignored, buffer) 1386 (chr, count, ignored, buffer))
1427 Lisp_Object chr, count, ignored, buffer;
1428 { 1387 {
1429 /* This function can GC */ 1388 /* This function can GC */
1430 REGISTER Bufbyte *string; 1389 REGISTER Bufbyte *string;
1431 REGISTER int slen; 1390 REGISTER int slen;
1432 REGISTER int i, j; 1391 REGISTER int i, j;
1478 } 1437 }
1479 1438
1480 1439
1481 /* Making strings from buffer contents. */ 1440 /* Making strings from buffer contents. */
1482 1441
1483 DEFUN ("buffer-substring", Fbuffer_substring, Sbuffer_substring, 0, 3, 0 /* 1442 DEFUN ("buffer-substring", Fbuffer_substring, 0, 3, 0, /*
1484 Return the contents of part of BUFFER as a string. 1443 Return the contents of part of BUFFER as a string.
1485 The two arguments START and END are character positions; 1444 The two arguments START and END are character positions;
1486 they can be in either order. If omitted, they default to the beginning 1445 they can be in either order. If omitted, they default to the beginning
1487 and end of BUFFER, respectively. 1446 and end of BUFFER, respectively.
1488 If there are duplicable extents in the region, the string remembers 1447 If there are duplicable extents in the region, the string remembers
1489 them in its extent data. 1448 them in its extent data.
1490 If BUFFER is nil, the current buffer is assumed. 1449 If BUFFER is nil, the current buffer is assumed.
1491 */ ) 1450 */
1492 (start, end, buffer) 1451 (start, end, buffer))
1493 Lisp_Object start, end, buffer;
1494 { 1452 {
1495 /* This function can GC */ 1453 /* This function can GC */
1496 Bufpos begv, zv; 1454 Bufpos begv, zv;
1497 struct buffer *b = decode_buffer (buffer, 1); 1455 struct buffer *b = decode_buffer (buffer, 1);
1498 1456
1499 get_buffer_range_char (b, start, end, &begv, &zv, GB_ALLOW_NIL); 1457 get_buffer_range_char (b, start, end, &begv, &zv, GB_ALLOW_NIL);
1500 return make_string_from_buffer (b, begv, zv - begv); 1458 return make_string_from_buffer (b, begv, zv - begv);
1501 } 1459 }
1502 1460
1503 DEFUN ("insert-buffer-substring", Finsert_buffer_substring, Sinsert_buffer_substring, 1461 DEFUN ("insert-buffer-substring", Finsert_buffer_substring, 1, 3, 0, /*
1504 1, 3, 0 /*
1505 Insert before point a substring of the contents of buffer BUFFER. 1462 Insert before point a substring of the contents of buffer BUFFER.
1506 BUFFER may be a buffer or a buffer name. 1463 BUFFER may be a buffer or a buffer name.
1507 Arguments START and END are character numbers specifying the substring. 1464 Arguments START and END are character numbers specifying the substring.
1508 They default to the beginning and the end of BUFFER. 1465 They default to the beginning and the end of BUFFER.
1509 */ ) 1466 */
1510 (buffer, start, end) 1467 (buffer, start, end))
1511 Lisp_Object buffer, start, end;
1512 { 1468 {
1513 /* This function can GC */ 1469 /* This function can GC */
1514 Bufpos b, e; 1470 Bufpos b, e;
1515 struct buffer *bp; 1471 struct buffer *bp;
1516 1472
1521 buffer_insert_from_buffer (current_buffer, bp, b, e - b); 1477 buffer_insert_from_buffer (current_buffer, bp, b, e - b);
1522 1478
1523 return Qnil; 1479 return Qnil;
1524 } 1480 }
1525 1481
1526 DEFUN ("compare-buffer-substrings", Fcompare_buffer_substrings, Scompare_buffer_substrings, 1482 DEFUN ("compare-buffer-substrings", Fcompare_buffer_substrings, 6, 6, 0, /*
1527 6, 6, 0 /*
1528 Compare two substrings of two buffers; return result as number. 1483 Compare two substrings of two buffers; return result as number.
1529 the value is -N if first string is less after N-1 chars, 1484 the value is -N if first string is less after N-1 chars,
1530 +N if first string is greater after N-1 chars, or 0 if strings match. 1485 +N if first string is greater after N-1 chars, or 0 if strings match.
1531 Each substring is represented as three arguments: BUFFER, START and END. 1486 Each substring is represented as three arguments: BUFFER, START and END.
1532 That makes six args in all, three for each substring. 1487 That makes six args in all, three for each substring.
1533 1488
1534 The value of `case-fold-search' in the current buffer 1489 The value of `case-fold-search' in the current buffer
1535 determines whether case is significant or ignored. 1490 determines whether case is significant or ignored.
1536 */ ) 1491 */
1537 (buffer1, start1, end1, buffer2, start2, end2) 1492 (buffer1, start1, end1, buffer2, start2, end2))
1538 Lisp_Object buffer1, start1, end1, buffer2, start2, end2;
1539 { 1493 {
1540 Bufpos begp1, endp1, begp2, endp2; 1494 Bufpos begp1, endp1, begp2, endp2;
1541 REGISTER Charcount len1, len2, length, i; 1495 REGISTER Charcount len1, len2, length, i;
1542 struct buffer *bp1, *bp2; 1496 struct buffer *bp1, *bp2;
1543 Lisp_Object trt = ((!NILP (current_buffer->case_fold_search)) ? 1497 Lisp_Object trt = ((!NILP (current_buffer->case_fold_search)) ?
1598 { 1552 {
1599 XBUFFER (XCAR (arg))->filename = XCDR (arg); 1553 XBUFFER (XCAR (arg))->filename = XCDR (arg);
1600 return Qnil; 1554 return Qnil;
1601 } 1555 }
1602 1556
1603 DEFUN ("subst-char-in-region", Fsubst_char_in_region, 1557 DEFUN ("subst-char-in-region", Fsubst_char_in_region, 4, 5, 0, /*
1604 Ssubst_char_in_region, 4, 5, 0 /*
1605 From START to END, replace FROMCHAR with TOCHAR each time it occurs. 1558 From START to END, replace FROMCHAR with TOCHAR each time it occurs.
1606 If optional arg NOUNDO is non-nil, don't record this change for undo 1559 If optional arg NOUNDO is non-nil, don't record this change for undo
1607 and don't mark the buffer as really changed. 1560 and don't mark the buffer as really changed.
1608 */ ) 1561 */
1609 (start, end, fromchar, tochar, noundo) 1562 (start, end, fromchar, tochar, noundo))
1610 Lisp_Object start, end, fromchar, tochar, noundo;
1611 { 1563 {
1612 /* This function can GC */ 1564 /* This function can GC */
1613 Bufpos pos, stop; 1565 Bufpos pos, stop;
1614 Emchar fromc, toc; 1566 Emchar fromc, toc;
1615 int mc_count; 1567 int mc_count;
1665 1617
1666 unbind_to (count, Qnil); 1618 unbind_to (count, Qnil);
1667 return Qnil; 1619 return Qnil;
1668 } 1620 }
1669 1621
1670 DEFUN ("translate-region", Ftranslate_region, Stranslate_region, 3, 3, 0 /* 1622 DEFUN ("translate-region", Ftranslate_region, 3, 3, 0, /*
1671 From START to END, translate characters according to TABLE. 1623 From START to END, translate characters according to TABLE.
1672 TABLE is a string; the Nth character in it is the mapping 1624 TABLE is a string; the Nth character in it is the mapping
1673 for the character with code N. Returns the number of characters changed. 1625 for the character with code N. Returns the number of characters changed.
1674 */ ) 1626 */
1675 (start, end, table) 1627 (start, end, table))
1676 Lisp_Object start;
1677 Lisp_Object end;
1678 Lisp_Object table;
1679 { 1628 {
1680 /* This function can GC */ 1629 /* This function can GC */
1681 Bufpos pos, stop; /* Limits of the region. */ 1630 Bufpos pos, stop; /* Limits of the region. */
1682 REGISTER Emchar oc; /* Old character. */ 1631 REGISTER Emchar oc; /* Old character. */
1683 REGISTER Emchar nc; /* New character. */ 1632 REGISTER Emchar nc; /* New character. */
1709 end_multiple_change (buf, mc_count); 1658 end_multiple_change (buf, mc_count);
1710 1659
1711 return make_int (cnt); 1660 return make_int (cnt);
1712 } 1661 }
1713 1662
1714 DEFUN ("delete-region", Fdelete_region, Sdelete_region, 2, 3, "r" /* 1663 DEFUN ("delete-region", Fdelete_region, 2, 3, "r", /*
1715 Delete the text between point and mark. 1664 Delete the text between point and mark.
1716 When called from a program, expects two arguments, 1665 When called from a program, expects two arguments,
1717 positions (integers or markers) specifying the stretch to be deleted. 1666 positions (integers or markers) specifying the stretch to be deleted.
1718 If BUFFER is nil, the current buffer is assumed. 1667 If BUFFER is nil, the current buffer is assumed.
1719 */ ) 1668 */
1720 (b, e, buffer) 1669 (b, e, buffer))
1721 Lisp_Object b, e, buffer;
1722 { 1670 {
1723 /* This function can GC */ 1671 /* This function can GC */
1724 Bufpos start, end; 1672 Bufpos start, end;
1725 struct buffer *buf = decode_buffer (buffer, 1); 1673 struct buffer *buf = decode_buffer (buffer, 1);
1726 1674
1751 column. */ 1699 column. */
1752 invalidate_current_column (); 1700 invalidate_current_column ();
1753 } 1701 }
1754 } 1702 }
1755 1703
1756 DEFUN ("widen", Fwiden, Swiden, 0, 1, "" /* 1704 DEFUN ("widen", Fwiden, 0, 1, "", /*
1757 Remove restrictions (narrowing) from BUFFER. 1705 Remove restrictions (narrowing) from BUFFER.
1758 This allows the buffer's full text to be seen and edited. 1706 This allows the buffer's full text to be seen and edited.
1759 If BUFFER is nil, the current buffer is assumed. 1707 If BUFFER is nil, the current buffer is assumed.
1760 */ ) 1708 */
1761 (buffer) 1709 (buffer))
1762 Lisp_Object buffer;
1763 { 1710 {
1764 struct buffer *b = decode_buffer (buffer, 1); 1711 struct buffer *b = decode_buffer (buffer, 1);
1765 widen_buffer (b, 0); 1712 widen_buffer (b, 0);
1766 zmacs_region_stays = 0; 1713 zmacs_region_stays = 0;
1767 return Qnil; 1714 return Qnil;
1768 } 1715 }
1769 1716
1770 DEFUN ("narrow-to-region", Fnarrow_to_region, Snarrow_to_region, 2, 3, "r" /* 1717 DEFUN ("narrow-to-region", Fnarrow_to_region, 2, 3, "r", /*
1771 Restrict editing in BUFFER to the current region. 1718 Restrict editing in BUFFER to the current region.
1772 The rest of the text becomes temporarily invisible and untouchable 1719 The rest of the text becomes temporarily invisible and untouchable
1773 but is not deleted; if you save the buffer in a file, the invisible 1720 but is not deleted; if you save the buffer in a file, the invisible
1774 text is included in the file. \\[widen] makes all visible again. 1721 text is included in the file. \\[widen] makes all visible again.
1775 If BUFFER is nil, the current buffer is assumed. 1722 If BUFFER is nil, the current buffer is assumed.
1776 See also `save-restriction'. 1723 See also `save-restriction'.
1777 1724
1778 When calling from a program, pass two arguments; positions (integers 1725 When calling from a program, pass two arguments; positions (integers
1779 or markers) bounding the text that should remain visible. 1726 or markers) bounding the text that should remain visible.
1780 */ ) 1727 */
1781 (b, e, buffer) 1728 (b, e, buffer))
1782 Lisp_Object b, e, buffer;
1783 { 1729 {
1784 Bufpos start, end; 1730 Bufpos start, end;
1785 struct buffer *buf = decode_buffer (buffer, 1); 1731 struct buffer *buf = decode_buffer (buffer, 1);
1786 Bytind bi_start, bi_end; 1732 Bytind bi_start, bi_end;
1787 1733
1873 BUF_ZV (buf))); 1819 BUF_ZV (buf)));
1874 1820
1875 return Qnil; 1821 return Qnil;
1876 } 1822 }
1877 1823
1878 DEFUN ("save-restriction", Fsave_restriction, Ssave_restriction, 0, UNEVALLED, 0 /* 1824 DEFUN ("save-restriction", Fsave_restriction, 0, UNEVALLED, 0, /*
1879 Execute BODY, saving and restoring current buffer's restrictions. 1825 Execute BODY, saving and restoring current buffer's restrictions.
1880 The buffer's restrictions make parts of the beginning and end invisible. 1826 The buffer's restrictions make parts of the beginning and end invisible.
1881 \(They are set up with `narrow-to-region' and eliminated with `widen'.) 1827 \(They are set up with `narrow-to-region' and eliminated with `widen'.)
1882 This special form, `save-restriction', saves the current buffer's restrictions 1828 This special form, `save-restriction', saves the current buffer's restrictions
1883 when it is entered, and restores them when it is exited. 1829 when it is entered, and restores them when it is exited.
1891 and then make changes outside the area within the saved restrictions. 1837 and then make changes outside the area within the saved restrictions.
1892 1838
1893 Note: if you are using both `save-excursion' and `save-restriction', 1839 Note: if you are using both `save-excursion' and `save-restriction',
1894 use `save-excursion' outermost: 1840 use `save-excursion' outermost:
1895 (save-excursion (save-restriction ...)) 1841 (save-excursion (save-restriction ...))
1896 */ ) 1842 */
1897 (body) 1843 (body))
1898 Lisp_Object body;
1899 { 1844 {
1900 /* This function can GC */ 1845 /* This function can GC */
1901 int speccount = specpdl_depth (); 1846 int speccount = specpdl_depth ();
1902 1847
1903 record_unwind_protect (save_restriction_restore, save_restriction_save ()); 1848 record_unwind_protect (save_restriction_restore, save_restriction_save ());
1904 1849
1905 return unbind_to (speccount, Fprogn (body)); 1850 return unbind_to (speccount, Fprogn (body));
1906 } 1851 }
1907 1852
1908 1853
1909 DEFUN ("format", Fformat, Sformat, 1, MANY, 0 /* 1854 DEFUN ("format", Fformat, 1, MANY, 0, /*
1910 Format a string out of a control-string and arguments. 1855 Format a string out of a control-string and arguments.
1911 The first argument is a control string. 1856 The first argument is a control string.
1912 The other arguments are substituted into it to make the result, a string. 1857 The other arguments are substituted into it to make the result, a string.
1913 It may contain %-sequences meaning to substitute the next argument. 1858 It may contain %-sequences meaning to substitute the next argument.
1914 %s means print all objects as-is, using `princ'. 1859 %s means print all objects as-is, using `princ'.
1956 a decimal point is printed in %f, %e, and %E conversions even if no 1901 a decimal point is printed in %f, %e, and %E conversions even if no
1957 numbers are printed after it; and trailing zeroes are not omitted in 1902 numbers are printed after it; and trailing zeroes are not omitted in
1958 %g and %G conversions. 1903 %g and %G conversions.
1959 1904
1960 Use %% to put a single % into the output. 1905 Use %% to put a single % into the output.
1961 */ ) 1906 */
1962 (nargs, args) 1907 (int nargs, Lisp_Object *args))
1963 int nargs;
1964 Lisp_Object *args;
1965 { 1908 {
1966 /* It should not be necessary to GCPRO ARGS, because 1909 /* It should not be necessary to GCPRO ARGS, because
1967 the caller in the interpreter should take care of that. */ 1910 the caller in the interpreter should take care of that. */
1968 1911
1969 CHECK_STRING (args[0]); 1912 CHECK_STRING (args[0]);
1970 return emacs_doprnt_string_lisp (0, args[0], 0, nargs - 1, args + 1); 1913 return emacs_doprnt_string_lisp (0, args[0], 0, nargs - 1, args + 1);
1971 } 1914 }
1972 1915
1973 1916
1974 DEFUN ("char-equal", Fchar_equal, Schar_equal, 2, 3, 0 /* 1917 DEFUN ("char-equal", Fchar_equal, 2, 3, 0, /*
1975 Return t if two characters match, optionally ignoring case. 1918 Return t if two characters match, optionally ignoring case.
1976 Both arguments must be characters (i.e. integers). 1919 Both arguments must be characters (i.e. integers).
1977 Case is ignored if `case-fold-search' is non-nil in BUFFER. 1920 Case is ignored if `case-fold-search' is non-nil in BUFFER.
1978 If BUFFER is nil, the current buffer is assumed. 1921 If BUFFER is nil, the current buffer is assumed.
1979 */ ) 1922 */
1980 (c1, c2, buffer) 1923 (c1, c2, buffer))
1981 Lisp_Object c1, c2, buffer;
1982 { 1924 {
1983 Emchar x1, x2; 1925 Emchar x1, x2;
1984 struct buffer *buf = decode_buffer (buffer, 1); 1926 struct buffer *buf = decode_buffer (buffer, 1);
1985 1927
1986 CHECK_CHAR_COERCE_INT (c1); 1928 CHECK_CHAR_COERCE_INT (c1);
2058 } 2000 }
2059 } 2001 }
2060 2002
2061 #endif 2003 #endif
2062 2004
2063 DEFUN ("transpose-regions", Ftranspose_regions, Stranspose_regions, 4, 5, 0 /* 2005 DEFUN ("transpose-regions", Ftranspose_regions, 4, 5, 0, /*
2064 Transpose region START1 to END1 with START2 to END2. 2006 Transpose region START1 to END1 with START2 to END2.
2065 The regions may not be overlapping, because the size of the buffer is 2007 The regions may not be overlapping, because the size of the buffer is
2066 never changed in a transposition. 2008 never changed in a transposition.
2067 2009
2068 Optional fifth arg LEAVE_MARKERS, if non-nil, means don't transpose 2010 Optional fifth arg LEAVE_MARKERS, if non-nil, means don't transpose
2069 any markers that happen to be located in the regions. (#### BUG: currently 2011 any markers that happen to be located in the regions. (#### BUG: currently
2070 this function always acts as if LEAVE_MARKERS is non-nil.) 2012 this function always acts as if LEAVE_MARKERS is non-nil.)
2071 2013
2072 Transposing beyond buffer boundaries is an error. 2014 Transposing beyond buffer boundaries is an error.
2073 */ ) 2015 */
2074 (startr1, endr1, startr2, endr2, leave_markers) 2016 (startr1, endr1, startr2, endr2, leave_markers))
2075 Lisp_Object startr1, endr1, startr2, endr2, leave_markers;
2076 { 2017 {
2077 Bufpos start1, end1, start2, end2; 2018 Bufpos start1, end1, start2, end2;
2078 Charcount len1, len2; 2019 Charcount len1, len2;
2079 Lisp_Object string1, string2; 2020 Lisp_Object string1, string2;
2080 struct buffer *buf = current_buffer; 2021 struct buffer *buf = current_buffer;
2117 defsymbol (&Qmark, "mark"); 2058 defsymbol (&Qmark, "mark");
2118 defsymbol (&Qregion_beginning, "region-beginning"); 2059 defsymbol (&Qregion_beginning, "region-beginning");
2119 defsymbol (&Qregion_end, "region-end"); 2060 defsymbol (&Qregion_end, "region-end");
2120 defsymbol (&Qformat, "format"); 2061 defsymbol (&Qformat, "format");
2121 2062
2122 defsubr (&Schar_equal); 2063 DEFSUBR (Fchar_equal);
2123 defsubr (&Sgoto_char); 2064 DEFSUBR (Fgoto_char);
2124 defsubr (&Sstring_to_char); 2065 DEFSUBR (Fstring_to_char);
2125 defsubr (&Schar_to_string); 2066 DEFSUBR (Fchar_to_string);
2126 defsubr (&Sbuffer_substring); 2067 DEFSUBR (Fbuffer_substring);
2127 2068
2128 defsubr (&Spoint_marker); 2069 DEFSUBR (Fpoint_marker);
2129 defsubr (&Smark_marker); 2070 DEFSUBR (Fmark_marker);
2130 defsubr (&Spoint); 2071 DEFSUBR (Fpoint);
2131 defsubr (&Sregion_beginning); 2072 DEFSUBR (Fregion_beginning);
2132 defsubr (&Sregion_end); 2073 DEFSUBR (Fregion_end);
2133 defsubr (&Ssave_excursion); 2074 DEFSUBR (Fsave_excursion);
2134 2075
2135 defsubr (&Sbufsize); 2076 DEFSUBR (Fbufsize);
2136 defsubr (&Spoint_max); 2077 DEFSUBR (Fpoint_max);
2137 defsubr (&Spoint_min); 2078 DEFSUBR (Fpoint_min);
2138 defsubr (&Spoint_min_marker); 2079 DEFSUBR (Fpoint_min_marker);
2139 defsubr (&Spoint_max_marker); 2080 DEFSUBR (Fpoint_max_marker);
2140 2081
2141 defsubr (&Sbobp); 2082 DEFSUBR (Fbobp);
2142 defsubr (&Seobp); 2083 DEFSUBR (Feobp);
2143 defsubr (&Sbolp); 2084 DEFSUBR (Fbolp);
2144 defsubr (&Seolp); 2085 DEFSUBR (Feolp);
2145 defsubr (&Sfollowing_char); 2086 DEFSUBR (Ffollowing_char);
2146 defsubr (&Spreceding_char); 2087 DEFSUBR (Fpreceding_char);
2147 defsubr (&Schar_after); 2088 DEFSUBR (Fchar_after);
2148 defsubr (&Sinsert); 2089 DEFSUBR (Finsert);
2149 defsubr (&Sinsert_string); 2090 DEFSUBR (Finsert_string);
2150 defsubr (&Sinsert_before_markers); 2091 DEFSUBR (Finsert_before_markers);
2151 defsubr (&Sinsert_char); 2092 DEFSUBR (Finsert_char);
2152 2093
2153 defsubr (&Suser_login_name); 2094 DEFSUBR (Fuser_login_name);
2154 defsubr (&Suser_real_login_name); 2095 DEFSUBR (Fuser_real_login_name);
2155 defsubr (&Suser_uid); 2096 DEFSUBR (Fuser_uid);
2156 defsubr (&Suser_real_uid); 2097 DEFSUBR (Fuser_real_uid);
2157 defsubr (&Suser_full_name); 2098 DEFSUBR (Fuser_full_name);
2158 defsubr (&Semacs_pid); 2099 DEFSUBR (Femacs_pid);
2159 defsubr (&Scurrent_time); 2100 DEFSUBR (Fcurrent_time);
2160 defsubr (&Scurrent_process_time); 2101 DEFSUBR (Fcurrent_process_time);
2161 defsubr (&Sformat_time_string); 2102 DEFSUBR (Fformat_time_string);
2162 defsubr (&Sdecode_time); 2103 DEFSUBR (Fdecode_time);
2163 defsubr (&Sencode_time); 2104 DEFSUBR (Fencode_time);
2164 defsubr (&Scurrent_time_string); 2105 DEFSUBR (Fcurrent_time_string);
2165 defsubr (&Scurrent_time_zone); 2106 DEFSUBR (Fcurrent_time_zone);
2166 defsubr (&Sset_time_zone_rule); 2107 DEFSUBR (Fset_time_zone_rule);
2167 defsubr (&Ssystem_name); 2108 DEFSUBR (Fsystem_name);
2168 defsubr (&Sformat); 2109 DEFSUBR (Fformat);
2169 2110
2170 defsubr (&Sinsert_buffer_substring); 2111 DEFSUBR (Finsert_buffer_substring);
2171 defsubr (&Scompare_buffer_substrings); 2112 DEFSUBR (Fcompare_buffer_substrings);
2172 defsubr (&Ssubst_char_in_region); 2113 DEFSUBR (Fsubst_char_in_region);
2173 defsubr (&Stranslate_region); 2114 DEFSUBR (Ftranslate_region);
2174 defsubr (&Sdelete_region); 2115 DEFSUBR (Fdelete_region);
2175 defsubr (&Swiden); 2116 DEFSUBR (Fwiden);
2176 defsubr (&Snarrow_to_region); 2117 DEFSUBR (Fnarrow_to_region);
2177 defsubr (&Ssave_restriction); 2118 DEFSUBR (Fsave_restriction);
2178 defsubr (&Stranspose_regions); 2119 DEFSUBR (Ftranspose_regions);
2179 2120
2180 defsymbol (&Qzmacs_update_region, "zmacs-update-region"); 2121 defsymbol (&Qzmacs_update_region, "zmacs-update-region");
2181 defsymbol (&Qzmacs_deactivate_region, "zmacs-deactivate-region"); 2122 defsymbol (&Qzmacs_deactivate_region, "zmacs-deactivate-region");
2182 defsymbol (&Qzmacs_region_buffer, "zmacs-region-buffer"); 2123 defsymbol (&Qzmacs_region_buffer, "zmacs-region-buffer");
2183 } 2124 }