emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] trunk r113844: * window.h (struct window): Convert left_ma


From: Dmitry Antipov
Subject: [Emacs-diffs] trunk r113844: * window.h (struct window): Convert left_margin_cols and
Date: Tue, 13 Aug 2013 14:49:02 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 113844
revision-id: address@hidden
parent: address@hidden
committer: Dmitry Antipov <address@hidden>
branch nick: trunk
timestamp: Tue 2013-08-13 18:45:58 +0400
message:
  * window.h (struct window): Convert left_margin_cols and
  right_margin_cols from Lisp_Objects to integers.  Adjust comment.
  (WINDOW_LEFT_MARGIN_COLS, WINDOW_RIGHT_MARGIN_COLS)
  (WINDOW_LEFT_MARGIN_WIDTH, WINDOW_RIGHT_MARGIN_WIDTH):
  Adjust users.
  * dispnew.c (margin_glyphs_to_reserve): Convert 3rd arg to int.
  Adjust comment.
  (showing_window_margins_p, update_window_line, update_frame_1):
  * fringe.c (draw_fringe_bitmap_1):
  * xdisp.c (window_box_width): Adjust users.
  * window.c (wset_left_margin_cols, wset_right_margin_cols): Remove.
  (adjust_window_margins, set_window_buffer, Fsplit_window_internal):
  Use direct assignment.
  (Fset_window_configuration, save_window_save, Fwindow_margins):
  Convert Lisp_Object to integer and back where appropriate.
  (Fset_window_margins): Adjust user.  Return t if any margin
  was actually changed, and mention this in docstring.
modified:
  src/ChangeLog                  changelog-20091113204419-o5vbwnq5f7feedwu-1438
  src/dispnew.c                  dispnew.c-20091113204419-o5vbwnq5f7feedwu-258
  src/fringe.c                   fringe.c-20091113204419-o5vbwnq5f7feedwu-2965
  src/window.c                   window.c-20091113204419-o5vbwnq5f7feedwu-231
  src/window.h                   window.h-20091113204419-o5vbwnq5f7feedwu-271
  src/xdisp.c                    xdisp.c-20091113204419-o5vbwnq5f7feedwu-240
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2013-08-13 14:26:39 +0000
+++ b/src/ChangeLog     2013-08-13 14:45:58 +0000
@@ -1,3 +1,23 @@
+2013-08-13  Dmitry Antipov  <address@hidden>
+
+       * window.h (struct window): Convert left_margin_cols and
+       right_margin_cols from Lisp_Objects to integers.  Adjust comment.
+       (WINDOW_LEFT_MARGIN_COLS, WINDOW_RIGHT_MARGIN_COLS)
+       (WINDOW_LEFT_MARGIN_WIDTH, WINDOW_RIGHT_MARGIN_WIDTH):
+       Adjust users.
+       * dispnew.c (margin_glyphs_to_reserve): Convert 3rd arg to int.
+       Adjust comment.
+       (showing_window_margins_p, update_window_line, update_frame_1):
+       * fringe.c (draw_fringe_bitmap_1):
+       * xdisp.c (window_box_width): Adjust users.
+       * window.c (wset_left_margin_cols, wset_right_margin_cols): Remove.
+       (adjust_window_margins, set_window_buffer, Fsplit_window_internal):
+       Use direct assignment.
+       (Fset_window_configuration, save_window_save, Fwindow_margins):
+       Convert Lisp_Object to integer and back where appropriate.
+       (Fset_window_margins): Adjust user.  Return t if any margin
+       was actually changed, and mention this in docstring.
+
 2013-08-13  Xue Fuqiao  <address@hidden>
 
        * syntax.c (forward_word):

=== modified file 'src/dispnew.c'
--- a/src/dispnew.c     2013-08-08 14:51:07 +0000
+++ b/src/dispnew.c     2013-08-13 14:45:58 +0000
@@ -359,25 +359,19 @@
 /* Return the number of glyphs to reserve for a marginal area of
    window W.  TOTAL_GLYPHS is the number of glyphs in a complete
    display line of window W.  MARGIN gives the width of the marginal
-   area in canonical character units.  MARGIN should be an integer
-   or a float.  */
+   area in canonical character units.  */
 
 static int
-margin_glyphs_to_reserve (struct window *w, int total_glyphs, Lisp_Object 
margin)
+margin_glyphs_to_reserve (struct window *w, int total_glyphs, int margin)
 {
-  int n;
-
-  if (NUMBERP (margin))
+  if (margin > 0)
     {
       int width = w->total_cols;
-      double d = max (0, XFLOATINT (margin));
+      double d = max (0, margin);
       d = min (width / 2 - 1, d);
-      n = (int) ((double) total_glyphs / width * d);
+      return (int) ((double) total_glyphs / width * d);
     }
-  else
-    n = 0;
-
-  return n;
+  return 0;
 }
 
 /* Return true if ROW's hash value is correct.
@@ -1867,7 +1861,7 @@
          if (showing_window_margins_p (XWINDOW (w->contents)))
            return 1;
        }
-      else if (!NILP (w->left_margin_cols) || !NILP (w->right_margin_cols))
+      else if (w->left_margin_cols > 0 || w->right_margin_cols > 0)
        return 1;
 
       w = NILP (w->next) ? 0 : XWINDOW (w->next);
@@ -3807,8 +3801,7 @@
       eassert (desired_row->enabled_p);
 
       /* Update display of the left margin area, if there is one.  */
-      if (!desired_row->full_width_p
-         && !NILP (w->left_margin_cols))
+      if (!desired_row->full_width_p && w->left_margin_cols > 0)
        {
          changed_p = 1;
          update_marginal_area (w, LEFT_MARGIN_AREA, vpos);
@@ -3828,8 +3821,7 @@
        }
 
       /* Update display of the right margin area, if there is one.  */
-      if (!desired_row->full_width_p
-         && !NILP (w->right_margin_cols))
+      if (!desired_row->full_width_p && w->right_margin_cols > 0)
        {
          changed_p = 1;
          update_marginal_area (w, RIGHT_MARGIN_AREA, vpos);
@@ -4606,10 +4598,7 @@
              int x = WINDOW_TO_FRAME_HPOS (w, w->cursor.hpos);
              int y = WINDOW_TO_FRAME_VPOS (w, w->cursor.vpos);
 
-             if (INTEGERP (w->left_margin_cols))
-               x += XFASTINT (w->left_margin_cols);
-
-             /* x = max (min (x, FRAME_TOTAL_COLS (f) - 1), 0); */
+             x += max (0, w->left_margin_cols);
              cursor_to (f, y, x);
            }
        }

=== modified file 'src/fringe.c'
--- a/src/fringe.c      2013-07-30 05:56:18 +0000
+++ b/src/fringe.c      2013-08-13 14:45:58 +0000
@@ -666,7 +666,7 @@
                     and OTOH leaving out that one pixel leaves behind
                     traces of the cursor, if it was in column zero
                     before drawing non-empty margin area.  */
-                 && NILP (w->left_margin_cols))
+                 && w->left_margin_cols == 0)
                 ? 1 : 0);
          p.bx = x - wd;
          p.nx = wd;

=== modified file 'src/window.c'
--- a/src/window.c      2013-08-13 12:13:04 +0000
+++ b/src/window.c      2013-08-13 14:45:58 +0000
@@ -151,11 +151,6 @@
   w->display_table = val;
 }
 static void
-wset_left_margin_cols (struct window *w, Lisp_Object val)
-{
-  w->left_margin_cols = val;
-}
-static void
 wset_new_normal (struct window *w, Lisp_Object val)
 {
   w->new_normal = val;
@@ -186,11 +181,6 @@
   w->pointm = val;
 }
 static void
-wset_right_margin_cols (struct window *w, Lisp_Object val)
-{
-  w->right_margin_cols = val;
-}
-static void
 wset_scroll_bar_width (struct window *w, Lisp_Object val)
 {
   w->scroll_bar_width = val;
@@ -3058,15 +3048,12 @@
   if (WINDOW_RIGHT_MARGIN_COLS (w) > 0)
     {
       if (WINDOW_LEFT_MARGIN_COLS (w) > 0)
-       {
-         wset_left_margin_cols (w, make_number (margin_cols / 2));
-         wset_right_margin_cols (w, make_number (margin_cols / 2));
-       }
+       w->left_margin_cols = w->right_margin_cols = margin_cols / 2;
       else
-       wset_right_margin_cols (w, make_number (margin_cols));
+       w->right_margin_cols = margin_cols;
     }
   else
-    wset_left_margin_cols (w, make_number (margin_cols));
+    w->left_margin_cols = margin_cols;
   return 1;
 }
 
@@ -3223,11 +3210,11 @@
 
       /* This may call adjust_window_margins three times, so
         temporarily disable window margins.  */
-      Lisp_Object save_left = w->left_margin_cols;
-      Lisp_Object save_right = w->right_margin_cols;
+      int save_left = w->left_margin_cols;
+      int save_right = w->right_margin_cols;
 
-      wset_left_margin_cols (w, Qnil);
-      wset_right_margin_cols (w, Qnil);
+      w->left_margin_cols = 0;
+      w->right_margin_cols = 0;
 
       Fset_window_fringes (window,
                           BVAR (b, left_fringe_width), BVAR (b, 
right_fringe_width),
@@ -3237,8 +3224,8 @@
                               BVAR (b, scroll_bar_width),
                               BVAR (b, vertical_scroll_bar_type), Qnil);
 
-      wset_left_margin_cols (w, save_left);
-      wset_right_margin_cols (w, save_right);
+      w->left_margin_cols = save_left;
+      w->right_margin_cols = save_right;
 
       Fset_window_margins (window,
                           BVAR (b, left_margin_cols), BVAR (b, 
right_margin_cols));
@@ -3939,8 +3926,8 @@
   memset (&n->last_cursor, 0, sizeof n->last_cursor);
 
   /* Get special geometry settings from reference window.  */
-  wset_left_margin_cols (n, r->left_margin_cols);
-  wset_right_margin_cols (n, r->right_margin_cols);
+  n->left_margin_cols = r->left_margin_cols;
+  n->right_margin_cols = r->right_margin_cols;
   n->left_fringe_width = r->left_fringe_width;
   n->right_fringe_width = r->right_fringe_width;
   n->fringes_outside_margins = r->fringes_outside_margins;
@@ -5682,8 +5669,8 @@
          w->hscroll = XFASTINT (p->hscroll);
          w->min_hscroll = XFASTINT (p->min_hscroll);
          wset_display_table (w, p->display_table);
-         wset_left_margin_cols (w, p->left_margin_cols);
-         wset_right_margin_cols (w, p->right_margin_cols);
+         w->left_margin_cols = XINT (p->left_margin_cols);
+         w->right_margin_cols = XINT (p->right_margin_cols);
          w->left_fringe_width = XINT (p->left_fringe_width);
          w->right_fringe_width = XINT (p->right_fringe_width);
          w->fringes_outside_margins = !NILP (p->fringes_outside_margins);
@@ -5983,8 +5970,8 @@
       XSETFASTINT (p->hscroll, w->hscroll);
       XSETFASTINT (p->min_hscroll, w->min_hscroll);
       p->display_table = w->display_table;
-      p->left_margin_cols = w->left_margin_cols;
-      p->right_margin_cols = w->right_margin_cols;
+      p->left_margin_cols = make_number (w->left_margin_cols);
+      p->right_margin_cols = make_number (w->right_margin_cols);
       p->left_fringe_width = make_number (w->left_fringe_width);
       p->right_fringe_width = make_number (w->right_fringe_width);
       p->fringes_outside_margins = w->fringes_outside_margins ? Qt : Qnil;
@@ -6142,38 +6129,31 @@
 Second arg LEFT-WIDTH specifies the number of character cells to
 reserve for the left marginal area.  Optional third arg RIGHT-WIDTH
 does the same for the right marginal area.  A nil width parameter
-means no margin.  */)
+means no margin.
+
+Return t if any margin was actually changed and nil otherwise.  */)
   (Lisp_Object window, Lisp_Object left_width, Lisp_Object right_width)
 {
   struct window *w = decode_live_window (window);
-
-  /* Translate negative or zero widths to nil.
-     Margins that are too wide have to be checked elsewhere.  */
-
-  if (!NILP (left_width))
-    {
-      CHECK_NUMBER (left_width);
-      if (XINT (left_width) <= 0)
-       left_width = Qnil;
-    }
-
-  if (!NILP (right_width))
-    {
-      CHECK_NUMBER (right_width);
-      if (XINT (right_width) <= 0)
-       right_width = Qnil;
-    }
-
-  if (!EQ (w->left_margin_cols, left_width)
-      || !EQ (w->right_margin_cols, right_width))
-    {
-      wset_left_margin_cols (w, left_width);
-      wset_right_margin_cols (w, right_width);
+  int left, right;
+
+  /* FIXME: what about margins that are too wide?  */
+
+  left = (NILP (left_width) ? 0
+         : (CHECK_NATNUM (left_width), XINT (left_width)));
+  right = (NILP (right_width) ? 0
+          : (CHECK_NATNUM (right_width), XINT (right_width)));
+
+  if (w->left_margin_cols != left || w->right_margin_cols != right)
+    {
+      w->left_margin_cols = left;
+      w->right_margin_cols = right;
 
       adjust_window_margins (w);
 
       ++windows_or_buffers_changed;
       adjust_glyphs (XFRAME (WINDOW_FRAME (w)));
+      return Qt;
     }
 
   return Qnil;
@@ -6191,7 +6171,8 @@
   (Lisp_Object window)
 {
   struct window *w = decode_live_window (window);
-  return Fcons (w->left_margin_cols, w->right_margin_cols);
+  return Fcons (make_number (w->left_margin_cols),
+               make_number (w->right_margin_cols));
 }
 
 

=== modified file 'src/window.h'
--- a/src/window.h      2013-08-13 12:13:04 +0000
+++ b/src/window.h      2013-08-13 14:45:58 +0000
@@ -141,11 +141,6 @@
        it yet, or if the frame doesn't have any scroll bars, this is nil.  */
     Lisp_Object vertical_scroll_bar;
 
-    /* Width of left and right marginal areas.  A value of nil means
-       no margin.  */
-    Lisp_Object left_margin_cols;
-    Lisp_Object right_margin_cols;
-
     /* Pixel width of scroll bars.
        A value of nil or t means use frame values.  */
     Lisp_Object scroll_bar_width;
@@ -269,6 +264,11 @@
     int left_fringe_width;
     int right_fringe_width;
 
+    /* Width of left and right marginal areas in columns.
+       A value of 0 means no margin.  */
+    int left_margin_cols;
+    int right_margin_cols;
+
     /* Non-zero if this window is a minibuffer window.  */
     unsigned mini : 1;
 
@@ -600,33 +600,21 @@
 
 /* Width of left margin area in columns.  */
 
-#define WINDOW_LEFT_MARGIN_COLS(W)     \
-  (NILP (W->left_margin_cols)          \
-   ? 0                                 \
-   : XINT (W->left_margin_cols))
+#define WINDOW_LEFT_MARGIN_COLS(W) (W->left_margin_cols)
 
 /* Width of right marginal area in columns.  */
 
-#define WINDOW_RIGHT_MARGIN_COLS(W)    \
-  (NILP (W->right_margin_cols)         \
-   ? 0                                 \
-   : XINT (W->right_margin_cols))
+#define WINDOW_RIGHT_MARGIN_COLS(W) (W->right_margin_cols)
 
 /* Width of left margin area in pixels.  */
 
-#define WINDOW_LEFT_MARGIN_WIDTH(W)    \
-  (NILP (W->left_margin_cols)          \
-   ? 0                                 \
-   : (XINT (W->left_margin_cols)       \
-      * WINDOW_FRAME_COLUMN_WIDTH (W)))
+#define WINDOW_LEFT_MARGIN_WIDTH(W)                    \
+  (W->left_margin_cols * WINDOW_FRAME_COLUMN_WIDTH (W))
 
 /* Width of right marginal area in pixels.  */
 
-#define WINDOW_RIGHT_MARGIN_WIDTH(W)   \
-  (NILP (W->right_margin_cols)         \
-   ? 0                                 \
-   : (XINT (W->right_margin_cols)      \
-      * WINDOW_FRAME_COLUMN_WIDTH (W)))
+#define WINDOW_RIGHT_MARGIN_WIDTH(W)                   \
+  (W->right_margin_cols * WINDOW_FRAME_COLUMN_WIDTH (W))
 
 /* Total width of fringes reserved for drawing truncation bitmaps,
    continuation bitmaps and alike.  The width is in canonical char

=== modified file 'src/xdisp.c'
--- a/src/xdisp.c       2013-08-13 08:58:15 +0000
+++ b/src/xdisp.c       2013-08-13 14:45:58 +0000
@@ -982,22 +982,18 @@
 
       if (area == TEXT_AREA)
        {
-         if (INTEGERP (w->left_margin_cols))
-           cols -= XFASTINT (w->left_margin_cols);
-         if (INTEGERP (w->right_margin_cols))
-           cols -= XFASTINT (w->right_margin_cols);
+         cols -= max (0, w->left_margin_cols);
+         cols -= max (0, w->right_margin_cols);
          pixels = -WINDOW_TOTAL_FRINGE_WIDTH (w);
        }
       else if (area == LEFT_MARGIN_AREA)
        {
-         cols = (INTEGERP (w->left_margin_cols)
-                  ? XFASTINT (w->left_margin_cols) : 0);
+         cols = max (0, w->left_margin_cols);
          pixels = 0;
        }
       else if (area == RIGHT_MARGIN_AREA)
        {
-         cols = (INTEGERP (w->right_margin_cols)
-                  ? XFASTINT (w->right_margin_cols) : 0);
+         cols = max (0, w->right_margin_cols);
          pixels = 0;
        }
     }


reply via email to

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