comparison src/buffer.c @ 9933:d3f22955b872

(Frename_buffer): Rename arg NAME to NEWNAME.
author Richard M. Stallman <rms@gnu.org>
date Tue, 15 Nov 1994 14:01:12 +0000
parents f653d8aac66a
children 686916b836b4
comparison
equal deleted inserted replaced
9932:c981c199462f 9933:d3f22955b872
566 If UNIQUE is non-nil, come up with a new name using\n\ 566 If UNIQUE is non-nil, come up with a new name using\n\
567 `generate-new-buffer-name'.\n\ 567 `generate-new-buffer-name'.\n\
568 Interactively, you can set UNIQUE with a prefix argument.\n\ 568 Interactively, you can set UNIQUE with a prefix argument.\n\
569 We return the name we actually gave the buffer.\n\ 569 We return the name we actually gave the buffer.\n\
570 This does not change the name of the visited file (if any).") 570 This does not change the name of the visited file (if any).")
571 (name, unique) 571 (newname, unique)
572 register Lisp_Object name, unique; 572 register Lisp_Object newname, unique;
573 { 573 {
574 register Lisp_Object tem, buf; 574 register Lisp_Object tem, buf;
575 575
576 CHECK_STRING (name, 0); 576 CHECK_STRING (newname, 0);
577 577
578 if (XSTRING (name)->size == 0) 578 if (XSTRING (newname)->size == 0)
579 error ("Empty string is invalid as a buffer name"); 579 error ("Empty string is invalid as a buffer name");
580 580
581 tem = Fget_buffer (name); 581 tem = Fget_buffer (newname);
582 /* Don't short-circuit if UNIQUE is t. That is a useful way to rename 582 /* Don't short-circuit if UNIQUE is t. That is a useful way to rename
583 the buffer automatically so you can create another with the original name. 583 the buffer automatically so you can create another with the original name.
584 It makes UNIQUE equivalent to 584 It makes UNIQUE equivalent to
585 (rename-buffer (generate-new-buffer-name NAME)). */ 585 (rename-buffer (generate-new-buffer-name NEWNAME)). */
586 if (NILP (unique) && XBUFFER (tem) == current_buffer) 586 if (NILP (unique) && XBUFFER (tem) == current_buffer)
587 return current_buffer->name; 587 return current_buffer->newname;
588 if (!NILP (tem)) 588 if (!NILP (tem))
589 { 589 {
590 if (!NILP (unique)) 590 if (!NILP (unique))
591 name = Fgenerate_new_buffer_name (name, current_buffer->name); 591 newname = Fgenerate_new_buffer_name (newname, current_buffer->name);
592 else 592 else
593 error ("Buffer name \"%s\" is in use", XSTRING (name)->data); 593 error ("Buffer name `%s' is in use", XSTRING (newname)->data);
594 } 594 }
595 595
596 current_buffer->name = name; 596 current_buffer->name = newname;
597 597
598 /* Catch redisplay's attention. Unless we do this, the mode lines for 598 /* Catch redisplay's attention. Unless we do this, the mode lines for
599 any windows displaying current_buffer will stay unchanged. */ 599 any windows displaying current_buffer will stay unchanged. */
600 update_mode_lines++; 600 update_mode_lines++;
601 601
602 XSETBUFFER (buf, current_buffer); 602 XSETBUFFER (buf, current_buffer);
603 Fsetcar (Frassq (buf, Vbuffer_alist), name); 603 Fsetcar (Frassq (buf, Vbuffer_alist), newname);
604 if (NILP (current_buffer->filename) 604 if (NILP (current_buffer->filename)
605 && !NILP (current_buffer->auto_save_file_name)) 605 && !NILP (current_buffer->auto_save_file_name))
606 call0 (intern ("rename-auto-save-file")); 606 call0 (intern ("rename-auto-save-file"));
607 /* refetch since that last call may have done GC */ 607 /* refetch since that last call may have done GC */
608 return current_buffer->name; 608 return current_buffer->newname;
609 } 609 }
610 610
611 DEFUN ("other-buffer", Fother_buffer, Sother_buffer, 0, 2, 0, 611 DEFUN ("other-buffer", Fother_buffer, Sother_buffer, 0, 2, 0,
612 "Return most recently selected buffer other than BUFFER.\n\ 612 "Return most recently selected buffer other than BUFFER.\n\
613 Buffers not visible in windows are preferred to visible buffers,\n\ 613 Buffers not visible in windows are preferred to visible buffers,\n\