Mercurial > hg > xemacs-beta
comparison src/specifier.c @ 408:501cfd01ee6d r21-2-34
Import from CVS: tag r21-2-34
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:18:11 +0200 |
parents | 2f8bb876ab1d |
children | de805c49cfc1 |
comparison
equal
deleted
inserted
replaced
407:ed6218a7d4d3 | 408:501cfd01ee6d |
---|---|
530 DEFUN ("make-specifier", Fmake_specifier, 1, 1, 0, /* | 530 DEFUN ("make-specifier", Fmake_specifier, 1, 1, 0, /* |
531 Return a new specifier object of type TYPE. | 531 Return a new specifier object of type TYPE. |
532 | 532 |
533 A specifier is an object that can be used to keep track of a property | 533 A specifier is an object that can be used to keep track of a property |
534 whose value can be per-buffer, per-window, per-frame, or per-device, | 534 whose value can be per-buffer, per-window, per-frame, or per-device, |
535 and can further be restricted to a particular console-type or device-class. | 535 and can further be restricted to a particular console-type or |
536 Specifiers are used, for example, for the various built-in properties of a | 536 device-class. Specifiers are used, for example, for the various |
537 face; this allows a face to have different values in different frames, | 537 built-in properties of a face; this allows a face to have different |
538 buffers, etc. For more information, see `specifier-instance', | 538 values in different frames, buffers, etc. |
539 | |
540 When speaking of the value of a specifier, it is important to | |
541 distinguish between the *setting* of a specifier, called an | |
542 \"instantiator\", and the *actual value*, called an \"instance\". You | |
543 put various possible instantiators (i.e. settings) into a specifier | |
544 and associate them with particular locales (buffer, window, frame, | |
545 device, global), and then the instance (i.e. actual value) is | |
546 retrieved in a specific domain (window, frame, device) by looking | |
547 through the possible instantiators (i.e. settings). This process is | |
548 called \"instantiation\". | |
549 | |
550 To put settings into a specifier, use `set-specifier', or the | |
551 lower-level functions `add-spec-to-specifier' and | |
552 `add-spec-list-to-specifier'. You can also temporarily bind a setting | |
553 to a specifier using `let-specifier'. To retrieve settings, use | |
554 `specifier-specs', or its lower-level counterpart | |
555 `specifier-spec-list'. To determine the actual value, use | |
556 `specifier-instance'. | |
557 | |
558 For more information, see `set-specifier', `specifier-instance', | |
539 `specifier-specs', and `add-spec-to-specifier'; or, for a detailed | 559 `specifier-specs', and `add-spec-to-specifier'; or, for a detailed |
540 description of specifiers, including how they are instantiated over a | 560 description of specifiers, including how exactly the instantiation |
541 particular domain (i.e. how their value in that domain is determined), | 561 process works, see the chapter on specifiers in the XEmacs Lisp |
542 see the chapter on specifiers in the XEmacs Lisp Reference Manual. | 562 Reference Manual. |
543 | 563 |
544 TYPE specifies the particular type of specifier, and should be one of | 564 TYPE specifies the particular type of specifier, and should be one of |
545 the symbols 'generic, 'integer, 'boolean, 'color, 'font, 'image, | 565 the symbols 'generic, 'integer, 'natnum, 'boolean, 'color, 'font, |
546 'face-boolean, 'gutter, 'gutter-size, 'gutter-visible or 'toolbar. | 566 'image, 'face-boolean, 'display-table, 'gutter, 'gutter-size, |
567 'gutter-visible or 'toolbar. | |
547 | 568 |
548 For more information on particular types of specifiers, see the | 569 For more information on particular types of specifiers, see the |
549 functions `generic-specifier-p', `integer-specifier-p', | 570 functions `make-generic-specifier', `make-integer-specifier', |
550 `boolean-specifier-p', `color-specifier-p', `font-specifier-p', | 571 `make-natnum-specifier', `make-boolean-specifier', |
551 `image-specifier-p', `face-boolean-specifier-p', `gutter-specifier-p, | 572 `make-color-specifier', `make-font-specifier', `make-image-specifier', |
552 `gutter-size-specifier-p, `gutter-visible-specifier-p and | 573 `make-face-boolean-specifier', `make-gutter-size-specifier', |
553 `toolbar-specifier-p'. | 574 `make-gutter-visible-specifier', `default-toolbar', `default-gutter', |
575 and `current-display-table'. | |
554 */ | 576 */ |
555 (type)) | 577 (type)) |
556 { | 578 { |
557 /* This function can GC */ | 579 /* This function can GC */ |
558 struct specifier_methods *meths = decode_specifier_type (type, | 580 struct specifier_methods *meths = decode_specifier_type (type, ERROR_ME); |
559 ERROR_ME); | |
560 | 581 |
561 return make_specifier (meths); | 582 return make_specifier (meths); |
562 } | 583 } |
563 | 584 |
564 DEFUN ("specifierp", Fspecifierp, 1, 1, 0, /* | 585 DEFUN ("specifierp", Fspecifierp, 1, 1, 0, /* |
607 } | 628 } |
608 | 629 |
609 DEFUN ("valid-specifier-domain-p", Fvalid_specifier_domain_p, 1, 1, 0, /* | 630 DEFUN ("valid-specifier-domain-p", Fvalid_specifier_domain_p, 1, 1, 0, /* |
610 Return t if DOMAIN is a valid specifier domain. | 631 Return t if DOMAIN is a valid specifier domain. |
611 A domain is used to instance a specifier (i.e. determine the specifier's | 632 A domain is used to instance a specifier (i.e. determine the specifier's |
612 value in that domain). Valid domains are windows, frames, and devices. | 633 value in that domain). Valid domains are image instances, windows, frames, |
613 \(nil is not valid.) | 634 and devices. \(nil is not valid.) image instances are pseudo-domains since |
635 instantiation will actually occur in the window the image instance itself is | |
636 instantiated in. | |
614 */ | 637 */ |
615 (domain)) | 638 (domain)) |
616 { | 639 { |
617 /* This cannot GC. */ | 640 /* This cannot GC. */ |
618 return ((DEVICEP (domain) && DEVICE_LIVE_P (XDEVICE (domain))) || | 641 return ((DEVICEP (domain) && DEVICE_LIVE_P (XDEVICE (domain))) || |
619 (FRAMEP (domain) && FRAME_LIVE_P (XFRAME (domain))) || | 642 (FRAMEP (domain) && FRAME_LIVE_P (XFRAME (domain))) || |
620 (WINDOWP (domain) && WINDOW_LIVE_P (XWINDOW (domain)))) | 643 (WINDOWP (domain) && WINDOW_LIVE_P (XWINDOW (domain))) || |
644 /* #### get image instances out of domains! */ | |
645 IMAGE_INSTANCEP (domain)) | |
621 ? Qt : Qnil; | 646 ? Qt : Qnil; |
622 } | 647 } |
623 | 648 |
624 DEFUN ("valid-specifier-locale-type-p", Fvalid_specifier_locale_type_p, 1, 1, 0, /* | 649 DEFUN ("valid-specifier-locale-type-p", Fvalid_specifier_locale_type_p, 1, 1, 0, /* |
625 Given a specifier LOCALE-TYPE, return non-nil if it is valid. | 650 Given a specifier LOCALE-TYPE, return non-nil if it is valid. |
727 { | 752 { |
728 if (NILP (Fvalid_specifier_domain_p (domain))) | 753 if (NILP (Fvalid_specifier_domain_p (domain))) |
729 signal_simple_error ("Invalid specifier domain", domain); | 754 signal_simple_error ("Invalid specifier domain", domain); |
730 } | 755 } |
731 | 756 |
732 static Lisp_Object | 757 Lisp_Object |
733 decode_domain (Lisp_Object domain) | 758 decode_domain (Lisp_Object domain) |
734 { | 759 { |
735 if (NILP (domain)) | 760 if (NILP (domain)) |
736 return Fselected_window (Qnil); | 761 return Fselected_window (Qnil); |
737 check_valid_domain (domain); | 762 check_valid_domain (domain); |
2433 struct gcpro gcpro1, gcpro2; | 2458 struct gcpro gcpro1, gcpro2; |
2434 | 2459 |
2435 GCPRO2 (specifier, inst_list); | 2460 GCPRO2 (specifier, inst_list); |
2436 | 2461 |
2437 sp = XSPECIFIER (specifier); | 2462 sp = XSPECIFIER (specifier); |
2438 device = DFW_DEVICE (domain); | 2463 device = DOMAIN_DEVICE (domain); |
2439 | 2464 |
2440 if (no_quit) | 2465 if (no_quit) |
2441 /* The instantiate method is allowed to call eval. Since it | 2466 /* The instantiate method is allowed to call eval. Since it |
2442 is quite common for this function to get called from somewhere in | 2467 is quite common for this function to get called from somewhere in |
2443 redisplay we need to make sure that quits are ignored. Otherwise | 2468 redisplay we need to make sure that quits are ignored. Otherwise |
2513 | 2538 |
2514 sp = XSPECIFIER (specifier); | 2539 sp = XSPECIFIER (specifier); |
2515 | 2540 |
2516 /* Attempt to determine buffer, window, frame, and device from the | 2541 /* Attempt to determine buffer, window, frame, and device from the |
2517 domain. */ | 2542 domain. */ |
2518 if (WINDOWP (domain)) | 2543 /* #### get image instances out of domains! */ |
2544 if (IMAGE_INSTANCEP (domain)) | |
2545 window = DOMAIN_WINDOW (domain); | |
2546 else if (WINDOWP (domain)) | |
2519 window = domain; | 2547 window = domain; |
2520 else if (FRAMEP (domain)) | 2548 else if (FRAMEP (domain)) |
2521 frame = domain; | 2549 frame = domain; |
2522 else if (DEVICEP (domain)) | 2550 else if (DEVICEP (domain)) |
2523 device = domain; | 2551 device = domain; |
2524 else | 2552 else |
2525 /* #### dmoore - dammit, this should just signal an error or something | 2553 /* dmoore writes: [dammit, this should just signal an error or something |
2526 shouldn't it? | 2554 shouldn't it?] |
2527 #### No. Errors are handled in Lisp primitives implementation. | 2555 |
2556 No. Errors are handled in Lisp primitives implementation. | |
2528 Invalid domain is a design error here - kkm. */ | 2557 Invalid domain is a design error here - kkm. */ |
2529 abort (); | 2558 abort (); |
2530 | 2559 |
2531 if (NILP (buffer) && !NILP (window)) | 2560 if (NILP (buffer) && !NILP (window)) |
2532 buffer = XWINDOW (window)->buffer; | 2561 buffer = XWINDOW (window)->buffer; |
2957 is supposed to require only that the specifier type is passed, | 2986 is supposed to require only that the specifier type is passed, |
2958 while with this approach the actual specifier is needed.) | 2987 while with this approach the actual specifier is needed.) |
2959 | 2988 |
2960 What really needs to be done is to write a function | 2989 What really needs to be done is to write a function |
2961 `make-specifier-type' that creates new specifier types. | 2990 `make-specifier-type' that creates new specifier types. |
2962 #### I'll look into this for 19.14. | 2991 |
2963 */ | 2992 #### [I'll look into this for 19.14.] Well, sometime. (Currently |
2993 May 2000, 21.2 is in development. 19.14 was released in June 1996.) */ | |
2964 | 2994 |
2965 "A generic specifier is a generalized kind of specifier with user-defined\n" | 2995 "A generic specifier is a generalized kind of specifier with user-defined\n" |
2966 "semantics. The instantiator can be any kind of Lisp object, and the\n" | 2996 "semantics. The instantiator can be any kind of Lisp object, and the\n" |
2967 "instance computed from it is likewise any kind of Lisp object. The\n" | 2997 "instance computed from it is likewise any kind of Lisp object. The\n" |
2968 "SPECIFIER-DATA should be an alist of methods governing how the specifier\n" | 2998 "SPECIFIER-DATA should be an alist of methods governing how the specifier\n" |
2995 #endif /* 0 */ | 3025 #endif /* 0 */ |
2996 | 3026 |
2997 DEFUN ("generic-specifier-p", Fgeneric_specifier_p, 1, 1, 0, /* | 3027 DEFUN ("generic-specifier-p", Fgeneric_specifier_p, 1, 1, 0, /* |
2998 Return non-nil if OBJECT is a generic specifier. | 3028 Return non-nil if OBJECT is a generic specifier. |
2999 | 3029 |
3000 A generic specifier allows any kind of Lisp object as an instantiator, | 3030 See `make-generic-specifier' for a description of possible generic |
3001 and returns back the Lisp object unchanged when it is instantiated. | 3031 instantiators. |
3002 */ | 3032 */ |
3003 (object)) | 3033 (object)) |
3004 { | 3034 { |
3005 return GENERIC_SPECIFIERP (object) ? Qt : Qnil; | 3035 return GENERIC_SPECIFIERP (object) ? Qt : Qnil; |
3006 } | 3036 } |
3018 CHECK_INT (instantiator); | 3048 CHECK_INT (instantiator); |
3019 } | 3049 } |
3020 | 3050 |
3021 DEFUN ("integer-specifier-p", Finteger_specifier_p, 1, 1, 0, /* | 3051 DEFUN ("integer-specifier-p", Finteger_specifier_p, 1, 1, 0, /* |
3022 Return non-nil if OBJECT is an integer specifier. | 3052 Return non-nil if OBJECT is an integer specifier. |
3053 | |
3054 See `make-integer-specifier' for a description of possible integer | |
3055 instantiators. | |
3023 */ | 3056 */ |
3024 (object)) | 3057 (object)) |
3025 { | 3058 { |
3026 return INTEGER_SPECIFIERP (object) ? Qt : Qnil; | 3059 return INTEGER_SPECIFIERP (object) ? Qt : Qnil; |
3027 } | 3060 } |
3038 CHECK_NATNUM (instantiator); | 3071 CHECK_NATNUM (instantiator); |
3039 } | 3072 } |
3040 | 3073 |
3041 DEFUN ("natnum-specifier-p", Fnatnum_specifier_p, 1, 1, 0, /* | 3074 DEFUN ("natnum-specifier-p", Fnatnum_specifier_p, 1, 1, 0, /* |
3042 Return non-nil if OBJECT is a natnum (non-negative-integer) specifier. | 3075 Return non-nil if OBJECT is a natnum (non-negative-integer) specifier. |
3076 | |
3077 See `make-natnum-specifier' for a description of possible natnum | |
3078 instantiators. | |
3043 */ | 3079 */ |
3044 (object)) | 3080 (object)) |
3045 { | 3081 { |
3046 return NATNUM_SPECIFIERP (object) ? Qt : Qnil; | 3082 return NATNUM_SPECIFIERP (object) ? Qt : Qnil; |
3047 } | 3083 } |
3059 signal_simple_error ("Must be t or nil", instantiator); | 3095 signal_simple_error ("Must be t or nil", instantiator); |
3060 } | 3096 } |
3061 | 3097 |
3062 DEFUN ("boolean-specifier-p", Fboolean_specifier_p, 1, 1, 0, /* | 3098 DEFUN ("boolean-specifier-p", Fboolean_specifier_p, 1, 1, 0, /* |
3063 Return non-nil if OBJECT is a boolean specifier. | 3099 Return non-nil if OBJECT is a boolean specifier. |
3100 | |
3101 See `make-boolean-specifier' for a description of possible boolean | |
3102 instantiators. | |
3064 */ | 3103 */ |
3065 (object)) | 3104 (object)) |
3066 { | 3105 { |
3067 return BOOLEAN_SPECIFIERP (object) ? Qt : Qnil; | 3106 return BOOLEAN_SPECIFIERP (object) ? Qt : Qnil; |
3068 } | 3107 } |
3071 /* Display table specifier type */ | 3110 /* Display table specifier type */ |
3072 /************************************************************************/ | 3111 /************************************************************************/ |
3073 | 3112 |
3074 DEFINE_SPECIFIER_TYPE (display_table); | 3113 DEFINE_SPECIFIER_TYPE (display_table); |
3075 | 3114 |
3076 #define VALID_SINGLE_DISPTABLE_INSTANTIATOR_P(instantiator) \ | 3115 #define VALID_SINGLE_DISPTABLE_INSTANTIATOR_P(instantiator) \ |
3077 (VECTORP (instantiator) \ | 3116 (VECTORP (instantiator) \ |
3078 || (CHAR_TABLEP (instantiator) \ | 3117 || (CHAR_TABLEP (instantiator) \ |
3079 && (XCHAR_TABLE_TYPE (instantiator) == CHAR_TABLE_TYPE_CHAR \ | 3118 && (XCHAR_TABLE_TYPE (instantiator) == CHAR_TABLE_TYPE_CHAR \ |
3080 || XCHAR_TABLE_TYPE (instantiator) == CHAR_TABLE_TYPE_GENERIC)) \ | 3119 || XCHAR_TABLE_TYPE (instantiator) == CHAR_TABLE_TYPE_GENERIC)) \ |
3081 || RANGE_TABLEP (instantiator)) | 3120 || RANGE_TABLEP (instantiator)) |
3082 | 3121 |
3083 static void | 3122 static void |
3084 display_table_validate (Lisp_Object instantiator) | 3123 display_table_validate (Lisp_Object instantiator) |
3085 { | 3124 { |
3107 } | 3146 } |
3108 } | 3147 } |
3109 | 3148 |
3110 DEFUN ("display-table-specifier-p", Fdisplay_table_specifier_p, 1, 1, 0, /* | 3149 DEFUN ("display-table-specifier-p", Fdisplay_table_specifier_p, 1, 1, 0, /* |
3111 Return non-nil if OBJECT is a display-table specifier. | 3150 Return non-nil if OBJECT is a display-table specifier. |
3151 | |
3152 See `current-display-table' for a description of possible display-table | |
3153 instantiators. | |
3112 */ | 3154 */ |
3113 (object)) | 3155 (object)) |
3114 { | 3156 { |
3115 return DISPLAYTABLE_SPECIFIERP (object) ? Qt : Qnil; | 3157 return DISPLAYTABLE_SPECIFIERP (object) ? Qt : Qnil; |
3116 } | 3158 } |