=== modified file 'src/textprop.c' --- trunk/src/textprop.c 2010-01-19 13:16:01 +0000 +++ patched/src/textprop.c 2010-05-22 01:39:11 +0000 @@ -629,6 +629,11 @@ Lisp_Object *overlay; { struct window *w = 0; + Lisp_Object tem = Qnil; + Lisp_Object tem_text = Qnil; + int priority; + int noverlays; + Lisp_Object *overlay_vec; CHECK_NUMBER_COERCE_MARKER (position); @@ -642,8 +647,6 @@ } if (BUFFERP (object)) { - int noverlays; - Lisp_Object *overlay_vec; struct buffer *obuf = current_buffer; if (XINT (position) < BUF_BEGV (XBUFFER (object)) @@ -658,26 +661,37 @@ set_buffer_temp (obuf); /* Now check the overlays in order of decreasing priority. */ - while (--noverlays >= 0) + while ( NILP (tem) && (--noverlays >= 0) ) { - Lisp_Object tem = Foverlay_get (overlay_vec[noverlays], prop); + tem = Foverlay_get (overlay_vec[noverlays], prop); if (!NILP (tem)) { - if (overlay) - /* Return the overlay we got the property from. */ - *overlay = overlay_vec[noverlays]; - return tem; + Lisp_Object tem_pri = Foverlay_get (overlay_vec[noverlays], Qpriority); + priority = (INTEGERP (tem_pri)) ? XINT (tem_pri) : 0; } } } - if (overlay) - /* Indicate that the return value is not from an overlay. */ - *overlay = Qnil; + /* Check what to return. */ + tem_text = Fget_text_property (position, prop, object); + if ( (!NILP (tem)) && ( (priority >= 0) + || NILP (tem_text) )) + { + if (overlay) + /* Return the overlay we got the property from. */ + *overlay = overlay_vec[noverlays]; + return tem; + } + else + { + if (overlay) + /* Indicate that the return value is not from an overlay. */ + *overlay = Qnil; - /* Not a buffer, or no appropriate overlay, so fall through to the - simpler case. */ - return Fget_text_property (position, prop, object); + /* Not a buffer, or no appropriate overlay, so fall through to the + simpler case. */ + return tem_text; + } } DEFUN ("get-char-property", Fget_char_property, Sget_char_property, 2, 3, 0, === modified file 'src/editfns.c' --- trunk/src/editfns.c 2010-03-24 18:02:56 +0000 +++ patched/src/editfns.c 2010-05-22 01:48:44 +0000 @@ -444,7 +444,9 @@ { int posn = XINT (position); int noverlays; - Lisp_Object *overlay_vec, tem; + Lisp_Object *overlay_vec; + Lisp_Object tem = Qnil; + Lisp_Object tem_pri; struct buffer *obuf = current_buffer; set_buffer_temp (XBUFFER (object)); @@ -466,7 +468,7 @@ set_buffer_temp (obuf); /* Now check the overlays in order of decreasing priority. */ - while (--noverlays >= 0) + while ( NILP (tem) && (--noverlays >= 0) ) { Lisp_Object ol = overlay_vec[noverlays]; tem = Foverlay_get (ol, prop); @@ -478,24 +480,28 @@ && XMARKER (start)->insertion_type == 1) || (OVERLAY_POSITION (finish) == posn && XMARKER (finish)->insertion_type == 0)) - ; /* The overlay will not cover a char inserted at point. */ + tem = Qnil; /* The overlay will not cover a char inserted at point. */ else { - return tem; + tem_pri = Foverlay_get (ol, Qpriority); + if (tem_pri >= 0) return tem; } } } { /* Now check the text properties. */ int stickiness = text_property_stickiness (prop, position, object); + Lisp_Object tem_text = Qnil; if (stickiness > 0) - return Fget_text_property (position, prop, object); + tem_text = Fget_text_property (position, prop, object); else if (stickiness < 0 && XINT (position) > BUF_BEGV (XBUFFER (object))) - return Fget_text_property (make_number (XINT (position) - 1), + tem_text = Fget_text_property (make_number (XINT (position) - 1), prop, object); + if (tem_text && (tem_pri < 0)) + return tem_text; else - return Qnil; + return tem; } } } === modified file 'src/xfaces.c' --- trunk/src/xfaces.c 2010-01-13 08:35:10 +0000 +++ patched/src/xfaces.c 2010-05-22 02:42:08 +0000 @@ -6278,7 +6278,7 @@ { struct frame *f = XFRAME (w->frame); Lisp_Object attrs[LFACE_VECTOR_SIZE]; - Lisp_Object prop, position; + Lisp_Object text_prop, prop, position; int i, noverlays; Lisp_Object *overlay_vec; Lisp_Object frame; @@ -6286,6 +6286,7 @@ Lisp_Object propname = mouse ? Qmouse_face : Qface; Lisp_Object limit1, end; struct face *default_face; + int text_merged = 0; /* W must display the current buffer. We could write this function to use the frame and buffer of W, but right now it doesn't. */ @@ -6300,7 +6301,7 @@ /* Get the `face' or `mouse_face' text property at POS, and determine the next position at which the property changes. */ - prop = Fget_text_property (position, propname, w->buffer); + text_prop = Fget_text_property (position, propname, w->buffer); XSETFASTINT (limit1, (limit < endpos ? limit : endpos)); end = Fnext_single_property_change (position, propname, w->buffer, limit1); if (INTEGERP (end)) @@ -6323,7 +6324,7 @@ /* Optimize common cases where we can use the default face. */ if (noverlays == 0 - && NILP (prop) + && NILP (text_prop) && !(pos >= region_beg && pos < region_end)) return default_face->id; @@ -6331,16 +6332,26 @@ bcopy (default_face->lface, attrs, sizeof attrs); /* Merge in attributes specified via text properties. */ - if (!NILP (prop)) - merge_face_ref (f, prop, attrs, 1, 0); + /* if (!NILP (prop)) */ + /* merge_face_ref (f, prop, attrs, 1, 0); */ - /* Now merge the overlay data. */ + /* Now merge the overlay data and the text properties. */ + if (NILP (text_prop)) text_merged = 1; noverlays = sort_overlays (overlay_vec, noverlays, w); for (i = 0; i < noverlays; i++) { Lisp_Object oend; int oendpos; + if (!text_merged) + { + int priority = Foverlay_get (overlay_vec[i], Qpriority); + if (priority >= 0) + { + merge_face_ref (f, text_prop, attrs, 1, 0); + text_merged = 1; + } + } prop = Foverlay_get (overlay_vec[i], propname); if (!NILP (prop)) merge_face_ref (f, prop, attrs, 1, 0); @@ -6350,6 +6361,9 @@ if (oendpos < endpos) endpos = oendpos; } + /* If there were no overlays or all had negative prioriteis we have + not handled text properties yet. */ + if (!text_merged) merge_face_ref (f, text_prop, attrs, 1, 0); /* If in the region, merge in the region face. */ if (pos >= region_beg && pos < region_end) === modified file 'src/lisp.h' --- trunk/src/lisp.h 2010-05-15 21:19:05 +0000 +++ patched/src/lisp.h 2010-05-22 13:50:56 +0000 @@ -2973,1 +2973,1 @@ extern void set_time_zone_rule P_ ((char *)); /* defined in buffer.c */ +extern Lisp_Object Qpriority; extern int mouse_face_overlay_overlaps P_ ((Lisp_Object)); extern void nsberror P_ ((Lisp_Object)) NO_RETURN; EXFUN (Fset_buffer_multibyte, 1);