aboutsummaryrefslogtreecommitdiffstats
path: root/src/buffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c53
1 files changed, 39 insertions, 14 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 3f27317dfbf..a5c36f73eb0 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -99,11 +99,16 @@ static Lisp_Object Vbuffer_local_symbols;
99 buffer_slot_type_mismatch will signal an error. */ 99 buffer_slot_type_mismatch will signal an error. */
100struct buffer buffer_local_types; 100struct buffer buffer_local_types;
101 101
102/* Flags indicating which built-in buffer-local variables
103 are permanent locals. */
104static int buffer_permanent_local_flags;
105
102Lisp_Object Fset_buffer (); 106Lisp_Object Fset_buffer ();
103void set_buffer_internal (); 107void set_buffer_internal ();
104void set_buffer_internal_1 (); 108void set_buffer_internal_1 ();
105static void call_overlay_mod_hooks (); 109static void call_overlay_mod_hooks ();
106static void swap_out_buffer_local_variables (); 110static void swap_out_buffer_local_variables ();
111static 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,
@@ -335,7 +340,7 @@ The value is never nil.")
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);
@@ -399,7 +404,7 @@ NAME should be a string which is not the name of an existing buffer.")
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);
@@ -474,12 +479,25 @@ reset_buffer (b)
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.
483
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. */
478 487
479reset_buffer_local_variables (b) 488static void
489reset_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.
@@ -502,7 +520,6 @@ reset_buffer_local_variables (b)
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
@@ -510,9 +527,9 @@ reset_buffer_local_variables (b)
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. */
@@ -522,9 +539,12 @@ reset_buffer_local_variables (b)
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
@@ -1090,7 +1110,7 @@ with SIGHUP.")
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
@@ -1553,7 +1573,7 @@ the normal hook `change-major-mode-hook'.")
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
@@ -3315,12 +3335,14 @@ 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;
@@ -3410,8 +3432,11 @@ init_buffer_once ()
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
3414 3438
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;