=== modified file 'src/xdisp.c' --- src/xdisp.c 2012-12-11 12:22:35 +0000 +++ src/xdisp.c 2012-12-12 08:44:59 +0000 @@ -2589,7 +2589,7 @@ ptrdiff_t charpos, ptrdiff_t bytepos, struct glyph_row *row, enum face_id base_face_id) { - int highlight_region_p; + ptrdiff_t markpos; enum face_id remapped_base_face_id = base_face_id; /* Some precondition checks. */ @@ -2692,16 +2692,20 @@ /* Are multibyte characters enabled in current_buffer? */ it->multibyte_p = !NILP (BVAR (current_buffer, enable_multibyte_characters)); - /* Non-zero if we should highlight the region. */ - highlight_region_p - = (!NILP (Vtransient_mark_mode) - && !NILP (BVAR (current_buffer, mark_active)) - && XMARKER (BVAR (current_buffer, mark))->buffer != 0); + /* If we should highlight the region and the region is + of non-zero length, store mark position in MARKPOS. */ + if (!NILP (Vtransient_mark_mode) + && !NILP (BVAR (current_buffer, mark_active)) + && XMARKER (BVAR (current_buffer, mark))->buffer != NULL + && (markpos = XMARKER (BVAR (current_buffer, mark))->charpos) != PT) + /* nothing */; + else + markpos = -1; /* Set IT->region_beg_charpos and IT->region_end_charpos to the start and end of a visible region in window IT->w. Set both to -1 to indicate no region. */ - if (highlight_region_p + if (markpos != -1 /* Maybe highlight only in selected window. */ && (/* Either show region everywhere. */ highlight_nonselected_windows @@ -2713,7 +2717,6 @@ && WINDOWP (minibuf_selected_window) && w == XWINDOW (minibuf_selected_window)))) { - ptrdiff_t markpos = marker_position (BVAR (current_buffer, mark)); it->region_beg_charpos = min (PT, markpos); it->region_end_charpos = max (PT, markpos); }