Mercurial > emacs
comparison src/buffer.c @ 15776:6018e01d4466
(buffer_permanent_local_flags): New variable.
(init_buffer_once): Initialize it.
(reset_buffer_local_variables): New argument PERMANENT_TOO.
Callers changed. Now declared static.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Tue, 23 Jul 1996 22:36:11 +0000 |
parents | fc00cd5ad30f |
children | f2d0e8928d57 |
comparison
equal
deleted
inserted
replaced
15775:2f589e0f2c7a | 15776:6018e01d4466 |
---|---|
97 slot contains an integer, then prospective values' tags must be | 97 slot contains an integer, then prospective values' tags must be |
98 equal to that integer. When a tag does not match, the function | 98 equal to that integer. When a tag does not match, the function |
99 buffer_slot_type_mismatch will signal an error. */ | 99 buffer_slot_type_mismatch will signal an error. */ |
100 struct buffer buffer_local_types; | 100 struct buffer buffer_local_types; |
101 | 101 |
102 /* Flags indicating which built-in buffer-local variables | |
103 are permanent locals. */ | |
104 static int buffer_permanent_local_flags; | |
105 | |
102 Lisp_Object Fset_buffer (); | 106 Lisp_Object Fset_buffer (); |
103 void set_buffer_internal (); | 107 void set_buffer_internal (); |
104 void set_buffer_internal_1 (); | 108 void set_buffer_internal_1 (); |
105 static void call_overlay_mod_hooks (); | 109 static void call_overlay_mod_hooks (); |
106 static void swap_out_buffer_local_variables (); | 110 static void swap_out_buffer_local_variables (); |
111 static void reset_buffer_local_variables (); | |
107 | 112 |
108 /* Alist of all buffer names vs the buffers. */ | 113 /* Alist of all buffer names vs the buffers. */ |
109 /* This used to be a variable, but is no longer, | 114 /* This used to be a variable, but is no longer, |
110 to prevent lossage due to user rplac'ing this alist or its elements. */ | 115 to prevent lossage due to user rplac'ing this alist or its elements. */ |
111 Lisp_Object Vbuffer_alist; | 116 Lisp_Object Vbuffer_alist; |
333 b->undo_list = Qnil; | 338 b->undo_list = Qnil; |
334 else | 339 else |
335 b->undo_list = Qt; | 340 b->undo_list = Qt; |
336 | 341 |
337 reset_buffer (b); | 342 reset_buffer (b); |
338 reset_buffer_local_variables (b); | 343 reset_buffer_local_variables (b, 1); |
339 | 344 |
340 /* Put this in the alist of all live buffers. */ | 345 /* Put this in the alist of all live buffers. */ |
341 XSETBUFFER (buf, b); | 346 XSETBUFFER (buf, b); |
342 Vbuffer_alist = nconc2 (Vbuffer_alist, Fcons (Fcons (name, buf), Qnil)); | 347 Vbuffer_alist = nconc2 (Vbuffer_alist, Fcons (Fcons (name, buf), Qnil)); |
343 | 348 |
397 name = Fcopy_sequence (name); | 402 name = Fcopy_sequence (name); |
398 INITIALIZE_INTERVAL (XSTRING (name), NULL_INTERVAL); | 403 INITIALIZE_INTERVAL (XSTRING (name), NULL_INTERVAL); |
399 b->name = name; | 404 b->name = name; |
400 | 405 |
401 reset_buffer (b); | 406 reset_buffer (b); |
402 reset_buffer_local_variables (b); | 407 reset_buffer_local_variables (b, 1); |
403 | 408 |
404 /* Put this in the alist of all live buffers. */ | 409 /* Put this in the alist of all live buffers. */ |
405 XSETBUFFER (buf, b); | 410 XSETBUFFER (buf, b); |
406 Vbuffer_alist = nconc2 (Vbuffer_alist, Fcons (Fcons (name, buf), Qnil)); | 411 Vbuffer_alist = nconc2 (Vbuffer_alist, Fcons (Fcons (name, buf), Qnil)); |
407 | 412 |
472 } | 477 } |
473 | 478 |
474 /* Reset buffer B's local variables info. | 479 /* Reset buffer B's local variables info. |
475 Don't use this on a buffer that has already been in use; | 480 Don't use this on a buffer that has already been in use; |
476 it does not treat permanent locals consistently. | 481 it does not treat permanent locals consistently. |
477 Instead, use Fkill_all_local_variables. */ | 482 Instead, use Fkill_all_local_variables. |
478 | 483 |
479 reset_buffer_local_variables (b) | 484 If PERMANENT_TOO is 1, then we reset permanent built-in |
485 buffer-local variables. If PERMANENT_TOO is 0, | |
486 we preserve those. */ | |
487 | |
488 static void | |
489 reset_buffer_local_variables (b, permanent_too) | |
480 register struct buffer *b; | 490 register struct buffer *b; |
491 int permanent_too; | |
481 { | 492 { |
482 register int offset; | 493 register int offset; |
494 int dont_reset; | |
495 | |
496 /* Decide which built-in local variables to reset. */ | |
497 if (permanent_too) | |
498 dont_reset = 0; | |
499 else | |
500 dont_reset = buffer_permanent_local_flags; | |
483 | 501 |
484 /* Reset the major mode to Fundamental, together with all the | 502 /* Reset the major mode to Fundamental, together with all the |
485 things that depend on the major mode. | 503 things that depend on the major mode. |
486 default-major-mode is handled at a higher level. | 504 default-major-mode is handled at a higher level. |
487 We ignore it here. */ | 505 We ignore it here. */ |
500 | 518 |
501 b->downcase_table = Vascii_downcase_table; | 519 b->downcase_table = Vascii_downcase_table; |
502 b->upcase_table = XCHAR_TABLE (Vascii_downcase_table)->extras[0]; | 520 b->upcase_table = XCHAR_TABLE (Vascii_downcase_table)->extras[0]; |
503 b->case_canon_table = XCHAR_TABLE (Vascii_downcase_table)->extras[1]; | 521 b->case_canon_table = XCHAR_TABLE (Vascii_downcase_table)->extras[1]; |
504 b->case_eqv_table = XCHAR_TABLE (Vascii_downcase_table)->extras[2]; | 522 b->case_eqv_table = XCHAR_TABLE (Vascii_downcase_table)->extras[2]; |
505 b->buffer_file_type = Qnil; | |
506 b->invisibility_spec = Qt; | 523 b->invisibility_spec = Qt; |
507 | 524 |
508 #if 0 | 525 #if 0 |
509 b->sort_table = XSTRING (Vascii_sort_table); | 526 b->sort_table = XSTRING (Vascii_sort_table); |
510 b->folding_sort_table = XSTRING (Vascii_folding_sort_table); | 527 b->folding_sort_table = XSTRING (Vascii_folding_sort_table); |
511 #endif /* 0 */ | 528 #endif /* 0 */ |
512 | 529 |
513 /* Reset all per-buffer variables to their defaults. */ | 530 /* Reset all (or most) per-buffer variables to their defaults. */ |
514 b->local_var_alist = Qnil; | 531 b->local_var_alist = Qnil; |
515 b->local_var_flags = 0; | 532 b->local_var_flags &= dont_reset; |
516 | 533 |
517 /* For each slot that has a default value, | 534 /* For each slot that has a default value, |
518 copy that into the slot. */ | 535 copy that into the slot. */ |
519 | 536 |
520 for (offset = (char *)&buffer_local_flags.name - (char *)&buffer_local_flags; | 537 for (offset = (char *)&buffer_local_flags.name - (char *)&buffer_local_flags; |
521 offset < sizeof (struct buffer); | 538 offset < sizeof (struct buffer); |
522 offset += sizeof (Lisp_Object)) /* sizeof EMACS_INT == sizeof Lisp_Object */ | 539 offset += sizeof (Lisp_Object)) /* sizeof EMACS_INT == sizeof Lisp_Object */ |
523 { | 540 { |
524 int flag = XINT (*(Lisp_Object *)(offset + (char *)&buffer_local_flags)); | 541 int flag = XINT (*(Lisp_Object *)(offset + (char *)&buffer_local_flags)); |
525 if (flag > 0 || flag == -2) | 542 if ((flag > 0 |
526 *(Lisp_Object *)(offset + (char *)b) = | 543 /* Don't reset a permanent local. */ |
527 *(Lisp_Object *)(offset + (char *)&buffer_defaults); | 544 && ! (dont_reset & flag)) |
545 || flag == -2) | |
546 *(Lisp_Object *)(offset + (char *)b) | |
547 = *(Lisp_Object *)(offset + (char *)&buffer_defaults); | |
528 } | 548 } |
529 } | 549 } |
530 | 550 |
531 /* We split this away from generate-new-buffer, because rename-buffer | 551 /* We split this away from generate-new-buffer, because rename-buffer |
532 and set-visited-file-name ought to be able to use this to really | 552 and set-visited-file-name ought to be able to use this to really |
1088 /* Reset the local variables, so that this buffer's local values | 1108 /* Reset the local variables, so that this buffer's local values |
1089 won't be protected from GC. They would be protected | 1109 won't be protected from GC. They would be protected |
1090 if they happened to remain encached in their symbols. | 1110 if they happened to remain encached in their symbols. |
1091 This gets rid of them for certain. */ | 1111 This gets rid of them for certain. */ |
1092 swap_out_buffer_local_variables (b); | 1112 swap_out_buffer_local_variables (b); |
1093 reset_buffer_local_variables (b); | 1113 reset_buffer_local_variables (b, 1); |
1094 | 1114 |
1095 b->name = Qnil; | 1115 b->name = Qnil; |
1096 | 1116 |
1097 BLOCK_INPUT; | 1117 BLOCK_INPUT; |
1098 if (! b->base_buffer) | 1118 if (! b->base_buffer) |
1551 | 1571 |
1552 swap_out_buffer_local_variables (current_buffer); | 1572 swap_out_buffer_local_variables (current_buffer); |
1553 | 1573 |
1554 /* Actually eliminate all local bindings of this buffer. */ | 1574 /* Actually eliminate all local bindings of this buffer. */ |
1555 | 1575 |
1556 reset_buffer_local_variables (current_buffer); | 1576 reset_buffer_local_variables (current_buffer, 0); |
1557 | 1577 |
1558 /* Redisplay mode lines; we are changing major mode. */ | 1578 /* Redisplay mode lines; we are changing major mode. */ |
1559 | 1579 |
1560 update_mode_lines++; | 1580 update_mode_lines++; |
1561 | 1581 |
3313 | 3333 |
3314 init_buffer_once () | 3334 init_buffer_once () |
3315 { | 3335 { |
3316 register Lisp_Object tem; | 3336 register Lisp_Object tem; |
3317 | 3337 |
3338 buffer_permanent_local_flags = 0; | |
3339 | |
3318 /* Make sure all markable slots in buffer_defaults | 3340 /* Make sure all markable slots in buffer_defaults |
3319 are initialized reasonably, so mark_buffer won't choke. */ | 3341 are initialized reasonably, so mark_buffer won't choke. */ |
3320 reset_buffer (&buffer_defaults); | 3342 reset_buffer (&buffer_defaults); |
3321 reset_buffer_local_variables (&buffer_defaults); | 3343 reset_buffer_local_variables (&buffer_defaults, 1); |
3322 reset_buffer (&buffer_local_symbols); | 3344 reset_buffer (&buffer_local_symbols); |
3323 reset_buffer_local_variables (&buffer_local_symbols); | 3345 reset_buffer_local_variables (&buffer_local_symbols, 1); |
3324 /* Prevent GC from getting confused. */ | 3346 /* Prevent GC from getting confused. */ |
3325 buffer_defaults.text = &buffer_defaults.own_text; | 3347 buffer_defaults.text = &buffer_defaults.own_text; |
3326 buffer_local_symbols.text = &buffer_local_symbols.own_text; | 3348 buffer_local_symbols.text = &buffer_local_symbols.own_text; |
3327 #ifdef USE_TEXT_PROPERTIES | 3349 #ifdef USE_TEXT_PROPERTIES |
3328 BUF_INTERVALS (&buffer_defaults) = 0; | 3350 BUF_INTERVALS (&buffer_defaults) = 0; |
3408 XSETFASTINT (buffer_local_flags.display_table, 0x2000); | 3430 XSETFASTINT (buffer_local_flags.display_table, 0x2000); |
3409 XSETFASTINT (buffer_local_flags.syntax_table, 0x8000); | 3431 XSETFASTINT (buffer_local_flags.syntax_table, 0x8000); |
3410 XSETFASTINT (buffer_local_flags.cache_long_line_scans, 0x10000); | 3432 XSETFASTINT (buffer_local_flags.cache_long_line_scans, 0x10000); |
3411 #ifdef DOS_NT | 3433 #ifdef DOS_NT |
3412 XSETFASTINT (buffer_local_flags.buffer_file_type, 0x4000); | 3434 XSETFASTINT (buffer_local_flags.buffer_file_type, 0x4000); |
3435 /* Make this one a permanent local. */ | |
3436 buffer_permanent_local_flags |= 0x4000; | |
3413 #endif | 3437 #endif |
3438 | |
3414 | 3439 |
3415 Vbuffer_alist = Qnil; | 3440 Vbuffer_alist = Qnil; |
3416 current_buffer = 0; | 3441 current_buffer = 0; |
3417 all_buffers = 0; | 3442 all_buffers = 0; |
3418 | 3443 |