diff options
Diffstat (limited to 'src/buffer.c')
| -rw-r--r-- | src/buffer.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/buffer.c b/src/buffer.c index 551898163f1..55598e4dd1b 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -331,13 +331,16 @@ reset_buffer_local_variables (b) | |||
| 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; |
| @@ -354,6 +357,9 @@ until an unused name is found, and then return that name.") | |||
| 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; |
| @@ -536,7 +542,7 @@ This does not change the name of the visited file (if any).") | |||
| 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 | } |