Index: src/textprop.c =================================================================== RCS file: /cvsroot/emacs/emacs/src/textprop.c,v retrieving revision 1.127 diff -u -d -r1.127 textprop.c --- src/textprop.c 29 Apr 2002 19:29:58 -0000 1.127 +++ src/textprop.c 30 May 2002 22:40:44 -0000 @@ -70,6 +70,7 @@ Lisp_Object Vinhibit_point_motion_hooks; Lisp_Object Vdefault_text_properties; +Lisp_Object Vchar_property_alternatives_alist; Lisp_Object Vtext_property_default_nonsticky; /* verify_interval_modification saves insertion hooks here @@ -2176,6 +2177,15 @@ The value of a property in this list is seen as the value for every character that does not have its own value for that property. */); Vdefault_text_properties = Qnil; + + DEFVAR_LISP ("char-property-alternatives-alist", &Vchar_property_alternatives_alist, + doc: /* Alist of alternative properties for properties without a value. +Each element should look like (PROPERTY ALTERNATIVE1 ALTERNATIVE2...). +If a piece of text has no direct value for a particular property, then +this alist is consulted. If that property appears in the alist, then +the first non-nil value from the associated alternative properties is +returned. */); + Vchar_property_alternatives_alist = Qnil; DEFVAR_LISP ("inhibit-point-motion-hooks", &Vinhibit_point_motion_hooks, doc: /* If non-nil, don't run `point-left' and `point-entered' text properties. Index: src/intervals.h =================================================================== RCS file: /cvsroot/emacs/emacs/src/intervals.h,v retrieving revision 1.48 diff -u -d -r1.48 intervals.h --- src/intervals.h 14 Mar 2002 08:09:59 -0000 1.48 +++ src/intervals.h 30 May 2002 22:40:44 -0000 @@ -267,6 +267,7 @@ extern Lisp_Object Vinhibit_point_motion_hooks; extern Lisp_Object Vdefault_text_properties; +extern Lisp_Object Vchar_property_alternatives_alist; extern Lisp_Object Vtext_property_default_nonsticky; /* Sticky properties */ Index: src/intervals.c =================================================================== RCS file: /cvsroot/emacs/emacs/src/intervals.c,v retrieving revision 1.113 diff -u -d -r1.113 intervals.c --- src/intervals.c 14 Mar 2002 08:11:46 -0000 1.113 +++ src/intervals.c 30 May 2002 22:40:44 -0000 @@ -1813,8 +1813,7 @@ Lisp_Object plist; register Lisp_Object prop; { - register Lisp_Object tail, fallback; - fallback = Qnil; + register Lisp_Object tail, fallback = Qnil; for (tail = plist; !NILP (tail); tail = Fcdr (Fcdr (tail))) { @@ -1834,7 +1833,18 @@ return fallback; if (CONSP (Vdefault_text_properties)) return Fplist_get (Vdefault_text_properties, prop); - return Qnil; + /* Check for alternative properties */ + tail = Fassq (prop, Vchar_property_alternatives_alist); + if (NILP (tail)) + return tail; + tail = XCDR (tail); + for (; NILP (fallback) && !NILP (tail); tail = XCDR (tail)) + { + if (!CONSP (tail)) + wrong_type_argument (Qlistp, tail); + fallback = Fplist_get (plist, XCAR (tail)); + } + return fallback; }