aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/ChangeLog20
-rw-r--r--src/dispnew.c31
-rw-r--r--src/fringe.c2
-rw-r--r--src/window.c79
-rw-r--r--src/window.h34
-rw-r--r--src/xdisp.c12
6 files changed, 76 insertions, 102 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 28e8ab66e37..dabc6241967 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,23 @@
12013-08-13 Dmitry Antipov <dmantipov@yandex.ru>
2
3 * window.h (struct window): Convert left_margin_cols and
4 right_margin_cols from Lisp_Objects to integers. Adjust comment.
5 (WINDOW_LEFT_MARGIN_COLS, WINDOW_RIGHT_MARGIN_COLS)
6 (WINDOW_LEFT_MARGIN_WIDTH, WINDOW_RIGHT_MARGIN_WIDTH):
7 Adjust users.
8 * dispnew.c (margin_glyphs_to_reserve): Convert 3rd arg to int.
9 Adjust comment.
10 (showing_window_margins_p, update_window_line, update_frame_1):
11 * fringe.c (draw_fringe_bitmap_1):
12 * xdisp.c (window_box_width): Adjust users.
13 * window.c (wset_left_margin_cols, wset_right_margin_cols): Remove.
14 (adjust_window_margins, set_window_buffer, Fsplit_window_internal):
15 Use direct assignment.
16 (Fset_window_configuration, save_window_save, Fwindow_margins):
17 Convert Lisp_Object to integer and back where appropriate.
18 (Fset_window_margins): Adjust user. Return t if any margin
19 was actually changed, and mention this in docstring.
20
12013-08-13 Xue Fuqiao <xfq.free@gmail.com> 212013-08-13 Xue Fuqiao <xfq.free@gmail.com>
2 22
3 * syntax.c (forward_word): 23 * syntax.c (forward_word):
diff --git a/src/dispnew.c b/src/dispnew.c
index 3959c303adb..cb38726ba2d 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -361,25 +361,19 @@ free_glyph_matrix (struct glyph_matrix *matrix)
361/* Return the number of glyphs to reserve for a marginal area of 361/* Return the number of glyphs to reserve for a marginal area of
362 window W. TOTAL_GLYPHS is the number of glyphs in a complete 362 window W. TOTAL_GLYPHS is the number of glyphs in a complete
363 display line of window W. MARGIN gives the width of the marginal 363 display line of window W. MARGIN gives the width of the marginal
364 area in canonical character units. MARGIN should be an integer 364 area in canonical character units. */
365 or a float. */
366 365
367static int 366static int
368margin_glyphs_to_reserve (struct window *w, int total_glyphs, Lisp_Object margin) 367margin_glyphs_to_reserve (struct window *w, int total_glyphs, int margin)
369{ 368{
370 int n; 369 if (margin > 0)
371
372 if (NUMBERP (margin))
373 { 370 {
374 int width = w->total_cols; 371 int width = w->total_cols;
375 double d = max (0, XFLOATINT (margin)); 372 double d = max (0, margin);
376 d = min (width / 2 - 1, d); 373 d = min (width / 2 - 1, d);
377 n = (int) ((double) total_glyphs / width * d); 374 return (int) ((double) total_glyphs / width * d);
378 } 375 }
379 else 376 return 0;
380 n = 0;
381
382 return n;
383} 377}
384 378
385/* Return true if ROW's hash value is correct. 379/* Return true if ROW's hash value is correct.
@@ -1869,7 +1863,7 @@ showing_window_margins_p (struct window *w)
1869 if (showing_window_margins_p (XWINDOW (w->contents))) 1863 if (showing_window_margins_p (XWINDOW (w->contents)))
1870 return 1; 1864 return 1;
1871 } 1865 }
1872 else if (!NILP (w->left_margin_cols) || !NILP (w->right_margin_cols)) 1866 else if (w->left_margin_cols > 0 || w->right_margin_cols > 0)
1873 return 1; 1867 return 1;
1874 1868
1875 w = NILP (w->next) ? 0 : XWINDOW (w->next); 1869 w = NILP (w->next) ? 0 : XWINDOW (w->next);
@@ -3812,8 +3806,7 @@ update_window_line (struct window *w, int vpos, bool *mouse_face_overwritten_p)
3812 eassert (desired_row->enabled_p); 3806 eassert (desired_row->enabled_p);
3813 3807
3814 /* Update display of the left margin area, if there is one. */ 3808 /* Update display of the left margin area, if there is one. */
3815 if (!desired_row->full_width_p 3809 if (!desired_row->full_width_p && w->left_margin_cols > 0)
3816 && !NILP (w->left_margin_cols))
3817 { 3810 {
3818 changed_p = 1; 3811 changed_p = 1;
3819 update_marginal_area (w, LEFT_MARGIN_AREA, vpos); 3812 update_marginal_area (w, LEFT_MARGIN_AREA, vpos);
@@ -3833,8 +3826,7 @@ update_window_line (struct window *w, int vpos, bool *mouse_face_overwritten_p)
3833 } 3826 }
3834 3827
3835 /* Update display of the right margin area, if there is one. */ 3828 /* Update display of the right margin area, if there is one. */
3836 if (!desired_row->full_width_p 3829 if (!desired_row->full_width_p && w->right_margin_cols > 0)
3837 && !NILP (w->right_margin_cols))
3838 { 3830 {
3839 changed_p = 1; 3831 changed_p = 1;
3840 update_marginal_area (w, RIGHT_MARGIN_AREA, vpos); 3832 update_marginal_area (w, RIGHT_MARGIN_AREA, vpos);
@@ -4617,10 +4609,7 @@ update_frame_1 (struct frame *f, bool force_p, bool inhibit_id_p)
4617 int x = WINDOW_TO_FRAME_HPOS (w, w->cursor.hpos); 4609 int x = WINDOW_TO_FRAME_HPOS (w, w->cursor.hpos);
4618 int y = WINDOW_TO_FRAME_VPOS (w, w->cursor.vpos); 4610 int y = WINDOW_TO_FRAME_VPOS (w, w->cursor.vpos);
4619 4611
4620 if (INTEGERP (w->left_margin_cols)) 4612 x += max (0, w->left_margin_cols);
4621 x += XFASTINT (w->left_margin_cols);
4622
4623 /* x = max (min (x, FRAME_TOTAL_COLS (f) - 1), 0); */
4624 cursor_to (f, y, x); 4613 cursor_to (f, y, x);
4625 } 4614 }
4626 } 4615 }
diff --git a/src/fringe.c b/src/fringe.c
index 1d05244e64e..492eddae8d4 100644
--- a/src/fringe.c
+++ b/src/fringe.c
@@ -666,7 +666,7 @@ draw_fringe_bitmap_1 (struct window *w, struct glyph_row *row, int left_p, int o
666 and OTOH leaving out that one pixel leaves behind 666 and OTOH leaving out that one pixel leaves behind
667 traces of the cursor, if it was in column zero 667 traces of the cursor, if it was in column zero
668 before drawing non-empty margin area. */ 668 before drawing non-empty margin area. */
669 && NILP (w->left_margin_cols)) 669 && w->left_margin_cols == 0)
670 ? 1 : 0); 670 ? 1 : 0);
671 p.bx = x - wd; 671 p.bx = x - wd;
672 p.nx = wd; 672 p.nx = wd;
diff --git a/src/window.c b/src/window.c
index 1328adcacd0..9d4bb4d4e11 100644
--- a/src/window.c
+++ b/src/window.c
@@ -154,11 +154,6 @@ wset_display_table (struct window *w, Lisp_Object val)
154 w->display_table = val; 154 w->display_table = val;
155} 155}
156static void 156static void
157wset_left_margin_cols (struct window *w, Lisp_Object val)
158{
159 w->left_margin_cols = val;
160}
161static void
162wset_new_normal (struct window *w, Lisp_Object val) 157wset_new_normal (struct window *w, Lisp_Object val)
163{ 158{
164 w->new_normal = val; 159 w->new_normal = val;
@@ -189,11 +184,6 @@ wset_pointm (struct window *w, Lisp_Object val)
189 w->pointm = val; 184 w->pointm = val;
190} 185}
191static void 186static void
192wset_right_margin_cols (struct window *w, Lisp_Object val)
193{
194 w->right_margin_cols = val;
195}
196static void
197wset_scroll_bar_width (struct window *w, Lisp_Object val) 187wset_scroll_bar_width (struct window *w, Lisp_Object val)
198{ 188{
199 w->scroll_bar_width = val; 189 w->scroll_bar_width = val;
@@ -3061,15 +3051,12 @@ adjust_window_margins (struct window *w)
3061 if (WINDOW_RIGHT_MARGIN_COLS (w) > 0) 3051 if (WINDOW_RIGHT_MARGIN_COLS (w) > 0)
3062 { 3052 {
3063 if (WINDOW_LEFT_MARGIN_COLS (w) > 0) 3053 if (WINDOW_LEFT_MARGIN_COLS (w) > 0)
3064 { 3054 w->left_margin_cols = w->right_margin_cols = margin_cols / 2;
3065 wset_left_margin_cols (w, make_number (margin_cols / 2));
3066 wset_right_margin_cols (w, make_number (margin_cols / 2));
3067 }
3068 else 3055 else
3069 wset_right_margin_cols (w, make_number (margin_cols)); 3056 w->right_margin_cols = margin_cols;
3070 } 3057 }
3071 else 3058 else
3072 wset_left_margin_cols (w, make_number (margin_cols)); 3059 w->left_margin_cols = margin_cols;
3073 return 1; 3060 return 1;
3074} 3061}
3075 3062
@@ -3226,11 +3213,11 @@ set_window_buffer (Lisp_Object window, Lisp_Object buffer,
3226 3213
3227 /* This may call adjust_window_margins three times, so 3214 /* This may call adjust_window_margins three times, so
3228 temporarily disable window margins. */ 3215 temporarily disable window margins. */
3229 Lisp_Object save_left = w->left_margin_cols; 3216 int save_left = w->left_margin_cols;
3230 Lisp_Object save_right = w->right_margin_cols; 3217 int save_right = w->right_margin_cols;
3231 3218
3232 wset_left_margin_cols (w, Qnil); 3219 w->left_margin_cols = 0;
3233 wset_right_margin_cols (w, Qnil); 3220 w->right_margin_cols = 0;
3234 3221
3235 Fset_window_fringes (window, 3222 Fset_window_fringes (window,
3236 BVAR (b, left_fringe_width), BVAR (b, right_fringe_width), 3223 BVAR (b, left_fringe_width), BVAR (b, right_fringe_width),
@@ -3240,8 +3227,8 @@ set_window_buffer (Lisp_Object window, Lisp_Object buffer,
3240 BVAR (b, scroll_bar_width), 3227 BVAR (b, scroll_bar_width),
3241 BVAR (b, vertical_scroll_bar_type), Qnil); 3228 BVAR (b, vertical_scroll_bar_type), Qnil);
3242 3229
3243 wset_left_margin_cols (w, save_left); 3230 w->left_margin_cols = save_left;
3244 wset_right_margin_cols (w, save_right); 3231 w->right_margin_cols = save_right;
3245 3232
3246 Fset_window_margins (window, 3233 Fset_window_margins (window,
3247 BVAR (b, left_margin_cols), BVAR (b, right_margin_cols)); 3234 BVAR (b, left_margin_cols), BVAR (b, right_margin_cols));
@@ -3942,8 +3929,8 @@ set correctly. See the code of `split-window' for how this is done. */)
3942 memset (&n->last_cursor, 0, sizeof n->last_cursor); 3929 memset (&n->last_cursor, 0, sizeof n->last_cursor);
3943 3930
3944 /* Get special geometry settings from reference window. */ 3931 /* Get special geometry settings from reference window. */
3945 wset_left_margin_cols (n, r->left_margin_cols); 3932 n->left_margin_cols = r->left_margin_cols;
3946 wset_right_margin_cols (n, r->right_margin_cols); 3933 n->right_margin_cols = r->right_margin_cols;
3947 n->left_fringe_width = r->left_fringe_width; 3934 n->left_fringe_width = r->left_fringe_width;
3948 n->right_fringe_width = r->right_fringe_width; 3935 n->right_fringe_width = r->right_fringe_width;
3949 n->fringes_outside_margins = r->fringes_outside_margins; 3936 n->fringes_outside_margins = r->fringes_outside_margins;
@@ -5688,8 +5675,8 @@ the return value is nil. Otherwise the value is t. */)
5688 w->hscroll = XFASTINT (p->hscroll); 5675 w->hscroll = XFASTINT (p->hscroll);
5689 w->min_hscroll = XFASTINT (p->min_hscroll); 5676 w->min_hscroll = XFASTINT (p->min_hscroll);
5690 wset_display_table (w, p->display_table); 5677 wset_display_table (w, p->display_table);
5691 wset_left_margin_cols (w, p->left_margin_cols); 5678 w->left_margin_cols = XINT (p->left_margin_cols);
5692 wset_right_margin_cols (w, p->right_margin_cols); 5679 w->right_margin_cols = XINT (p->right_margin_cols);
5693 w->left_fringe_width = XINT (p->left_fringe_width); 5680 w->left_fringe_width = XINT (p->left_fringe_width);
5694 w->right_fringe_width = XINT (p->right_fringe_width); 5681 w->right_fringe_width = XINT (p->right_fringe_width);
5695 w->fringes_outside_margins = !NILP (p->fringes_outside_margins); 5682 w->fringes_outside_margins = !NILP (p->fringes_outside_margins);
@@ -5989,8 +5976,8 @@ save_window_save (Lisp_Object window, struct Lisp_Vector *vector, int i)
5989 XSETFASTINT (p->hscroll, w->hscroll); 5976 XSETFASTINT (p->hscroll, w->hscroll);
5990 XSETFASTINT (p->min_hscroll, w->min_hscroll); 5977 XSETFASTINT (p->min_hscroll, w->min_hscroll);
5991 p->display_table = w->display_table; 5978 p->display_table = w->display_table;
5992 p->left_margin_cols = w->left_margin_cols; 5979 p->left_margin_cols = make_number (w->left_margin_cols);
5993 p->right_margin_cols = w->right_margin_cols; 5980 p->right_margin_cols = make_number (w->right_margin_cols);
5994 p->left_fringe_width = make_number (w->left_fringe_width); 5981 p->left_fringe_width = make_number (w->left_fringe_width);
5995 p->right_fringe_width = make_number (w->right_fringe_width); 5982 p->right_fringe_width = make_number (w->right_fringe_width);
5996 p->fringes_outside_margins = w->fringes_outside_margins ? Qt : Qnil; 5983 p->fringes_outside_margins = w->fringes_outside_margins ? Qt : Qnil;
@@ -6148,38 +6135,31 @@ WINDOW must be a live window and defaults to the selected one.
6148Second arg LEFT-WIDTH specifies the number of character cells to 6135Second arg LEFT-WIDTH specifies the number of character cells to
6149reserve for the left marginal area. Optional third arg RIGHT-WIDTH 6136reserve for the left marginal area. Optional third arg RIGHT-WIDTH
6150does the same for the right marginal area. A nil width parameter 6137does the same for the right marginal area. A nil width parameter
6151means no margin. */) 6138means no margin.
6139
6140Return t if any margin was actually changed and nil otherwise. */)
6152 (Lisp_Object window, Lisp_Object left_width, Lisp_Object right_width) 6141 (Lisp_Object window, Lisp_Object left_width, Lisp_Object right_width)
6153{ 6142{
6154 struct window *w = decode_live_window (window); 6143 struct window *w = decode_live_window (window);
6144 int left, right;
6155 6145
6156 /* Translate negative or zero widths to nil. 6146 /* FIXME: what about margins that are too wide? */
6157 Margins that are too wide have to be checked elsewhere. */
6158 6147
6159 if (!NILP (left_width)) 6148 left = (NILP (left_width) ? 0
6160 { 6149 : (CHECK_NATNUM (left_width), XINT (left_width)));
6161 CHECK_NUMBER (left_width); 6150 right = (NILP (right_width) ? 0
6162 if (XINT (left_width) <= 0) 6151 : (CHECK_NATNUM (right_width), XINT (right_width)));
6163 left_width = Qnil;
6164 }
6165
6166 if (!NILP (right_width))
6167 {
6168 CHECK_NUMBER (right_width);
6169 if (XINT (right_width) <= 0)
6170 right_width = Qnil;
6171 }
6172 6152
6173 if (!EQ (w->left_margin_cols, left_width) 6153 if (w->left_margin_cols != left || w->right_margin_cols != right)
6174 || !EQ (w->right_margin_cols, right_width))
6175 { 6154 {
6176 wset_left_margin_cols (w, left_width); 6155 w->left_margin_cols = left;
6177 wset_right_margin_cols (w, right_width); 6156 w->right_margin_cols = right;
6178 6157
6179 adjust_window_margins (w); 6158 adjust_window_margins (w);
6180 6159
6181 ++windows_or_buffers_changed; 6160 ++windows_or_buffers_changed;
6182 adjust_glyphs (XFRAME (WINDOW_FRAME (w))); 6161 adjust_glyphs (XFRAME (WINDOW_FRAME (w)));
6162 return Qt;
6183 } 6163 }
6184 6164
6185 return Qnil; 6165 return Qnil;
@@ -6197,7 +6177,8 @@ as nil. */)
6197 (Lisp_Object window) 6177 (Lisp_Object window)
6198{ 6178{
6199 struct window *w = decode_live_window (window); 6179 struct window *w = decode_live_window (window);
6200 return Fcons (w->left_margin_cols, w->right_margin_cols); 6180 return Fcons (make_number (w->left_margin_cols),
6181 make_number (w->right_margin_cols));
6201} 6182}
6202 6183
6203 6184
diff --git a/src/window.h b/src/window.h
index ea573fbf3e1..a9afbc7f4a3 100644
--- a/src/window.h
+++ b/src/window.h
@@ -141,11 +141,6 @@ struct window
141 it yet, or if the frame doesn't have any scroll bars, this is nil. */ 141 it yet, or if the frame doesn't have any scroll bars, this is nil. */
142 Lisp_Object vertical_scroll_bar; 142 Lisp_Object vertical_scroll_bar;
143 143
144 /* Width of left and right marginal areas. A value of nil means
145 no margin. */
146 Lisp_Object left_margin_cols;
147 Lisp_Object right_margin_cols;
148
149 /* Pixel width of scroll bars. 144 /* Pixel width of scroll bars.
150 A value of nil or t means use frame values. */ 145 A value of nil or t means use frame values. */
151 Lisp_Object scroll_bar_width; 146 Lisp_Object scroll_bar_width;
@@ -269,6 +264,11 @@ struct window
269 int left_fringe_width; 264 int left_fringe_width;
270 int right_fringe_width; 265 int right_fringe_width;
271 266
267 /* Width of left and right marginal areas in columns.
268 A value of 0 means no margin. */
269 int left_margin_cols;
270 int right_margin_cols;
271
272 /* Non-zero if this window is a minibuffer window. */ 272 /* Non-zero if this window is a minibuffer window. */
273 unsigned mini : 1; 273 unsigned mini : 1;
274 274
@@ -600,33 +600,21 @@ wset_next_buffers (struct window *w, Lisp_Object val)
600 600
601/* Width of left margin area in columns. */ 601/* Width of left margin area in columns. */
602 602
603#define WINDOW_LEFT_MARGIN_COLS(W) \ 603#define WINDOW_LEFT_MARGIN_COLS(W) (W->left_margin_cols)
604 (NILP (W->left_margin_cols) \
605 ? 0 \
606 : XINT (W->left_margin_cols))
607 604
608/* Width of right marginal area in columns. */ 605/* Width of right marginal area in columns. */
609 606
610#define WINDOW_RIGHT_MARGIN_COLS(W) \ 607#define WINDOW_RIGHT_MARGIN_COLS(W) (W->right_margin_cols)
611 (NILP (W->right_margin_cols) \
612 ? 0 \
613 : XINT (W->right_margin_cols))
614 608
615/* Width of left margin area in pixels. */ 609/* Width of left margin area in pixels. */
616 610
617#define WINDOW_LEFT_MARGIN_WIDTH(W) \ 611#define WINDOW_LEFT_MARGIN_WIDTH(W) \
618 (NILP (W->left_margin_cols) \ 612 (W->left_margin_cols * WINDOW_FRAME_COLUMN_WIDTH (W))
619 ? 0 \
620 : (XINT (W->left_margin_cols) \
621 * WINDOW_FRAME_COLUMN_WIDTH (W)))
622 613
623/* Width of right marginal area in pixels. */ 614/* Width of right marginal area in pixels. */
624 615
625#define WINDOW_RIGHT_MARGIN_WIDTH(W) \ 616#define WINDOW_RIGHT_MARGIN_WIDTH(W) \
626 (NILP (W->right_margin_cols) \ 617 (W->right_margin_cols * WINDOW_FRAME_COLUMN_WIDTH (W))
627 ? 0 \
628 : (XINT (W->right_margin_cols) \
629 * WINDOW_FRAME_COLUMN_WIDTH (W)))
630 618
631/* Total width of fringes reserved for drawing truncation bitmaps, 619/* Total width of fringes reserved for drawing truncation bitmaps,
632 continuation bitmaps and alike. The width is in canonical char 620 continuation bitmaps and alike. The width is in canonical char
diff --git a/src/xdisp.c b/src/xdisp.c
index aecca138e04..490c1f3440f 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -989,22 +989,18 @@ window_box_width (struct window *w, int area)
989 989
990 if (area == TEXT_AREA) 990 if (area == TEXT_AREA)
991 { 991 {
992 if (INTEGERP (w->left_margin_cols)) 992 cols -= max (0, w->left_margin_cols);
993 cols -= XFASTINT (w->left_margin_cols); 993 cols -= max (0, w->right_margin_cols);
994 if (INTEGERP (w->right_margin_cols))
995 cols -= XFASTINT (w->right_margin_cols);
996 pixels = -WINDOW_TOTAL_FRINGE_WIDTH (w); 994 pixels = -WINDOW_TOTAL_FRINGE_WIDTH (w);
997 } 995 }
998 else if (area == LEFT_MARGIN_AREA) 996 else if (area == LEFT_MARGIN_AREA)
999 { 997 {
1000 cols = (INTEGERP (w->left_margin_cols) 998 cols = max (0, w->left_margin_cols);
1001 ? XFASTINT (w->left_margin_cols) : 0);
1002 pixels = 0; 999 pixels = 0;
1003 } 1000 }
1004 else if (area == RIGHT_MARGIN_AREA) 1001 else if (area == RIGHT_MARGIN_AREA)
1005 { 1002 {
1006 cols = (INTEGERP (w->right_margin_cols) 1003 cols = max (0, w->right_margin_cols);
1007 ? XFASTINT (w->right_margin_cols) : 0);
1008 pixels = 0; 1004 pixels = 0;
1009 } 1005 }
1010 } 1006 }