(CLIP_TEXT_POS_FROM_MARKER): New macro.
* dispnew.c (buffer_posn_from_coords):
* window.c (Fwindow_end, displayed_window_lines):
* xdisp.c (redisplay_mode_lines): Use it.
+2013-09-01 Dmitry Antipov <dmantipov@yandex.ru>
+
+ * dispextern.h (SET_TEXT_POS_FROM_MARKER): Indent.
+ (CLIP_TEXT_POS_FROM_MARKER): New macro.
+ * dispnew.c (buffer_posn_from_coords):
+ * window.c (Fwindow_end, displayed_window_lines):
+ * xdisp.c (redisplay_mode_lines): Use it.
+
2013-09-01 Jan Djärv <jan.h.d@swipnet.se>
* fontset.c (face_for_char): Check char in the current face font first
/* Set text position POS from marker MARKER. */
#define SET_TEXT_POS_FROM_MARKER(POS, MARKER) \
- (CHARPOS (POS) = marker_position ((MARKER)), \
- BYTEPOS (POS) = marker_byte_position ((MARKER)))
+ (CHARPOS (POS) = marker_position (MARKER), \
+ BYTEPOS (POS) = marker_byte_position (MARKER))
+
+/* Like above, but clip POS within accessible range. */
+
+#define CLIP_TEXT_POS_FROM_MARKER(POS, MARKER) \
+ (CHARPOS (POS) = clip_to_bounds \
+ (BEGV, marker_position (MARKER), ZV), \
+ BYTEPOS (POS) = clip_to_bounds \
+ (BEGV_BYTE, marker_byte_position (MARKER), ZV_BYTE))
/* Set marker MARKER from text position POS. */
wrong thing with `face-remapping-alist' (bug#2044). */
Fset_buffer (w->contents);
itdata = bidi_shelve_cache ();
- SET_TEXT_POS_FROM_MARKER (startp, w->start);
- CHARPOS (startp) = min (ZV, max (BEGV, CHARPOS (startp)));
- BYTEPOS (startp) = min (ZV_BYTE, max (BEGV_BYTE, BYTEPOS (startp)));
+ CLIP_TEXT_POS_FROM_MARKER (startp, w->start);
start_display (&it, w, startp);
/* start_display takes into account the header-line row, but IT's
vpos still counts from the glyph row that includes the window's
&& !noninteractive)
{
struct text_pos startp;
- ptrdiff_t charpos = marker_position (w->start);
struct it it;
struct buffer *old_buffer = NULL;
void *itdata = NULL;
`-l' containing a call to `rmail' with subsequent other
commands. At the end, W->start happened to be BEG, while
rmail had already narrowed the buffer. */
- if (charpos < BEGV)
- SET_TEXT_POS (startp, BEGV, BEGV_BYTE);
- else if (charpos > ZV)
- SET_TEXT_POS (startp, ZV, ZV_BYTE);
- else
- SET_TEXT_POS_FROM_MARKER (startp, w->start);
+ CLIP_TEXT_POS_FROM_MARKER (startp, w->start);
itdata = bidi_shelve_cache ();
start_display (&it, w, startp);
{
struct it it;
struct text_pos start;
- ptrdiff_t charpos = marker_position (w->start);
int height = window_box_height (w);
struct buffer *old_buffer;
int bottom_y;
/* In case W->start is out of the accessible range, do something
reasonable. This happens in Info mode when Info-scroll-down
calls (recenter -1) while W->start is 1. */
- if (charpos < BEGV)
- SET_TEXT_POS (start, BEGV, BEGV_BYTE);
- else if (charpos > ZV)
- SET_TEXT_POS (start, ZV, ZV_BYTE);
- else
- SET_TEXT_POS_FROM_MARKER (start, w->start);
+ CLIP_TEXT_POS_FROM_MARKER (start, w->start);
itdata = bidi_shelve_cache ();
start_display (&it, w, start);
{
struct text_pos pt;
- SET_TEXT_POS_FROM_MARKER (pt, w->pointm);
- if (CHARPOS (pt) < BEGV)
- TEMP_SET_PT_BOTH (BEGV, BEGV_BYTE);
- else if (CHARPOS (pt) > (ZV - 1))
- TEMP_SET_PT_BOTH (ZV, ZV_BYTE);
- else
- TEMP_SET_PT_BOTH (CHARPOS (pt), BYTEPOS (pt));
+ CLIP_TEXT_POS_FROM_MARKER (pt, w->pointm);
+ TEMP_SET_PT_BOTH (CHARPOS (pt), BYTEPOS (pt));
}
/* Display mode lines. */