emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r113865: * xdisp.c (adjust_window_ends): Move duplic


From: Dmitry Antipov
Subject: [Emacs-diffs] trunk r113865: * xdisp.c (adjust_window_ends): Move duplicated code to new function.
Date: Wed, 14 Aug 2013 06:21:43 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 113865
revision-id: address@hidden
parent: address@hidden
committer: Dmitry Antipov <address@hidden>
branch nick: trunk
timestamp: Wed 2013-08-14 10:06:56 +0400
message:
  * xdisp.c (adjust_window_ends): Move duplicated code to new function.
  (try_window, try_window_reusing_current_matrix, try_window_id): Use it.
modified:
  src/ChangeLog                  changelog-20091113204419-o5vbwnq5f7feedwu-1438
  src/xdisp.c                    xdisp.c-20091113204419-o5vbwnq5f7feedwu-240
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2013-08-14 05:41:48 +0000
+++ b/src/ChangeLog     2013-08-14 06:06:56 +0000
@@ -1,5 +1,10 @@
 2013-08-14  Dmitry Antipov  <address@hidden>
 
+       * xdisp.c (adjust_window_ends): Move duplicated code to new function.
+       (try_window, try_window_reusing_current_matrix, try_window_id): Use it.
+
+2013-08-14  Dmitry Antipov  <address@hidden>
+
        * window.h (struct window): Convert window_end_pos and
        window_end_vpos from Lisp_Object to ptrdiff_t and int, respectively.
        (wset_window_end_pos, wset_window_end_vpos): Remove.

=== modified file 'src/xdisp.c'
--- a/src/xdisp.c       2013-08-14 05:41:48 +0000
+++ b/src/xdisp.c       2013-08-14 06:06:56 +0000
@@ -2461,7 +2461,16 @@
 
 #endif /* HAVE_WINDOW_SYSTEM */
 
-
+static void
+adjust_window_ends (struct window *w, struct glyph_row *row, bool current)
+{
+  eassert (w);
+  w->window_end_pos = Z - MATRIX_ROW_END_CHARPOS (row);
+  w->window_end_bytepos = Z_BYTE - MATRIX_ROW_END_BYTEPOS (row);
+  w->window_end_vpos
+    = MATRIX_ROW_VPOS (row, current ? w->current_matrix : w->desired_matrix);
+}
+
 /***********************************************************************
                        Lisp form evaluation
  ***********************************************************************/
@@ -16291,9 +16300,7 @@
   if (last_text_row)
     {
       eassert (MATRIX_ROW_DISPLAYS_TEXT_P (last_text_row));
-      w->window_end_bytepos = Z_BYTE - MATRIX_ROW_END_BYTEPOS (last_text_row);
-      w->window_end_pos = Z - MATRIX_ROW_END_CHARPOS (last_text_row);
-      w->window_end_vpos = MATRIX_ROW_VPOS (last_text_row, w->desired_matrix);
+      adjust_window_ends (w, last_text_row, 0);
       eassert
        (MATRIX_ROW_DISPLAYS_TEXT_P (MATRIX_ROW (w->desired_matrix,
                                                 w->window_end_vpos)));
@@ -16526,23 +16533,9 @@
         The value of last_text_row is the last displayed line
         containing text.  */
       if (last_reused_text_row)
-       {
-         w->window_end_bytepos
-           = Z_BYTE - MATRIX_ROW_END_BYTEPOS (last_reused_text_row);
-         w->window_end_pos
-           = Z - MATRIX_ROW_END_CHARPOS (last_reused_text_row);
-         w->window_end_vpos
-           = MATRIX_ROW_VPOS (last_reused_text_row, w->current_matrix);
-       }
+       adjust_window_ends (w, last_reused_text_row, 1);
       else if (last_text_row)
-       {
-         w->window_end_bytepos
-           = Z_BYTE - MATRIX_ROW_END_BYTEPOS (last_text_row);
-         w->window_end_pos
-           = Z - MATRIX_ROW_END_CHARPOS (last_text_row);
-         w->window_end_vpos
-           = MATRIX_ROW_VPOS (last_text_row, w->desired_matrix);
-       }
+       adjust_window_ends (w, last_text_row, 0);
       else
        {
          /* This window must be completely empty.  */
@@ -16733,14 +16726,7 @@
         the window end is in reused rows which in turn means that
         only its vpos can have changed.  */
       if (last_text_row)
-       {
-         w->window_end_bytepos
-           = Z_BYTE - MATRIX_ROW_END_BYTEPOS (last_text_row);
-         w->window_end_pos
-           = Z - MATRIX_ROW_END_CHARPOS (last_text_row);
-         w->window_end_vpos
-           = MATRIX_ROW_VPOS (last_text_row, w->desired_matrix);
-       }
+       adjust_window_ends (w, last_text_row, 0);
       else
        w->window_end_vpos -= nrows_scrolled;
 
@@ -17748,21 +17734,13 @@
       row = find_last_row_displaying_text (w->current_matrix, &it,
                                           first_unchanged_at_end_row);
       eassert (row && MATRIX_ROW_DISPLAYS_TEXT_P (row));
-
-      w->window_end_pos = Z - MATRIX_ROW_END_CHARPOS (row);
-      w->window_end_bytepos = Z_BYTE - MATRIX_ROW_END_BYTEPOS (row);
-      w->window_end_vpos = MATRIX_ROW_VPOS (row, w->current_matrix);
+      adjust_window_ends (w, row, 1);
       eassert (w->window_end_bytepos >= 0);
       IF_DEBUG (debug_method_add (w, "A"));
     }
   else if (last_text_row_at_end)
     {
-      w->window_end_pos
-       = Z - MATRIX_ROW_END_CHARPOS (last_text_row_at_end);
-      w->window_end_bytepos
-       = Z_BYTE - MATRIX_ROW_END_BYTEPOS (last_text_row_at_end);
-      w->window_end_vpos
-       = MATRIX_ROW_VPOS (last_text_row_at_end, desired_matrix);
+      adjust_window_ends (w, last_text_row_at_end, 0);
       eassert (w->window_end_bytepos >= 0);
       IF_DEBUG (debug_method_add (w, "B"));
     }
@@ -17771,11 +17749,7 @@
       /* We have displayed either to the end of the window or at the
         end of the window, i.e. the last row with text is to be found
         in the desired matrix.  */
-      w->window_end_pos
-       = Z - MATRIX_ROW_END_CHARPOS (last_text_row);
-      w->window_end_bytepos
-       = Z_BYTE - MATRIX_ROW_END_BYTEPOS (last_text_row);
-      w->window_end_vpos = MATRIX_ROW_VPOS (last_text_row, desired_matrix);
+      adjust_window_ends (w, last_text_row, 0);
       eassert (w->window_end_bytepos >= 0);
     }
   else if (first_unchanged_at_end_row == NULL


reply via email to

[Prev in Thread] Current Thread [Next in Thread]