Mercurial > emacs
comparison src/buffer.c @ 91204:53108e6cea98
Merge from emacs--devo--0
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-294
| author | Miles Bader <miles@gnu.org> |
|---|---|
| date | Thu, 06 Dec 2007 09:51:45 +0000 |
| parents | 1251cabc40b7 13041217da4b |
| children | 2fcaae6177a5 |
comparison
equal
deleted
inserted
replaced
| 91203:db40129142b2 | 91204:53108e6cea98 |
|---|---|
| 96 | 96 |
| 97 DECL_ALIGN (struct buffer, buffer_local_symbols); | 97 DECL_ALIGN (struct buffer, buffer_local_symbols); |
| 98 | 98 |
| 99 /* A Lisp_Object pointer to the above, used for staticpro */ | 99 /* A Lisp_Object pointer to the above, used for staticpro */ |
| 100 static Lisp_Object Vbuffer_local_symbols; | 100 static Lisp_Object Vbuffer_local_symbols; |
| 101 | |
| 102 /* This structure holds the required types for the values in the | |
| 103 buffer-local slots. If a slot contains Qnil, then the | |
| 104 corresponding buffer slot may contain a value of any type. If a | |
| 105 slot contains an integer, then prospective values' tags must be | |
| 106 equal to that integer (except nil is always allowed). | |
| 107 When a tag does not match, the function | |
| 108 buffer_slot_type_mismatch will signal an error. | |
| 109 | |
| 110 If a slot here contains -1, the corresponding variable is read-only. */ | |
| 111 struct buffer buffer_local_types; | |
| 112 | 101 |
| 113 /* Flags indicating which built-in buffer-local variables | 102 /* Flags indicating which built-in buffer-local variables |
| 114 are permanent locals. */ | 103 are permanent locals. */ |
| 115 static char buffer_permanent_local_flags[MAX_PER_BUFFER_VARS]; | 104 static char buffer_permanent_local_flags[MAX_PER_BUFFER_VARS]; |
| 116 | 105 |
| 358 return buf; | 347 return buf; |
| 359 | 348 |
| 360 if (SCHARS (name) == 0) | 349 if (SCHARS (name) == 0) |
| 361 error ("Empty string for buffer name is not allowed"); | 350 error ("Empty string for buffer name is not allowed"); |
| 362 | 351 |
| 363 b = (struct buffer *) allocate_buffer (); | 352 b = allocate_buffer (); |
| 364 | 353 |
| 365 /* An ordinary buffer uses its own struct buffer_text. */ | 354 /* An ordinary buffer uses its own struct buffer_text. */ |
| 366 b->text = &b->own_text; | 355 b->text = &b->own_text; |
| 367 b->base_buffer = 0; | 356 b->base_buffer = 0; |
| 368 | 357 |
| 559 error ("Base buffer has been killed"); | 548 error ("Base buffer has been killed"); |
| 560 | 549 |
| 561 if (SCHARS (name) == 0) | 550 if (SCHARS (name) == 0) |
| 562 error ("Empty string for buffer name is not allowed"); | 551 error ("Empty string for buffer name is not allowed"); |
| 563 | 552 |
| 564 b = (struct buffer *) allocate_buffer (); | 553 b = allocate_buffer (); |
| 565 | 554 |
| 566 b->base_buffer = (XBUFFER (base_buffer)->base_buffer | 555 b->base_buffer = (XBUFFER (base_buffer)->base_buffer |
| 567 ? XBUFFER (base_buffer)->base_buffer | 556 ? XBUFFER (base_buffer)->base_buffer |
| 568 : XBUFFER (base_buffer)); | 557 : XBUFFER (base_buffer)); |
| 569 | 558 |
| 894 | 883 |
| 895 CHECK_SYMBOL (variable); | 884 CHECK_SYMBOL (variable); |
| 896 CHECK_BUFFER (buffer); | 885 CHECK_BUFFER (buffer); |
| 897 buf = XBUFFER (buffer); | 886 buf = XBUFFER (buffer); |
| 898 | 887 |
| 899 if (SYMBOLP (variable)) | 888 variable = indirect_variable (variable); |
| 900 variable = indirect_variable (variable); | |
| 901 | 889 |
| 902 /* Look in local_var_list */ | 890 /* Look in local_var_list */ |
| 903 result = Fassoc (variable, buf->local_var_alist); | 891 result = Fassoc (variable, buf->local_var_alist); |
| 904 if (NILP (result)) | 892 if (NILP (result)) |
| 905 { | 893 { |
| 2532 { | 2520 { |
| 2533 sym = XCAR (XCAR (alist)); | 2521 sym = XCAR (XCAR (alist)); |
| 2534 | 2522 |
| 2535 /* Need not do anything if some other buffer's binding is now encached. */ | 2523 /* Need not do anything if some other buffer's binding is now encached. */ |
| 2536 tem = XBUFFER_LOCAL_VALUE (SYMBOL_VALUE (sym))->buffer; | 2524 tem = XBUFFER_LOCAL_VALUE (SYMBOL_VALUE (sym))->buffer; |
| 2537 if (BUFFERP (tem) && XBUFFER (tem) == current_buffer) | 2525 if (EQ (tem, buffer)) |
| 2538 { | 2526 { |
| 2539 /* Symbol is set up for this buffer's old local value. | 2527 /* Symbol is set up for this buffer's old local value: |
| 2540 Set it up for the current buffer with the default value. */ | 2528 swap it out! */ |
| 2541 | 2529 swap_in_global_binding (sym); |
| 2542 tem = XBUFFER_LOCAL_VALUE (SYMBOL_VALUE (sym))->cdr; | |
| 2543 /* Store the symbol's current value into the alist entry | |
| 2544 it is currently set up for. This is so that, if the | |
| 2545 local is marked permanent, and we make it local again | |
| 2546 later in Fkill_all_local_variables, we don't lose the value. */ | |
| 2547 XSETCDR (XCAR (tem), | |
| 2548 do_symval_forwarding (XBUFFER_LOCAL_VALUE (SYMBOL_VALUE (sym))->realvalue)); | |
| 2549 /* Switch to the symbol's default-value alist entry. */ | |
| 2550 XSETCAR (tem, tem); | |
| 2551 /* Mark it as current for buffer B. */ | |
| 2552 XBUFFER_LOCAL_VALUE (SYMBOL_VALUE (sym))->buffer = buffer; | |
| 2553 /* Store the current value into any forwarding in the symbol. */ | |
| 2554 store_symval_forwarding (sym, | |
| 2555 XBUFFER_LOCAL_VALUE (SYMBOL_VALUE (sym))->realvalue, | |
| 2556 XCDR (tem), NULL); | |
| 2557 } | 2530 } |
| 2558 } | 2531 } |
| 2559 } | 2532 } |
| 2560 | 2533 |
| 2561 /* Find all the overlays in the current buffer that contain position POS. | 2534 /* Find all the overlays in the current buffer that contain position POS. |
| 4432 | 4405 |
| 4433 /* Somebody has tried to store a value with an unacceptable type | 4406 /* Somebody has tried to store a value with an unacceptable type |
| 4434 in the slot with offset OFFSET. */ | 4407 in the slot with offset OFFSET. */ |
| 4435 | 4408 |
| 4436 void | 4409 void |
| 4437 buffer_slot_type_mismatch (offset) | 4410 buffer_slot_type_mismatch (sym, type) |
| 4438 int offset; | 4411 Lisp_Object sym; |
| 4439 { | 4412 int type; |
| 4440 Lisp_Object sym; | 4413 { |
| 4441 char *type_name; | 4414 char *type_name; |
| 4442 | 4415 |
| 4443 switch (XINT (PER_BUFFER_TYPE (offset))) | 4416 switch (type) |
| 4444 { | 4417 { |
| 4445 case Lisp_Int: | 4418 case Lisp_Int: |
| 4446 type_name = "integers"; | 4419 type_name = "integers"; |
| 4447 break; | 4420 break; |
| 4448 | 4421 |
| 4456 | 4429 |
| 4457 default: | 4430 default: |
| 4458 abort (); | 4431 abort (); |
| 4459 } | 4432 } |
| 4460 | 4433 |
| 4461 sym = PER_BUFFER_SYMBOL (offset); | |
| 4462 error ("Only %s should be stored in the buffer-local variable %s", | 4434 error ("Only %s should be stored in the buffer-local variable %s", |
| 4463 type_name, SDATA (SYMBOL_NAME (sym))); | 4435 type_name, SDATA (SYMBOL_NAME (sym))); |
| 4464 } | 4436 } |
| 4465 | 4437 |
| 4466 | 4438 |
| 5304 val = allocate_misc (); | 5276 val = allocate_misc (); |
| 5305 offset = (char *)address - (char *)current_buffer; | 5277 offset = (char *)address - (char *)current_buffer; |
| 5306 | 5278 |
| 5307 XMISCTYPE (val) = Lisp_Misc_Buffer_Objfwd; | 5279 XMISCTYPE (val) = Lisp_Misc_Buffer_Objfwd; |
| 5308 XBUFFER_OBJFWD (val)->offset = offset; | 5280 XBUFFER_OBJFWD (val)->offset = offset; |
| 5281 XBUFFER_OBJFWD (val)->slottype = type; | |
| 5309 SET_SYMBOL_VALUE (sym, val); | 5282 SET_SYMBOL_VALUE (sym, val); |
| 5310 PER_BUFFER_SYMBOL (offset) = sym; | 5283 PER_BUFFER_SYMBOL (offset) = sym; |
| 5311 PER_BUFFER_TYPE (offset) = type; | |
| 5312 | 5284 |
| 5313 if (PER_BUFFER_IDX (offset) == 0) | 5285 if (PER_BUFFER_IDX (offset) == 0) |
| 5314 /* Did a DEFVAR_PER_BUFFER without initializing the corresponding | 5286 /* Did a DEFVAR_PER_BUFFER without initializing the corresponding |
| 5315 slot of buffer_local_flags */ | 5287 slot of buffer_local_flags */ |
| 5316 abort (); | 5288 abort (); |
