diff options
| author | Dmitry Antipov | 2013-08-13 18:45:58 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2013-08-13 18:45:58 +0400 |
| commit | eeaf9bf3377b6d4b9083159726da8bb67b36cb56 (patch) | |
| tree | 1fe61fad7218d96666305a07a681a7c33c296c49 /src/window.c | |
| parent | f73f4ce69f4b2e8f6c422aca8f8cc36ef72fa725 (diff) | |
| download | emacs-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/window.c')
| -rw-r--r-- | src/window.c | 79 |
1 files changed, 30 insertions, 49 deletions
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 | } |
| 153 | static void | 153 | static void |
| 154 | wset_left_margin_cols (struct window *w, Lisp_Object val) | ||
| 155 | { | ||
| 156 | w->left_margin_cols = val; | ||
| 157 | } | ||
| 158 | static void | ||
| 159 | wset_new_normal (struct window *w, Lisp_Object val) | 154 | wset_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 | } |
| 188 | static void | 183 | static void |
| 189 | wset_right_margin_cols (struct window *w, Lisp_Object val) | ||
| 190 | { | ||
| 191 | w->right_margin_cols = val; | ||
| 192 | } | ||
| 193 | static void | ||
| 194 | wset_scroll_bar_width (struct window *w, Lisp_Object val) | 184 | wset_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. | |||
| 6142 | Second arg LEFT-WIDTH specifies the number of character cells to | 6129 | Second arg LEFT-WIDTH specifies the number of character cells to |
| 6143 | reserve for the left marginal area. Optional third arg RIGHT-WIDTH | 6130 | reserve for the left marginal area. Optional third arg RIGHT-WIDTH |
| 6144 | does the same for the right marginal area. A nil width parameter | 6131 | does the same for the right marginal area. A nil width parameter |
| 6145 | means no margin. */) | 6132 | means no margin. |
| 6133 | |||
| 6134 | Return 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 | ||