Mercurial > hg > xemacs-beta
comparison src/symbols.c @ 173:8eaf7971accc r20-3b13
Import from CVS: tag r20-3b13
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:49:09 +0200 |
parents | 85ec50267440 |
children | e121b013d1f0 |
comparison
equal
deleted
inserted
replaced
172:a38aed19690b | 173:8eaf7971accc |
---|---|
103 ((markobj) (sym->value)); | 103 ((markobj) (sym->value)); |
104 ((markobj) (sym->function)); | 104 ((markobj) (sym->function)); |
105 XSETSTRING (pname, sym->name); | 105 XSETSTRING (pname, sym->name); |
106 ((markobj) (pname)); | 106 ((markobj) (pname)); |
107 if (!symbol_next (sym)) | 107 if (!symbol_next (sym)) |
108 return (sym->plist); | 108 return sym->plist; |
109 else | 109 else |
110 { | 110 { |
111 ((markobj) (sym->plist)); | 111 ((markobj) (sym->plist)); |
112 /* Mark the rest of the symbols in the obarray hash-chain */ | 112 /* Mark the rest of the symbols in the obarray hash-chain */ |
113 sym = symbol_next (sym); | 113 sym = symbol_next (sym); |
114 XSETSYMBOL (obj, sym); | 114 XSETSYMBOL (obj, sym); |
115 return (obj); | 115 return obj; |
116 } | 116 } |
117 } | 117 } |
118 | 118 |
119 #endif /* LRECORD_SYMBOL */ | 119 #endif /* LRECORD_SYMBOL */ |
120 | 120 |
134 static int oblookup_last_bucket_number; | 134 static int oblookup_last_bucket_number; |
135 | 135 |
136 static Lisp_Object | 136 static Lisp_Object |
137 check_obarray (Lisp_Object obarray) | 137 check_obarray (Lisp_Object obarray) |
138 { | 138 { |
139 while (!VECTORP (obarray) || vector_length (XVECTOR (obarray)) == 0) | 139 while (!VECTORP (obarray) || XVECTOR_LENGTH (obarray) == 0) |
140 { | 140 { |
141 /* If Vobarray is now invalid, force it to be valid. */ | 141 /* If Vobarray is now invalid, force it to be valid. */ |
142 if (EQ (Vobarray, obarray)) Vobarray = initial_obarray; | 142 if (EQ (Vobarray, obarray)) Vobarray = initial_obarray; |
143 | 143 |
144 obarray = wrong_type_argument (Qvectorp, obarray); | 144 obarray = wrong_type_argument (Qvectorp, obarray); |
150 intern (CONST char *str) | 150 intern (CONST char *str) |
151 { | 151 { |
152 Lisp_Object tem; | 152 Lisp_Object tem; |
153 Bytecount len = strlen (str); | 153 Bytecount len = strlen (str); |
154 Lisp_Object obarray = Vobarray; | 154 Lisp_Object obarray = Vobarray; |
155 if (!VECTORP (obarray) || vector_length (XVECTOR (obarray)) == 0) | 155 if (!VECTORP (obarray) || XVECTOR_LENGTH (obarray) == 0) |
156 obarray = check_obarray (obarray); | 156 obarray = check_obarray (obarray); |
157 tem = oblookup (obarray, (CONST Bufbyte *) str, len); | 157 tem = oblookup (obarray, (CONST Bufbyte *) str, len); |
158 | 158 |
159 if (SYMBOLP (tem)) | 159 if (SYMBOLP (tem)) |
160 return tem; | 160 return tem; |
161 return Fintern (((purify_flag) | 161 return Fintern (((purify_flag) |
162 ? make_pure_pname ((CONST Bufbyte *) str, len, 0) | 162 ? make_pure_pname ((CONST Bufbyte *) str, len, 0) |
163 : make_string ((CONST Bufbyte *) str, len)), | 163 : make_string ((CONST Bufbyte *) str, len)), |
184 sym = oblookup (obarray, XSTRING_DATA (str), len); | 184 sym = oblookup (obarray, XSTRING_DATA (str), len); |
185 if (!INTP (sym)) | 185 if (!INTP (sym)) |
186 /* Found it */ | 186 /* Found it */ |
187 return sym; | 187 return sym; |
188 | 188 |
189 ptr = &vector_data (XVECTOR (obarray))[XINT (sym)]; | 189 ptr = &XVECTOR_DATA (obarray)[XINT (sym)]; |
190 | 190 |
191 if (purify_flag && ! purified (str)) | 191 if (purify_flag && ! purified (str)) |
192 str = make_pure_pname (XSTRING_DATA (str), len, 0); | 192 str = make_pure_pname (XSTRING_DATA (str), len, 0); |
193 sym = Fmake_symbol (str); | 193 sym = Fmake_symbol (str); |
194 | 194 |
250 if (SYMBOLP (name) && !EQ (name, tem)) | 250 if (SYMBOLP (name) && !EQ (name, tem)) |
251 return Qnil; | 251 return Qnil; |
252 | 252 |
253 hash = oblookup_last_bucket_number; | 253 hash = oblookup_last_bucket_number; |
254 | 254 |
255 if (EQ (XVECTOR (obarray)->contents[hash], tem)) | 255 if (EQ (XVECTOR_DATA (obarray)[hash], tem)) |
256 { | 256 { |
257 if (XSYMBOL (tem)->next) | 257 if (XSYMBOL (tem)->next) |
258 XSETSYMBOL (XVECTOR (obarray)->contents[hash], XSYMBOL (tem)->next); | 258 XSETSYMBOL (XVECTOR_DATA (obarray)[hash], XSYMBOL (tem)->next); |
259 else | 259 else |
260 XVECTOR (obarray)->contents[hash] = Qzero; | 260 XVECTOR_DATA (obarray)[hash] = Qzero; |
261 } | 261 } |
262 else | 262 else |
263 { | 263 { |
264 Lisp_Object tail, following; | 264 Lisp_Object tail, following; |
265 | 265 |
266 for (tail = XVECTOR (obarray)->contents[hash]; | 266 for (tail = XVECTOR_DATA (obarray)[hash]; |
267 XSYMBOL (tail)->next; | 267 XSYMBOL (tail)->next; |
268 tail = following) | 268 tail = following) |
269 { | 269 { |
270 XSETSYMBOL (following, XSYMBOL (tail)->next); | 270 XSETSYMBOL (following, XSYMBOL (tail)->next); |
271 if (EQ (following, tem)) | 271 if (EQ (following, tem)) |
291 int hash, obsize; | 291 int hash, obsize; |
292 struct Lisp_Symbol *tail; | 292 struct Lisp_Symbol *tail; |
293 Lisp_Object bucket; | 293 Lisp_Object bucket; |
294 | 294 |
295 if (!VECTORP (obarray) || | 295 if (!VECTORP (obarray) || |
296 (obsize = vector_length (XVECTOR (obarray))) == 0) | 296 (obsize = XVECTOR_LENGTH (obarray)) == 0) |
297 { | 297 { |
298 obarray = check_obarray (obarray); | 298 obarray = check_obarray (obarray); |
299 obsize = vector_length (XVECTOR (obarray)); | 299 obsize = XVECTOR_LENGTH (obarray); |
300 } | 300 } |
301 #if 0 /* FSFmacs */ | 301 #if 0 /* FSFmacs */ |
302 /* #### Huh? */ | 302 /* #### Huh? */ |
303 /* This is sometimes needed in the middle of GC. */ | 303 /* This is sometimes needed in the middle of GC. */ |
304 obsize &= ~ARRAY_MARK_FLAG; | 304 obsize &= ~ARRAY_MARK_FLAG; |
305 #endif | 305 #endif |
306 /* Combining next two lines breaks VMS C 2.3. */ | 306 /* Combining next two lines breaks VMS C 2.3. */ |
307 hash = hash_string (ptr, size); | 307 hash = hash_string (ptr, size); |
308 hash %= obsize; | 308 hash %= obsize; |
309 bucket = vector_data (XVECTOR (obarray))[hash]; | 309 bucket = XVECTOR_DATA (obarray)[hash]; |
310 oblookup_last_bucket_number = hash; | 310 oblookup_last_bucket_number = hash; |
311 if (ZEROP (bucket)) | 311 if (ZEROP (bucket)) |
312 ; | 312 ; |
313 else if (!SYMBOLP (bucket)) | 313 else if (!SYMBOLP (bucket)) |
314 error ("Bad data in guts of obarray"); /* Like CADR error message */ | 314 error ("Bad data in guts of obarray"); /* Like CADR error message */ |
317 { | 317 { |
318 if (string_length (tail->name) == size && | 318 if (string_length (tail->name) == size && |
319 !memcmp (string_data (tail->name), ptr, size)) | 319 !memcmp (string_data (tail->name), ptr, size)) |
320 { | 320 { |
321 XSETSYMBOL (bucket, tail); | 321 XSETSYMBOL (bucket, tail); |
322 return (bucket); | 322 return bucket; |
323 } | 323 } |
324 tail = symbol_next (tail); | 324 tail = symbol_next (tail); |
325 if (!tail) | 325 if (!tail) |
326 break; | 326 break; |
327 } | 327 } |
328 return (make_int (hash)); | 328 return make_int (hash); |
329 } | 329 } |
330 | 330 |
331 #if 0 /* Emacs 19.34 */ | 331 #if 0 /* Emacs 19.34 */ |
332 int | 332 int |
333 hash_string (CONST Bufbyte *ptr, Bytecount len) | 333 hash_string (CONST Bufbyte *ptr, Bytecount len) |
356 Bytecount count = len; | 356 Bytecount count = len; |
357 | 357 |
358 while (count-- > 0) | 358 while (count-- > 0) |
359 { | 359 { |
360 hash = (hash << 4) + *p++; | 360 hash = (hash << 4) + *p++; |
361 if (g = (hash & 0xf0000000)) { | 361 if ((g = (hash & 0xf0000000))) { |
362 hash = hash ^ (g >> 24); | 362 hash = hash ^ (g >> 24); |
363 hash = hash ^ g; | 363 hash = hash ^ g; |
364 } | 364 } |
365 } | 365 } |
366 return hash & 07777777777; | 366 return hash & 07777777777; |
370 map_obarray (Lisp_Object obarray, | 370 map_obarray (Lisp_Object obarray, |
371 void (*fn) (Lisp_Object sym, Lisp_Object arg), | 371 void (*fn) (Lisp_Object sym, Lisp_Object arg), |
372 Lisp_Object arg) | 372 Lisp_Object arg) |
373 { | 373 { |
374 REGISTER int i; | 374 REGISTER int i; |
375 REGISTER Lisp_Object tail; | 375 Lisp_Object tail; |
376 CHECK_VECTOR (obarray); | 376 CHECK_VECTOR (obarray); |
377 for (i = vector_length (XVECTOR (obarray)) - 1; i >= 0; i--) | 377 for (i = XVECTOR_LENGTH (obarray) - 1; i >= 0; i--) |
378 { | 378 { |
379 tail = vector_data (XVECTOR (obarray))[i]; | 379 tail = XVECTOR_DATA (obarray)[i]; |
380 if (SYMBOLP (tail)) | 380 if (SYMBOLP (tail)) |
381 while (1) | 381 while (1) |
382 { | 382 { |
383 struct Lisp_Symbol *next; | 383 struct Lisp_Symbol *next; |
384 (*fn) (tail, arg); | 384 (*fn) (tail, arg); |
447 accumulation = Fcons (string, Fcons (pred, Qnil)); | 447 accumulation = Fcons (string, Fcons (pred, Qnil)); |
448 GCPRO1 (accumulation); | 448 GCPRO1 (accumulation); |
449 map_obarray (Vobarray, apropos_accum, accumulation); | 449 map_obarray (Vobarray, apropos_accum, accumulation); |
450 accumulation = Fsort (Fcdr (Fcdr (accumulation)), Qstring_lessp); | 450 accumulation = Fsort (Fcdr (Fcdr (accumulation)), Qstring_lessp); |
451 UNGCPRO; | 451 UNGCPRO; |
452 return (accumulation); | 452 return accumulation; |
453 } | 453 } |
454 | 454 |
455 | 455 |
456 /* Extract and set components of symbols */ | 456 /* Extract and set components of symbols */ |
457 | 457 |
458 static void set_up_buffer_local_cache (Lisp_Object sym, | 458 static void set_up_buffer_local_cache (Lisp_Object sym, |
459 struct symbol_value_buffer_local *bfwd, | 459 struct symbol_value_buffer_local *bfwd, |
460 struct buffer *buf, | 460 struct buffer *buf, |
461 Lisp_Object new_alist_el, | 461 Lisp_Object new_alist_el, |
462 int set_it_p); | 462 int set_it_p); |
463 | 463 |
465 T if SYMBOL's value is not void. | 465 T if SYMBOL's value is not void. |
466 */ | 466 */ |
467 (sym)) | 467 (sym)) |
468 { | 468 { |
469 CHECK_SYMBOL (sym); | 469 CHECK_SYMBOL (sym); |
470 return (UNBOUNDP (find_symbol_value (sym)) ? Qnil : Qt); | 470 return UNBOUNDP (find_symbol_value (sym)) ? Qnil : Qt; |
471 } | 471 } |
472 | 472 |
473 DEFUN ("globally-boundp", Fglobally_boundp, 1, 1, 0, /* | 473 DEFUN ("globally-boundp", Fglobally_boundp, 1, 1, 0, /* |
474 T if SYMBOL has a global (non-bound) value. | 474 T if SYMBOL has a global (non-bound) value. |
475 This is for the byte-compiler; you really shouldn't be using this. | 475 This is for the byte-compiler; you really shouldn't be using this. |
476 */ | 476 */ |
477 (sym)) | 477 (sym)) |
478 { | 478 { |
479 CHECK_SYMBOL (sym); | 479 CHECK_SYMBOL (sym); |
480 return (UNBOUNDP (top_level_value (sym)) ? Qnil : Qt); | 480 return UNBOUNDP (top_level_value (sym)) ? Qnil : Qt; |
481 } | 481 } |
482 | 482 |
483 DEFUN ("fboundp", Ffboundp, 1, 1, 0, /* | 483 DEFUN ("fboundp", Ffboundp, 1, 1, 0, /* |
484 T if SYMBOL's function definition is not void. | 484 T if SYMBOL's function definition is not void. |
485 */ | 485 */ |
486 (sym)) | 486 (sym)) |
487 { | 487 { |
488 CHECK_SYMBOL (sym); | 488 CHECK_SYMBOL (sym); |
489 return ((UNBOUNDP (XSYMBOL (sym)->function)) ? Qnil : Qt); | 489 return (UNBOUNDP (XSYMBOL (sym)->function)) ? Qnil : Qt; |
490 } | 490 } |
491 | 491 |
492 /* Return non-zero if SYM's value or function (the current contents of | 492 /* Return non-zero if SYM's value or function (the current contents of |
493 which should be passed in as VAL) is constant, i.e. unsettable. */ | 493 which should be passed in as VAL) is constant, i.e. unsettable. */ |
494 | 494 |
565 but I don't want to consider that right now. */ | 565 but I don't want to consider that right now. */ |
566 (SYMBOL_VALUE_MAGIC_P (val) && | 566 (SYMBOL_VALUE_MAGIC_P (val) && |
567 XSYMBOL_VALUE_MAGIC_TYPE (val) == | 567 XSYMBOL_VALUE_MAGIC_TYPE (val) == |
568 SYMVAL_SELECTED_CONSOLE_FORWARD) | 568 SYMVAL_SELECTED_CONSOLE_FORWARD) |
569 ) | 569 ) |
570 signal_error (Qerror, | 570 signal_error (Qerror, |
571 list2 (build_string ("Symbol may not be buffer-local"), | 571 list2 (build_string ("Symbol may not be buffer-local"), |
572 sym)); | 572 sym)); |
573 } | 573 } |
574 | 574 |
575 DEFUN ("makunbound", Fmakunbound, 1, 1, 0, /* | 575 DEFUN ("makunbound", Fmakunbound, 1, 1, 0, /* |
793 However, calling `make-local-variable' or | 793 However, calling `make-local-variable' or |
794 `make-variable-buffer-local' on one of these variables | 794 `make-variable-buffer-local' on one of these variables |
795 is currently disallowed because that would entail having | 795 is currently disallowed because that would entail having |
796 both console-local and buffer-local variables, which is | 796 both console-local and buffer-local variables, which is |
797 trickier to implement. | 797 trickier to implement. |
798 | 798 |
799 SYMVAL_CONST_SELECTED_CONSOLE_FORWARD: | 799 SYMVAL_CONST_SELECTED_CONSOLE_FORWARD: |
800 (declare with DEFVAR_CONST_CONSOLE_LOCAL) | 800 (declare with DEFVAR_CONST_CONSOLE_LOCAL) |
801 Same as SYMVAL_SELECTED_CONSOLE_FORWARD except that the | 801 Same as SYMVAL_SELECTED_CONSOLE_FORWARD except that the |
802 value cannot be set. | 802 value cannot be set. |
803 | 803 |
878 this_one_is_unmarkable, | 878 this_one_is_unmarkable, |
879 print_symbol_value_magic, 0, 0, 0, | 879 print_symbol_value_magic, 0, 0, 0, |
880 struct symbol_value_forward); | 880 struct symbol_value_forward); |
881 | 881 |
882 DEFINE_LRECORD_IMPLEMENTATION ("symbol-value-buffer-local", | 882 DEFINE_LRECORD_IMPLEMENTATION ("symbol-value-buffer-local", |
883 symbol_value_buffer_local, | 883 symbol_value_buffer_local, |
884 mark_symbol_value_buffer_local, | 884 mark_symbol_value_buffer_local, |
885 print_symbol_value_magic, | 885 print_symbol_value_magic, |
886 0, 0, 0, | 886 0, 0, 0, |
887 struct symbol_value_buffer_local); | 887 struct symbol_value_buffer_local); |
888 | 888 |
889 DEFINE_LRECORD_IMPLEMENTATION ("symbol-value-lisp-magic", | 889 DEFINE_LRECORD_IMPLEMENTATION ("symbol-value-lisp-magic", |
890 symbol_value_lisp_magic, | 890 symbol_value_lisp_magic, |
891 mark_symbol_value_lisp_magic, | 891 mark_symbol_value_lisp_magic, |
892 print_symbol_value_magic, | 892 print_symbol_value_magic, |
893 0, 0, 0, | 893 0, 0, 0, |
894 struct symbol_value_lisp_magic); | 894 struct symbol_value_lisp_magic); |
895 | 895 |
896 DEFINE_LRECORD_IMPLEMENTATION ("symbol-value-varalias", | 896 DEFINE_LRECORD_IMPLEMENTATION ("symbol-value-varalias", |
897 symbol_value_varalias, | 897 symbol_value_varalias, |
898 mark_symbol_value_varalias, | 898 mark_symbol_value_varalias, |
899 print_symbol_value_magic, | 899 print_symbol_value_magic, |
900 0, 0, 0, | 900 0, 0, 0, |
901 struct symbol_value_varalias); | 901 struct symbol_value_varalias); |
902 | 902 |
903 static Lisp_Object | 903 static Lisp_Object |
904 mark_symbol_value_buffer_local (Lisp_Object obj, | 904 mark_symbol_value_buffer_local (Lisp_Object obj, |
911 | 911 |
912 bfwd = XSYMBOL_VALUE_BUFFER_LOCAL (obj); | 912 bfwd = XSYMBOL_VALUE_BUFFER_LOCAL (obj); |
913 ((markobj) (bfwd->default_value)); | 913 ((markobj) (bfwd->default_value)); |
914 ((markobj) (bfwd->current_value)); | 914 ((markobj) (bfwd->current_value)); |
915 ((markobj) (bfwd->current_buffer)); | 915 ((markobj) (bfwd->current_buffer)); |
916 return (bfwd->current_alist_element); | 916 return bfwd->current_alist_element; |
917 } | 917 } |
918 | 918 |
919 static Lisp_Object | 919 static Lisp_Object |
920 mark_symbol_value_lisp_magic (Lisp_Object obj, | 920 mark_symbol_value_lisp_magic (Lisp_Object obj, |
921 void (*markobj) (Lisp_Object)) | 921 void (*markobj) (Lisp_Object)) |
929 for (i = 0; i < MAGIC_HANDLER_MAX; i++) | 929 for (i = 0; i < MAGIC_HANDLER_MAX; i++) |
930 { | 930 { |
931 ((markobj) (bfwd->handler[i])); | 931 ((markobj) (bfwd->handler[i])); |
932 ((markobj) (bfwd->harg[i])); | 932 ((markobj) (bfwd->harg[i])); |
933 } | 933 } |
934 return (bfwd->shadowed); | 934 return bfwd->shadowed; |
935 } | 935 } |
936 | 936 |
937 static Lisp_Object | 937 static Lisp_Object |
938 mark_symbol_value_varalias (Lisp_Object obj, | 938 mark_symbol_value_varalias (Lisp_Object obj, |
939 void (*markobj) (Lisp_Object)) | 939 void (*markobj) (Lisp_Object)) |
942 | 942 |
943 assert (XSYMBOL_VALUE_MAGIC_TYPE (obj) == SYMVAL_VARALIAS); | 943 assert (XSYMBOL_VALUE_MAGIC_TYPE (obj) == SYMVAL_VARALIAS); |
944 | 944 |
945 bfwd = XSYMBOL_VALUE_VARALIAS (obj); | 945 bfwd = XSYMBOL_VALUE_VARALIAS (obj); |
946 ((markobj) (bfwd->shadowed)); | 946 ((markobj) (bfwd->shadowed)); |
947 return (bfwd->aliasee); | 947 return bfwd->aliasee; |
948 } | 948 } |
949 | 949 |
950 /* Should never, ever be called. (except by an external debugger) */ | 950 /* Should never, ever be called. (except by an external debugger) */ |
951 void | 951 void |
952 print_symbol_value_magic (Lisp_Object obj, | 952 print_symbol_value_magic (Lisp_Object obj, |
953 Lisp_Object printcharfun, int escapeflag) | 953 Lisp_Object printcharfun, int escapeflag) |
954 { | 954 { |
955 char buf[200]; | 955 char buf[200]; |
956 sprintf (buf, "#<INTERNAL EMACS BUG (symfwd %d) 0x%x>", | 956 sprintf (buf, "#<INTERNAL EMACS BUG (symfwd %d) 0x%p>", |
957 (EMACS_INT) XSYMBOL_VALUE_MAGIC_TYPE (obj), | 957 XSYMBOL_VALUE_MAGIC_TYPE (obj), (void *) XPNTR (obj)); |
958 (EMACS_INT) XPNTR (obj)); | |
959 write_c_string (buf, printcharfun); | 958 write_c_string (buf, printcharfun); |
960 } | 959 } |
961 | 960 |
962 | 961 |
963 /* Getting and setting values of symbols */ | 962 /* Getting and setting values of symbols */ |
982 struct console *console) | 981 struct console *console) |
983 { | 982 { |
984 CONST struct symbol_value_forward *fwd; | 983 CONST struct symbol_value_forward *fwd; |
985 | 984 |
986 if (!SYMBOL_VALUE_MAGIC_P (valcontents)) | 985 if (!SYMBOL_VALUE_MAGIC_P (valcontents)) |
987 return (valcontents); | 986 return valcontents; |
988 | 987 |
989 fwd = XSYMBOL_VALUE_FORWARD (valcontents); | 988 fwd = XSYMBOL_VALUE_FORWARD (valcontents); |
990 switch (fwd->magic.type) | 989 switch (fwd->magic.type) |
991 { | 990 { |
992 case SYMVAL_FIXNUM_FORWARD: | 991 case SYMVAL_FIXNUM_FORWARD: |
993 case SYMVAL_CONST_FIXNUM_FORWARD: | 992 case SYMVAL_CONST_FIXNUM_FORWARD: |
994 return (make_int (*((int *)symbol_value_forward_forward (fwd)))); | 993 return make_int (*((int *)symbol_value_forward_forward (fwd))); |
995 | 994 |
996 case SYMVAL_BOOLEAN_FORWARD: | 995 case SYMVAL_BOOLEAN_FORWARD: |
997 case SYMVAL_CONST_BOOLEAN_FORWARD: | 996 case SYMVAL_CONST_BOOLEAN_FORWARD: |
998 { | 997 return *((int *)symbol_value_forward_forward (fwd)) ? Qt : Qnil; |
999 if (*((int *)symbol_value_forward_forward (fwd))) | |
1000 return (Qt); | |
1001 else | |
1002 return (Qnil); | |
1003 } | |
1004 | 998 |
1005 case SYMVAL_OBJECT_FORWARD: | 999 case SYMVAL_OBJECT_FORWARD: |
1006 case SYMVAL_CONST_OBJECT_FORWARD: | 1000 case SYMVAL_CONST_OBJECT_FORWARD: |
1007 case SYMVAL_CONST_SPECIFIER_FORWARD: | 1001 case SYMVAL_CONST_SPECIFIER_FORWARD: |
1008 return (*((Lisp_Object *)symbol_value_forward_forward (fwd))); | 1002 return *((Lisp_Object *)symbol_value_forward_forward (fwd)); |
1009 | 1003 |
1010 case SYMVAL_DEFAULT_BUFFER_FORWARD: | 1004 case SYMVAL_DEFAULT_BUFFER_FORWARD: |
1011 return (*((Lisp_Object *)((char *) XBUFFER (Vbuffer_defaults) | 1005 return (*((Lisp_Object *)((char *) XBUFFER (Vbuffer_defaults) |
1012 + ((char *)symbol_value_forward_forward (fwd) | 1006 + ((char *)symbol_value_forward_forward (fwd) |
1013 - (char *)&buffer_local_flags)))); | 1007 - (char *)&buffer_local_flags)))); |
1031 return (*((Lisp_Object *)((char *)console | 1025 return (*((Lisp_Object *)((char *)console |
1032 + ((char *)symbol_value_forward_forward (fwd) | 1026 + ((char *)symbol_value_forward_forward (fwd) |
1033 - (char *)&console_local_flags)))); | 1027 - (char *)&console_local_flags)))); |
1034 | 1028 |
1035 case SYMVAL_UNBOUND_MARKER: | 1029 case SYMVAL_UNBOUND_MARKER: |
1036 return (valcontents); | 1030 return valcontents; |
1037 | 1031 |
1038 default: | 1032 default: |
1039 abort (); | 1033 abort (); |
1040 } | 1034 } |
1041 return Qnil; /* suppress compiler warning */ | 1035 return Qnil; /* suppress compiler warning */ |
1052 */ | 1046 */ |
1053 /* At this point, the value cell may not contain a symbol-value-varalias | 1047 /* At this point, the value cell may not contain a symbol-value-varalias |
1054 or symbol-value-buffer-local, and if there's a handler, we should | 1048 or symbol-value-buffer-local, and if there's a handler, we should |
1055 have already called it. */ | 1049 have already called it. */ |
1056 Lisp_Object valcontents = fetch_value_maybe_past_magic (sym, Qt); | 1050 Lisp_Object valcontents = fetch_value_maybe_past_magic (sym, Qt); |
1057 CONST struct symbol_value_forward *fwd | 1051 CONST struct symbol_value_forward *fwd |
1058 = XSYMBOL_VALUE_FORWARD (valcontents); | 1052 = XSYMBOL_VALUE_FORWARD (valcontents); |
1059 int offset = ((char *) symbol_value_forward_forward (fwd) | 1053 int offset = ((char *) symbol_value_forward_forward (fwd) |
1060 - (char *) &buffer_local_flags); | 1054 - (char *) &buffer_local_flags); |
1061 int mask = XINT (*((Lisp_Object *) symbol_value_forward_forward (fwd))); | 1055 int mask = XINT (*((Lisp_Object *) symbol_value_forward_forward (fwd))); |
1062 int (*magicfun) (Lisp_Object simm, Lisp_Object *val, Lisp_Object in_object, | 1056 int (*magicfun) (Lisp_Object simm, Lisp_Object *val, Lisp_Object in_object, |
1063 int flags) = symbol_value_forward_magicfun (fwd); | 1057 int flags) = symbol_value_forward_magicfun (fwd); |
1064 | 1058 |
1065 *((Lisp_Object *) (offset + (char *) XBUFFER (Vbuffer_defaults))) | 1059 *((Lisp_Object *) (offset + (char *) XBUFFER (Vbuffer_defaults))) |
1066 = value; | 1060 = value; |
1067 | 1061 |
1068 if (mask > 0) /* Not always per-buffer */ | 1062 if (mask > 0) /* Not always per-buffer */ |
1069 { | 1063 { |
1070 Lisp_Object tail; | 1064 Lisp_Object tail; |
1071 | 1065 |
1072 /* Set value in each buffer which hasn't shadowed the default */ | 1066 /* Set value in each buffer which hasn't shadowed the default */ |
1073 LIST_LOOP (tail, Vbuffer_alist) | 1067 LIST_LOOP (tail, Vbuffer_alist) |
1074 { | 1068 { |
1075 struct buffer *b = XBUFFER (XCDR (XCAR (tail))); | 1069 struct buffer *b = XBUFFER (XCDR (XCAR (tail))); |
1076 if (!(b->local_var_flags & mask)) | 1070 if (!(b->local_var_flags & mask)) |
1077 { | 1071 { |
1078 if (magicfun) | 1072 if (magicfun) |
1079 (magicfun) (sym, &value, make_buffer (b), 0); | 1073 (magicfun) (sym, &value, make_buffer (b), 0); |
1080 *((Lisp_Object *) (offset + (char *) b)) = value; | 1074 *((Lisp_Object *) (offset + (char *) b)) = value; |
1081 } | 1075 } |
1082 } | 1076 } |
1083 } | 1077 } |
1084 } | 1078 } |
1085 | 1079 |
1094 */ | 1088 */ |
1095 /* At this point, the value cell may not contain a symbol-value-varalias | 1089 /* At this point, the value cell may not contain a symbol-value-varalias |
1096 or symbol-value-buffer-local, and if there's a handler, we should | 1090 or symbol-value-buffer-local, and if there's a handler, we should |
1097 have already called it. */ | 1091 have already called it. */ |
1098 Lisp_Object valcontents = fetch_value_maybe_past_magic (sym, Qt); | 1092 Lisp_Object valcontents = fetch_value_maybe_past_magic (sym, Qt); |
1099 CONST struct symbol_value_forward *fwd | 1093 CONST struct symbol_value_forward *fwd |
1100 = XSYMBOL_VALUE_FORWARD (valcontents); | 1094 = XSYMBOL_VALUE_FORWARD (valcontents); |
1101 int offset = ((char *) symbol_value_forward_forward (fwd) | 1095 int offset = ((char *) symbol_value_forward_forward (fwd) |
1102 - (char *) &console_local_flags); | 1096 - (char *) &console_local_flags); |
1103 int mask = XINT (*((Lisp_Object *) symbol_value_forward_forward (fwd))); | 1097 int mask = XINT (*((Lisp_Object *) symbol_value_forward_forward (fwd))); |
1104 int (*magicfun) (Lisp_Object simm, Lisp_Object *val, Lisp_Object in_object, | 1098 int (*magicfun) (Lisp_Object simm, Lisp_Object *val, Lisp_Object in_object, |
1105 int flags) = symbol_value_forward_magicfun (fwd); | 1099 int flags) = symbol_value_forward_magicfun (fwd); |
1106 | 1100 |
1107 *((Lisp_Object *) (offset + (char *) XCONSOLE (Vconsole_defaults))) | 1101 *((Lisp_Object *) (offset + (char *) XCONSOLE (Vconsole_defaults))) |
1108 = value; | 1102 = value; |
1109 | 1103 |
1110 if (mask > 0) /* Not always per-console */ | 1104 if (mask > 0) /* Not always per-console */ |
1111 { | 1105 { |
1112 Lisp_Object tail; | 1106 Lisp_Object tail; |
1113 | 1107 |
1114 /* Set value in each console which hasn't shadowed the default */ | 1108 /* Set value in each console which hasn't shadowed the default */ |
1115 LIST_LOOP (tail, Vconsole_list) | 1109 LIST_LOOP (tail, Vconsole_list) |
1116 { | 1110 { |
1117 Lisp_Object dev = XCAR (tail); | 1111 Lisp_Object dev = XCAR (tail); |
1118 struct console *d = XCONSOLE (dev); | 1112 struct console *d = XCONSOLE (dev); |
1119 if (!(d->local_var_flags & mask)) | 1113 if (!(d->local_var_flags & mask)) |
1120 { | 1114 { |
1121 if (magicfun) | 1115 if (magicfun) |
1122 (magicfun) (sym, &value, dev, 0); | 1116 (magicfun) (sym, &value, dev, 0); |
1123 *((Lisp_Object *) (offset + (char *) d)) = value; | 1117 *((Lisp_Object *) (offset + (char *) d)) = value; |
1124 } | 1118 } |
1125 } | 1119 } |
1126 } | 1120 } |
1127 } | 1121 } |
1128 | 1122 |
1196 if (magicfun) | 1190 if (magicfun) |
1197 (magicfun) (sym, &newval, Qnil, 0); | 1191 (magicfun) (sym, &newval, Qnil, 0); |
1198 *((Lisp_Object *) symbol_value_forward_forward (fwd)) = newval; | 1192 *((Lisp_Object *) symbol_value_forward_forward (fwd)) = newval; |
1199 return; | 1193 return; |
1200 } | 1194 } |
1201 | 1195 |
1202 case SYMVAL_DEFAULT_BUFFER_FORWARD: | 1196 case SYMVAL_DEFAULT_BUFFER_FORWARD: |
1203 { | 1197 { |
1204 set_default_buffer_slot_variable (sym, newval); | 1198 set_default_buffer_slot_variable (sym, newval); |
1205 return; | 1199 return; |
1206 } | 1200 } |
1209 { | 1203 { |
1210 if (magicfun) | 1204 if (magicfun) |
1211 (magicfun) (sym, &newval, make_buffer (current_buffer), 0); | 1205 (magicfun) (sym, &newval, make_buffer (current_buffer), 0); |
1212 *((Lisp_Object *) ((char *) current_buffer | 1206 *((Lisp_Object *) ((char *) current_buffer |
1213 + ((char *) symbol_value_forward_forward (fwd) | 1207 + ((char *) symbol_value_forward_forward (fwd) |
1214 - (char *) &buffer_local_flags))) | 1208 - (char *) &buffer_local_flags))) |
1215 = newval; | 1209 = newval; |
1216 return; | 1210 return; |
1217 } | 1211 } |
1218 | 1212 |
1219 case SYMVAL_DEFAULT_CONSOLE_FORWARD: | 1213 case SYMVAL_DEFAULT_CONSOLE_FORWARD: |
1226 { | 1220 { |
1227 if (magicfun) | 1221 if (magicfun) |
1228 (magicfun) (sym, &newval, Vselected_console, 0); | 1222 (magicfun) (sym, &newval, Vselected_console, 0); |
1229 *((Lisp_Object *) ((char *) XCONSOLE (Vselected_console) | 1223 *((Lisp_Object *) ((char *) XCONSOLE (Vselected_console) |
1230 + ((char *) symbol_value_forward_forward (fwd) | 1224 + ((char *) symbol_value_forward_forward (fwd) |
1231 - (char *) &console_local_flags))) | 1225 - (char *) &console_local_flags))) |
1232 = newval; | 1226 = newval; |
1233 return; | 1227 return; |
1234 } | 1228 } |
1235 | 1229 |
1236 default: | 1230 default: |
1251 struct symbol_value_buffer_local *bfwd) | 1245 struct symbol_value_buffer_local *bfwd) |
1252 { | 1246 { |
1253 if (!NILP (bfwd->current_buffer) && | 1247 if (!NILP (bfwd->current_buffer) && |
1254 XBUFFER (bfwd->current_buffer) == buffer) | 1248 XBUFFER (bfwd->current_buffer) == buffer) |
1255 /* This is just an optimization of the below. */ | 1249 /* This is just an optimization of the below. */ |
1256 return (bfwd->current_alist_element); | 1250 return bfwd->current_alist_element; |
1257 else | 1251 else |
1258 return (assq_no_quit (symbol, buffer->local_var_alist)); | 1252 return assq_no_quit (symbol, buffer->local_var_alist); |
1259 } | 1253 } |
1260 | 1254 |
1261 /* [Remember that the slot that mirrors CURRENT-VALUE in the | 1255 /* [Remember that the slot that mirrors CURRENT-VALUE in the |
1262 symbol-value-buffer-local of a per-buffer variable -- i.e. the | 1256 symbol-value-buffer-local of a per-buffer variable -- i.e. the |
1263 slot in CURRENT-BUFFER's local_var_alist, or the DEFAULT-VALUE | 1257 slot in CURRENT-BUFFER's local_var_alist, or the DEFAULT-VALUE |
1300 (Otherwise, you can just retrieve the value without changing the | 1294 (Otherwise, you can just retrieve the value without changing the |
1301 cache, at the expense of slower retrieval.) | 1295 cache, at the expense of slower retrieval.) |
1302 */ | 1296 */ |
1303 | 1297 |
1304 static void | 1298 static void |
1305 set_up_buffer_local_cache (Lisp_Object sym, | 1299 set_up_buffer_local_cache (Lisp_Object sym, |
1306 struct symbol_value_buffer_local *bfwd, | 1300 struct symbol_value_buffer_local *bfwd, |
1307 struct buffer *buf, | 1301 struct buffer *buf, |
1308 Lisp_Object new_alist_el, | 1302 Lisp_Object new_alist_el, |
1309 int set_it_p) | 1303 int set_it_p) |
1310 { | 1304 { |
1349 Lisp_Object prev = Qnil; | 1343 Lisp_Object prev = Qnil; |
1350 Lisp_Object alist; | 1344 Lisp_Object alist; |
1351 | 1345 |
1352 /* Any which are supposed to be permanent, | 1346 /* Any which are supposed to be permanent, |
1353 make local again, with the same values they had. */ | 1347 make local again, with the same values they had. */ |
1354 | 1348 |
1355 for (alist = buf->local_var_alist; !NILP (alist); alist = XCDR (alist)) | 1349 for (alist = buf->local_var_alist; !NILP (alist); alist = XCDR (alist)) |
1356 { | 1350 { |
1357 Lisp_Object sym = XCAR (XCAR (alist)); | 1351 Lisp_Object sym = XCAR (XCAR (alist)); |
1358 struct symbol_value_buffer_local *bfwd; | 1352 struct symbol_value_buffer_local *bfwd; |
1359 /* Variables with a symbol-value-varalias should not be here | 1353 /* Variables with a symbol-value-varalias should not be here |
1409 retry: | 1403 retry: |
1410 valcontents = XSYMBOL (sym)->value; | 1404 valcontents = XSYMBOL (sym)->value; |
1411 | 1405 |
1412 retry_2: | 1406 retry_2: |
1413 if (!SYMBOL_VALUE_MAGIC_P (valcontents)) | 1407 if (!SYMBOL_VALUE_MAGIC_P (valcontents)) |
1414 return (valcontents); | 1408 return valcontents; |
1415 | 1409 |
1416 switch (XSYMBOL_VALUE_MAGIC_TYPE (valcontents)) | 1410 switch (XSYMBOL_VALUE_MAGIC_TYPE (valcontents)) |
1417 { | 1411 { |
1418 case SYMVAL_LISP_MAGIC: | 1412 case SYMVAL_LISP_MAGIC: |
1419 /* #### kludge */ | 1413 /* #### kludge */ |
1455 else | 1449 else |
1456 valcontents = XCDR (symcons); | 1450 valcontents = XCDR (symcons); |
1457 } | 1451 } |
1458 break; | 1452 break; |
1459 } | 1453 } |
1460 | 1454 |
1461 default: | 1455 default: |
1462 break; | 1456 break; |
1463 } | 1457 } |
1464 return (do_symval_forwarding (valcontents, buf, con)); | 1458 return do_symval_forwarding (valcontents, buf, con); |
1465 } | 1459 } |
1466 | 1460 |
1467 | 1461 |
1468 /* Find the value of a symbol in BUFFER, returning Qunbound if it's not | 1462 /* Find the value of a symbol in BUFFER, returning Qunbound if it's not |
1469 bound. Note that it must not be possible to QUIT within this | 1463 bound. Note that it must not be possible to QUIT within this |
1550 { | 1544 { |
1551 /* WARNING: This function can be called when current_buffer is 0 | 1545 /* WARNING: This function can be called when current_buffer is 0 |
1552 and Vselected_console is Qnil, early in initialization. */ | 1546 and Vselected_console is Qnil, early in initialization. */ |
1553 struct console *dev; | 1547 struct console *dev; |
1554 Lisp_Object sym = find_it_p ? XCAR (symbol_cons) : symbol_cons; | 1548 Lisp_Object sym = find_it_p ? XCAR (symbol_cons) : symbol_cons; |
1555 | 1549 |
1556 CHECK_SYMBOL (sym); | 1550 CHECK_SYMBOL (sym); |
1557 if (CONSOLEP (Vselected_console)) | 1551 if (CONSOLEP (Vselected_console)) |
1558 dev = XCONSOLE (Vselected_console); | 1552 dev = XCONSOLE (Vselected_console); |
1559 else | 1553 else |
1560 { | 1554 { |
1615 return newval; | 1609 return newval; |
1616 valcontents = XSYMBOL_VALUE_LISP_MAGIC (valcontents)->shadowed; | 1610 valcontents = XSYMBOL_VALUE_LISP_MAGIC (valcontents)->shadowed; |
1617 /* semi-change-o */ | 1611 /* semi-change-o */ |
1618 goto retry_2; | 1612 goto retry_2; |
1619 } | 1613 } |
1620 | 1614 |
1621 case SYMVAL_VARALIAS: | 1615 case SYMVAL_VARALIAS: |
1622 sym = follow_varalias_pointers (sym, | 1616 sym = follow_varalias_pointers (sym, |
1623 UNBOUNDP (newval) | 1617 UNBOUNDP (newval) |
1624 ? Qmakunbound : Qset); | 1618 ? Qmakunbound : Qset); |
1625 /* presto change-o! */ | 1619 /* presto change-o! */ |
1629 case SYMVAL_BOOLEAN_FORWARD: | 1623 case SYMVAL_BOOLEAN_FORWARD: |
1630 case SYMVAL_OBJECT_FORWARD: | 1624 case SYMVAL_OBJECT_FORWARD: |
1631 case SYMVAL_DEFAULT_BUFFER_FORWARD: | 1625 case SYMVAL_DEFAULT_BUFFER_FORWARD: |
1632 case SYMVAL_DEFAULT_CONSOLE_FORWARD: | 1626 case SYMVAL_DEFAULT_CONSOLE_FORWARD: |
1633 if (UNBOUNDP (newval)) | 1627 if (UNBOUNDP (newval)) |
1634 signal_error (Qerror, | 1628 signal_error (Qerror, |
1635 list2 (build_string ("Cannot makunbound"), sym)); | 1629 list2 (build_string ("Cannot makunbound"), sym)); |
1636 break; | 1630 break; |
1637 | 1631 |
1638 case SYMVAL_UNBOUND_MARKER: | 1632 case SYMVAL_UNBOUND_MARKER: |
1639 break; | 1633 break; |
1671 store the current CURRENT-VALUE value into | 1665 store the current CURRENT-VALUE value into |
1672 CURRENT-ALIST- ELEMENT, then find the appropriate alist | 1666 CURRENT-ALIST- ELEMENT, then find the appropriate alist |
1673 element for the buffer now current and set up | 1667 element for the buffer now current and set up |
1674 CURRENT-ALIST-ELEMENT. Then we set CURRENT-VALUE out | 1668 CURRENT-ALIST-ELEMENT. Then we set CURRENT-VALUE out |
1675 of that element, and store into CURRENT-BUFFER. | 1669 of that element, and store into CURRENT-BUFFER. |
1676 | 1670 |
1677 If we are setting the variable and the current buffer does | 1671 If we are setting the variable and the current buffer does |
1678 not have an alist entry for this variable, an alist entry is | 1672 not have an alist entry for this variable, an alist entry is |
1679 created. | 1673 created. |
1680 | 1674 |
1681 Note that CURRENT-VALUE can be a forwarding pointer. | 1675 Note that CURRENT-VALUE can be a forwarding pointer. |
1682 Each time it is examined or set, forwarding must be | 1676 Each time it is examined or set, forwarding must be |
1683 done. */ | 1677 done. */ |
1684 struct symbol_value_buffer_local *bfwd | 1678 struct symbol_value_buffer_local *bfwd |
1685 = XSYMBOL_VALUE_BUFFER_LOCAL (valcontents); | 1679 = XSYMBOL_VALUE_BUFFER_LOCAL (valcontents); |
1703 /* If the current buffer is not the buffer whose binding is | 1697 /* If the current buffer is not the buffer whose binding is |
1704 currently cached, or if it's a SYMVAL_BUFFER_LOCAL and | 1698 currently cached, or if it's a SYMVAL_BUFFER_LOCAL and |
1705 we're looking at the default value, the cache is invalid; we | 1699 we're looking at the default value, the cache is invalid; we |
1706 need to write it out, and find the new CURRENT-ALIST-ELEMENT | 1700 need to write it out, and find the new CURRENT-ALIST-ELEMENT |
1707 */ | 1701 */ |
1708 | 1702 |
1709 /* Write out the cached value for the old buffer; copy it | 1703 /* Write out the cached value for the old buffer; copy it |
1710 back to its alist element. This works if the current | 1704 back to its alist element. This works if the current |
1711 buffer only sees the default value, too. */ | 1705 buffer only sees the default value, too. */ |
1712 write_out_buffer_local_cache (sym, bfwd); | 1706 write_out_buffer_local_cache (sym, bfwd); |
1713 | 1707 |
1748 abort (); | 1742 abort (); |
1749 } | 1743 } |
1750 } | 1744 } |
1751 store_symval_forwarding (sym, valcontents, newval); | 1745 store_symval_forwarding (sym, valcontents, newval); |
1752 | 1746 |
1753 return (newval); | 1747 return newval; |
1754 } | 1748 } |
1755 | 1749 |
1756 | 1750 |
1757 /* Access or set a buffer-local symbol's default value. */ | 1751 /* Access or set a buffer-local symbol's default value. */ |
1758 | 1752 |
1769 retry: | 1763 retry: |
1770 valcontents = XSYMBOL (sym)->value; | 1764 valcontents = XSYMBOL (sym)->value; |
1771 | 1765 |
1772 retry_2: | 1766 retry_2: |
1773 if (!SYMBOL_VALUE_MAGIC_P (valcontents)) | 1767 if (!SYMBOL_VALUE_MAGIC_P (valcontents)) |
1774 return (valcontents); | 1768 return valcontents; |
1775 | 1769 |
1776 switch (XSYMBOL_VALUE_MAGIC_TYPE (valcontents)) | 1770 switch (XSYMBOL_VALUE_MAGIC_TYPE (valcontents)) |
1777 { | 1771 { |
1778 case SYMVAL_LISP_MAGIC: | 1772 case SYMVAL_LISP_MAGIC: |
1779 /* #### kludge */ | 1773 /* #### kludge */ |
1780 valcontents = XSYMBOL_VALUE_LISP_MAGIC (valcontents)->shadowed; | 1774 valcontents = XSYMBOL_VALUE_LISP_MAGIC (valcontents)->shadowed; |
1808 } | 1802 } |
1809 | 1803 |
1810 case SYMVAL_BUFFER_LOCAL: | 1804 case SYMVAL_BUFFER_LOCAL: |
1811 case SYMVAL_SOME_BUFFER_LOCAL: | 1805 case SYMVAL_SOME_BUFFER_LOCAL: |
1812 { | 1806 { |
1813 struct symbol_value_buffer_local *bfwd = | 1807 struct symbol_value_buffer_local *bfwd = |
1814 XSYMBOL_VALUE_BUFFER_LOCAL (valcontents); | 1808 XSYMBOL_VALUE_BUFFER_LOCAL (valcontents); |
1815 | 1809 |
1816 /* Handle user-created local variables. */ | 1810 /* Handle user-created local variables. */ |
1817 /* If var is set up for a buffer that lacks a local value for it, | 1811 /* If var is set up for a buffer that lacks a local value for it, |
1818 the current value is nominally the default value. | 1812 the current value is nominally the default value. |
1819 But the current value slot may be more up to date, since | 1813 But the current value slot may be more up to date, since |
1820 ordinary setq stores just that slot. So use that. */ | 1814 ordinary setq stores just that slot. So use that. */ |
1821 if (NILP (bfwd->current_alist_element)) | 1815 if (NILP (bfwd->current_alist_element)) |
1822 return (do_symval_forwarding (bfwd->current_value, current_buffer, | 1816 return do_symval_forwarding (bfwd->current_value, current_buffer, |
1823 XCONSOLE (Vselected_console))); | 1817 XCONSOLE (Vselected_console)); |
1824 else | 1818 else |
1825 return (bfwd->default_value); | 1819 return bfwd->default_value; |
1826 } | 1820 } |
1827 default: | 1821 default: |
1828 /* For other variables, get the current value. */ | 1822 /* For other variables, get the current value. */ |
1829 return (do_symval_forwarding (valcontents, current_buffer, | 1823 return do_symval_forwarding (valcontents, current_buffer, |
1830 XCONSOLE (Vselected_console))); | 1824 XCONSOLE (Vselected_console)); |
1831 } | 1825 } |
1832 | 1826 |
1833 RETURN_NOT_REACHED(Qnil) /* suppress compiler warning */ | 1827 RETURN_NOT_REACHED(Qnil) /* suppress compiler warning */ |
1834 } | 1828 } |
1835 | 1829 |
1836 DEFUN ("default-boundp", Fdefault_boundp, 1, 1, 0, /* | 1830 DEFUN ("default-boundp", Fdefault_boundp, 1, 1, 0, /* |
1837 Return T if SYMBOL has a non-void default value. | 1831 Return T if SYMBOL has a non-void default value. |
1838 This is the value that is seen in buffers that do not have their own values | 1832 This is the value that is seen in buffers that do not have their own values |
1839 for this variable. | 1833 for this variable. |
1840 */ | 1834 */ |
1841 (sym)) | 1835 (sym)) |
1842 { | 1836 { |
1843 Lisp_Object value; | 1837 return UNBOUNDP (default_value (sym)) ? Qnil : Qt; |
1844 | |
1845 value = default_value (sym); | |
1846 return (UNBOUNDP (value) ? Qnil : Qt); | |
1847 } | 1838 } |
1848 | 1839 |
1849 DEFUN ("default-value", Fdefault_value, 1, 1, 0, /* | 1840 DEFUN ("default-value", Fdefault_value, 1, 1, 0, /* |
1850 Return SYMBOL's default value. | 1841 Return SYMBOL's default value. |
1851 This is the value that is seen in buffers that do not have their own values | 1842 This is the value that is seen in buffers that do not have their own values |
1852 for this variable. The default value is meaningful for variables with | 1843 for this variable. The default value is meaningful for variables with |
1853 local bindings in certain buffers. | 1844 local bindings in certain buffers. |
1854 */ | 1845 */ |
1855 (sym)) | 1846 (sym)) |
1856 { | 1847 { |
1857 Lisp_Object value; | 1848 Lisp_Object value = default_value (sym); |
1858 | 1849 |
1859 value = default_value (sym); | 1850 return UNBOUNDP (value) ? Fsignal (Qvoid_variable, list1 (sym)) : value; |
1860 if (UNBOUNDP (value)) | |
1861 return Fsignal (Qvoid_variable, list1 (sym)); | |
1862 return value; | |
1863 } | 1851 } |
1864 | 1852 |
1865 DEFUN ("set-default", Fset_default, 2, 2, 0, /* | 1853 DEFUN ("set-default", Fset_default, 2, 2, 0, /* |
1866 Set SYMBOL's default value to VAL. SYMBOL and VAL are evaluated. | 1854 Set SYMBOL's default value to VAL. SYMBOL and VAL are evaluated. |
1867 The default value is seen in buffers that do not have their own values | 1855 The default value is seen in buffers that do not have their own values |
1886 RETURN_IF_NOT_UNBOUND (maybe_call_magic_handler (sym, Qset_default, 1, | 1874 RETURN_IF_NOT_UNBOUND (maybe_call_magic_handler (sym, Qset_default, 1, |
1887 value)); | 1875 value)); |
1888 valcontents = XSYMBOL_VALUE_LISP_MAGIC (valcontents)->shadowed; | 1876 valcontents = XSYMBOL_VALUE_LISP_MAGIC (valcontents)->shadowed; |
1889 /* semi-change-o */ | 1877 /* semi-change-o */ |
1890 goto retry_2; | 1878 goto retry_2; |
1891 | 1879 |
1892 case SYMVAL_VARALIAS: | 1880 case SYMVAL_VARALIAS: |
1893 sym = follow_varalias_pointers (sym, Qset_default); | 1881 sym = follow_varalias_pointers (sym, Qset_default); |
1894 /* presto change-o! */ | 1882 /* presto change-o! */ |
1895 goto retry; | 1883 goto retry; |
1896 | 1884 |
1897 case SYMVAL_CURRENT_BUFFER_FORWARD: | 1885 case SYMVAL_CURRENT_BUFFER_FORWARD: |
1898 set_default_buffer_slot_variable (sym, value); | 1886 set_default_buffer_slot_variable (sym, value); |
1899 return (value); | 1887 return value; |
1900 | 1888 |
1901 case SYMVAL_SELECTED_CONSOLE_FORWARD: | 1889 case SYMVAL_SELECTED_CONSOLE_FORWARD: |
1902 set_default_console_slot_variable (sym, value); | 1890 set_default_console_slot_variable (sym, value); |
1903 return (value); | 1891 return value; |
1904 | 1892 |
1905 case SYMVAL_BUFFER_LOCAL: | 1893 case SYMVAL_BUFFER_LOCAL: |
1906 case SYMVAL_SOME_BUFFER_LOCAL: | 1894 case SYMVAL_SOME_BUFFER_LOCAL: |
1907 { | 1895 { |
1908 /* Store new value into the DEFAULT-VALUE slot */ | 1896 /* Store new value into the DEFAULT-VALUE slot */ |
1912 bfwd->default_value = value; | 1900 bfwd->default_value = value; |
1913 /* If current-buffer doesn't shadow default_value, | 1901 /* If current-buffer doesn't shadow default_value, |
1914 * we must set the CURRENT-VALUE slot too */ | 1902 * we must set the CURRENT-VALUE slot too */ |
1915 if (NILP (bfwd->current_alist_element)) | 1903 if (NILP (bfwd->current_alist_element)) |
1916 store_symval_forwarding (sym, bfwd->current_value, value); | 1904 store_symval_forwarding (sym, bfwd->current_value, value); |
1917 return (value); | 1905 return value; |
1918 } | 1906 } |
1919 | 1907 |
1920 default: | 1908 default: |
1921 return Fset (sym, value); | 1909 return Fset (sym, value); |
1922 } | 1910 } |
2012 break; | 2000 break; |
2013 | 2001 |
2014 case SYMVAL_CURRENT_BUFFER_FORWARD: | 2002 case SYMVAL_CURRENT_BUFFER_FORWARD: |
2015 case SYMVAL_BUFFER_LOCAL: | 2003 case SYMVAL_BUFFER_LOCAL: |
2016 /* Already per-each-buffer */ | 2004 /* Already per-each-buffer */ |
2017 return (variable); | 2005 return variable; |
2018 | 2006 |
2019 case SYMVAL_SOME_BUFFER_LOCAL: | 2007 case SYMVAL_SOME_BUFFER_LOCAL: |
2020 /* Transmogrify */ | 2008 /* Transmogrify */ |
2021 XSYMBOL_VALUE_BUFFER_LOCAL (valcontents)->magic.type = | 2009 XSYMBOL_VALUE_BUFFER_LOCAL (valcontents)->magic.type = |
2022 SYMVAL_BUFFER_LOCAL; | 2010 SYMVAL_BUFFER_LOCAL; |
2023 return (variable); | 2011 return variable; |
2024 | 2012 |
2025 default: | 2013 default: |
2026 abort (); | 2014 abort (); |
2027 } | 2015 } |
2028 } | 2016 } |
2029 | 2017 |
2030 { | 2018 { |
2031 struct symbol_value_buffer_local *bfwd | 2019 struct symbol_value_buffer_local *bfwd |
2032 = alloc_lcrecord (sizeof (struct symbol_value_buffer_local), | 2020 = alloc_lcrecord (sizeof (struct symbol_value_buffer_local), |
2033 lrecord_symbol_value_buffer_local); | 2021 lrecord_symbol_value_buffer_local); |
2034 Lisp_Object foo = Qnil; | 2022 Lisp_Object foo = Qnil; |
2114 case SYMVAL_CURRENT_BUFFER_FORWARD: | 2102 case SYMVAL_CURRENT_BUFFER_FORWARD: |
2115 { | 2103 { |
2116 /* Make sure the symbol has a local value in this particular | 2104 /* Make sure the symbol has a local value in this particular |
2117 buffer, by setting it to the same value it already has. */ | 2105 buffer, by setting it to the same value it already has. */ |
2118 Fset (variable, find_symbol_value (variable)); | 2106 Fset (variable, find_symbol_value (variable)); |
2119 return (variable); | 2107 return variable; |
2120 } | 2108 } |
2121 | 2109 |
2122 case SYMVAL_SOME_BUFFER_LOCAL: | 2110 case SYMVAL_SOME_BUFFER_LOCAL: |
2123 { | 2111 { |
2124 if (!NILP (buffer_local_alist_element (current_buffer, | 2112 if (!NILP (buffer_local_alist_element (current_buffer, |
2167 XSETBUFFER (bfwd->current_buffer, current_buffer); | 2155 XSETBUFFER (bfwd->current_buffer, current_buffer); |
2168 bfwd->current_alist_element = Fcons (variable, Qnil); | 2156 bfwd->current_alist_element = Fcons (variable, Qnil); |
2169 current_buffer->local_var_alist = | 2157 current_buffer->local_var_alist = |
2170 Fcons (bfwd->current_alist_element, current_buffer->local_var_alist); | 2158 Fcons (bfwd->current_alist_element, current_buffer->local_var_alist); |
2171 store_symval_forwarding (variable, bfwd->current_value, Qnil); | 2159 store_symval_forwarding (variable, bfwd->current_value, Qnil); |
2172 return (variable); | 2160 return variable; |
2173 } | 2161 } |
2174 | 2162 |
2175 current_buffer->local_var_alist | 2163 current_buffer->local_var_alist |
2176 = Fcons (Fcons (variable, bfwd->default_value), | 2164 = Fcons (Fcons (variable, bfwd->default_value), |
2177 current_buffer->local_var_alist); | 2165 current_buffer->local_var_alist); |
2207 default: | 2195 default: |
2208 abort (); | 2196 abort (); |
2209 } | 2197 } |
2210 } | 2198 } |
2211 | 2199 |
2212 return (variable); | 2200 return variable; |
2213 } | 2201 } |
2214 | 2202 |
2215 DEFUN ("kill-local-variable", Fkill_local_variable, 1, 1, "vKill Local Variable: ", /* | 2203 DEFUN ("kill-local-variable", Fkill_local_variable, 1, 1, "vKill Local Variable: ", /* |
2216 Make VARIABLE no longer have a separate value in the current buffer. | 2204 Make VARIABLE no longer have a separate value in the current buffer. |
2217 From now on the default value will apply in this buffer. | 2205 From now on the default value will apply in this buffer. |
2225 retry: | 2213 retry: |
2226 valcontents = XSYMBOL (variable)->value; | 2214 valcontents = XSYMBOL (variable)->value; |
2227 | 2215 |
2228 retry_2: | 2216 retry_2: |
2229 if (!SYMBOL_VALUE_MAGIC_P (valcontents)) | 2217 if (!SYMBOL_VALUE_MAGIC_P (valcontents)) |
2230 return (variable); | 2218 return variable; |
2231 | 2219 |
2232 switch (XSYMBOL_VALUE_MAGIC_TYPE (valcontents)) | 2220 switch (XSYMBOL_VALUE_MAGIC_TYPE (valcontents)) |
2233 { | 2221 { |
2234 case SYMVAL_LISP_MAGIC: | 2222 case SYMVAL_LISP_MAGIC: |
2235 if (!UNBOUNDP (maybe_call_magic_handler | 2223 if (!UNBOUNDP (maybe_call_magic_handler |
2246 | 2234 |
2247 case SYMVAL_CURRENT_BUFFER_FORWARD: | 2235 case SYMVAL_CURRENT_BUFFER_FORWARD: |
2248 { | 2236 { |
2249 CONST struct symbol_value_forward *fwd | 2237 CONST struct symbol_value_forward *fwd |
2250 = XSYMBOL_VALUE_FORWARD (valcontents); | 2238 = XSYMBOL_VALUE_FORWARD (valcontents); |
2251 int offset = ((char *) symbol_value_forward_forward (fwd) | 2239 int offset = ((char *) symbol_value_forward_forward (fwd) |
2252 - (char *) &buffer_local_flags); | 2240 - (char *) &buffer_local_flags); |
2253 int mask = | 2241 int mask = |
2254 XINT (*((Lisp_Object *) symbol_value_forward_forward (fwd))); | 2242 XINT (*((Lisp_Object *) symbol_value_forward_forward (fwd))); |
2255 | 2243 |
2256 if (mask > 0) | 2244 if (mask > 0) |
2264 (magicfun) (variable, &oldval, make_buffer (current_buffer), 0); | 2252 (magicfun) (variable, &oldval, make_buffer (current_buffer), 0); |
2265 *(Lisp_Object *) (offset + (char *) current_buffer) | 2253 *(Lisp_Object *) (offset + (char *) current_buffer) |
2266 = oldval; | 2254 = oldval; |
2267 current_buffer->local_var_flags &= ~mask; | 2255 current_buffer->local_var_flags &= ~mask; |
2268 } | 2256 } |
2269 return (variable); | 2257 return variable; |
2270 } | 2258 } |
2271 | 2259 |
2272 case SYMVAL_BUFFER_LOCAL: | 2260 case SYMVAL_BUFFER_LOCAL: |
2273 case SYMVAL_SOME_BUFFER_LOCAL: | 2261 case SYMVAL_SOME_BUFFER_LOCAL: |
2274 { | 2262 { |
2293 value of the C variable. set_up_buffer_local_cache() | 2281 value of the C variable. set_up_buffer_local_cache() |
2294 will do this. It doesn't hurt to do it always, | 2282 will do this. It doesn't hurt to do it always, |
2295 so just go ahead and do that. */ | 2283 so just go ahead and do that. */ |
2296 set_up_buffer_local_cache (variable, bfwd, current_buffer, Qnil, 1); | 2284 set_up_buffer_local_cache (variable, bfwd, current_buffer, Qnil, 1); |
2297 } | 2285 } |
2298 return (variable); | 2286 return variable; |
2299 | 2287 |
2300 default: | 2288 default: |
2301 return (variable); | 2289 return variable; |
2302 } | 2290 } |
2303 RETURN_NOT_REACHED(Qnil) /* suppress compiler warning */ | 2291 RETURN_NOT_REACHED(Qnil) /* suppress compiler warning */ |
2304 } | 2292 } |
2305 | 2293 |
2306 | 2294 |
2317 retry: | 2305 retry: |
2318 valcontents = XSYMBOL (variable)->value; | 2306 valcontents = XSYMBOL (variable)->value; |
2319 | 2307 |
2320 retry_2: | 2308 retry_2: |
2321 if (!SYMBOL_VALUE_MAGIC_P (valcontents)) | 2309 if (!SYMBOL_VALUE_MAGIC_P (valcontents)) |
2322 return (variable); | 2310 return variable; |
2323 | 2311 |
2324 switch (XSYMBOL_VALUE_MAGIC_TYPE (valcontents)) | 2312 switch (XSYMBOL_VALUE_MAGIC_TYPE (valcontents)) |
2325 { | 2313 { |
2326 case SYMVAL_LISP_MAGIC: | 2314 case SYMVAL_LISP_MAGIC: |
2327 if (!UNBOUNDP (maybe_call_magic_handler | 2315 if (!UNBOUNDP (maybe_call_magic_handler |
2339 | 2327 |
2340 case SYMVAL_SELECTED_CONSOLE_FORWARD: | 2328 case SYMVAL_SELECTED_CONSOLE_FORWARD: |
2341 { | 2329 { |
2342 CONST struct symbol_value_forward *fwd | 2330 CONST struct symbol_value_forward *fwd |
2343 = XSYMBOL_VALUE_FORWARD (valcontents); | 2331 = XSYMBOL_VALUE_FORWARD (valcontents); |
2344 int offset = ((char *) symbol_value_forward_forward (fwd) | 2332 int offset = ((char *) symbol_value_forward_forward (fwd) |
2345 - (char *) &console_local_flags); | 2333 - (char *) &console_local_flags); |
2346 int mask = | 2334 int mask = |
2347 XINT (*((Lisp_Object *) symbol_value_forward_forward (fwd))); | 2335 XINT (*((Lisp_Object *) symbol_value_forward_forward (fwd))); |
2348 | 2336 |
2349 if (mask > 0) | 2337 if (mask > 0) |
2357 (magicfun) (variable, &oldval, Vselected_console, 0); | 2345 (magicfun) (variable, &oldval, Vselected_console, 0); |
2358 *(Lisp_Object *) (offset + (char *) XCONSOLE (Vselected_console)) | 2346 *(Lisp_Object *) (offset + (char *) XCONSOLE (Vselected_console)) |
2359 = oldval; | 2347 = oldval; |
2360 XCONSOLE (Vselected_console)->local_var_flags &= ~mask; | 2348 XCONSOLE (Vselected_console)->local_var_flags &= ~mask; |
2361 } | 2349 } |
2362 return (variable); | 2350 return variable; |
2363 } | 2351 } |
2364 | 2352 |
2365 default: | 2353 default: |
2366 return (variable); | 2354 return variable; |
2367 } | 2355 } |
2368 RETURN_NOT_REACHED(Qnil) /* suppress compiler warning */ | 2356 RETURN_NOT_REACHED(Qnil) /* suppress compiler warning */ |
2369 } | 2357 } |
2370 | 2358 |
2371 /* Used by specbind to determine what effects it might have. Returns: | 2359 /* Used by specbind to determine what effects it might have. Returns: |
2403 = XSYMBOL_VALUE_FORWARD (valcontents); | 2391 = XSYMBOL_VALUE_FORWARD (valcontents); |
2404 int mask = XINT (*((Lisp_Object *) | 2392 int mask = XINT (*((Lisp_Object *) |
2405 symbol_value_forward_forward (fwd))); | 2393 symbol_value_forward_forward (fwd))); |
2406 if ((mask <= 0) || (buffer && (buffer->local_var_flags & mask))) | 2394 if ((mask <= 0) || (buffer && (buffer->local_var_flags & mask))) |
2407 /* Already buffer-local */ | 2395 /* Already buffer-local */ |
2408 return (1); | 2396 return 1; |
2409 else | 2397 else |
2410 /* Would be buffer-local after set */ | 2398 /* Would be buffer-local after set */ |
2411 return (-1); | 2399 return -1; |
2412 } | 2400 } |
2413 case SYMVAL_BUFFER_LOCAL: | 2401 case SYMVAL_BUFFER_LOCAL: |
2414 case SYMVAL_SOME_BUFFER_LOCAL: | 2402 case SYMVAL_SOME_BUFFER_LOCAL: |
2415 { | 2403 { |
2416 struct symbol_value_buffer_local *bfwd | 2404 struct symbol_value_buffer_local *bfwd |
2417 = XSYMBOL_VALUE_BUFFER_LOCAL (valcontents); | 2405 = XSYMBOL_VALUE_BUFFER_LOCAL (valcontents); |
2418 if (buffer | 2406 if (buffer |
2419 && !NILP (buffer_local_alist_element (buffer, symbol, bfwd))) | 2407 && !NILP (buffer_local_alist_element (buffer, symbol, bfwd))) |
2420 return (1); | 2408 return 1; |
2421 else | 2409 else |
2422 return ((bfwd->magic.type == SYMVAL_BUFFER_LOCAL) | 2410 /* Automatically becomes local when set */ |
2423 ? -1 /* Automatically becomes local when set */ | 2411 return bfwd->magic.type == SYMVAL_BUFFER_LOCAL ? -1 : 0; |
2424 : 0); | |
2425 } | 2412 } |
2426 default: | 2413 default: |
2427 return (0); | 2414 return 0; |
2428 } | 2415 } |
2429 } | 2416 } |
2430 return (0); | 2417 return 0; |
2431 } | 2418 } |
2432 | 2419 |
2433 | 2420 |
2434 DEFUN ("symbol-value-in-buffer", Fsymbol_value_in_buffer, 2, 3, 0, /* | 2421 DEFUN ("symbol-value-in-buffer", Fsymbol_value_in_buffer, 2, 3, 0, /* |
2435 Return the value of SYMBOL in BUFFER, or UNBOUND-VALUE if it is unbound. | 2422 Return the value of SYMBOL in BUFFER, or UNBOUND-VALUE if it is unbound. |
2439 Lisp_Object value; | 2426 Lisp_Object value; |
2440 CHECK_SYMBOL (symbol); | 2427 CHECK_SYMBOL (symbol); |
2441 CHECK_BUFFER (buffer); | 2428 CHECK_BUFFER (buffer); |
2442 value = symbol_value_in_buffer (symbol, buffer); | 2429 value = symbol_value_in_buffer (symbol, buffer); |
2443 if (UNBOUNDP (value)) | 2430 if (UNBOUNDP (value)) |
2444 return (unbound_value); | 2431 return unbound_value; |
2445 else | 2432 else |
2446 return (value); | 2433 return value; |
2447 } | 2434 } |
2448 | 2435 |
2449 DEFUN ("symbol-value-in-console", Fsymbol_value_in_console, 2, 3, 0, /* | 2436 DEFUN ("symbol-value-in-console", Fsymbol_value_in_console, 2, 3, 0, /* |
2450 Return the value of SYMBOL in CONSOLE, or UNBOUND-VALUE if it is unbound. | 2437 Return the value of SYMBOL in CONSOLE, or UNBOUND-VALUE if it is unbound. |
2451 */ | 2438 */ |
2454 Lisp_Object value; | 2441 Lisp_Object value; |
2455 CHECK_SYMBOL (symbol); | 2442 CHECK_SYMBOL (symbol); |
2456 CHECK_CONSOLE (console); | 2443 CHECK_CONSOLE (console); |
2457 value = symbol_value_in_console (symbol, console); | 2444 value = symbol_value_in_console (symbol, console); |
2458 if (UNBOUNDP (value)) | 2445 if (UNBOUNDP (value)) |
2459 return (unbound_value); | 2446 return unbound_value; |
2460 else | 2447 else |
2461 return (value); | 2448 return value; |
2462 } | 2449 } |
2463 | 2450 |
2464 DEFUN ("built-in-variable-type", Fbuilt_in_variable_type, 1, 1, 0, /* | 2451 DEFUN ("built-in-variable-type", Fbuilt_in_variable_type, 1, 1, 0, /* |
2465 If SYM is a built-in variable, return info about this; else return nil. | 2452 If SYM is a built-in variable, return info about this; else return nil. |
2466 The returned info will be a symbol, one of | 2453 The returned info will be a symbol, one of |
2497 { | 2484 { |
2498 case SYMVAL_LISP_MAGIC: | 2485 case SYMVAL_LISP_MAGIC: |
2499 valcontents = XSYMBOL_VALUE_LISP_MAGIC (valcontents)->shadowed; | 2486 valcontents = XSYMBOL_VALUE_LISP_MAGIC (valcontents)->shadowed; |
2500 /* semi-change-o */ | 2487 /* semi-change-o */ |
2501 goto retry_2; | 2488 goto retry_2; |
2502 | 2489 |
2503 case SYMVAL_VARALIAS: | 2490 case SYMVAL_VARALIAS: |
2504 sym = follow_varalias_pointers (sym, Qt); | 2491 sym = follow_varalias_pointers (sym, Qt); |
2505 /* presto change-o! */ | 2492 /* presto change-o! */ |
2506 goto retry; | 2493 goto retry; |
2507 | 2494 |
2579 the variable has had `make-variable-buffer-local' applied to it. | 2566 the variable has had `make-variable-buffer-local' applied to it. |
2580 */ | 2567 */ |
2581 (symbol, buffer, after_set)) | 2568 (symbol, buffer, after_set)) |
2582 { | 2569 { |
2583 int local_info; | 2570 int local_info; |
2584 | 2571 |
2585 CHECK_SYMBOL (symbol); | 2572 CHECK_SYMBOL (symbol); |
2586 if (!NILP (buffer)) | 2573 if (!NILP (buffer)) |
2587 { | 2574 { |
2588 buffer = get_buffer (buffer, 1); | 2575 buffer = get_buffer (buffer, 1); |
2589 local_info = symbol_value_buffer_local_info (symbol, XBUFFER (buffer)); | 2576 local_info = symbol_value_buffer_local_info (symbol, XBUFFER (buffer)); |
2590 } | 2577 } |
2591 else | 2578 else |
2592 { | 2579 { |
2593 local_info = symbol_value_buffer_local_info (symbol, 0); | 2580 local_info = symbol_value_buffer_local_info (symbol, 0); |
2594 } | 2581 } |
2595 | 2582 |
2596 if (NILP (after_set)) | 2583 if (NILP (after_set)) |
2597 return ((local_info > 0) ? Qt : Qnil); | 2584 return local_info > 0 ? Qt : Qnil; |
2598 else | 2585 else |
2599 return ((local_info != 0) ? Qt : Qnil); | 2586 return local_info != 0 ? Qt : Qnil; |
2600 } | 2587 } |
2601 | 2588 |
2602 | 2589 |
2603 /* | 2590 /* |
2604 I've gone ahead and partially implemented this because it's | 2591 I've gone ahead and partially implemented this because it's |
2605 super-useful for dealing with the compatibility problems in supporting | 2592 super-useful for dealing with the compatibility problems in supporting |
2606 the old pointer-shape variables, and preventing people from `setq'ing | 2593 the old pointer-shape variables, and preventing people from `setq'ing |
2607 the new variables. Any other way of handling this problem is way | 2594 the new variables. Any other way of handling this problem is way |
2608 ugly, likely to be slow, and generally not something I want to waste | 2595 ugly, likely to be slow, and generally not something I want to waste |
2647 would_be_magic_handled() so it knows about this, | 2634 would_be_magic_handled() so it knows about this, |
2648 or dire things could result. | 2635 or dire things could result. |
2649 ************************************************************ | 2636 ************************************************************ |
2650 NOTE NOTE NOTE NOTE NOTE NOTE NOTE | 2637 NOTE NOTE NOTE NOTE NOTE NOTE NOTE |
2651 | 2638 |
2652 Real documentation is as follows. | 2639 Real documentation is as follows. |
2653 | 2640 |
2654 Set a magic handler for VARIABLE. | 2641 Set a magic handler for VARIABLE. |
2655 This allows you to specify arbitrary behavior that results from | 2642 This allows you to specify arbitrary behavior that results from |
2656 accessing or setting a variable. For example, retrieving the | 2643 accessing or setting a variable. For example, retrieving the |
2657 variable's value might actually retrieve the first element off of | 2644 variable's value might actually retrieve the first element off of |
2717 | 2704 |
2718 The meanings of the arguments are as follows: | 2705 The meanings of the arguments are as follows: |
2719 | 2706 |
2720 SYM is the symbol on which the function was called, and is always | 2707 SYM is the symbol on which the function was called, and is always |
2721 the first argument to the function. | 2708 the first argument to the function. |
2722 | 2709 |
2723 ARGS are the remaining arguments in the original call (i.e. all | 2710 ARGS are the remaining arguments in the original call (i.e. all |
2724 but the first). In the case of `set-value' in particular, | 2711 but the first). In the case of `set-value' in particular, |
2725 the first element of ARGS is the value to which the variable | 2712 the first element of ARGS is the value to which the variable |
2726 is being set. In some cases, ARGS is sanitized from what was | 2713 is being set. In some cases, ARGS is sanitized from what was |
2727 actually given. For example, whenever `nil' is passed to an | 2714 actually given. For example, whenever `nil' is passed to an |
2728 argument and it means `current-buffer', the current buffer is | 2715 argument and it means `current-buffer', the current buffer is |
2729 substituted instead. | 2716 substituted instead. |
2730 | 2717 |
2731 FUN is a symbol indicating which function is being called. | 2718 FUN is a symbol indicating which function is being called. |
2732 For many of the functions, you can determine the corresponding | 2719 For many of the functions, you can determine the corresponding |
2733 function of a different class using | 2720 function of a different class using |
2734 `symbol-function-corresponding-function'. | 2721 `symbol-function-corresponding-function'. |
2735 | 2722 |
2736 HARG is the argument that was given in the call | 2723 HARG is the argument that was given in the call |
2737 to `set-symbol-value-handler' for SYM and HANDLER-TYPE. | 2724 to `set-symbol-value-handler' for SYM and HANDLER-TYPE. |
2738 | 2725 |
2739 HANDLERS is a structure containing the remaining handlers | 2726 HANDLERS is a structure containing the remaining handlers |
2740 for the variable; to call one of them, use | 2727 for the variable; to call one of them, use |
2741 `chain-to-symbol-value-handler'. | 2728 `chain-to-symbol-value-handler'. |
2742 | 2729 |
2743 NOTE: You may *not* modify the list in ARGS, and if you want to | 2730 NOTE: You may *not* modify the list in ARGS, and if you want to |
2746 */ | 2733 */ |
2747 | 2734 |
2748 static enum lisp_magic_handler | 2735 static enum lisp_magic_handler |
2749 decode_magic_handler_type (Lisp_Object symbol) | 2736 decode_magic_handler_type (Lisp_Object symbol) |
2750 { | 2737 { |
2751 if (EQ (symbol, Qget_value)) | 2738 if (EQ (symbol, Qget_value)) return MAGIC_HANDLER_GET_VALUE; |
2752 return MAGIC_HANDLER_GET_VALUE; | 2739 if (EQ (symbol, Qset_value)) return MAGIC_HANDLER_SET_VALUE; |
2753 if (EQ (symbol, Qset_value)) | 2740 if (EQ (symbol, Qbound_predicate)) return MAGIC_HANDLER_BOUND_PREDICATE; |
2754 return MAGIC_HANDLER_SET_VALUE; | 2741 if (EQ (symbol, Qmake_unbound)) return MAGIC_HANDLER_MAKE_UNBOUND; |
2755 if (EQ (symbol, Qbound_predicate)) | 2742 if (EQ (symbol, Qlocal_predicate)) return MAGIC_HANDLER_LOCAL_PREDICATE; |
2756 return MAGIC_HANDLER_BOUND_PREDICATE; | 2743 if (EQ (symbol, Qmake_local)) return MAGIC_HANDLER_MAKE_LOCAL; |
2757 if (EQ (symbol, Qmake_unbound)) | 2744 |
2758 return MAGIC_HANDLER_MAKE_UNBOUND; | |
2759 if (EQ (symbol, Qlocal_predicate)) | |
2760 return MAGIC_HANDLER_LOCAL_PREDICATE; | |
2761 if (EQ (symbol, Qmake_local)) | |
2762 return MAGIC_HANDLER_MAKE_LOCAL; | |
2763 signal_simple_error ("Unrecognized symbol value handler type", symbol); | 2745 signal_simple_error ("Unrecognized symbol value handler type", symbol); |
2764 abort (); | 2746 abort (); |
2765 return MAGIC_HANDLER_MAX; | 2747 return MAGIC_HANDLER_MAX; |
2766 } | 2748 } |
2767 | 2749 |
2955 | 2937 |
2956 static Lisp_Object | 2938 static Lisp_Object |
2957 follow_varalias_pointers (Lisp_Object object, | 2939 follow_varalias_pointers (Lisp_Object object, |
2958 Lisp_Object follow_past_lisp_magic) | 2940 Lisp_Object follow_past_lisp_magic) |
2959 { | 2941 { |
2960 Lisp_Object tortoise = object; | 2942 Lisp_Object tortoise = object; |
2961 Lisp_Object hare = object; | 2943 Lisp_Object hare = object; |
2962 | 2944 |
2963 /* quick out just in case */ | 2945 /* quick out just in case */ |
2964 if (!SYMBOL_VALUE_MAGIC_P (XSYMBOL (object)->value)) | 2946 if (!SYMBOL_VALUE_MAGIC_P (XSYMBOL (object)->value)) |
2965 return object; | 2947 return object; |
2981 value = fetch_value_maybe_past_magic (tortoise, follow_past_lisp_magic); | 2963 value = fetch_value_maybe_past_magic (tortoise, follow_past_lisp_magic); |
2982 tortoise = symbol_value_varalias_aliasee | 2964 tortoise = symbol_value_varalias_aliasee |
2983 (XSYMBOL_VALUE_VARALIAS (value)); | 2965 (XSYMBOL_VALUE_VARALIAS (value)); |
2984 | 2966 |
2985 if (EQ (hare, tortoise)) | 2967 if (EQ (hare, tortoise)) |
2986 return (Fsignal (Qcyclic_variable_indirection, list1 (object))); | 2968 return Fsignal (Qcyclic_variable_indirection, list1 (object)); |
2987 } | 2969 } |
2988 | 2970 |
2989 return hare; | 2971 return hare; |
2990 } | 2972 } |
2991 | 2973 |
3020 symbol_value_varalias_shadowed | 3002 symbol_value_varalias_shadowed |
3021 (XSYMBOL_VALUE_VARALIAS (valcontents)); | 3003 (XSYMBOL_VALUE_VARALIAS (valcontents)); |
3022 } | 3004 } |
3023 return Qnil; | 3005 return Qnil; |
3024 } | 3006 } |
3025 | 3007 |
3026 CHECK_SYMBOL (alias); | 3008 CHECK_SYMBOL (alias); |
3027 if (SYMBOL_VALUE_VARALIAS_P (valcontents)) | 3009 if (SYMBOL_VALUE_VARALIAS_P (valcontents)) |
3028 { | 3010 { |
3029 /* transmogrify */ | 3011 /* transmogrify */ |
3030 XSYMBOL_VALUE_VARALIAS (valcontents)->aliasee = alias; | 3012 XSYMBOL_VALUE_VARALIAS (valcontents)->aliasee = alias; |
3039 bfwd = alloc_lcrecord (sizeof (struct symbol_value_varalias), | 3021 bfwd = alloc_lcrecord (sizeof (struct symbol_value_varalias), |
3040 lrecord_symbol_value_varalias); | 3022 lrecord_symbol_value_varalias); |
3041 bfwd->magic.type = SYMVAL_VARALIAS; | 3023 bfwd->magic.type = SYMVAL_VARALIAS; |
3042 bfwd->aliasee = alias; | 3024 bfwd->aliasee = alias; |
3043 bfwd->shadowed = valcontents; | 3025 bfwd->shadowed = valcontents; |
3044 | 3026 |
3045 XSETSYMBOL_VALUE_MAGIC (valcontents, bfwd); | 3027 XSETSYMBOL_VALUE_MAGIC (valcontents, bfwd); |
3046 XSYMBOL (variable)->value = valcontents; | 3028 XSYMBOL (variable)->value = valcontents; |
3047 return Qnil; | 3029 return Qnil; |
3048 } | 3030 } |
3049 | 3031 |
3120 /* Bootstrapping problem: Qnil isn't set when make_pure_pname is | 3102 /* Bootstrapping problem: Qnil isn't set when make_pure_pname is |
3121 called the first time. */ | 3103 called the first time. */ |
3122 XSYMBOL (Qnil)->name->plist = Qnil; | 3104 XSYMBOL (Qnil)->name->plist = Qnil; |
3123 XSYMBOL (Qnil)->value = Qnil; /* Nihil ex nihil */ | 3105 XSYMBOL (Qnil)->value = Qnil; /* Nihil ex nihil */ |
3124 XSYMBOL (Qnil)->plist = Qnil; | 3106 XSYMBOL (Qnil)->plist = Qnil; |
3125 | 3107 |
3126 #ifndef Qzero | 3108 #ifndef Qzero |
3127 Qzero = make_int (0); /* Only used if Lisp_Object is a union type */ | 3109 Qzero = make_int (0); /* Only used if Lisp_Object is a union type */ |
3128 #endif | 3110 #endif |
3129 | 3111 |
3130 Vobarray = make_vector (OBARRAY_SIZE, Qzero); | 3112 Vobarray = make_vector (OBARRAY_SIZE, Qzero); |
3131 initial_obarray = Vobarray; | 3113 initial_obarray = Vobarray; |
3132 staticpro (&initial_obarray); | 3114 staticpro (&initial_obarray); |
3133 /* Intern nil in the obarray */ | 3115 /* Intern nil in the obarray */ |
3134 { | 3116 { |
3135 /* These locals are to kludge around a pyramid compiler bug. */ | 3117 /* These locals are to kludge around a pyramid compiler bug. */ |
3136 int hash; | 3118 int hash; |
3137 Lisp_Object *tem; | 3119 Lisp_Object *tem; |
3138 | 3120 |
3139 hash = hash_string (string_data (XSYMBOL (Qnil)->name), 3); | 3121 hash = hash_string (string_data (XSYMBOL (Qnil)->name), 3); |
3140 /* Separate statement here to avoid VAXC bug. */ | 3122 /* Separate statement here to avoid VAXC bug. */ |
3141 hash %= OBARRAY_SIZE; | 3123 hash %= OBARRAY_SIZE; |
3142 tem = &vector_data (XVECTOR (Vobarray))[hash]; | 3124 tem = &XVECTOR_DATA (Vobarray)[hash]; |
3143 *tem = Qnil; | 3125 *tem = Qnil; |
3144 } | 3126 } |
3145 | 3127 |
3146 { | 3128 { |
3147 /* Required to get around a GCC syntax error on certain | 3129 /* Required to get around a GCC syntax error on certain |
3148 architectures */ | 3130 architectures */ |
3149 struct symbol_value_magic *tem = &guts_of_unbound_marker; | 3131 struct symbol_value_magic *tem = &guts_of_unbound_marker; |
3150 | 3132 |
3151 XSETSYMBOL_VALUE_MAGIC (Qunbound, tem); | 3133 XSETSYMBOL_VALUE_MAGIC (Qunbound, tem); |
3152 } | 3134 } |
3153 if ((CONST void *) XPNTR (Qunbound) != | 3135 if ((CONST void *) XPNTR (Qunbound) != |
3154 (CONST void *)&guts_of_unbound_marker) | 3136 (CONST void *)&guts_of_unbound_marker) |
3155 { | 3137 { |
3159 So heap-allocate it. */ | 3141 So heap-allocate it. */ |
3160 struct symbol_value_magic *urk = xmalloc (sizeof (*urk)); | 3142 struct symbol_value_magic *urk = xmalloc (sizeof (*urk)); |
3161 memcpy (urk, &guts_of_unbound_marker, sizeof (*urk)); | 3143 memcpy (urk, &guts_of_unbound_marker, sizeof (*urk)); |
3162 XSETSYMBOL_VALUE_MAGIC (Qunbound, urk); | 3144 XSETSYMBOL_VALUE_MAGIC (Qunbound, urk); |
3163 } | 3145 } |
3164 | 3146 |
3165 XSYMBOL (Qnil)->function = Qunbound; | 3147 XSYMBOL (Qnil)->function = Qunbound; |
3166 | 3148 |
3167 defsymbol (&Qt, "t"); | 3149 defsymbol (&Qt, "t"); |
3168 XSYMBOL (Qt)->value = Qt; /* Veritas aetera */ | 3150 XSYMBOL (Qt)->value = Qt; /* Veritas aetera */ |
3169 Vquit_flag = Qnil; | 3151 Vquit_flag = Qnil; |
3170 } | 3152 } |
3171 | 3153 |
3199 { | 3181 { |
3200 /* Need to fix lisp.h and eval.c if SUBR_MAX_ARGS too small */ | 3182 /* Need to fix lisp.h and eval.c if SUBR_MAX_ARGS too small */ |
3201 assert (subr->max_args <= SUBR_MAX_ARGS); | 3183 assert (subr->max_args <= SUBR_MAX_ARGS); |
3202 assert (subr->min_args <= subr->max_args); | 3184 assert (subr->min_args <= subr->max_args); |
3203 } | 3185 } |
3204 | 3186 |
3205 assert (UNBOUNDP (XSYMBOL (sym)->function)); | 3187 assert (UNBOUNDP (XSYMBOL (sym)->function)); |
3206 #endif /* DEBUG_XEMACS */ | 3188 #endif /* DEBUG_XEMACS */ |
3207 | 3189 |
3208 XSETSUBR (XSYMBOL (sym)->function, subr); | 3190 XSETSUBR (XSYMBOL (sym)->function, subr); |
3209 } | 3191 } |
3304 DEFSUBR (Fdontusethis_set_symbol_value_handler); | 3286 DEFSUBR (Fdontusethis_set_symbol_value_handler); |
3305 } | 3287 } |
3306 | 3288 |
3307 /* Create and initialize a variable whose value is forwarded to C data */ | 3289 /* Create and initialize a variable whose value is forwarded to C data */ |
3308 void | 3290 void |
3309 defvar_mumble (CONST char *namestring, | 3291 defvar_mumble (CONST char *namestring, |
3310 CONST void *magic, int sizeof_magic) | 3292 CONST void *magic, int sizeof_magic) |
3311 { | 3293 { |
3312 Lisp_Object kludge; | 3294 Lisp_Object kludge; |
3313 Lisp_Object sym = Fintern (make_pure_pname ((CONST Bufbyte *) namestring, | 3295 Lisp_Object sym = Fintern (make_pure_pname ((CONST Bufbyte *) namestring, |
3314 strlen (namestring), | 3296 strlen (namestring), |