aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Antipov2012-08-17 18:24:43 +0400
committerDmitry Antipov2012-08-17 18:24:43 +0400
commita04e2c62ec8ce903310b7c7635c43f42ccab5e2f (patch)
tree79da6e7e7455731a813eb601a158057c66bdcee6
parent8223e9280fa69afeeae1a8b51735cbb8393f2e8d (diff)
downloademacs-a04e2c62ec8ce903310b7c7635c43f42ccab5e2f.tar.gz
emacs-a04e2c62ec8ce903310b7c7635c43f42ccab5e2f.zip
Functions to get and set Lisp_Object fields of buffer-local variables.
* lisp.h (blv_found, set_blv_found, blv_value, set_blv_value) (set_blv_where, set_blv_defcell, set_blv_valcell): New functions. (BLV_FOUND, SET_BLV_FOUND, BLV_VALUE, SET_BLV_VALUE): Remove. * data.c, eval.c, frame.c: Adjust users.
-rw-r--r--src/ChangeLog8
-rw-r--r--src/data.c58
-rw-r--r--src/eval.c4
-rw-r--r--src/frame.c2
-rw-r--r--src/lisp.h54
5 files changed, 84 insertions, 42 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 72a11c177c4..9ceaa95dcea 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,11 @@
12012-08-17 Dmitry Antipov <dmantipov@yandex.ru>
2
3 Functions to get and set Lisp_Object fields of buffer-local variables.
4 * lisp.h (blv_found, set_blv_found, blv_value, set_blv_value)
5 (set_blv_where, set_blv_defcell, set_blv_valcell): New functions.
6 (BLV_FOUND, SET_BLV_FOUND, BLV_VALUE, SET_BLV_VALUE): Remove.
7 * data.c, eval.c, frame.c: Adjust users.
8
12012-08-17 Chong Yidong <cyd@gnu.org> 92012-08-17 Chong Yidong <cyd@gnu.org>
2 10
3 * xfaces.c (merge_face_vectors): If the target font specfies a 11 * xfaces.c (merge_face_vectors): If the target font specfies a
diff --git a/src/data.c b/src/data.c
index d0ef5734abc..6cd3649d45f 100644
--- a/src/data.c
+++ b/src/data.c
@@ -543,7 +543,7 @@ DEFUN ("boundp", Fboundp, Sboundp, 1, 1, 0,
543 else 543 else
544 { 544 {
545 swap_in_symval_forwarding (sym, blv); 545 swap_in_symval_forwarding (sym, blv);
546 valcontents = BLV_VALUE (blv); 546 valcontents = blv_value (blv);
547 } 547 }
548 break; 548 break;
549 } 549 }
@@ -964,16 +964,16 @@ swap_in_global_binding (struct Lisp_Symbol *symbol)
964 964
965 /* Unload the previously loaded binding. */ 965 /* Unload the previously loaded binding. */
966 if (blv->fwd) 966 if (blv->fwd)
967 SET_BLV_VALUE (blv, do_symval_forwarding (blv->fwd)); 967 set_blv_value (blv, do_symval_forwarding (blv->fwd));
968 968
969 /* Select the global binding in the symbol. */ 969 /* Select the global binding in the symbol. */
970 blv->valcell = blv->defcell; 970 set_blv_valcell (blv, blv->defcell);
971 if (blv->fwd) 971 if (blv->fwd)
972 store_symval_forwarding (blv->fwd, XCDR (blv->defcell), NULL); 972 store_symval_forwarding (blv->fwd, XCDR (blv->defcell), NULL);
973 973
974 /* Indicate that the global binding is set up now. */ 974 /* Indicate that the global binding is set up now. */
975 blv->where = Qnil; 975 set_blv_where (blv, Qnil);
976 SET_BLV_FOUND (blv, 0); 976 set_blv_found (blv, 0);
977} 977}
978 978
979/* Set up the buffer-local symbol SYMBOL for validity in the current buffer. 979/* Set up the buffer-local symbol SYMBOL for validity in the current buffer.
@@ -1001,7 +1001,7 @@ swap_in_symval_forwarding (struct Lisp_Symbol *symbol, struct Lisp_Buffer_Local_
1001 /* Unload the previously loaded binding. */ 1001 /* Unload the previously loaded binding. */
1002 tem1 = blv->valcell; 1002 tem1 = blv->valcell;
1003 if (blv->fwd) 1003 if (blv->fwd)
1004 SET_BLV_VALUE (blv, do_symval_forwarding (blv->fwd)); 1004 set_blv_value (blv, do_symval_forwarding (blv->fwd));
1005 /* Choose the new binding. */ 1005 /* Choose the new binding. */
1006 { 1006 {
1007 Lisp_Object var; 1007 Lisp_Object var;
@@ -1009,7 +1009,7 @@ swap_in_symval_forwarding (struct Lisp_Symbol *symbol, struct Lisp_Buffer_Local_
1009 if (blv->frame_local) 1009 if (blv->frame_local)
1010 { 1010 {
1011 tem1 = assq_no_quit (var, XFRAME (selected_frame)->param_alist); 1011 tem1 = assq_no_quit (var, XFRAME (selected_frame)->param_alist);
1012 blv->where = selected_frame; 1012 set_blv_where (blv, selected_frame);
1013 } 1013 }
1014 else 1014 else
1015 { 1015 {
@@ -1021,9 +1021,9 @@ swap_in_symval_forwarding (struct Lisp_Symbol *symbol, struct Lisp_Buffer_Local_
1021 tem1 = blv->defcell; 1021 tem1 = blv->defcell;
1022 1022
1023 /* Load the new binding. */ 1023 /* Load the new binding. */
1024 blv->valcell = tem1; 1024 set_blv_valcell (blv, tem1);
1025 if (blv->fwd) 1025 if (blv->fwd)
1026 store_symval_forwarding (blv->fwd, BLV_VALUE (blv), NULL); 1026 store_symval_forwarding (blv->fwd, blv_value (blv), NULL);
1027 } 1027 }
1028} 1028}
1029 1029
@@ -1050,7 +1050,7 @@ find_symbol_value (Lisp_Object symbol)
1050 { 1050 {
1051 struct Lisp_Buffer_Local_Value *blv = SYMBOL_BLV (sym); 1051 struct Lisp_Buffer_Local_Value *blv = SYMBOL_BLV (sym);
1052 swap_in_symval_forwarding (sym, blv); 1052 swap_in_symval_forwarding (sym, blv);
1053 return blv->fwd ? do_symval_forwarding (blv->fwd) : BLV_VALUE (blv); 1053 return blv->fwd ? do_symval_forwarding (blv->fwd) : blv_value (blv);
1054 } 1054 }
1055 /* FALLTHROUGH */ 1055 /* FALLTHROUGH */
1056 case SYMBOL_FORWARDED: 1056 case SYMBOL_FORWARDED:
@@ -1175,7 +1175,7 @@ set_internal (register Lisp_Object symbol, register Lisp_Object newval, register
1175 1175
1176 /* Write out `realvalue' to the old loaded binding. */ 1176 /* Write out `realvalue' to the old loaded binding. */
1177 if (blv->fwd) 1177 if (blv->fwd)
1178 SET_BLV_VALUE (blv, do_symval_forwarding (blv->fwd)); 1178 set_blv_value (blv, do_symval_forwarding (blv->fwd));
1179 1179
1180 /* Find the new binding. */ 1180 /* Find the new binding. */
1181 XSETSYMBOL (symbol, sym); /* May have changed via aliasing. */ 1181 XSETSYMBOL (symbol, sym); /* May have changed via aliasing. */
@@ -1183,8 +1183,8 @@ set_internal (register Lisp_Object symbol, register Lisp_Object newval, register
1183 (blv->frame_local 1183 (blv->frame_local
1184 ? XFRAME (where)->param_alist 1184 ? XFRAME (where)->param_alist
1185 : BVAR (XBUFFER (where), local_var_alist))); 1185 : BVAR (XBUFFER (where), local_var_alist)));
1186 blv->where = where; 1186 set_blv_where (blv, where);
1187 blv->found = 1; 1187 set_blv_found (blv, 1);
1188 1188
1189 if (NILP (tem1)) 1189 if (NILP (tem1))
1190 { 1190 {
@@ -1199,7 +1199,7 @@ set_internal (register Lisp_Object symbol, register Lisp_Object newval, register
1199 if (bindflag || !blv->local_if_set 1199 if (bindflag || !blv->local_if_set
1200 || let_shadows_buffer_binding_p (sym)) 1200 || let_shadows_buffer_binding_p (sym))
1201 { 1201 {
1202 blv->found = 0; 1202 set_blv_found (blv, 0);
1203 tem1 = blv->defcell; 1203 tem1 = blv->defcell;
1204 } 1204 }
1205 /* If it's a local_if_set, being set not bound, 1205 /* If it's a local_if_set, being set not bound,
@@ -1219,11 +1219,11 @@ set_internal (register Lisp_Object symbol, register Lisp_Object newval, register
1219 } 1219 }
1220 1220
1221 /* Record which binding is now loaded. */ 1221 /* Record which binding is now loaded. */
1222 blv->valcell = tem1; 1222 set_blv_valcell (blv, tem1);
1223 } 1223 }
1224 1224
1225 /* Store the new value in the cons cell. */ 1225 /* Store the new value in the cons cell. */
1226 SET_BLV_VALUE (blv, newval); 1226 set_blv_value (blv, newval);
1227 1227
1228 if (blv->fwd) 1228 if (blv->fwd)
1229 { 1229 {
@@ -1479,12 +1479,12 @@ make_blv (struct Lisp_Symbol *sym, int forwarded, union Lisp_Val_Fwd valcontents
1479 eassert (!(forwarded && BUFFER_OBJFWDP (valcontents.fwd))); 1479 eassert (!(forwarded && BUFFER_OBJFWDP (valcontents.fwd)));
1480 eassert (!(forwarded && KBOARD_OBJFWDP (valcontents.fwd))); 1480 eassert (!(forwarded && KBOARD_OBJFWDP (valcontents.fwd)));
1481 blv->fwd = forwarded ? valcontents.fwd : NULL; 1481 blv->fwd = forwarded ? valcontents.fwd : NULL;
1482 blv->where = Qnil; 1482 set_blv_where (blv, Qnil);
1483 blv->frame_local = 0; 1483 blv->frame_local = 0;
1484 blv->local_if_set = 0; 1484 blv->local_if_set = 0;
1485 blv->defcell = tem; 1485 set_blv_defcell (blv, tem);
1486 blv->valcell = tem; 1486 set_blv_valcell (blv, tem);
1487 SET_BLV_FOUND (blv, 0); 1487 set_blv_found (blv, 0);
1488 return blv; 1488 return blv;
1489} 1489}
1490 1490
@@ -1660,10 +1660,8 @@ Instead, use `add-hook' and specify t for the LOCAL argument. */)
1660 /* Make sure symbol does not think it is set up for this buffer; 1660 /* Make sure symbol does not think it is set up for this buffer;
1661 force it to look once again for this buffer's value. */ 1661 force it to look once again for this buffer's value. */
1662 if (current_buffer == XBUFFER (blv->where)) 1662 if (current_buffer == XBUFFER (blv->where))
1663 blv->where = Qnil; 1663 set_blv_where (blv, Qnil);
1664 /* blv->valcell = blv->defcell; 1664 set_blv_found (blv, 0);
1665 * SET_BLV_FOUND (blv, 0); */
1666 blv->found = 0;
1667 } 1665 }
1668 1666
1669 /* If the symbol forwards into a C variable, then load the binding 1667 /* If the symbol forwards into a C variable, then load the binding
@@ -1733,10 +1731,8 @@ From now on the default value will apply in this buffer. Return VARIABLE. */)
1733 Lisp_Object buf; XSETBUFFER (buf, current_buffer); 1731 Lisp_Object buf; XSETBUFFER (buf, current_buffer);
1734 if (EQ (buf, blv->where)) 1732 if (EQ (buf, blv->where))
1735 { 1733 {
1736 blv->where = Qnil; 1734 set_blv_where (blv, Qnil);
1737 /* blv->valcell = blv->defcell; 1735 set_blv_found (blv, 0);
1738 * SET_BLV_FOUND (blv, 0); */
1739 blv->found = 0;
1740 find_symbol_value (variable); 1736 find_symbol_value (variable);
1741 } 1737 }
1742 } 1738 }
@@ -1857,11 +1853,11 @@ BUFFER defaults to the current buffer. */)
1857 if (EQ (variable, XCAR (elt))) 1853 if (EQ (variable, XCAR (elt)))
1858 { 1854 {
1859 eassert (!blv->frame_local); 1855 eassert (!blv->frame_local);
1860 eassert (BLV_FOUND (blv) || !EQ (blv->where, tmp)); 1856 eassert (blv_found (blv) || !EQ (blv->where, tmp));
1861 return Qt; 1857 return Qt;
1862 } 1858 }
1863 } 1859 }
1864 eassert (!BLV_FOUND (blv) || !EQ (blv->where, tmp)); 1860 eassert (!blv_found (blv) || !EQ (blv->where, tmp));
1865 return Qnil; 1861 return Qnil;
1866 } 1862 }
1867 case SYMBOL_FORWARDED: 1863 case SYMBOL_FORWARDED:
@@ -1951,7 +1947,7 @@ If the current binding is global (the default), the value is nil. */)
1951 if (!NILP (Flocal_variable_p (variable, Qnil))) 1947 if (!NILP (Flocal_variable_p (variable, Qnil)))
1952 return Fcurrent_buffer (); 1948 return Fcurrent_buffer ();
1953 else if (sym->redirect == SYMBOL_LOCALIZED 1949 else if (sym->redirect == SYMBOL_LOCALIZED
1954 && BLV_FOUND (SYMBOL_BLV (sym))) 1950 && blv_found (SYMBOL_BLV (sym)))
1955 return SYMBOL_BLV (sym)->where; 1951 return SYMBOL_BLV (sym)->where;
1956 else 1952 else
1957 return Qnil; 1953 return Qnil;
diff --git a/src/eval.c b/src/eval.c
index f3f14d60e1c..771cd7b160a 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -3169,12 +3169,12 @@ specbind (Lisp_Object symbol, Lisp_Object value)
3169 if (!NILP (Flocal_variable_p (symbol, Qnil))) 3169 if (!NILP (Flocal_variable_p (symbol, Qnil)))
3170 { 3170 {
3171 eassert (sym->redirect != SYMBOL_LOCALIZED 3171 eassert (sym->redirect != SYMBOL_LOCALIZED
3172 || (BLV_FOUND (SYMBOL_BLV (sym)) 3172 || (blv_found (SYMBOL_BLV (sym))
3173 && EQ (cur_buf, SYMBOL_BLV (sym)->where))); 3173 && EQ (cur_buf, SYMBOL_BLV (sym)->where)));
3174 where = cur_buf; 3174 where = cur_buf;
3175 } 3175 }
3176 else if (sym->redirect == SYMBOL_LOCALIZED 3176 else if (sym->redirect == SYMBOL_LOCALIZED
3177 && BLV_FOUND (SYMBOL_BLV (sym))) 3177 && blv_found (SYMBOL_BLV (sym)))
3178 where = SYMBOL_BLV (sym)->where; 3178 where = SYMBOL_BLV (sym)->where;
3179 else 3179 else
3180 where = Qnil; 3180 where = Qnil;
diff --git a/src/frame.c b/src/frame.c
index 9dabae55abc..f033ac21c24 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -2098,7 +2098,7 @@ store_frame_param (struct frame *f, Lisp_Object prop, Lisp_Object val)
2098 case SYMBOL_PLAINVAL: case SYMBOL_FORWARDED: break; 2098 case SYMBOL_PLAINVAL: case SYMBOL_FORWARDED: break;
2099 case SYMBOL_LOCALIZED: 2099 case SYMBOL_LOCALIZED:
2100 { struct Lisp_Buffer_Local_Value *blv = sym->val.blv; 2100 { struct Lisp_Buffer_Local_Value *blv = sym->val.blv;
2101 if (blv->frame_local && BLV_FOUND (blv) && XFRAME (blv->where) == f) 2101 if (blv->frame_local && blv_found (blv) && XFRAME (blv->where) == f)
2102 swap_in_global_binding (sym); 2102 swap_in_global_binding (sym);
2103 break; 2103 break;
2104 } 2104 }
diff --git a/src/lisp.h b/src/lisp.h
index 8ac01211a1f..827f2be06d0 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -1472,14 +1472,6 @@ struct Lisp_Buffer_Local_Value
1472 Lisp_Object valcell; 1472 Lisp_Object valcell;
1473 }; 1473 };
1474 1474
1475#define BLV_FOUND(blv) \
1476 (eassert ((blv)->found == !EQ ((blv)->defcell, (blv)->valcell)), (blv)->found)
1477#define SET_BLV_FOUND(blv, v) \
1478 (eassert ((v) == !EQ ((blv)->defcell, (blv)->valcell)), (blv)->found = (v))
1479
1480#define BLV_VALUE(blv) (XCDR ((blv)->valcell))
1481#define SET_BLV_VALUE(blv, v) (XSETCDR ((blv)->valcell, v))
1482
1483/* Like Lisp_Objfwd except that value lives in a slot in the 1475/* Like Lisp_Objfwd except that value lives in a slot in the
1484 current kboard. */ 1476 current kboard. */
1485struct Lisp_Kboard_Objfwd 1477struct Lisp_Kboard_Objfwd
@@ -2415,6 +2407,52 @@ set_symbol_next (Lisp_Object sym, struct Lisp_Symbol *next)
2415 XSYMBOL (sym)->next = next; 2407 XSYMBOL (sym)->next = next;
2416} 2408}
2417 2409
2410/* Buffer-local (also frame-local) variable access functions. */
2411
2412LISP_INLINE int
2413blv_found (struct Lisp_Buffer_Local_Value *blv)
2414{
2415 eassert (blv->found == !EQ (blv->defcell, blv->valcell));
2416 return blv->found;
2417}
2418
2419LISP_INLINE void
2420set_blv_found (struct Lisp_Buffer_Local_Value *blv, int found)
2421{
2422 eassert (found == !EQ (blv->defcell, blv->valcell));
2423 blv->found = found;
2424}
2425
2426LISP_INLINE Lisp_Object
2427blv_value (struct Lisp_Buffer_Local_Value *blv)
2428{
2429 return XCDR (blv->valcell);
2430}
2431
2432LISP_INLINE void
2433set_blv_value (struct Lisp_Buffer_Local_Value *blv, Lisp_Object val)
2434{
2435 XSETCDR (blv->valcell, val);
2436}
2437
2438LISP_INLINE void
2439set_blv_where (struct Lisp_Buffer_Local_Value *blv, Lisp_Object val)
2440{
2441 blv->where = val;
2442}
2443
2444LISP_INLINE void
2445set_blv_defcell (struct Lisp_Buffer_Local_Value *blv, Lisp_Object val)
2446{
2447 blv->defcell = val;
2448}
2449
2450LISP_INLINE void
2451set_blv_valcell (struct Lisp_Buffer_Local_Value *blv, Lisp_Object val)
2452{
2453 blv->valcell = val;
2454}
2455
2418/* Set overlay's property list. */ 2456/* Set overlay's property list. */
2419 2457
2420LISP_INLINE void 2458LISP_INLINE void