aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDmitry Antipov2013-08-13 18:45:58 +0400
committerDmitry Antipov2013-08-13 18:45:58 +0400
commiteeaf9bf3377b6d4b9083159726da8bb67b36cb56 (patch)
tree1fe61fad7218d96666305a07a681a7c33c296c49 /src
parentf73f4ce69f4b2e8f6c422aca8f8cc36ef72fa725 (diff)
downloademacs-eeaf9bf3377b6d4b9083159726da8bb67b36cb56.tar.gz
emacs-eeaf9bf3377b6d4b9083159726da8bb67b36cb56.zip
* 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.
Diffstat (limited to 'src')
-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 519659a104c..9b93a31e0b1 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -359,25 +359,19 @@ free_glyph_matrix (struct glyph_matrix *matrix)
359/* Return the number of glyphs to reserve for a marginal area of 359/* Return the number of glyphs to reserve for a marginal area of
360 window W. TOTAL_GLYPHS is the number of glyphs in a complete 360 window W. TOTAL_GLYPHS is the number of glyphs in a complete
361 display line of window W. MARGIN gives the width of the marginal 361 display line of window W. MARGIN gives the width of the marginal
362 area in canonical character units. MARGIN should be an integer 362 area in canonical character units. */
363 or a float. */
364 363
365static int 364static int
366margin_glyphs_to_reserve (struct window *w, int total_glyphs, Lisp_Object margin) 365margin_glyphs_to_reserve (struct window *w, int total_glyphs, int margin)
367{ 366{
368 int n; 367 if (margin > 0)
369
370 if (NUMBERP (margin))
371 { 368 {
372 int width = w->total_cols; 369 int width = w->total_cols;
373 double d = max (0, XFLOATINT (margin)); 370 double d = max (0, margin);
374 d = min (width / 2 - 1, d); 371 d = min (width / 2 - 1, d);
375 n = (int) ((double) total_glyphs / width * d); 372 return (int) ((double) total_glyphs / width * d);
376 } 373 }
377 else 374 return 0;
378 n = 0;
379
380 return n;
381} 375}
382 376
383/* Return true if ROW's hash value is correct. 377/* Return true if ROW's hash value is correct.
@@ -1867,7 +1861,7 @@ showing_window_margins_p (struct window *w)
1867 if (showing_window_margins_p (XWINDOW (w->contents))) 1861 if (showing_window_margins_p (XWINDOW (w->contents)))
1868 return 1; 1862 return 1;
1869 } 1863 }
1870 else if (!NILP (w->left_margin_cols) || !NILP (w->right_margin_cols)) 1864 else if (w->left_margin_cols > 0 || w->right_margin_cols > 0)
1871 return 1; 1865 return 1;
1872 1866
1873 w = NILP (w->next) ? 0 : XWINDOW (w->next); 1867 w = NILP (w->next) ? 0 : XWINDOW (w->next);
@@ -3807,8 +3801,7 @@ update_window_line (struct window *w, int vpos, bool *mouse_face_overwritten_p)
3807 eassert (desired_row->enabled_p); 3801 eassert (desired_row->enabled_p);
3808 3802
3809 /* Update display of the left margin area, if there is one. */ 3803 /* Update display of the left margin area, if there is one. */
3810 if (!desired_row->full_width_p 3804 if (!desired_row->full_width_p && w->left_margin_cols > 0)
3811 && !NILP (w->left_margin_cols))
3812 { 3805 {
3813 changed_p = 1; 3806 changed_p = 1;
3814 update_marginal_area (w, LEFT_MARGIN_AREA, vpos); 3807 update_marginal_area (w, LEFT_MARGIN_AREA, vpos);
@@ -3828,8 +3821,7 @@ update_window_line (struct window *w, int vpos, bool *mouse_face_overwritten_p)
3828 } 3821 }
3829 3822
3830 /* Update display of the right margin area, if there is one. */ 3823 /* Update display of the right margin area, if there is one. */
3831 if (!desired_row->full_width_p 3824 if (!desired_row->full_width_p && w->right_margin_cols > 0)
3832 && !NILP (w->right_margin_cols))
3833 { 3825 {
3834 changed_p = 1; 3826 changed_p = 1;
3835 update_marginal_area (w, RIGHT_MARGIN_AREA, vpos); 3827 update_marginal_area (w, RIGHT_MARGIN_AREA, vpos);
@@ -4606,10 +4598,7 @@ update_frame_1 (struct frame *f, bool force_p, bool inhibit_id_p)
4606 int x = WINDOW_TO_FRAME_HPOS (w, w->cursor.hpos); 4598 int x = WINDOW_TO_FRAME_HPOS (w, w->cursor.hpos);
4607 int y = WINDOW_TO_FRAME_VPOS (w, w->cursor.vpos); 4599 int y = WINDOW_TO_FRAME_VPOS (w, w->cursor.vpos);
4608 4600
4609 if (INTEGERP (w->left_margin_cols)) 4601 x += max (0, w->left_margin_cols);
4610 x += XFASTINT (w->left_margin_cols);
4611
4612 /* x = max (min (x, FRAME_TOTAL_COLS (f) - 1), 0); */
4613 cursor_to (f, y, x); 4602 cursor_to (f, y, x);
4614 } 4603 }
4615 } 4604 }
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 6de93b077ca..b33dc328983 100644
--- a/src/window.c
+++ b/src/window.c
@@ -151,11 +151,6 @@ wset_display_table (struct window *w, Lisp_Object val)
151 w->display_table = val; 151 w->display_table = val;
152} 152}
153static void 153static void
154wset_left_margin_cols (struct window *w, Lisp_Object val)
155{
156 w->left_margin_cols = val;
157}
158static void
159wset_new_normal (struct window *w, Lisp_Object val) 154wset_new_normal (struct window *w, Lisp_Object val)
160{ 155{
161 w->new_normal = val; 156 w->new_normal = val;
@@ -186,11 +181,6 @@ wset_pointm (struct window *w, Lisp_Object val)
186 w->pointm = val; 181 w->pointm = val;
187} 182}
188static void 183static void
189wset_right_margin_cols (struct window *w, Lisp_Object val)
190{
191 w->right_margin_cols = val;
192}
193static void
194wset_scroll_bar_width (struct window *w, Lisp_Object val) 184wset_scroll_bar_width (struct window *w, Lisp_Object val)
195{ 185{
196 w->scroll_bar_width = val; 186 w->scroll_bar_width = val;
@@ -3058,15 +3048,12 @@ adjust_window_margins (struct window *w)
3058 if (WINDOW_RIGHT_MARGIN_COLS (w) > 0) 3048 if (WINDOW_RIGHT_MARGIN_COLS (w) > 0)
3059 { 3049 {
3060 if (WINDOW_LEFT_MARGIN_COLS (w) > 0) 3050 if (WINDOW_LEFT_MARGIN_COLS (w) > 0)
3061 { 3051 w->left_margin_cols = w->right_margin_cols = margin_cols / 2;
3062 wset_left_margin_cols (w, make_number (margin_cols / 2));
3063 wset_right_margin_cols (w, make_number (margin_cols / 2));
3064 }
3065 else 3052 else
3066 wset_right_margin_cols (w, make_number (margin_cols)); 3053 w->right_margin_cols = margin_cols;
3067 } 3054 }
3068 else 3055 else
3069 wset_left_margin_cols (w, make_number (margin_cols)); 3056 w->left_margin_cols = margin_cols;
3070 return 1; 3057 return 1;
3071} 3058}
3072 3059
@@ -3223,11 +3210,11 @@ set_window_buffer (Lisp_Object window, Lisp_Object buffer,
3223 3210
3224 /* This may call adjust_window_margins three times, so 3211 /* This may call adjust_window_margins three times, so
3225 temporarily disable window margins. */ 3212 temporarily disable window margins. */
3226 Lisp_Object save_left = w->left_margin_cols; 3213 int save_left = w->left_margin_cols;
3227 Lisp_Object save_right = w->right_margin_cols; 3214 int save_right = w->right_margin_cols;
3228 3215
3229 wset_left_margin_cols (w, Qnil); 3216 w->left_margin_cols = 0;
3230 wset_right_margin_cols (w, Qnil); 3217 w->right_margin_cols = 0;
3231 3218
3232 Fset_window_fringes (window, 3219 Fset_window_fringes (window,
3233 BVAR (b, left_fringe_width), BVAR (b, right_fringe_width), 3220 BVAR (b, left_fringe_width), BVAR (b, right_fringe_width),
@@ -3237,8 +3224,8 @@ set_window_buffer (Lisp_Object window, Lisp_Object buffer,
3237 BVAR (b, scroll_bar_width), 3224 BVAR (b, scroll_bar_width),
3238 BVAR (b, vertical_scroll_bar_type), Qnil); 3225 BVAR (b, vertical_scroll_bar_type), Qnil);
3239 3226
3240 wset_left_margin_cols (w, save_left); 3227 w->left_margin_cols = save_left;
3241 wset_right_margin_cols (w, save_right); 3228 w->right_margin_cols = save_right;
3242 3229
3243 Fset_window_margins (window, 3230 Fset_window_margins (window,
3244 BVAR (b, left_margin_cols), BVAR (b, right_margin_cols)); 3231 BVAR (b, left_margin_cols), BVAR (b, right_margin_cols));
@@ -3939,8 +3926,8 @@ set correctly. See the code of `split-window' for how this is done. */)
3939 memset (&n->last_cursor, 0, sizeof n->last_cursor); 3926 memset (&n->last_cursor, 0, sizeof n->last_cursor);
3940 3927
3941 /* Get special geometry settings from reference window. */ 3928 /* Get special geometry settings from reference window. */
3942 wset_left_margin_cols (n, r->left_margin_cols); 3929 n->left_margin_cols = r->left_margin_cols;
3943 wset_right_margin_cols (n, r->right_margin_cols); 3930 n->right_margin_cols = r->right_margin_cols;
3944 n->left_fringe_width = r->left_fringe_width; 3931 n->left_fringe_width = r->left_fringe_width;
3945 n->right_fringe_width = r->right_fringe_width; 3932 n->right_fringe_width = r->right_fringe_width;
3946 n->fringes_outside_margins = r->fringes_outside_margins; 3933 n->fringes_outside_margins = r->fringes_outside_margins;
@@ -5682,8 +5669,8 @@ the return value is nil. Otherwise the value is t. */)
5682 w->hscroll = XFASTINT (p->hscroll); 5669 w->hscroll = XFASTINT (p->hscroll);
5683 w->min_hscroll = XFASTINT (p->min_hscroll); 5670 w->min_hscroll = XFASTINT (p->min_hscroll);
5684 wset_display_table (w, p->display_table); 5671 wset_display_table (w, p->display_table);
5685 wset_left_margin_cols (w, p->left_margin_cols); 5672 w->left_margin_cols = XINT (p->left_margin_cols);
5686 wset_right_margin_cols (w, p->right_margin_cols); 5673 w->right_margin_cols = XINT (p->right_margin_cols);
5687 w->left_fringe_width = XINT (p->left_fringe_width); 5674 w->left_fringe_width = XINT (p->left_fringe_width);
5688 w->right_fringe_width = XINT (p->right_fringe_width); 5675 w->right_fringe_width = XINT (p->right_fringe_width);
5689 w->fringes_outside_margins = !NILP (p->fringes_outside_margins); 5676 w->fringes_outside_margins = !NILP (p->fringes_outside_margins);
@@ -5983,8 +5970,8 @@ save_window_save (Lisp_Object window, struct Lisp_Vector *vector, int i)
5983 XSETFASTINT (p->hscroll, w->hscroll); 5970 XSETFASTINT (p->hscroll, w->hscroll);
5984 XSETFASTINT (p->min_hscroll, w->min_hscroll); 5971 XSETFASTINT (p->min_hscroll, w->min_hscroll);
5985 p->display_table = w->display_table; 5972 p->display_table = w->display_table;
5986 p->left_margin_cols = w->left_margin_cols; 5973 p->left_margin_cols = make_number (w->left_margin_cols);
5987 p->right_margin_cols = w->right_margin_cols; 5974 p->right_margin_cols = make_number (w->right_margin_cols);
5988 p->left_fringe_width = make_number (w->left_fringe_width); 5975 p->left_fringe_width = make_number (w->left_fringe_width);
5989 p->right_fringe_width = make_number (w->right_fringe_width); 5976 p->right_fringe_width = make_number (w->right_fringe_width);
5990 p->fringes_outside_margins = w->fringes_outside_margins ? Qt : Qnil; 5977 p->fringes_outside_margins = w->fringes_outside_margins ? Qt : Qnil;
@@ -6142,38 +6129,31 @@ WINDOW must be a live window and defaults to the selected one.
6142Second arg LEFT-WIDTH specifies the number of character cells to 6129Second arg LEFT-WIDTH specifies the number of character cells to
6143reserve for the left marginal area. Optional third arg RIGHT-WIDTH 6130reserve for the left marginal area. Optional third arg RIGHT-WIDTH
6144does the same for the right marginal area. A nil width parameter 6131does the same for the right marginal area. A nil width parameter
6145means no margin. */) 6132means no margin.
6133
6134Return t if any margin was actually changed and nil otherwise. */)
6146 (Lisp_Object window, Lisp_Object left_width, Lisp_Object right_width) 6135 (Lisp_Object window, Lisp_Object left_width, Lisp_Object right_width)
6147{ 6136{
6148 struct window *w = decode_live_window (window); 6137 struct window *w = decode_live_window (window);
6138 int left, right;
6149 6139
6150 /* Translate negative or zero widths to nil. 6140 /* FIXME: what about margins that are too wide? */
6151 Margins that are too wide have to be checked elsewhere. */
6152 6141
6153 if (!NILP (left_width)) 6142 left = (NILP (left_width) ? 0
6154 { 6143 : (CHECK_NATNUM (left_width), XINT (left_width)));
6155 CHECK_NUMBER (left_width); 6144 right = (NILP (right_width) ? 0
6156 if (XINT (left_width) <= 0) 6145 : (CHECK_NATNUM (right_width), XINT (right_width)));
6157 left_width = Qnil;
6158 }
6159
6160 if (!NILP (right_width))
6161 {
6162 CHECK_NUMBER (right_width);
6163 if (XINT (right_width) <= 0)
6164 right_width = Qnil;
6165 }
6166 6146
6167 if (!EQ (w->left_margin_cols, left_width) 6147 if (w->left_margin_cols != left || w->right_margin_cols != right)
6168 || !EQ (w->right_margin_cols, right_width))
6169 { 6148 {
6170 wset_left_margin_cols (w, left_width); 6149 w->left_margin_cols = left;
6171 wset_right_margin_cols (w, right_width); 6150 w->right_margin_cols = right;
6172 6151
6173 adjust_window_margins (w); 6152 adjust_window_margins (w);
6174 6153
6175 ++windows_or_buffers_changed; 6154 ++windows_or_buffers_changed;
6176 adjust_glyphs (XFRAME (WINDOW_FRAME (w))); 6155 adjust_glyphs (XFRAME (WINDOW_FRAME (w)));
6156 return Qt;
6177 } 6157 }
6178 6158
6179 return Qnil; 6159 return Qnil;
@@ -6191,7 +6171,8 @@ as nil. */)
6191 (Lisp_Object window) 6171 (Lisp_Object window)
6192{ 6172{
6193 struct window *w = decode_live_window (window); 6173 struct window *w = decode_live_window (window);
6194 return Fcons (w->left_margin_cols, w->right_margin_cols); 6174 return Fcons (make_number (w->left_margin_cols),
6175 make_number (w->right_margin_cols));
6195} 6176}
6196 6177
6197 6178
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 8ef46d5be10..de5fd6ef26a 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -982,22 +982,18 @@ window_box_width (struct window *w, int area)
982 982
983 if (area == TEXT_AREA) 983 if (area == TEXT_AREA)
984 { 984 {
985 if (INTEGERP (w->left_margin_cols)) 985 cols -= max (0, w->left_margin_cols);
986 cols -= XFASTINT (w->left_margin_cols); 986 cols -= max (0, w->right_margin_cols);
987 if (INTEGERP (w->right_margin_cols))
988 cols -= XFASTINT (w->right_margin_cols);
989 pixels = -WINDOW_TOTAL_FRINGE_WIDTH (w); 987 pixels = -WINDOW_TOTAL_FRINGE_WIDTH (w);
990 } 988 }
991 else if (area == LEFT_MARGIN_AREA) 989 else if (area == LEFT_MARGIN_AREA)
992 { 990 {
993 cols = (INTEGERP (w->left_margin_cols) 991 cols = max (0, w->left_margin_cols);
994 ? XFASTINT (w->left_margin_cols) : 0);
995 pixels = 0; 992 pixels = 0;
996 } 993 }
997 else if (area == RIGHT_MARGIN_AREA) 994 else if (area == RIGHT_MARGIN_AREA)
998 { 995 {
999 cols = (INTEGERP (w->right_margin_cols) 996 cols = max (0, w->right_margin_cols);
1000 ? XFASTINT (w->right_margin_cols) : 0);
1001 pixels = 0; 997 pixels = 0;
1002 } 998 }
1003 } 999 }