Mercurial > emacs
comparison src/buffer.c @ 99080:ccaba4c89996
(Fget_buffer_create): Rename arg to buffer_or_name. Reword doc-string.
(Fbury_buffer): In doc-string say what happens to the buffer's window.
| author | Martin Rudalics <rudalics@gmx.at> |
|---|---|
| date | Thu, 23 Oct 2008 09:01:50 +0000 |
| parents | 7ccc521ae6b1 |
| children | df0a1afd03b2 |
comparison
equal
deleted
inserted
replaced
| 99079:ffe8b1e92732 | 99080:ccaba4c89996 |
|---|---|
| 332 | 332 |
| 333 /* Incremented for each buffer created, to assign the buffer number. */ | 333 /* Incremented for each buffer created, to assign the buffer number. */ |
| 334 int buffer_count; | 334 int buffer_count; |
| 335 | 335 |
| 336 DEFUN ("get-buffer-create", Fget_buffer_create, Sget_buffer_create, 1, 1, 0, | 336 DEFUN ("get-buffer-create", Fget_buffer_create, Sget_buffer_create, 1, 1, 0, |
| 337 doc: /* Return the buffer named NAME, or create such a buffer and return it. | 337 doc: /* Return the buffer specified by BUFFER-OR-NAME, creating a new one if needed. |
| 338 A new buffer is created if there is no live buffer named NAME. | 338 If BUFFER-OR-NAME is a string and a live buffer with that name exists, |
| 339 If NAME starts with a space, the new buffer does not keep undo information. | 339 return that buffer. If no such buffer exists, create a new buffer with |
| 340 If NAME is a buffer instead of a string, then it is the value returned. | 340 that name and return it. If BUFFER-OR-NAME starts with a space, the new |
| 341 The value is never nil. */) | 341 buffer does not keep undo information. |
| 342 (name) | 342 |
| 343 register Lisp_Object name; | 343 If BUFFER-OR-NAME is a buffer instead of a string, return it as given, |
| 344 { | 344 even if it is dead. The return value is never nil. */) |
| 345 register Lisp_Object buf; | 345 (buffer_or_name) |
| 346 register Lisp_Object buffer_or_name; | |
| 347 { | |
| 348 register Lisp_Object buffer, name; | |
| 346 register struct buffer *b; | 349 register struct buffer *b; |
| 347 | 350 |
| 348 buf = Fget_buffer (name); | 351 buffer = Fget_buffer (buffer_or_name); |
| 349 if (!NILP (buf)) | 352 if (!NILP (buffer)) |
| 350 return buf; | 353 return buffer; |
| 351 | 354 |
| 352 if (SCHARS (name) == 0) | 355 if (SCHARS (buffer_or_name) == 0) |
| 353 error ("Empty string for buffer name is not allowed"); | 356 error ("Empty string for buffer name is not allowed"); |
| 354 | 357 |
| 355 b = allocate_buffer (); | 358 b = allocate_buffer (); |
| 356 | 359 |
| 357 /* An ordinary buffer uses its own struct buffer_text. */ | 360 /* An ordinary buffer uses its own struct buffer_text. */ |
| 401 to handle BEGV and ZV. */ | 404 to handle BEGV and ZV. */ |
| 402 b->pt_marker = Qnil; | 405 b->pt_marker = Qnil; |
| 403 b->begv_marker = Qnil; | 406 b->begv_marker = Qnil; |
| 404 b->zv_marker = Qnil; | 407 b->zv_marker = Qnil; |
| 405 | 408 |
| 406 name = Fcopy_sequence (name); | 409 name = Fcopy_sequence (buffer_or_name); |
| 407 STRING_SET_INTERVALS (name, NULL_INTERVAL); | 410 STRING_SET_INTERVALS (name, NULL_INTERVAL); |
| 408 b->name = name; | 411 b->name = name; |
| 409 | 412 |
| 410 b->undo_list = (SREF (name, 0) != ' ') ? Qnil : Qt; | 413 b->undo_list = (SREF (name, 0) != ' ') ? Qnil : Qt; |
| 411 | 414 |
| 415 b->mark = Fmake_marker (); | 418 b->mark = Fmake_marker (); |
| 416 BUF_MARKERS (b) = NULL; | 419 BUF_MARKERS (b) = NULL; |
| 417 b->name = name; | 420 b->name = name; |
| 418 | 421 |
| 419 /* Put this in the alist of all live buffers. */ | 422 /* Put this in the alist of all live buffers. */ |
| 420 XSETBUFFER (buf, b); | 423 XSETBUFFER (buffer, b); |
| 421 Vbuffer_alist = nconc2 (Vbuffer_alist, Fcons (Fcons (name, buf), Qnil)); | 424 Vbuffer_alist = nconc2 (Vbuffer_alist, Fcons (Fcons (name, buffer), Qnil)); |
| 422 | 425 |
| 423 /* An error in calling the function here (should someone redefine it) | 426 /* An error in calling the function here (should someone redefine it) |
| 424 can lead to infinite regress until you run out of stack. rms | 427 can lead to infinite regress until you run out of stack. rms |
| 425 says that's not worth protecting against. */ | 428 says that's not worth protecting against. */ |
| 426 if (!NILP (Ffboundp (Qucs_set_table_for_input))) | 429 if (!NILP (Ffboundp (Qucs_set_table_for_input))) |
| 427 /* buf is on buffer-alist, so no gcpro. */ | 430 /* buffer is on buffer-alist, so no gcpro. */ |
| 428 call1 (Qucs_set_table_for_input, buf); | 431 call1 (Qucs_set_table_for_input, buffer); |
| 429 | 432 |
| 430 return buf; | 433 return buffer; |
| 431 } | 434 } |
| 432 | 435 |
| 433 | 436 |
| 434 /* Return a list of overlays which is a copy of the overlay list | 437 /* Return a list of overlays which is a copy of the overlay list |
| 435 LIST, but for buffer B. */ | 438 LIST, but for buffer B. */ |
| 2045 thus, the least likely buffer for \\[switch-to-buffer] to select by | 2048 thus, the least likely buffer for \\[switch-to-buffer] to select by |
| 2046 default. | 2049 default. |
| 2047 | 2050 |
| 2048 The argument may be a buffer name or an actual buffer object. If | 2051 The argument may be a buffer name or an actual buffer object. If |
| 2049 BUFFER-OR-NAME is nil or omitted, bury the current buffer and remove it | 2052 BUFFER-OR-NAME is nil or omitted, bury the current buffer and remove it |
| 2050 from the selected window if it is displayed there. */) | 2053 from the selected window if it is displayed there. If the selected |
| 2054 window is dedicated to its buffer, delete that window if there are other | |
| 2055 windows on the same frame. If the selected window is the only window on | |
| 2056 its frame, iconify that frame. */) | |
| 2051 (buffer_or_name) | 2057 (buffer_or_name) |
| 2052 register Lisp_Object buffer_or_name; | 2058 register Lisp_Object buffer_or_name; |
| 2053 { | 2059 { |
| 2054 Lisp_Object buffer; | 2060 Lisp_Object buffer; |
| 2055 | 2061 |
