aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStefan Monnier2007-10-16 15:42:58 +0000
committerStefan Monnier2007-10-16 15:42:58 +0000
commit67ee9f6e9121a43a5bad61145b55d785d88bfabf (patch)
treea776c1c5a82747dd188a8e34d9499f2f0d6a0928 /src
parent4144e15e96e7d67ff0ebbed15ecc14154ba68da2 (diff)
downloademacs-67ee9f6e9121a43a5bad61145b55d785d88bfabf.tar.gz
emacs-67ee9f6e9121a43a5bad61145b55d785d88bfabf.zip
* lisp.h (enum Lisp_Misc_Type): Del Lisp_Misc_Some_Buffer_Local_Value.
(XMISCANY): New macro. (XMISCTYPE): Use it. (struct Lisp_Misc_Any): New type. (union Lisp_Misc): Use it. (struct Lisp_Buffer_Local_Value): Add `local_if_set' bit. * data.c (Fboundp, store_symval_forwarding, swap_in_global_binding) (find_symbol_value, set_internal, default_value, Fset_default) (Fmake_variable_buffer_local, Fmake_local_variable) (Fkill_local_variable, Fmake_variable_frame_local, Flocal_variable_p) (Flocal_variable_if_set_p, Fvariable_binding_locus): The SOME_BUFFER_LOCAL_VALUEP distinction is replaced by local_if_set. * alloc.c (allocate_buffer): Set the size and tag. (allocate_misc, mark_maybe_object, mark_object, survives_gc_p): Use XMISCANY. (die): Follow the GNU convention for error messages. * print.c (print_object): SOME_BUFFER_LOCAL_VALUEP -> local_if_set. * buffer.c (Fget_buffer_create, Fmake_indirect_buffer): Don't set the tag any more. (set_buffer_internal_1): * frame.c (store_frame_param): * eval.c (specbind): * xdisp.c (select_frame_for_redisplay): Drop SOME_BUFFER_LOCAL_VALUEP.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog24
-rw-r--r--src/alloc.c15
-rw-r--r--src/buffer.c27
-rw-r--r--src/data.c99
-rw-r--r--src/eval.c11
-rw-r--r--src/frame.c3
-rw-r--r--src/lisp.h30
-rw-r--r--src/print.c6
-rw-r--r--src/xdisp.c6
9 files changed, 114 insertions, 107 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index bed9166f9f0..3c275302f9f 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,29 @@
12007-10-16 Stefan Monnier <monnier@iro.umontreal.ca> 12007-10-16 Stefan Monnier <monnier@iro.umontreal.ca>
2 2
3 * lisp.h (enum Lisp_Misc_Type): Del Lisp_Misc_Some_Buffer_Local_Value.
4 (XMISCANY): New macro.
5 (XMISCTYPE): Use it.
6 (struct Lisp_Misc_Any): New type.
7 (union Lisp_Misc): Use it.
8 (struct Lisp_Buffer_Local_Value): Add `local_if_set' bit.
9 * data.c (Fboundp, store_symval_forwarding, swap_in_global_binding)
10 (find_symbol_value, set_internal, default_value, Fset_default)
11 (Fmake_variable_buffer_local, Fmake_local_variable)
12 (Fkill_local_variable, Fmake_variable_frame_local, Flocal_variable_p)
13 (Flocal_variable_if_set_p, Fvariable_binding_locus):
14 The SOME_BUFFER_LOCAL_VALUEP distinction is replaced by local_if_set.
15 * alloc.c (allocate_buffer): Set the size and tag.
16 (allocate_misc, mark_maybe_object, mark_object, survives_gc_p):
17 Use XMISCANY.
18 (die): Follow the GNU convention for error messages.
19 * print.c (print_object): SOME_BUFFER_LOCAL_VALUEP -> local_if_set.
20 * buffer.c (Fget_buffer_create, Fmake_indirect_buffer): Don't set the
21 tag any more.
22 (set_buffer_internal_1):
23 * frame.c (store_frame_param):
24 * eval.c (specbind):
25 * xdisp.c (select_frame_for_redisplay): Drop SOME_BUFFER_LOCAL_VALUEP.
26
3 * doc.c (Fsnarf_documentation): Simplify. 27 * doc.c (Fsnarf_documentation): Simplify.
4 28
52007-10-14 Juanma Barranquero <lekktu@gmail.com> 292007-10-14 Juanma Barranquero <lekktu@gmail.com>
diff --git a/src/alloc.c b/src/alloc.c
index 8e00733a60b..48857ecff14 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -1153,6 +1153,8 @@ allocate_buffer ()
1153 struct buffer *b 1153 struct buffer *b
1154 = (struct buffer *) lisp_malloc (sizeof (struct buffer), 1154 = (struct buffer *) lisp_malloc (sizeof (struct buffer),
1155 MEM_TYPE_BUFFER); 1155 MEM_TYPE_BUFFER);
1156 b->size = sizeof (struct buffer) / sizeof (EMACS_INT);
1157 XSETPVECTYPE (b, PVEC_BUFFER);
1156 return b; 1158 return b;
1157} 1159}
1158 1160
@@ -3352,7 +3354,7 @@ allocate_misc ()
3352 --total_free_markers; 3354 --total_free_markers;
3353 consing_since_gc += sizeof (union Lisp_Misc); 3355 consing_since_gc += sizeof (union Lisp_Misc);
3354 misc_objects_consed++; 3356 misc_objects_consed++;
3355 XMARKER (val)->gcmarkbit = 0; 3357 XMISCANY (val)->gcmarkbit = 0;
3356 return val; 3358 return val;
3357} 3359}
3358 3360
@@ -4209,7 +4211,7 @@ mark_maybe_object (obj)
4209 break; 4211 break;
4210 4212
4211 case Lisp_Misc: 4213 case Lisp_Misc:
4212 mark_p = (live_misc_p (m, po) && !XMARKER (obj)->gcmarkbit); 4214 mark_p = (live_misc_p (m, po) && !XMISCANY (obj)->gcmarkbit);
4213 break; 4215 break;
4214 4216
4215 case Lisp_Int: 4217 case Lisp_Int:
@@ -5654,14 +5656,13 @@ mark_object (arg)
5654 5656
5655 case Lisp_Misc: 5657 case Lisp_Misc:
5656 CHECK_ALLOCATED_AND_LIVE (live_misc_p); 5658 CHECK_ALLOCATED_AND_LIVE (live_misc_p);
5657 if (XMARKER (obj)->gcmarkbit) 5659 if (XMISCANY (obj)->gcmarkbit)
5658 break; 5660 break;
5659 XMARKER (obj)->gcmarkbit = 1; 5661 XMISCANY (obj)->gcmarkbit = 1;
5660 5662
5661 switch (XMISCTYPE (obj)) 5663 switch (XMISCTYPE (obj))
5662 { 5664 {
5663 case Lisp_Misc_Buffer_Local_Value: 5665 case Lisp_Misc_Buffer_Local_Value:
5664 case Lisp_Misc_Some_Buffer_Local_Value:
5665 { 5666 {
5666 register struct Lisp_Buffer_Local_Value *ptr 5667 register struct Lisp_Buffer_Local_Value *ptr
5667 = XBUFFER_LOCAL_VALUE (obj); 5668 = XBUFFER_LOCAL_VALUE (obj);
@@ -5847,7 +5848,7 @@ survives_gc_p (obj)
5847 break; 5848 break;
5848 5849
5849 case Lisp_Misc: 5850 case Lisp_Misc:
5850 survives_p = XMARKER (obj)->gcmarkbit; 5851 survives_p = XMISCANY (obj)->gcmarkbit;
5851 break; 5852 break;
5852 5853
5853 case Lisp_String: 5854 case Lisp_String:
@@ -6297,7 +6298,7 @@ die (msg, file, line)
6297 const char *file; 6298 const char *file;
6298 int line; 6299 int line;
6299{ 6300{
6300 fprintf (stderr, "\r\nEmacs fatal error: %s:%d: %s\r\n", 6301 fprintf (stderr, "\r\n%s:%d: Emacs fatal error: %s\r\n",
6301 file, line, msg); 6302 file, line, msg);
6302 abort (); 6303 abort ();
6303} 6304}
diff --git a/src/buffer.c b/src/buffer.c
index 740f9fe53d6..c53d427499a 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -361,8 +361,6 @@ The value is never nil. */)
361 361
362 b = (struct buffer *) allocate_buffer (); 362 b = (struct buffer *) allocate_buffer ();
363 363
364 b->size = sizeof (struct buffer) / sizeof (EMACS_INT);
365
366 /* An ordinary buffer uses its own struct buffer_text. */ 364 /* An ordinary buffer uses its own struct buffer_text. */
367 b->text = &b->own_text; 365 b->text = &b->own_text;
368 b->base_buffer = 0; 366 b->base_buffer = 0;
@@ -416,10 +414,7 @@ The value is never nil. */)
416 STRING_SET_INTERVALS (name, NULL_INTERVAL); 414 STRING_SET_INTERVALS (name, NULL_INTERVAL);
417 b->name = name; 415 b->name = name;
418 416
419 if (SREF (name, 0) != ' ') 417 b->undo_list = (SREF (name, 0) != ' ') ? Qnil : Qt;
420 b->undo_list = Qnil;
421 else
422 b->undo_list = Qt;
423 418
424 reset_buffer (b); 419 reset_buffer (b);
425 reset_buffer_local_variables (b, 1); 420 reset_buffer_local_variables (b, 1);
@@ -429,7 +424,6 @@ The value is never nil. */)
429 b->name = name; 424 b->name = name;
430 425
431 /* Put this in the alist of all live buffers. */ 426 /* Put this in the alist of all live buffers. */
432 XSETPVECTYPE (b, PVEC_BUFFER);
433 XSETBUFFER (buf, b); 427 XSETBUFFER (buf, b);
434 Vbuffer_alist = nconc2 (Vbuffer_alist, Fcons (Fcons (name, buf), Qnil)); 428 Vbuffer_alist = nconc2 (Vbuffer_alist, Fcons (Fcons (name, buf), Qnil));
435 429
@@ -567,13 +561,10 @@ CLONE nil means the indirect buffer's state is reset to default values. */)
567 error ("Empty string for buffer name is not allowed"); 561 error ("Empty string for buffer name is not allowed");
568 562
569 b = (struct buffer *) allocate_buffer (); 563 b = (struct buffer *) allocate_buffer ();
570 b->size = sizeof (struct buffer) / sizeof (EMACS_INT);
571 XSETPVECTYPE (b, PVEC_BUFFER);
572 564
573 if (XBUFFER (base_buffer)->base_buffer) 565 b->base_buffer = (XBUFFER (base_buffer)->base_buffer
574 b->base_buffer = XBUFFER (base_buffer)->base_buffer; 566 ? XBUFFER (base_buffer)->base_buffer
575 else 567 : XBUFFER (base_buffer));
576 b->base_buffer = XBUFFER (base_buffer);
577 568
578 /* Use the base buffer's text object. */ 569 /* Use the base buffer's text object. */
579 b->text = b->base_buffer->text; 570 b->text = b->base_buffer->text;
@@ -1918,8 +1909,7 @@ set_buffer_internal_1 (b)
1918 for (tail = b->local_var_alist; CONSP (tail); tail = XCDR (tail)) 1909 for (tail = b->local_var_alist; CONSP (tail); tail = XCDR (tail))
1919 { 1910 {
1920 valcontents = SYMBOL_VALUE (XCAR (XCAR (tail))); 1911 valcontents = SYMBOL_VALUE (XCAR (XCAR (tail)));
1921 if ((BUFFER_LOCAL_VALUEP (valcontents) 1912 if ((BUFFER_LOCAL_VALUEP (valcontents))
1922 || SOME_BUFFER_LOCAL_VALUEP (valcontents))
1923 && (tem = XBUFFER_LOCAL_VALUE (valcontents)->realvalue, 1913 && (tem = XBUFFER_LOCAL_VALUE (valcontents)->realvalue,
1924 (BOOLFWDP (tem) || INTFWDP (tem) || OBJFWDP (tem)))) 1914 (BOOLFWDP (tem) || INTFWDP (tem) || OBJFWDP (tem))))
1925 /* Just reference the variable 1915 /* Just reference the variable
@@ -1933,8 +1923,7 @@ set_buffer_internal_1 (b)
1933 for (tail = old_buf->local_var_alist; CONSP (tail); tail = XCDR (tail)) 1923 for (tail = old_buf->local_var_alist; CONSP (tail); tail = XCDR (tail))
1934 { 1924 {
1935 valcontents = SYMBOL_VALUE (XCAR (XCAR (tail))); 1925 valcontents = SYMBOL_VALUE (XCAR (XCAR (tail)));
1936 if ((BUFFER_LOCAL_VALUEP (valcontents) 1926 if ((BUFFER_LOCAL_VALUEP (valcontents))
1937 || SOME_BUFFER_LOCAL_VALUEP (valcontents))
1938 && (tem = XBUFFER_LOCAL_VALUE (valcontents)->realvalue, 1927 && (tem = XBUFFER_LOCAL_VALUE (valcontents)->realvalue,
1939 (BOOLFWDP (tem) || INTFWDP (tem) || OBJFWDP (tem)))) 1928 (BOOLFWDP (tem) || INTFWDP (tem) || OBJFWDP (tem))))
1940 /* Just reference the variable 1929 /* Just reference the variable
@@ -2493,7 +2482,7 @@ the normal hook `change-major-mode-hook'. */)
2493 /* Any which are supposed to be permanent, 2482 /* Any which are supposed to be permanent,
2494 make local again, with the same values they had. */ 2483 make local again, with the same values they had. */
2495 2484
2496 for (alist = oalist; !NILP (alist); alist = XCDR (alist)) 2485 for (alist = oalist; CONSP (alist); alist = XCDR (alist))
2497 { 2486 {
2498 sym = XCAR (XCAR (alist)); 2487 sym = XCAR (XCAR (alist));
2499 tem = Fget (sym, Qpermanent_local); 2488 tem = Fget (sym, Qpermanent_local);
@@ -2523,7 +2512,7 @@ swap_out_buffer_local_variables (b)
2523 XSETBUFFER (buffer, b); 2512 XSETBUFFER (buffer, b);
2524 oalist = b->local_var_alist; 2513 oalist = b->local_var_alist;
2525 2514
2526 for (alist = oalist; !NILP (alist); alist = XCDR (alist)) 2515 for (alist = oalist; CONSP (alist); alist = XCDR (alist))
2527 { 2516 {
2528 sym = XCAR (XCAR (alist)); 2517 sym = XCAR (XCAR (alist));
2529 2518
diff --git a/src/data.c b/src/data.c
index c8c40aa6df0..2a99a728a76 100644
--- a/src/data.c
+++ b/src/data.c
@@ -584,8 +584,7 @@ DEFUN ("boundp", Fboundp, Sboundp, 1, 1, 0,
584 584
585 valcontents = SYMBOL_VALUE (symbol); 585 valcontents = SYMBOL_VALUE (symbol);
586 586
587 if (BUFFER_LOCAL_VALUEP (valcontents) 587 if (BUFFER_LOCAL_VALUEP (valcontents))
588 || SOME_BUFFER_LOCAL_VALUEP (valcontents))
589 valcontents = swap_in_symval_forwarding (symbol, valcontents); 588 valcontents = swap_in_symval_forwarding (symbol, valcontents);
590 589
591 return (EQ (valcontents, Qunbound) ? Qnil : Qt); 590 return (EQ (valcontents, Qunbound) ? Qnil : Qt);
@@ -998,8 +997,7 @@ store_symval_forwarding (symbol, valcontents, newval, buf)
998 default: 997 default:
999 def: 998 def:
1000 valcontents = SYMBOL_VALUE (symbol); 999 valcontents = SYMBOL_VALUE (symbol);
1001 if (BUFFER_LOCAL_VALUEP (valcontents) 1000 if (BUFFER_LOCAL_VALUEP (valcontents))
1002 || SOME_BUFFER_LOCAL_VALUEP (valcontents))
1003 XBUFFER_LOCAL_VALUE (valcontents)->realvalue = newval; 1001 XBUFFER_LOCAL_VALUE (valcontents)->realvalue = newval;
1004 else 1002 else
1005 SET_SYMBOL_VALUE (symbol, newval); 1003 SET_SYMBOL_VALUE (symbol, newval);
@@ -1016,8 +1014,7 @@ swap_in_global_binding (symbol)
1016 Lisp_Object valcontents, cdr; 1014 Lisp_Object valcontents, cdr;
1017 1015
1018 valcontents = SYMBOL_VALUE (symbol); 1016 valcontents = SYMBOL_VALUE (symbol);
1019 if (!BUFFER_LOCAL_VALUEP (valcontents) 1017 if (!BUFFER_LOCAL_VALUEP (valcontents))
1020 && !SOME_BUFFER_LOCAL_VALUEP (valcontents))
1021 abort (); 1018 abort ();
1022 cdr = XBUFFER_LOCAL_VALUE (valcontents)->cdr; 1019 cdr = XBUFFER_LOCAL_VALUE (valcontents)->cdr;
1023 1020
@@ -1106,8 +1103,7 @@ find_symbol_value (symbol)
1106 CHECK_SYMBOL (symbol); 1103 CHECK_SYMBOL (symbol);
1107 valcontents = SYMBOL_VALUE (symbol); 1104 valcontents = SYMBOL_VALUE (symbol);
1108 1105
1109 if (BUFFER_LOCAL_VALUEP (valcontents) 1106 if (BUFFER_LOCAL_VALUEP (valcontents))
1110 || SOME_BUFFER_LOCAL_VALUEP (valcontents))
1111 valcontents = swap_in_symval_forwarding (symbol, valcontents); 1107 valcontents = swap_in_symval_forwarding (symbol, valcontents);
1112 1108
1113 if (MISCP (valcontents)) 1109 if (MISCP (valcontents))
@@ -1225,8 +1221,7 @@ set_internal (symbol, newval, buf, bindflag)
1225 && !let_shadows_buffer_binding_p (symbol)) 1221 && !let_shadows_buffer_binding_p (symbol))
1226 SET_PER_BUFFER_VALUE_P (buf, idx, 1); 1222 SET_PER_BUFFER_VALUE_P (buf, idx, 1);
1227 } 1223 }
1228 else if (BUFFER_LOCAL_VALUEP (valcontents) 1224 else if (BUFFER_LOCAL_VALUEP (valcontents))
1229 || SOME_BUFFER_LOCAL_VALUEP (valcontents))
1230 { 1225 {
1231 /* valcontents is a struct Lisp_Buffer_Local_Value. */ 1226 /* valcontents is a struct Lisp_Buffer_Local_Value. */
1232 if (XSYMBOL (symbol)->indirect_variable) 1227 if (XSYMBOL (symbol)->indirect_variable)
@@ -1271,7 +1266,7 @@ set_internal (symbol, newval, buf, bindflag)
1271 indicating that we're seeing the default value. 1266 indicating that we're seeing the default value.
1272 Likewise if the variable has been let-bound 1267 Likewise if the variable has been let-bound
1273 in the current buffer. */ 1268 in the current buffer. */
1274 if (bindflag || SOME_BUFFER_LOCAL_VALUEP (valcontents) 1269 if (bindflag || !XBUFFER_LOCAL_VALUE (valcontents)->local_if_set
1275 || let_shadows_buffer_binding_p (symbol)) 1270 || let_shadows_buffer_binding_p (symbol))
1276 { 1271 {
1277 XBUFFER_LOCAL_VALUE (valcontents)->found_for_buffer = 0; 1272 XBUFFER_LOCAL_VALUE (valcontents)->found_for_buffer = 0;
@@ -1299,8 +1294,7 @@ set_internal (symbol, newval, buf, bindflag)
1299 } 1294 }
1300 1295
1301 /* Record which binding is now loaded. */ 1296 /* Record which binding is now loaded. */
1302 XSETCAR (XBUFFER_LOCAL_VALUE (valcontents)->cdr, 1297 XSETCAR (XBUFFER_LOCAL_VALUE (valcontents)->cdr, tem1);
1303 tem1);
1304 1298
1305 /* Set `buffer' and `frame' slots for the binding now loaded. */ 1299 /* Set `buffer' and `frame' slots for the binding now loaded. */
1306 XSETBUFFER (XBUFFER_LOCAL_VALUE (valcontents)->buffer, buf); 1300 XSETBUFFER (XBUFFER_LOCAL_VALUE (valcontents)->buffer, buf);
@@ -1319,8 +1313,7 @@ set_internal (symbol, newval, buf, bindflag)
1319 /* If we just set a variable whose current binding is frame-local, 1313 /* If we just set a variable whose current binding is frame-local,
1320 store the new value in the frame parameter too. */ 1314 store the new value in the frame parameter too. */
1321 1315
1322 if (BUFFER_LOCAL_VALUEP (valcontents) 1316 if (BUFFER_LOCAL_VALUEP (valcontents))
1323 || SOME_BUFFER_LOCAL_VALUEP (valcontents))
1324 { 1317 {
1325 /* What binding is loaded right now? */ 1318 /* What binding is loaded right now? */
1326 current_alist_element 1319 current_alist_element
@@ -1362,8 +1355,7 @@ default_value (symbol)
1362 } 1355 }
1363 1356
1364 /* Handle user-created local variables. */ 1357 /* Handle user-created local variables. */
1365 if (BUFFER_LOCAL_VALUEP (valcontents) 1358 if (BUFFER_LOCAL_VALUEP (valcontents))
1366 || SOME_BUFFER_LOCAL_VALUEP (valcontents))
1367 { 1359 {
1368 /* If var is set up for a buffer that lacks a local value for it, 1360 /* If var is set up for a buffer that lacks a local value for it,
1369 the current value is nominally the default value. 1361 the current value is nominally the default value.
@@ -1447,8 +1439,7 @@ for this variable. */)
1447 return value; 1439 return value;
1448 } 1440 }
1449 1441
1450 if (!BUFFER_LOCAL_VALUEP (valcontents) 1442 if (!BUFFER_LOCAL_VALUEP (valcontents))
1451 && !SOME_BUFFER_LOCAL_VALUEP (valcontents))
1452 return Fset (symbol, value); 1443 return Fset (symbol, value);
1453 1444
1454 /* Store new value into the DEFAULT-VALUE slot. */ 1445 /* Store new value into the DEFAULT-VALUE slot. */
@@ -1533,27 +1524,28 @@ The function `default-value' gets the default value and `set-default' sets it.
1533 if (EQ (variable, Qnil) || EQ (variable, Qt) || KBOARD_OBJFWDP (valcontents)) 1524 if (EQ (variable, Qnil) || EQ (variable, Qt) || KBOARD_OBJFWDP (valcontents))
1534 error ("Symbol %s may not be buffer-local", SDATA (SYMBOL_NAME (variable))); 1525 error ("Symbol %s may not be buffer-local", SDATA (SYMBOL_NAME (variable)));
1535 1526
1536 if (BUFFER_LOCAL_VALUEP (valcontents) || BUFFER_OBJFWDP (valcontents)) 1527 if (BUFFER_OBJFWDP (valcontents))
1537 return variable; 1528 return variable;
1538 if (SOME_BUFFER_LOCAL_VALUEP (valcontents)) 1529 else if (BUFFER_LOCAL_VALUEP (valcontents))
1530 newval = valcontents;
1531 else
1539 { 1532 {
1540 XMISCTYPE (SYMBOL_VALUE (variable)) = Lisp_Misc_Buffer_Local_Value; 1533 if (EQ (valcontents, Qunbound))
1541 return variable; 1534 SET_SYMBOL_VALUE (variable, Qnil);
1535 tem = Fcons (Qnil, Fsymbol_value (variable));
1536 XSETCAR (tem, tem);
1537 newval = allocate_misc ();
1538 XMISCTYPE (newval) = Lisp_Misc_Buffer_Local_Value;
1539 XBUFFER_LOCAL_VALUE (newval)->realvalue = SYMBOL_VALUE (variable);
1540 XBUFFER_LOCAL_VALUE (newval)->buffer = Fcurrent_buffer ();
1541 XBUFFER_LOCAL_VALUE (newval)->frame = Qnil;
1542 XBUFFER_LOCAL_VALUE (newval)->found_for_buffer = 0;
1543 XBUFFER_LOCAL_VALUE (newval)->found_for_frame = 0;
1544 XBUFFER_LOCAL_VALUE (newval)->check_frame = 0;
1545 XBUFFER_LOCAL_VALUE (newval)->cdr = tem;
1546 SET_SYMBOL_VALUE (variable, newval);
1542 } 1547 }
1543 if (EQ (valcontents, Qunbound)) 1548 XBUFFER_LOCAL_VALUE (newval)->local_if_set = 1;
1544 SET_SYMBOL_VALUE (variable, Qnil);
1545 tem = Fcons (Qnil, Fsymbol_value (variable));
1546 XSETCAR (tem, tem);
1547 newval = allocate_misc ();
1548 XMISCTYPE (newval) = Lisp_Misc_Buffer_Local_Value;
1549 XBUFFER_LOCAL_VALUE (newval)->realvalue = SYMBOL_VALUE (variable);
1550 XBUFFER_LOCAL_VALUE (newval)->buffer = Fcurrent_buffer ();
1551 XBUFFER_LOCAL_VALUE (newval)->frame = Qnil;
1552 XBUFFER_LOCAL_VALUE (newval)->found_for_buffer = 0;
1553 XBUFFER_LOCAL_VALUE (newval)->found_for_frame = 0;
1554 XBUFFER_LOCAL_VALUE (newval)->check_frame = 0;
1555 XBUFFER_LOCAL_VALUE (newval)->cdr = tem;
1556 SET_SYMBOL_VALUE (variable, newval);
1557 return variable; 1549 return variable;
1558} 1550}
1559 1551
@@ -1589,7 +1581,9 @@ Instead, use `add-hook' and specify t for the LOCAL argument. */)
1589 if (EQ (variable, Qnil) || EQ (variable, Qt) || KBOARD_OBJFWDP (valcontents)) 1581 if (EQ (variable, Qnil) || EQ (variable, Qt) || KBOARD_OBJFWDP (valcontents))
1590 error ("Symbol %s may not be buffer-local", SDATA (SYMBOL_NAME (variable))); 1582 error ("Symbol %s may not be buffer-local", SDATA (SYMBOL_NAME (variable)));
1591 1583
1592 if (BUFFER_LOCAL_VALUEP (valcontents) || BUFFER_OBJFWDP (valcontents)) 1584 if ((BUFFER_LOCAL_VALUEP (valcontents)
1585 && XBUFFER_LOCAL_VALUE (valcontents)->local_if_set)
1586 || BUFFER_OBJFWDP (valcontents))
1593 { 1587 {
1594 tem = Fboundp (variable); 1588 tem = Fboundp (variable);
1595 1589
@@ -1599,16 +1593,17 @@ Instead, use `add-hook' and specify t for the LOCAL argument. */)
1599 return variable; 1593 return variable;
1600 } 1594 }
1601 /* Make sure symbol is set up to hold per-buffer values. */ 1595 /* Make sure symbol is set up to hold per-buffer values. */
1602 if (!SOME_BUFFER_LOCAL_VALUEP (valcontents)) 1596 if (!BUFFER_LOCAL_VALUEP (valcontents))
1603 { 1597 {
1604 Lisp_Object newval; 1598 Lisp_Object newval;
1605 tem = Fcons (Qnil, do_symval_forwarding (valcontents)); 1599 tem = Fcons (Qnil, do_symval_forwarding (valcontents));
1606 XSETCAR (tem, tem); 1600 XSETCAR (tem, tem);
1607 newval = allocate_misc (); 1601 newval = allocate_misc ();
1608 XMISCTYPE (newval) = Lisp_Misc_Some_Buffer_Local_Value; 1602 XMISCTYPE (newval) = Lisp_Misc_Buffer_Local_Value;
1609 XBUFFER_LOCAL_VALUE (newval)->realvalue = SYMBOL_VALUE (variable); 1603 XBUFFER_LOCAL_VALUE (newval)->realvalue = SYMBOL_VALUE (variable);
1610 XBUFFER_LOCAL_VALUE (newval)->buffer = Qnil; 1604 XBUFFER_LOCAL_VALUE (newval)->buffer = Qnil;
1611 XBUFFER_LOCAL_VALUE (newval)->frame = Qnil; 1605 XBUFFER_LOCAL_VALUE (newval)->frame = Qnil;
1606 XBUFFER_LOCAL_VALUE (newval)->local_if_set = 0;
1612 XBUFFER_LOCAL_VALUE (newval)->found_for_buffer = 0; 1607 XBUFFER_LOCAL_VALUE (newval)->found_for_buffer = 0;
1613 XBUFFER_LOCAL_VALUE (newval)->found_for_frame = 0; 1608 XBUFFER_LOCAL_VALUE (newval)->found_for_frame = 0;
1614 XBUFFER_LOCAL_VALUE (newval)->check_frame = 0; 1609 XBUFFER_LOCAL_VALUE (newval)->check_frame = 0;
@@ -1681,8 +1676,7 @@ From now on the default value will apply in this buffer. Return VARIABLE. */)
1681 return variable; 1676 return variable;
1682 } 1677 }
1683 1678
1684 if (!BUFFER_LOCAL_VALUEP (valcontents) 1679 if (!BUFFER_LOCAL_VALUEP (valcontents))
1685 && !SOME_BUFFER_LOCAL_VALUEP (valcontents))
1686 return variable; 1680 return variable;
1687 1681
1688 /* Get rid of this buffer's alist element, if any. */ 1682 /* Get rid of this buffer's alist element, if any. */
@@ -1743,8 +1737,7 @@ Buffer-local bindings take precedence over frame-local bindings. */)
1743 || BUFFER_OBJFWDP (valcontents)) 1737 || BUFFER_OBJFWDP (valcontents))
1744 error ("Symbol %s may not be frame-local", SDATA (SYMBOL_NAME (variable))); 1738 error ("Symbol %s may not be frame-local", SDATA (SYMBOL_NAME (variable)));
1745 1739
1746 if (BUFFER_LOCAL_VALUEP (valcontents) 1740 if (BUFFER_LOCAL_VALUEP (valcontents))
1747 || SOME_BUFFER_LOCAL_VALUEP (valcontents))
1748 { 1741 {
1749 XBUFFER_LOCAL_VALUE (valcontents)->check_frame = 1; 1742 XBUFFER_LOCAL_VALUE (valcontents)->check_frame = 1;
1750 return variable; 1743 return variable;
@@ -1755,10 +1748,11 @@ Buffer-local bindings take precedence over frame-local bindings. */)
1755 tem = Fcons (Qnil, Fsymbol_value (variable)); 1748 tem = Fcons (Qnil, Fsymbol_value (variable));
1756 XSETCAR (tem, tem); 1749 XSETCAR (tem, tem);
1757 newval = allocate_misc (); 1750 newval = allocate_misc ();
1758 XMISCTYPE (newval) = Lisp_Misc_Some_Buffer_Local_Value; 1751 XMISCTYPE (newval) = Lisp_Misc_Buffer_Local_Value;
1759 XBUFFER_LOCAL_VALUE (newval)->realvalue = SYMBOL_VALUE (variable); 1752 XBUFFER_LOCAL_VALUE (newval)->realvalue = SYMBOL_VALUE (variable);
1760 XBUFFER_LOCAL_VALUE (newval)->buffer = Qnil; 1753 XBUFFER_LOCAL_VALUE (newval)->buffer = Qnil;
1761 XBUFFER_LOCAL_VALUE (newval)->frame = Qnil; 1754 XBUFFER_LOCAL_VALUE (newval)->frame = Qnil;
1755 XBUFFER_LOCAL_VALUE (newval)->local_if_set = 0;
1762 XBUFFER_LOCAL_VALUE (newval)->found_for_buffer = 0; 1756 XBUFFER_LOCAL_VALUE (newval)->found_for_buffer = 0;
1763 XBUFFER_LOCAL_VALUE (newval)->found_for_frame = 0; 1757 XBUFFER_LOCAL_VALUE (newval)->found_for_frame = 0;
1764 XBUFFER_LOCAL_VALUE (newval)->check_frame = 1; 1758 XBUFFER_LOCAL_VALUE (newval)->check_frame = 1;
@@ -1789,8 +1783,7 @@ BUFFER defaults to the current buffer. */)
1789 variable = indirect_variable (variable); 1783 variable = indirect_variable (variable);
1790 1784
1791 valcontents = SYMBOL_VALUE (variable); 1785 valcontents = SYMBOL_VALUE (variable);
1792 if (BUFFER_LOCAL_VALUEP (valcontents) 1786 if (BUFFER_LOCAL_VALUEP (valcontents))
1793 || SOME_BUFFER_LOCAL_VALUEP (valcontents))
1794 { 1787 {
1795 Lisp_Object tail, elt; 1788 Lisp_Object tail, elt;
1796 1789
@@ -1838,15 +1831,14 @@ BUFFER defaults to the current buffer. */)
1838 1831
1839 valcontents = SYMBOL_VALUE (variable); 1832 valcontents = SYMBOL_VALUE (variable);
1840 1833
1841 /* This means that make-variable-buffer-local was done. */
1842 if (BUFFER_LOCAL_VALUEP (valcontents))
1843 return Qt;
1844 /* All these slots become local if they are set. */
1845 if (BUFFER_OBJFWDP (valcontents)) 1834 if (BUFFER_OBJFWDP (valcontents))
1835 /* All these slots become local if they are set. */
1846 return Qt; 1836 return Qt;
1847 if (SOME_BUFFER_LOCAL_VALUEP (valcontents)) 1837 else if (BUFFER_LOCAL_VALUEP (valcontents))
1848 { 1838 {
1849 Lisp_Object tail, elt; 1839 Lisp_Object tail, elt;
1840 if (XBUFFER_LOCAL_VALUE (valcontents)->local_if_set)
1841 return Qt;
1850 for (tail = buf->local_var_alist; CONSP (tail); tail = XCDR (tail)) 1842 for (tail = buf->local_var_alist; CONSP (tail); tail = XCDR (tail))
1851 { 1843 {
1852 elt = XCAR (tail); 1844 elt = XCAR (tail);
@@ -1877,14 +1869,13 @@ If the current binding is global (the default), the value is nil. */)
1877 valcontents = XSYMBOL (variable)->value; 1869 valcontents = XSYMBOL (variable)->value;
1878 1870
1879 if (BUFFER_LOCAL_VALUEP (valcontents) 1871 if (BUFFER_LOCAL_VALUEP (valcontents)
1880 || SOME_BUFFER_LOCAL_VALUEP (valcontents)
1881 || BUFFER_OBJFWDP (valcontents)) 1872 || BUFFER_OBJFWDP (valcontents))
1882 { 1873 {
1883 /* For a local variable, record both the symbol and which 1874 /* For a local variable, record both the symbol and which
1884 buffer's or frame's value we are saving. */ 1875 buffer's or frame's value we are saving. */
1885 if (!NILP (Flocal_variable_p (variable, Qnil))) 1876 if (!NILP (Flocal_variable_p (variable, Qnil)))
1886 return Fcurrent_buffer (); 1877 return Fcurrent_buffer ();
1887 else if (!BUFFER_OBJFWDP (valcontents) 1878 else if (BUFFER_LOCAL_VALUEP (valcontents)
1888 && XBUFFER_LOCAL_VALUE (valcontents)->found_for_frame) 1879 && XBUFFER_LOCAL_VALUE (valcontents)->found_for_frame)
1889 return XBUFFER_LOCAL_VALUE (valcontents)->frame; 1880 return XBUFFER_LOCAL_VALUE (valcontents)->frame;
1890 } 1881 }
diff --git a/src/eval.c b/src/eval.c
index b69eea44c75..d71d646a25b 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1043,10 +1043,10 @@ usage: (let VARLIST BODY...) */)
1043 GCPRO2 (args, *temps); 1043 GCPRO2 (args, *temps);
1044 gcpro2.nvars = 0; 1044 gcpro2.nvars = 0;
1045 1045
1046 for (argnum = 0; !NILP (varlist); varlist = Fcdr (varlist)) 1046 for (argnum = 0; CONSP (varlist); varlist = XCDR (varlist))
1047 { 1047 {
1048 QUIT; 1048 QUIT;
1049 elt = Fcar (varlist); 1049 elt = XCAR (varlist);
1050 if (SYMBOLP (elt)) 1050 if (SYMBOLP (elt))
1051 temps [argnum++] = Qnil; 1051 temps [argnum++] = Qnil;
1052 else if (! NILP (Fcdr (Fcdr (elt)))) 1052 else if (! NILP (Fcdr (Fcdr (elt))))
@@ -1058,9 +1058,9 @@ usage: (let VARLIST BODY...) */)
1058 UNGCPRO; 1058 UNGCPRO;
1059 1059
1060 varlist = Fcar (args); 1060 varlist = Fcar (args);
1061 for (argnum = 0; !NILP (varlist); varlist = Fcdr (varlist)) 1061 for (argnum = 0; CONSP (varlist); varlist = XCDR (varlist))
1062 { 1062 {
1063 elt = Fcar (varlist); 1063 elt = XCAR (varlist);
1064 tem = temps[argnum++]; 1064 tem = temps[argnum++];
1065 if (SYMBOLP (elt)) 1065 if (SYMBOLP (elt))
1066 specbind (elt, tem); 1066 specbind (elt, tem);
@@ -3285,7 +3285,6 @@ specbind (symbol, value)
3285 valcontents = XSYMBOL (symbol)->value; 3285 valcontents = XSYMBOL (symbol)->value;
3286 3286
3287 if (BUFFER_LOCAL_VALUEP (valcontents) 3287 if (BUFFER_LOCAL_VALUEP (valcontents)
3288 || SOME_BUFFER_LOCAL_VALUEP (valcontents)
3289 || BUFFER_OBJFWDP (valcontents)) 3288 || BUFFER_OBJFWDP (valcontents))
3290 { 3289 {
3291 Lisp_Object where, current_buffer; 3290 Lisp_Object where, current_buffer;
@@ -3296,7 +3295,7 @@ specbind (symbol, value)
3296 buffer's or frame's value we are saving. */ 3295 buffer's or frame's value we are saving. */
3297 if (!NILP (Flocal_variable_p (symbol, Qnil))) 3296 if (!NILP (Flocal_variable_p (symbol, Qnil)))
3298 where = current_buffer; 3297 where = current_buffer;
3299 else if (!BUFFER_OBJFWDP (valcontents) 3298 else if (BUFFER_LOCAL_VALUEP (valcontents)
3300 && XBUFFER_LOCAL_VALUE (valcontents)->found_for_frame) 3299 && XBUFFER_LOCAL_VALUE (valcontents)->found_for_frame)
3301 where = XBUFFER_LOCAL_VALUE (valcontents)->frame; 3300 where = XBUFFER_LOCAL_VALUE (valcontents)->frame;
3302 else 3301 else
diff --git a/src/frame.c b/src/frame.c
index ff860d83509..090de96cebd 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -2289,8 +2289,7 @@ store_frame_param (f, prop, val)
2289 { 2289 {
2290 Lisp_Object valcontents; 2290 Lisp_Object valcontents;
2291 valcontents = SYMBOL_VALUE (prop); 2291 valcontents = SYMBOL_VALUE (prop);
2292 if ((BUFFER_LOCAL_VALUEP (valcontents) 2292 if ((BUFFER_LOCAL_VALUEP (valcontents))
2293 || SOME_BUFFER_LOCAL_VALUEP (valcontents))
2294 && XBUFFER_LOCAL_VALUE (valcontents)->check_frame 2293 && XBUFFER_LOCAL_VALUE (valcontents)->check_frame
2295 && XBUFFER_LOCAL_VALUE (valcontents)->found_for_frame 2294 && XBUFFER_LOCAL_VALUE (valcontents)->found_for_frame
2296 && XFRAME (XBUFFER_LOCAL_VALUE (valcontents)->frame) == f) 2295 && XFRAME (XBUFFER_LOCAL_VALUE (valcontents)->frame) == f)
diff --git a/src/lisp.h b/src/lisp.h
index 70329a07764..74957e9fe18 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -214,7 +214,6 @@ enum Lisp_Misc_Type
214 Lisp_Misc_Objfwd, 214 Lisp_Misc_Objfwd,
215 Lisp_Misc_Buffer_Objfwd, 215 Lisp_Misc_Buffer_Objfwd,
216 Lisp_Misc_Buffer_Local_Value, 216 Lisp_Misc_Buffer_Local_Value,
217 Lisp_Misc_Some_Buffer_Local_Value,
218 Lisp_Misc_Overlay, 217 Lisp_Misc_Overlay,
219 Lisp_Misc_Kboard_Objfwd, 218 Lisp_Misc_Kboard_Objfwd,
220 Lisp_Misc_Save_Value, 219 Lisp_Misc_Save_Value,
@@ -522,7 +521,8 @@ extern size_t pure_size;
522/* Misc types. */ 521/* Misc types. */
523 522
524#define XMISC(a) ((union Lisp_Misc *) XPNTR(a)) 523#define XMISC(a) ((union Lisp_Misc *) XPNTR(a))
525#define XMISCTYPE(a) (XMARKER (a)->type) 524#define XMISCANY(a) (&(XMISC(a)->u_any))
525#define XMISCTYPE(a) (XMISCANY (a)->type)
526#define XMARKER(a) (&(XMISC(a)->u_marker)) 526#define XMARKER(a) (&(XMISC(a)->u_marker))
527#define XINTFWD(a) (&(XMISC(a)->u_intfwd)) 527#define XINTFWD(a) (&(XMISC(a)->u_intfwd))
528#define XBOOLFWD(a) (&(XMISC(a)->u_boolfwd)) 528#define XBOOLFWD(a) (&(XMISC(a)->u_boolfwd))
@@ -1124,6 +1124,13 @@ struct Lisp_Hash_Table
1124 1124
1125/* These structures are used for various misc types. */ 1125/* These structures are used for various misc types. */
1126 1126
1127struct Lisp_Misc_Any /* Supertype of all Misc types. */
1128{
1129 int type : 16; /* = Lisp_Misc_Marker */
1130 unsigned gcmarkbit : 1;
1131 int spacer : 15;
1132};
1133
1127struct Lisp_Marker 1134struct Lisp_Marker
1128{ 1135{
1129 int type : 16; /* = Lisp_Misc_Marker */ 1136 int type : 16; /* = Lisp_Misc_Marker */
@@ -1224,19 +1231,19 @@ struct Lisp_Buffer_Objfwd
1224 binding into `realvalue' (or through it). Also update 1231 binding into `realvalue' (or through it). Also update
1225 LOADED-BINDING to point to the newly loaded binding. 1232 LOADED-BINDING to point to the newly loaded binding.
1226 1233
1227 Lisp_Misc_Buffer_Local_Value and Lisp_Misc_Some_Buffer_Local_Value 1234 `local_if_set' indicates that merely setting the variable creates a local
1228 both use this kind of structure. With the former, merely setting 1235 binding for the current buffer. Otherwise the latter, setting the
1229 the variable creates a local binding for the current buffer. With 1236 variable does not do that; only make-local-variable does that. */
1230 the latter, setting the variable does not do that; only
1231 make-local-variable does that. */
1232 1237
1233struct Lisp_Buffer_Local_Value 1238struct Lisp_Buffer_Local_Value
1234 { 1239 {
1235 int type : 16; /* = Lisp_Misc_Buffer_Local_Value 1240 int type : 16; /* = Lisp_Misc_Buffer_Local_Value */
1236 or Lisp_Misc_Some_Buffer_Local_Value */
1237 unsigned gcmarkbit : 1; 1241 unsigned gcmarkbit : 1;
1238 int spacer : 12; 1242 int spacer : 11;
1239 1243
1244 /* 1 means that merely setting the variable creates a local
1245 binding for the current buffer */
1246 unsigned int local_if_set : 1;
1240 /* 1 means this variable is allowed to have frame-local bindings, 1247 /* 1 means this variable is allowed to have frame-local bindings,
1241 so check for them when looking for the proper binding. */ 1248 so check for them when looking for the proper binding. */
1242 unsigned int check_frame : 1; 1249 unsigned int check_frame : 1;
@@ -1326,7 +1333,8 @@ struct Lisp_Free
1326 1333
1327union Lisp_Misc 1334union Lisp_Misc
1328 { 1335 {
1329 struct Lisp_Free u_free; 1336 struct Lisp_Misc_Any u_any; /* Supertype of all Misc types. */
1337 struct Lisp_Free u_free; /* Includes padding to force alignment. */
1330 struct Lisp_Marker u_marker; 1338 struct Lisp_Marker u_marker;
1331 struct Lisp_Intfwd u_intfwd; 1339 struct Lisp_Intfwd u_intfwd;
1332 struct Lisp_Boolfwd u_boolfwd; 1340 struct Lisp_Boolfwd u_boolfwd;
diff --git a/src/print.c b/src/print.c
index ccb2d6e8c45..56880eb4bf1 100644
--- a/src/print.c
+++ b/src/print.c
@@ -2145,10 +2145,8 @@ print_object (obj, printcharfun, escapeflag)
2145 2145
2146 case Lisp_Misc_Buffer_Local_Value: 2146 case Lisp_Misc_Buffer_Local_Value:
2147 strout ("#<buffer_local_value ", -1, -1, printcharfun, 0); 2147 strout ("#<buffer_local_value ", -1, -1, printcharfun, 0);
2148 goto do_buffer_local; 2148 if (XBUFFER_LOCAL_VALUE (obj)->local_if_set)
2149 case Lisp_Misc_Some_Buffer_Local_Value: 2149 strout ("[local-if-set] ", -1, -1, printcharfun, 0);
2150 strout ("#<some_buffer_local_value ", -1, -1, printcharfun, 0);
2151 do_buffer_local:
2152 strout ("[realvalue] ", -1, -1, printcharfun, 0); 2150 strout ("[realvalue] ", -1, -1, printcharfun, 0);
2153 print_object (XBUFFER_LOCAL_VALUE (obj)->realvalue, 2151 print_object (XBUFFER_LOCAL_VALUE (obj)->realvalue,
2154 printcharfun, escapeflag); 2152 printcharfun, escapeflag);
diff --git a/src/xdisp.c b/src/xdisp.c
index b907ea516d6..5bf4208ff64 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -10804,8 +10804,7 @@ select_frame_for_redisplay (frame)
10804 SYMBOLP (sym)) 10804 SYMBOLP (sym))
10805 && (sym = indirect_variable (sym), 10805 && (sym = indirect_variable (sym),
10806 val = SYMBOL_VALUE (sym), 10806 val = SYMBOL_VALUE (sym),
10807 (BUFFER_LOCAL_VALUEP (val) 10807 (BUFFER_LOCAL_VALUEP (val)))
10808 || SOME_BUFFER_LOCAL_VALUEP (val)))
10809 && XBUFFER_LOCAL_VALUE (val)->check_frame) 10808 && XBUFFER_LOCAL_VALUE (val)->check_frame)
10810 /* Use find_symbol_value rather than Fsymbol_value 10809 /* Use find_symbol_value rather than Fsymbol_value
10811 to avoid an error if it is void. */ 10810 to avoid an error if it is void. */
@@ -10817,8 +10816,7 @@ select_frame_for_redisplay (frame)
10817 SYMBOLP (sym)) 10816 SYMBOLP (sym))
10818 && (sym = indirect_variable (sym), 10817 && (sym = indirect_variable (sym),
10819 val = SYMBOL_VALUE (sym), 10818 val = SYMBOL_VALUE (sym),
10820 (BUFFER_LOCAL_VALUEP (val) 10819 (BUFFER_LOCAL_VALUEP (val)))
10821 || SOME_BUFFER_LOCAL_VALUEP (val)))
10822 && XBUFFER_LOCAL_VALUE (val)->check_frame) 10820 && XBUFFER_LOCAL_VALUE (val)->check_frame)
10823 find_symbol_value (sym); 10821 find_symbol_value (sym);
10824} 10822}