From: Dmitry Antipov Date: Sun, 1 Sep 2013 16:21:48 +0000 (+0400) Subject: * dispextern.h (SET_TEXT_POS_FROM_MARKER): Indent. X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~387^2~1686^2~31 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=cf91889acb493863b93dc199d2a39e7f3a9b4cd4;p=emacs.git * 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. --- diff --git a/src/ChangeLog b/src/ChangeLog index 7c09394cbf8..96df66999da 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2013-09-01 Dmitry Antipov + + * 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 * fontset.c (face_for_char): Check char in the current face font first diff --git a/src/dispextern.h b/src/dispextern.h index ce9a34a2e71..947e50fa4dd 100644 --- a/src/dispextern.h +++ b/src/dispextern.h @@ -223,8 +223,16 @@ struct text_pos /* 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. */ diff --git a/src/dispnew.c b/src/dispnew.c index f2298ffabe4..0e336d4feea 100644 --- a/src/dispnew.c +++ b/src/dispnew.c @@ -5066,9 +5066,7 @@ buffer_posn_from_coords (struct window *w, int *x, int *y, struct display_pos *p 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 diff --git a/src/window.c b/src/window.c index 560f31e2c27..ef96861dc71 100644 --- a/src/window.c +++ b/src/window.c @@ -1494,7 +1494,6 @@ if it isn't already recorded. */) && !noninteractive) { struct text_pos startp; - ptrdiff_t charpos = marker_position (w->start); struct it it; struct buffer *old_buffer = NULL; void *itdata = NULL; @@ -1512,12 +1511,7 @@ if it isn't already recorded. */) `-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); @@ -5038,7 +5032,6 @@ displayed_window_lines (struct window *w) { 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; @@ -5055,12 +5048,7 @@ displayed_window_lines (struct window *w) /* 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); diff --git a/src/xdisp.c b/src/xdisp.c index b65800bd4c4..d78e78a58d3 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -20606,13 +20606,8 @@ redisplay_mode_lines (Lisp_Object window, int force) { 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. */