comparison src/buffer.c @ 3226:bc4beddaf2c7

(Fgenerate_new_buffer_name): New arg IGNORE. (Frename_buffer): Pass new arg.
author Richard M. Stallman <rms@gnu.org>
date Fri, 28 May 1993 23:58:29 +0000
parents a3007f83650c
children f873e6b9af52
comparison
equal deleted inserted replaced
3225:1544ad5c9f99 3226:bc4beddaf2c7
329 /* We split this away from generate-new-buffer, because rename-buffer 329 /* We split this away from generate-new-buffer, because rename-buffer
330 and set-visited-file-name ought to be able to use this to really 330 and set-visited-file-name ought to be able to use this to really
331 rename the buffer properly. */ 331 rename the buffer properly. */
332 332
333 DEFUN ("generate-new-buffer-name", Fgenerate_new_buffer_name, Sgenerate_new_buffer_name, 333 DEFUN ("generate-new-buffer-name", Fgenerate_new_buffer_name, Sgenerate_new_buffer_name,
334 1, 1, 0, 334 1, 2, 0,
335 "Return a string that is the name of no existing buffer based on NAME.\n\ 335 "Return a string that is the name of no existing buffer based on NAME.\n\
336 If there is no live buffer named NAME, then return NAME.\n\ 336 If there is no live buffer named NAME, then return NAME.\n\
337 Otherwise modify name by appending `<NUMBER>', incrementing NUMBER\n\ 337 Otherwise modify name by appending `<NUMBER>', incrementing NUMBER\n\
338 until an unused name is found, and then return that name.") 338 until an unused name is found, and then return that name.\n\
339 (name) 339 Optional second argument ignore specifies a name that is okay to use\n\
340 register Lisp_Object name; 340 \(if it is in the sequence to be tried)\n\
341 even if a buffer with that name exists.
342 (name, ignore)
343 register Lisp_Object name, ignore;
341 { 344 {
342 register Lisp_Object gentemp, tem; 345 register Lisp_Object gentemp, tem;
343 int count; 346 int count;
344 char number[10]; 347 char number[10];
345 348
352 count = 1; 355 count = 1;
353 while (1) 356 while (1)
354 { 357 {
355 sprintf (number, "<%d>", ++count); 358 sprintf (number, "<%d>", ++count);
356 gentemp = concat2 (name, build_string (number)); 359 gentemp = concat2 (name, build_string (number));
360 tem = Fstring_equal (name, ignore);
361 if (!NILP (tem))
362 return gentemp;
357 tem = Fget_buffer (gentemp); 363 tem = Fget_buffer (gentemp);
358 if (NILP (tem)) 364 if (NILP (tem))
359 return gentemp; 365 return gentemp;
360 } 366 }
361 } 367 }
534 if (XBUFFER (tem) == current_buffer) 540 if (XBUFFER (tem) == current_buffer)
535 return current_buffer->name; 541 return current_buffer->name;
536 if (!NILP (tem)) 542 if (!NILP (tem))
537 { 543 {
538 if (!NILP (unique)) 544 if (!NILP (unique))
539 name = Fgenerate_new_buffer_name (name); 545 name = Fgenerate_new_buffer_name (name, current_buffer->name);
540 else 546 else
541 error ("Buffer name \"%s\" is in use", XSTRING (name)->data); 547 error ("Buffer name \"%s\" is in use", XSTRING (name)->data);
542 } 548 }
543 549
544 current_buffer->name = name; 550 current_buffer->name = name;