diff options
| author | Eli Zaretskii | 2013-09-05 11:01:04 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2013-09-05 11:01:04 +0300 |
| commit | 41306318777a942420bc4feadbfacf662ea179dc (patch) | |
| tree | 669e5cca02f95d6064ce73c0d3fbbf91b8c8b563 /src/window.c | |
| parent | 141f1ff7a40cda10f0558e891dd196a943a5082e (diff) | |
| parent | 257b3b03cb1cff917e0b3b7832ad3eab5b59f257 (diff) | |
| download | emacs-41306318777a942420bc4feadbfacf662ea179dc.tar.gz emacs-41306318777a942420bc4feadbfacf662ea179dc.zip | |
Merge from trunk after a lot of time.
Diffstat (limited to 'src/window.c')
| -rw-r--r-- | src/window.c | 2614 |
1 files changed, 1322 insertions, 1292 deletions
diff --git a/src/window.c b/src/window.c index 563b52a0ca4..6828f5d0792 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | /* Window creation, deletion and examination for GNU Emacs. | 1 | /* Window creation, deletion and examination for GNU Emacs. |
| 2 | Does not include redisplay. | 2 | Does not include redisplay. |
| 3 | Copyright (C) 1985-1987, 1993-1998, 2000-2012 | 3 | Copyright (C) 1985-1987, 1993-1998, 2000-2013 Free Software |
| 4 | Free Software Foundation, Inc. | 4 | Foundation, Inc. |
| 5 | 5 | ||
| 6 | This file is part of GNU Emacs. | 6 | This file is part of GNU Emacs. |
| 7 | 7 | ||
| @@ -19,10 +19,13 @@ You should have received a copy of the GNU General Public License | |||
| 19 | along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | 19 | along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ |
| 20 | 20 | ||
| 21 | #include <config.h> | 21 | #include <config.h> |
| 22 | |||
| 23 | #define WINDOW_INLINE EXTERN_INLINE | ||
| 24 | |||
| 22 | #include <stdio.h> | 25 | #include <stdio.h> |
| 23 | #include <setjmp.h> | ||
| 24 | 26 | ||
| 25 | #include "lisp.h" | 27 | #include "lisp.h" |
| 28 | #include "character.h" | ||
| 26 | #include "buffer.h" | 29 | #include "buffer.h" |
| 27 | #include "keyboard.h" | 30 | #include "keyboard.h" |
| 28 | #include "keymap.h" | 31 | #include "keymap.h" |
| @@ -40,7 +43,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 40 | #ifdef HAVE_X_WINDOWS | 43 | #ifdef HAVE_X_WINDOWS |
| 41 | #include "xterm.h" | 44 | #include "xterm.h" |
| 42 | #endif /* HAVE_X_WINDOWS */ | 45 | #endif /* HAVE_X_WINDOWS */ |
| 43 | #ifdef WINDOWSNT | 46 | #ifdef HAVE_NTGUI |
| 44 | #include "w32term.h" | 47 | #include "w32term.h" |
| 45 | #endif | 48 | #endif |
| 46 | #ifdef MSDOS | 49 | #ifdef MSDOS |
| @@ -51,26 +54,23 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 51 | #endif | 54 | #endif |
| 52 | 55 | ||
| 53 | Lisp_Object Qwindowp, Qwindow_live_p; | 56 | Lisp_Object Qwindowp, Qwindow_live_p; |
| 54 | static Lisp_Object Qwindow_configuration_p, Qrecord_window_buffer; | 57 | static Lisp_Object Qwindow_valid_p; |
| 58 | static Lisp_Object Qwindow_configuration_p; | ||
| 59 | static Lisp_Object Qrecord_window_buffer; | ||
| 55 | static Lisp_Object Qwindow_deletable_p, Qdelete_window, Qdisplay_buffer; | 60 | static Lisp_Object Qwindow_deletable_p, Qdelete_window, Qdisplay_buffer; |
| 56 | static Lisp_Object Qreplace_buffer_in_windows, Qget_mru_window; | 61 | static Lisp_Object Qreplace_buffer_in_windows, Qget_mru_window; |
| 57 | static Lisp_Object Qwindow_resize_root_window, Qwindow_resize_root_window_vertically; | 62 | static Lisp_Object Qwindow_resize_root_window, Qwindow_resize_root_window_vertically; |
| 58 | static Lisp_Object Qscroll_up, Qscroll_down, Qscroll_command; | 63 | static Lisp_Object Qscroll_up, Qscroll_down, Qscroll_command; |
| 59 | static Lisp_Object Qsafe, Qabove, Qbelow; | 64 | static Lisp_Object Qsafe, Qabove, Qbelow, Qwindow_size, Qclone_of; |
| 60 | static Lisp_Object Qauto_buffer_name, Qclone_of; | ||
| 61 | 65 | ||
| 62 | static int displayed_window_lines (struct window *); | 66 | static int displayed_window_lines (struct window *); |
| 63 | static struct window *decode_window (Lisp_Object); | ||
| 64 | static int count_windows (struct window *); | 67 | static int count_windows (struct window *); |
| 65 | static int get_leaf_windows (struct window *, struct window **, int); | 68 | static int get_leaf_windows (struct window *, struct window **, int); |
| 66 | static void window_scroll (Lisp_Object, EMACS_INT, int, int); | 69 | static void window_scroll (Lisp_Object, EMACS_INT, bool, int); |
| 67 | static void window_scroll_pixel_based (Lisp_Object, int, int, int); | 70 | static void window_scroll_pixel_based (Lisp_Object, int, bool, int); |
| 68 | static void window_scroll_line_based (Lisp_Object, int, int, int); | 71 | static void window_scroll_line_based (Lisp_Object, int, bool, int); |
| 69 | static int freeze_window_start (struct window *, void *); | ||
| 70 | static Lisp_Object window_list (void); | 72 | static Lisp_Object window_list (void); |
| 71 | static int add_window_to_list (struct window *, void *); | 73 | static int add_window_to_list (struct window *, void *); |
| 72 | static int candidate_window_p (Lisp_Object, Lisp_Object, Lisp_Object, | ||
| 73 | Lisp_Object); | ||
| 74 | static Lisp_Object next_window (Lisp_Object, Lisp_Object, | 74 | static Lisp_Object next_window (Lisp_Object, Lisp_Object, |
| 75 | Lisp_Object, int); | 75 | Lisp_Object, int); |
| 76 | static void decode_next_window_args (Lisp_Object *, Lisp_Object *, | 76 | static void decode_next_window_args (Lisp_Object *, Lisp_Object *, |
| @@ -82,9 +82,18 @@ static int foreach_window_1 (struct window *, | |||
| 82 | int (* fn) (struct window *, void *), | 82 | int (* fn) (struct window *, void *), |
| 83 | void *); | 83 | void *); |
| 84 | static Lisp_Object window_list_1 (Lisp_Object, Lisp_Object, Lisp_Object); | 84 | static Lisp_Object window_list_1 (Lisp_Object, Lisp_Object, Lisp_Object); |
| 85 | static int window_resize_check (struct window *, int); | 85 | static int window_resize_check (struct window *, bool); |
| 86 | static void window_resize_apply (struct window *, int); | 86 | static void window_resize_apply (struct window *, bool); |
| 87 | static Lisp_Object select_window (Lisp_Object, Lisp_Object, int); | 87 | static Lisp_Object select_window (Lisp_Object, Lisp_Object, int); |
| 88 | static void select_window_1 (Lisp_Object, bool); | ||
| 89 | |||
| 90 | static struct window *set_window_fringes (struct window *, Lisp_Object, | ||
| 91 | Lisp_Object, Lisp_Object); | ||
| 92 | static struct window *set_window_margins (struct window *, Lisp_Object, | ||
| 93 | Lisp_Object); | ||
| 94 | static struct window *set_window_scroll_bars (struct window *, Lisp_Object, | ||
| 95 | Lisp_Object, Lisp_Object); | ||
| 96 | static void apply_window_adjustment (struct window *); | ||
| 88 | 97 | ||
| 89 | /* This is the window in which the terminal's cursor should | 98 | /* This is the window in which the terminal's cursor should |
| 90 | be left when nothing is being done with it. This must | 99 | be left when nothing is being done with it. This must |
| @@ -113,9 +122,6 @@ Lisp_Object minibuf_selected_window; | |||
| 113 | /* Hook run at end of temp_output_buffer_show. */ | 122 | /* Hook run at end of temp_output_buffer_show. */ |
| 114 | static Lisp_Object Qtemp_buffer_show_hook; | 123 | static Lisp_Object Qtemp_buffer_show_hook; |
| 115 | 124 | ||
| 116 | /* Incremented for each window created. */ | ||
| 117 | static int sequence_number; | ||
| 118 | |||
| 119 | /* Nonzero after init_window_once has finished. */ | 125 | /* Nonzero after init_window_once has finished. */ |
| 120 | static int window_initialized; | 126 | static int window_initialized; |
| 121 | 127 | ||
| @@ -130,8 +136,104 @@ static int window_scroll_pixel_based_preserve_y; | |||
| 130 | static EMACS_INT window_scroll_preserve_hpos; | 136 | static EMACS_INT window_scroll_preserve_hpos; |
| 131 | static EMACS_INT window_scroll_preserve_vpos; | 137 | static EMACS_INT window_scroll_preserve_vpos; |
| 132 | 138 | ||
| 133 | static struct window * | 139 | static void |
| 134 | decode_window (register Lisp_Object window) | 140 | CHECK_WINDOW_CONFIGURATION (Lisp_Object x) |
| 141 | { | ||
| 142 | CHECK_TYPE (WINDOW_CONFIGURATIONP (x), Qwindow_configuration_p, x); | ||
| 143 | } | ||
| 144 | |||
| 145 | /* These setters are used only in this file, so they can be private. */ | ||
| 146 | static void | ||
| 147 | wset_combination_limit (struct window *w, Lisp_Object val) | ||
| 148 | { | ||
| 149 | w->combination_limit = val; | ||
| 150 | } | ||
| 151 | static void | ||
| 152 | wset_dedicated (struct window *w, Lisp_Object val) | ||
| 153 | { | ||
| 154 | w->dedicated = val; | ||
| 155 | } | ||
| 156 | static void | ||
| 157 | wset_display_table (struct window *w, Lisp_Object val) | ||
| 158 | { | ||
| 159 | w->display_table = val; | ||
| 160 | } | ||
| 161 | static void | ||
| 162 | wset_new_normal (struct window *w, Lisp_Object val) | ||
| 163 | { | ||
| 164 | w->new_normal = val; | ||
| 165 | } | ||
| 166 | static void | ||
| 167 | wset_new_total (struct window *w, Lisp_Object val) | ||
| 168 | { | ||
| 169 | w->new_total = val; | ||
| 170 | } | ||
| 171 | static void | ||
| 172 | wset_normal_cols (struct window *w, Lisp_Object val) | ||
| 173 | { | ||
| 174 | w->normal_cols = val; | ||
| 175 | } | ||
| 176 | static void | ||
| 177 | wset_normal_lines (struct window *w, Lisp_Object val) | ||
| 178 | { | ||
| 179 | w->normal_lines = val; | ||
| 180 | } | ||
| 181 | static void | ||
| 182 | wset_parent (struct window *w, Lisp_Object val) | ||
| 183 | { | ||
| 184 | w->parent = val; | ||
| 185 | } | ||
| 186 | static void | ||
| 187 | wset_pointm (struct window *w, Lisp_Object val) | ||
| 188 | { | ||
| 189 | w->pointm = val; | ||
| 190 | } | ||
| 191 | static void | ||
| 192 | wset_start (struct window *w, Lisp_Object val) | ||
| 193 | { | ||
| 194 | w->start = val; | ||
| 195 | } | ||
| 196 | static void | ||
| 197 | wset_temslot (struct window *w, Lisp_Object val) | ||
| 198 | { | ||
| 199 | w->temslot = val; | ||
| 200 | } | ||
| 201 | static void | ||
| 202 | wset_vertical_scroll_bar_type (struct window *w, Lisp_Object val) | ||
| 203 | { | ||
| 204 | w->vertical_scroll_bar_type = val; | ||
| 205 | } | ||
| 206 | static void | ||
| 207 | wset_window_parameters (struct window *w, Lisp_Object val) | ||
| 208 | { | ||
| 209 | w->window_parameters = val; | ||
| 210 | } | ||
| 211 | static void | ||
| 212 | wset_combination (struct window *w, bool horflag, Lisp_Object val) | ||
| 213 | { | ||
| 214 | /* Since leaf windows never becomes non-leaf, there should | ||
| 215 | be no buffer and markers in start and pointm fields of W. */ | ||
| 216 | eassert (!BUFFERP (w->contents) && NILP (w->start) && NILP (w->pointm)); | ||
| 217 | w->contents = val; | ||
| 218 | /* When an internal window is deleted and VAL is nil, HORFLAG | ||
| 219 | is meaningless. */ | ||
| 220 | if (!NILP (val)) | ||
| 221 | w->horizontal = horflag; | ||
| 222 | } | ||
| 223 | |||
| 224 | /* Nonzero if leaf window W doesn't reflect the actual state | ||
| 225 | of displayed buffer due to its text or overlays change. */ | ||
| 226 | |||
| 227 | bool | ||
| 228 | window_outdated (struct window *w) | ||
| 229 | { | ||
| 230 | struct buffer *b = XBUFFER (w->contents); | ||
| 231 | return (w->last_modified < BUF_MODIFF (b) | ||
| 232 | || w->last_overlay_modified < BUF_OVERLAY_MODIFF (b)); | ||
| 233 | } | ||
| 234 | |||
| 235 | struct window * | ||
| 236 | decode_live_window (register Lisp_Object window) | ||
| 135 | { | 237 | { |
| 136 | if (NILP (window)) | 238 | if (NILP (window)) |
| 137 | return XWINDOW (selected_window); | 239 | return XWINDOW (selected_window); |
| @@ -140,14 +242,66 @@ decode_window (register Lisp_Object window) | |||
| 140 | return XWINDOW (window); | 242 | return XWINDOW (window); |
| 141 | } | 243 | } |
| 142 | 244 | ||
| 143 | static struct window * | 245 | struct window * |
| 144 | decode_any_window (register Lisp_Object window) | 246 | decode_any_window (register Lisp_Object window) |
| 145 | { | 247 | { |
| 248 | struct window *w; | ||
| 249 | |||
| 146 | if (NILP (window)) | 250 | if (NILP (window)) |
| 147 | return XWINDOW (selected_window); | 251 | return XWINDOW (selected_window); |
| 148 | 252 | ||
| 149 | CHECK_WINDOW (window); | 253 | CHECK_WINDOW (window); |
| 150 | return XWINDOW (window); | 254 | w = XWINDOW (window); |
| 255 | return w; | ||
| 256 | } | ||
| 257 | |||
| 258 | static struct window * | ||
| 259 | decode_valid_window (register Lisp_Object window) | ||
| 260 | { | ||
| 261 | struct window *w; | ||
| 262 | |||
| 263 | if (NILP (window)) | ||
| 264 | return XWINDOW (selected_window); | ||
| 265 | |||
| 266 | CHECK_VALID_WINDOW (window); | ||
| 267 | w = XWINDOW (window); | ||
| 268 | return w; | ||
| 269 | } | ||
| 270 | |||
| 271 | /* Called when W's buffer slot is changed. ARG -1 means that W is about to | ||
| 272 | cease its buffer, and 1 means that W is about to set up the new one. */ | ||
| 273 | |||
| 274 | static void | ||
| 275 | adjust_window_count (struct window *w, int arg) | ||
| 276 | { | ||
| 277 | eassert (eabs (arg) == 1); | ||
| 278 | if (BUFFERP (w->contents)) | ||
| 279 | { | ||
| 280 | struct buffer *b = XBUFFER (w->contents); | ||
| 281 | |||
| 282 | if (b->base_buffer) | ||
| 283 | b = b->base_buffer; | ||
| 284 | b->window_count += arg; | ||
| 285 | eassert (b->window_count >= 0); | ||
| 286 | /* These should be recalculated by redisplay code. */ | ||
| 287 | w->window_end_valid = 0; | ||
| 288 | w->base_line_pos = 0; | ||
| 289 | } | ||
| 290 | } | ||
| 291 | |||
| 292 | /* Set W's buffer slot to VAL and recompute number | ||
| 293 | of windows showing VAL if it is a buffer. */ | ||
| 294 | |||
| 295 | void | ||
| 296 | wset_buffer (struct window *w, Lisp_Object val) | ||
| 297 | { | ||
| 298 | adjust_window_count (w, -1); | ||
| 299 | if (BUFFERP (val)) | ||
| 300 | /* Make sure that we do not assign the buffer | ||
| 301 | to an internal window. */ | ||
| 302 | eassert (MARKERP (w->start) && MARKERP (w->pointm)); | ||
| 303 | w->contents = val; | ||
| 304 | adjust_window_count (w, 1); | ||
| 151 | } | 305 | } |
| 152 | 306 | ||
| 153 | DEFUN ("windowp", Fwindowp, Swindowp, 1, 1, 0, | 307 | DEFUN ("windowp", Fwindowp, Swindowp, 1, 1, 0, |
| @@ -157,6 +311,15 @@ DEFUN ("windowp", Fwindowp, Swindowp, 1, 1, 0, | |||
| 157 | return WINDOWP (object) ? Qt : Qnil; | 311 | return WINDOWP (object) ? Qt : Qnil; |
| 158 | } | 312 | } |
| 159 | 313 | ||
| 314 | DEFUN ("window-valid-p", Fwindow_valid_p, Swindow_valid_p, 1, 1, 0, | ||
| 315 | doc: /* Return t if OBJECT is a valid window and nil otherwise. | ||
| 316 | A valid window is either a window that displays a buffer or an internal | ||
| 317 | window. Deleted windows are not live. */) | ||
| 318 | (Lisp_Object object) | ||
| 319 | { | ||
| 320 | return WINDOW_VALID_P (object) ? Qt : Qnil; | ||
| 321 | } | ||
| 322 | |||
| 160 | DEFUN ("window-live-p", Fwindow_live_p, Swindow_live_p, 1, 1, 0, | 323 | DEFUN ("window-live-p", Fwindow_live_p, Swindow_live_p, 1, 1, 0, |
| 161 | doc: /* Return t if OBJECT is a live window and nil otherwise. | 324 | doc: /* Return t if OBJECT is a live window and nil otherwise. |
| 162 | A live window is a window that displays a buffer. | 325 | A live window is a window that displays a buffer. |
| @@ -167,12 +330,12 @@ Internal windows and deleted windows are not live. */) | |||
| 167 | } | 330 | } |
| 168 | 331 | ||
| 169 | /* Frames and windows. */ | 332 | /* Frames and windows. */ |
| 170 | DEFUN ("window-frame", Fwindow_frame, Swindow_frame, 1, 1, 0, | 333 | DEFUN ("window-frame", Fwindow_frame, Swindow_frame, 0, 1, 0, |
| 171 | doc: /* Return the frame that window WINDOW is on. | 334 | doc: /* Return the frame that window WINDOW is on. |
| 172 | If WINDOW is omitted or nil, it defaults to the selected window. */) | 335 | WINDOW must be a valid window and defaults to the selected one. */) |
| 173 | (Lisp_Object window) | 336 | (Lisp_Object window) |
| 174 | { | 337 | { |
| 175 | return decode_any_window (window)->frame; | 338 | return decode_valid_window (window)->frame; |
| 176 | } | 339 | } |
| 177 | 340 | ||
| 178 | DEFUN ("frame-root-window", Fframe_root_window, Sframe_root_window, 0, 1, 0, | 341 | DEFUN ("frame-root-window", Fframe_root_window, Sframe_root_window, 0, 1, 0, |
| @@ -186,8 +349,8 @@ With a window argument, return the root window of that window's frame. */) | |||
| 186 | 349 | ||
| 187 | if (NILP (frame_or_window)) | 350 | if (NILP (frame_or_window)) |
| 188 | window = SELECTED_FRAME ()->root_window; | 351 | window = SELECTED_FRAME ()->root_window; |
| 189 | else if (WINDOWP (frame_or_window)) | 352 | else if (WINDOW_VALID_P (frame_or_window)) |
| 190 | window = XFRAME (WINDOW_FRAME (XWINDOW (frame_or_window)))->root_window; | 353 | window = XFRAME (XWINDOW (frame_or_window)->frame)->root_window; |
| 191 | else | 354 | else |
| 192 | { | 355 | { |
| 193 | CHECK_LIVE_FRAME (frame_or_window); | 356 | CHECK_LIVE_FRAME (frame_or_window); |
| @@ -202,27 +365,24 @@ DEFUN ("minibuffer-window", Fminibuffer_window, Sminibuffer_window, 0, 1, 0, | |||
| 202 | If FRAME is omitted or nil, it defaults to the selected frame. */) | 365 | If FRAME is omitted or nil, it defaults to the selected frame. */) |
| 203 | (Lisp_Object frame) | 366 | (Lisp_Object frame) |
| 204 | { | 367 | { |
| 205 | if (NILP (frame)) | 368 | return FRAME_MINIBUF_WINDOW (decode_live_frame (frame)); |
| 206 | frame = selected_frame; | ||
| 207 | CHECK_LIVE_FRAME (frame); | ||
| 208 | return FRAME_MINIBUF_WINDOW (XFRAME (frame)); | ||
| 209 | } | 369 | } |
| 210 | 370 | ||
| 211 | DEFUN ("window-minibuffer-p", Fwindow_minibuffer_p, | 371 | DEFUN ("window-minibuffer-p", Fwindow_minibuffer_p, |
| 212 | Swindow_minibuffer_p, 0, 1, 0, | 372 | Swindow_minibuffer_p, 0, 1, 0, |
| 213 | doc: /* Return non-nil if WINDOW is a minibuffer window. | 373 | doc: /* Return non-nil if WINDOW is a minibuffer window. |
| 214 | If WINDOW is omitted or nil, it defaults to the selected window. */) | 374 | WINDOW must be a valid window and defaults to the selected one. */) |
| 215 | (Lisp_Object window) | 375 | (Lisp_Object window) |
| 216 | { | 376 | { |
| 217 | return MINI_WINDOW_P (decode_any_window (window)) ? Qt : Qnil; | 377 | return MINI_WINDOW_P (decode_valid_window (window)) ? Qt : Qnil; |
| 218 | } | 378 | } |
| 219 | 379 | ||
| 220 | /* Don't move this to window.el - this must be a safe routine. */ | 380 | /* Don't move this to window.el - this must be a safe routine. */ |
| 221 | DEFUN ("frame-first-window", Fframe_first_window, Sframe_first_window, 0, 1, 0, | 381 | DEFUN ("frame-first-window", Fframe_first_window, Sframe_first_window, 0, 1, 0, |
| 222 | doc: /* Return the topmost, leftmost live window on FRAME-OR-WINDOW. | 382 | doc: /* Return the topmost, leftmost live window on FRAME-OR-WINDOW. |
| 223 | If omitted, FRAME-OR-WINDOW defaults to the currently selected frame. | 383 | If omitted, FRAME-OR-WINDOW defaults to the currently selected frame. |
| 224 | Else if FRAME-OR-WINDOW denotes any window, return the first window of | 384 | Else if FRAME-OR-WINDOW denotes a valid window, return the first window |
| 225 | that window's frame. If FRAME-OR-WINDOW denotes a live frame, return | 385 | of that window's frame. If FRAME-OR-WINDOW denotes a live frame, return |
| 226 | the first window of that frame. */) | 386 | the first window of that frame. */) |
| 227 | (Lisp_Object frame_or_window) | 387 | (Lisp_Object frame_or_window) |
| 228 | { | 388 | { |
| @@ -230,7 +390,7 @@ the first window of that frame. */) | |||
| 230 | 390 | ||
| 231 | if (NILP (frame_or_window)) | 391 | if (NILP (frame_or_window)) |
| 232 | window = SELECTED_FRAME ()->root_window; | 392 | window = SELECTED_FRAME ()->root_window; |
| 233 | else if (WINDOWP (frame_or_window)) | 393 | else if (WINDOW_VALID_P (frame_or_window)) |
| 234 | window = XFRAME (WINDOW_FRAME (XWINDOW (frame_or_window)))->root_window; | 394 | window = XFRAME (WINDOW_FRAME (XWINDOW (frame_or_window)))->root_window; |
| 235 | else | 395 | else |
| 236 | { | 396 | { |
| @@ -238,15 +398,8 @@ the first window of that frame. */) | |||
| 238 | window = XFRAME (frame_or_window)->root_window; | 398 | window = XFRAME (frame_or_window)->root_window; |
| 239 | } | 399 | } |
| 240 | 400 | ||
| 241 | while (NILP (XWINDOW (window)->buffer)) | 401 | while (WINDOWP (XWINDOW (window)->contents)) |
| 242 | { | 402 | window = XWINDOW (window)->contents; |
| 243 | if (! NILP (XWINDOW (window)->hchild)) | ||
| 244 | window = XWINDOW (window)->hchild; | ||
| 245 | else if (! NILP (XWINDOW (window)->vchild)) | ||
| 246 | window = XWINDOW (window)->vchild; | ||
| 247 | else | ||
| 248 | abort (); | ||
| 249 | } | ||
| 250 | 403 | ||
| 251 | return window; | 404 | return window; |
| 252 | } | 405 | } |
| @@ -255,16 +408,16 @@ DEFUN ("frame-selected-window", Fframe_selected_window, | |||
| 255 | Sframe_selected_window, 0, 1, 0, | 408 | Sframe_selected_window, 0, 1, 0, |
| 256 | doc: /* Return the selected window of FRAME-OR-WINDOW. | 409 | doc: /* Return the selected window of FRAME-OR-WINDOW. |
| 257 | If omitted, FRAME-OR-WINDOW defaults to the currently selected frame. | 410 | If omitted, FRAME-OR-WINDOW defaults to the currently selected frame. |
| 258 | Else if FRAME-OR-WINDOW denotes any window, return the selected window | 411 | Else if FRAME-OR-WINDOW denotes a valid window, return the selected |
| 259 | of that window's frame. If FRAME-OR-WINDOW denotes a live frame, return | 412 | window of that window's frame. If FRAME-OR-WINDOW denotes a live frame, |
| 260 | the selected window of that frame. */) | 413 | return the selected window of that frame. */) |
| 261 | (Lisp_Object frame_or_window) | 414 | (Lisp_Object frame_or_window) |
| 262 | { | 415 | { |
| 263 | Lisp_Object window; | 416 | Lisp_Object window; |
| 264 | 417 | ||
| 265 | if (NILP (frame_or_window)) | 418 | if (NILP (frame_or_window)) |
| 266 | window = SELECTED_FRAME ()->selected_window; | 419 | window = SELECTED_FRAME ()->selected_window; |
| 267 | else if (WINDOWP (frame_or_window)) | 420 | else if (WINDOW_VALID_P (frame_or_window)) |
| 268 | window = XFRAME (WINDOW_FRAME (XWINDOW (frame_or_window)))->selected_window; | 421 | window = XFRAME (WINDOW_FRAME (XWINDOW (frame_or_window)))->selected_window; |
| 269 | else | 422 | else |
| 270 | { | 423 | { |
| @@ -297,7 +450,10 @@ Return WINDOW. */) | |||
| 297 | if (EQ (frame, selected_frame)) | 450 | if (EQ (frame, selected_frame)) |
| 298 | return Fselect_window (window, norecord); | 451 | return Fselect_window (window, norecord); |
| 299 | else | 452 | else |
| 300 | return XFRAME (frame)->selected_window = window; | 453 | { |
| 454 | fset_selected_window (XFRAME (frame), window); | ||
| 455 | return window; | ||
| 456 | } | ||
| 301 | } | 457 | } |
| 302 | 458 | ||
| 303 | DEFUN ("selected-window", Fselected_window, Sselected_window, 0, 0, 0, | 459 | DEFUN ("selected-window", Fselected_window, Sselected_window, 0, 0, 0, |
| @@ -320,28 +476,25 @@ static Lisp_Object | |||
| 320 | select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap) | 476 | select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap) |
| 321 | { | 477 | { |
| 322 | register struct window *w; | 478 | register struct window *w; |
| 323 | register struct window *ow; | ||
| 324 | struct frame *sf; | 479 | struct frame *sf; |
| 325 | 480 | ||
| 326 | CHECK_LIVE_WINDOW (window); | 481 | CHECK_LIVE_WINDOW (window); |
| 327 | 482 | ||
| 328 | w = XWINDOW (window); | 483 | w = XWINDOW (window); |
| 329 | w->frozen_window_start_p = 0; | ||
| 330 | 484 | ||
| 331 | if (NILP (norecord)) | 485 | /* Make the selected window's buffer current. */ |
| 332 | { | 486 | Fset_buffer (w->contents); |
| 333 | ++window_select_count; | ||
| 334 | XSETFASTINT (w->use_time, window_select_count); | ||
| 335 | record_buffer (w->buffer); | ||
| 336 | } | ||
| 337 | 487 | ||
| 338 | if (EQ (window, selected_window) && !inhibit_point_swap) | 488 | if (EQ (window, selected_window) && !inhibit_point_swap) |
| 339 | return window; | 489 | /* `switch-to-buffer' uses (select-window (selected-window)) as a "clever" |
| 490 | way to call record_buffer from Elisp, so it's important that we call | ||
| 491 | record_buffer before returning here. */ | ||
| 492 | goto record_and_return; | ||
| 340 | 493 | ||
| 341 | sf = SELECTED_FRAME (); | 494 | sf = SELECTED_FRAME (); |
| 342 | if (XFRAME (WINDOW_FRAME (w)) != sf) | 495 | if (XFRAME (WINDOW_FRAME (w)) != sf) |
| 343 | { | 496 | { |
| 344 | XFRAME (WINDOW_FRAME (w))->selected_window = window; | 497 | fset_selected_window (XFRAME (WINDOW_FRAME (w)), window); |
| 345 | /* Use this rather than Fhandle_switch_frame | 498 | /* Use this rather than Fhandle_switch_frame |
| 346 | so that FRAME_FOCUS_FRAME is moved appropriately as we | 499 | so that FRAME_FOCUS_FRAME is moved appropriately as we |
| 347 | move around in the state where a minibuffer in a separate | 500 | move around in the state where a minibuffer in a separate |
| @@ -352,49 +505,59 @@ select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap) | |||
| 352 | return window; | 505 | return window; |
| 353 | } | 506 | } |
| 354 | else | 507 | else |
| 355 | sf->selected_window = window; | 508 | fset_selected_window (sf, window); |
| 356 | 509 | ||
| 357 | /* Store the current buffer's actual point into the | 510 | select_window_1 (window, inhibit_point_swap); |
| 358 | old selected window. It belongs to that window, | 511 | bset_last_selected_window (XBUFFER (w->contents), window); |
| 359 | and when the window is not selected, must be in the window. */ | 512 | windows_or_buffers_changed++; |
| 360 | if (!inhibit_point_swap) | 513 | |
| 514 | record_and_return: | ||
| 515 | /* record_buffer can run QUIT, so make sure it is run only after we have | ||
| 516 | re-established the invariant between selected_window and selected_frame, | ||
| 517 | otherwise the temporary broken invariant might "escape" (bug#14161). */ | ||
| 518 | if (NILP (norecord)) | ||
| 361 | { | 519 | { |
| 362 | ow = XWINDOW (selected_window); | 520 | w->use_time = ++window_select_count; |
| 363 | if (! NILP (ow->buffer)) | 521 | record_buffer (w->contents); |
| 364 | set_marker_both (ow->pointm, ow->buffer, | ||
| 365 | BUF_PT (XBUFFER (ow->buffer)), | ||
| 366 | BUF_PT_BYTE (XBUFFER (ow->buffer))); | ||
| 367 | } | 522 | } |
| 368 | 523 | ||
| 369 | selected_window = window; | 524 | return window; |
| 525 | } | ||
| 370 | 526 | ||
| 371 | Fset_buffer (w->buffer); | 527 | /* Select window with a minimum of fuss, i.e. don't record the change anywhere |
| 528 | (not even for redisplay's benefit), and assume that the window's frame is | ||
| 529 | already selected. */ | ||
| 530 | static void | ||
| 531 | select_window_1 (Lisp_Object window, bool inhibit_point_swap) | ||
| 532 | { | ||
| 533 | /* Store the old selected window's buffer's point in pointm of the old | ||
| 534 | selected window. It belongs to that window, and when the window is | ||
| 535 | not selected, must be in the window. */ | ||
| 536 | if (!inhibit_point_swap) | ||
| 537 | { | ||
| 538 | struct window *ow = XWINDOW (selected_window); | ||
| 539 | if (BUFFERP (ow->contents)) | ||
| 540 | set_marker_both (ow->pointm, ow->contents, | ||
| 541 | BUF_PT (XBUFFER (ow->contents)), | ||
| 542 | BUF_PT_BYTE (XBUFFER (ow->contents))); | ||
| 543 | } | ||
| 372 | 544 | ||
| 373 | BVAR (XBUFFER (w->buffer), last_selected_window) = window; | 545 | selected_window = window; |
| 374 | 546 | ||
| 375 | /* Go to the point recorded in the window. | 547 | /* Go to the point recorded in the window. |
| 376 | This is important when the buffer is in more | 548 | This is important when the buffer is in more |
| 377 | than one window. It also matters when | 549 | than one window. It also matters when |
| 378 | redisplay_window has altered point after scrolling, | 550 | redisplay_window has altered point after scrolling, |
| 379 | because it makes the change only in the window. */ | 551 | because it makes the change only in the window. */ |
| 380 | { | 552 | set_point_from_marker (XWINDOW (window)->pointm); |
| 381 | register ptrdiff_t new_point = marker_position (w->pointm); | ||
| 382 | if (new_point < BEGV) | ||
| 383 | SET_PT (BEGV); | ||
| 384 | else if (new_point > ZV) | ||
| 385 | SET_PT (ZV); | ||
| 386 | else | ||
| 387 | SET_PT (new_point); | ||
| 388 | } | ||
| 389 | |||
| 390 | windows_or_buffers_changed++; | ||
| 391 | return window; | ||
| 392 | } | 553 | } |
| 393 | 554 | ||
| 394 | DEFUN ("select-window", Fselect_window, Sselect_window, 1, 2, 0, | 555 | DEFUN ("select-window", Fselect_window, Sselect_window, 1, 2, 0, |
| 395 | doc: /* Select WINDOW. Most editing will apply to WINDOW's buffer. | 556 | doc: /* Select WINDOW which must be a live window. |
| 396 | Also make WINDOW's buffer current and make WINDOW the frame's selected | 557 | Also make WINDOW's frame the selected frame and WINDOW that frame's |
| 397 | window. Return WINDOW. | 558 | selected window. In addition, make WINDOW's buffer current and set that |
| 559 | buffer's value of `point' to the value of WINDOW's `window-point'. | ||
| 560 | Return WINDOW. | ||
| 398 | 561 | ||
| 399 | Optional second arg NORECORD non-nil means do not put this buffer at the | 562 | Optional second arg NORECORD non-nil means do not put this buffer at the |
| 400 | front of the buffer list and do not make this window the most recently | 563 | front of the buffer list and do not make this window the most recently |
| @@ -413,97 +576,111 @@ If WINDOW is omitted or nil, it defaults to the selected window. | |||
| 413 | Return nil for an internal window or a deleted window. */) | 576 | Return nil for an internal window or a deleted window. */) |
| 414 | (Lisp_Object window) | 577 | (Lisp_Object window) |
| 415 | { | 578 | { |
| 416 | return decode_any_window (window)->buffer; | 579 | struct window *w = decode_any_window (window); |
| 580 | return WINDOW_LEAF_P (w) ? w->contents : Qnil; | ||
| 417 | } | 581 | } |
| 418 | 582 | ||
| 419 | DEFUN ("window-parent", Fwindow_parent, Swindow_parent, 0, 1, 0, | 583 | DEFUN ("window-parent", Fwindow_parent, Swindow_parent, 0, 1, 0, |
| 420 | doc: /* Return the parent window of window WINDOW. | 584 | doc: /* Return the parent window of window WINDOW. |
| 421 | If WINDOW is omitted or nil, it defaults to the selected window. | 585 | WINDOW must be a valid window and defaults to the selected one. |
| 422 | Return nil for a window with no parent (e.g. a root window). */) | 586 | Return nil for a window with no parent (e.g. a root window). */) |
| 423 | (Lisp_Object window) | 587 | (Lisp_Object window) |
| 424 | { | 588 | { |
| 425 | return decode_any_window (window)->parent; | 589 | return decode_valid_window (window)->parent; |
| 426 | } | 590 | } |
| 427 | 591 | ||
| 428 | DEFUN ("window-top-child", Fwindow_top_child, Swindow_top_child, 1, 1, 0, | 592 | DEFUN ("window-top-child", Fwindow_top_child, Swindow_top_child, 0, 1, 0, |
| 429 | doc: /* Return the topmost child window of window WINDOW. | 593 | doc: /* Return the topmost child window of window WINDOW. |
| 594 | WINDOW must be a valid window and defaults to the selected one. | ||
| 430 | Return nil if WINDOW is a live window (live windows have no children). | 595 | Return nil if WINDOW is a live window (live windows have no children). |
| 431 | Return nil if WINDOW is an internal window whose children form a | 596 | Return nil if WINDOW is an internal window whose children form a |
| 432 | horizontal combination. */) | 597 | horizontal combination. */) |
| 433 | (Lisp_Object window) | 598 | (Lisp_Object window) |
| 434 | { | 599 | { |
| 435 | CHECK_WINDOW (window); | 600 | struct window *w = decode_valid_window (window); |
| 436 | return decode_any_window (window)->vchild; | 601 | return WINDOW_VERTICAL_COMBINATION_P (w) ? w->contents : Qnil; |
| 437 | } | 602 | } |
| 438 | 603 | ||
| 439 | DEFUN ("window-left-child", Fwindow_left_child, Swindow_left_child, 1, 1, 0, | 604 | DEFUN ("window-left-child", Fwindow_left_child, Swindow_left_child, 0, 1, 0, |
| 440 | doc: /* Return the leftmost child window of window WINDOW. | 605 | doc: /* Return the leftmost child window of window WINDOW. |
| 606 | WINDOW must be a valid window and defaults to the selected one. | ||
| 441 | Return nil if WINDOW is a live window (live windows have no children). | 607 | Return nil if WINDOW is a live window (live windows have no children). |
| 442 | Return nil if WINDOW is an internal window whose children form a | 608 | Return nil if WINDOW is an internal window whose children form a |
| 443 | vertical combination. */) | 609 | vertical combination. */) |
| 444 | (Lisp_Object window) | 610 | (Lisp_Object window) |
| 445 | { | 611 | { |
| 446 | CHECK_WINDOW (window); | 612 | struct window *w = decode_valid_window (window); |
| 447 | return decode_any_window (window)->hchild; | 613 | return WINDOW_HORIZONTAL_COMBINATION_P (w) ? w->contents : Qnil; |
| 448 | } | 614 | } |
| 449 | 615 | ||
| 450 | DEFUN ("window-next-sibling", Fwindow_next_sibling, Swindow_next_sibling, 0, 1, 0, | 616 | DEFUN ("window-next-sibling", Fwindow_next_sibling, Swindow_next_sibling, 0, 1, 0, |
| 451 | doc: /* Return the next sibling window of window WINDOW. | 617 | doc: /* Return the next sibling window of window WINDOW. |
| 452 | If WINDOW is omitted or nil, it defaults to the selected window. | 618 | WINDOW must be a valid window and defaults to the selected one. |
| 453 | Return nil if WINDOW has no next sibling. */) | 619 | Return nil if WINDOW has no next sibling. */) |
| 454 | (Lisp_Object window) | 620 | (Lisp_Object window) |
| 455 | { | 621 | { |
| 456 | return decode_any_window (window)->next; | 622 | return decode_valid_window (window)->next; |
| 457 | } | 623 | } |
| 458 | 624 | ||
| 459 | DEFUN ("window-prev-sibling", Fwindow_prev_sibling, Swindow_prev_sibling, 0, 1, 0, | 625 | DEFUN ("window-prev-sibling", Fwindow_prev_sibling, Swindow_prev_sibling, 0, 1, 0, |
| 460 | doc: /* Return the previous sibling window of window WINDOW. | 626 | doc: /* Return the previous sibling window of window WINDOW. |
| 461 | If WINDOW is omitted or nil, it defaults to the selected window. | 627 | WINDOW must be a valid window and defaults to the selected one. |
| 462 | Return nil if WINDOW has no previous sibling. */) | 628 | Return nil if WINDOW has no previous sibling. */) |
| 463 | (Lisp_Object window) | 629 | (Lisp_Object window) |
| 464 | { | 630 | { |
| 465 | return decode_any_window (window)->prev; | 631 | return decode_valid_window (window)->prev; |
| 466 | } | 632 | } |
| 467 | 633 | ||
| 468 | DEFUN ("window-combination-limit", Fwindow_combination_limit, Swindow_combination_limit, 1, 1, 0, | 634 | DEFUN ("window-combination-limit", Fwindow_combination_limit, Swindow_combination_limit, 1, 1, 0, |
| 469 | doc: /* Return combination limit of window WINDOW. | 635 | doc: /* Return combination limit of window WINDOW. |
| 636 | WINDOW must be a valid window used in horizontal or vertical combination. | ||
| 470 | If the return value is nil, child windows of WINDOW can be recombined with | 637 | If the return value is nil, child windows of WINDOW can be recombined with |
| 471 | WINDOW's siblings. A return value of t means that child windows of | 638 | WINDOW's siblings. A return value of t means that child windows of |
| 472 | WINDOW are never \(re-)combined with WINDOW's siblings. */) | 639 | WINDOW are never \(re-)combined with WINDOW's siblings. */) |
| 473 | (Lisp_Object window) | 640 | (Lisp_Object window) |
| 474 | { | 641 | { |
| 475 | return decode_any_window (window)->combination_limit; | 642 | struct window *w; |
| 643 | |||
| 644 | CHECK_VALID_WINDOW (window); | ||
| 645 | w = XWINDOW (window); | ||
| 646 | if (WINDOW_LEAF_P (w)) | ||
| 647 | error ("Combination limit is meaningful for internal windows only"); | ||
| 648 | return w->combination_limit; | ||
| 476 | } | 649 | } |
| 477 | 650 | ||
| 478 | DEFUN ("set-window-combination-limit", Fset_window_combination_limit, Sset_window_combination_limit, 2, 2, 0, | 651 | DEFUN ("set-window-combination-limit", Fset_window_combination_limit, Sset_window_combination_limit, 2, 2, 0, |
| 479 | doc: /* Set combination limit of window WINDOW to LIMIT; return LIMIT. | 652 | doc: /* Set combination limit of window WINDOW to LIMIT; return LIMIT. |
| 480 | If LIMIT is nil, child windows of WINDOW can be recombined with | 653 | WINDOW must be a valid window used in horizontal or vertical combination. |
| 481 | WINDOW's siblings. LIMIT t means that child windows of WINDOW are | 654 | If LIMIT is nil, child windows of WINDOW can be recombined with WINDOW's |
| 482 | never \(re-)combined with WINDOW's siblings. Other values are reserved | 655 | siblings. LIMIT t means that child windows of WINDOW are never |
| 483 | for future use. */) | 656 | \(re-)combined with WINDOW's siblings. Other values are reserved for |
| 657 | future use. */) | ||
| 484 | (Lisp_Object window, Lisp_Object limit) | 658 | (Lisp_Object window, Lisp_Object limit) |
| 485 | { | 659 | { |
| 486 | register struct window *w = decode_any_window (window); | 660 | struct window *w; |
| 487 | |||
| 488 | w->combination_limit = limit; | ||
| 489 | 661 | ||
| 490 | return w->combination_limit; | 662 | CHECK_VALID_WINDOW (window); |
| 663 | w = XWINDOW (window); | ||
| 664 | if (WINDOW_LEAF_P (w)) | ||
| 665 | error ("Combination limit is meaningful for internal windows only"); | ||
| 666 | wset_combination_limit (w, limit); | ||
| 667 | return limit; | ||
| 491 | } | 668 | } |
| 492 | 669 | ||
| 493 | DEFUN ("window-use-time", Fwindow_use_time, Swindow_use_time, 0, 1, 0, | 670 | DEFUN ("window-use-time", Fwindow_use_time, Swindow_use_time, 0, 1, 0, |
| 494 | doc: /* Return the use time of window WINDOW. | 671 | doc: /* Return the use time of window WINDOW. |
| 495 | If WINDOW is omitted or nil, it defaults to the selected window. | 672 | WINDOW must be a live window and defaults to the selected one. |
| 496 | The window with the highest use time is the most recently selected | 673 | The window with the highest use time is the most recently selected |
| 497 | one. The window with the lowest use time is the least recently | 674 | one. The window with the lowest use time is the least recently |
| 498 | selected one. */) | 675 | selected one. */) |
| 499 | (Lisp_Object window) | 676 | (Lisp_Object window) |
| 500 | { | 677 | { |
| 501 | return decode_window (window)->use_time; | 678 | return make_number (decode_live_window (window)->use_time); |
| 502 | } | 679 | } |
| 503 | 680 | ||
| 504 | DEFUN ("window-total-height", Fwindow_total_height, Swindow_total_height, 0, 1, 0, | 681 | DEFUN ("window-total-height", Fwindow_total_height, Swindow_total_height, 0, 1, 0, |
| 505 | doc: /* Return the total height, in lines, of window WINDOW. | 682 | doc: /* Return the total height, in lines, of window WINDOW. |
| 506 | If WINDOW is omitted or nil, it defaults to the selected window. | 683 | WINDOW must be a valid window and defaults to the selected one. |
| 507 | 684 | ||
| 508 | The return value includes the mode line and header line, if any. | 685 | The return value includes the mode line and header line, if any. |
| 509 | If WINDOW is an internal window, the total height is the height | 686 | If WINDOW is an internal window, the total height is the height |
| @@ -513,12 +690,12 @@ On a graphical display, this total height is reported as an | |||
| 513 | integer multiple of the default character height. */) | 690 | integer multiple of the default character height. */) |
| 514 | (Lisp_Object window) | 691 | (Lisp_Object window) |
| 515 | { | 692 | { |
| 516 | return decode_any_window (window)->total_lines; | 693 | return make_number (decode_valid_window (window)->total_lines); |
| 517 | } | 694 | } |
| 518 | 695 | ||
| 519 | DEFUN ("window-total-width", Fwindow_total_width, Swindow_total_width, 0, 1, 0, | 696 | DEFUN ("window-total-width", Fwindow_total_width, Swindow_total_width, 0, 1, 0, |
| 520 | doc: /* Return the total width, in columns, of window WINDOW. | 697 | doc: /* Return the total width, in columns, of window WINDOW. |
| 521 | If WINDOW is omitted or nil, it defaults to the selected window. | 698 | WINDOW must be a valid window and defaults to the selected one. |
| 522 | 699 | ||
| 523 | The return value includes any vertical dividers or scroll bars | 700 | The return value includes any vertical dividers or scroll bars |
| 524 | belonging to WINDOW. If WINDOW is an internal window, the total width | 701 | belonging to WINDOW. If WINDOW is an internal window, the total width |
| @@ -528,35 +705,34 @@ On a graphical display, this total width is reported as an | |||
| 528 | integer multiple of the default character width. */) | 705 | integer multiple of the default character width. */) |
| 529 | (Lisp_Object window) | 706 | (Lisp_Object window) |
| 530 | { | 707 | { |
| 531 | return decode_any_window (window)->total_cols; | 708 | return make_number (decode_valid_window (window)->total_cols); |
| 532 | } | 709 | } |
| 533 | 710 | ||
| 534 | DEFUN ("window-new-total", Fwindow_new_total, Swindow_new_total, 0, 1, 0, | 711 | DEFUN ("window-new-total", Fwindow_new_total, Swindow_new_total, 0, 1, 0, |
| 535 | doc: /* Return the new total size of window WINDOW. | 712 | doc: /* Return the new total size of window WINDOW. |
| 536 | If WINDOW is omitted or nil, it defaults to the selected window. */) | 713 | WINDOW must be a valid window and defaults to the selected one. */) |
| 537 | (Lisp_Object window) | 714 | (Lisp_Object window) |
| 538 | { | 715 | { |
| 539 | return decode_any_window (window)->new_total; | 716 | return decode_valid_window (window)->new_total; |
| 540 | } | 717 | } |
| 541 | 718 | ||
| 542 | DEFUN ("window-normal-size", Fwindow_normal_size, Swindow_normal_size, 0, 2, 0, | 719 | DEFUN ("window-normal-size", Fwindow_normal_size, Swindow_normal_size, 0, 2, 0, |
| 543 | doc: /* Return the normal height of window WINDOW. | 720 | doc: /* Return the normal height of window WINDOW. |
| 544 | If WINDOW is omitted or nil, it defaults to the selected window. | 721 | WINDOW must be a valid window and defaults to the selected one. |
| 545 | If HORIZONTAL is non-nil, return the normal width of WINDOW. */) | 722 | If HORIZONTAL is non-nil, return the normal width of WINDOW. */) |
| 546 | (Lisp_Object window, Lisp_Object horizontal) | 723 | (Lisp_Object window, Lisp_Object horizontal) |
| 547 | { | 724 | { |
| 548 | if (NILP (horizontal)) | 725 | struct window *w = decode_valid_window (window); |
| 549 | return decode_any_window (window)->normal_lines; | 726 | |
| 550 | else | 727 | return NILP (horizontal) ? w->normal_lines : w->normal_cols; |
| 551 | return decode_any_window (window)->normal_cols; | ||
| 552 | } | 728 | } |
| 553 | 729 | ||
| 554 | DEFUN ("window-new-normal", Fwindow_new_normal, Swindow_new_normal, 0, 1, 0, | 730 | DEFUN ("window-new-normal", Fwindow_new_normal, Swindow_new_normal, 0, 1, 0, |
| 555 | doc: /* Return new normal size of window WINDOW. | 731 | doc: /* Return new normal size of window WINDOW. |
| 556 | If WINDOW is omitted or nil, it defaults to the selected window. */) | 732 | WINDOW must be a valid window and defaults to the selected one. */) |
| 557 | (Lisp_Object window) | 733 | (Lisp_Object window) |
| 558 | { | 734 | { |
| 559 | return decode_any_window (window)->new_normal; | 735 | return decode_valid_window (window)->new_normal; |
| 560 | } | 736 | } |
| 561 | 737 | ||
| 562 | DEFUN ("window-left-column", Fwindow_left_column, Swindow_left_column, 0, 1, 0, | 738 | DEFUN ("window-left-column", Fwindow_left_column, Swindow_left_column, 0, 1, 0, |
| @@ -565,10 +741,10 @@ This is the distance, in columns, between the left edge of WINDOW and | |||
| 565 | the left edge of the frame's window area. For instance, the return | 741 | the left edge of the frame's window area. For instance, the return |
| 566 | value is 0 if there is no window to the left of WINDOW. | 742 | value is 0 if there is no window to the left of WINDOW. |
| 567 | 743 | ||
| 568 | If WINDOW is omitted or nil, it defaults to the selected window. */) | 744 | WINDOW must be a valid window and defaults to the selected one. */) |
| 569 | (Lisp_Object window) | 745 | (Lisp_Object window) |
| 570 | { | 746 | { |
| 571 | return decode_any_window (window)->left_col; | 747 | return make_number (decode_valid_window (window)->left_col); |
| 572 | } | 748 | } |
| 573 | 749 | ||
| 574 | DEFUN ("window-top-line", Fwindow_top_line, Swindow_top_line, 0, 1, 0, | 750 | DEFUN ("window-top-line", Fwindow_top_line, Swindow_top_line, 0, 1, 0, |
| @@ -577,10 +753,10 @@ This is the distance, in lines, between the top of WINDOW and the top | |||
| 577 | of the frame's window area. For instance, the return value is 0 if | 753 | of the frame's window area. For instance, the return value is 0 if |
| 578 | there is no window above WINDOW. | 754 | there is no window above WINDOW. |
| 579 | 755 | ||
| 580 | If WINDOW is omitted or nil, it defaults to the selected window. */) | 756 | WINDOW must be a valid window and defaults to the selected one. */) |
| 581 | (Lisp_Object window) | 757 | (Lisp_Object window) |
| 582 | { | 758 | { |
| 583 | return decode_any_window (window)->top_line; | 759 | return make_number (decode_valid_window (window)->top_line); |
| 584 | } | 760 | } |
| 585 | 761 | ||
| 586 | /* Return the number of lines of W's body. Don't count any mode or | 762 | /* Return the number of lines of W's body. Don't count any mode or |
| @@ -589,7 +765,7 @@ If WINDOW is omitted or nil, it defaults to the selected window. */) | |||
| 589 | static int | 765 | static int |
| 590 | window_body_lines (struct window *w) | 766 | window_body_lines (struct window *w) |
| 591 | { | 767 | { |
| 592 | int height = XFASTINT (w->total_lines); | 768 | int height = w->total_lines; |
| 593 | 769 | ||
| 594 | if (!MINI_WINDOW_P (w)) | 770 | if (!MINI_WINDOW_P (w)) |
| 595 | { | 771 | { |
| @@ -611,7 +787,7 @@ int | |||
| 611 | window_body_cols (struct window *w) | 787 | window_body_cols (struct window *w) |
| 612 | { | 788 | { |
| 613 | struct frame *f = XFRAME (WINDOW_FRAME (w)); | 789 | struct frame *f = XFRAME (WINDOW_FRAME (w)); |
| 614 | int width = XINT (w->total_cols); | 790 | int width = w->total_cols; |
| 615 | 791 | ||
| 616 | if (WINDOW_HAS_VERTICAL_SCROLL_BAR (w)) | 792 | if (WINDOW_HAS_VERTICAL_SCROLL_BAR (w)) |
| 617 | /* Scroll bars occupy a few columns. */ | 793 | /* Scroll bars occupy a few columns. */ |
| @@ -622,20 +798,19 @@ window_body_cols (struct window *w) | |||
| 622 | occupies one column only. */ | 798 | occupies one column only. */ |
| 623 | width -= 1; | 799 | width -= 1; |
| 624 | 800 | ||
| 801 | /* Display margins cannot be used for normal text. */ | ||
| 802 | width -= WINDOW_LEFT_MARGIN_COLS (w) + WINDOW_RIGHT_MARGIN_COLS (w); | ||
| 803 | |||
| 625 | if (FRAME_WINDOW_P (f)) | 804 | if (FRAME_WINDOW_P (f)) |
| 626 | /* On window-systems, fringes and display margins cannot be | 805 | /* On window-systems, fringes cannot be used for normal text. */ |
| 627 | used for normal text. */ | 806 | width -= WINDOW_FRINGE_COLS (w); |
| 628 | width -= (WINDOW_FRINGE_COLS (w) | ||
| 629 | + WINDOW_LEFT_MARGIN_COLS (w) | ||
| 630 | + WINDOW_RIGHT_MARGIN_COLS (w)); | ||
| 631 | 807 | ||
| 632 | return width; | 808 | return width; |
| 633 | } | 809 | } |
| 634 | 810 | ||
| 635 | DEFUN ("window-body-height", Fwindow_body_height, Swindow_body_height, 0, 1, 0, | 811 | DEFUN ("window-body-height", Fwindow_body_height, Swindow_body_height, 0, 1, 0, |
| 636 | doc: /* Return the height, in lines, of WINDOW's text area. | 812 | doc: /* Return the height, in lines, of WINDOW's text area. |
| 637 | If WINDOW is omitted or nil, it defaults to the selected window. | 813 | WINDOW must be a live window and defaults to the selected one. |
| 638 | Signal an error if the window is not live. | ||
| 639 | 814 | ||
| 640 | The returned height does not include the mode line or header line. | 815 | The returned height does not include the mode line or header line. |
| 641 | On a graphical display, the height is expressed as an integer multiple | 816 | On a graphical display, the height is expressed as an integer multiple |
| @@ -644,22 +819,19 @@ area is only partially visible, that counts as a whole line; to | |||
| 644 | exclude partially-visible lines, use `window-text-height'. */) | 819 | exclude partially-visible lines, use `window-text-height'. */) |
| 645 | (Lisp_Object window) | 820 | (Lisp_Object window) |
| 646 | { | 821 | { |
| 647 | struct window *w = decode_window (window); | 822 | return make_number (window_body_lines (decode_live_window (window))); |
| 648 | return make_number (window_body_lines (w)); | ||
| 649 | } | 823 | } |
| 650 | 824 | ||
| 651 | DEFUN ("window-body-width", Fwindow_body_width, Swindow_body_width, 0, 1, 0, | 825 | DEFUN ("window-body-width", Fwindow_body_width, Swindow_body_width, 0, 1, 0, |
| 652 | doc: /* Return the width, in columns, of WINDOW's text area. | 826 | doc: /* Return the width, in columns, of WINDOW's text area. |
| 653 | If WINDOW is omitted or nil, it defaults to the selected window. | 827 | WINDOW must be a live window and defaults to the selected one. |
| 654 | Signal an error if the window is not live. | ||
| 655 | 828 | ||
| 656 | The return value does not include any vertical dividers, fringe or | 829 | The return value does not include any vertical dividers, fringe or |
| 657 | marginal areas, or scroll bars. On a graphical display, the width is | 830 | marginal areas, or scroll bars. On a graphical display, the width is |
| 658 | expressed as an integer multiple of the default character width. */) | 831 | expressed as an integer multiple of the default character width. */) |
| 659 | (Lisp_Object window) | 832 | (Lisp_Object window) |
| 660 | { | 833 | { |
| 661 | struct window *w = decode_window (window); | 834 | return make_number (window_body_cols (decode_live_window (window))); |
| 662 | return make_number (window_body_cols (w)); | ||
| 663 | } | 835 | } |
| 664 | 836 | ||
| 665 | DEFUN ("window-hscroll", Fwindow_hscroll, Swindow_hscroll, 0, 1, 0, | 837 | DEFUN ("window-hscroll", Fwindow_hscroll, Swindow_hscroll, 0, 1, 0, |
| @@ -667,85 +839,97 @@ DEFUN ("window-hscroll", Fwindow_hscroll, Swindow_hscroll, 0, 1, 0, | |||
| 667 | WINDOW must be a live window and defaults to the selected one. */) | 839 | WINDOW must be a live window and defaults to the selected one. */) |
| 668 | (Lisp_Object window) | 840 | (Lisp_Object window) |
| 669 | { | 841 | { |
| 670 | return decode_window (window)->hscroll; | 842 | return make_number (decode_live_window (window)->hscroll); |
| 843 | } | ||
| 844 | |||
| 845 | /* Set W's horizontal scroll amount to HSCROLL clipped to a reasonable | ||
| 846 | range, returning the new amount as a fixnum. */ | ||
| 847 | static Lisp_Object | ||
| 848 | set_window_hscroll (struct window *w, EMACS_INT hscroll) | ||
| 849 | { | ||
| 850 | /* Horizontal scrolling has problems with large scroll amounts. | ||
| 851 | It's too slow with long lines, and even with small lines the | ||
| 852 | display can be messed up. For now, though, impose only the limits | ||
| 853 | required by the internal representation: horizontal scrolling must | ||
| 854 | fit in fixnum (since it's visible to Elisp) and into ptrdiff_t | ||
| 855 | (since it's stored in a ptrdiff_t). */ | ||
| 856 | ptrdiff_t hscroll_max = min (MOST_POSITIVE_FIXNUM, PTRDIFF_MAX); | ||
| 857 | ptrdiff_t new_hscroll = clip_to_bounds (0, hscroll, hscroll_max); | ||
| 858 | |||
| 859 | /* Prevent redisplay shortcuts when changing the hscroll. */ | ||
| 860 | if (w->hscroll != new_hscroll) | ||
| 861 | XBUFFER (w->contents)->prevent_redisplay_optimizations_p = 1; | ||
| 862 | |||
| 863 | w->hscroll = new_hscroll; | ||
| 864 | return make_number (new_hscroll); | ||
| 671 | } | 865 | } |
| 672 | 866 | ||
| 673 | DEFUN ("set-window-hscroll", Fset_window_hscroll, Sset_window_hscroll, 2, 2, 0, | 867 | DEFUN ("set-window-hscroll", Fset_window_hscroll, Sset_window_hscroll, 2, 2, 0, |
| 674 | doc: /* Set number of columns WINDOW is scrolled from left margin to NCOL. | 868 | doc: /* Set number of columns WINDOW is scrolled from left margin to NCOL. |
| 675 | If WINDOW is nil, the selected window is used. | 869 | WINDOW must be a live window and defaults to the selected one. |
| 676 | Return NCOL. NCOL should be zero or positive. | 870 | Clip the number to a reasonable value if out of range. |
| 871 | Return the new number. NCOL should be zero or positive. | ||
| 677 | 872 | ||
| 678 | Note that if `automatic-hscrolling' is non-nil, you cannot scroll the | 873 | Note that if `automatic-hscrolling' is non-nil, you cannot scroll the |
| 679 | window so that the location of point moves off-window. */) | 874 | window so that the location of point moves off-window. */) |
| 680 | (Lisp_Object window, Lisp_Object ncol) | 875 | (Lisp_Object window, Lisp_Object ncol) |
| 681 | { | 876 | { |
| 682 | struct window *w = decode_window (window); | ||
| 683 | ptrdiff_t hscroll; | ||
| 684 | |||
| 685 | CHECK_NUMBER (ncol); | 877 | CHECK_NUMBER (ncol); |
| 686 | hscroll = clip_to_bounds (0, XINT (ncol), PTRDIFF_MAX); | 878 | return set_window_hscroll (decode_live_window (window), XINT (ncol)); |
| 687 | |||
| 688 | /* Prevent redisplay shortcuts when changing the hscroll. */ | ||
| 689 | if (XINT (w->hscroll) != hscroll) | ||
| 690 | XBUFFER (w->buffer)->prevent_redisplay_optimizations_p = 1; | ||
| 691 | |||
| 692 | w->hscroll = make_number (hscroll); | ||
| 693 | return ncol; | ||
| 694 | } | 879 | } |
| 695 | 880 | ||
| 696 | DEFUN ("window-redisplay-end-trigger", Fwindow_redisplay_end_trigger, | 881 | DEFUN ("window-redisplay-end-trigger", Fwindow_redisplay_end_trigger, |
| 697 | Swindow_redisplay_end_trigger, 0, 1, 0, | 882 | Swindow_redisplay_end_trigger, 0, 1, 0, |
| 698 | doc: /* Return WINDOW's redisplay end trigger value. | 883 | doc: /* Return WINDOW's redisplay end trigger value. |
| 699 | WINDOW defaults to the selected window. | 884 | WINDOW must be a live window and defaults to the selected one. |
| 700 | See `set-window-redisplay-end-trigger' for more information. */) | 885 | See `set-window-redisplay-end-trigger' for more information. */) |
| 701 | (Lisp_Object window) | 886 | (Lisp_Object window) |
| 702 | { | 887 | { |
| 703 | return decode_window (window)->redisplay_end_trigger; | 888 | return decode_live_window (window)->redisplay_end_trigger; |
| 704 | } | 889 | } |
| 705 | 890 | ||
| 706 | DEFUN ("set-window-redisplay-end-trigger", Fset_window_redisplay_end_trigger, | 891 | DEFUN ("set-window-redisplay-end-trigger", Fset_window_redisplay_end_trigger, |
| 707 | Sset_window_redisplay_end_trigger, 2, 2, 0, | 892 | Sset_window_redisplay_end_trigger, 2, 2, 0, |
| 708 | doc: /* Set WINDOW's redisplay end trigger value to VALUE. | 893 | doc: /* Set WINDOW's redisplay end trigger value to VALUE. |
| 709 | VALUE should be a buffer position (typically a marker) or nil. | 894 | WINDOW must be a live window and defaults to the selected one. VALUE |
| 710 | If it is a buffer position, then if redisplay in WINDOW reaches a position | 895 | should be a buffer position (typically a marker) or nil. If it is a |
| 711 | beyond VALUE, the functions in `redisplay-end-trigger-functions' are called | 896 | buffer position, then if redisplay in WINDOW reaches a position beyond |
| 712 | with two arguments: WINDOW, and the end trigger value. | 897 | VALUE, the functions in `redisplay-end-trigger-functions' are called |
| 713 | Afterwards the end-trigger value is reset to nil. */) | 898 | with two arguments: WINDOW, and the end trigger value. Afterwards the |
| 899 | end-trigger value is reset to nil. */) | ||
| 714 | (register Lisp_Object window, Lisp_Object value) | 900 | (register Lisp_Object window, Lisp_Object value) |
| 715 | { | 901 | { |
| 716 | register struct window *w; | 902 | wset_redisplay_end_trigger (decode_live_window (window), value); |
| 717 | |||
| 718 | w = decode_window (window); | ||
| 719 | w->redisplay_end_trigger = value; | ||
| 720 | return value; | 903 | return value; |
| 721 | } | 904 | } |
| 722 | 905 | ||
| 723 | DEFUN ("window-edges", Fwindow_edges, Swindow_edges, 0, 1, 0, | 906 | DEFUN ("window-edges", Fwindow_edges, Swindow_edges, 0, 1, 0, |
| 724 | doc: /* Return a list of the edge coordinates of WINDOW. | 907 | doc: /* Return a list of the edge coordinates of WINDOW. |
| 725 | The list has the form (LEFT TOP RIGHT BOTTOM). | 908 | WINDOW must be a valid window and defaults to the selected one. |
| 726 | TOP and BOTTOM count by lines, and LEFT and RIGHT count by columns, | 909 | |
| 727 | all relative to 0, 0 at top left corner of frame. | 910 | The returned list has the form (LEFT TOP RIGHT BOTTOM). TOP and BOTTOM |
| 728 | 911 | count by lines, and LEFT and RIGHT count by columns, all relative to 0, | |
| 729 | RIGHT is one more than the rightmost column occupied by WINDOW. | 912 | 0 at top left corner of frame. |
| 730 | BOTTOM is one more than the bottommost row occupied by WINDOW. | 913 | |
| 731 | The edges include the space used by WINDOW's scroll bar, display | 914 | RIGHT is one more than the rightmost column occupied by WINDOW. BOTTOM |
| 732 | margins, fringes, header line, and/or mode line. For the edges of | 915 | is one more than the bottommost row occupied by WINDOW. The edges |
| 733 | just the text area, use `window-inside-edges'. */) | 916 | include the space used by WINDOW's scroll bar, display margins, fringes, |
| 917 | header line, and/or mode line. For the edges of just the text area, use | ||
| 918 | `window-inside-edges'. */) | ||
| 734 | (Lisp_Object window) | 919 | (Lisp_Object window) |
| 735 | { | 920 | { |
| 736 | register struct window *w = decode_any_window (window); | 921 | register struct window *w = decode_valid_window (window); |
| 737 | 922 | ||
| 738 | return Fcons (make_number (WINDOW_LEFT_EDGE_COL (w)), | 923 | return list4i (WINDOW_LEFT_EDGE_COL (w), WINDOW_TOP_EDGE_LINE (w), |
| 739 | Fcons (make_number (WINDOW_TOP_EDGE_LINE (w)), | 924 | WINDOW_RIGHT_EDGE_COL (w), WINDOW_BOTTOM_EDGE_LINE (w)); |
| 740 | Fcons (make_number (WINDOW_RIGHT_EDGE_COL (w)), | ||
| 741 | Fcons (make_number (WINDOW_BOTTOM_EDGE_LINE (w)), | ||
| 742 | Qnil)))); | ||
| 743 | } | 925 | } |
| 744 | 926 | ||
| 745 | DEFUN ("window-pixel-edges", Fwindow_pixel_edges, Swindow_pixel_edges, 0, 1, 0, | 927 | DEFUN ("window-pixel-edges", Fwindow_pixel_edges, Swindow_pixel_edges, 0, 1, 0, |
| 746 | doc: /* Return a list of the edge pixel coordinates of WINDOW. | 928 | doc: /* Return a list of the edge pixel coordinates of WINDOW. |
| 747 | The list has the form (LEFT TOP RIGHT BOTTOM), all relative to 0, 0 at | 929 | WINDOW must be a valid window and defaults to the selected one. |
| 748 | the top left corner of the frame. | 930 | |
| 931 | The returned list has the form (LEFT TOP RIGHT BOTTOM), all relative to | ||
| 932 | 0, 0 at the top left corner of the frame. | ||
| 749 | 933 | ||
| 750 | RIGHT is one more than the rightmost x position occupied by WINDOW. | 934 | RIGHT is one more than the rightmost x position occupied by WINDOW. |
| 751 | BOTTOM is one more than the bottommost y position occupied by WINDOW. | 935 | BOTTOM is one more than the bottommost y position occupied by WINDOW. |
| @@ -754,13 +938,10 @@ margins, fringes, header line, and/or mode line. For the pixel edges | |||
| 754 | of just the text area, use `window-inside-pixel-edges'. */) | 938 | of just the text area, use `window-inside-pixel-edges'. */) |
| 755 | (Lisp_Object window) | 939 | (Lisp_Object window) |
| 756 | { | 940 | { |
| 757 | register struct window *w = decode_any_window (window); | 941 | register struct window *w = decode_valid_window (window); |
| 758 | 942 | ||
| 759 | return Fcons (make_number (WINDOW_LEFT_EDGE_X (w)), | 943 | return list4i (WINDOW_LEFT_EDGE_X (w), WINDOW_TOP_EDGE_Y (w), |
| 760 | Fcons (make_number (WINDOW_TOP_EDGE_Y (w)), | 944 | WINDOW_RIGHT_EDGE_X (w), WINDOW_BOTTOM_EDGE_Y (w)); |
| 761 | Fcons (make_number (WINDOW_RIGHT_EDGE_X (w)), | ||
| 762 | Fcons (make_number (WINDOW_BOTTOM_EDGE_Y (w)), | ||
| 763 | Qnil)))); | ||
| 764 | } | 945 | } |
| 765 | 946 | ||
| 766 | static void | 947 | static void |
| @@ -788,8 +969,10 @@ calc_absolute_offset (struct window *w, int *add_x, int *add_y) | |||
| 788 | DEFUN ("window-absolute-pixel-edges", Fwindow_absolute_pixel_edges, | 969 | DEFUN ("window-absolute-pixel-edges", Fwindow_absolute_pixel_edges, |
| 789 | Swindow_absolute_pixel_edges, 0, 1, 0, | 970 | Swindow_absolute_pixel_edges, 0, 1, 0, |
| 790 | doc: /* Return a list of the edge pixel coordinates of WINDOW. | 971 | doc: /* Return a list of the edge pixel coordinates of WINDOW. |
| 791 | The list has the form (LEFT TOP RIGHT BOTTOM), all relative to 0, 0 at | 972 | WINDOW must be a valid window and defaults to the selected one. |
| 792 | the top left corner of the display. | 973 | |
| 974 | The returned list has the form (LEFT TOP RIGHT BOTTOM), all relative to | ||
| 975 | 0, 0 at the top left corner of the display. | ||
| 793 | 976 | ||
| 794 | RIGHT is one more than the rightmost x position occupied by WINDOW. | 977 | RIGHT is one more than the rightmost x position occupied by WINDOW. |
| 795 | BOTTOM is one more than the bottommost y position occupied by WINDOW. | 978 | BOTTOM is one more than the bottommost y position occupied by WINDOW. |
| @@ -798,47 +981,51 @@ margins, fringes, header line, and/or mode line. For the pixel edges | |||
| 798 | of just the text area, use `window-inside-absolute-pixel-edges'. */) | 981 | of just the text area, use `window-inside-absolute-pixel-edges'. */) |
| 799 | (Lisp_Object window) | 982 | (Lisp_Object window) |
| 800 | { | 983 | { |
| 801 | register struct window *w = decode_any_window (window); | 984 | register struct window *w = decode_valid_window (window); |
| 802 | int add_x, add_y; | 985 | int add_x, add_y; |
| 986 | |||
| 803 | calc_absolute_offset (w, &add_x, &add_y); | 987 | calc_absolute_offset (w, &add_x, &add_y); |
| 804 | 988 | ||
| 805 | return Fcons (make_number (WINDOW_LEFT_EDGE_X (w) + add_x), | 989 | return list4i (WINDOW_LEFT_EDGE_X (w) + add_x, |
| 806 | Fcons (make_number (WINDOW_TOP_EDGE_Y (w) + add_y), | 990 | WINDOW_TOP_EDGE_Y (w) + add_y, |
| 807 | Fcons (make_number (WINDOW_RIGHT_EDGE_X (w) + add_x), | 991 | WINDOW_RIGHT_EDGE_X (w) + add_x, |
| 808 | Fcons (make_number (WINDOW_BOTTOM_EDGE_Y (w) + add_y), | 992 | WINDOW_BOTTOM_EDGE_Y (w) + add_y); |
| 809 | Qnil)))); | ||
| 810 | } | 993 | } |
| 811 | 994 | ||
| 812 | DEFUN ("window-inside-edges", Fwindow_inside_edges, Swindow_inside_edges, 0, 1, 0, | 995 | DEFUN ("window-inside-edges", Fwindow_inside_edges, Swindow_inside_edges, 0, 1, 0, |
| 813 | doc: /* Return a list of the edge coordinates of WINDOW. | 996 | doc: /* Return a list of the edge coordinates of WINDOW. |
| 814 | The list has the form (LEFT TOP RIGHT BOTTOM). | 997 | WINDOW must be a live window and defaults to the selected one. |
| 815 | TOP and BOTTOM count by lines, and LEFT and RIGHT count by columns, | 998 | |
| 816 | all relative to 0, 0 at top left corner of frame. | 999 | The returned list has the form (LEFT TOP RIGHT BOTTOM). TOP and BOTTOM |
| 1000 | count by lines, and LEFT and RIGHT count by columns, all relative to 0, | ||
| 1001 | 0 at top left corner of frame. | ||
| 817 | 1002 | ||
| 818 | RIGHT is one more than the rightmost column of WINDOW's text area. | 1003 | RIGHT is one more than the rightmost column of WINDOW's text area. |
| 819 | BOTTOM is one more than the bottommost row of WINDOW's text area. | 1004 | BOTTOM is one more than the bottommost row of WINDOW's text area. The |
| 820 | The inside edges do not include the space used by the WINDOW's scroll | 1005 | inside edges do not include the space used by the WINDOW's scroll bar, |
| 821 | bar, display margins, fringes, header line, and/or mode line. */) | 1006 | display margins, fringes, header line, and/or mode line. */) |
| 822 | (Lisp_Object window) | 1007 | (Lisp_Object window) |
| 823 | { | 1008 | { |
| 824 | register struct window *w = decode_window (window); | 1009 | register struct window *w = decode_live_window (window); |
| 825 | 1010 | ||
| 826 | return list4 (make_number (WINDOW_BOX_LEFT_EDGE_COL (w) | 1011 | return list4i ((WINDOW_BOX_LEFT_EDGE_COL (w) |
| 827 | + WINDOW_LEFT_MARGIN_COLS (w) | 1012 | + WINDOW_LEFT_MARGIN_COLS (w) |
| 828 | + WINDOW_LEFT_FRINGE_COLS (w)), | 1013 | + WINDOW_LEFT_FRINGE_COLS (w)), |
| 829 | make_number (WINDOW_TOP_EDGE_LINE (w) | 1014 | (WINDOW_TOP_EDGE_LINE (w) |
| 830 | + WINDOW_HEADER_LINE_LINES (w)), | 1015 | + WINDOW_HEADER_LINE_LINES (w)), |
| 831 | make_number (WINDOW_BOX_RIGHT_EDGE_COL (w) | 1016 | (WINDOW_BOX_RIGHT_EDGE_COL (w) |
| 832 | - WINDOW_RIGHT_MARGIN_COLS (w) | 1017 | - WINDOW_RIGHT_MARGIN_COLS (w) |
| 833 | - WINDOW_RIGHT_FRINGE_COLS (w)), | 1018 | - WINDOW_RIGHT_FRINGE_COLS (w)), |
| 834 | make_number (WINDOW_BOTTOM_EDGE_LINE (w) | 1019 | (WINDOW_BOTTOM_EDGE_LINE (w) |
| 835 | - WINDOW_MODE_LINE_LINES (w))); | 1020 | - WINDOW_MODE_LINE_LINES (w))); |
| 836 | } | 1021 | } |
| 837 | 1022 | ||
| 838 | DEFUN ("window-inside-pixel-edges", Fwindow_inside_pixel_edges, Swindow_inside_pixel_edges, 0, 1, 0, | 1023 | DEFUN ("window-inside-pixel-edges", Fwindow_inside_pixel_edges, Swindow_inside_pixel_edges, 0, 1, 0, |
| 839 | doc: /* Return a list of the edge pixel coordinates of WINDOW's text area. | 1024 | doc: /* Return a list of the edge pixel coordinates of WINDOW's text area. |
| 840 | The list has the form (LEFT TOP RIGHT BOTTOM), all relative to (0,0) | 1025 | WINDOW must be a live window and defaults to the selected one. |
| 841 | at the top left corner of the frame's window area. | 1026 | |
| 1027 | The returned list has the form (LEFT TOP RIGHT BOTTOM), all relative to | ||
| 1028 | (0,0) at the top left corner of the frame's window area. | ||
| 842 | 1029 | ||
| 843 | RIGHT is one more than the rightmost x position of WINDOW's text area. | 1030 | RIGHT is one more than the rightmost x position of WINDOW's text area. |
| 844 | BOTTOM is one more than the bottommost y position of WINDOW's text area. | 1031 | BOTTOM is one more than the bottommost y position of WINDOW's text area. |
| @@ -846,26 +1033,28 @@ The inside edges do not include the space used by WINDOW's scroll bar, | |||
| 846 | display margins, fringes, header line, and/or mode line. */) | 1033 | display margins, fringes, header line, and/or mode line. */) |
| 847 | (Lisp_Object window) | 1034 | (Lisp_Object window) |
| 848 | { | 1035 | { |
| 849 | register struct window *w = decode_window (window); | 1036 | register struct window *w = decode_live_window (window); |
| 850 | 1037 | ||
| 851 | return list4 (make_number (WINDOW_BOX_LEFT_EDGE_X (w) | 1038 | return list4i ((WINDOW_BOX_LEFT_EDGE_X (w) |
| 852 | + WINDOW_LEFT_MARGIN_WIDTH (w) | 1039 | + WINDOW_LEFT_MARGIN_WIDTH (w) |
| 853 | + WINDOW_LEFT_FRINGE_WIDTH (w)), | 1040 | + WINDOW_LEFT_FRINGE_WIDTH (w)), |
| 854 | make_number (WINDOW_TOP_EDGE_Y (w) | 1041 | (WINDOW_TOP_EDGE_Y (w) |
| 855 | + WINDOW_HEADER_LINE_HEIGHT (w)), | 1042 | + WINDOW_HEADER_LINE_HEIGHT (w)), |
| 856 | make_number (WINDOW_BOX_RIGHT_EDGE_X (w) | 1043 | (WINDOW_BOX_RIGHT_EDGE_X (w) |
| 857 | - WINDOW_RIGHT_MARGIN_WIDTH (w) | 1044 | - WINDOW_RIGHT_MARGIN_WIDTH (w) |
| 858 | - WINDOW_RIGHT_FRINGE_WIDTH (w)), | 1045 | - WINDOW_RIGHT_FRINGE_WIDTH (w)), |
| 859 | make_number (WINDOW_BOTTOM_EDGE_Y (w) | 1046 | (WINDOW_BOTTOM_EDGE_Y (w) |
| 860 | - WINDOW_MODE_LINE_HEIGHT (w))); | 1047 | - WINDOW_MODE_LINE_HEIGHT (w))); |
| 861 | } | 1048 | } |
| 862 | 1049 | ||
| 863 | DEFUN ("window-inside-absolute-pixel-edges", | 1050 | DEFUN ("window-inside-absolute-pixel-edges", |
| 864 | Fwindow_inside_absolute_pixel_edges, | 1051 | Fwindow_inside_absolute_pixel_edges, |
| 865 | Swindow_inside_absolute_pixel_edges, 0, 1, 0, | 1052 | Swindow_inside_absolute_pixel_edges, 0, 1, 0, |
| 866 | doc: /* Return a list of the edge pixel coordinates of WINDOW's text area. | 1053 | doc: /* Return a list of the edge pixel coordinates of WINDOW's text area. |
| 867 | The list has the form (LEFT TOP RIGHT BOTTOM), all relative to (0,0) | 1054 | WINDOW must be a live window and defaults to the selected one. |
| 868 | at the top left corner of the frame's window area. | 1055 | |
| 1056 | The returned list has the form (LEFT TOP RIGHT BOTTOM), all relative to | ||
| 1057 | (0,0) at the top left corner of the frame's window area. | ||
| 869 | 1058 | ||
| 870 | RIGHT is one more than the rightmost x position of WINDOW's text area. | 1059 | RIGHT is one more than the rightmost x position of WINDOW's text area. |
| 871 | BOTTOM is one more than the bottommost y position of WINDOW's text area. | 1060 | BOTTOM is one more than the bottommost y position of WINDOW's text area. |
| @@ -873,20 +1062,21 @@ The inside edges do not include the space used by WINDOW's scroll bar, | |||
| 873 | display margins, fringes, header line, and/or mode line. */) | 1062 | display margins, fringes, header line, and/or mode line. */) |
| 874 | (Lisp_Object window) | 1063 | (Lisp_Object window) |
| 875 | { | 1064 | { |
| 876 | register struct window *w = decode_window (window); | 1065 | register struct window *w = decode_live_window (window); |
| 877 | int add_x, add_y; | 1066 | int add_x, add_y; |
| 1067 | |||
| 878 | calc_absolute_offset (w, &add_x, &add_y); | 1068 | calc_absolute_offset (w, &add_x, &add_y); |
| 879 | 1069 | ||
| 880 | return list4 (make_number (WINDOW_BOX_LEFT_EDGE_X (w) | 1070 | return list4i ((WINDOW_BOX_LEFT_EDGE_X (w) |
| 881 | + WINDOW_LEFT_MARGIN_WIDTH (w) | 1071 | + WINDOW_LEFT_MARGIN_WIDTH (w) |
| 882 | + WINDOW_LEFT_FRINGE_WIDTH (w) + add_x), | 1072 | + WINDOW_LEFT_FRINGE_WIDTH (w) + add_x), |
| 883 | make_number (WINDOW_TOP_EDGE_Y (w) | 1073 | (WINDOW_TOP_EDGE_Y (w) |
| 884 | + WINDOW_HEADER_LINE_HEIGHT (w) + add_y), | 1074 | + WINDOW_HEADER_LINE_HEIGHT (w) + add_y), |
| 885 | make_number (WINDOW_BOX_RIGHT_EDGE_X (w) | 1075 | (WINDOW_BOX_RIGHT_EDGE_X (w) |
| 886 | - WINDOW_RIGHT_MARGIN_WIDTH (w) | 1076 | - WINDOW_RIGHT_MARGIN_WIDTH (w) |
| 887 | - WINDOW_RIGHT_FRINGE_WIDTH (w) + add_x), | 1077 | - WINDOW_RIGHT_FRINGE_WIDTH (w) + add_x), |
| 888 | make_number (WINDOW_BOTTOM_EDGE_Y (w) | 1078 | (WINDOW_BOTTOM_EDGE_Y (w) |
| 889 | - WINDOW_MODE_LINE_HEIGHT (w) + add_y)); | 1079 | - WINDOW_MODE_LINE_HEIGHT (w) + add_y)); |
| 890 | } | 1080 | } |
| 891 | 1081 | ||
| 892 | /* Test if the character at column X, row Y is within window W. | 1082 | /* Test if the character at column X, row Y is within window W. |
| @@ -1052,7 +1242,7 @@ window_relative_x_coord (struct window *w, enum window_part part, int x) | |||
| 1052 | DEFUN ("coordinates-in-window-p", Fcoordinates_in_window_p, | 1242 | DEFUN ("coordinates-in-window-p", Fcoordinates_in_window_p, |
| 1053 | Scoordinates_in_window_p, 2, 2, 0, | 1243 | Scoordinates_in_window_p, 2, 2, 0, |
| 1054 | doc: /* Return non-nil if COORDINATES are in WINDOW. | 1244 | doc: /* Return non-nil if COORDINATES are in WINDOW. |
| 1055 | WINDOW must be a live window. | 1245 | WINDOW must be a live window and defaults to the selected one. |
| 1056 | COORDINATES is a cons of the form (X . Y), X and Y being distances | 1246 | COORDINATES is a cons of the form (X . Y), X and Y being distances |
| 1057 | measured in characters from the upper-left corner of the frame. | 1247 | measured in characters from the upper-left corner of the frame. |
| 1058 | \(0 . 0) denotes the character in the upper left corner of the | 1248 | \(0 . 0) denotes the character in the upper left corner of the |
| @@ -1074,8 +1264,7 @@ If they are in the windows's left or right marginal areas, `left-margin'\n\ | |||
| 1074 | int x, y; | 1264 | int x, y; |
| 1075 | Lisp_Object lx, ly; | 1265 | Lisp_Object lx, ly; |
| 1076 | 1266 | ||
| 1077 | CHECK_LIVE_WINDOW (window); | 1267 | w = decode_live_window (window); |
| 1078 | w = XWINDOW (window); | ||
| 1079 | f = XFRAME (w->frame); | 1268 | f = XFRAME (w->frame); |
| 1080 | CHECK_CONS (coordinates); | 1269 | CHECK_CONS (coordinates); |
| 1081 | lx = Fcar (coordinates); | 1270 | lx = Fcar (coordinates); |
| @@ -1124,7 +1313,7 @@ If they are in the windows's left or right marginal areas, `left-margin'\n\ | |||
| 1124 | return Qnil; | 1313 | return Qnil; |
| 1125 | 1314 | ||
| 1126 | default: | 1315 | default: |
| 1127 | abort (); | 1316 | emacs_abort (); |
| 1128 | } | 1317 | } |
| 1129 | } | 1318 | } |
| 1130 | 1319 | ||
| @@ -1148,7 +1337,7 @@ struct check_window_data | |||
| 1148 | static int | 1337 | static int |
| 1149 | check_window_containing (struct window *w, void *user_data) | 1338 | check_window_containing (struct window *w, void *user_data) |
| 1150 | { | 1339 | { |
| 1151 | struct check_window_data *cw = (struct check_window_data *) user_data; | 1340 | struct check_window_data *cw = user_data; |
| 1152 | enum window_part found; | 1341 | enum window_part found; |
| 1153 | int continue_p = 1; | 1342 | int continue_p = 1; |
| 1154 | 1343 | ||
| @@ -1184,7 +1373,7 @@ check_window_containing (struct window *w, void *user_data) | |||
| 1184 | 1373 | ||
| 1185 | Lisp_Object | 1374 | Lisp_Object |
| 1186 | window_from_coordinates (struct frame *f, int x, int y, | 1375 | window_from_coordinates (struct frame *f, int x, int y, |
| 1187 | enum window_part *part, int tool_bar_p) | 1376 | enum window_part *part, bool tool_bar_p) |
| 1188 | { | 1377 | { |
| 1189 | Lisp_Object window; | 1378 | Lisp_Object window; |
| 1190 | struct check_window_data cw; | 1379 | struct check_window_data cw; |
| @@ -1220,12 +1409,7 @@ The top left corner of the frame is considered to be row 0, | |||
| 1220 | column 0. */) | 1409 | column 0. */) |
| 1221 | (Lisp_Object x, Lisp_Object y, Lisp_Object frame) | 1410 | (Lisp_Object x, Lisp_Object y, Lisp_Object frame) |
| 1222 | { | 1411 | { |
| 1223 | struct frame *f; | 1412 | struct frame *f = decode_live_frame (frame); |
| 1224 | |||
| 1225 | if (NILP (frame)) | ||
| 1226 | frame = selected_frame; | ||
| 1227 | CHECK_LIVE_FRAME (frame); | ||
| 1228 | f = XFRAME (frame); | ||
| 1229 | 1413 | ||
| 1230 | /* Check that arguments are integers or floats. */ | 1414 | /* Check that arguments are integers or floats. */ |
| 1231 | CHECK_NUMBER_OR_FLOAT (x); | 1415 | CHECK_NUMBER_OR_FLOAT (x); |
| @@ -1243,22 +1427,21 @@ DEFUN ("window-point", Fwindow_point, Swindow_point, 0, 1, 0, | |||
| 1243 | doc: /* Return current value of point in WINDOW. | 1427 | doc: /* Return current value of point in WINDOW. |
| 1244 | WINDOW must be a live window and defaults to the selected one. | 1428 | WINDOW must be a live window and defaults to the selected one. |
| 1245 | 1429 | ||
| 1246 | For a nonselected window, this is the value point would have | 1430 | For a nonselected window, this is the value point would have if that |
| 1247 | if that window were selected. | 1431 | window were selected. |
| 1248 | 1432 | ||
| 1249 | Note that, when WINDOW is the selected window and its buffer | 1433 | Note that, when WINDOW is selected, the value returned is the same as |
| 1250 | is also currently selected, the value returned is the same as (point). | 1434 | that returned by `point' for WINDOW's buffer. It would be more strictly |
| 1251 | It would be more strictly correct to return the `top-level' value | 1435 | correct to return the top-level value of `point', outside of any |
| 1252 | of point, outside of any save-excursion forms. | 1436 | `save-excursion' forms. But that is hard to define. */) |
| 1253 | But that is hard to define. */) | ||
| 1254 | (Lisp_Object window) | 1437 | (Lisp_Object window) |
| 1255 | { | 1438 | { |
| 1256 | register struct window *w = decode_window (window); | 1439 | register struct window *w = decode_live_window (window); |
| 1257 | 1440 | ||
| 1258 | if (w == XWINDOW (selected_window) | 1441 | if (w == XWINDOW (selected_window)) |
| 1259 | && current_buffer == XBUFFER (w->buffer)) | 1442 | return make_number (BUF_PT (XBUFFER (w->contents))); |
| 1260 | return Fpoint (); | 1443 | else |
| 1261 | return Fmarker_position (w->pointm); | 1444 | return Fmarker_position (w->pointm); |
| 1262 | } | 1445 | } |
| 1263 | 1446 | ||
| 1264 | DEFUN ("window-start", Fwindow_start, Swindow_start, 0, 1, 0, | 1447 | DEFUN ("window-start", Fwindow_start, Swindow_start, 0, 1, 0, |
| @@ -1267,7 +1450,7 @@ WINDOW must be a live window and defaults to the selected one. | |||
| 1267 | This is updated by redisplay or by calling `set-window-start'. */) | 1450 | This is updated by redisplay or by calling `set-window-start'. */) |
| 1268 | (Lisp_Object window) | 1451 | (Lisp_Object window) |
| 1269 | { | 1452 | { |
| 1270 | return Fmarker_position (decode_window (window)->start); | 1453 | return Fmarker_position (decode_live_window (window)->start); |
| 1271 | } | 1454 | } |
| 1272 | 1455 | ||
| 1273 | /* This is text temporarily removed from the doc string below. | 1456 | /* This is text temporarily removed from the doc string below. |
| @@ -1294,27 +1477,20 @@ if it isn't already recorded. */) | |||
| 1294 | (Lisp_Object window, Lisp_Object update) | 1477 | (Lisp_Object window, Lisp_Object update) |
| 1295 | { | 1478 | { |
| 1296 | Lisp_Object value; | 1479 | Lisp_Object value; |
| 1297 | struct window *w = decode_window (window); | 1480 | struct window *w = decode_live_window (window); |
| 1298 | Lisp_Object buf; | 1481 | Lisp_Object buf; |
| 1299 | struct buffer *b; | 1482 | struct buffer *b; |
| 1300 | 1483 | ||
| 1301 | buf = w->buffer; | 1484 | buf = w->contents; |
| 1302 | CHECK_BUFFER (buf); | 1485 | CHECK_BUFFER (buf); |
| 1303 | b = XBUFFER (buf); | 1486 | b = XBUFFER (buf); |
| 1304 | 1487 | ||
| 1305 | #if 0 /* This change broke some things. We should make it later. */ | ||
| 1306 | /* If we don't know the end position, return nil. | ||
| 1307 | The user can compute it with vertical-motion if he wants to. | ||
| 1308 | It would be nicer to do it automatically, | ||
| 1309 | but that's so slow that it would probably bother people. */ | ||
| 1310 | if (NILP (w->window_end_valid)) | ||
| 1311 | return Qnil; | ||
| 1312 | #endif | ||
| 1313 | |||
| 1314 | if (! NILP (update) | 1488 | if (! NILP (update) |
| 1315 | && ! (! NILP (w->window_end_valid) | 1489 | && (windows_or_buffers_changed |
| 1316 | && XFASTINT (w->last_modified) >= BUF_MODIFF (b) | 1490 | || !w->window_end_valid |
| 1317 | && XFASTINT (w->last_overlay_modified) >= BUF_OVERLAY_MODIFF (b)) | 1491 | || b->clip_changed |
| 1492 | || b->prevent_redisplay_optimizations_p | ||
| 1493 | || window_outdated (w)) | ||
| 1318 | && !noninteractive) | 1494 | && !noninteractive) |
| 1319 | { | 1495 | { |
| 1320 | struct text_pos startp; | 1496 | struct text_pos startp; |
| @@ -1335,12 +1511,7 @@ if it isn't already recorded. */) | |||
| 1335 | `-l' containing a call to `rmail' with subsequent other | 1511 | `-l' containing a call to `rmail' with subsequent other |
| 1336 | commands. At the end, W->start happened to be BEG, while | 1512 | commands. At the end, W->start happened to be BEG, while |
| 1337 | rmail had already narrowed the buffer. */ | 1513 | rmail had already narrowed the buffer. */ |
| 1338 | if (XMARKER (w->start)->charpos < BEGV) | 1514 | CLIP_TEXT_POS_FROM_MARKER (startp, w->start); |
| 1339 | SET_TEXT_POS (startp, BEGV, BEGV_BYTE); | ||
| 1340 | else if (XMARKER (w->start)->charpos > ZV) | ||
| 1341 | SET_TEXT_POS (startp, ZV, ZV_BYTE); | ||
| 1342 | else | ||
| 1343 | SET_TEXT_POS_FROM_MARKER (startp, w->start); | ||
| 1344 | 1515 | ||
| 1345 | itdata = bidi_shelve_cache (); | 1516 | itdata = bidi_shelve_cache (); |
| 1346 | start_display (&it, w, startp); | 1517 | start_display (&it, w, startp); |
| @@ -1354,52 +1525,64 @@ if it isn't already recorded. */) | |||
| 1354 | set_buffer_internal (old_buffer); | 1525 | set_buffer_internal (old_buffer); |
| 1355 | } | 1526 | } |
| 1356 | else | 1527 | else |
| 1357 | XSETINT (value, BUF_Z (b) - XFASTINT (w->window_end_pos)); | 1528 | XSETINT (value, BUF_Z (b) - w->window_end_pos); |
| 1358 | 1529 | ||
| 1359 | return value; | 1530 | return value; |
| 1360 | } | 1531 | } |
| 1361 | 1532 | ||
| 1362 | DEFUN ("set-window-point", Fset_window_point, Sset_window_point, 2, 2, 0, | 1533 | DEFUN ("set-window-point", Fset_window_point, Sset_window_point, 2, 2, 0, |
| 1363 | doc: /* Make point value in WINDOW be at position POS in WINDOW's buffer. | 1534 | doc: /* Make point value in WINDOW be at position POS in WINDOW's buffer. |
| 1535 | WINDOW must be a live window and defaults to the selected one. | ||
| 1364 | Return POS. */) | 1536 | Return POS. */) |
| 1365 | (Lisp_Object window, Lisp_Object pos) | 1537 | (Lisp_Object window, Lisp_Object pos) |
| 1366 | { | 1538 | { |
| 1367 | register struct window *w = decode_window (window); | 1539 | register struct window *w = decode_live_window (window); |
| 1368 | 1540 | ||
| 1369 | CHECK_NUMBER_COERCE_MARKER (pos); | 1541 | /* Type of POS is checked by Fgoto_char or set_marker_restricted ... */ |
| 1370 | if (w == XWINDOW (selected_window) | ||
| 1371 | && XBUFFER (w->buffer) == current_buffer) | ||
| 1372 | Fgoto_char (pos); | ||
| 1373 | else | ||
| 1374 | set_marker_restricted (w->pointm, pos, w->buffer); | ||
| 1375 | 1542 | ||
| 1376 | /* We have to make sure that redisplay updates the window to show | 1543 | if (w == XWINDOW (selected_window)) |
| 1377 | the new value of point. */ | 1544 | { |
| 1378 | if (!EQ (window, selected_window)) | 1545 | if (XBUFFER (w->contents) == current_buffer) |
| 1379 | ++windows_or_buffers_changed; | 1546 | Fgoto_char (pos); |
| 1547 | else | ||
| 1548 | { | ||
| 1549 | struct buffer *old_buffer = current_buffer; | ||
| 1550 | |||
| 1551 | /* ... but here we want to catch type error before buffer change. */ | ||
| 1552 | CHECK_NUMBER_COERCE_MARKER (pos); | ||
| 1553 | set_buffer_internal (XBUFFER (w->contents)); | ||
| 1554 | Fgoto_char (pos); | ||
| 1555 | set_buffer_internal (old_buffer); | ||
| 1556 | } | ||
| 1557 | } | ||
| 1558 | else | ||
| 1559 | { | ||
| 1560 | set_marker_restricted (w->pointm, pos, w->contents); | ||
| 1561 | /* We have to make sure that redisplay updates the window to show | ||
| 1562 | the new value of point. */ | ||
| 1563 | ++windows_or_buffers_changed; | ||
| 1564 | } | ||
| 1380 | 1565 | ||
| 1381 | return pos; | 1566 | return pos; |
| 1382 | } | 1567 | } |
| 1383 | 1568 | ||
| 1384 | DEFUN ("set-window-start", Fset_window_start, Sset_window_start, 2, 3, 0, | 1569 | DEFUN ("set-window-start", Fset_window_start, Sset_window_start, 2, 3, 0, |
| 1385 | doc: /* Make display in WINDOW start at position POS in WINDOW's buffer. | 1570 | doc: /* Make display in WINDOW start at position POS in WINDOW's buffer. |
| 1386 | If WINDOW is nil, the selected window is used. Return POS. | 1571 | WINDOW must be a live window and defaults to the selected one. Return |
| 1387 | Optional third arg NOFORCE non-nil inhibits next redisplay from | 1572 | POS. Optional third arg NOFORCE non-nil inhibits next redisplay from |
| 1388 | overriding motion of point in order to display at this exact start. */) | 1573 | overriding motion of point in order to display at this exact start. */) |
| 1389 | (Lisp_Object window, Lisp_Object pos, Lisp_Object noforce) | 1574 | (Lisp_Object window, Lisp_Object pos, Lisp_Object noforce) |
| 1390 | { | 1575 | { |
| 1391 | register struct window *w = decode_window (window); | 1576 | register struct window *w = decode_live_window (window); |
| 1392 | 1577 | ||
| 1393 | CHECK_NUMBER_COERCE_MARKER (pos); | 1578 | set_marker_restricted (w->start, pos, w->contents); |
| 1394 | set_marker_restricted (w->start, pos, w->buffer); | 1579 | /* This is not right, but much easier than doing what is right. */ |
| 1395 | /* this is not right, but much easier than doing what is right. */ | ||
| 1396 | w->start_at_line_beg = 0; | 1580 | w->start_at_line_beg = 0; |
| 1397 | if (NILP (noforce)) | 1581 | if (NILP (noforce)) |
| 1398 | w->force_start = 1; | 1582 | w->force_start = 1; |
| 1399 | w->update_mode_line = 1; | 1583 | w->update_mode_line = 1; |
| 1400 | XSETFASTINT (w->last_modified, 0); | 1584 | if (w != XWINDOW (selected_window)) |
| 1401 | XSETFASTINT (w->last_overlay_modified, 0); | 1585 | /* Enforce full redisplay. FIXME: make it more selective. */ |
| 1402 | if (!EQ (window, selected_window)) | ||
| 1403 | windows_or_buffers_changed++; | 1586 | windows_or_buffers_changed++; |
| 1404 | 1587 | ||
| 1405 | return pos; | 1588 | return pos; |
| @@ -1408,20 +1591,23 @@ overriding motion of point in order to display at this exact start. */) | |||
| 1408 | DEFUN ("pos-visible-in-window-p", Fpos_visible_in_window_p, | 1591 | DEFUN ("pos-visible-in-window-p", Fpos_visible_in_window_p, |
| 1409 | Spos_visible_in_window_p, 0, 3, 0, | 1592 | Spos_visible_in_window_p, 0, 3, 0, |
| 1410 | doc: /* Return non-nil if position POS is currently on the frame in WINDOW. | 1593 | doc: /* Return non-nil if position POS is currently on the frame in WINDOW. |
| 1411 | Return nil if that position is scrolled vertically out of view. | 1594 | WINDOW must be a live window and defaults to the selected one. |
| 1412 | If a character is only partially visible, nil is returned, unless the | 1595 | |
| 1413 | optional argument PARTIALLY is non-nil. | 1596 | Return nil if that position is scrolled vertically out of view. If a |
| 1414 | If POS is only out of view because of horizontal scrolling, return non-nil. | 1597 | character is only partially visible, nil is returned, unless the |
| 1415 | If POS is t, it specifies the position of the last visible glyph in WINDOW. | 1598 | optional argument PARTIALLY is non-nil. If POS is only out of view |
| 1416 | POS defaults to point in WINDOW; WINDOW defaults to the selected window. | 1599 | because of horizontal scrolling, return non-nil. If POS is t, it |
| 1600 | specifies the position of the last visible glyph in WINDOW. POS | ||
| 1601 | defaults to point in WINDOW; WINDOW defaults to the selected window. | ||
| 1417 | 1602 | ||
| 1418 | If POS is visible, return t if PARTIALLY is nil; if PARTIALLY is non-nil, | 1603 | If POS is visible, return t if PARTIALLY is nil; if PARTIALLY is non-nil, |
| 1419 | return value is a list of 2 or 6 elements (X Y [RTOP RBOT ROWH VPOS]), | 1604 | the return value is a list of 2 or 6 elements (X Y [RTOP RBOT ROWH VPOS]), |
| 1420 | where X and Y are the pixel coordinates relative to the top left corner | 1605 | where X and Y are the pixel coordinates relative to the top left corner |
| 1421 | of the window. The remaining elements are omitted if the character after | 1606 | of the window. The remaining elements are omitted if the character after |
| 1422 | POS is fully visible; otherwise, RTOP and RBOT are the number of pixels | 1607 | POS is fully visible; otherwise, RTOP and RBOT are the number of pixels |
| 1423 | off-window at the top and bottom of the row, ROWH is the height of the | 1608 | off-window at the top and bottom of the screen line ("row") containing |
| 1424 | display row, and VPOS is the row number (0-based) containing POS. */) | 1609 | POS, ROWH is the visible height of that row, and VPOS is the row number |
| 1610 | \(zero-based). */) | ||
| 1425 | (Lisp_Object pos, Lisp_Object window, Lisp_Object partially) | 1611 | (Lisp_Object pos, Lisp_Object window, Lisp_Object partially) |
| 1426 | { | 1612 | { |
| 1427 | register struct window *w; | 1613 | register struct window *w; |
| @@ -1432,8 +1618,8 @@ display row, and VPOS is the row number (0-based) containing POS. */) | |||
| 1432 | int rtop, rbot, rowh, vpos, fully_p = 1; | 1618 | int rtop, rbot, rowh, vpos, fully_p = 1; |
| 1433 | int x, y; | 1619 | int x, y; |
| 1434 | 1620 | ||
| 1435 | w = decode_window (window); | 1621 | w = decode_live_window (window); |
| 1436 | buf = XBUFFER (w->buffer); | 1622 | buf = XBUFFER (w->contents); |
| 1437 | SET_TEXT_POS_FROM_MARKER (top, w->start); | 1623 | SET_TEXT_POS_FROM_MARKER (top, w->start); |
| 1438 | 1624 | ||
| 1439 | if (EQ (pos, Qt)) | 1625 | if (EQ (pos, Qt)) |
| @@ -1446,7 +1632,7 @@ display row, and VPOS is the row number (0-based) containing POS. */) | |||
| 1446 | else if (w == XWINDOW (selected_window)) | 1632 | else if (w == XWINDOW (selected_window)) |
| 1447 | posint = PT; | 1633 | posint = PT; |
| 1448 | else | 1634 | else |
| 1449 | posint = XMARKER (w->pointm)->charpos; | 1635 | posint = marker_position (w->pointm); |
| 1450 | 1636 | ||
| 1451 | /* If position is above window start or outside buffer boundaries, | 1637 | /* If position is above window start or outside buffer boundaries, |
| 1452 | or if window start is out of range, position is not visible. */ | 1638 | or if window start is out of range, position is not visible. */ |
| @@ -1462,8 +1648,7 @@ display row, and VPOS is the row number (0-based) containing POS. */) | |||
| 1462 | { | 1648 | { |
| 1463 | Lisp_Object part = Qnil; | 1649 | Lisp_Object part = Qnil; |
| 1464 | if (!fully_p) | 1650 | if (!fully_p) |
| 1465 | part = list4 (make_number (rtop), make_number (rbot), | 1651 | part = list4i (rtop, rbot, rowh, vpos); |
| 1466 | make_number (rowh), make_number (vpos)); | ||
| 1467 | in_window = Fcons (make_number (x), | 1652 | in_window = Fcons (make_number (x), |
| 1468 | Fcons (make_number (y), part)); | 1653 | Fcons (make_number (y), part)); |
| 1469 | } | 1654 | } |
| @@ -1474,7 +1659,7 @@ display row, and VPOS is the row number (0-based) containing POS. */) | |||
| 1474 | DEFUN ("window-line-height", Fwindow_line_height, | 1659 | DEFUN ("window-line-height", Fwindow_line_height, |
| 1475 | Swindow_line_height, 0, 2, 0, | 1660 | Swindow_line_height, 0, 2, 0, |
| 1476 | doc: /* Return height in pixels of text line LINE in window WINDOW. | 1661 | doc: /* Return height in pixels of text line LINE in window WINDOW. |
| 1477 | WINDOW defaults to the selected window. | 1662 | WINDOW must be a live window and defaults to the selected one. |
| 1478 | 1663 | ||
| 1479 | Return height of current line if LINE is omitted or nil. Return height of | 1664 | Return height of current line if LINE is omitted or nil. Return height of |
| 1480 | header or mode line if LINE is `header-line' or `mode-line'. | 1665 | header or mode line if LINE is `header-line' or `mode-line'. |
| @@ -1498,20 +1683,20 @@ Return nil if window display is not up-to-date. In that case, use | |||
| 1498 | int max_y, crop, i; | 1683 | int max_y, crop, i; |
| 1499 | EMACS_INT n; | 1684 | EMACS_INT n; |
| 1500 | 1685 | ||
| 1501 | w = decode_window (window); | 1686 | w = decode_live_window (window); |
| 1502 | 1687 | ||
| 1503 | if (noninteractive || w->pseudo_window_p) | 1688 | if (noninteractive || w->pseudo_window_p) |
| 1504 | return Qnil; | 1689 | return Qnil; |
| 1505 | 1690 | ||
| 1506 | CHECK_BUFFER (w->buffer); | 1691 | CHECK_BUFFER (w->contents); |
| 1507 | b = XBUFFER (w->buffer); | 1692 | b = XBUFFER (w->contents); |
| 1508 | 1693 | ||
| 1509 | /* Fail if current matrix is not up-to-date. */ | 1694 | /* Fail if current matrix is not up-to-date. */ |
| 1510 | if (NILP (w->window_end_valid) | 1695 | if (!w->window_end_valid |
| 1511 | || current_buffer->clip_changed | 1696 | || windows_or_buffers_changed |
| 1512 | || current_buffer->prevent_redisplay_optimizations_p | 1697 | || b->clip_changed |
| 1513 | || XFASTINT (w->last_modified) < BUF_MODIFF (b) | 1698 | || b->prevent_redisplay_optimizations_p |
| 1514 | || XFASTINT (w->last_overlay_modified) < BUF_OVERLAY_MODIFF (b)) | 1699 | || window_outdated (w)) |
| 1515 | return Qnil; | 1700 | return Qnil; |
| 1516 | 1701 | ||
| 1517 | if (NILP (line)) | 1702 | if (NILP (line)) |
| @@ -1529,23 +1714,19 @@ Return nil if window display is not up-to-date. In that case, use | |||
| 1529 | if (!WINDOW_WANTS_HEADER_LINE_P (w)) | 1714 | if (!WINDOW_WANTS_HEADER_LINE_P (w)) |
| 1530 | return Qnil; | 1715 | return Qnil; |
| 1531 | row = MATRIX_HEADER_LINE_ROW (w->current_matrix); | 1716 | row = MATRIX_HEADER_LINE_ROW (w->current_matrix); |
| 1532 | if (!row->enabled_p) | 1717 | return row->enabled_p ? list4i (row->height, 0, 0, 0) : Qnil; |
| 1533 | return Qnil; | ||
| 1534 | return list4 (make_number (row->height), | ||
| 1535 | make_number (0), make_number (0), | ||
| 1536 | make_number (0)); | ||
| 1537 | } | 1718 | } |
| 1538 | 1719 | ||
| 1539 | if (EQ (line, Qmode_line)) | 1720 | if (EQ (line, Qmode_line)) |
| 1540 | { | 1721 | { |
| 1541 | row = MATRIX_MODE_LINE_ROW (w->current_matrix); | 1722 | row = MATRIX_MODE_LINE_ROW (w->current_matrix); |
| 1542 | if (!row->enabled_p) | 1723 | return (row->enabled_p ? |
| 1543 | return Qnil; | 1724 | list4i (row->height, |
| 1544 | return list4 (make_number (row->height), | 1725 | 0, /* not accurate */ |
| 1545 | make_number (0), /* not accurate */ | 1726 | (WINDOW_HEADER_LINE_HEIGHT (w) |
| 1546 | make_number (WINDOW_HEADER_LINE_HEIGHT (w) | 1727 | + window_text_bottom_y (w)), |
| 1547 | + window_text_bottom_y (w)), | 1728 | 0) |
| 1548 | make_number (0)); | 1729 | : Qnil); |
| 1549 | } | 1730 | } |
| 1550 | 1731 | ||
| 1551 | CHECK_NUMBER (line); | 1732 | CHECK_NUMBER (line); |
| @@ -1574,10 +1755,7 @@ Return nil if window display is not up-to-date. In that case, use | |||
| 1574 | 1755 | ||
| 1575 | found_row: | 1756 | found_row: |
| 1576 | crop = max (0, (row->y + row->height) - max_y); | 1757 | crop = max (0, (row->y + row->height) - max_y); |
| 1577 | return list4 (make_number (row->height + min (0, row->y) - crop), | 1758 | return list4i (row->height + min (0, row->y) - crop, i, row->y, crop); |
| 1578 | make_number (i), | ||
| 1579 | make_number (row->y), | ||
| 1580 | make_number (crop)); | ||
| 1581 | } | 1759 | } |
| 1582 | 1760 | ||
| 1583 | DEFUN ("window-dedicated-p", Fwindow_dedicated_p, Swindow_dedicated_p, | 1761 | DEFUN ("window-dedicated-p", Fwindow_dedicated_p, Swindow_dedicated_p, |
| @@ -1586,8 +1764,8 @@ DEFUN ("window-dedicated-p", Fwindow_dedicated_p, Swindow_dedicated_p, | |||
| 1586 | More precisely, return the value assigned by the last call of | 1764 | More precisely, return the value assigned by the last call of |
| 1587 | `set-window-dedicated-p' for WINDOW. Return nil if that function was | 1765 | `set-window-dedicated-p' for WINDOW. Return nil if that function was |
| 1588 | never called with WINDOW as its argument, or the value set by that | 1766 | never called with WINDOW as its argument, or the value set by that |
| 1589 | function was internally reset since its last call. WINDOW defaults to | 1767 | function was internally reset since its last call. WINDOW must be a |
| 1590 | the selected window. | 1768 | live window and defaults to the selected one. |
| 1591 | 1769 | ||
| 1592 | When a window is dedicated to its buffer, `display-buffer' will refrain | 1770 | When a window is dedicated to its buffer, `display-buffer' will refrain |
| 1593 | from displaying another buffer in it. `get-lru-window' and | 1771 | from displaying another buffer in it. `get-lru-window' and |
| @@ -1600,7 +1778,7 @@ window, unless that window is "strongly" dedicated to its buffer, that | |||
| 1600 | is the value returned by `window-dedicated-p' is t. */) | 1778 | is the value returned by `window-dedicated-p' is t. */) |
| 1601 | (Lisp_Object window) | 1779 | (Lisp_Object window) |
| 1602 | { | 1780 | { |
| 1603 | return decode_window (window)->dedicated; | 1781 | return decode_live_window (window)->dedicated; |
| 1604 | } | 1782 | } |
| 1605 | 1783 | ||
| 1606 | DEFUN ("set-window-dedicated-p", Fset_window_dedicated_p, | 1784 | DEFUN ("set-window-dedicated-p", Fset_window_dedicated_p, |
| @@ -1624,10 +1802,8 @@ buffer. If and when `set-window-buffer' displays another buffer in a | |||
| 1624 | window, it also makes sure that the window is no more dedicated. */) | 1802 | window, it also makes sure that the window is no more dedicated. */) |
| 1625 | (Lisp_Object window, Lisp_Object flag) | 1803 | (Lisp_Object window, Lisp_Object flag) |
| 1626 | { | 1804 | { |
| 1627 | register struct window *w = decode_window (window); | 1805 | wset_dedicated (decode_live_window (window), flag); |
| 1628 | 1806 | return flag; | |
| 1629 | w->dedicated = flag; | ||
| 1630 | return w->dedicated; | ||
| 1631 | } | 1807 | } |
| 1632 | 1808 | ||
| 1633 | DEFUN ("window-prev-buffers", Fwindow_prev_buffers, Swindow_prev_buffers, | 1809 | DEFUN ("window-prev-buffers", Fwindow_prev_buffers, Swindow_prev_buffers, |
| @@ -1640,7 +1816,7 @@ where BUFFER is a buffer, WINDOW-START is the start position of the | |||
| 1640 | window for that buffer, and POS is a window-specific point value. */) | 1816 | window for that buffer, and POS is a window-specific point value. */) |
| 1641 | (Lisp_Object window) | 1817 | (Lisp_Object window) |
| 1642 | { | 1818 | { |
| 1643 | return decode_window (window)->prev_buffers; | 1819 | return decode_live_window (window)->prev_buffers; |
| 1644 | } | 1820 | } |
| 1645 | 1821 | ||
| 1646 | DEFUN ("set-window-prev-buffers", Fset_window_prev_buffers, | 1822 | DEFUN ("set-window-prev-buffers", Fset_window_prev_buffers, |
| @@ -1653,7 +1829,8 @@ where BUFFER is a buffer, WINDOW-START is the start position of the | |||
| 1653 | window for that buffer, and POS is a window-specific point value. */) | 1829 | window for that buffer, and POS is a window-specific point value. */) |
| 1654 | (Lisp_Object window, Lisp_Object prev_buffers) | 1830 | (Lisp_Object window, Lisp_Object prev_buffers) |
| 1655 | { | 1831 | { |
| 1656 | return decode_window (window)->prev_buffers = prev_buffers; | 1832 | wset_prev_buffers (decode_live_window (window), prev_buffers); |
| 1833 | return prev_buffers; | ||
| 1657 | } | 1834 | } |
| 1658 | 1835 | ||
| 1659 | DEFUN ("window-next-buffers", Fwindow_next_buffers, Swindow_next_buffers, | 1836 | DEFUN ("window-next-buffers", Fwindow_next_buffers, Swindow_next_buffers, |
| @@ -1662,7 +1839,7 @@ DEFUN ("window-next-buffers", Fwindow_next_buffers, Swindow_next_buffers, | |||
| 1662 | WINDOW must be a live window and defaults to the selected one. */) | 1839 | WINDOW must be a live window and defaults to the selected one. */) |
| 1663 | (Lisp_Object window) | 1840 | (Lisp_Object window) |
| 1664 | { | 1841 | { |
| 1665 | return decode_window (window)->next_buffers; | 1842 | return decode_live_window (window)->next_buffers; |
| 1666 | } | 1843 | } |
| 1667 | 1844 | ||
| 1668 | DEFUN ("set-window-next-buffers", Fset_window_next_buffers, | 1845 | DEFUN ("set-window-next-buffers", Fset_window_next_buffers, |
| @@ -1672,23 +1849,24 @@ WINDOW must be a live window and defaults to the selected one. | |||
| 1672 | NEXT-BUFFERS should be a list of buffers. */) | 1849 | NEXT-BUFFERS should be a list of buffers. */) |
| 1673 | (Lisp_Object window, Lisp_Object next_buffers) | 1850 | (Lisp_Object window, Lisp_Object next_buffers) |
| 1674 | { | 1851 | { |
| 1675 | return decode_window (window)->next_buffers = next_buffers; | 1852 | wset_next_buffers (decode_live_window (window), next_buffers); |
| 1853 | return next_buffers; | ||
| 1676 | } | 1854 | } |
| 1677 | 1855 | ||
| 1678 | DEFUN ("window-parameters", Fwindow_parameters, Swindow_parameters, | 1856 | DEFUN ("window-parameters", Fwindow_parameters, Swindow_parameters, |
| 1679 | 0, 1, 0, | 1857 | 0, 1, 0, |
| 1680 | doc: /* Return the parameters of WINDOW and their values. | 1858 | doc: /* Return the parameters of WINDOW and their values. |
| 1681 | WINDOW defaults to the selected window. The return value is a list of | 1859 | WINDOW must be a valid window and defaults to the selected one. The |
| 1682 | elements of the form (PARAMETER . VALUE). */) | 1860 | return value is a list of elements of the form (PARAMETER . VALUE). */) |
| 1683 | (Lisp_Object window) | 1861 | (Lisp_Object window) |
| 1684 | { | 1862 | { |
| 1685 | return Fcopy_alist (decode_any_window (window)->window_parameters); | 1863 | return Fcopy_alist (decode_valid_window (window)->window_parameters); |
| 1686 | } | 1864 | } |
| 1687 | 1865 | ||
| 1688 | DEFUN ("window-parameter", Fwindow_parameter, Swindow_parameter, | 1866 | DEFUN ("window-parameter", Fwindow_parameter, Swindow_parameter, |
| 1689 | 2, 2, 0, | 1867 | 2, 2, 0, |
| 1690 | doc: /* Return WINDOW's value for PARAMETER. | 1868 | doc: /* Return WINDOW's value for PARAMETER. |
| 1691 | WINDOW defaults to the selected window. */) | 1869 | WINDOW can be any window and defaults to the selected one. */) |
| 1692 | (Lisp_Object window, Lisp_Object parameter) | 1870 | (Lisp_Object window, Lisp_Object parameter) |
| 1693 | { | 1871 | { |
| 1694 | Lisp_Object result; | 1872 | Lisp_Object result; |
| @@ -1700,7 +1878,8 @@ WINDOW defaults to the selected window. */) | |||
| 1700 | DEFUN ("set-window-parameter", Fset_window_parameter, | 1878 | DEFUN ("set-window-parameter", Fset_window_parameter, |
| 1701 | Sset_window_parameter, 3, 3, 0, | 1879 | Sset_window_parameter, 3, 3, 0, |
| 1702 | doc: /* Set WINDOW's value of PARAMETER to VALUE. | 1880 | doc: /* Set WINDOW's value of PARAMETER to VALUE. |
| 1703 | WINDOW defaults to the selected window. Return VALUE. */) | 1881 | WINDOW can be any window and defaults to the selected one. |
| 1882 | Return VALUE. */) | ||
| 1704 | (Lisp_Object window, Lisp_Object parameter, Lisp_Object value) | 1883 | (Lisp_Object window, Lisp_Object parameter, Lisp_Object value) |
| 1705 | { | 1884 | { |
| 1706 | register struct window *w = decode_any_window (window); | 1885 | register struct window *w = decode_any_window (window); |
| @@ -1708,7 +1887,8 @@ WINDOW defaults to the selected window. Return VALUE. */) | |||
| 1708 | 1887 | ||
| 1709 | old_alist_elt = Fassq (parameter, w->window_parameters); | 1888 | old_alist_elt = Fassq (parameter, w->window_parameters); |
| 1710 | if (NILP (old_alist_elt)) | 1889 | if (NILP (old_alist_elt)) |
| 1711 | w->window_parameters = Fcons (Fcons (parameter, value), w->window_parameters); | 1890 | wset_window_parameters |
| 1891 | (w, Fcons (Fcons (parameter, value), w->window_parameters)); | ||
| 1712 | else | 1892 | else |
| 1713 | Fsetcdr (old_alist_elt, value); | 1893 | Fsetcdr (old_alist_elt, value); |
| 1714 | return value; | 1894 | return value; |
| @@ -1717,10 +1897,10 @@ WINDOW defaults to the selected window. Return VALUE. */) | |||
| 1717 | DEFUN ("window-display-table", Fwindow_display_table, Swindow_display_table, | 1897 | DEFUN ("window-display-table", Fwindow_display_table, Swindow_display_table, |
| 1718 | 0, 1, 0, | 1898 | 0, 1, 0, |
| 1719 | doc: /* Return the display-table that WINDOW is using. | 1899 | doc: /* Return the display-table that WINDOW is using. |
| 1720 | WINDOW defaults to the selected window. */) | 1900 | WINDOW must be a live window and defaults to the selected one. */) |
| 1721 | (Lisp_Object window) | 1901 | (Lisp_Object window) |
| 1722 | { | 1902 | { |
| 1723 | return decode_window (window)->display_table; | 1903 | return decode_live_window (window)->display_table; |
| 1724 | } | 1904 | } |
| 1725 | 1905 | ||
| 1726 | /* Get the display table for use on window W. This is either W's | 1906 | /* Get the display table for use on window W. This is either W's |
| @@ -1735,9 +1915,9 @@ window_display_table (struct window *w) | |||
| 1735 | 1915 | ||
| 1736 | if (DISP_TABLE_P (w->display_table)) | 1916 | if (DISP_TABLE_P (w->display_table)) |
| 1737 | dp = XCHAR_TABLE (w->display_table); | 1917 | dp = XCHAR_TABLE (w->display_table); |
| 1738 | else if (BUFFERP (w->buffer)) | 1918 | else if (BUFFERP (w->contents)) |
| 1739 | { | 1919 | { |
| 1740 | struct buffer *b = XBUFFER (w->buffer); | 1920 | struct buffer *b = XBUFFER (w->contents); |
| 1741 | 1921 | ||
| 1742 | if (DISP_TABLE_P (BVAR (b, display_table))) | 1922 | if (DISP_TABLE_P (BVAR (b, display_table))) |
| 1743 | dp = XCHAR_TABLE (BVAR (b, display_table)); | 1923 | dp = XCHAR_TABLE (BVAR (b, display_table)); |
| @@ -1749,13 +1929,11 @@ window_display_table (struct window *w) | |||
| 1749 | } | 1929 | } |
| 1750 | 1930 | ||
| 1751 | DEFUN ("set-window-display-table", Fset_window_display_table, Sset_window_display_table, 2, 2, 0, | 1931 | DEFUN ("set-window-display-table", Fset_window_display_table, Sset_window_display_table, 2, 2, 0, |
| 1752 | doc: /* Set WINDOW's display-table to TABLE. */) | 1932 | doc: /* Set WINDOW's display-table to TABLE. |
| 1933 | WINDOW must be a live window and defaults to the selected one. */) | ||
| 1753 | (register Lisp_Object window, Lisp_Object table) | 1934 | (register Lisp_Object window, Lisp_Object table) |
| 1754 | { | 1935 | { |
| 1755 | register struct window *w; | 1936 | wset_display_table (decode_live_window (window), table); |
| 1756 | |||
| 1757 | w = decode_window (window); | ||
| 1758 | w->display_table = table; | ||
| 1759 | return table; | 1937 | return table; |
| 1760 | } | 1938 | } |
| 1761 | 1939 | ||
| @@ -1764,17 +1942,14 @@ DEFUN ("set-window-display-table", Fset_window_display_table, Sset_window_displa | |||
| 1764 | static void | 1942 | static void |
| 1765 | unshow_buffer (register struct window *w) | 1943 | unshow_buffer (register struct window *w) |
| 1766 | { | 1944 | { |
| 1767 | Lisp_Object buf; | 1945 | Lisp_Object buf = w->contents; |
| 1768 | struct buffer *b; | 1946 | struct buffer *b = XBUFFER (buf); |
| 1769 | 1947 | ||
| 1770 | buf = w->buffer; | 1948 | eassert (b == XMARKER (w->pointm)->buffer); |
| 1771 | b = XBUFFER (buf); | ||
| 1772 | if (b != XMARKER (w->pointm)->buffer) | ||
| 1773 | abort (); | ||
| 1774 | 1949 | ||
| 1775 | #if 0 | 1950 | #if 0 |
| 1776 | if (w == XWINDOW (selected_window) | 1951 | if (w == XWINDOW (selected_window) |
| 1777 | || ! EQ (buf, XWINDOW (selected_window)->buffer)) | 1952 | || ! EQ (buf, XWINDOW (selected_window)->contents)) |
| 1778 | /* Do this except when the selected window's buffer | 1953 | /* Do this except when the selected window's buffer |
| 1779 | is being removed from some other window. */ | 1954 | is being removed from some other window. */ |
| 1780 | #endif | 1955 | #endif |
| @@ -1790,14 +1965,17 @@ unshow_buffer (register struct window *w) | |||
| 1790 | /* Point in the selected window's buffer | 1965 | /* Point in the selected window's buffer |
| 1791 | is actually stored in that buffer, and the window's pointm isn't used. | 1966 | is actually stored in that buffer, and the window's pointm isn't used. |
| 1792 | So don't clobber point in that buffer. */ | 1967 | So don't clobber point in that buffer. */ |
| 1793 | if (! EQ (buf, XWINDOW (selected_window)->buffer) | 1968 | if (! EQ (buf, XWINDOW (selected_window)->contents) |
| 1969 | /* Don't clobber point in current buffer either (this could be | ||
| 1970 | useful in connection with bug#12208). | ||
| 1971 | && XBUFFER (buf) != current_buffer */ | ||
| 1794 | /* This line helps to fix Horsley's testbug.el bug. */ | 1972 | /* This line helps to fix Horsley's testbug.el bug. */ |
| 1795 | && !(WINDOWP (BVAR (b, last_selected_window)) | 1973 | && !(WINDOWP (BVAR (b, last_selected_window)) |
| 1796 | && w != XWINDOW (BVAR (b, last_selected_window)) | 1974 | && w != XWINDOW (BVAR (b, last_selected_window)) |
| 1797 | && EQ (buf, XWINDOW (BVAR (b, last_selected_window))->buffer))) | 1975 | && EQ (buf, XWINDOW (BVAR (b, last_selected_window))->contents))) |
| 1798 | temp_set_point_both (b, | 1976 | temp_set_point_both (b, |
| 1799 | clip_to_bounds (BUF_BEGV (b), | 1977 | clip_to_bounds (BUF_BEGV (b), |
| 1800 | XMARKER (w->pointm)->charpos, | 1978 | marker_position (w->pointm), |
| 1801 | BUF_ZV (b)), | 1979 | BUF_ZV (b)), |
| 1802 | clip_to_bounds (BUF_BEGV_BYTE (b), | 1980 | clip_to_bounds (BUF_BEGV_BYTE (b), |
| 1803 | marker_byte_position (w->pointm), | 1981 | marker_byte_position (w->pointm), |
| @@ -1805,7 +1983,7 @@ unshow_buffer (register struct window *w) | |||
| 1805 | 1983 | ||
| 1806 | if (WINDOWP (BVAR (b, last_selected_window)) | 1984 | if (WINDOWP (BVAR (b, last_selected_window)) |
| 1807 | && w == XWINDOW (BVAR (b, last_selected_window))) | 1985 | && w == XWINDOW (BVAR (b, last_selected_window))) |
| 1808 | BVAR (b, last_selected_window) = Qnil; | 1986 | bset_last_selected_window (b, Qnil); |
| 1809 | } | 1987 | } |
| 1810 | 1988 | ||
| 1811 | /* Put NEW into the window structure in place of OLD. SETFLAG zero | 1989 | /* Put NEW into the window structure in place of OLD. SETFLAG zero |
| @@ -1820,7 +1998,7 @@ replace_window (Lisp_Object old, Lisp_Object new, int setflag) | |||
| 1820 | /* If OLD is its frame's root window, then NEW is the new | 1998 | /* If OLD is its frame's root window, then NEW is the new |
| 1821 | root window for that frame. */ | 1999 | root window for that frame. */ |
| 1822 | if (EQ (old, FRAME_ROOT_WINDOW (XFRAME (o->frame)))) | 2000 | if (EQ (old, FRAME_ROOT_WINDOW (XFRAME (o->frame)))) |
| 1823 | FRAME_ROOT_WINDOW (XFRAME (o->frame)) = new; | 2001 | fset_root_window (XFRAME (o->frame), new); |
| 1824 | 2002 | ||
| 1825 | if (setflag) | 2003 | if (setflag) |
| 1826 | { | 2004 | { |
| @@ -1828,41 +2006,38 @@ replace_window (Lisp_Object old, Lisp_Object new, int setflag) | |||
| 1828 | n->top_line = o->top_line; | 2006 | n->top_line = o->top_line; |
| 1829 | n->total_cols = o->total_cols; | 2007 | n->total_cols = o->total_cols; |
| 1830 | n->total_lines = o->total_lines; | 2008 | n->total_lines = o->total_lines; |
| 1831 | n->normal_cols = o->normal_cols; | 2009 | wset_normal_cols (n, o->normal_cols); |
| 1832 | o->normal_cols = make_float (1.0); | 2010 | wset_normal_cols (o, make_float (1.0)); |
| 1833 | n->normal_lines = o->normal_lines; | 2011 | wset_normal_lines (n, o->normal_lines); |
| 1834 | o->normal_lines = make_float (1.0); | 2012 | wset_normal_lines (o, make_float (1.0)); |
| 1835 | n->desired_matrix = n->current_matrix = 0; | 2013 | n->desired_matrix = n->current_matrix = 0; |
| 1836 | n->vscroll = 0; | 2014 | n->vscroll = 0; |
| 1837 | memset (&n->cursor, 0, sizeof (n->cursor)); | 2015 | memset (&n->cursor, 0, sizeof (n->cursor)); |
| 1838 | memset (&n->last_cursor, 0, sizeof (n->last_cursor)); | ||
| 1839 | memset (&n->phys_cursor, 0, sizeof (n->phys_cursor)); | 2016 | memset (&n->phys_cursor, 0, sizeof (n->phys_cursor)); |
| 2017 | n->last_cursor_vpos = 0; | ||
| 1840 | n->phys_cursor_type = -1; | 2018 | n->phys_cursor_type = -1; |
| 1841 | n->phys_cursor_width = -1; | 2019 | n->phys_cursor_width = -1; |
| 1842 | n->must_be_updated_p = 0; | 2020 | n->must_be_updated_p = 0; |
| 1843 | n->pseudo_window_p = 0; | 2021 | n->pseudo_window_p = 0; |
| 1844 | XSETFASTINT (n->window_end_vpos, 0); | 2022 | n->window_end_vpos = 0; |
| 1845 | XSETFASTINT (n->window_end_pos, 0); | 2023 | n->window_end_pos = 0; |
| 1846 | n->window_end_valid = Qnil; | 2024 | n->window_end_valid = 0; |
| 1847 | n->frozen_window_start_p = 0; | ||
| 1848 | } | 2025 | } |
| 1849 | 2026 | ||
| 1850 | n->next = tem = o->next; | 2027 | tem = o->next; |
| 2028 | wset_next (n, tem); | ||
| 1851 | if (!NILP (tem)) | 2029 | if (!NILP (tem)) |
| 1852 | XWINDOW (tem)->prev = new; | 2030 | wset_prev (XWINDOW (tem), new); |
| 1853 | 2031 | ||
| 1854 | n->prev = tem = o->prev; | 2032 | tem = o->prev; |
| 2033 | wset_prev (n, tem); | ||
| 1855 | if (!NILP (tem)) | 2034 | if (!NILP (tem)) |
| 1856 | XWINDOW (tem)->next = new; | 2035 | wset_next (XWINDOW (tem), new); |
| 1857 | 2036 | ||
| 1858 | n->parent = tem = o->parent; | 2037 | tem = o->parent; |
| 1859 | if (!NILP (tem)) | 2038 | wset_parent (n, tem); |
| 1860 | { | 2039 | if (!NILP (tem) && EQ (XWINDOW (tem)->contents, old)) |
| 1861 | if (EQ (XWINDOW (tem)->vchild, old)) | 2040 | wset_combination (XWINDOW (tem), XWINDOW (tem)->horizontal, new); |
| 1862 | XWINDOW (tem)->vchild = new; | ||
| 1863 | if (EQ (XWINDOW (tem)->hchild, old)) | ||
| 1864 | XWINDOW (tem)->hchild = new; | ||
| 1865 | } | ||
| 1866 | } | 2041 | } |
| 1867 | 2042 | ||
| 1868 | /* If window WINDOW and its parent window are iso-combined, merge | 2043 | /* If window WINDOW and its parent window are iso-combined, merge |
| @@ -1874,54 +2049,51 @@ recombine_windows (Lisp_Object window) | |||
| 1874 | { | 2049 | { |
| 1875 | struct window *w, *p, *c; | 2050 | struct window *w, *p, *c; |
| 1876 | Lisp_Object parent, child; | 2051 | Lisp_Object parent, child; |
| 1877 | int horflag; | 2052 | bool horflag; |
| 1878 | 2053 | ||
| 1879 | w = XWINDOW (window); | 2054 | w = XWINDOW (window); |
| 1880 | parent = w->parent; | 2055 | parent = w->parent; |
| 1881 | if (!NILP (parent) && NILP (w->combination_limit)) | 2056 | if (!NILP (parent) && NILP (w->combination_limit)) |
| 1882 | { | 2057 | { |
| 1883 | p = XWINDOW (parent); | 2058 | p = XWINDOW (parent); |
| 1884 | if (((!NILP (p->vchild) && !NILP (w->vchild)) | 2059 | if (WINDOWP (p->contents) && WINDOWP (w->contents) |
| 1885 | || (!NILP (p->hchild) && !NILP (w->hchild)))) | 2060 | && p->horizontal == w->horizontal) |
| 1886 | /* WINDOW and PARENT are both either a vertical or a horizontal | 2061 | /* WINDOW and PARENT are both either a vertical or a horizontal |
| 1887 | combination. */ | 2062 | combination. */ |
| 1888 | { | 2063 | { |
| 1889 | horflag = NILP (w->vchild); | 2064 | horflag = WINDOW_HORIZONTAL_COMBINATION_P (w); |
| 1890 | child = horflag ? w->hchild : w->vchild; | 2065 | child = w->contents; |
| 1891 | c = XWINDOW (child); | 2066 | c = XWINDOW (child); |
| 1892 | 2067 | ||
| 1893 | /* Splice WINDOW's children into its parent's children and | 2068 | /* Splice WINDOW's children into its parent's children and |
| 1894 | assign new normal sizes. */ | 2069 | assign new normal sizes. */ |
| 1895 | if (NILP (w->prev)) | 2070 | if (NILP (w->prev)) |
| 1896 | if (horflag) | 2071 | wset_combination (p, horflag, child); |
| 1897 | p->hchild = child; | ||
| 1898 | else | ||
| 1899 | p->vchild = child; | ||
| 1900 | else | 2072 | else |
| 1901 | { | 2073 | { |
| 1902 | c->prev = w->prev; | 2074 | wset_prev (c, w->prev); |
| 1903 | XWINDOW (w->prev)->next = child; | 2075 | wset_next (XWINDOW (w->prev), child); |
| 1904 | } | 2076 | } |
| 1905 | 2077 | ||
| 1906 | while (c) | 2078 | while (c) |
| 1907 | { | 2079 | { |
| 1908 | c->parent = parent; | 2080 | wset_parent (c, parent); |
| 1909 | 2081 | ||
| 1910 | if (horflag) | 2082 | if (horflag) |
| 1911 | c->normal_cols | 2083 | wset_normal_cols (c, |
| 1912 | = make_float (XFLOATINT (c->total_cols) | 2084 | make_float ((double) c->total_cols |
| 1913 | / XFLOATINT (p->total_cols)); | 2085 | / (double) p->total_cols)); |
| 1914 | else | 2086 | else |
| 1915 | c->normal_lines | 2087 | wset_normal_lines (c, |
| 1916 | = make_float (XFLOATINT (c->total_lines) | 2088 | make_float ((double) c->total_lines |
| 1917 | / XFLOATINT (p->total_lines)); | 2089 | / (double) p->total_lines)); |
| 1918 | 2090 | ||
| 1919 | if (NILP (c->next)) | 2091 | if (NILP (c->next)) |
| 1920 | { | 2092 | { |
| 1921 | if (!NILP (w->next)) | 2093 | if (!NILP (w->next)) |
| 1922 | { | 2094 | { |
| 1923 | c->next = w->next; | 2095 | wset_next (c, w->next); |
| 1924 | XWINDOW (c->next)->prev = child; | 2096 | wset_prev (XWINDOW (c->next), child); |
| 1925 | } | 2097 | } |
| 1926 | 2098 | ||
| 1927 | c = 0; | 2099 | c = 0; |
| @@ -1934,7 +2106,7 @@ recombine_windows (Lisp_Object window) | |||
| 1934 | } | 2106 | } |
| 1935 | 2107 | ||
| 1936 | /* WINDOW can be deleted now. */ | 2108 | /* WINDOW can be deleted now. */ |
| 1937 | w->vchild = w->hchild = Qnil; | 2109 | wset_combination (w, 0, Qnil); |
| 1938 | } | 2110 | } |
| 1939 | } | 2111 | } |
| 1940 | } | 2112 | } |
| @@ -1958,7 +2130,7 @@ delete_deletable_window (Lisp_Object window) | |||
| 1958 | static int | 2130 | static int |
| 1959 | add_window_to_list (struct window *w, void *user_data) | 2131 | add_window_to_list (struct window *w, void *user_data) |
| 1960 | { | 2132 | { |
| 1961 | Lisp_Object *list = (Lisp_Object *) user_data; | 2133 | Lisp_Object *list = user_data; |
| 1962 | Lisp_Object window; | 2134 | Lisp_Object window; |
| 1963 | XSETWINDOW (window, w); | 2135 | XSETWINDOW (window, w); |
| 1964 | *list = Fcons (window, *list); | 2136 | *list = Fcons (window, *list); |
| @@ -1975,10 +2147,10 @@ window_list (void) | |||
| 1975 | { | 2147 | { |
| 1976 | if (!CONSP (Vwindow_list)) | 2148 | if (!CONSP (Vwindow_list)) |
| 1977 | { | 2149 | { |
| 1978 | Lisp_Object tail; | 2150 | Lisp_Object tail, frame; |
| 1979 | 2151 | ||
| 1980 | Vwindow_list = Qnil; | 2152 | Vwindow_list = Qnil; |
| 1981 | for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail)) | 2153 | FOR_EACH_FRAME (tail, frame) |
| 1982 | { | 2154 | { |
| 1983 | Lisp_Object args[2]; | 2155 | Lisp_Object args[2]; |
| 1984 | 2156 | ||
| @@ -1986,7 +2158,7 @@ window_list (void) | |||
| 1986 | new windows at the front of args[1], which means we | 2158 | new windows at the front of args[1], which means we |
| 1987 | have to reverse this list at the end. */ | 2159 | have to reverse this list at the end. */ |
| 1988 | args[1] = Qnil; | 2160 | args[1] = Qnil; |
| 1989 | foreach_window (XFRAME (XCAR (tail)), add_window_to_list, &args[1]); | 2161 | foreach_window (XFRAME (frame), add_window_to_list, &args[1]); |
| 1990 | args[0] = Vwindow_list; | 2162 | args[0] = Vwindow_list; |
| 1991 | args[1] = Fnreverse (args[1]); | 2163 | args[1] = Fnreverse (args[1]); |
| 1992 | Vwindow_list = Fnconc (2, args); | 2164 | Vwindow_list = Fnconc (2, args); |
| @@ -2013,14 +2185,15 @@ window_list (void) | |||
| 2013 | a window means search the frame that window belongs to, | 2185 | a window means search the frame that window belongs to, |
| 2014 | a frame means consider windows on that frame, only. */ | 2186 | a frame means consider windows on that frame, only. */ |
| 2015 | 2187 | ||
| 2016 | static int | 2188 | static bool |
| 2017 | candidate_window_p (Lisp_Object window, Lisp_Object owindow, Lisp_Object minibuf, Lisp_Object all_frames) | 2189 | candidate_window_p (Lisp_Object window, Lisp_Object owindow, |
| 2190 | Lisp_Object minibuf, Lisp_Object all_frames) | ||
| 2018 | { | 2191 | { |
| 2019 | struct window *w = XWINDOW (window); | 2192 | struct window *w = XWINDOW (window); |
| 2020 | struct frame *f = XFRAME (w->frame); | 2193 | struct frame *f = XFRAME (w->frame); |
| 2021 | int candidate_p = 1; | 2194 | bool candidate_p = 1; |
| 2022 | 2195 | ||
| 2023 | if (!BUFFERP (w->buffer)) | 2196 | if (!BUFFERP (w->contents)) |
| 2024 | candidate_p = 0; | 2197 | candidate_p = 0; |
| 2025 | else if (MINI_WINDOW_P (w) | 2198 | else if (MINI_WINDOW_P (w) |
| 2026 | && (EQ (minibuf, Qlambda) | 2199 | && (EQ (minibuf, Qlambda) |
| @@ -2034,12 +2207,11 @@ candidate_window_p (Lisp_Object window, Lisp_Object owindow, Lisp_Object minibuf | |||
| 2034 | candidate_p = 1; | 2207 | candidate_p = 1; |
| 2035 | else if (NILP (all_frames)) | 2208 | else if (NILP (all_frames)) |
| 2036 | { | 2209 | { |
| 2037 | xassert (WINDOWP (owindow)); | 2210 | eassert (WINDOWP (owindow)); |
| 2038 | candidate_p = EQ (w->frame, XWINDOW (owindow)->frame); | 2211 | candidate_p = EQ (w->frame, XWINDOW (owindow)->frame); |
| 2039 | } | 2212 | } |
| 2040 | else if (EQ (all_frames, Qvisible)) | 2213 | else if (EQ (all_frames, Qvisible)) |
| 2041 | { | 2214 | { |
| 2042 | FRAME_SAMPLE_VISIBILITY (f); | ||
| 2043 | candidate_p = FRAME_VISIBLE_P (f) | 2215 | candidate_p = FRAME_VISIBLE_P (f) |
| 2044 | && (FRAME_TERMINAL (XFRAME (w->frame)) | 2216 | && (FRAME_TERMINAL (XFRAME (w->frame)) |
| 2045 | == FRAME_TERMINAL (XFRAME (selected_frame))); | 2217 | == FRAME_TERMINAL (XFRAME (selected_frame))); |
| @@ -2047,7 +2219,6 @@ candidate_window_p (Lisp_Object window, Lisp_Object owindow, Lisp_Object minibuf | |||
| 2047 | } | 2219 | } |
| 2048 | else if (INTEGERP (all_frames) && XINT (all_frames) == 0) | 2220 | else if (INTEGERP (all_frames) && XINT (all_frames) == 0) |
| 2049 | { | 2221 | { |
| 2050 | FRAME_SAMPLE_VISIBILITY (f); | ||
| 2051 | candidate_p = (FRAME_VISIBLE_P (f) || FRAME_ICONIFIED_P (f) | 2222 | candidate_p = (FRAME_VISIBLE_P (f) || FRAME_ICONIFIED_P (f) |
| 2052 | #ifdef HAVE_X_WINDOWS | 2223 | #ifdef HAVE_X_WINDOWS |
| 2053 | /* Yuck!! If we've just created the frame and the | 2224 | /* Yuck!! If we've just created the frame and the |
| @@ -2081,11 +2252,9 @@ candidate_window_p (Lisp_Object window, Lisp_Object owindow, Lisp_Object minibuf | |||
| 2081 | static void | 2252 | static void |
| 2082 | decode_next_window_args (Lisp_Object *window, Lisp_Object *minibuf, Lisp_Object *all_frames) | 2253 | decode_next_window_args (Lisp_Object *window, Lisp_Object *minibuf, Lisp_Object *all_frames) |
| 2083 | { | 2254 | { |
| 2084 | if (NILP (*window)) | 2255 | struct window *w = decode_live_window (*window); |
| 2085 | *window = selected_window; | ||
| 2086 | else | ||
| 2087 | CHECK_LIVE_WINDOW (*window); | ||
| 2088 | 2256 | ||
| 2257 | XSETWINDOW (*window, w); | ||
| 2089 | /* MINIBUF nil may or may not include minibuffers. Decide if it | 2258 | /* MINIBUF nil may or may not include minibuffers. Decide if it |
| 2090 | does. */ | 2259 | does. */ |
| 2091 | if (NILP (*minibuf)) | 2260 | if (NILP (*minibuf)) |
| @@ -2099,9 +2268,10 @@ decode_next_window_args (Lisp_Object *window, Lisp_Object *minibuf, Lisp_Object | |||
| 2099 | 2268 | ||
| 2100 | /* ALL_FRAMES nil doesn't specify which frames to include. */ | 2269 | /* ALL_FRAMES nil doesn't specify which frames to include. */ |
| 2101 | if (NILP (*all_frames)) | 2270 | if (NILP (*all_frames)) |
| 2102 | *all_frames = (!EQ (*minibuf, Qlambda) | 2271 | *all_frames |
| 2103 | ? FRAME_MINIBUF_WINDOW (XFRAME (XWINDOW (*window)->frame)) | 2272 | = (!EQ (*minibuf, Qlambda) |
| 2104 | : Qnil); | 2273 | ? FRAME_MINIBUF_WINDOW (XFRAME (w->frame)) |
| 2274 | : Qnil); | ||
| 2105 | else if (EQ (*all_frames, Qvisible)) | 2275 | else if (EQ (*all_frames, Qvisible)) |
| 2106 | ; | 2276 | ; |
| 2107 | else if (EQ (*all_frames, make_number (0))) | 2277 | else if (EQ (*all_frames, make_number (0))) |
| @@ -2363,7 +2533,7 @@ enum window_loop | |||
| 2363 | GET_BUFFER_WINDOW, /* Arg is buffer */ | 2533 | GET_BUFFER_WINDOW, /* Arg is buffer */ |
| 2364 | REPLACE_BUFFER_IN_WINDOWS_SAFELY, /* Arg is buffer */ | 2534 | REPLACE_BUFFER_IN_WINDOWS_SAFELY, /* Arg is buffer */ |
| 2365 | REDISPLAY_BUFFER_WINDOWS, /* Arg is buffer */ | 2535 | REDISPLAY_BUFFER_WINDOWS, /* Arg is buffer */ |
| 2366 | CHECK_ALL_WINDOWS | 2536 | CHECK_ALL_WINDOWS /* Arg is ignored */ |
| 2367 | }; | 2537 | }; |
| 2368 | 2538 | ||
| 2369 | static Lisp_Object | 2539 | static Lisp_Object |
| @@ -2427,7 +2597,7 @@ window_loop (enum window_loop type, Lisp_Object obj, int mini, Lisp_Object frame | |||
| 2427 | switch (type) | 2597 | switch (type) |
| 2428 | { | 2598 | { |
| 2429 | case GET_BUFFER_WINDOW: | 2599 | case GET_BUFFER_WINDOW: |
| 2430 | if (EQ (w->buffer, obj) | 2600 | if (EQ (w->contents, obj) |
| 2431 | /* Don't find any minibuffer window except the one that | 2601 | /* Don't find any minibuffer window except the one that |
| 2432 | is currently in use. */ | 2602 | is currently in use. */ |
| 2433 | && (MINI_WINDOW_P (w) ? EQ (window, minibuf_window) : 1)) | 2603 | && (MINI_WINDOW_P (w) ? EQ (window, minibuf_window) : 1)) |
| @@ -2451,25 +2621,25 @@ window_loop (enum window_loop type, Lisp_Object obj, int mini, Lisp_Object frame | |||
| 2451 | case REPLACE_BUFFER_IN_WINDOWS_SAFELY: | 2621 | case REPLACE_BUFFER_IN_WINDOWS_SAFELY: |
| 2452 | /* We could simply check whether the buffer shown by window | 2622 | /* We could simply check whether the buffer shown by window |
| 2453 | is live, and show another buffer in case it isn't. */ | 2623 | is live, and show another buffer in case it isn't. */ |
| 2454 | if (EQ (w->buffer, obj)) | 2624 | if (EQ (w->contents, obj)) |
| 2455 | { | 2625 | { |
| 2456 | /* Undedicate WINDOW. */ | 2626 | /* Undedicate WINDOW. */ |
| 2457 | w->dedicated = Qnil; | 2627 | wset_dedicated (w, Qnil); |
| 2458 | /* Make WINDOW show the buffer returned by | 2628 | /* Make WINDOW show the buffer returned by |
| 2459 | other_buffer_safely, don't run any hooks. */ | 2629 | other_buffer_safely, don't run any hooks. */ |
| 2460 | set_window_buffer | 2630 | set_window_buffer |
| 2461 | (window, other_buffer_safely (w->buffer), 0, 0); | 2631 | (window, other_buffer_safely (w->contents), 0, 0); |
| 2462 | /* If WINDOW is the selected window, make its buffer | 2632 | /* If WINDOW is the selected window, make its buffer |
| 2463 | current. But do so only if the window shows the | 2633 | current. But do so only if the window shows the |
| 2464 | current buffer (Bug#6454). */ | 2634 | current buffer (Bug#6454). */ |
| 2465 | if (EQ (window, selected_window) | 2635 | if (EQ (window, selected_window) |
| 2466 | && XBUFFER (w->buffer) == current_buffer) | 2636 | && XBUFFER (w->contents) == current_buffer) |
| 2467 | Fset_buffer (w->buffer); | 2637 | Fset_buffer (w->contents); |
| 2468 | } | 2638 | } |
| 2469 | break; | 2639 | break; |
| 2470 | 2640 | ||
| 2471 | case REDISPLAY_BUFFER_WINDOWS: | 2641 | case REDISPLAY_BUFFER_WINDOWS: |
| 2472 | if (EQ (w->buffer, obj)) | 2642 | if (EQ (w->contents, obj)) |
| 2473 | { | 2643 | { |
| 2474 | mark_window_display_accurate (window, 0); | 2644 | mark_window_display_accurate (window, 0); |
| 2475 | w->update_mode_line = 1; | 2645 | w->update_mode_line = 1; |
| @@ -2479,11 +2649,20 @@ window_loop (enum window_loop type, Lisp_Object obj, int mini, Lisp_Object frame | |||
| 2479 | } | 2649 | } |
| 2480 | break; | 2650 | break; |
| 2481 | 2651 | ||
| 2482 | /* Check for a window that has a killed buffer. */ | 2652 | /* Check for a leaf window that has a killed buffer |
| 2653 | or broken markers. */ | ||
| 2483 | case CHECK_ALL_WINDOWS: | 2654 | case CHECK_ALL_WINDOWS: |
| 2484 | if (! NILP (w->buffer) | 2655 | if (BUFFERP (w->contents)) |
| 2485 | && NILP (BVAR (XBUFFER (w->buffer), name))) | 2656 | { |
| 2486 | abort (); | 2657 | struct buffer *b = XBUFFER (w->contents); |
| 2658 | |||
| 2659 | if (!BUFFER_LIVE_P (b)) | ||
| 2660 | emacs_abort (); | ||
| 2661 | if (!MARKERP (w->start) || XMARKER (w->start)->buffer != b) | ||
| 2662 | emacs_abort (); | ||
| 2663 | if (!MARKERP (w->pointm) || XMARKER (w->pointm)->buffer != b) | ||
| 2664 | emacs_abort (); | ||
| 2665 | } | ||
| 2487 | break; | 2666 | break; |
| 2488 | 2667 | ||
| 2489 | case WINDOW_LOOP_UNUSED: | 2668 | case WINDOW_LOOP_UNUSED: |
| @@ -2547,8 +2726,8 @@ resize_root_window (Lisp_Object window, Lisp_Object delta, Lisp_Object horizonta | |||
| 2547 | DEFUN ("delete-other-windows-internal", Fdelete_other_windows_internal, | 2726 | DEFUN ("delete-other-windows-internal", Fdelete_other_windows_internal, |
| 2548 | Sdelete_other_windows_internal, 0, 2, "", | 2727 | Sdelete_other_windows_internal, 0, 2, "", |
| 2549 | doc: /* Make WINDOW fill its frame. | 2728 | doc: /* Make WINDOW fill its frame. |
| 2550 | Only the frame WINDOW is on is affected. WINDOW may be any window and | 2729 | Only the frame WINDOW is on is affected. WINDOW must be a valid window |
| 2551 | defaults to the selected one. | 2730 | and defaults to the selected one. |
| 2552 | 2731 | ||
| 2553 | Optional argument ROOT, if non-nil, must specify an internal window such | 2732 | Optional argument ROOT, if non-nil, must specify an internal window such |
| 2554 | that WINDOW is in its window subtree. If this is the case, replace ROOT | 2733 | that WINDOW is in its window subtree. If this is the case, replace ROOT |
| @@ -2564,11 +2743,10 @@ window-start value is reasonable when this function is called. */) | |||
| 2564 | struct window *w, *r, *s; | 2743 | struct window *w, *r, *s; |
| 2565 | struct frame *f; | 2744 | struct frame *f; |
| 2566 | Lisp_Object sibling, pwindow, swindow IF_LINT (= Qnil), delta; | 2745 | Lisp_Object sibling, pwindow, swindow IF_LINT (= Qnil), delta; |
| 2567 | ptrdiff_t startpos IF_LINT (= 0); | 2746 | ptrdiff_t startpos IF_LINT (= 0), startbyte IF_LINT (= 0); |
| 2568 | int top IF_LINT (= 0), new_top, resize_failed; | 2747 | int top IF_LINT (= 0), new_top, resize_failed; |
| 2569 | Mouse_HLInfo *hlinfo; | ||
| 2570 | 2748 | ||
| 2571 | w = decode_any_window (window); | 2749 | w = decode_valid_window (window); |
| 2572 | XSETWINDOW (window, w); | 2750 | XSETWINDOW (window, w); |
| 2573 | f = XFRAME (w->frame); | 2751 | f = XFRAME (w->frame); |
| 2574 | 2752 | ||
| @@ -2581,7 +2759,7 @@ window-start value is reasonable when this function is called. */) | |||
| 2581 | else | 2759 | else |
| 2582 | /* ROOT must be an ancestor of WINDOW. */ | 2760 | /* ROOT must be an ancestor of WINDOW. */ |
| 2583 | { | 2761 | { |
| 2584 | r = decode_any_window (root); | 2762 | r = decode_valid_window (root); |
| 2585 | pwindow = XWINDOW (window)->parent; | 2763 | pwindow = XWINDOW (window)->parent; |
| 2586 | while (!NILP (pwindow)) | 2764 | while (!NILP (pwindow)) |
| 2587 | if (EQ (pwindow, root)) | 2765 | if (EQ (pwindow, root)) |
| @@ -2601,9 +2779,10 @@ window-start value is reasonable when this function is called. */) | |||
| 2601 | else if (MINI_WINDOW_P (w)) /* && top > 0) */ | 2779 | else if (MINI_WINDOW_P (w)) /* && top > 0) */ |
| 2602 | error ("Can't expand minibuffer to full frame"); | 2780 | error ("Can't expand minibuffer to full frame"); |
| 2603 | 2781 | ||
| 2604 | if (!NILP (w->buffer)) | 2782 | if (BUFFERP (w->contents)) |
| 2605 | { | 2783 | { |
| 2606 | startpos = marker_position (w->start); | 2784 | startpos = marker_position (w->start); |
| 2785 | startbyte = marker_byte_position (w->start); | ||
| 2607 | top = WINDOW_TOP_EDGE_LINE (w) | 2786 | top = WINDOW_TOP_EDGE_LINE (w) |
| 2608 | - FRAME_TOP_MARGIN (XFRAME (WINDOW_FRAME (w))); | 2787 | - FRAME_TOP_MARGIN (XFRAME (WINDOW_FRAME (w))); |
| 2609 | /* Make sure WINDOW is the frame's selected window. */ | 2788 | /* Make sure WINDOW is the frame's selected window. */ |
| @@ -2612,7 +2791,7 @@ window-start value is reasonable when this function is called. */) | |||
| 2612 | if (EQ (selected_frame, w->frame)) | 2791 | if (EQ (selected_frame, w->frame)) |
| 2613 | Fselect_window (window, Qnil); | 2792 | Fselect_window (window, Qnil); |
| 2614 | else | 2793 | else |
| 2615 | FRAME_SELECTED_WINDOW (f) = window; | 2794 | fset_selected_window (f, window); |
| 2616 | } | 2795 | } |
| 2617 | } | 2796 | } |
| 2618 | else | 2797 | else |
| @@ -2642,24 +2821,24 @@ window-start value is reasonable when this function is called. */) | |||
| 2642 | if (EQ (selected_frame, w->frame)) | 2821 | if (EQ (selected_frame, w->frame)) |
| 2643 | Fselect_window (swindow, Qnil); | 2822 | Fselect_window (swindow, Qnil); |
| 2644 | else | 2823 | else |
| 2645 | FRAME_SELECTED_WINDOW (f) = swindow; | 2824 | fset_selected_window (f, swindow); |
| 2646 | } | 2825 | } |
| 2647 | } | 2826 | } |
| 2648 | 2827 | ||
| 2649 | BLOCK_INPUT; | 2828 | block_input (); |
| 2650 | hlinfo = MOUSE_HL_INFO (f); | 2829 | if (!FRAME_INITIAL_P (f)) |
| 2651 | /* We are going to free the glyph matrices of WINDOW, and with that | ||
| 2652 | we might lose any information about glyph rows that have some of | ||
| 2653 | their glyphs highlighted in mouse face. (These rows are marked | ||
| 2654 | with a non-zero mouse_face_p flag.) If WINDOW indeed has some | ||
| 2655 | glyphs highlighted in mouse face, signal to frame's up-to-date | ||
| 2656 | hook that mouse highlight was overwritten, so that it will | ||
| 2657 | arrange for redisplaying the highlight. */ | ||
| 2658 | if (EQ (hlinfo->mouse_face_window, window)) | ||
| 2659 | { | 2830 | { |
| 2660 | hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1; | 2831 | Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f); |
| 2661 | hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1; | 2832 | |
| 2662 | hlinfo->mouse_face_window = Qnil; | 2833 | /* We are going to free the glyph matrices of WINDOW, and with |
| 2834 | that we might lose any information about glyph rows that have | ||
| 2835 | some of their glyphs highlighted in mouse face. (These rows | ||
| 2836 | are marked with a non-zero mouse_face_p flag.) If WINDOW | ||
| 2837 | indeed has some glyphs highlighted in mouse face, signal to | ||
| 2838 | frame's up-to-date hook that mouse highlight was overwritten, | ||
| 2839 | so that it will arrange for redisplaying the highlight. */ | ||
| 2840 | if (EQ (hlinfo->mouse_face_window, window)) | ||
| 2841 | reset_mouse_highlight (hlinfo); | ||
| 2663 | } | 2842 | } |
| 2664 | free_window_matrices (r); | 2843 | free_window_matrices (r); |
| 2665 | 2844 | ||
| @@ -2668,10 +2847,10 @@ window-start value is reasonable when this function is called. */) | |||
| 2668 | FRAME_WINDOW_SIZES_CHANGED (f) = 1; | 2847 | FRAME_WINDOW_SIZES_CHANGED (f) = 1; |
| 2669 | resize_failed = 0; | 2848 | resize_failed = 0; |
| 2670 | 2849 | ||
| 2671 | if (NILP (w->buffer)) | 2850 | if (!WINDOW_LEAF_P (w)) |
| 2672 | { | 2851 | { |
| 2673 | /* Resize child windows vertically. */ | 2852 | /* Resize child windows vertically. */ |
| 2674 | XSETINT (delta, XINT (r->total_lines) - XINT (w->total_lines)); | 2853 | XSETINT (delta, r->total_lines - w->total_lines); |
| 2675 | w->top_line = r->top_line; | 2854 | w->top_line = r->top_line; |
| 2676 | resize_root_window (window, delta, Qnil, Qnil); | 2855 | resize_root_window (window, delta, Qnil, Qnil); |
| 2677 | if (window_resize_check (w, 0)) | 2856 | if (window_resize_check (w, 0)) |
| @@ -2689,8 +2868,7 @@ window-start value is reasonable when this function is called. */) | |||
| 2689 | if (!resize_failed) | 2868 | if (!resize_failed) |
| 2690 | { | 2869 | { |
| 2691 | w->left_col = r->left_col; | 2870 | w->left_col = r->left_col; |
| 2692 | XSETINT (delta, XINT (r->total_cols) - XINT (w->total_cols)); | 2871 | XSETINT (delta, r->total_cols - w->total_cols); |
| 2693 | w->left_col = r->left_col; | ||
| 2694 | resize_root_window (window, delta, Qt, Qnil); | 2872 | resize_root_window (window, delta, Qt, Qnil); |
| 2695 | if (window_resize_check (w, 1)) | 2873 | if (window_resize_check (w, 1)) |
| 2696 | window_resize_apply (w, 1); | 2874 | window_resize_apply (w, 1); |
| @@ -2718,38 +2896,31 @@ window-start value is reasonable when this function is called. */) | |||
| 2718 | { | 2896 | { |
| 2719 | sibling = w->prev; | 2897 | sibling = w->prev; |
| 2720 | s = XWINDOW (sibling); | 2898 | s = XWINDOW (sibling); |
| 2721 | s->next = w->next; | 2899 | wset_next (s, w->next); |
| 2722 | if (!NILP (s->next)) | 2900 | if (!NILP (s->next)) |
| 2723 | XWINDOW (s->next)->prev = sibling; | 2901 | wset_prev (XWINDOW (s->next), sibling); |
| 2724 | } | 2902 | } |
| 2725 | else | 2903 | else |
| 2726 | /* Get SIBLING below (on the right of) WINDOW. */ | 2904 | /* Get SIBLING below (on the right of) WINDOW. */ |
| 2727 | { | 2905 | { |
| 2728 | sibling = w->next; | 2906 | sibling = w->next; |
| 2729 | s = XWINDOW (sibling); | 2907 | s = XWINDOW (sibling); |
| 2730 | s->prev = Qnil; | 2908 | wset_prev (s, Qnil); |
| 2731 | if (!NILP (XWINDOW (w->parent)->vchild)) | 2909 | wset_combination (XWINDOW (w->parent), |
| 2732 | XWINDOW (w->parent)->vchild = sibling; | 2910 | XWINDOW (w->parent)->horizontal, sibling); |
| 2733 | else | ||
| 2734 | XWINDOW (w->parent)->hchild = sibling; | ||
| 2735 | } | 2911 | } |
| 2736 | 2912 | ||
| 2737 | /* Delete ROOT and all child windows of ROOT. */ | 2913 | /* Delete ROOT and all child windows of ROOT. */ |
| 2738 | if (!NILP (r->vchild)) | 2914 | if (WINDOWP (r->contents)) |
| 2739 | { | ||
| 2740 | delete_all_child_windows (r->vchild); | ||
| 2741 | r->vchild = Qnil; | ||
| 2742 | } | ||
| 2743 | else if (!NILP (r->hchild)) | ||
| 2744 | { | 2915 | { |
| 2745 | delete_all_child_windows (r->hchild); | 2916 | delete_all_child_windows (r->contents); |
| 2746 | r->hchild = Qnil; | 2917 | wset_combination (r, 0, Qnil); |
| 2747 | } | 2918 | } |
| 2748 | 2919 | ||
| 2749 | replace_window (root, window, 1); | 2920 | replace_window (root, window, 1); |
| 2750 | 2921 | ||
| 2751 | /* This must become SWINDOW anyway ....... */ | 2922 | /* This must become SWINDOW anyway ....... */ |
| 2752 | if (!NILP (w->buffer) && !resize_failed) | 2923 | if (BUFFERP (w->contents) && !resize_failed) |
| 2753 | { | 2924 | { |
| 2754 | /* Try to minimize scrolling, by setting the window start to the | 2925 | /* Try to minimize scrolling, by setting the window start to the |
| 2755 | point will cause the text at the old window start to be at the | 2926 | point will cause the text at the old window start to be at the |
| @@ -2758,19 +2929,19 @@ window-start value is reasonable when this function is called. */) | |||
| 2758 | when the display is not current, due to typeahead). */ | 2929 | when the display is not current, due to typeahead). */ |
| 2759 | new_top = WINDOW_TOP_EDGE_LINE (w) - FRAME_TOP_MARGIN (XFRAME (WINDOW_FRAME (w))); | 2930 | new_top = WINDOW_TOP_EDGE_LINE (w) - FRAME_TOP_MARGIN (XFRAME (WINDOW_FRAME (w))); |
| 2760 | if (new_top != top | 2931 | if (new_top != top |
| 2761 | && startpos >= BUF_BEGV (XBUFFER (w->buffer)) | 2932 | && startpos >= BUF_BEGV (XBUFFER (w->contents)) |
| 2762 | && startpos <= BUF_ZV (XBUFFER (w->buffer))) | 2933 | && startpos <= BUF_ZV (XBUFFER (w->contents))) |
| 2763 | { | 2934 | { |
| 2764 | struct position pos; | 2935 | struct position pos; |
| 2765 | struct buffer *obuf = current_buffer; | 2936 | struct buffer *obuf = current_buffer; |
| 2766 | 2937 | ||
| 2767 | Fset_buffer (w->buffer); | 2938 | Fset_buffer (w->contents); |
| 2768 | /* This computation used to temporarily move point, but that | 2939 | /* This computation used to temporarily move point, but that |
| 2769 | can have unwanted side effects due to text properties. */ | 2940 | can have unwanted side effects due to text properties. */ |
| 2770 | pos = *vmotion (startpos, -top, w); | 2941 | pos = *vmotion (startpos, startbyte, -top, w); |
| 2771 | 2942 | ||
| 2772 | set_marker_both (w->start, w->buffer, pos.bufpos, pos.bytepos); | 2943 | set_marker_both (w->start, w->contents, pos.bufpos, pos.bytepos); |
| 2773 | w->window_end_valid = Qnil; | 2944 | w->window_end_valid = 0; |
| 2774 | w->start_at_line_beg = (pos.bytepos == BEGV_BYTE | 2945 | w->start_at_line_beg = (pos.bytepos == BEGV_BYTE |
| 2775 | || FETCH_BYTE (pos.bytepos - 1) == '\n'); | 2946 | || FETCH_BYTE (pos.bytepos - 1) == '\n'); |
| 2776 | /* We need to do this, so that the window-scroll-functions | 2947 | /* We need to do this, so that the window-scroll-functions |
| @@ -2782,7 +2953,7 @@ window-start value is reasonable when this function is called. */) | |||
| 2782 | } | 2953 | } |
| 2783 | 2954 | ||
| 2784 | adjust_glyphs (f); | 2955 | adjust_glyphs (f); |
| 2785 | UNBLOCK_INPUT; | 2956 | unblock_input (); |
| 2786 | 2957 | ||
| 2787 | run_window_configuration_change_hook (f); | 2958 | run_window_configuration_change_hook (f); |
| 2788 | 2959 | ||
| @@ -2796,27 +2967,29 @@ replace_buffer_in_windows (Lisp_Object buffer) | |||
| 2796 | call1 (Qreplace_buffer_in_windows, buffer); | 2967 | call1 (Qreplace_buffer_in_windows, buffer); |
| 2797 | } | 2968 | } |
| 2798 | 2969 | ||
| 2799 | 2970 | /* If BUFFER is shown in a window, safely replace it with some other | |
| 2800 | /* Safely replace BUFFER with some other buffer in all windows of all | 2971 | buffer in all windows of all frames, even those on other keyboards. */ |
| 2801 | frames, even those on other keyboards. */ | ||
| 2802 | 2972 | ||
| 2803 | void | 2973 | void |
| 2804 | replace_buffer_in_windows_safely (Lisp_Object buffer) | 2974 | replace_buffer_in_windows_safely (Lisp_Object buffer) |
| 2805 | { | 2975 | { |
| 2806 | Lisp_Object tail, frame; | 2976 | if (buffer_window_count (XBUFFER (buffer))) |
| 2977 | { | ||
| 2978 | Lisp_Object tail, frame; | ||
| 2807 | 2979 | ||
| 2808 | /* A single call to window_loop won't do the job because it only | 2980 | /* A single call to window_loop won't do the job because it only |
| 2809 | considers frames on the current keyboard. So loop manually over | 2981 | considers frames on the current keyboard. So loop manually over |
| 2810 | frames, and handle each one. */ | 2982 | frames, and handle each one. */ |
| 2811 | FOR_EACH_FRAME (tail, frame) | 2983 | FOR_EACH_FRAME (tail, frame) |
| 2812 | window_loop (REPLACE_BUFFER_IN_WINDOWS_SAFELY, buffer, 1, frame); | 2984 | window_loop (REPLACE_BUFFER_IN_WINDOWS_SAFELY, buffer, 1, frame); |
| 2985 | } | ||
| 2813 | } | 2986 | } |
| 2814 | 2987 | ||
| 2815 | /* If *ROWS or *COLS are too small a size for FRAME, set them to the | 2988 | /* If *ROWS or *COLS are too small a size for FRAME, set them to the |
| 2816 | minimum allowable size. */ | 2989 | minimum allowable size. */ |
| 2817 | 2990 | ||
| 2818 | void | 2991 | void |
| 2819 | check_frame_size (FRAME_PTR frame, int *rows, int *cols) | 2992 | check_frame_size (struct frame *frame, int *rows, int *cols) |
| 2820 | { | 2993 | { |
| 2821 | /* For height, we have to see: | 2994 | /* For height, we have to see: |
| 2822 | how many windows the frame has at minimum (one or two), | 2995 | how many windows the frame has at minimum (one or two), |
| @@ -2860,23 +3033,15 @@ adjust_window_margins (struct window *w) | |||
| 2860 | if (WINDOW_RIGHT_MARGIN_COLS (w) > 0) | 3033 | if (WINDOW_RIGHT_MARGIN_COLS (w) > 0) |
| 2861 | { | 3034 | { |
| 2862 | if (WINDOW_LEFT_MARGIN_COLS (w) > 0) | 3035 | if (WINDOW_LEFT_MARGIN_COLS (w) > 0) |
| 2863 | w->left_margin_cols = w->right_margin_cols | 3036 | w->left_margin_cols = w->right_margin_cols = margin_cols / 2; |
| 2864 | = make_number (margin_cols/2); | ||
| 2865 | else | 3037 | else |
| 2866 | w->right_margin_cols = make_number (margin_cols); | 3038 | w->right_margin_cols = margin_cols; |
| 2867 | } | 3039 | } |
| 2868 | else | 3040 | else |
| 2869 | w->left_margin_cols = make_number (margin_cols); | 3041 | w->left_margin_cols = margin_cols; |
| 2870 | return 1; | 3042 | return 1; |
| 2871 | } | 3043 | } |
| 2872 | 3044 | ||
| 2873 | static Lisp_Object Fset_window_margins (Lisp_Object, Lisp_Object, Lisp_Object); | ||
| 2874 | static Lisp_Object Fset_window_fringes (Lisp_Object, Lisp_Object, Lisp_Object, | ||
| 2875 | Lisp_Object); | ||
| 2876 | static Lisp_Object Fset_window_scroll_bars (Lisp_Object, Lisp_Object, | ||
| 2877 | Lisp_Object, Lisp_Object); | ||
| 2878 | static Lisp_Object Fset_window_vscroll (Lisp_Object, Lisp_Object, Lisp_Object); | ||
| 2879 | |||
| 2880 | /* The following three routines are needed for running a window's | 3045 | /* The following three routines are needed for running a window's |
| 2881 | configuration change hook. */ | 3046 | configuration change hook. */ |
| 2882 | static void | 3047 | static void |
| @@ -2887,18 +3052,18 @@ run_funs (Lisp_Object funs) | |||
| 2887 | call0 (XCAR (funs)); | 3052 | call0 (XCAR (funs)); |
| 2888 | } | 3053 | } |
| 2889 | 3054 | ||
| 2890 | static Lisp_Object | 3055 | static void |
| 2891 | select_window_norecord (Lisp_Object window) | 3056 | select_window_norecord (Lisp_Object window) |
| 2892 | { | 3057 | { |
| 2893 | return WINDOW_LIVE_P (window) | 3058 | if (WINDOW_LIVE_P (window)) |
| 2894 | ? Fselect_window (window, Qt) : selected_window; | 3059 | Fselect_window (window, Qt); |
| 2895 | } | 3060 | } |
| 2896 | 3061 | ||
| 2897 | static Lisp_Object | 3062 | static void |
| 2898 | select_frame_norecord (Lisp_Object frame) | 3063 | select_frame_norecord (Lisp_Object frame) |
| 2899 | { | 3064 | { |
| 2900 | return FRAME_LIVE_P (XFRAME (frame)) | 3065 | if (FRAME_LIVE_P (XFRAME (frame))) |
| 2901 | ? Fselect_frame (frame, Qt) : selected_frame; | 3066 | Fselect_frame (frame, Qt); |
| 2902 | } | 3067 | } |
| 2903 | 3068 | ||
| 2904 | void | 3069 | void |
| @@ -2915,13 +3080,13 @@ run_window_configuration_change_hook (struct frame *f) | |||
| 2915 | /* Use the right buffer. Matters when running the local hooks. */ | 3080 | /* Use the right buffer. Matters when running the local hooks. */ |
| 2916 | if (current_buffer != XBUFFER (Fwindow_buffer (Qnil))) | 3081 | if (current_buffer != XBUFFER (Fwindow_buffer (Qnil))) |
| 2917 | { | 3082 | { |
| 2918 | record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); | 3083 | record_unwind_current_buffer (); |
| 2919 | Fset_buffer (Fwindow_buffer (Qnil)); | 3084 | Fset_buffer (Fwindow_buffer (Qnil)); |
| 2920 | } | 3085 | } |
| 2921 | 3086 | ||
| 2922 | if (SELECTED_FRAME () != f) | 3087 | if (SELECTED_FRAME () != f) |
| 2923 | { | 3088 | { |
| 2924 | record_unwind_protect (select_frame_norecord, Fselected_frame ()); | 3089 | record_unwind_protect (select_frame_norecord, selected_frame); |
| 2925 | select_frame_norecord (frame); | 3090 | select_frame_norecord (frame); |
| 2926 | } | 3091 | } |
| 2927 | 3092 | ||
| @@ -2936,7 +3101,7 @@ run_window_configuration_change_hook (struct frame *f) | |||
| 2936 | buffer))) | 3101 | buffer))) |
| 2937 | { | 3102 | { |
| 2938 | ptrdiff_t inner_count = SPECPDL_INDEX (); | 3103 | ptrdiff_t inner_count = SPECPDL_INDEX (); |
| 2939 | record_unwind_protect (select_window_norecord, Fselected_window ()); | 3104 | record_unwind_protect (select_window_norecord, selected_window); |
| 2940 | select_window_norecord (window); | 3105 | select_window_norecord (window); |
| 2941 | run_funs (Fbuffer_local_value (Qwindow_configuration_change_hook, | 3106 | run_funs (Fbuffer_local_value (Qwindow_configuration_change_hook, |
| 2942 | buffer)); | 3107 | buffer)); |
| @@ -2950,12 +3115,12 @@ run_window_configuration_change_hook (struct frame *f) | |||
| 2950 | } | 3115 | } |
| 2951 | 3116 | ||
| 2952 | DEFUN ("run-window-configuration-change-hook", Frun_window_configuration_change_hook, | 3117 | DEFUN ("run-window-configuration-change-hook", Frun_window_configuration_change_hook, |
| 2953 | Srun_window_configuration_change_hook, 1, 1, 0, | 3118 | Srun_window_configuration_change_hook, 0, 1, 0, |
| 2954 | doc: /* Run `window-configuration-change-hook' for FRAME. */) | 3119 | doc: /* Run `window-configuration-change-hook' for FRAME. |
| 2955 | (Lisp_Object frame) | 3120 | If FRAME is omitted or nil, it defaults to the selected frame. */) |
| 3121 | (Lisp_Object frame) | ||
| 2956 | { | 3122 | { |
| 2957 | CHECK_LIVE_FRAME (frame); | 3123 | run_window_configuration_change_hook (decode_live_frame (frame)); |
| 2958 | run_window_configuration_change_hook (XFRAME (frame)); | ||
| 2959 | return Qnil; | 3124 | return Qnil; |
| 2960 | } | 3125 | } |
| 2961 | 3126 | ||
| @@ -2966,30 +3131,31 @@ DEFUN ("run-window-configuration-change-hook", Frun_window_configuration_change_ | |||
| 2966 | reset from the buffer's local settings. */ | 3131 | reset from the buffer's local settings. */ |
| 2967 | 3132 | ||
| 2968 | void | 3133 | void |
| 2969 | set_window_buffer (Lisp_Object window, Lisp_Object buffer, int run_hooks_p, int keep_margins_p) | 3134 | set_window_buffer (Lisp_Object window, Lisp_Object buffer, |
| 3135 | bool run_hooks_p, bool keep_margins_p) | ||
| 2970 | { | 3136 | { |
| 2971 | struct window *w = XWINDOW (window); | 3137 | struct window *w = XWINDOW (window); |
| 2972 | struct buffer *b = XBUFFER (buffer); | 3138 | struct buffer *b = XBUFFER (buffer); |
| 2973 | ptrdiff_t count = SPECPDL_INDEX (); | 3139 | ptrdiff_t count = SPECPDL_INDEX (); |
| 2974 | int samebuf = EQ (buffer, w->buffer); | 3140 | int samebuf = EQ (buffer, w->contents); |
| 2975 | 3141 | ||
| 2976 | w->buffer = buffer; | 3142 | wset_buffer (w, buffer); |
| 2977 | 3143 | ||
| 2978 | if (EQ (window, selected_window)) | 3144 | if (EQ (window, selected_window)) |
| 2979 | BVAR (b, last_selected_window) = window; | 3145 | bset_last_selected_window (b, window); |
| 2980 | 3146 | ||
| 2981 | /* Let redisplay errors through. */ | 3147 | /* Let redisplay errors through. */ |
| 2982 | b->display_error_modiff = 0; | 3148 | b->display_error_modiff = 0; |
| 2983 | 3149 | ||
| 2984 | /* Update time stamps of buffer display. */ | 3150 | /* Update time stamps of buffer display. */ |
| 2985 | if (INTEGERP (BVAR (b, display_count))) | 3151 | if (INTEGERP (BVAR (b, display_count))) |
| 2986 | XSETINT (BVAR (b, display_count), XINT (BVAR (b, display_count)) + 1); | 3152 | bset_display_count (b, make_number (XINT (BVAR (b, display_count)) + 1)); |
| 2987 | BVAR (b, display_time) = Fcurrent_time (); | 3153 | bset_display_time (b, Fcurrent_time ()); |
| 3154 | |||
| 3155 | w->window_end_pos = 0; | ||
| 3156 | w->window_end_vpos = 0; | ||
| 3157 | w->last_cursor_vpos = 0; | ||
| 2988 | 3158 | ||
| 2989 | XSETFASTINT (w->window_end_pos, 0); | ||
| 2990 | XSETFASTINT (w->window_end_vpos, 0); | ||
| 2991 | memset (&w->last_cursor, 0, sizeof w->last_cursor); | ||
| 2992 | w->window_end_valid = Qnil; | ||
| 2993 | if (!(keep_margins_p && samebuf)) | 3159 | if (!(keep_margins_p && samebuf)) |
| 2994 | { /* If we're not actually changing the buffer, don't reset hscroll and | 3160 | { /* If we're not actually changing the buffer, don't reset hscroll and |
| 2995 | vscroll. This case happens for example when called from | 3161 | vscroll. This case happens for example when called from |
| @@ -2999,7 +3165,7 @@ set_window_buffer (Lisp_Object window, Lisp_Object buffer, int run_hooks_p, int | |||
| 2999 | Resetting hscroll and vscroll here is problematic for things like | 3165 | Resetting hscroll and vscroll here is problematic for things like |
| 3000 | image-mode and doc-view-mode since it resets the image's position | 3166 | image-mode and doc-view-mode since it resets the image's position |
| 3001 | whenever we resize the frame. */ | 3167 | whenever we resize the frame. */ |
| 3002 | w->hscroll = w->min_hscroll = make_number (0); | 3168 | w->hscroll = w->min_hscroll = 0; |
| 3003 | w->vscroll = 0; | 3169 | w->vscroll = 0; |
| 3004 | set_marker_both (w->pointm, buffer, BUF_PT (b), BUF_PT_BYTE (b)); | 3170 | set_marker_both (w->pointm, buffer, BUF_PT (b), BUF_PT_BYTE (b)); |
| 3005 | set_marker_restricted (w->start, | 3171 | set_marker_restricted (w->start, |
| @@ -3007,8 +3173,6 @@ set_window_buffer (Lisp_Object window, Lisp_Object buffer, int run_hooks_p, int | |||
| 3007 | buffer); | 3173 | buffer); |
| 3008 | w->start_at_line_beg = 0; | 3174 | w->start_at_line_beg = 0; |
| 3009 | w->force_start = 0; | 3175 | w->force_start = 0; |
| 3010 | XSETFASTINT (w->last_modified, 0); | ||
| 3011 | XSETFASTINT (w->last_overlay_modified, 0); | ||
| 3012 | } | 3176 | } |
| 3013 | /* Maybe we could move this into the `if' but it's not obviously safe and | 3177 | /* Maybe we could move this into the `if' but it's not obviously safe and |
| 3014 | I doubt it's worth the trouble. */ | 3178 | I doubt it's worth the trouble. */ |
| @@ -3019,7 +3183,7 @@ set_window_buffer (Lisp_Object window, Lisp_Object buffer, int run_hooks_p, int | |||
| 3019 | because that might itself be a local variable. */ | 3183 | because that might itself be a local variable. */ |
| 3020 | if (window_initialized) | 3184 | if (window_initialized) |
| 3021 | { | 3185 | { |
| 3022 | record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); | 3186 | record_unwind_current_buffer (); |
| 3023 | Fset_buffer (buffer); | 3187 | Fset_buffer (buffer); |
| 3024 | } | 3188 | } |
| 3025 | 3189 | ||
| @@ -3028,27 +3192,14 @@ set_window_buffer (Lisp_Object window, Lisp_Object buffer, int run_hooks_p, int | |||
| 3028 | if (!keep_margins_p) | 3192 | if (!keep_margins_p) |
| 3029 | { | 3193 | { |
| 3030 | /* Set left and right marginal area width etc. from buffer. */ | 3194 | /* Set left and right marginal area width etc. from buffer. */ |
| 3031 | 3195 | set_window_fringes (w, BVAR (b, left_fringe_width), | |
| 3032 | /* This may call adjust_window_margins three times, so | 3196 | BVAR (b, right_fringe_width), |
| 3033 | temporarily disable window margins. */ | 3197 | BVAR (b, fringes_outside_margins)); |
| 3034 | Lisp_Object save_left = w->left_margin_cols; | 3198 | set_window_scroll_bars (w, BVAR (b, scroll_bar_width), |
| 3035 | Lisp_Object save_right = w->right_margin_cols; | 3199 | BVAR (b, vertical_scroll_bar_type), Qnil); |
| 3036 | 3200 | set_window_margins (w, BVAR (b, left_margin_cols), | |
| 3037 | w->left_margin_cols = w->right_margin_cols = Qnil; | 3201 | BVAR (b, right_margin_cols)); |
| 3038 | 3202 | apply_window_adjustment (w); | |
| 3039 | Fset_window_fringes (window, | ||
| 3040 | BVAR (b, left_fringe_width), BVAR (b, right_fringe_width), | ||
| 3041 | BVAR (b, fringes_outside_margins)); | ||
| 3042 | |||
| 3043 | Fset_window_scroll_bars (window, | ||
| 3044 | BVAR (b, scroll_bar_width), | ||
| 3045 | BVAR (b, vertical_scroll_bar_type), Qnil); | ||
| 3046 | |||
| 3047 | w->left_margin_cols = save_left; | ||
| 3048 | w->right_margin_cols = save_right; | ||
| 3049 | |||
| 3050 | Fset_window_margins (window, | ||
| 3051 | BVAR (b, left_margin_cols), BVAR (b, right_margin_cols)); | ||
| 3052 | } | 3203 | } |
| 3053 | 3204 | ||
| 3054 | if (run_hooks_p) | 3205 | if (run_hooks_p) |
| @@ -3064,7 +3215,7 @@ set_window_buffer (Lisp_Object window, Lisp_Object buffer, int run_hooks_p, int | |||
| 3064 | 3215 | ||
| 3065 | DEFUN ("set-window-buffer", Fset_window_buffer, Sset_window_buffer, 2, 3, 0, | 3216 | DEFUN ("set-window-buffer", Fset_window_buffer, Sset_window_buffer, 2, 3, 0, |
| 3066 | doc: /* Make WINDOW display BUFFER-OR-NAME as its contents. | 3217 | doc: /* Make WINDOW display BUFFER-OR-NAME as its contents. |
| 3067 | WINDOW has to be a live window and defaults to the selected one. | 3218 | WINDOW must be a live window and defaults to the selected one. |
| 3068 | BUFFER-OR-NAME must be a buffer or the name of an existing buffer. | 3219 | BUFFER-OR-NAME must be a buffer or the name of an existing buffer. |
| 3069 | 3220 | ||
| 3070 | Optional third argument KEEP-MARGINS non-nil means that WINDOW's current | 3221 | Optional third argument KEEP-MARGINS non-nil means that WINDOW's current |
| @@ -3081,19 +3232,18 @@ This function runs `window-scroll-functions' before running | |||
| 3081 | (register Lisp_Object window, Lisp_Object buffer_or_name, Lisp_Object keep_margins) | 3232 | (register Lisp_Object window, Lisp_Object buffer_or_name, Lisp_Object keep_margins) |
| 3082 | { | 3233 | { |
| 3083 | register Lisp_Object tem, buffer; | 3234 | register Lisp_Object tem, buffer; |
| 3084 | register struct window *w = decode_window (window); | 3235 | register struct window *w = decode_live_window (window); |
| 3085 | 3236 | ||
| 3086 | XSETWINDOW (window, w); | 3237 | XSETWINDOW (window, w); |
| 3087 | buffer = Fget_buffer (buffer_or_name); | 3238 | buffer = Fget_buffer (buffer_or_name); |
| 3088 | CHECK_BUFFER (buffer); | 3239 | CHECK_BUFFER (buffer); |
| 3089 | if (NILP (BVAR (XBUFFER (buffer), name))) | 3240 | if (!BUFFER_LIVE_P (XBUFFER (buffer))) |
| 3090 | error ("Attempt to display deleted buffer"); | 3241 | error ("Attempt to display deleted buffer"); |
| 3091 | 3242 | ||
| 3092 | tem = w->buffer; | 3243 | tem = w->contents; |
| 3093 | if (NILP (tem)) | 3244 | if (NILP (tem)) |
| 3094 | error ("Window is deleted"); | 3245 | error ("Window is deleted"); |
| 3095 | else if (!EQ (tem, Qt)) | 3246 | else |
| 3096 | /* w->buffer is t when the window is first being set up. */ | ||
| 3097 | { | 3247 | { |
| 3098 | if (!EQ (tem, buffer)) | 3248 | if (!EQ (tem, buffer)) |
| 3099 | { | 3249 | { |
| @@ -3104,7 +3254,7 @@ This function runs `window-scroll-functions' before running | |||
| 3104 | else | 3254 | else |
| 3105 | /* WINDOW is weakly dedicated to its buffer, reset | 3255 | /* WINDOW is weakly dedicated to its buffer, reset |
| 3106 | dedication. */ | 3256 | dedication. */ |
| 3107 | w->dedicated = Qnil; | 3257 | wset_dedicated (w, Qnil); |
| 3108 | 3258 | ||
| 3109 | call1 (Qrecord_window_buffer, window); | 3259 | call1 (Qrecord_window_buffer, window); |
| 3110 | } | 3260 | } |
| @@ -3143,19 +3293,19 @@ displaying that buffer. */) | |||
| 3143 | struct window *w = XWINDOW (object); | 3293 | struct window *w = XWINDOW (object); |
| 3144 | mark_window_display_accurate (object, 0); | 3294 | mark_window_display_accurate (object, 0); |
| 3145 | w->update_mode_line = 1; | 3295 | w->update_mode_line = 1; |
| 3146 | if (BUFFERP (w->buffer)) | 3296 | if (BUFFERP (w->contents)) |
| 3147 | XBUFFER (w->buffer)->prevent_redisplay_optimizations_p = 1; | 3297 | XBUFFER (w->contents)->prevent_redisplay_optimizations_p = 1; |
| 3148 | ++update_mode_lines; | 3298 | ++update_mode_lines; |
| 3149 | return Qt; | 3299 | return Qt; |
| 3150 | } | 3300 | } |
| 3151 | 3301 | ||
| 3152 | if (STRINGP (object)) | 3302 | if (STRINGP (object)) |
| 3153 | object = Fget_buffer (object); | 3303 | object = Fget_buffer (object); |
| 3154 | if (BUFFERP (object) && !NILP (BVAR (XBUFFER (object), name))) | 3304 | if (BUFFERP (object) && BUFFER_LIVE_P (XBUFFER (object)) |
| 3305 | && buffer_window_count (XBUFFER (object))) | ||
| 3155 | { | 3306 | { |
| 3156 | /* Walk all windows looking for buffer, and force update | 3307 | /* If buffer is live and shown in at least one window, find |
| 3157 | of each of those windows. */ | 3308 | all windows showing this buffer and force update of them. */ |
| 3158 | |||
| 3159 | object = window_loop (REDISPLAY_BUFFER_WINDOWS, object, 0, Qvisible); | 3309 | object = window_loop (REDISPLAY_BUFFER_WINDOWS, object, 0, Qvisible); |
| 3160 | return NILP (object) ? Qnil : Qt; | 3310 | return NILP (object) ? Qnil : Qt; |
| 3161 | } | 3311 | } |
| @@ -3166,7 +3316,7 @@ displaying that buffer. */) | |||
| 3166 | return Qnil; | 3316 | return Qnil; |
| 3167 | } | 3317 | } |
| 3168 | 3318 | ||
| 3169 | 3319 | /* Obsolete since 24.3. */ | |
| 3170 | void | 3320 | void |
| 3171 | temp_output_buffer_show (register Lisp_Object buf) | 3321 | temp_output_buffer_show (register Lisp_Object buf) |
| 3172 | { | 3322 | { |
| @@ -3174,7 +3324,7 @@ temp_output_buffer_show (register Lisp_Object buf) | |||
| 3174 | register Lisp_Object window; | 3324 | register Lisp_Object window; |
| 3175 | register struct window *w; | 3325 | register struct window *w; |
| 3176 | 3326 | ||
| 3177 | BVAR (XBUFFER (buf), directory) = BVAR (current_buffer, directory); | 3327 | bset_directory (XBUFFER (buf), BVAR (current_buffer, directory)); |
| 3178 | 3328 | ||
| 3179 | Fset_buffer (buf); | 3329 | Fset_buffer (buf); |
| 3180 | BUF_SAVE_MODIFF (XBUFFER (buf)) = MODIFF; | 3330 | BUF_SAVE_MODIFF (XBUFFER (buf)) = MODIFF; |
| @@ -3185,16 +3335,14 @@ temp_output_buffer_show (register Lisp_Object buf) | |||
| 3185 | 3335 | ||
| 3186 | if (!NILP (Vtemp_buffer_show_function)) | 3336 | if (!NILP (Vtemp_buffer_show_function)) |
| 3187 | call1 (Vtemp_buffer_show_function, buf); | 3337 | call1 (Vtemp_buffer_show_function, buf); |
| 3188 | else | 3338 | else if (WINDOW_LIVE_P (window = display_buffer (buf, Qnil, Qnil))) |
| 3189 | { | 3339 | { |
| 3190 | window = display_buffer (buf, Qnil, Qnil); | ||
| 3191 | |||
| 3192 | if (!EQ (XWINDOW (window)->frame, selected_frame)) | 3340 | if (!EQ (XWINDOW (window)->frame, selected_frame)) |
| 3193 | Fmake_frame_visible (WINDOW_FRAME (XWINDOW (window))); | 3341 | Fmake_frame_visible (WINDOW_FRAME (XWINDOW (window))); |
| 3194 | Vminibuf_scroll_window = window; | 3342 | Vminibuf_scroll_window = window; |
| 3195 | w = XWINDOW (window); | 3343 | w = XWINDOW (window); |
| 3196 | XSETFASTINT (w->hscroll, 0); | 3344 | w->hscroll = 0; |
| 3197 | XSETFASTINT (w->min_hscroll, 0); | 3345 | w->min_hscroll = 0; |
| 3198 | set_marker_restricted_both (w->start, buf, BEG, BEG); | 3346 | set_marker_restricted_both (w->start, buf, BEG, BEG); |
| 3199 | set_marker_restricted_both (w->pointm, buf, BEG, BEG); | 3347 | set_marker_restricted_both (w->pointm, buf, BEG, BEG); |
| 3200 | 3348 | ||
| @@ -3210,59 +3358,46 @@ temp_output_buffer_show (register Lisp_Object buf) | |||
| 3210 | Note: Both Fselect_window and select_window_norecord may | 3358 | Note: Both Fselect_window and select_window_norecord may |
| 3211 | set-buffer to the buffer displayed in the window, | 3359 | set-buffer to the buffer displayed in the window, |
| 3212 | so we need to save the current buffer. --stef */ | 3360 | so we need to save the current buffer. --stef */ |
| 3213 | record_unwind_protect (Fset_buffer, prev_buffer); | 3361 | record_unwind_protect (restore_buffer, prev_buffer); |
| 3214 | record_unwind_protect (select_window_norecord, prev_window); | 3362 | record_unwind_protect (select_window_norecord, prev_window); |
| 3215 | Fselect_window (window, Qt); | 3363 | Fselect_window (window, Qt); |
| 3216 | Fset_buffer (w->buffer); | 3364 | Fset_buffer (w->contents); |
| 3217 | Frun_hooks (1, &Qtemp_buffer_show_hook); | 3365 | Frun_hooks (1, &Qtemp_buffer_show_hook); |
| 3218 | unbind_to (count, Qnil); | 3366 | unbind_to (count, Qnil); |
| 3219 | } | 3367 | } |
| 3220 | } | 3368 | } |
| 3221 | } | 3369 | } |
| 3222 | |||
| 3223 | DEFUN ("internal-temp-output-buffer-show", | ||
| 3224 | Ftemp_output_buffer_show, Stemp_output_buffer_show, | ||
| 3225 | 1, 1, 0, | ||
| 3226 | doc: /* Internal function for `with-output-to-temp-buffer'. */) | ||
| 3227 | (Lisp_Object buf) | ||
| 3228 | { | ||
| 3229 | temp_output_buffer_show (buf); | ||
| 3230 | return Qnil; | ||
| 3231 | } | ||
| 3232 | 3370 | ||
| 3233 | /* Make new window, have it replace WINDOW in window-tree, and make | 3371 | /* Make new window, have it replace WINDOW in window-tree, and make |
| 3234 | WINDOW its only vertical child (HORFLAG 1 means make WINDOW its only | 3372 | WINDOW its only vertical child (HORFLAG 1 means make WINDOW its only |
| 3235 | horizontal child). */ | 3373 | horizontal child). */ |
| 3236 | static void | 3374 | static void |
| 3237 | make_parent_window (Lisp_Object window, int horflag) | 3375 | make_parent_window (Lisp_Object window, bool horflag) |
| 3238 | { | 3376 | { |
| 3239 | Lisp_Object parent; | 3377 | Lisp_Object parent; |
| 3240 | register struct window *o, *p; | 3378 | register struct window *o, *p; |
| 3241 | int i; | ||
| 3242 | 3379 | ||
| 3243 | o = XWINDOW (window); | 3380 | o = XWINDOW (window); |
| 3244 | p = allocate_window (); | 3381 | p = allocate_window (); |
| 3245 | for (i = 0; i < VECSIZE (struct window); ++i) | 3382 | memcpy ((char *) p + sizeof (struct vectorlike_header), |
| 3246 | ((struct Lisp_Vector *) p)->contents[i] | 3383 | (char *) o + sizeof (struct vectorlike_header), |
| 3247 | = ((struct Lisp_Vector *) o)->contents[i]; | 3384 | word_size * VECSIZE (struct window)); |
| 3385 | /* P's buffer slot may change from nil to a buffer... */ | ||
| 3386 | adjust_window_count (p, 1); | ||
| 3248 | XSETWINDOW (parent, p); | 3387 | XSETWINDOW (parent, p); |
| 3249 | 3388 | ||
| 3250 | ++sequence_number; | ||
| 3251 | XSETFASTINT (p->sequence_number, sequence_number); | ||
| 3252 | |||
| 3253 | replace_window (window, parent, 1); | 3389 | replace_window (window, parent, 1); |
| 3254 | 3390 | ||
| 3255 | o->next = Qnil; | 3391 | wset_next (o, Qnil); |
| 3256 | o->prev = Qnil; | 3392 | wset_prev (o, Qnil); |
| 3257 | o->parent = parent; | 3393 | wset_parent (o, parent); |
| 3258 | 3394 | /* ...but now P becomes an internal window. */ | |
| 3259 | p->hchild = horflag ? window : Qnil; | 3395 | wset_start (p, Qnil); |
| 3260 | p->vchild = horflag ? Qnil : window; | 3396 | wset_pointm (p, Qnil); |
| 3261 | p->start = Qnil; | 3397 | wset_buffer (p, Qnil); |
| 3262 | p->pointm = Qnil; | 3398 | wset_combination (p, horflag, window); |
| 3263 | p->buffer = Qnil; | 3399 | wset_combination_limit (p, Qnil); |
| 3264 | p->combination_limit = Qnil; | 3400 | wset_window_parameters (p, Qnil); |
| 3265 | p->window_parameters = Qnil; | ||
| 3266 | } | 3401 | } |
| 3267 | 3402 | ||
| 3268 | /* Make new window from scratch. */ | 3403 | /* Make new window from scratch. */ |
| @@ -3273,59 +3408,29 @@ make_window (void) | |||
| 3273 | register struct window *w; | 3408 | register struct window *w; |
| 3274 | 3409 | ||
| 3275 | w = allocate_window (); | 3410 | w = allocate_window (); |
| 3276 | /* Initialize all Lisp data. */ | 3411 | /* Initialize Lisp data. Note that allocate_window initializes all |
| 3277 | w->frame = Qnil; | 3412 | Lisp data to nil, so do it only for slots which should not be nil. */ |
| 3278 | w->mini = 0; | 3413 | wset_normal_lines (w, make_float (1.0)); |
| 3279 | w->next = w->prev = w->hchild = w->vchild = w->parent = Qnil; | 3414 | wset_normal_cols (w, make_float (1.0)); |
| 3280 | XSETFASTINT (w->left_col, 0); | 3415 | wset_new_total (w, make_number (0)); |
| 3281 | XSETFASTINT (w->top_line, 0); | 3416 | wset_new_normal (w, make_number (0)); |
| 3282 | XSETFASTINT (w->total_lines, 0); | 3417 | wset_start (w, Fmake_marker ()); |
| 3283 | XSETFASTINT (w->total_cols, 0); | 3418 | wset_pointm (w, Fmake_marker ()); |
| 3284 | w->normal_lines = make_float (1.0); | 3419 | wset_vertical_scroll_bar_type (w, Qt); |
| 3285 | w->normal_cols = make_float (1.0); | 3420 | /* These Lisp fields are marked specially so they're not set to nil by |
| 3286 | XSETFASTINT (w->new_total, 0); | 3421 | allocate_window. */ |
| 3287 | XSETFASTINT (w->new_normal, 0); | 3422 | wset_prev_buffers (w, Qnil); |
| 3288 | w->buffer = Qnil; | 3423 | wset_next_buffers (w, Qnil); |
| 3289 | w->start = Fmake_marker (); | 3424 | |
| 3290 | w->pointm = Fmake_marker (); | 3425 | /* Initialize non-Lisp data. Note that allocate_window zeroes out all |
| 3291 | w->force_start = w->optional_new_start = 0; | 3426 | non-Lisp data, so do it only for slots which should not be zero. */ |
| 3292 | XSETFASTINT (w->hscroll, 0); | ||
| 3293 | XSETFASTINT (w->min_hscroll, 0); | ||
| 3294 | XSETFASTINT (w->use_time, 0); | ||
| 3295 | ++sequence_number; | ||
| 3296 | XSETFASTINT (w->sequence_number, sequence_number); | ||
| 3297 | w->temslot = w->last_modified = w->last_overlay_modified = Qnil; | ||
| 3298 | XSETFASTINT (w->last_point, 0); | ||
| 3299 | w->last_had_star = 0; | ||
| 3300 | w->vertical_scroll_bar = Qnil; | ||
| 3301 | w->left_margin_cols = w->right_margin_cols = Qnil; | ||
| 3302 | w->left_fringe_width = w->right_fringe_width = Qnil; | ||
| 3303 | w->fringes_outside_margins = Qnil; | ||
| 3304 | w->scroll_bar_width = Qnil; | ||
| 3305 | w->vertical_scroll_bar_type = Qt; | ||
| 3306 | XSETFASTINT (w->window_end_pos, 0); | ||
| 3307 | XSETFASTINT (w->window_end_vpos, 0); | ||
| 3308 | w->window_end_valid = w->display_table = Qnil; | ||
| 3309 | w->update_mode_line = w->start_at_line_beg = 0; | ||
| 3310 | w->dedicated = Qnil; | ||
| 3311 | w->base_line_number = w->base_line_pos = w->region_showing = Qnil; | ||
| 3312 | w->column_number_displayed = w->redisplay_end_trigger = Qnil; | ||
| 3313 | w->combination_limit = w->window_parameters = Qnil; | ||
| 3314 | w->prev_buffers = w->next_buffers = Qnil; | ||
| 3315 | /* Initialize non-Lisp data. */ | ||
| 3316 | w->desired_matrix = w->current_matrix = 0; | ||
| 3317 | w->nrows_scale_factor = w->ncols_scale_factor = 1; | 3427 | w->nrows_scale_factor = w->ncols_scale_factor = 1; |
| 3318 | memset (&w->cursor, 0, sizeof (w->cursor)); | 3428 | w->left_fringe_width = w->right_fringe_width = -1; |
| 3319 | memset (&w->last_cursor, 0, sizeof (w->last_cursor)); | ||
| 3320 | memset (&w->phys_cursor, 0, sizeof (w->phys_cursor)); | ||
| 3321 | w->phys_cursor_type = -1; | 3429 | w->phys_cursor_type = -1; |
| 3322 | w->phys_cursor_width = -1; | 3430 | w->phys_cursor_width = -1; |
| 3323 | w->phys_cursor_on_p = 0; | 3431 | w->scroll_bar_width = -1; |
| 3324 | w->last_cursor_off_p = w->cursor_off_p = 0; | 3432 | w->column_number_displayed = -1; |
| 3325 | w->must_be_updated_p = 0; | 3433 | |
| 3326 | w->pseudo_window_p = 0; | ||
| 3327 | w->frozen_window_start_p = 0; | ||
| 3328 | w->vscroll = 0; | ||
| 3329 | /* Reset window_list. */ | 3434 | /* Reset window_list. */ |
| 3330 | Vwindow_list = Qnil; | 3435 | Vwindow_list = Qnil; |
| 3331 | /* Return window. */ | 3436 | /* Return window. */ |
| @@ -3335,6 +3440,7 @@ make_window (void) | |||
| 3335 | 3440 | ||
| 3336 | DEFUN ("set-window-new-total", Fset_window_new_total, Sset_window_new_total, 2, 3, 0, | 3441 | DEFUN ("set-window-new-total", Fset_window_new_total, Sset_window_new_total, 2, 3, 0, |
| 3337 | doc: /* Set new total size of WINDOW to SIZE. | 3442 | doc: /* Set new total size of WINDOW to SIZE. |
| 3443 | WINDOW must be a valid window and defaults to the selected one. | ||
| 3338 | Return SIZE. | 3444 | Return SIZE. |
| 3339 | 3445 | ||
| 3340 | Optional argument ADD non-nil means add SIZE to the new total size of | 3446 | Optional argument ADD non-nil means add SIZE to the new total size of |
| @@ -3343,28 +3449,27 @@ WINDOW and return the sum. | |||
| 3343 | Note: This function does not operate on any child windows of WINDOW. */) | 3449 | Note: This function does not operate on any child windows of WINDOW. */) |
| 3344 | (Lisp_Object window, Lisp_Object size, Lisp_Object add) | 3450 | (Lisp_Object window, Lisp_Object size, Lisp_Object add) |
| 3345 | { | 3451 | { |
| 3346 | struct window *w = decode_any_window (window); | 3452 | struct window *w = decode_valid_window (window); |
| 3347 | 3453 | ||
| 3348 | CHECK_NUMBER (size); | 3454 | CHECK_NUMBER (size); |
| 3349 | if (NILP (add)) | 3455 | if (NILP (add)) |
| 3350 | XSETINT (w->new_total, XINT (size)); | 3456 | wset_new_total (w, size); |
| 3351 | else | 3457 | else |
| 3352 | XSETINT (w->new_total, XINT (w->new_total) + XINT (size)); | 3458 | wset_new_total (w, make_number (XINT (w->new_total) + XINT (size))); |
| 3353 | 3459 | ||
| 3354 | return w->new_total; | 3460 | return w->new_total; |
| 3355 | } | 3461 | } |
| 3356 | 3462 | ||
| 3357 | DEFUN ("set-window-new-normal", Fset_window_new_normal, Sset_window_new_normal, 1, 2, 0, | 3463 | DEFUN ("set-window-new-normal", Fset_window_new_normal, Sset_window_new_normal, 1, 2, 0, |
| 3358 | doc: /* Set new normal size of WINDOW to SIZE. | 3464 | doc: /* Set new normal size of WINDOW to SIZE. |
| 3465 | WINDOW must be a valid window and defaults to the selected one. | ||
| 3359 | Return SIZE. | 3466 | Return SIZE. |
| 3360 | 3467 | ||
| 3361 | Note: This function does not operate on any child windows of WINDOW. */) | 3468 | Note: This function does not operate on any child windows of WINDOW. */) |
| 3362 | (Lisp_Object window, Lisp_Object size) | 3469 | (Lisp_Object window, Lisp_Object size) |
| 3363 | { | 3470 | { |
| 3364 | struct window *w = decode_any_window (window); | 3471 | wset_new_normal (decode_valid_window (window), size); |
| 3365 | 3472 | return size; | |
| 3366 | w->new_normal = size; | ||
| 3367 | return w->new_normal; | ||
| 3368 | } | 3473 | } |
| 3369 | 3474 | ||
| 3370 | /* Return 1 if setting w->total_lines (w->total_cols if HORFLAG is | 3475 | /* Return 1 if setting w->total_lines (w->total_cols if HORFLAG is |
| @@ -3375,14 +3480,14 @@ Note: This function does not operate on any child windows of WINDOW. */) | |||
| 3375 | `window-min-height' or `window-min-width'. It does check that window | 3480 | `window-min-height' or `window-min-width'. It does check that window |
| 3376 | sizes do not drop below one line (two columns). */ | 3481 | sizes do not drop below one line (two columns). */ |
| 3377 | static int | 3482 | static int |
| 3378 | window_resize_check (struct window *w, int horflag) | 3483 | window_resize_check (struct window *w, bool horflag) |
| 3379 | { | 3484 | { |
| 3380 | struct window *c; | 3485 | struct window *c; |
| 3381 | 3486 | ||
| 3382 | if (!NILP (w->vchild)) | 3487 | if (WINDOW_VERTICAL_COMBINATION_P (w)) |
| 3383 | /* W is a vertical combination. */ | 3488 | /* W is a vertical combination. */ |
| 3384 | { | 3489 | { |
| 3385 | c = XWINDOW (w->vchild); | 3490 | c = XWINDOW (w->contents); |
| 3386 | if (horflag) | 3491 | if (horflag) |
| 3387 | /* All child windows of W must have the same width as W. */ | 3492 | /* All child windows of W must have the same width as W. */ |
| 3388 | { | 3493 | { |
| @@ -3410,10 +3515,10 @@ window_resize_check (struct window *w, int horflag) | |||
| 3410 | return (sum_of_sizes == XINT (w->new_total)); | 3515 | return (sum_of_sizes == XINT (w->new_total)); |
| 3411 | } | 3516 | } |
| 3412 | } | 3517 | } |
| 3413 | else if (!NILP (w->hchild)) | 3518 | else if (WINDOW_HORIZONTAL_COMBINATION_P (w)) |
| 3414 | /* W is a horizontal combination. */ | 3519 | /* W is a horizontal combination. */ |
| 3415 | { | 3520 | { |
| 3416 | c = XWINDOW (w->hchild); | 3521 | c = XWINDOW (w->contents); |
| 3417 | if (horflag) | 3522 | if (horflag) |
| 3418 | /* The sum of the widths of the child windows of W must equal W's | 3523 | /* The sum of the widths of the child windows of W must equal W's |
| 3419 | width. */ | 3524 | width. */ |
| @@ -3456,7 +3561,7 @@ window_resize_check (struct window *w, int horflag) | |||
| 3456 | This function does not perform any error checks. Make sure you have | 3561 | This function does not perform any error checks. Make sure you have |
| 3457 | run window_resize_check on W before applying this function. */ | 3562 | run window_resize_check on W before applying this function. */ |
| 3458 | static void | 3563 | static void |
| 3459 | window_resize_apply (struct window *w, int horflag) | 3564 | window_resize_apply (struct window *w, bool horflag) |
| 3460 | { | 3565 | { |
| 3461 | struct window *c; | 3566 | struct window *c; |
| 3462 | int pos; | 3567 | int pos; |
| @@ -3465,64 +3570,62 @@ window_resize_apply (struct window *w, int horflag) | |||
| 3465 | parent window has been set *before*. */ | 3570 | parent window has been set *before*. */ |
| 3466 | if (horflag) | 3571 | if (horflag) |
| 3467 | { | 3572 | { |
| 3468 | w->total_cols = w->new_total; | 3573 | w->total_cols = XFASTINT (w->new_total); |
| 3469 | if (NUMBERP (w->new_normal)) | 3574 | if (NUMBERP (w->new_normal)) |
| 3470 | w->normal_cols = w->new_normal; | 3575 | wset_normal_cols (w, w->new_normal); |
| 3471 | 3576 | ||
| 3472 | pos = XINT (w->left_col); | 3577 | pos = w->left_col; |
| 3473 | } | 3578 | } |
| 3474 | else | 3579 | else |
| 3475 | { | 3580 | { |
| 3476 | w->total_lines = w->new_total; | 3581 | w->total_lines = XFASTINT (w->new_total); |
| 3477 | if (NUMBERP (w->new_normal)) | 3582 | if (NUMBERP (w->new_normal)) |
| 3478 | w->normal_lines = w->new_normal; | 3583 | wset_normal_lines (w, w->new_normal); |
| 3479 | 3584 | ||
| 3480 | pos = XINT (w->top_line); | 3585 | pos = w->top_line; |
| 3481 | } | 3586 | } |
| 3482 | 3587 | ||
| 3483 | if (!NILP (w->vchild)) | 3588 | if (WINDOW_VERTICAL_COMBINATION_P (w)) |
| 3484 | /* W is a vertical combination. */ | 3589 | /* W is a vertical combination. */ |
| 3485 | { | 3590 | { |
| 3486 | c = XWINDOW (w->vchild); | 3591 | c = XWINDOW (w->contents); |
| 3487 | while (c) | 3592 | while (c) |
| 3488 | { | 3593 | { |
| 3489 | if (horflag) | 3594 | if (horflag) |
| 3490 | XSETFASTINT (c->left_col, pos); | 3595 | c->left_col = pos; |
| 3491 | else | 3596 | else |
| 3492 | XSETFASTINT (c->top_line, pos); | 3597 | c->top_line = pos; |
| 3493 | window_resize_apply (c, horflag); | 3598 | window_resize_apply (c, horflag); |
| 3494 | if (!horflag) | 3599 | if (!horflag) |
| 3495 | pos = pos + XINT (c->total_lines); | 3600 | pos = pos + c->total_lines; |
| 3496 | c = NILP (c->next) ? 0 : XWINDOW (c->next); | 3601 | c = NILP (c->next) ? 0 : XWINDOW (c->next); |
| 3497 | } | 3602 | } |
| 3498 | } | 3603 | } |
| 3499 | else if (!NILP (w->hchild)) | 3604 | else if (WINDOW_HORIZONTAL_COMBINATION_P (w)) |
| 3500 | /* W is a horizontal combination. */ | 3605 | /* W is a horizontal combination. */ |
| 3501 | { | 3606 | { |
| 3502 | c = XWINDOW (w->hchild); | 3607 | c = XWINDOW (w->contents); |
| 3503 | while (c) | 3608 | while (c) |
| 3504 | { | 3609 | { |
| 3505 | if (horflag) | 3610 | if (horflag) |
| 3506 | XSETFASTINT (c->left_col, pos); | 3611 | c->left_col = pos; |
| 3507 | else | 3612 | else |
| 3508 | XSETFASTINT (c->top_line, pos); | 3613 | c->top_line = pos; |
| 3509 | window_resize_apply (c, horflag); | 3614 | window_resize_apply (c, horflag); |
| 3510 | if (horflag) | 3615 | if (horflag) |
| 3511 | pos = pos + XINT (c->total_cols); | 3616 | pos = pos + c->total_cols; |
| 3512 | c = NILP (c->next) ? 0 : XWINDOW (c->next); | 3617 | c = NILP (c->next) ? 0 : XWINDOW (c->next); |
| 3513 | } | 3618 | } |
| 3514 | } | 3619 | } |
| 3515 | |||
| 3516 | /* Clear out some redisplay caches. */ | ||
| 3517 | XSETFASTINT (w->last_modified, 0); | ||
| 3518 | XSETFASTINT (w->last_overlay_modified, 0); | ||
| 3519 | } | 3620 | } |
| 3520 | 3621 | ||
| 3521 | 3622 | ||
| 3522 | DEFUN ("window-resize-apply", Fwindow_resize_apply, Swindow_resize_apply, 1, 2, 0, | 3623 | DEFUN ("window-resize-apply", Fwindow_resize_apply, Swindow_resize_apply, 0, 2, 0, |
| 3523 | doc: /* Apply requested size values for window-tree of FRAME. | 3624 | doc: /* Apply requested size values for window-tree of FRAME. |
| 3524 | Optional argument HORIZONTAL omitted or nil means apply requested height | 3625 | If FRAME is omitted or nil, it defaults to the selected frame. |
| 3525 | values. HORIZONTAL non-nil means apply requested width values. | 3626 | |
| 3627 | Optional argument HORIZONTAL omitted or nil means apply requested | ||
| 3628 | height values. HORIZONTAL non-nil means apply requested width values. | ||
| 3526 | 3629 | ||
| 3527 | This function checks whether the requested values sum up to a valid | 3630 | This function checks whether the requested values sum up to a valid |
| 3528 | window layout, recursively assigns the new sizes of all child windows | 3631 | window layout, recursively assigns the new sizes of all child windows |
| @@ -3533,29 +3636,23 @@ Note: This function does not check any of `window-fixed-size-p', | |||
| 3533 | be applied on the Elisp level. */) | 3636 | be applied on the Elisp level. */) |
| 3534 | (Lisp_Object frame, Lisp_Object horizontal) | 3637 | (Lisp_Object frame, Lisp_Object horizontal) |
| 3535 | { | 3638 | { |
| 3536 | struct frame *f; | 3639 | struct frame *f = decode_live_frame (frame); |
| 3537 | struct window *r; | 3640 | struct window *r = XWINDOW (FRAME_ROOT_WINDOW (f)); |
| 3538 | int horflag = !NILP (horizontal); | 3641 | bool horflag = !NILP (horizontal); |
| 3539 | |||
| 3540 | if (NILP (frame)) | ||
| 3541 | frame = selected_frame; | ||
| 3542 | CHECK_LIVE_FRAME (frame); | ||
| 3543 | |||
| 3544 | f = XFRAME (frame); | ||
| 3545 | r = XWINDOW (FRAME_ROOT_WINDOW (f)); | ||
| 3546 | 3642 | ||
| 3547 | if (!window_resize_check (r, horflag) | 3643 | if (!window_resize_check (r, horflag) |
| 3548 | || ! EQ (r->new_total, (horflag ? r->total_cols : r->total_lines))) | 3644 | || (XINT (r->new_total) |
| 3645 | != (horflag ? r->total_cols : r->total_lines))) | ||
| 3549 | return Qnil; | 3646 | return Qnil; |
| 3550 | 3647 | ||
| 3551 | BLOCK_INPUT; | 3648 | block_input (); |
| 3552 | window_resize_apply (r, horflag); | 3649 | window_resize_apply (r, horflag); |
| 3553 | 3650 | ||
| 3554 | windows_or_buffers_changed++; | 3651 | windows_or_buffers_changed++; |
| 3555 | FRAME_WINDOW_SIZES_CHANGED (f) = 1; | 3652 | FRAME_WINDOW_SIZES_CHANGED (f) = 1; |
| 3556 | 3653 | ||
| 3557 | adjust_glyphs (f); | 3654 | adjust_glyphs (f); |
| 3558 | UNBLOCK_INPUT; | 3655 | unblock_input (); |
| 3559 | 3656 | ||
| 3560 | run_window_configuration_change_hook (f); | 3657 | run_window_configuration_change_hook (f); |
| 3561 | 3658 | ||
| @@ -3571,7 +3668,7 @@ be applied on the Elisp level. */) | |||
| 3571 | satisfy the request. The result will be meaningful if and only if | 3668 | satisfy the request. The result will be meaningful if and only if |
| 3572 | F's windows have meaningful sizes when you call this. */ | 3669 | F's windows have meaningful sizes when you call this. */ |
| 3573 | void | 3670 | void |
| 3574 | resize_frame_windows (struct frame *f, int size, int horflag) | 3671 | resize_frame_windows (struct frame *f, int size, bool horflag) |
| 3575 | { | 3672 | { |
| 3576 | Lisp_Object root = f->root_window; | 3673 | Lisp_Object root = f->root_window; |
| 3577 | struct window *r = XWINDOW (root); | 3674 | struct window *r = XWINDOW (root); |
| @@ -3585,23 +3682,24 @@ resize_frame_windows (struct frame *f, int size, int horflag) | |||
| 3585 | - ((FRAME_HAS_MINIBUF_P (f) && !FRAME_MINIBUF_ONLY_P (f)) | 3682 | - ((FRAME_HAS_MINIBUF_P (f) && !FRAME_MINIBUF_ONLY_P (f)) |
| 3586 | ? 1 : 0))); | 3683 | ? 1 : 0))); |
| 3587 | 3684 | ||
| 3588 | XSETFASTINT (r->top_line, FRAME_TOP_MARGIN (f)); | 3685 | r->top_line = FRAME_TOP_MARGIN (f); |
| 3589 | if (NILP (r->vchild) && NILP (r->hchild)) | 3686 | if (WINDOW_LEAF_P (r)) |
| 3590 | /* For a leaf root window just set the size. */ | 3687 | /* For a leaf root window just set the size. */ |
| 3591 | if (horflag) | 3688 | if (horflag) |
| 3592 | XSETFASTINT (r->total_cols, new_size); | 3689 | r->total_cols = new_size; |
| 3593 | else | 3690 | else |
| 3594 | XSETFASTINT (r->total_lines, new_size); | 3691 | r->total_lines = new_size; |
| 3595 | else | 3692 | else |
| 3596 | { | 3693 | { |
| 3597 | /* old_size is the old size of the frame's root window. */ | 3694 | /* old_size is the old size of the frame's root window. */ |
| 3598 | int old_size = XFASTINT (horflag ? r->total_cols : r->total_lines); | 3695 | int old_size = horflag ? r->total_cols : r->total_lines; |
| 3599 | Lisp_Object delta; | 3696 | Lisp_Object delta; |
| 3600 | 3697 | ||
| 3601 | XSETINT (delta, new_size - old_size); | 3698 | XSETINT (delta, new_size - old_size); |
| 3602 | /* Try a "normal" resize first. */ | 3699 | /* Try a "normal" resize first. */ |
| 3603 | resize_root_window (root, delta, horflag ? Qt : Qnil, Qnil); | 3700 | resize_root_window (root, delta, horflag ? Qt : Qnil, Qnil); |
| 3604 | if (window_resize_check (r, horflag) && new_size == XINT (r->new_total)) | 3701 | if (window_resize_check (r, horflag) |
| 3702 | && new_size == XINT (r->new_total)) | ||
| 3605 | window_resize_apply (r, horflag); | 3703 | window_resize_apply (r, horflag); |
| 3606 | else | 3704 | else |
| 3607 | { | 3705 | { |
| @@ -3624,9 +3722,9 @@ resize_frame_windows (struct frame *f, int size, int horflag) | |||
| 3624 | root = f->selected_window; | 3722 | root = f->selected_window; |
| 3625 | Fdelete_other_windows_internal (root, Qnil); | 3723 | Fdelete_other_windows_internal (root, Qnil); |
| 3626 | if (horflag) | 3724 | if (horflag) |
| 3627 | XSETFASTINT (XWINDOW (root)->total_cols, new_size); | 3725 | XWINDOW (root)->total_cols = new_size; |
| 3628 | else | 3726 | else |
| 3629 | XSETFASTINT (XWINDOW (root)->total_lines, new_size); | 3727 | XWINDOW (root)->total_lines = new_size; |
| 3630 | } | 3728 | } |
| 3631 | } | 3729 | } |
| 3632 | } | 3730 | } |
| @@ -3636,14 +3734,16 @@ resize_frame_windows (struct frame *f, int size, int horflag) | |||
| 3636 | { | 3734 | { |
| 3637 | m = XWINDOW (mini); | 3735 | m = XWINDOW (mini); |
| 3638 | if (horflag) | 3736 | if (horflag) |
| 3639 | XSETFASTINT (m->total_cols, size); | 3737 | m->total_cols = size; |
| 3640 | else | 3738 | else |
| 3641 | { | 3739 | { |
| 3642 | /* Are we sure we always want 1 line here? */ | 3740 | /* Are we sure we always want 1 line here? */ |
| 3643 | XSETFASTINT (m->total_lines, 1); | 3741 | m->total_lines = 1; |
| 3644 | XSETFASTINT (m->top_line, XINT (r->top_line) + XINT (r->total_lines)); | 3742 | m->top_line = r->top_line + r->total_lines; |
| 3645 | } | 3743 | } |
| 3646 | } | 3744 | } |
| 3745 | |||
| 3746 | windows_or_buffers_changed++; | ||
| 3647 | } | 3747 | } |
| 3648 | 3748 | ||
| 3649 | 3749 | ||
| @@ -3680,7 +3780,7 @@ set correctly. See the code of `split-window' for how this is done. */) | |||
| 3680 | register Lisp_Object new, frame, reference; | 3780 | register Lisp_Object new, frame, reference; |
| 3681 | register struct window *o, *p, *n, *r; | 3781 | register struct window *o, *p, *n, *r; |
| 3682 | struct frame *f; | 3782 | struct frame *f; |
| 3683 | int horflag | 3783 | bool horflag |
| 3684 | /* HORFLAG is 1 when we split side-by-side, 0 otherwise. */ | 3784 | /* HORFLAG is 1 when we split side-by-side, 0 otherwise. */ |
| 3685 | = EQ (side, Qt) || EQ (side, Qleft) || EQ (side, Qright); | 3785 | = EQ (side, Qt) || EQ (side, Qleft) || EQ (side, Qright); |
| 3686 | int combination_limit = 0; | 3786 | int combination_limit = 0; |
| @@ -3696,11 +3796,11 @@ set correctly. See the code of `split-window' for how this is done. */) | |||
| 3696 | We do that if either `window-combination-limit' is t, or OLD has no | 3796 | We do that if either `window-combination-limit' is t, or OLD has no |
| 3697 | parent, or OLD is ortho-combined. */ | 3797 | parent, or OLD is ortho-combined. */ |
| 3698 | combination_limit = | 3798 | combination_limit = |
| 3699 | !NILP (Vwindow_combination_limit) | 3799 | EQ (Vwindow_combination_limit, Qt) |
| 3700 | || NILP (o->parent) | 3800 | || NILP (o->parent) |
| 3701 | || NILP (horflag | 3801 | || (horflag |
| 3702 | ? (XWINDOW (o->parent)->hchild) | 3802 | ? WINDOW_VERTICAL_COMBINATION_P (XWINDOW (o->parent)) |
| 3703 | : (XWINDOW (o->parent)->vchild)); | 3803 | : WINDOW_HORIZONTAL_COMBINATION_P (XWINDOW (o->parent))); |
| 3704 | 3804 | ||
| 3705 | /* We need a live reference window to initialize some parameters. */ | 3805 | /* We need a live reference window to initialize some parameters. */ |
| 3706 | if (WINDOW_LIVE_P (old)) | 3806 | if (WINDOW_LIVE_P (old)) |
| @@ -3722,21 +3822,22 @@ set correctly. See the code of `split-window' for how this is done. */) | |||
| 3722 | { | 3822 | { |
| 3723 | p = XWINDOW (o->parent); | 3823 | p = XWINDOW (o->parent); |
| 3724 | /* Temporarily pretend we split the parent window. */ | 3824 | /* Temporarily pretend we split the parent window. */ |
| 3725 | XSETINT (p->new_total, | 3825 | wset_new_total |
| 3726 | XINT (horflag ? p->total_cols : p->total_lines) | 3826 | (p, make_number ((horflag ? p->total_cols : p->total_lines) |
| 3727 | - XINT (total_size)); | 3827 | - XINT (total_size))); |
| 3728 | if (!window_resize_check (p, horflag)) | 3828 | if (!window_resize_check (p, horflag)) |
| 3729 | error ("Window sizes don't fit"); | 3829 | error ("Window sizes don't fit"); |
| 3730 | else | 3830 | else |
| 3731 | /* Undo the temporary pretension. */ | 3831 | /* Undo the temporary pretension. */ |
| 3732 | p->new_total = horflag ? p->total_cols : p->total_lines; | 3832 | wset_new_total (p, make_number |
| 3833 | (horflag ? p->total_cols : p->total_lines)); | ||
| 3733 | } | 3834 | } |
| 3734 | else | 3835 | else |
| 3735 | { | 3836 | { |
| 3736 | if (!window_resize_check (o, horflag)) | 3837 | if (!window_resize_check (o, horflag)) |
| 3737 | error ("Resizing old window failed"); | 3838 | error ("Resizing old window failed"); |
| 3738 | else if (XINT (total_size) + XINT (o->new_total) | 3839 | else if (XINT (total_size) + XINT (o->new_total) |
| 3739 | != XINT (horflag ? o->total_cols : o->total_lines)) | 3840 | != (horflag ? o->total_cols : o->total_lines)) |
| 3740 | error ("Sum of sizes of old and new window don't fit"); | 3841 | error ("Sum of sizes of old and new window don't fit"); |
| 3741 | } | 3842 | } |
| 3742 | 3843 | ||
| @@ -3746,16 +3847,19 @@ set correctly. See the code of `split-window' for how this is done. */) | |||
| 3746 | /* Save the old value of o->normal_cols/lines. It gets corrupted | 3847 | /* Save the old value of o->normal_cols/lines. It gets corrupted |
| 3747 | by make_parent_window and we need it below for assigning it to | 3848 | by make_parent_window and we need it below for assigning it to |
| 3748 | p->new_normal. */ | 3849 | p->new_normal. */ |
| 3749 | Lisp_Object new_normal = horflag ? o->normal_cols : o->normal_lines; | 3850 | Lisp_Object new_normal |
| 3851 | = horflag ? o->normal_cols : o->normal_lines; | ||
| 3750 | 3852 | ||
| 3751 | make_parent_window (old, horflag); | 3853 | make_parent_window (old, horflag); |
| 3752 | p = XWINDOW (o->parent); | 3854 | p = XWINDOW (o->parent); |
| 3753 | /* Store value of `window-combination-limit' in new parent's | 3855 | if (EQ (Vwindow_combination_limit, Qt)) |
| 3754 | combination_limit slot. */ | 3856 | /* Store t in the new parent's combination_limit slot to avoid |
| 3755 | p->combination_limit = Vwindow_combination_limit; | 3857 | that its children get merged into another window. */ |
| 3858 | wset_combination_limit (p, Qt); | ||
| 3756 | /* These get applied below. */ | 3859 | /* These get applied below. */ |
| 3757 | p->new_total = horflag ? o->total_cols : o->total_lines; | 3860 | wset_new_total (p, make_number |
| 3758 | p->new_normal = new_normal; | 3861 | (horflag ? o->total_cols : o->total_lines)); |
| 3862 | wset_new_normal (p, new_normal); | ||
| 3759 | } | 3863 | } |
| 3760 | else | 3864 | else |
| 3761 | p = XWINDOW (o->parent); | 3865 | p = XWINDOW (o->parent); |
| @@ -3764,35 +3868,30 @@ set correctly. See the code of `split-window' for how this is done. */) | |||
| 3764 | FRAME_WINDOW_SIZES_CHANGED (f) = 1; | 3868 | FRAME_WINDOW_SIZES_CHANGED (f) = 1; |
| 3765 | new = make_window (); | 3869 | new = make_window (); |
| 3766 | n = XWINDOW (new); | 3870 | n = XWINDOW (new); |
| 3767 | n->frame = frame; | 3871 | wset_frame (n, frame); |
| 3768 | n->parent = o->parent; | 3872 | wset_parent (n, o->parent); |
| 3769 | n->vchild = n->hchild = Qnil; | ||
| 3770 | 3873 | ||
| 3771 | if (EQ (side, Qabove) || EQ (side, Qleft)) | 3874 | if (EQ (side, Qabove) || EQ (side, Qleft)) |
| 3772 | { | 3875 | { |
| 3773 | n->prev = o->prev; | 3876 | wset_prev (n, o->prev); |
| 3774 | if (NILP (n->prev)) | 3877 | if (NILP (n->prev)) |
| 3775 | if (horflag) | 3878 | wset_combination (p, horflag, new); |
| 3776 | p->hchild = new; | ||
| 3777 | else | ||
| 3778 | p->vchild = new; | ||
| 3779 | else | 3879 | else |
| 3780 | XWINDOW (n->prev)->next = new; | 3880 | wset_next (XWINDOW (n->prev), new); |
| 3781 | n->next = old; | 3881 | wset_next (n, old); |
| 3782 | o->prev = new; | 3882 | wset_prev (o, new); |
| 3783 | } | 3883 | } |
| 3784 | else | 3884 | else |
| 3785 | { | 3885 | { |
| 3786 | n->next = o->next; | 3886 | wset_next (n, o->next); |
| 3787 | if (!NILP (n->next)) | 3887 | if (!NILP (n->next)) |
| 3788 | XWINDOW (n->next)->prev = new; | 3888 | wset_prev (XWINDOW (n->next), new); |
| 3789 | n->prev = old; | 3889 | wset_prev (n, old); |
| 3790 | o->next = new; | 3890 | wset_next (o, new); |
| 3791 | } | 3891 | } |
| 3792 | 3892 | ||
| 3793 | n->buffer = Qt; | 3893 | n->window_end_valid = 0; |
| 3794 | n->window_end_valid = Qnil; | 3894 | n->last_cursor_vpos = 0; |
| 3795 | memset (&n->last_cursor, 0, sizeof n->last_cursor); | ||
| 3796 | 3895 | ||
| 3797 | /* Get special geometry settings from reference window. */ | 3896 | /* Get special geometry settings from reference window. */ |
| 3798 | n->left_margin_cols = r->left_margin_cols; | 3897 | n->left_margin_cols = r->left_margin_cols; |
| @@ -3801,7 +3900,7 @@ set correctly. See the code of `split-window' for how this is done. */) | |||
| 3801 | n->right_fringe_width = r->right_fringe_width; | 3900 | n->right_fringe_width = r->right_fringe_width; |
| 3802 | n->fringes_outside_margins = r->fringes_outside_margins; | 3901 | n->fringes_outside_margins = r->fringes_outside_margins; |
| 3803 | n->scroll_bar_width = r->scroll_bar_width; | 3902 | n->scroll_bar_width = r->scroll_bar_width; |
| 3804 | n->vertical_scroll_bar_type = r->vertical_scroll_bar_type; | 3903 | wset_vertical_scroll_bar_type (n, r->vertical_scroll_bar_type); |
| 3805 | 3904 | ||
| 3806 | /* Directly assign orthogonal coordinates and sizes. */ | 3905 | /* Directly assign orthogonal coordinates and sizes. */ |
| 3807 | if (horflag) | 3906 | if (horflag) |
| @@ -3817,16 +3916,16 @@ set correctly. See the code of `split-window' for how this is done. */) | |||
| 3817 | 3916 | ||
| 3818 | /* Iso-coordinates and sizes are assigned by window_resize_apply, | 3917 | /* Iso-coordinates and sizes are assigned by window_resize_apply, |
| 3819 | get them ready here. */ | 3918 | get them ready here. */ |
| 3820 | n->new_total = total_size; | 3919 | wset_new_total (n, total_size); |
| 3821 | n->new_normal = normal_size; | 3920 | wset_new_normal (n, normal_size); |
| 3822 | 3921 | ||
| 3823 | BLOCK_INPUT; | 3922 | block_input (); |
| 3824 | window_resize_apply (p, horflag); | 3923 | window_resize_apply (p, horflag); |
| 3825 | adjust_glyphs (f); | 3924 | adjust_glyphs (f); |
| 3826 | /* Set buffer of NEW to buffer of reference window. Don't run | 3925 | /* Set buffer of NEW to buffer of reference window. Don't run |
| 3827 | any hooks. */ | 3926 | any hooks. */ |
| 3828 | set_window_buffer (new, r->buffer, 0, 1); | 3927 | set_window_buffer (new, r->contents, 0, 1); |
| 3829 | UNBLOCK_INPUT; | 3928 | unblock_input (); |
| 3830 | 3929 | ||
| 3831 | /* Maybe we should run the scroll functions in Elisp (which already | 3930 | /* Maybe we should run the scroll functions in Elisp (which already |
| 3832 | runs the configuration change hook). */ | 3931 | runs the configuration change hook). */ |
| @@ -3847,12 +3946,11 @@ Signal an error when WINDOW is the only window on its frame. */) | |||
| 3847 | register Lisp_Object parent, sibling, frame, root; | 3946 | register Lisp_Object parent, sibling, frame, root; |
| 3848 | struct window *w, *p, *s, *r; | 3947 | struct window *w, *p, *s, *r; |
| 3849 | struct frame *f; | 3948 | struct frame *f; |
| 3850 | int horflag; | 3949 | bool horflag, before_sibling = 0; |
| 3851 | int before_sibling = 0; | ||
| 3852 | 3950 | ||
| 3853 | w = decode_any_window (window); | 3951 | w = decode_any_window (window); |
| 3854 | XSETWINDOW (window, w); | 3952 | XSETWINDOW (window, w); |
| 3855 | if (NILP (w->buffer) && NILP (w->hchild) && NILP (w->vchild)) | 3953 | if (NILP (w->contents)) |
| 3856 | /* It's a no-op to delete an already deleted window. */ | 3954 | /* It's a no-op to delete an already deleted window. */ |
| 3857 | return Qnil; | 3955 | return Qnil; |
| 3858 | 3956 | ||
| @@ -3866,7 +3964,7 @@ Signal an error when WINDOW is the only window on its frame. */) | |||
| 3866 | error ("Attempt to delete sole window of parent"); | 3964 | error ("Attempt to delete sole window of parent"); |
| 3867 | 3965 | ||
| 3868 | p = XWINDOW (parent); | 3966 | p = XWINDOW (parent); |
| 3869 | horflag = NILP (p->vchild); | 3967 | horflag = WINDOW_HORIZONTAL_COMBINATION_P (p); |
| 3870 | 3968 | ||
| 3871 | frame = WINDOW_FRAME (w); | 3969 | frame = WINDOW_FRAME (w); |
| 3872 | f = XFRAME (frame); | 3970 | f = XFRAME (frame); |
| @@ -3883,61 +3981,57 @@ Signal an error when WINDOW is the only window on its frame. */) | |||
| 3883 | before_sibling = 1; | 3981 | before_sibling = 1; |
| 3884 | sibling = w->next; | 3982 | sibling = w->next; |
| 3885 | s = XWINDOW (sibling); | 3983 | s = XWINDOW (sibling); |
| 3886 | s->prev = Qnil; | 3984 | wset_prev (s, Qnil); |
| 3887 | if (horflag) | 3985 | wset_combination (p, horflag, sibling); |
| 3888 | p->hchild = sibling; | ||
| 3889 | else | ||
| 3890 | p->vchild = sibling; | ||
| 3891 | } | 3986 | } |
| 3892 | else | 3987 | else |
| 3893 | /* Get SIBLING above (on the left of) WINDOW. */ | 3988 | /* Get SIBLING above (on the left of) WINDOW. */ |
| 3894 | { | 3989 | { |
| 3895 | sibling = w->prev; | 3990 | sibling = w->prev; |
| 3896 | s = XWINDOW (sibling); | 3991 | s = XWINDOW (sibling); |
| 3897 | s->next = w->next; | 3992 | wset_next (s, w->next); |
| 3898 | if (!NILP (s->next)) | 3993 | if (!NILP (s->next)) |
| 3899 | XWINDOW (s->next)->prev = sibling; | 3994 | wset_prev (XWINDOW (s->next), sibling); |
| 3900 | } | 3995 | } |
| 3901 | 3996 | ||
| 3902 | if (window_resize_check (r, horflag) | 3997 | if (window_resize_check (r, horflag) |
| 3903 | && EQ (r->new_total, (horflag ? r->total_cols : r->total_lines))) | 3998 | && (XINT (r->new_total) |
| 3999 | == (horflag ? r->total_cols : r->total_lines))) | ||
| 3904 | /* We can delete WINDOW now. */ | 4000 | /* We can delete WINDOW now. */ |
| 3905 | { | 4001 | { |
| 3906 | Mouse_HLInfo *hlinfo; | ||
| 3907 | 4002 | ||
| 3908 | /* Block input. */ | 4003 | /* Block input. */ |
| 3909 | BLOCK_INPUT; | 4004 | block_input (); |
| 3910 | window_resize_apply (p, horflag); | 4005 | window_resize_apply (p, horflag); |
| 3911 | 4006 | ||
| 3912 | /* If this window is referred to by the dpyinfo's mouse | 4007 | /* If this window is referred to by the dpyinfo's mouse |
| 3913 | highlight, invalidate that slot to be safe (Bug#9904). */ | 4008 | highlight, invalidate that slot to be safe (Bug#9904). */ |
| 3914 | hlinfo = MOUSE_HL_INFO (XFRAME (w->frame)); | 4009 | if (!FRAME_INITIAL_P (f)) |
| 3915 | if (EQ (hlinfo->mouse_face_window, window)) | 4010 | { |
| 3916 | hlinfo->mouse_face_window = Qnil; | 4011 | Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f); |
| 4012 | |||
| 4013 | if (EQ (hlinfo->mouse_face_window, window)) | ||
| 4014 | hlinfo->mouse_face_window = Qnil; | ||
| 4015 | } | ||
| 3917 | 4016 | ||
| 3918 | windows_or_buffers_changed++; | 4017 | windows_or_buffers_changed++; |
| 3919 | Vwindow_list = Qnil; | 4018 | Vwindow_list = Qnil; |
| 3920 | FRAME_WINDOW_SIZES_CHANGED (f) = 1; | 4019 | FRAME_WINDOW_SIZES_CHANGED (f) = 1; |
| 3921 | 4020 | ||
| 3922 | w->next = Qnil; /* Don't delete w->next too. */ | 4021 | wset_next (w, Qnil); /* Don't delete w->next too. */ |
| 3923 | free_window_matrices (w); | 4022 | free_window_matrices (w); |
| 3924 | 4023 | ||
| 3925 | if (!NILP (w->vchild)) | 4024 | if (WINDOWP (w->contents)) |
| 3926 | { | 4025 | { |
| 3927 | delete_all_child_windows (w->vchild); | 4026 | delete_all_child_windows (w->contents); |
| 3928 | w->vchild = Qnil; | 4027 | wset_combination (w, 0, Qnil); |
| 3929 | } | 4028 | } |
| 3930 | else if (!NILP (w->hchild)) | 4029 | else |
| 3931 | { | ||
| 3932 | delete_all_child_windows (w->hchild); | ||
| 3933 | w->hchild = Qnil; | ||
| 3934 | } | ||
| 3935 | else if (!NILP (w->buffer)) | ||
| 3936 | { | 4030 | { |
| 3937 | unshow_buffer (w); | 4031 | unshow_buffer (w); |
| 3938 | unchain_marker (XMARKER (w->pointm)); | 4032 | unchain_marker (XMARKER (w->pointm)); |
| 3939 | unchain_marker (XMARKER (w->start)); | 4033 | unchain_marker (XMARKER (w->start)); |
| 3940 | w->buffer = Qnil; | 4034 | wset_buffer (w, Qnil); |
| 3941 | } | 4035 | } |
| 3942 | 4036 | ||
| 3943 | if (NILP (s->prev) && NILP (s->next)) | 4037 | if (NILP (s->prev) && NILP (s->next)) |
| @@ -3948,10 +4042,10 @@ Signal an error when WINDOW is the only window on its frame. */) | |||
| 3948 | replace_window (parent, sibling, 0); | 4042 | replace_window (parent, sibling, 0); |
| 3949 | /* Have SIBLING inherit the following three slot values from | 4043 | /* Have SIBLING inherit the following three slot values from |
| 3950 | PARENT (the combination_limit slot is not inherited). */ | 4044 | PARENT (the combination_limit slot is not inherited). */ |
| 3951 | s->normal_cols = p->normal_cols; | 4045 | wset_normal_cols (s, p->normal_cols); |
| 3952 | s->normal_lines = p->normal_lines; | 4046 | wset_normal_lines (s, p->normal_lines); |
| 3953 | /* Mark PARENT as deleted. */ | 4047 | /* Mark PARENT as deleted. */ |
| 3954 | p->vchild = p->hchild = Qnil; | 4048 | wset_combination (p, 0, Qnil); |
| 3955 | /* Try to merge SIBLING into its new parent. */ | 4049 | /* Try to merge SIBLING into its new parent. */ |
| 3956 | recombine_windows (sibling); | 4050 | recombine_windows (sibling); |
| 3957 | } | 4051 | } |
| @@ -3971,9 +4065,9 @@ Signal an error when WINDOW is the only window on its frame. */) | |||
| 3971 | if (EQ (FRAME_SELECTED_WINDOW (f), selected_window)) | 4065 | if (EQ (FRAME_SELECTED_WINDOW (f), selected_window)) |
| 3972 | Fselect_window (new_selected_window, Qt); | 4066 | Fselect_window (new_selected_window, Qt); |
| 3973 | else | 4067 | else |
| 3974 | FRAME_SELECTED_WINDOW (f) = new_selected_window; | 4068 | fset_selected_window (f, new_selected_window); |
| 3975 | 4069 | ||
| 3976 | UNBLOCK_INPUT; | 4070 | unblock_input (); |
| 3977 | 4071 | ||
| 3978 | /* Now look whether `get-mru-window' gets us something. */ | 4072 | /* Now look whether `get-mru-window' gets us something. */ |
| 3979 | mru_window = call1 (Qget_mru_window, frame); | 4073 | mru_window = call1 (Qget_mru_window, frame); |
| @@ -3985,10 +4079,10 @@ Signal an error when WINDOW is the only window on its frame. */) | |||
| 3985 | if (EQ (FRAME_SELECTED_WINDOW (f), selected_window)) | 4079 | if (EQ (FRAME_SELECTED_WINDOW (f), selected_window)) |
| 3986 | Fselect_window (new_selected_window, Qnil); | 4080 | Fselect_window (new_selected_window, Qnil); |
| 3987 | else | 4081 | else |
| 3988 | FRAME_SELECTED_WINDOW (f) = new_selected_window; | 4082 | fset_selected_window (f, new_selected_window); |
| 3989 | } | 4083 | } |
| 3990 | else | 4084 | else |
| 3991 | UNBLOCK_INPUT; | 4085 | unblock_input (); |
| 3992 | 4086 | ||
| 3993 | /* Must be run by the caller: | 4087 | /* Must be run by the caller: |
| 3994 | run_window_configuration_change_hook (f); */ | 4088 | run_window_configuration_change_hook (f); */ |
| @@ -3998,17 +4092,14 @@ Signal an error when WINDOW is the only window on its frame. */) | |||
| 3998 | { | 4092 | { |
| 3999 | if (before_sibling) | 4093 | if (before_sibling) |
| 4000 | { | 4094 | { |
| 4001 | s->prev = window; | 4095 | wset_prev (s, window); |
| 4002 | if (horflag) | 4096 | wset_combination (p, horflag, window); |
| 4003 | p->hchild = window; | ||
| 4004 | else | ||
| 4005 | p->vchild = window; | ||
| 4006 | } | 4097 | } |
| 4007 | else | 4098 | else |
| 4008 | { | 4099 | { |
| 4009 | s->next = window; | 4100 | wset_next (s, window); |
| 4010 | if (!NILP (w->next)) | 4101 | if (!NILP (w->next)) |
| 4011 | XWINDOW (w->next)->prev = window; | 4102 | wset_prev (XWINDOW (w->next), window); |
| 4012 | } | 4103 | } |
| 4013 | error ("Deletion failed"); | 4104 | error ("Deletion failed"); |
| 4014 | } | 4105 | } |
| @@ -4029,8 +4120,8 @@ grow_mini_window (struct window *w, int delta) | |||
| 4029 | struct window *r; | 4120 | struct window *r; |
| 4030 | Lisp_Object root, value; | 4121 | Lisp_Object root, value; |
| 4031 | 4122 | ||
| 4032 | xassert (MINI_WINDOW_P (w)); | 4123 | eassert (MINI_WINDOW_P (w)); |
| 4033 | xassert (delta >= 0); | 4124 | eassert (delta >= 0); |
| 4034 | 4125 | ||
| 4035 | root = FRAME_ROOT_WINDOW (f); | 4126 | root = FRAME_ROOT_WINDOW (f); |
| 4036 | r = XWINDOW (root); | 4127 | r = XWINDOW (root); |
| @@ -4038,17 +4129,16 @@ grow_mini_window (struct window *w, int delta) | |||
| 4038 | root, make_number (- delta)); | 4129 | root, make_number (- delta)); |
| 4039 | if (INTEGERP (value) && window_resize_check (r, 0)) | 4130 | if (INTEGERP (value) && window_resize_check (r, 0)) |
| 4040 | { | 4131 | { |
| 4041 | BLOCK_INPUT; | 4132 | block_input (); |
| 4042 | window_resize_apply (r, 0); | 4133 | window_resize_apply (r, 0); |
| 4043 | 4134 | ||
| 4044 | /* Grow the mini-window. */ | 4135 | /* Grow the mini-window. */ |
| 4045 | XSETFASTINT (w->top_line, XFASTINT (r->top_line) + XFASTINT (r->total_lines)); | 4136 | w->top_line = r->top_line + r->total_lines; |
| 4046 | XSETFASTINT (w->total_lines, XFASTINT (w->total_lines) - XINT (value)); | 4137 | w->total_lines -= XINT (value); |
| 4047 | XSETFASTINT (w->last_modified, 0); | 4138 | /* Enforce full redisplay. FIXME: make it more selective. */ |
| 4048 | XSETFASTINT (w->last_overlay_modified, 0); | 4139 | windows_or_buffers_changed++; |
| 4049 | |||
| 4050 | adjust_glyphs (f); | 4140 | adjust_glyphs (f); |
| 4051 | UNBLOCK_INPUT; | 4141 | unblock_input (); |
| 4052 | } | 4142 | } |
| 4053 | } | 4143 | } |
| 4054 | 4144 | ||
| @@ -4062,9 +4152,9 @@ shrink_mini_window (struct window *w) | |||
| 4062 | Lisp_Object root, value; | 4152 | Lisp_Object root, value; |
| 4063 | EMACS_INT size; | 4153 | EMACS_INT size; |
| 4064 | 4154 | ||
| 4065 | xassert (MINI_WINDOW_P (w)); | 4155 | eassert (MINI_WINDOW_P (w)); |
| 4066 | 4156 | ||
| 4067 | size = XINT (w->total_lines); | 4157 | size = w->total_lines; |
| 4068 | if (size > 1) | 4158 | if (size > 1) |
| 4069 | { | 4159 | { |
| 4070 | root = FRAME_ROOT_WINDOW (f); | 4160 | root = FRAME_ROOT_WINDOW (f); |
| @@ -4073,18 +4163,16 @@ shrink_mini_window (struct window *w) | |||
| 4073 | root, make_number (size - 1)); | 4163 | root, make_number (size - 1)); |
| 4074 | if (INTEGERP (value) && window_resize_check (r, 0)) | 4164 | if (INTEGERP (value) && window_resize_check (r, 0)) |
| 4075 | { | 4165 | { |
| 4076 | BLOCK_INPUT; | 4166 | block_input (); |
| 4077 | window_resize_apply (r, 0); | 4167 | window_resize_apply (r, 0); |
| 4078 | 4168 | ||
| 4079 | /* Shrink the mini-window. */ | 4169 | /* Shrink the mini-window. */ |
| 4080 | XSETFASTINT (w->top_line, XFASTINT (r->top_line) + XFASTINT (r->total_lines)); | 4170 | w->top_line = r->top_line + r->total_lines; |
| 4081 | XSETFASTINT (w->total_lines, 1); | 4171 | w->total_lines = 1; |
| 4082 | 4172 | /* Enforce full redisplay. FIXME: make it more selective. */ | |
| 4083 | XSETFASTINT (w->last_modified, 0); | 4173 | windows_or_buffers_changed++; |
| 4084 | XSETFASTINT (w->last_overlay_modified, 0); | ||
| 4085 | |||
| 4086 | adjust_glyphs (f); | 4174 | adjust_glyphs (f); |
| 4087 | UNBLOCK_INPUT; | 4175 | unblock_input (); |
| 4088 | } | 4176 | } |
| 4089 | /* If the above failed for whatever strange reason we must make a | 4177 | /* If the above failed for whatever strange reason we must make a |
| 4090 | one window frame here. The same routine will be needed when | 4178 | one window frame here. The same routine will be needed when |
| @@ -4111,21 +4199,21 @@ DEFUN ("resize-mini-window-internal", Fresize_mini_window_internal, Sresize_mini | |||
| 4111 | error ("Cannot resize a minibuffer-only frame"); | 4199 | error ("Cannot resize a minibuffer-only frame"); |
| 4112 | 4200 | ||
| 4113 | r = XWINDOW (FRAME_ROOT_WINDOW (f)); | 4201 | r = XWINDOW (FRAME_ROOT_WINDOW (f)); |
| 4114 | height = XINT (r->total_lines) + XINT (w->total_lines); | 4202 | height = r->total_lines + w->total_lines; |
| 4115 | if (window_resize_check (r, 0) | 4203 | if (window_resize_check (r, 0) |
| 4116 | && XINT (w->new_total) > 0 | 4204 | && XINT (w->new_total) > 0 |
| 4117 | && height == XINT (r->new_total) + XINT (w->new_total)) | 4205 | && height == XINT (r->new_total) + XINT (w->new_total)) |
| 4118 | { | 4206 | { |
| 4119 | BLOCK_INPUT; | 4207 | block_input (); |
| 4120 | window_resize_apply (r, 0); | 4208 | window_resize_apply (r, 0); |
| 4121 | 4209 | ||
| 4122 | w->total_lines = w->new_total; | 4210 | w->total_lines = XFASTINT (w->new_total); |
| 4123 | XSETFASTINT (w->top_line, XINT (r->top_line) + XINT (r->total_lines)); | 4211 | w->top_line = r->top_line + r->total_lines; |
| 4124 | 4212 | ||
| 4125 | windows_or_buffers_changed++; | 4213 | windows_or_buffers_changed++; |
| 4126 | FRAME_WINDOW_SIZES_CHANGED (f) = 1; | 4214 | FRAME_WINDOW_SIZES_CHANGED (f) = 1; |
| 4127 | adjust_glyphs (f); | 4215 | adjust_glyphs (f); |
| 4128 | UNBLOCK_INPUT; | 4216 | unblock_input (); |
| 4129 | 4217 | ||
| 4130 | run_window_configuration_change_hook (f); | 4218 | run_window_configuration_change_hook (f); |
| 4131 | return Qt; | 4219 | return Qt; |
| @@ -4143,10 +4231,8 @@ mark_window_cursors_off (struct window *w) | |||
| 4143 | { | 4231 | { |
| 4144 | while (w) | 4232 | while (w) |
| 4145 | { | 4233 | { |
| 4146 | if (!NILP (w->hchild)) | 4234 | if (WINDOWP (w->contents)) |
| 4147 | mark_window_cursors_off (XWINDOW (w->hchild)); | 4235 | mark_window_cursors_off (XWINDOW (w->contents)); |
| 4148 | else if (!NILP (w->vchild)) | ||
| 4149 | mark_window_cursors_off (XWINDOW (w->vchild)); | ||
| 4150 | else | 4236 | else |
| 4151 | w->phys_cursor_on_p = 0; | 4237 | w->phys_cursor_on_p = 0; |
| 4152 | 4238 | ||
| @@ -4160,13 +4246,12 @@ mark_window_cursors_off (struct window *w) | |||
| 4160 | int | 4246 | int |
| 4161 | window_internal_height (struct window *w) | 4247 | window_internal_height (struct window *w) |
| 4162 | { | 4248 | { |
| 4163 | int ht = XFASTINT (w->total_lines); | 4249 | int ht = w->total_lines; |
| 4164 | 4250 | ||
| 4165 | if (!MINI_WINDOW_P (w)) | 4251 | if (!MINI_WINDOW_P (w)) |
| 4166 | { | 4252 | { |
| 4167 | if (!NILP (w->parent) | 4253 | if (!NILP (w->parent) |
| 4168 | || !NILP (w->vchild) | 4254 | || WINDOWP (w->contents) |
| 4169 | || !NILP (w->hchild) | ||
| 4170 | || !NILP (w->next) | 4255 | || !NILP (w->next) |
| 4171 | || !NILP (w->prev) | 4256 | || !NILP (w->prev) |
| 4172 | || WINDOW_WANTS_MODELINE_P (w)) | 4257 | || WINDOW_WANTS_MODELINE_P (w)) |
| @@ -4191,7 +4276,7 @@ window_internal_height (struct window *w) | |||
| 4191 | respectively. */ | 4276 | respectively. */ |
| 4192 | 4277 | ||
| 4193 | static void | 4278 | static void |
| 4194 | window_scroll (Lisp_Object window, EMACS_INT n, int whole, int noerror) | 4279 | window_scroll (Lisp_Object window, EMACS_INT n, bool whole, int noerror) |
| 4195 | { | 4280 | { |
| 4196 | immediate_quit = 1; | 4281 | immediate_quit = 1; |
| 4197 | n = clip_to_bounds (INT_MIN, n, INT_MAX); | 4282 | n = clip_to_bounds (INT_MIN, n, INT_MAX); |
| @@ -4212,7 +4297,7 @@ window_scroll (Lisp_Object window, EMACS_INT n, int whole, int noerror) | |||
| 4212 | descriptions. */ | 4297 | descriptions. */ |
| 4213 | 4298 | ||
| 4214 | static void | 4299 | static void |
| 4215 | window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror) | 4300 | window_scroll_pixel_based (Lisp_Object window, int n, bool whole, int noerror) |
| 4216 | { | 4301 | { |
| 4217 | struct it it; | 4302 | struct it it; |
| 4218 | struct window *w = XWINDOW (window); | 4303 | struct window *w = XWINDOW (window); |
| @@ -4222,6 +4307,8 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror) | |||
| 4222 | int vscrolled = 0; | 4307 | int vscrolled = 0; |
| 4223 | int x, y, rtop, rbot, rowh, vpos; | 4308 | int x, y, rtop, rbot, rowh, vpos; |
| 4224 | void *itdata = NULL; | 4309 | void *itdata = NULL; |
| 4310 | int window_total_lines; | ||
| 4311 | int frame_line_height = default_line_pixel_height (w); | ||
| 4225 | 4312 | ||
| 4226 | SET_TEXT_POS_FROM_MARKER (start, w->start); | 4313 | SET_TEXT_POS_FROM_MARKER (start, w->start); |
| 4227 | /* Scrolling a minibuffer window via scroll bar when the echo area | 4314 | /* Scrolling a minibuffer window via scroll bar when the echo area |
| @@ -4265,7 +4352,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror) | |||
| 4265 | if (rtop || rbot) /* partially visible */ | 4352 | if (rtop || rbot) /* partially visible */ |
| 4266 | { | 4353 | { |
| 4267 | int px; | 4354 | int px; |
| 4268 | int dy = WINDOW_FRAME_LINE_HEIGHT (w); | 4355 | int dy = frame_line_height; |
| 4269 | if (whole) | 4356 | if (whole) |
| 4270 | dy = max ((window_box_height (w) | 4357 | dy = max ((window_box_height (w) |
| 4271 | - next_screen_context_lines * dy), | 4358 | - next_screen_context_lines * dy), |
| @@ -4305,11 +4392,9 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror) | |||
| 4305 | else | 4392 | else |
| 4306 | spos = min (XINT (Fline_end_position (Qnil)) + 1, ZV); | 4393 | spos = min (XINT (Fline_end_position (Qnil)) + 1, ZV); |
| 4307 | set_marker_restricted (w->start, make_number (spos), | 4394 | set_marker_restricted (w->start, make_number (spos), |
| 4308 | w->buffer); | 4395 | w->contents); |
| 4309 | w->start_at_line_beg = 1; | 4396 | w->start_at_line_beg = 1; |
| 4310 | w->update_mode_line = 1; | 4397 | w->update_mode_line = 1; |
| 4311 | XSETFASTINT (w->last_modified, 0); | ||
| 4312 | XSETFASTINT (w->last_overlay_modified, 0); | ||
| 4313 | /* Set force_start so that redisplay_window will run the | 4398 | /* Set force_start so that redisplay_window will run the |
| 4314 | window-scroll-functions. */ | 4399 | window-scroll-functions. */ |
| 4315 | w->force_start = 1; | 4400 | w->force_start = 1; |
| @@ -4351,7 +4436,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror) | |||
| 4351 | if (whole) | 4436 | if (whole) |
| 4352 | { | 4437 | { |
| 4353 | ptrdiff_t start_pos = IT_CHARPOS (it); | 4438 | ptrdiff_t start_pos = IT_CHARPOS (it); |
| 4354 | int dy = WINDOW_FRAME_LINE_HEIGHT (w); | 4439 | int dy = frame_line_height; |
| 4355 | dy = max ((window_box_height (w) | 4440 | dy = max ((window_box_height (w) |
| 4356 | - next_screen_context_lines * dy), | 4441 | - next_screen_context_lines * dy), |
| 4357 | dy) * n; | 4442 | dy) * n; |
| @@ -4429,7 +4514,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror) | |||
| 4429 | 4514 | ||
| 4430 | /* If control gets here, then we vscrolled. */ | 4515 | /* If control gets here, then we vscrolled. */ |
| 4431 | 4516 | ||
| 4432 | XBUFFER (w->buffer)->prevent_redisplay_optimizations_p = 1; | 4517 | XBUFFER (w->contents)->prevent_redisplay_optimizations_p = 1; |
| 4433 | 4518 | ||
| 4434 | /* Don't try to change the window start below. */ | 4519 | /* Don't try to change the window start below. */ |
| 4435 | vscrolled = 1; | 4520 | vscrolled = 1; |
| @@ -4449,13 +4534,11 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror) | |||
| 4449 | } | 4534 | } |
| 4450 | 4535 | ||
| 4451 | /* Set the window start, and set up the window for redisplay. */ | 4536 | /* Set the window start, and set up the window for redisplay. */ |
| 4452 | set_marker_restricted (w->start, make_number (pos), | 4537 | set_marker_restricted_both (w->start, w->contents, IT_CHARPOS (it), |
| 4453 | w->buffer); | 4538 | IT_BYTEPOS (it)); |
| 4454 | bytepos = XMARKER (w->start)->bytepos; | 4539 | bytepos = marker_byte_position (w->start); |
| 4455 | w->start_at_line_beg = (pos == BEGV || FETCH_BYTE (bytepos - 1) == '\n'); | 4540 | w->start_at_line_beg = (pos == BEGV || FETCH_BYTE (bytepos - 1) == '\n'); |
| 4456 | w->update_mode_line = 1; | 4541 | w->update_mode_line = 1; |
| 4457 | XSETFASTINT (w->last_modified, 0); | ||
| 4458 | XSETFASTINT (w->last_overlay_modified, 0); | ||
| 4459 | /* Set force_start so that redisplay_window will run the | 4542 | /* Set force_start so that redisplay_window will run the |
| 4460 | window-scroll-functions. */ | 4543 | window-scroll-functions. */ |
| 4461 | w->force_start = 1; | 4544 | w->force_start = 1; |
| @@ -4468,9 +4551,12 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror) | |||
| 4468 | /* Move PT out of scroll margins. | 4551 | /* Move PT out of scroll margins. |
| 4469 | This code wants current_y to be zero at the window start position | 4552 | This code wants current_y to be zero at the window start position |
| 4470 | even if there is a header line. */ | 4553 | even if there is a header line. */ |
| 4554 | window_total_lines | ||
| 4555 | = w->total_lines * WINDOW_FRAME_LINE_HEIGHT (w) / frame_line_height; | ||
| 4471 | this_scroll_margin = max (0, scroll_margin); | 4556 | this_scroll_margin = max (0, scroll_margin); |
| 4472 | this_scroll_margin = min (this_scroll_margin, XFASTINT (w->total_lines) / 4); | 4557 | this_scroll_margin |
| 4473 | this_scroll_margin *= FRAME_LINE_HEIGHT (it.f); | 4558 | = min (this_scroll_margin, window_total_lines / 4); |
| 4559 | this_scroll_margin *= frame_line_height; | ||
| 4474 | 4560 | ||
| 4475 | if (n > 0) | 4561 | if (n > 0) |
| 4476 | { | 4562 | { |
| @@ -4575,7 +4661,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror) | |||
| 4575 | See the comment of window_scroll for parameter descriptions. */ | 4661 | See the comment of window_scroll for parameter descriptions. */ |
| 4576 | 4662 | ||
| 4577 | static void | 4663 | static void |
| 4578 | window_scroll_line_based (Lisp_Object window, int n, int whole, int noerror) | 4664 | window_scroll_line_based (Lisp_Object window, int n, bool whole, int noerror) |
| 4579 | { | 4665 | { |
| 4580 | register struct window *w = XWINDOW (window); | 4666 | register struct window *w = XWINDOW (window); |
| 4581 | /* Fvertical_motion enters redisplay, which can trigger | 4667 | /* Fvertical_motion enters redisplay, which can trigger |
| @@ -4587,9 +4673,10 @@ window_scroll_line_based (Lisp_Object window, int n, int whole, int noerror) | |||
| 4587 | register ptrdiff_t pos, pos_byte; | 4673 | register ptrdiff_t pos, pos_byte; |
| 4588 | register int ht = window_internal_height (w); | 4674 | register int ht = window_internal_height (w); |
| 4589 | register Lisp_Object tem; | 4675 | register Lisp_Object tem; |
| 4590 | int lose; | 4676 | bool lose; |
| 4591 | Lisp_Object bolp; | 4677 | Lisp_Object bolp; |
| 4592 | ptrdiff_t startpos; | 4678 | ptrdiff_t startpos = marker_position (w->start); |
| 4679 | ptrdiff_t startbyte = marker_byte_position (w->start); | ||
| 4593 | Lisp_Object original_pos = Qnil; | 4680 | Lisp_Object original_pos = Qnil; |
| 4594 | 4681 | ||
| 4595 | /* If scrolling screen-fulls, compute the number of lines to | 4682 | /* If scrolling screen-fulls, compute the number of lines to |
| @@ -4597,8 +4684,6 @@ window_scroll_line_based (Lisp_Object window, int n, int whole, int noerror) | |||
| 4597 | if (whole) | 4684 | if (whole) |
| 4598 | n *= max (1, ht - next_screen_context_lines); | 4685 | n *= max (1, ht - next_screen_context_lines); |
| 4599 | 4686 | ||
| 4600 | startpos = marker_position (w->start); | ||
| 4601 | |||
| 4602 | if (!NILP (Vscroll_preserve_screen_position)) | 4687 | if (!NILP (Vscroll_preserve_screen_position)) |
| 4603 | { | 4688 | { |
| 4604 | if (window_scroll_preserve_vpos <= 0 | 4689 | if (window_scroll_preserve_vpos <= 0 |
| @@ -4606,12 +4691,10 @@ window_scroll_line_based (Lisp_Object window, int n, int whole, int noerror) | |||
| 4606 | || NILP (Fget (KVAR (current_kboard, Vlast_command), Qscroll_command))) | 4691 | || NILP (Fget (KVAR (current_kboard, Vlast_command), Qscroll_command))) |
| 4607 | { | 4692 | { |
| 4608 | struct position posit | 4693 | struct position posit |
| 4609 | = *compute_motion (startpos, 0, 0, 0, | 4694 | = *compute_motion (startpos, startbyte, 0, 0, 0, |
| 4610 | PT, ht, 0, | 4695 | PT, ht, 0, -1, w->hscroll, 0, w); |
| 4611 | -1, XINT (w->hscroll), | ||
| 4612 | 0, w); | ||
| 4613 | window_scroll_preserve_vpos = posit.vpos; | 4696 | window_scroll_preserve_vpos = posit.vpos; |
| 4614 | window_scroll_preserve_hpos = posit.hpos + XINT (w->hscroll); | 4697 | window_scroll_preserve_hpos = posit.hpos + w->hscroll; |
| 4615 | } | 4698 | } |
| 4616 | 4699 | ||
| 4617 | original_pos = Fcons (make_number (window_scroll_preserve_hpos), | 4700 | original_pos = Fcons (make_number (window_scroll_preserve_hpos), |
| @@ -4625,9 +4708,10 @@ window_scroll_line_based (Lisp_Object window, int n, int whole, int noerror) | |||
| 4625 | { | 4708 | { |
| 4626 | Fvertical_motion (make_number (- (ht / 2)), window); | 4709 | Fvertical_motion (make_number (- (ht / 2)), window); |
| 4627 | startpos = PT; | 4710 | startpos = PT; |
| 4711 | startbyte = PT_BYTE; | ||
| 4628 | } | 4712 | } |
| 4629 | 4713 | ||
| 4630 | SET_PT (startpos); | 4714 | SET_PT_BOTH (startpos, startbyte); |
| 4631 | lose = n < 0 && PT == BEGV; | 4715 | lose = n < 0 && PT == BEGV; |
| 4632 | Fvertical_motion (make_number (n), window); | 4716 | Fvertical_motion (make_number (n), window); |
| 4633 | pos = PT; | 4717 | pos = PT; |
| @@ -4648,13 +4732,11 @@ window_scroll_line_based (Lisp_Object window, int n, int whole, int noerror) | |||
| 4648 | { | 4732 | { |
| 4649 | /* Don't use a scroll margin that is negative or too large. */ | 4733 | /* Don't use a scroll margin that is negative or too large. */ |
| 4650 | int this_scroll_margin = | 4734 | int this_scroll_margin = |
| 4651 | max (0, min (scroll_margin, XINT (w->total_lines) / 4)); | 4735 | max (0, min (scroll_margin, w->total_lines / 4)); |
| 4652 | 4736 | ||
| 4653 | set_marker_restricted_both (w->start, w->buffer, pos, pos_byte); | 4737 | set_marker_restricted_both (w->start, w->contents, pos, pos_byte); |
| 4654 | w->start_at_line_beg = !NILP (bolp); | 4738 | w->start_at_line_beg = !NILP (bolp); |
| 4655 | w->update_mode_line = 1; | 4739 | w->update_mode_line = 1; |
| 4656 | XSETFASTINT (w->last_modified, 0); | ||
| 4657 | XSETFASTINT (w->last_overlay_modified, 0); | ||
| 4658 | /* Set force_start so that redisplay_window will run | 4740 | /* Set force_start so that redisplay_window will run |
| 4659 | the window-scroll-functions. */ | 4741 | the window-scroll-functions. */ |
| 4660 | w->force_start = 1; | 4742 | w->force_start = 1; |
| @@ -4740,14 +4822,14 @@ scroll_command (Lisp_Object n, int direction) | |||
| 4740 | { | 4822 | { |
| 4741 | ptrdiff_t count = SPECPDL_INDEX (); | 4823 | ptrdiff_t count = SPECPDL_INDEX (); |
| 4742 | 4824 | ||
| 4743 | xassert (eabs (direction) == 1); | 4825 | eassert (eabs (direction) == 1); |
| 4744 | 4826 | ||
| 4745 | /* If selected window's buffer isn't current, make it current for | 4827 | /* If selected window's buffer isn't current, make it current for |
| 4746 | the moment. But don't screw up if window_scroll gets an error. */ | 4828 | the moment. But don't screw up if window_scroll gets an error. */ |
| 4747 | if (XBUFFER (XWINDOW (selected_window)->buffer) != current_buffer) | 4829 | if (XBUFFER (XWINDOW (selected_window)->contents) != current_buffer) |
| 4748 | { | 4830 | { |
| 4749 | record_unwind_protect (save_excursion_restore, save_excursion_save ()); | 4831 | record_unwind_protect (save_excursion_restore, save_excursion_save ()); |
| 4750 | Fset_buffer (XWINDOW (selected_window)->buffer); | 4832 | Fset_buffer (XWINDOW (selected_window)->contents); |
| 4751 | 4833 | ||
| 4752 | /* Make redisplay consider other windows than just selected_window. */ | 4834 | /* Make redisplay consider other windows than just selected_window. */ |
| 4753 | ++windows_or_buffers_changed; | 4835 | ++windows_or_buffers_changed; |
| @@ -4862,8 +4944,8 @@ specifies the window to scroll. This takes precedence over | |||
| 4862 | record_unwind_protect (save_excursion_restore, save_excursion_save ()); | 4944 | record_unwind_protect (save_excursion_restore, save_excursion_save ()); |
| 4863 | ++windows_or_buffers_changed; | 4945 | ++windows_or_buffers_changed; |
| 4864 | 4946 | ||
| 4865 | Fset_buffer (w->buffer); | 4947 | Fset_buffer (w->contents); |
| 4866 | SET_PT (marker_position (w->pointm)); | 4948 | SET_PT_BOTH (marker_position (w->pointm), marker_byte_position (w->pointm)); |
| 4867 | 4949 | ||
| 4868 | if (NILP (arg)) | 4950 | if (NILP (arg)) |
| 4869 | window_scroll (window, 1, 1, 1); | 4951 | window_scroll (window, 1, 1, 1); |
| @@ -4872,7 +4954,7 @@ specifies the window to scroll. This takes precedence over | |||
| 4872 | else | 4954 | else |
| 4873 | { | 4955 | { |
| 4874 | if (CONSP (arg)) | 4956 | if (CONSP (arg)) |
| 4875 | arg = Fcar (arg); | 4957 | arg = XCAR (arg); |
| 4876 | CHECK_NUMBER (arg); | 4958 | CHECK_NUMBER (arg); |
| 4877 | window_scroll (window, XINT (arg), 0, 1); | 4959 | window_scroll (window, XINT (arg), 0, 1); |
| 4878 | } | 4960 | } |
| @@ -4894,17 +4976,11 @@ will not scroll a window to a column less than the value returned | |||
| 4894 | by this function. This happens in an interactive call. */) | 4976 | by this function. This happens in an interactive call. */) |
| 4895 | (register Lisp_Object arg, Lisp_Object set_minimum) | 4977 | (register Lisp_Object arg, Lisp_Object set_minimum) |
| 4896 | { | 4978 | { |
| 4897 | Lisp_Object result; | ||
| 4898 | EMACS_INT hscroll; | ||
| 4899 | struct window *w = XWINDOW (selected_window); | 4979 | struct window *w = XWINDOW (selected_window); |
| 4900 | 4980 | EMACS_INT requested_arg = (NILP (arg) | |
| 4901 | if (NILP (arg)) | 4981 | ? window_body_cols (w) - 2 |
| 4902 | XSETFASTINT (arg, window_body_cols (w) - 2); | 4982 | : XINT (Fprefix_numeric_value (arg))); |
| 4903 | else | 4983 | Lisp_Object result = set_window_hscroll (w, w->hscroll + requested_arg); |
| 4904 | arg = Fprefix_numeric_value (arg); | ||
| 4905 | |||
| 4906 | hscroll = XINT (w->hscroll) + XINT (arg); | ||
| 4907 | result = Fset_window_hscroll (selected_window, make_number (hscroll)); | ||
| 4908 | 4984 | ||
| 4909 | if (!NILP (set_minimum)) | 4985 | if (!NILP (set_minimum)) |
| 4910 | w->min_hscroll = w->hscroll; | 4986 | w->min_hscroll = w->hscroll; |
| @@ -4923,17 +4999,11 @@ will not scroll a window to a column less than the value returned | |||
| 4923 | by this function. This happens in an interactive call. */) | 4999 | by this function. This happens in an interactive call. */) |
| 4924 | (register Lisp_Object arg, Lisp_Object set_minimum) | 5000 | (register Lisp_Object arg, Lisp_Object set_minimum) |
| 4925 | { | 5001 | { |
| 4926 | Lisp_Object result; | ||
| 4927 | EMACS_INT hscroll; | ||
| 4928 | struct window *w = XWINDOW (selected_window); | 5002 | struct window *w = XWINDOW (selected_window); |
| 4929 | 5003 | EMACS_INT requested_arg = (NILP (arg) | |
| 4930 | if (NILP (arg)) | 5004 | ? window_body_cols (w) - 2 |
| 4931 | XSETFASTINT (arg, window_body_cols (w) - 2); | 5005 | : XINT (Fprefix_numeric_value (arg))); |
| 4932 | else | 5006 | Lisp_Object result = set_window_hscroll (w, w->hscroll - requested_arg); |
| 4933 | arg = Fprefix_numeric_value (arg); | ||
| 4934 | |||
| 4935 | hscroll = XINT (w->hscroll) - XINT (arg); | ||
| 4936 | result = Fset_window_hscroll (selected_window, make_number (hscroll)); | ||
| 4937 | 5007 | ||
| 4938 | if (!NILP (set_minimum)) | 5008 | if (!NILP (set_minimum)) |
| 4939 | w->min_hscroll = w->hscroll; | 5009 | w->min_hscroll = w->hscroll; |
| @@ -4967,10 +5037,10 @@ displayed_window_lines (struct window *w) | |||
| 4967 | int bottom_y; | 5037 | int bottom_y; |
| 4968 | void *itdata = NULL; | 5038 | void *itdata = NULL; |
| 4969 | 5039 | ||
| 4970 | if (XBUFFER (w->buffer) != current_buffer) | 5040 | if (XBUFFER (w->contents) != current_buffer) |
| 4971 | { | 5041 | { |
| 4972 | old_buffer = current_buffer; | 5042 | old_buffer = current_buffer; |
| 4973 | set_buffer_internal (XBUFFER (w->buffer)); | 5043 | set_buffer_internal (XBUFFER (w->contents)); |
| 4974 | } | 5044 | } |
| 4975 | else | 5045 | else |
| 4976 | old_buffer = NULL; | 5046 | old_buffer = NULL; |
| @@ -4978,12 +5048,7 @@ displayed_window_lines (struct window *w) | |||
| 4978 | /* In case W->start is out of the accessible range, do something | 5048 | /* In case W->start is out of the accessible range, do something |
| 4979 | reasonable. This happens in Info mode when Info-scroll-down | 5049 | reasonable. This happens in Info mode when Info-scroll-down |
| 4980 | calls (recenter -1) while W->start is 1. */ | 5050 | calls (recenter -1) while W->start is 1. */ |
| 4981 | if (XMARKER (w->start)->charpos < BEGV) | 5051 | CLIP_TEXT_POS_FROM_MARKER (start, w->start); |
| 4982 | SET_TEXT_POS (start, BEGV, BEGV_BYTE); | ||
| 4983 | else if (XMARKER (w->start)->charpos > ZV) | ||
| 4984 | SET_TEXT_POS (start, ZV, ZV_BYTE); | ||
| 4985 | else | ||
| 4986 | SET_TEXT_POS_FROM_MARKER (start, w->start); | ||
| 4987 | 5052 | ||
| 4988 | itdata = bidi_shelve_cache (); | 5053 | itdata = bidi_shelve_cache (); |
| 4989 | start_display (&it, w, start); | 5054 | start_display (&it, w, start); |
| @@ -5016,7 +5081,7 @@ displayed_window_lines (struct window *w) | |||
| 5016 | 5081 | ||
| 5017 | DEFUN ("recenter", Frecenter, Srecenter, 0, 1, "P", | 5082 | DEFUN ("recenter", Frecenter, Srecenter, 0, 1, "P", |
| 5018 | doc: /* Center point in selected window and maybe redisplay frame. | 5083 | doc: /* Center point in selected window and maybe redisplay frame. |
| 5019 | With prefix argument ARG, recenter putting point on screen line ARG | 5084 | With a numeric prefix argument ARG, recenter putting point on screen line ARG |
| 5020 | relative to the selected window. If ARG is negative, it counts up from the | 5085 | relative to the selected window. If ARG is negative, it counts up from the |
| 5021 | bottom of the window. (ARG should be less than the height of the window.) | 5086 | bottom of the window. (ARG should be less than the height of the window.) |
| 5022 | 5087 | ||
| @@ -5032,9 +5097,9 @@ and redisplay normally--don't erase and redraw the frame. */) | |||
| 5032 | (register Lisp_Object arg) | 5097 | (register Lisp_Object arg) |
| 5033 | { | 5098 | { |
| 5034 | struct window *w = XWINDOW (selected_window); | 5099 | struct window *w = XWINDOW (selected_window); |
| 5035 | struct buffer *buf = XBUFFER (w->buffer); | 5100 | struct buffer *buf = XBUFFER (w->contents); |
| 5036 | struct buffer *obuf = current_buffer; | 5101 | struct buffer *obuf = current_buffer; |
| 5037 | int center_p = 0; | 5102 | bool center_p = 0; |
| 5038 | ptrdiff_t charpos, bytepos; | 5103 | ptrdiff_t charpos, bytepos; |
| 5039 | EMACS_INT iarg IF_LINT (= 0); | 5104 | EMACS_INT iarg IF_LINT (= 0); |
| 5040 | int this_scroll_margin; | 5105 | int this_scroll_margin; |
| @@ -5076,7 +5141,7 @@ and redisplay normally--don't erase and redraw the frame. */) | |||
| 5076 | /* Do this after making BUF current | 5141 | /* Do this after making BUF current |
| 5077 | in case scroll_margin is buffer-local. */ | 5142 | in case scroll_margin is buffer-local. */ |
| 5078 | this_scroll_margin = | 5143 | this_scroll_margin = |
| 5079 | max (0, min (scroll_margin, XFASTINT (w->total_lines) / 4)); | 5144 | max (0, min (scroll_margin, w->total_lines / 4)); |
| 5080 | 5145 | ||
| 5081 | /* Handle centering on a graphical frame specially. Such frames can | 5146 | /* Handle centering on a graphical frame specially. Such frames can |
| 5082 | have variable-height lines and centering point on the basis of | 5147 | have variable-height lines and centering point on the basis of |
| @@ -5173,7 +5238,7 @@ and redisplay normally--don't erase and redraw the frame. */) | |||
| 5173 | 5238 | ||
| 5174 | iarg = max (iarg, this_scroll_margin); | 5239 | iarg = max (iarg, this_scroll_margin); |
| 5175 | 5240 | ||
| 5176 | pos = *vmotion (PT, -iarg, w); | 5241 | pos = *vmotion (PT, PT_BYTE, -iarg, w); |
| 5177 | charpos = pos.bufpos; | 5242 | charpos = pos.bufpos; |
| 5178 | bytepos = pos.bytepos; | 5243 | bytepos = pos.bytepos; |
| 5179 | } | 5244 | } |
| @@ -5189,17 +5254,17 @@ and redisplay normally--don't erase and redraw the frame. */) | |||
| 5189 | iarg += ht; | 5254 | iarg += ht; |
| 5190 | 5255 | ||
| 5191 | /* Don't let it get into the margin at either top or bottom. */ | 5256 | /* Don't let it get into the margin at either top or bottom. */ |
| 5192 | iarg = max (iarg, this_scroll_margin); | 5257 | iarg = clip_to_bounds (this_scroll_margin, iarg, |
| 5193 | iarg = min (iarg, ht - this_scroll_margin - 1); | 5258 | ht - this_scroll_margin - 1); |
| 5194 | 5259 | ||
| 5195 | pos = *vmotion (PT, - iarg, w); | 5260 | pos = *vmotion (PT, PT_BYTE, - iarg, w); |
| 5196 | charpos = pos.bufpos; | 5261 | charpos = pos.bufpos; |
| 5197 | bytepos = pos.bytepos; | 5262 | bytepos = pos.bytepos; |
| 5198 | } | 5263 | } |
| 5199 | 5264 | ||
| 5200 | /* Set the new window start. */ | 5265 | /* Set the new window start. */ |
| 5201 | set_marker_both (w->start, w->buffer, charpos, bytepos); | 5266 | set_marker_both (w->start, w->contents, charpos, bytepos); |
| 5202 | w->window_end_valid = Qnil; | 5267 | w->window_end_valid = 0; |
| 5203 | 5268 | ||
| 5204 | w->optional_new_start = 1; | 5269 | w->optional_new_start = 1; |
| 5205 | 5270 | ||
| @@ -5213,13 +5278,13 @@ and redisplay normally--don't erase and redraw the frame. */) | |||
| 5213 | DEFUN ("window-text-height", Fwindow_text_height, Swindow_text_height, | 5278 | DEFUN ("window-text-height", Fwindow_text_height, Swindow_text_height, |
| 5214 | 0, 1, 0, | 5279 | 0, 1, 0, |
| 5215 | doc: /* Return the height in lines of the text display area of WINDOW. | 5280 | doc: /* Return the height in lines of the text display area of WINDOW. |
| 5216 | If WINDOW is omitted or nil, it defaults to the selected window. | 5281 | WINDOW must be a live window and defaults to the selected one. |
| 5217 | 5282 | ||
| 5218 | The returned height does not include the mode line, any header line, | 5283 | The returned height does not include the mode line, any header line, |
| 5219 | nor any partial-height lines at the bottom of the text area. */) | 5284 | nor any partial-height lines at the bottom of the text area. */) |
| 5220 | (Lisp_Object window) | 5285 | (Lisp_Object window) |
| 5221 | { | 5286 | { |
| 5222 | struct window *w = decode_window (window); | 5287 | struct window *w = decode_live_window (window); |
| 5223 | int pixel_height = window_box_height (w); | 5288 | int pixel_height = window_box_height (w); |
| 5224 | int line_height = pixel_height / FRAME_LINE_HEIGHT (XFRAME (w->frame)); | 5289 | int line_height = pixel_height / FRAME_LINE_HEIGHT (XFRAME (w->frame)); |
| 5225 | return make_number (line_height); | 5290 | return make_number (line_height); |
| @@ -5242,9 +5307,8 @@ zero means top of window, negative means relative to bottom of window. */) | |||
| 5242 | int this_scroll_margin; | 5307 | int this_scroll_margin; |
| 5243 | #endif | 5308 | #endif |
| 5244 | 5309 | ||
| 5245 | if (!(BUFFERP (w->buffer) | 5310 | if (!(BUFFERP (w->contents) && XBUFFER (w->contents) == current_buffer)) |
| 5246 | && XBUFFER (w->buffer) == current_buffer)) | 5311 | /* This test is needed to make sure PT/PT_BYTE make sense in w->contents |
| 5247 | /* This test is needed to make sure PT/PT_BYTE make sense in w->buffer | ||
| 5248 | when passed below to set_marker_both. */ | 5312 | when passed below to set_marker_both. */ |
| 5249 | error ("move-to-window-line called from unrelated buffer"); | 5313 | error ("move-to-window-line called from unrelated buffer"); |
| 5250 | 5314 | ||
| @@ -5254,7 +5318,7 @@ zero means top of window, negative means relative to bottom of window. */) | |||
| 5254 | { | 5318 | { |
| 5255 | int height = window_internal_height (w); | 5319 | int height = window_internal_height (w); |
| 5256 | Fvertical_motion (make_number (- (height / 2)), window); | 5320 | Fvertical_motion (make_number (- (height / 2)), window); |
| 5257 | set_marker_both (w->start, w->buffer, PT, PT_BYTE); | 5321 | set_marker_both (w->start, w->contents, PT, PT_BYTE); |
| 5258 | w->start_at_line_beg = !NILP (Fbolp ()); | 5322 | w->start_at_line_beg = !NILP (Fbolp ()); |
| 5259 | w->force_start = 1; | 5323 | w->force_start = 1; |
| 5260 | } | 5324 | } |
| @@ -5318,7 +5382,7 @@ struct save_window_data | |||
| 5318 | Lisp_Object saved_windows; | 5382 | Lisp_Object saved_windows; |
| 5319 | 5383 | ||
| 5320 | /* All fields above are traced by the GC. | 5384 | /* All fields above are traced by the GC. |
| 5321 | From `fame-cols' down, the fields are ignored by the GC. */ | 5385 | From `frame-cols' down, the fields are ignored by the GC. */ |
| 5322 | 5386 | ||
| 5323 | int frame_cols, frame_lines, frame_menu_bar_lines; | 5387 | int frame_cols, frame_lines, frame_menu_bar_lines; |
| 5324 | int frame_tool_bar_lines; | 5388 | int frame_tool_bar_lines; |
| @@ -5380,8 +5444,7 @@ the return value is nil. Otherwise the value is t. */) | |||
| 5380 | struct Lisp_Vector *saved_windows; | 5444 | struct Lisp_Vector *saved_windows; |
| 5381 | Lisp_Object new_current_buffer; | 5445 | Lisp_Object new_current_buffer; |
| 5382 | Lisp_Object frame; | 5446 | Lisp_Object frame; |
| 5383 | Lisp_Object auto_buffer_name; | 5447 | struct frame *f; |
| 5384 | FRAME_PTR f; | ||
| 5385 | ptrdiff_t old_point = -1; | 5448 | ptrdiff_t old_point = -1; |
| 5386 | 5449 | ||
| 5387 | CHECK_WINDOW_CONFIGURATION (configuration); | 5450 | CHECK_WINDOW_CONFIGURATION (configuration); |
| @@ -5390,7 +5453,7 @@ the return value is nil. Otherwise the value is t. */) | |||
| 5390 | saved_windows = XVECTOR (data->saved_windows); | 5453 | saved_windows = XVECTOR (data->saved_windows); |
| 5391 | 5454 | ||
| 5392 | new_current_buffer = data->current_buffer; | 5455 | new_current_buffer = data->current_buffer; |
| 5393 | if (NILP (BVAR (XBUFFER (new_current_buffer), name))) | 5456 | if (!BUFFER_LIVE_P (XBUFFER (new_current_buffer))) |
| 5394 | new_current_buffer = Qnil; | 5457 | new_current_buffer = Qnil; |
| 5395 | else | 5458 | else |
| 5396 | { | 5459 | { |
| @@ -5405,11 +5468,11 @@ the return value is nil. Otherwise the value is t. */) | |||
| 5405 | window-point of the final-selected-window to the window-point of | 5468 | window-point of the final-selected-window to the window-point of |
| 5406 | the current-selected-window. So we have to be careful which | 5469 | the current-selected-window. So we have to be careful which |
| 5407 | point of the current-buffer we copy into old_point. */ | 5470 | point of the current-buffer we copy into old_point. */ |
| 5408 | if (EQ (XWINDOW (data->current_window)->buffer, new_current_buffer) | 5471 | if (EQ (XWINDOW (data->current_window)->contents, new_current_buffer) |
| 5409 | && WINDOWP (selected_window) | 5472 | && WINDOWP (selected_window) |
| 5410 | && EQ (XWINDOW (selected_window)->buffer, new_current_buffer) | 5473 | && EQ (XWINDOW (selected_window)->contents, new_current_buffer) |
| 5411 | && !EQ (selected_window, data->current_window)) | 5474 | && !EQ (selected_window, data->current_window)) |
| 5412 | old_point = XMARKER (XWINDOW (data->current_window)->pointm)->charpos; | 5475 | old_point = marker_position (XWINDOW (data->current_window)->pointm); |
| 5413 | else | 5476 | else |
| 5414 | old_point = PT; | 5477 | old_point = PT; |
| 5415 | else | 5478 | else |
| @@ -5421,10 +5484,10 @@ the return value is nil. Otherwise the value is t. */) | |||
| 5421 | So if possible we want this arbitrary choice of "which point" to | 5484 | So if possible we want this arbitrary choice of "which point" to |
| 5422 | be the one from the to-be-selected-window so as to prevent this | 5485 | be the one from the to-be-selected-window so as to prevent this |
| 5423 | window's cursor from being copied from another window. */ | 5486 | window's cursor from being copied from another window. */ |
| 5424 | if (EQ (XWINDOW (data->current_window)->buffer, new_current_buffer) | 5487 | if (EQ (XWINDOW (data->current_window)->contents, new_current_buffer) |
| 5425 | /* If current_window = selected_window, its point is in BUF_PT. */ | 5488 | /* If current_window = selected_window, its point is in BUF_PT. */ |
| 5426 | && !EQ (selected_window, data->current_window)) | 5489 | && !EQ (selected_window, data->current_window)) |
| 5427 | old_point = XMARKER (XWINDOW (data->current_window)->pointm)->charpos; | 5490 | old_point = marker_position (XWINDOW (data->current_window)->pointm); |
| 5428 | else | 5491 | else |
| 5429 | old_point = BUF_PT (XBUFFER (new_current_buffer)); | 5492 | old_point = BUF_PT (XBUFFER (new_current_buffer)); |
| 5430 | } | 5493 | } |
| @@ -5456,9 +5519,24 @@ the return value is nil. Otherwise the value is t. */) | |||
| 5456 | int previous_frame_menu_bar_lines = FRAME_MENU_BAR_LINES (f); | 5519 | int previous_frame_menu_bar_lines = FRAME_MENU_BAR_LINES (f); |
| 5457 | int previous_frame_tool_bar_lines = FRAME_TOOL_BAR_LINES (f); | 5520 | int previous_frame_tool_bar_lines = FRAME_TOOL_BAR_LINES (f); |
| 5458 | 5521 | ||
| 5522 | /* Don't do this within the main loop below: This may call Lisp | ||
| 5523 | code and is thus potentially unsafe while input is blocked. */ | ||
| 5524 | for (k = 0; k < saved_windows->header.size; k++) | ||
| 5525 | { | ||
| 5526 | p = SAVED_WINDOW_N (saved_windows, k); | ||
| 5527 | window = p->window; | ||
| 5528 | w = XWINDOW (window); | ||
| 5529 | if (BUFFERP (w->contents) | ||
| 5530 | && !EQ (w->contents, p->buffer) | ||
| 5531 | && BUFFER_LIVE_P (XBUFFER (p->buffer))) | ||
| 5532 | /* If a window we restore gets another buffer, record the | ||
| 5533 | window's old buffer. */ | ||
| 5534 | call1 (Qrecord_window_buffer, window); | ||
| 5535 | } | ||
| 5536 | |||
| 5459 | /* The mouse highlighting code could get screwed up | 5537 | /* The mouse highlighting code could get screwed up |
| 5460 | if it runs during this. */ | 5538 | if it runs during this. */ |
| 5461 | BLOCK_INPUT; | 5539 | block_input (); |
| 5462 | 5540 | ||
| 5463 | if (data->frame_lines != previous_frame_lines | 5541 | if (data->frame_lines != previous_frame_lines |
| 5464 | || data->frame_cols != previous_frame_cols) | 5542 | || data->frame_cols != previous_frame_cols) |
| @@ -5488,13 +5566,13 @@ the return value is nil. Otherwise the value is t. */) | |||
| 5488 | window holds garbage.) We do this now, before | 5566 | window holds garbage.) We do this now, before |
| 5489 | restoring the window contents, and prevent it from | 5567 | restoring the window contents, and prevent it from |
| 5490 | being done later on when we select a new window. */ | 5568 | being done later on when we select a new window. */ |
| 5491 | if (! NILP (XWINDOW (selected_window)->buffer)) | 5569 | if (! NILP (XWINDOW (selected_window)->contents)) |
| 5492 | { | 5570 | { |
| 5493 | w = XWINDOW (selected_window); | 5571 | w = XWINDOW (selected_window); |
| 5494 | set_marker_both (w->pointm, | 5572 | set_marker_both (w->pointm, |
| 5495 | w->buffer, | 5573 | w->contents, |
| 5496 | BUF_PT (XBUFFER (w->buffer)), | 5574 | BUF_PT (XBUFFER (w->contents)), |
| 5497 | BUF_PT_BYTE (XBUFFER (w->buffer))); | 5575 | BUF_PT_BYTE (XBUFFER (w->contents))); |
| 5498 | } | 5576 | } |
| 5499 | 5577 | ||
| 5500 | windows_or_buffers_changed++; | 5578 | windows_or_buffers_changed++; |
| @@ -5505,9 +5583,8 @@ the return value is nil. Otherwise the value is t. */) | |||
| 5505 | really like to do is to free only those matrices not reused | 5583 | really like to do is to free only those matrices not reused |
| 5506 | below. */ | 5584 | below. */ |
| 5507 | root_window = XWINDOW (FRAME_ROOT_WINDOW (f)); | 5585 | root_window = XWINDOW (FRAME_ROOT_WINDOW (f)); |
| 5508 | leaf_windows | 5586 | leaf_windows = alloca (count_windows (root_window) |
| 5509 | = (struct window **) alloca (count_windows (root_window) | 5587 | * sizeof *leaf_windows); |
| 5510 | * sizeof (struct window *)); | ||
| 5511 | n_leaf_windows = get_leaf_windows (root_window, leaf_windows, 0); | 5588 | n_leaf_windows = get_leaf_windows (root_window, leaf_windows, 0); |
| 5512 | 5589 | ||
| 5513 | /* Kludge Alert! | 5590 | /* Kludge Alert! |
| @@ -5524,60 +5601,51 @@ the return value is nil. Otherwise the value is t. */) | |||
| 5524 | p = SAVED_WINDOW_N (saved_windows, k); | 5601 | p = SAVED_WINDOW_N (saved_windows, k); |
| 5525 | window = p->window; | 5602 | window = p->window; |
| 5526 | w = XWINDOW (window); | 5603 | w = XWINDOW (window); |
| 5527 | w->next = Qnil; | 5604 | wset_next (w, Qnil); |
| 5528 | 5605 | ||
| 5529 | if (!NILP (p->parent)) | 5606 | if (!NILP (p->parent)) |
| 5530 | w->parent = SAVED_WINDOW_N (saved_windows, | 5607 | wset_parent |
| 5531 | XFASTINT (p->parent))->window; | 5608 | (w, SAVED_WINDOW_N (saved_windows, XFASTINT (p->parent))->window); |
| 5532 | else | 5609 | else |
| 5533 | w->parent = Qnil; | 5610 | wset_parent (w, Qnil); |
| 5534 | 5611 | ||
| 5535 | if (!NILP (p->prev)) | 5612 | if (!NILP (p->prev)) |
| 5536 | { | 5613 | { |
| 5537 | w->prev = SAVED_WINDOW_N (saved_windows, | 5614 | wset_prev |
| 5538 | XFASTINT (p->prev))->window; | 5615 | (w, SAVED_WINDOW_N (saved_windows, XFASTINT (p->prev))->window); |
| 5539 | XWINDOW (w->prev)->next = p->window; | 5616 | wset_next (XWINDOW (w->prev), p->window); |
| 5540 | } | 5617 | } |
| 5541 | else | 5618 | else |
| 5542 | { | 5619 | { |
| 5543 | w->prev = Qnil; | 5620 | wset_prev (w, Qnil); |
| 5544 | if (!NILP (w->parent)) | 5621 | if (!NILP (w->parent)) |
| 5545 | { | 5622 | wset_combination (XWINDOW (w->parent), |
| 5546 | if (EQ (p->total_cols, XWINDOW (w->parent)->total_cols)) | 5623 | (XINT (p->total_cols) |
| 5547 | { | 5624 | != XWINDOW (w->parent)->total_cols), |
| 5548 | XWINDOW (w->parent)->vchild = p->window; | 5625 | p->window); |
| 5549 | XWINDOW (w->parent)->hchild = Qnil; | ||
| 5550 | } | ||
| 5551 | else | ||
| 5552 | { | ||
| 5553 | XWINDOW (w->parent)->hchild = p->window; | ||
| 5554 | XWINDOW (w->parent)->vchild = Qnil; | ||
| 5555 | } | ||
| 5556 | } | ||
| 5557 | } | 5626 | } |
| 5558 | 5627 | ||
| 5559 | /* If we squirreled away the buffer in the window's height, | 5628 | /* If we squirreled away the buffer, restore it now. */ |
| 5560 | restore it now. */ | 5629 | if (BUFFERP (w->combination_limit)) |
| 5561 | if (BUFFERP (w->total_lines)) | 5630 | wset_buffer (w, w->combination_limit); |
| 5562 | w->buffer = w->total_lines; | 5631 | w->left_col = XFASTINT (p->left_col); |
| 5563 | w->left_col = p->left_col; | 5632 | w->top_line = XFASTINT (p->top_line); |
| 5564 | w->top_line = p->top_line; | 5633 | w->total_cols = XFASTINT (p->total_cols); |
| 5565 | w->total_cols = p->total_cols; | 5634 | w->total_lines = XFASTINT (p->total_lines); |
| 5566 | w->total_lines = p->total_lines; | 5635 | wset_normal_cols (w, p->normal_cols); |
| 5567 | w->normal_cols = p->normal_cols; | 5636 | wset_normal_lines (w, p->normal_lines); |
| 5568 | w->normal_lines = p->normal_lines; | 5637 | w->hscroll = XFASTINT (p->hscroll); |
| 5569 | w->hscroll = p->hscroll; | 5638 | w->min_hscroll = XFASTINT (p->min_hscroll); |
| 5570 | w->min_hscroll = p->min_hscroll; | 5639 | wset_display_table (w, p->display_table); |
| 5571 | w->display_table = p->display_table; | 5640 | w->left_margin_cols = XINT (p->left_margin_cols); |
| 5572 | w->left_margin_cols = p->left_margin_cols; | 5641 | w->right_margin_cols = XINT (p->right_margin_cols); |
| 5573 | w->right_margin_cols = p->right_margin_cols; | 5642 | w->left_fringe_width = XINT (p->left_fringe_width); |
| 5574 | w->left_fringe_width = p->left_fringe_width; | 5643 | w->right_fringe_width = XINT (p->right_fringe_width); |
| 5575 | w->right_fringe_width = p->right_fringe_width; | 5644 | w->fringes_outside_margins = !NILP (p->fringes_outside_margins); |
| 5576 | w->fringes_outside_margins = p->fringes_outside_margins; | 5645 | w->scroll_bar_width = XINT (p->scroll_bar_width); |
| 5577 | w->scroll_bar_width = p->scroll_bar_width; | 5646 | wset_vertical_scroll_bar_type (w, p->vertical_scroll_bar_type); |
| 5578 | w->vertical_scroll_bar_type = p->vertical_scroll_bar_type; | 5647 | wset_dedicated (w, p->dedicated); |
| 5579 | w->dedicated = p->dedicated; | 5648 | wset_combination_limit (w, p->combination_limit); |
| 5580 | w->combination_limit = p->combination_limit; | ||
| 5581 | /* Restore any window parameters that have been saved. | 5649 | /* Restore any window parameters that have been saved. |
| 5582 | Parameters that have not been saved are left alone. */ | 5650 | Parameters that have not been saved are left alone. */ |
| 5583 | for (tem = p->window_parameters; CONSP (tem); tem = XCDR (tem)) | 5651 | for (tem = p->window_parameters; CONSP (tem); tem = XCDR (tem)) |
| @@ -5600,22 +5668,16 @@ the return value is nil. Otherwise the value is t. */) | |||
| 5600 | } | 5668 | } |
| 5601 | } | 5669 | } |
| 5602 | 5670 | ||
| 5603 | XSETFASTINT (w->last_modified, 0); | 5671 | if (BUFFERP (p->buffer) && BUFFER_LIVE_P (XBUFFER (p->buffer))) |
| 5604 | XSETFASTINT (w->last_overlay_modified, 0); | ||
| 5605 | |||
| 5606 | /* Reinstall the saved buffer and pointers into it. */ | ||
| 5607 | if (NILP (p->buffer)) | ||
| 5608 | /* An internal window. */ | ||
| 5609 | w->buffer = p->buffer; | ||
| 5610 | else if (!NILP (BVAR (XBUFFER (p->buffer), name))) | ||
| 5611 | /* If saved buffer is alive, install it. */ | 5672 | /* If saved buffer is alive, install it. */ |
| 5612 | { | 5673 | { |
| 5613 | w->buffer = p->buffer; | 5674 | wset_buffer (w, p->buffer); |
| 5614 | w->start_at_line_beg = !NILP (p->start_at_line_beg); | 5675 | w->start_at_line_beg = !NILP (p->start_at_line_beg); |
| 5615 | set_marker_restricted (w->start, p->start, w->buffer); | 5676 | set_marker_restricted (w->start, p->start, w->contents); |
| 5616 | set_marker_restricted (w->pointm, p->pointm, w->buffer); | 5677 | set_marker_restricted (w->pointm, p->pointm, |
| 5617 | Fset_marker (BVAR (XBUFFER (w->buffer), mark), | 5678 | w->contents); |
| 5618 | p->mark, w->buffer); | 5679 | Fset_marker (BVAR (XBUFFER (w->contents), mark), |
| 5680 | p->mark, w->contents); | ||
| 5619 | 5681 | ||
| 5620 | /* As documented in Fcurrent_window_configuration, don't | 5682 | /* As documented in Fcurrent_window_configuration, don't |
| 5621 | restore the location of point in the buffer which was | 5683 | restore the location of point in the buffer which was |
| @@ -5623,65 +5685,55 @@ the return value is nil. Otherwise the value is t. */) | |||
| 5623 | if (!EQ (p->buffer, new_current_buffer) | 5685 | if (!EQ (p->buffer, new_current_buffer) |
| 5624 | && XBUFFER (p->buffer) == current_buffer) | 5686 | && XBUFFER (p->buffer) == current_buffer) |
| 5625 | Fgoto_char (w->pointm); | 5687 | Fgoto_char (w->pointm); |
| 5626 | } | 5688 | } |
| 5627 | else if (!NILP (w->buffer) && !NILP (BVAR (XBUFFER (w->buffer), name))) | 5689 | else if (BUFFERP (w->contents) && BUFFER_LIVE_P (XBUFFER (w->contents))) |
| 5628 | /* Keep window's old buffer; make sure the markers are | 5690 | /* Keep window's old buffer; make sure the markers are real. */ |
| 5629 | real. */ | ||
| 5630 | { | 5691 | { |
| 5631 | /* Set window markers at start of visible range. */ | 5692 | /* Set window markers at start of visible range. */ |
| 5632 | if (XMARKER (w->start)->buffer == 0) | 5693 | if (XMARKER (w->start)->buffer == 0) |
| 5633 | set_marker_restricted (w->start, make_number (0), | 5694 | set_marker_restricted_both (w->start, w->contents, 0, 0); |
| 5634 | w->buffer); | ||
| 5635 | if (XMARKER (w->pointm)->buffer == 0) | 5695 | if (XMARKER (w->pointm)->buffer == 0) |
| 5636 | set_marker_restricted_both (w->pointm, w->buffer, | 5696 | set_marker_restricted_both |
| 5637 | BUF_PT (XBUFFER (w->buffer)), | 5697 | (w->pointm, w->contents, |
| 5638 | BUF_PT_BYTE (XBUFFER (w->buffer))); | 5698 | BUF_PT (XBUFFER (w->contents)), |
| 5699 | BUF_PT_BYTE (XBUFFER (w->contents))); | ||
| 5639 | w->start_at_line_beg = 1; | 5700 | w->start_at_line_beg = 1; |
| 5640 | } | 5701 | } |
| 5641 | else if (STRINGP (auto_buffer_name = | 5702 | else if (!NILP (w->start)) |
| 5642 | Fwindow_parameter (window, Qauto_buffer_name)) | 5703 | /* Leaf window has no live buffer, get one. */ |
| 5643 | && SCHARS (auto_buffer_name) != 0 | ||
| 5644 | && !NILP (w->buffer = Fget_buffer_create (auto_buffer_name))) | ||
| 5645 | { | ||
| 5646 | set_marker_restricted (w->start, make_number (0), w->buffer); | ||
| 5647 | set_marker_restricted (w->pointm, make_number (0), w->buffer); | ||
| 5648 | w->start_at_line_beg = 1; | ||
| 5649 | } | ||
| 5650 | else | ||
| 5651 | /* Window has no live buffer, get one. */ | ||
| 5652 | { | 5704 | { |
| 5653 | /* Get the buffer via other_buffer_safely in order to | 5705 | /* Get the buffer via other_buffer_safely in order to |
| 5654 | avoid showing an unimportant buffer and, if necessary, to | 5706 | avoid showing an unimportant buffer and, if necessary, to |
| 5655 | recreate *scratch* in the course (part of Juanma's bs-show | 5707 | recreate *scratch* in the course (part of Juanma's bs-show |
| 5656 | scenario from March 2011). */ | 5708 | scenario from March 2011). */ |
| 5657 | w->buffer = other_buffer_safely (Fcurrent_buffer ()); | 5709 | wset_buffer (w, other_buffer_safely (Fcurrent_buffer ())); |
| 5658 | /* This will set the markers to beginning of visible | 5710 | /* This will set the markers to beginning of visible |
| 5659 | range. */ | 5711 | range. */ |
| 5660 | set_marker_restricted (w->start, make_number (0), w->buffer); | 5712 | set_marker_restricted_both (w->start, w->contents, 0, 0); |
| 5661 | set_marker_restricted (w->pointm, make_number (0), w->buffer); | 5713 | set_marker_restricted_both (w->pointm, w->contents, 0, 0); |
| 5662 | w->start_at_line_beg = 1; | 5714 | w->start_at_line_beg = 1; |
| 5663 | if (!NILP (w->dedicated)) | 5715 | if (!NILP (w->dedicated)) |
| 5664 | /* Record this window as dead. */ | 5716 | /* Record this window as dead. */ |
| 5665 | dead_windows = Fcons (window, dead_windows); | 5717 | dead_windows = Fcons (window, dead_windows); |
| 5666 | /* Make sure window is no more dedicated. */ | 5718 | /* Make sure window is no more dedicated. */ |
| 5667 | w->dedicated = Qnil; | 5719 | wset_dedicated (w, Qnil); |
| 5668 | } | 5720 | } |
| 5669 | } | 5721 | } |
| 5670 | 5722 | ||
| 5671 | FRAME_ROOT_WINDOW (f) = data->root_window; | 5723 | fset_root_window (f, data->root_window); |
| 5672 | /* Arrange *not* to restore point in the buffer that was | 5724 | /* Arrange *not* to restore point in the buffer that was |
| 5673 | current when the window configuration was saved. */ | 5725 | current when the window configuration was saved. */ |
| 5674 | if (EQ (XWINDOW (data->current_window)->buffer, new_current_buffer)) | 5726 | if (EQ (XWINDOW (data->current_window)->contents, new_current_buffer)) |
| 5675 | set_marker_restricted (XWINDOW (data->current_window)->pointm, | 5727 | set_marker_restricted (XWINDOW (data->current_window)->pointm, |
| 5676 | make_number (old_point), | 5728 | make_number (old_point), |
| 5677 | XWINDOW (data->current_window)->buffer); | 5729 | XWINDOW (data->current_window)->contents); |
| 5678 | 5730 | ||
| 5679 | /* In the following call to `select-window', prevent "swapping out | 5731 | /* In the following call to `select-window', prevent "swapping out |
| 5680 | point" in the old selected window using the buffer that has | 5732 | point" in the old selected window using the buffer that has |
| 5681 | been restored into it. We already swapped out that point from | 5733 | been restored into it. We already swapped out that point from |
| 5682 | that window's old buffer. */ | 5734 | that window's old buffer. */ |
| 5683 | select_window (data->current_window, Qnil, 1); | 5735 | select_window (data->current_window, Qnil, 1); |
| 5684 | BVAR (XBUFFER (XWINDOW (selected_window)->buffer), last_selected_window) | 5736 | BVAR (XBUFFER (XWINDOW (selected_window)->contents), last_selected_window) |
| 5685 | = selected_window; | 5737 | = selected_window; |
| 5686 | 5738 | ||
| 5687 | if (NILP (data->focus_frame) | 5739 | if (NILP (data->focus_frame) |
| @@ -5715,19 +5767,14 @@ the return value is nil. Otherwise the value is t. */) | |||
| 5715 | /* Now, free glyph matrices in windows that were not reused. */ | 5767 | /* Now, free glyph matrices in windows that were not reused. */ |
| 5716 | for (i = n = 0; i < n_leaf_windows; ++i) | 5768 | for (i = n = 0; i < n_leaf_windows; ++i) |
| 5717 | { | 5769 | { |
| 5718 | if (NILP (leaf_windows[i]->buffer)) | 5770 | if (NILP (leaf_windows[i]->contents)) |
| 5719 | { | 5771 | free_window_matrices (leaf_windows[i]); |
| 5720 | /* Assert it's not reused as a combination. */ | 5772 | else if (EQ (leaf_windows[i]->contents, new_current_buffer)) |
| 5721 | xassert (NILP (leaf_windows[i]->hchild) | ||
| 5722 | && NILP (leaf_windows[i]->vchild)); | ||
| 5723 | free_window_matrices (leaf_windows[i]); | ||
| 5724 | } | ||
| 5725 | else if (EQ (leaf_windows[i]->buffer, new_current_buffer)) | ||
| 5726 | ++n; | 5773 | ++n; |
| 5727 | } | 5774 | } |
| 5728 | 5775 | ||
| 5729 | adjust_glyphs (f); | 5776 | adjust_glyphs (f); |
| 5730 | UNBLOCK_INPUT; | 5777 | unblock_input (); |
| 5731 | 5778 | ||
| 5732 | /* Scan dead buffer windows. */ | 5779 | /* Scan dead buffer windows. */ |
| 5733 | for (; CONSP (dead_windows); dead_windows = XCDR (dead_windows)) | 5780 | for (; CONSP (dead_windows); dead_windows = XCDR (dead_windows)) |
| @@ -5749,7 +5796,13 @@ the return value is nil. Otherwise the value is t. */) | |||
| 5749 | } | 5796 | } |
| 5750 | 5797 | ||
| 5751 | if (!NILP (new_current_buffer)) | 5798 | if (!NILP (new_current_buffer)) |
| 5752 | Fset_buffer (new_current_buffer); | 5799 | { |
| 5800 | Fset_buffer (new_current_buffer); | ||
| 5801 | /* If the new current buffer doesn't appear in the selected | ||
| 5802 | window, go to its old point (see bug#12208). */ | ||
| 5803 | if (!EQ (XWINDOW (data->current_window)->contents, new_current_buffer)) | ||
| 5804 | Fgoto_char (make_number (old_point)); | ||
| 5805 | } | ||
| 5753 | 5806 | ||
| 5754 | Vminibuf_scroll_window = data->minibuf_scroll_window; | 5807 | Vminibuf_scroll_window = data->minibuf_scroll_window; |
| 5755 | minibuf_selected_window = data->minibuf_selected_window; | 5808 | minibuf_selected_window = data->minibuf_selected_window; |
| @@ -5757,9 +5810,17 @@ the return value is nil. Otherwise the value is t. */) | |||
| 5757 | return (FRAME_LIVE_P (f) ? Qt : Qnil); | 5810 | return (FRAME_LIVE_P (f) ? Qt : Qnil); |
| 5758 | } | 5811 | } |
| 5759 | 5812 | ||
| 5813 | void | ||
| 5814 | restore_window_configuration (Lisp_Object configuration) | ||
| 5815 | { | ||
| 5816 | Fset_window_configuration (configuration); | ||
| 5817 | } | ||
| 5818 | |||
| 5819 | |||
| 5820 | /* If WINDOW is an internal window, recursively delete all child windows | ||
| 5821 | reachable via the next and contents slots of WINDOW. Otherwise setup | ||
| 5822 | WINDOW to not show any buffer. */ | ||
| 5760 | 5823 | ||
| 5761 | /* Recursively delete all child windows reachable via the next, vchild, | ||
| 5762 | and hchild slots of WINDOW. */ | ||
| 5763 | void | 5824 | void |
| 5764 | delete_all_child_windows (Lisp_Object window) | 5825 | delete_all_child_windows (Lisp_Object window) |
| 5765 | { | 5826 | { |
| @@ -5771,24 +5832,21 @@ delete_all_child_windows (Lisp_Object window) | |||
| 5771 | /* Delete WINDOW's siblings (we traverse postorderly). */ | 5832 | /* Delete WINDOW's siblings (we traverse postorderly). */ |
| 5772 | delete_all_child_windows (w->next); | 5833 | delete_all_child_windows (w->next); |
| 5773 | 5834 | ||
| 5774 | w->total_lines = w->buffer; /* See Fset_window_configuration for excuse. */ | 5835 | if (WINDOWP (w->contents)) |
| 5775 | |||
| 5776 | if (!NILP (w->vchild)) | ||
| 5777 | { | ||
| 5778 | delete_all_child_windows (w->vchild); | ||
| 5779 | w->vchild = Qnil; | ||
| 5780 | } | ||
| 5781 | else if (!NILP (w->hchild)) | ||
| 5782 | { | 5836 | { |
| 5783 | delete_all_child_windows (w->hchild); | 5837 | delete_all_child_windows (w->contents); |
| 5784 | w->hchild = Qnil; | 5838 | wset_combination (w, 0, Qnil); |
| 5785 | } | 5839 | } |
| 5786 | else if (!NILP (w->buffer)) | 5840 | else if (BUFFERP (w->contents)) |
| 5787 | { | 5841 | { |
| 5788 | unshow_buffer (w); | 5842 | unshow_buffer (w); |
| 5789 | unchain_marker (XMARKER (w->pointm)); | 5843 | unchain_marker (XMARKER (w->pointm)); |
| 5790 | unchain_marker (XMARKER (w->start)); | 5844 | unchain_marker (XMARKER (w->start)); |
| 5791 | w->buffer = Qnil; | 5845 | /* Since combination limit makes sense for an internal windows |
| 5846 | only, we use this slot to save the buffer for the sake of | ||
| 5847 | possible resurrection in Fset_window_configuration. */ | ||
| 5848 | wset_combination_limit (w, w->contents); | ||
| 5849 | wset_buffer (w, Qnil); | ||
| 5792 | } | 5850 | } |
| 5793 | 5851 | ||
| 5794 | Vwindow_list = Qnil; | 5852 | Vwindow_list = Qnil; |
| @@ -5800,10 +5858,8 @@ count_windows (register struct window *window) | |||
| 5800 | register int count = 1; | 5858 | register int count = 1; |
| 5801 | if (!NILP (window->next)) | 5859 | if (!NILP (window->next)) |
| 5802 | count += count_windows (XWINDOW (window->next)); | 5860 | count += count_windows (XWINDOW (window->next)); |
| 5803 | if (!NILP (window->vchild)) | 5861 | if (WINDOWP (window->contents)) |
| 5804 | count += count_windows (XWINDOW (window->vchild)); | 5862 | count += count_windows (XWINDOW (window->contents)); |
| 5805 | if (!NILP (window->hchild)) | ||
| 5806 | count += count_windows (XWINDOW (window->hchild)); | ||
| 5807 | return count; | 5863 | return count; |
| 5808 | } | 5864 | } |
| 5809 | 5865 | ||
| @@ -5815,10 +5871,8 @@ get_leaf_windows (struct window *w, struct window **flat, int i) | |||
| 5815 | { | 5871 | { |
| 5816 | while (w) | 5872 | while (w) |
| 5817 | { | 5873 | { |
| 5818 | if (!NILP (w->hchild)) | 5874 | if (WINDOWP (w->contents)) |
| 5819 | i = get_leaf_windows (XWINDOW (w->hchild), flat, i); | 5875 | i = get_leaf_windows (XWINDOW (w->contents), flat, i); |
| 5820 | else if (!NILP (w->vchild)) | ||
| 5821 | i = get_leaf_windows (XWINDOW (w->vchild), flat, i); | ||
| 5822 | else | 5876 | else |
| 5823 | flat[i++] = w; | 5877 | flat[i++] = w; |
| 5824 | 5878 | ||
| @@ -5847,7 +5901,7 @@ get_phys_cursor_glyph (struct window *w) | |||
| 5847 | if (!row->enabled_p) | 5901 | if (!row->enabled_p) |
| 5848 | return NULL; | 5902 | return NULL; |
| 5849 | 5903 | ||
| 5850 | if (XINT (w->hscroll)) | 5904 | if (w->hscroll) |
| 5851 | { | 5905 | { |
| 5852 | /* When the window is hscrolled, cursor hpos can legitimately be | 5906 | /* When the window is hscrolled, cursor hpos can legitimately be |
| 5853 | out of bounds, but we draw the cursor at the corresponding | 5907 | out of bounds, but we draw the cursor at the corresponding |
| @@ -5858,8 +5912,7 @@ get_phys_cursor_glyph (struct window *w) | |||
| 5858 | hpos = row->used[TEXT_AREA] - 1; | 5912 | hpos = row->used[TEXT_AREA] - 1; |
| 5859 | } | 5913 | } |
| 5860 | 5914 | ||
| 5861 | if (row->used[TEXT_AREA] > hpos | 5915 | if (0 <= hpos && hpos < row->used[TEXT_AREA]) |
| 5862 | && 0 <= hpos) | ||
| 5863 | glyph = row->glyphs[TEXT_AREA] + hpos; | 5916 | glyph = row->glyphs[TEXT_AREA] + hpos; |
| 5864 | else | 5917 | else |
| 5865 | glyph = NULL; | 5918 | glyph = NULL; |
| @@ -5875,29 +5928,29 @@ save_window_save (Lisp_Object window, struct Lisp_Vector *vector, int i) | |||
| 5875 | register struct window *w; | 5928 | register struct window *w; |
| 5876 | register Lisp_Object tem, pers, par; | 5929 | register Lisp_Object tem, pers, par; |
| 5877 | 5930 | ||
| 5878 | for (;!NILP (window); window = w->next) | 5931 | for (; !NILP (window); window = w->next) |
| 5879 | { | 5932 | { |
| 5880 | p = SAVED_WINDOW_N (vector, i); | 5933 | p = SAVED_WINDOW_N (vector, i); |
| 5881 | w = XWINDOW (window); | 5934 | w = XWINDOW (window); |
| 5882 | 5935 | ||
| 5883 | XSETFASTINT (w->temslot, i); i++; | 5936 | wset_temslot (w, make_number (i)); i++; |
| 5884 | p->window = window; | 5937 | p->window = window; |
| 5885 | p->buffer = w->buffer; | 5938 | p->buffer = (WINDOW_LEAF_P (w) ? w->contents : Qnil); |
| 5886 | p->left_col = w->left_col; | 5939 | p->left_col = make_number (w->left_col); |
| 5887 | p->top_line = w->top_line; | 5940 | p->top_line = make_number (w->top_line); |
| 5888 | p->total_cols = w->total_cols; | 5941 | p->total_cols = make_number (w->total_cols); |
| 5889 | p->total_lines = w->total_lines; | 5942 | p->total_lines = make_number (w->total_lines); |
| 5890 | p->normal_cols = w->normal_cols; | 5943 | p->normal_cols = w->normal_cols; |
| 5891 | p->normal_lines = w->normal_lines; | 5944 | p->normal_lines = w->normal_lines; |
| 5892 | p->hscroll = w->hscroll; | 5945 | XSETFASTINT (p->hscroll, w->hscroll); |
| 5893 | p->min_hscroll = w->min_hscroll; | 5946 | XSETFASTINT (p->min_hscroll, w->min_hscroll); |
| 5894 | p->display_table = w->display_table; | 5947 | p->display_table = w->display_table; |
| 5895 | p->left_margin_cols = w->left_margin_cols; | 5948 | p->left_margin_cols = make_number (w->left_margin_cols); |
| 5896 | p->right_margin_cols = w->right_margin_cols; | 5949 | p->right_margin_cols = make_number (w->right_margin_cols); |
| 5897 | p->left_fringe_width = w->left_fringe_width; | 5950 | p->left_fringe_width = make_number (w->left_fringe_width); |
| 5898 | p->right_fringe_width = w->right_fringe_width; | 5951 | p->right_fringe_width = make_number (w->right_fringe_width); |
| 5899 | p->fringes_outside_margins = w->fringes_outside_margins; | 5952 | p->fringes_outside_margins = w->fringes_outside_margins ? Qt : Qnil; |
| 5900 | p->scroll_bar_width = w->scroll_bar_width; | 5953 | p->scroll_bar_width = make_number (w->scroll_bar_width); |
| 5901 | p->vertical_scroll_bar_type = w->vertical_scroll_bar_type; | 5954 | p->vertical_scroll_bar_type = w->vertical_scroll_bar_type; |
| 5902 | p->dedicated = w->dedicated; | 5955 | p->dedicated = w->dedicated; |
| 5903 | p->combination_limit = w->combination_limit; | 5956 | p->combination_limit = w->combination_limit; |
| @@ -5949,18 +6002,15 @@ save_window_save (Lisp_Object window, struct Lisp_Vector *vector, int i) | |||
| 5949 | } | 6002 | } |
| 5950 | } | 6003 | } |
| 5951 | 6004 | ||
| 5952 | if (!NILP (w->buffer)) | 6005 | if (BUFFERP (w->contents)) |
| 5953 | { | 6006 | { |
| 5954 | /* Save w's value of point in the window configuration. If w | 6007 | /* Save w's value of point in the window configuration. If w |
| 5955 | is the selected window, then get the value of point from | 6008 | is the selected window, then get the value of point from |
| 5956 | the buffer; pointm is garbage in the selected window. */ | 6009 | the buffer; pointm is garbage in the selected window. */ |
| 5957 | if (EQ (window, selected_window)) | 6010 | if (EQ (window, selected_window)) |
| 5958 | { | 6011 | p->pointm = build_marker (XBUFFER (w->contents), |
| 5959 | p->pointm = Fmake_marker (); | 6012 | BUF_PT (XBUFFER (w->contents)), |
| 5960 | set_marker_both (p->pointm, w->buffer, | 6013 | BUF_PT_BYTE (XBUFFER (w->contents))); |
| 5961 | BUF_PT (XBUFFER (w->buffer)), | ||
| 5962 | BUF_PT_BYTE (XBUFFER (w->buffer))); | ||
| 5963 | } | ||
| 5964 | else | 6014 | else |
| 5965 | p->pointm = Fcopy_marker (w->pointm, Qnil); | 6015 | p->pointm = Fcopy_marker (w->pointm, Qnil); |
| 5966 | XMARKER (p->pointm)->insertion_type | 6016 | XMARKER (p->pointm)->insertion_type |
| @@ -5969,7 +6019,7 @@ save_window_save (Lisp_Object window, struct Lisp_Vector *vector, int i) | |||
| 5969 | p->start = Fcopy_marker (w->start, Qnil); | 6019 | p->start = Fcopy_marker (w->start, Qnil); |
| 5970 | p->start_at_line_beg = w->start_at_line_beg ? Qt : Qnil; | 6020 | p->start_at_line_beg = w->start_at_line_beg ? Qt : Qnil; |
| 5971 | 6021 | ||
| 5972 | tem = BVAR (XBUFFER (w->buffer), mark); | 6022 | tem = BVAR (XBUFFER (w->contents), mark); |
| 5973 | p->mark = Fcopy_marker (tem, Qnil); | 6023 | p->mark = Fcopy_marker (tem, Qnil); |
| 5974 | } | 6024 | } |
| 5975 | else | 6025 | else |
| @@ -5990,10 +6040,8 @@ save_window_save (Lisp_Object window, struct Lisp_Vector *vector, int i) | |||
| 5990 | else | 6040 | else |
| 5991 | p->prev = XWINDOW (w->prev)->temslot; | 6041 | p->prev = XWINDOW (w->prev)->temslot; |
| 5992 | 6042 | ||
| 5993 | if (!NILP (w->vchild)) | 6043 | if (WINDOWP (w->contents)) |
| 5994 | i = save_window_save (w->vchild, vector, i); | 6044 | i = save_window_save (w->contents, vector, i); |
| 5995 | if (!NILP (w->hchild)) | ||
| 5996 | i = save_window_save (w->hchild, vector, i); | ||
| 5997 | } | 6045 | } |
| 5998 | 6046 | ||
| 5999 | return i; | 6047 | return i; |
| @@ -6017,12 +6065,7 @@ saved by this function. */) | |||
| 6017 | register int n_windows; | 6065 | register int n_windows; |
| 6018 | register struct save_window_data *data; | 6066 | register struct save_window_data *data; |
| 6019 | register int i; | 6067 | register int i; |
| 6020 | FRAME_PTR f; | 6068 | struct frame *f = decode_live_frame (frame); |
| 6021 | |||
| 6022 | if (NILP (frame)) | ||
| 6023 | frame = selected_frame; | ||
| 6024 | CHECK_LIVE_FRAME (frame); | ||
| 6025 | f = XFRAME (frame); | ||
| 6026 | 6069 | ||
| 6027 | n_windows = count_windows (XWINDOW (FRAME_ROOT_WINDOW (f))); | 6070 | n_windows = count_windows (XWINDOW (FRAME_ROOT_WINDOW (f))); |
| 6028 | data = ALLOCATE_PSEUDOVECTOR (struct save_window_data, frame_cols, | 6071 | data = ALLOCATE_PSEUDOVECTOR (struct save_window_data, frame_cols, |
| @@ -6039,76 +6082,87 @@ saved by this function. */) | |||
| 6039 | data->minibuf_selected_window = minibuf_level > 0 ? minibuf_selected_window : Qnil; | 6082 | data->minibuf_selected_window = minibuf_level > 0 ? minibuf_selected_window : Qnil; |
| 6040 | data->root_window = FRAME_ROOT_WINDOW (f); | 6083 | data->root_window = FRAME_ROOT_WINDOW (f); |
| 6041 | data->focus_frame = FRAME_FOCUS_FRAME (f); | 6084 | data->focus_frame = FRAME_FOCUS_FRAME (f); |
| 6042 | tem = Fmake_vector (make_number (n_windows), Qnil); | 6085 | tem = make_uninit_vector (n_windows); |
| 6043 | data->saved_windows = tem; | 6086 | data->saved_windows = tem; |
| 6044 | for (i = 0; i < n_windows; i++) | 6087 | for (i = 0; i < n_windows; i++) |
| 6045 | XVECTOR (tem)->contents[i] | 6088 | ASET (tem, i, |
| 6046 | = Fmake_vector (make_number (VECSIZE (struct saved_window)), Qnil); | 6089 | Fmake_vector (make_number (VECSIZE (struct saved_window)), Qnil)); |
| 6047 | save_window_save (FRAME_ROOT_WINDOW (f), XVECTOR (tem), 0); | 6090 | save_window_save (FRAME_ROOT_WINDOW (f), XVECTOR (tem), 0); |
| 6048 | XSETWINDOW_CONFIGURATION (tem, data); | 6091 | XSETWINDOW_CONFIGURATION (tem, data); |
| 6049 | return (tem); | 6092 | return (tem); |
| 6050 | } | 6093 | } |
| 6094 | |||
| 6095 | /* Called after W's margins, fringes or scroll bars was adjusted. */ | ||
| 6096 | |||
| 6097 | static void | ||
| 6098 | apply_window_adjustment (struct window *w) | ||
| 6099 | { | ||
| 6100 | eassert (w); | ||
| 6101 | adjust_window_margins (w); | ||
| 6102 | clear_glyph_matrix (w->current_matrix); | ||
| 6103 | w->window_end_valid = 0; | ||
| 6104 | windows_or_buffers_changed++; | ||
| 6105 | adjust_glyphs (XFRAME (WINDOW_FRAME (w))); | ||
| 6106 | } | ||
| 6107 | |||
| 6051 | 6108 | ||
| 6052 | /*********************************************************************** | 6109 | /*********************************************************************** |
| 6053 | Marginal Areas | 6110 | Marginal Areas |
| 6054 | ***********************************************************************/ | 6111 | ***********************************************************************/ |
| 6055 | 6112 | ||
| 6056 | DEFUN ("set-window-margins", Fset_window_margins, Sset_window_margins, | 6113 | static struct window * |
| 6057 | 2, 3, 0, | 6114 | set_window_margins (struct window *w, Lisp_Object left_width, |
| 6058 | doc: /* Set width of marginal areas of window WINDOW. | 6115 | Lisp_Object right_width) |
| 6059 | If WINDOW is nil, set margins of the currently selected window. | ||
| 6060 | Second arg LEFT-WIDTH specifies the number of character cells to | ||
| 6061 | reserve for the left marginal area. Optional third arg RIGHT-WIDTH | ||
| 6062 | does the same for the right marginal area. A nil width parameter | ||
| 6063 | means no margin. */) | ||
| 6064 | (Lisp_Object window, Lisp_Object left_width, Lisp_Object right_width) | ||
| 6065 | { | 6116 | { |
| 6066 | struct window *w = decode_window (window); | 6117 | int left, right; |
| 6067 | 6118 | ||
| 6068 | /* Translate negative or zero widths to nil. | 6119 | /* FIXME: what about margins that are too wide? */ |
| 6069 | Margins that are too wide have to be checked elsewhere. */ | 6120 | left = (NILP (left_width) ? 0 |
| 6121 | : (CHECK_NATNUM (left_width), XINT (left_width))); | ||
| 6122 | right = (NILP (right_width) ? 0 | ||
| 6123 | : (CHECK_NATNUM (right_width), XINT (right_width))); | ||
| 6070 | 6124 | ||
| 6071 | if (!NILP (left_width)) | 6125 | if (w->left_margin_cols != left || w->right_margin_cols != right) |
| 6072 | { | 6126 | { |
| 6073 | CHECK_NUMBER (left_width); | 6127 | w->left_margin_cols = left; |
| 6074 | if (XINT (left_width) <= 0) | 6128 | w->right_margin_cols = right; |
| 6075 | left_width = Qnil; | 6129 | return w; |
| 6076 | } | 6130 | } |
| 6131 | return NULL; | ||
| 6132 | } | ||
| 6077 | 6133 | ||
| 6078 | if (!NILP (right_width)) | 6134 | DEFUN ("set-window-margins", Fset_window_margins, Sset_window_margins, |
| 6079 | { | 6135 | 2, 3, 0, |
| 6080 | CHECK_NUMBER (right_width); | 6136 | doc: /* Set width of marginal areas of window WINDOW. |
| 6081 | if (XINT (right_width) <= 0) | 6137 | WINDOW must be a live window and defaults to the selected one. |
| 6082 | right_width = Qnil; | ||
| 6083 | } | ||
| 6084 | |||
| 6085 | if (!EQ (w->left_margin_cols, left_width) | ||
| 6086 | || !EQ (w->right_margin_cols, right_width)) | ||
| 6087 | { | ||
| 6088 | w->left_margin_cols = left_width; | ||
| 6089 | w->right_margin_cols = right_width; | ||
| 6090 | |||
| 6091 | adjust_window_margins (w); | ||
| 6092 | 6138 | ||
| 6093 | ++windows_or_buffers_changed; | 6139 | Second arg LEFT-WIDTH specifies the number of character cells to |
| 6094 | adjust_glyphs (XFRAME (WINDOW_FRAME (w))); | 6140 | reserve for the left marginal area. Optional third arg RIGHT-WIDTH |
| 6095 | } | 6141 | does the same for the right marginal area. A nil width parameter |
| 6142 | means no margin. | ||
| 6096 | 6143 | ||
| 6097 | return Qnil; | 6144 | Return t if any margin was actually changed and nil otherwise. */) |
| 6145 | (Lisp_Object window, Lisp_Object left_width, Lisp_Object right_width) | ||
| 6146 | { | ||
| 6147 | struct window *w = set_window_margins (decode_live_window (window), | ||
| 6148 | left_width, right_width); | ||
| 6149 | return w ? (apply_window_adjustment (w), Qt) : Qnil; | ||
| 6098 | } | 6150 | } |
| 6099 | 6151 | ||
| 6100 | 6152 | ||
| 6101 | DEFUN ("window-margins", Fwindow_margins, Swindow_margins, | 6153 | DEFUN ("window-margins", Fwindow_margins, Swindow_margins, |
| 6102 | 0, 1, 0, | 6154 | 0, 1, 0, |
| 6103 | doc: /* Get width of marginal areas of window WINDOW. | 6155 | doc: /* Get width of marginal areas of window WINDOW. |
| 6104 | If WINDOW is omitted or nil, it defaults to the selected window. | 6156 | WINDOW must be a live window and defaults to the selected one. |
| 6157 | |||
| 6105 | Value is a cons of the form (LEFT-WIDTH . RIGHT-WIDTH). | 6158 | Value is a cons of the form (LEFT-WIDTH . RIGHT-WIDTH). |
| 6106 | If a marginal area does not exist, its width will be returned | 6159 | If a marginal area does not exist, its width will be returned |
| 6107 | as nil. */) | 6160 | as nil. */) |
| 6108 | (Lisp_Object window) | 6161 | (Lisp_Object window) |
| 6109 | { | 6162 | { |
| 6110 | struct window *w = decode_window (window); | 6163 | struct window *w = decode_live_window (window); |
| 6111 | return Fcons (w->left_margin_cols, w->right_margin_cols); | 6164 | return Fcons (w->left_margin_cols ? make_number (w->left_margin_cols) : Qnil, |
| 6165 | w->right_margin_cols ? make_number (w->right_margin_cols) : Qnil); | ||
| 6112 | } | 6166 | } |
| 6113 | 6167 | ||
| 6114 | 6168 | ||
| @@ -6117,11 +6171,36 @@ as nil. */) | |||
| 6117 | Fringes | 6171 | Fringes |
| 6118 | ***********************************************************************/ | 6172 | ***********************************************************************/ |
| 6119 | 6173 | ||
| 6174 | static struct window * | ||
| 6175 | set_window_fringes (struct window *w, Lisp_Object left_width, | ||
| 6176 | Lisp_Object right_width, Lisp_Object outside_margins) | ||
| 6177 | { | ||
| 6178 | int left, right, outside = !NILP (outside_margins); | ||
| 6179 | |||
| 6180 | left = (NILP (left_width) ? -1 | ||
| 6181 | : (CHECK_NATNUM (left_width), XINT (left_width))); | ||
| 6182 | right = (NILP (right_width) ? -1 | ||
| 6183 | : (CHECK_NATNUM (right_width), XINT (right_width))); | ||
| 6184 | |||
| 6185 | /* Do nothing on a tty or if nothing to actually change. */ | ||
| 6186 | if (FRAME_WINDOW_P (WINDOW_XFRAME (w)) | ||
| 6187 | && (w->left_fringe_width != left | ||
| 6188 | || w->right_fringe_width != right | ||
| 6189 | || w->fringes_outside_margins != outside)) | ||
| 6190 | { | ||
| 6191 | w->left_fringe_width = left; | ||
| 6192 | w->right_fringe_width = right; | ||
| 6193 | w->fringes_outside_margins = outside; | ||
| 6194 | return w; | ||
| 6195 | } | ||
| 6196 | return NULL; | ||
| 6197 | } | ||
| 6198 | |||
| 6120 | DEFUN ("set-window-fringes", Fset_window_fringes, Sset_window_fringes, | 6199 | DEFUN ("set-window-fringes", Fset_window_fringes, Sset_window_fringes, |
| 6121 | 2, 4, 0, | 6200 | 2, 4, 0, |
| 6122 | doc: /* Set the fringe widths of window WINDOW. | 6201 | doc: /* Set the fringe widths of window WINDOW. |
| 6123 | If WINDOW is nil, set the fringe widths of the currently selected | 6202 | WINDOW must be a live window and defaults to the selected one. |
| 6124 | window. | 6203 | |
| 6125 | Second arg LEFT-WIDTH specifies the number of pixels to reserve for | 6204 | Second arg LEFT-WIDTH specifies the number of pixels to reserve for |
| 6126 | the left fringe. Optional third arg RIGHT-WIDTH specifies the right | 6205 | the left fringe. Optional third arg RIGHT-WIDTH specifies the right |
| 6127 | fringe width. If a fringe width arg is nil, that means to use the | 6206 | fringe width. If a fringe width arg is nil, that means to use the |
| @@ -6129,52 +6208,32 @@ frame's default fringe width. Default fringe widths can be set with | |||
| 6129 | the command `set-fringe-style'. | 6208 | the command `set-fringe-style'. |
| 6130 | If optional fourth arg OUTSIDE-MARGINS is non-nil, draw the fringes | 6209 | If optional fourth arg OUTSIDE-MARGINS is non-nil, draw the fringes |
| 6131 | outside of the display margins. By default, fringes are drawn between | 6210 | outside of the display margins. By default, fringes are drawn between |
| 6132 | display marginal areas and the text area. */) | 6211 | display marginal areas and the text area. |
| 6133 | (Lisp_Object window, Lisp_Object left_width, Lisp_Object right_width, Lisp_Object outside_margins) | ||
| 6134 | { | ||
| 6135 | struct window *w = decode_window (window); | ||
| 6136 | |||
| 6137 | if (!NILP (left_width)) | ||
| 6138 | CHECK_NATNUM (left_width); | ||
| 6139 | if (!NILP (right_width)) | ||
| 6140 | CHECK_NATNUM (right_width); | ||
| 6141 | |||
| 6142 | /* Do nothing on a tty. */ | ||
| 6143 | if (FRAME_WINDOW_P (WINDOW_XFRAME (w)) | ||
| 6144 | && (!EQ (w->left_fringe_width, left_width) | ||
| 6145 | || !EQ (w->right_fringe_width, right_width) | ||
| 6146 | || !EQ (w->fringes_outside_margins, outside_margins))) | ||
| 6147 | { | ||
| 6148 | w->left_fringe_width = left_width; | ||
| 6149 | w->right_fringe_width = right_width; | ||
| 6150 | w->fringes_outside_margins = outside_margins; | ||
| 6151 | |||
| 6152 | adjust_window_margins (w); | ||
| 6153 | |||
| 6154 | clear_glyph_matrix (w->current_matrix); | ||
| 6155 | w->window_end_valid = Qnil; | ||
| 6156 | |||
| 6157 | ++windows_or_buffers_changed; | ||
| 6158 | adjust_glyphs (XFRAME (WINDOW_FRAME (w))); | ||
| 6159 | } | ||
| 6160 | 6212 | ||
| 6161 | return Qnil; | 6213 | Return t if any fringe was actually changed and nil otherwise. */) |
| 6214 | (Lisp_Object window, Lisp_Object left_width, | ||
| 6215 | Lisp_Object right_width, Lisp_Object outside_margins) | ||
| 6216 | { | ||
| 6217 | struct window *w | ||
| 6218 | = set_window_fringes (decode_live_window (window), | ||
| 6219 | left_width, right_width, outside_margins); | ||
| 6220 | return w ? (apply_window_adjustment (w), Qt) : Qnil; | ||
| 6162 | } | 6221 | } |
| 6163 | 6222 | ||
| 6164 | 6223 | ||
| 6165 | DEFUN ("window-fringes", Fwindow_fringes, Swindow_fringes, | 6224 | DEFUN ("window-fringes", Fwindow_fringes, Swindow_fringes, |
| 6166 | 0, 1, 0, | 6225 | 0, 1, 0, |
| 6167 | doc: /* Get width of fringes of window WINDOW. | 6226 | doc: /* Get width of fringes of window WINDOW. |
| 6168 | If WINDOW is omitted or nil, it defaults to the selected window. | 6227 | WINDOW must be a live window and defaults to the selected one. |
| 6228 | |||
| 6169 | Value is a list of the form (LEFT-WIDTH RIGHT-WIDTH OUTSIDE-MARGINS). */) | 6229 | Value is a list of the form (LEFT-WIDTH RIGHT-WIDTH OUTSIDE-MARGINS). */) |
| 6170 | (Lisp_Object window) | 6230 | (Lisp_Object window) |
| 6171 | { | 6231 | { |
| 6172 | struct window *w = decode_window (window); | 6232 | struct window *w = decode_live_window (window); |
| 6173 | 6233 | ||
| 6174 | return Fcons (make_number (WINDOW_LEFT_FRINGE_WIDTH (w)), | 6234 | return list3 (make_number (WINDOW_LEFT_FRINGE_WIDTH (w)), |
| 6175 | Fcons (make_number (WINDOW_RIGHT_FRINGE_WIDTH (w)), | 6235 | make_number (WINDOW_RIGHT_FRINGE_WIDTH (w)), |
| 6176 | Fcons ((WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w) | 6236 | WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w) ? Qt : Qnil); |
| 6177 | ? Qt : Qnil), Qnil))); | ||
| 6178 | } | 6237 | } |
| 6179 | 6238 | ||
| 6180 | 6239 | ||
| @@ -6183,28 +6242,14 @@ Value is a list of the form (LEFT-WIDTH RIGHT-WIDTH OUTSIDE-MARGINS). */) | |||
| 6183 | Scroll bars | 6242 | Scroll bars |
| 6184 | ***********************************************************************/ | 6243 | ***********************************************************************/ |
| 6185 | 6244 | ||
| 6186 | DEFUN ("set-window-scroll-bars", Fset_window_scroll_bars, | 6245 | static struct window * |
| 6187 | Sset_window_scroll_bars, 2, 4, 0, | 6246 | set_window_scroll_bars (struct window *w, Lisp_Object width, |
| 6188 | doc: /* Set width and type of scroll bars of window WINDOW. | 6247 | Lisp_Object vertical_type, Lisp_Object horizontal_type) |
| 6189 | If window is nil, set scroll bars of the currently selected window. | ||
| 6190 | Second parameter WIDTH specifies the pixel width for the scroll bar; | ||
| 6191 | this is automatically adjusted to a multiple of the frame column width. | ||
| 6192 | Third parameter VERTICAL-TYPE specifies the type of the vertical scroll | ||
| 6193 | bar: left, right, or nil. | ||
| 6194 | If WIDTH is nil, use the frame's scroll-bar width. | ||
| 6195 | If VERTICAL-TYPE is t, use the frame's scroll-bar type. | ||
| 6196 | Fourth parameter HORIZONTAL-TYPE is currently unused. */) | ||
| 6197 | (Lisp_Object window, Lisp_Object width, Lisp_Object vertical_type, Lisp_Object horizontal_type) | ||
| 6198 | { | 6248 | { |
| 6199 | struct window *w = decode_window (window); | 6249 | int iwidth = (NILP (width) ? -1 : (CHECK_NATNUM (width), XINT (width))); |
| 6200 | |||
| 6201 | if (!NILP (width)) | ||
| 6202 | { | ||
| 6203 | CHECK_RANGED_INTEGER (0, width, INT_MAX); | ||
| 6204 | 6250 | ||
| 6205 | if (XINT (width) == 0) | 6251 | if (iwidth == 0) |
| 6206 | vertical_type = Qnil; | 6252 | vertical_type = Qnil; |
| 6207 | } | ||
| 6208 | 6253 | ||
| 6209 | if (!(NILP (vertical_type) | 6254 | if (!(NILP (vertical_type) |
| 6210 | || EQ (vertical_type, Qleft) | 6255 | || EQ (vertical_type, Qleft) |
| @@ -6212,41 +6257,57 @@ Fourth parameter HORIZONTAL-TYPE is currently unused. */) | |||
| 6212 | || EQ (vertical_type, Qt))) | 6257 | || EQ (vertical_type, Qt))) |
| 6213 | error ("Invalid type of vertical scroll bar"); | 6258 | error ("Invalid type of vertical scroll bar"); |
| 6214 | 6259 | ||
| 6215 | if (!EQ (w->scroll_bar_width, width) | 6260 | if (w->scroll_bar_width != iwidth |
| 6216 | || !EQ (w->vertical_scroll_bar_type, vertical_type)) | 6261 | || !EQ (w->vertical_scroll_bar_type, vertical_type)) |
| 6217 | { | 6262 | { |
| 6218 | w->scroll_bar_width = width; | 6263 | w->scroll_bar_width = iwidth; |
| 6219 | w->vertical_scroll_bar_type = vertical_type; | 6264 | wset_vertical_scroll_bar_type (w, vertical_type); |
| 6220 | 6265 | return w; | |
| 6221 | adjust_window_margins (w); | 6266 | } |
| 6267 | return NULL; | ||
| 6268 | } | ||
| 6222 | 6269 | ||
| 6223 | clear_glyph_matrix (w->current_matrix); | 6270 | DEFUN ("set-window-scroll-bars", Fset_window_scroll_bars, |
| 6224 | w->window_end_valid = Qnil; | 6271 | Sset_window_scroll_bars, 2, 4, 0, |
| 6272 | doc: /* Set width and type of scroll bars of window WINDOW. | ||
| 6273 | WINDOW must be a live window and defaults to the selected one. | ||
| 6225 | 6274 | ||
| 6226 | ++windows_or_buffers_changed; | 6275 | Second parameter WIDTH specifies the pixel width for the scroll bar; |
| 6227 | adjust_glyphs (XFRAME (WINDOW_FRAME (w))); | 6276 | this is automatically adjusted to a multiple of the frame column width. |
| 6228 | } | 6277 | Third parameter VERTICAL-TYPE specifies the type of the vertical scroll |
| 6278 | bar: left, right, or nil. | ||
| 6279 | If WIDTH is nil, use the frame's scroll-bar width. | ||
| 6280 | If VERTICAL-TYPE is t, use the frame's scroll-bar type. | ||
| 6281 | Fourth parameter HORIZONTAL-TYPE is currently unused. | ||
| 6229 | 6282 | ||
| 6230 | return Qnil; | 6283 | Return t if scroll bars was actually changed and nil otherwise. */) |
| 6284 | (Lisp_Object window, Lisp_Object width, | ||
| 6285 | Lisp_Object vertical_type, Lisp_Object horizontal_type) | ||
| 6286 | { | ||
| 6287 | struct window *w | ||
| 6288 | = set_window_scroll_bars (decode_live_window (window), | ||
| 6289 | width, vertical_type, horizontal_type); | ||
| 6290 | return w ? (apply_window_adjustment (w), Qt) : Qnil; | ||
| 6231 | } | 6291 | } |
| 6232 | 6292 | ||
| 6233 | 6293 | ||
| 6234 | DEFUN ("window-scroll-bars", Fwindow_scroll_bars, Swindow_scroll_bars, | 6294 | DEFUN ("window-scroll-bars", Fwindow_scroll_bars, Swindow_scroll_bars, |
| 6235 | 0, 1, 0, | 6295 | 0, 1, 0, |
| 6236 | doc: /* Get width and type of scroll bars of window WINDOW. | 6296 | doc: /* Get width and type of scroll bars of window WINDOW. |
| 6237 | If WINDOW is omitted or nil, it defaults to the selected window. | 6297 | WINDOW must be a live window and defaults to the selected one. |
| 6298 | |||
| 6238 | Value is a list of the form (WIDTH COLS VERTICAL-TYPE HORIZONTAL-TYPE). | 6299 | Value is a list of the form (WIDTH COLS VERTICAL-TYPE HORIZONTAL-TYPE). |
| 6239 | If WIDTH is nil or TYPE is t, the window is using the frame's corresponding | 6300 | If WIDTH is nil or TYPE is t, the window is using the frame's corresponding |
| 6240 | value. */) | 6301 | value. */) |
| 6241 | (Lisp_Object window) | 6302 | (Lisp_Object window) |
| 6242 | { | 6303 | { |
| 6243 | struct window *w = decode_window (window); | 6304 | struct window *w = decode_live_window (window); |
| 6244 | return Fcons (make_number ((WINDOW_CONFIG_SCROLL_BAR_WIDTH (w) | 6305 | |
| 6306 | return list4 (make_number ((WINDOW_CONFIG_SCROLL_BAR_WIDTH (w) | ||
| 6245 | ? WINDOW_CONFIG_SCROLL_BAR_WIDTH (w) | 6307 | ? WINDOW_CONFIG_SCROLL_BAR_WIDTH (w) |
| 6246 | : WINDOW_SCROLL_BAR_AREA_WIDTH (w))), | 6308 | : WINDOW_SCROLL_BAR_AREA_WIDTH (w))), |
| 6247 | Fcons (make_number (WINDOW_SCROLL_BAR_COLS (w)), | 6309 | make_number (WINDOW_SCROLL_BAR_COLS (w)), |
| 6248 | Fcons (w->vertical_scroll_bar_type, | 6310 | w->vertical_scroll_bar_type, Qnil); |
| 6249 | Fcons (Qnil, Qnil)))); | ||
| 6250 | } | 6311 | } |
| 6251 | 6312 | ||
| 6252 | 6313 | ||
| @@ -6263,15 +6324,8 @@ optional second arg PIXELS-P means value is measured in pixels. */) | |||
| 6263 | (Lisp_Object window, Lisp_Object pixels_p) | 6324 | (Lisp_Object window, Lisp_Object pixels_p) |
| 6264 | { | 6325 | { |
| 6265 | Lisp_Object result; | 6326 | Lisp_Object result; |
| 6266 | struct frame *f; | 6327 | struct window *w = decode_live_window (window); |
| 6267 | struct window *w; | 6328 | struct frame *f = XFRAME (w->frame); |
| 6268 | |||
| 6269 | if (NILP (window)) | ||
| 6270 | window = selected_window; | ||
| 6271 | else | ||
| 6272 | CHECK_WINDOW (window); | ||
| 6273 | w = XWINDOW (window); | ||
| 6274 | f = XFRAME (w->frame); | ||
| 6275 | 6329 | ||
| 6276 | if (FRAME_WINDOW_P (f)) | 6330 | if (FRAME_WINDOW_P (f)) |
| 6277 | result = (NILP (pixels_p) | 6331 | result = (NILP (pixels_p) |
| @@ -6295,18 +6349,11 @@ result of this rounding. | |||
| 6295 | If PIXELS-P is non-nil, the return value is VSCROLL. */) | 6349 | If PIXELS-P is non-nil, the return value is VSCROLL. */) |
| 6296 | (Lisp_Object window, Lisp_Object vscroll, Lisp_Object pixels_p) | 6350 | (Lisp_Object window, Lisp_Object vscroll, Lisp_Object pixels_p) |
| 6297 | { | 6351 | { |
| 6298 | struct window *w; | 6352 | struct window *w = decode_live_window (window); |
| 6299 | struct frame *f; | 6353 | struct frame *f = XFRAME (w->frame); |
| 6300 | 6354 | ||
| 6301 | if (NILP (window)) | ||
| 6302 | window = selected_window; | ||
| 6303 | else | ||
| 6304 | CHECK_WINDOW (window); | ||
| 6305 | CHECK_NUMBER_OR_FLOAT (vscroll); | 6355 | CHECK_NUMBER_OR_FLOAT (vscroll); |
| 6306 | 6356 | ||
| 6307 | w = XWINDOW (window); | ||
| 6308 | f = XFRAME (w->frame); | ||
| 6309 | |||
| 6310 | if (FRAME_WINDOW_P (f)) | 6357 | if (FRAME_WINDOW_P (f)) |
| 6311 | { | 6358 | { |
| 6312 | int old_dy = w->vscroll; | 6359 | int old_dy = w->vscroll; |
| @@ -6324,7 +6371,7 @@ If PIXELS-P is non-nil, the return value is VSCROLL. */) | |||
| 6324 | adjust_glyphs (f); | 6371 | adjust_glyphs (f); |
| 6325 | 6372 | ||
| 6326 | /* Prevent redisplay shortcuts. */ | 6373 | /* Prevent redisplay shortcuts. */ |
| 6327 | XBUFFER (w->buffer)->prevent_redisplay_optimizations_p = 1; | 6374 | XBUFFER (w->contents)->prevent_redisplay_optimizations_p = 1; |
| 6328 | } | 6375 | } |
| 6329 | } | 6376 | } |
| 6330 | 6377 | ||
| @@ -6358,10 +6405,8 @@ foreach_window_1 (struct window *w, int (*fn) (struct window *, void *), void *u | |||
| 6358 | 6405 | ||
| 6359 | for (cont = 1; w && cont;) | 6406 | for (cont = 1; w && cont;) |
| 6360 | { | 6407 | { |
| 6361 | if (!NILP (w->hchild)) | 6408 | if (WINDOWP (w->contents)) |
| 6362 | cont = foreach_window_1 (XWINDOW (w->hchild), fn, user_data); | 6409 | cont = foreach_window_1 (XWINDOW (w->contents), fn, user_data); |
| 6363 | else if (!NILP (w->vchild)) | ||
| 6364 | cont = foreach_window_1 (XWINDOW (w->vchild), fn, user_data); | ||
| 6365 | else | 6410 | else |
| 6366 | cont = fn (w, user_data); | 6411 | cont = fn (w, user_data); |
| 6367 | 6412 | ||
| @@ -6371,38 +6416,6 @@ foreach_window_1 (struct window *w, int (*fn) (struct window *, void *), void *u | |||
| 6371 | return cont; | 6416 | return cont; |
| 6372 | } | 6417 | } |
| 6373 | 6418 | ||
| 6374 | |||
| 6375 | /* Freeze or unfreeze the window start of W unless it is a | ||
| 6376 | mini-window or the selected window. FREEZE_P non-null means freeze | ||
| 6377 | the window start. */ | ||
| 6378 | |||
| 6379 | static int | ||
| 6380 | freeze_window_start (struct window *w, void *freeze_p) | ||
| 6381 | { | ||
| 6382 | if (MINI_WINDOW_P (w) | ||
| 6383 | || (WINDOWP (selected_window) /* Can be nil in corner cases. */ | ||
| 6384 | && (w == XWINDOW (selected_window) | ||
| 6385 | || (MINI_WINDOW_P (XWINDOW (selected_window)) | ||
| 6386 | && ! NILP (Vminibuf_scroll_window) | ||
| 6387 | && w == XWINDOW (Vminibuf_scroll_window))))) | ||
| 6388 | freeze_p = NULL; | ||
| 6389 | |||
| 6390 | w->frozen_window_start_p = freeze_p != NULL; | ||
| 6391 | return 1; | ||
| 6392 | } | ||
| 6393 | |||
| 6394 | |||
| 6395 | /* Freeze or unfreeze the window starts of all leaf windows on frame | ||
| 6396 | F, except the selected window and a mini-window. FREEZE_P non-zero | ||
| 6397 | means freeze the window start. */ | ||
| 6398 | |||
| 6399 | void | ||
| 6400 | freeze_window_starts (struct frame *f, int freeze_p) | ||
| 6401 | { | ||
| 6402 | foreach_window (f, freeze_window_start, (void *) (freeze_p ? f : 0)); | ||
| 6403 | } | ||
| 6404 | |||
| 6405 | |||
| 6406 | /*********************************************************************** | 6419 | /*********************************************************************** |
| 6407 | Initialization | 6420 | Initialization |
| 6408 | ***********************************************************************/ | 6421 | ***********************************************************************/ |
| @@ -6410,15 +6423,17 @@ freeze_window_starts (struct frame *f, int freeze_p) | |||
| 6410 | /* Return 1 if window configurations CONFIGURATION1 and CONFIGURATION2 | 6423 | /* Return 1 if window configurations CONFIGURATION1 and CONFIGURATION2 |
| 6411 | describe the same state of affairs. This is used by Fequal. | 6424 | describe the same state of affairs. This is used by Fequal. |
| 6412 | 6425 | ||
| 6413 | ignore_positions non-zero means ignore non-matching scroll positions | 6426 | IGNORE_POSITIONS means ignore non-matching scroll positions |
| 6414 | and the like. | 6427 | and the like. |
| 6415 | 6428 | ||
| 6416 | This ignores a couple of things like the dedication status of | 6429 | This ignores a couple of things like the dedication status of |
| 6417 | window, combination_limit and the like. This might have to be | 6430 | window, combination_limit and the like. This might have to be |
| 6418 | fixed. */ | 6431 | fixed. */ |
| 6419 | 6432 | ||
| 6420 | int | 6433 | bool |
| 6421 | compare_window_configurations (Lisp_Object configuration1, Lisp_Object configuration2, int ignore_positions) | 6434 | compare_window_configurations (Lisp_Object configuration1, |
| 6435 | Lisp_Object configuration2, | ||
| 6436 | bool ignore_positions) | ||
| 6422 | { | 6437 | { |
| 6423 | register struct save_window_data *d1, *d2; | 6438 | register struct save_window_data *d1, *d2; |
| 6424 | struct Lisp_Vector *sws1, *sws2; | 6439 | struct Lisp_Vector *sws1, *sws2; |
| @@ -6534,6 +6549,7 @@ syms_of_window (void) | |||
| 6534 | DEFSYM (Qwindowp, "windowp"); | 6549 | DEFSYM (Qwindowp, "windowp"); |
| 6535 | DEFSYM (Qwindow_configuration_p, "window-configuration-p"); | 6550 | DEFSYM (Qwindow_configuration_p, "window-configuration-p"); |
| 6536 | DEFSYM (Qwindow_live_p, "window-live-p"); | 6551 | DEFSYM (Qwindow_live_p, "window-live-p"); |
| 6552 | DEFSYM (Qwindow_valid_p, "window-valid-p"); | ||
| 6537 | DEFSYM (Qwindow_deletable_p, "window-deletable-p"); | 6553 | DEFSYM (Qwindow_deletable_p, "window-deletable-p"); |
| 6538 | DEFSYM (Qdelete_window, "delete-window"); | 6554 | DEFSYM (Qdelete_window, "delete-window"); |
| 6539 | DEFSYM (Qwindow_resize_root_window, "window--resize-root-window"); | 6555 | DEFSYM (Qwindow_resize_root_window, "window--resize-root-window"); |
| @@ -6543,10 +6559,10 @@ syms_of_window (void) | |||
| 6543 | DEFSYM (Qreplace_buffer_in_windows, "replace-buffer-in-windows"); | 6559 | DEFSYM (Qreplace_buffer_in_windows, "replace-buffer-in-windows"); |
| 6544 | DEFSYM (Qrecord_window_buffer, "record-window-buffer"); | 6560 | DEFSYM (Qrecord_window_buffer, "record-window-buffer"); |
| 6545 | DEFSYM (Qget_mru_window, "get-mru-window"); | 6561 | DEFSYM (Qget_mru_window, "get-mru-window"); |
| 6562 | DEFSYM (Qwindow_size, "window-size"); | ||
| 6546 | DEFSYM (Qtemp_buffer_show_hook, "temp-buffer-show-hook"); | 6563 | DEFSYM (Qtemp_buffer_show_hook, "temp-buffer-show-hook"); |
| 6547 | DEFSYM (Qabove, "above"); | 6564 | DEFSYM (Qabove, "above"); |
| 6548 | DEFSYM (Qbelow, "below"); | 6565 | DEFSYM (Qbelow, "below"); |
| 6549 | DEFSYM (Qauto_buffer_name, "auto-buffer-name"); | ||
| 6550 | DEFSYM (Qclone_of, "clone-of"); | 6566 | DEFSYM (Qclone_of, "clone-of"); |
| 6551 | 6567 | ||
| 6552 | staticpro (&Vwindow_list); | 6568 | staticpro (&Vwindow_list); |
| @@ -6635,27 +6651,41 @@ same combination. | |||
| 6635 | 6651 | ||
| 6636 | Other values are reserved for future use. | 6652 | Other values are reserved for future use. |
| 6637 | 6653 | ||
| 6638 | This variable takes no effect if `window-combination-limit' is non-nil. */); | 6654 | This variable takes no effect if the variable `window-combination-limit' is |
| 6655 | non-nil. */); | ||
| 6639 | Vwindow_combination_resize = Qnil; | 6656 | Vwindow_combination_resize = Qnil; |
| 6640 | 6657 | ||
| 6641 | DEFVAR_LISP ("window-combination-limit", Vwindow_combination_limit, | 6658 | DEFVAR_LISP ("window-combination-limit", Vwindow_combination_limit, |
| 6642 | doc: /* If t, splitting a window makes a new parent window. | 6659 | doc: /* If non-nil, splitting a window makes a new parent window. |
| 6643 | If this variable is nil, splitting a window will create a new parent | 6660 | The following values are recognized: |
| 6644 | window only if the window has no parent window or the window shall | ||
| 6645 | become a combination orthogonal to the one it is part of. | ||
| 6646 | 6661 | ||
| 6647 | If this variable is t, splitting a window always creates a new parent | 6662 | nil means splitting a window will create a new parent window only if the |
| 6648 | window. If all splits behave this way, each frame's window tree is a | 6663 | window has no parent window or the window shall become part of a |
| 6649 | binary tree and every window but the frame's root window has exactly one | 6664 | combination orthogonal to the one it is part of. |
| 6650 | sibling. | ||
| 6651 | 6665 | ||
| 6652 | Other values are reserved for future use. | 6666 | `window-size' means that splitting a window for displaying a buffer |
| 6667 | makes a new parent window provided `display-buffer' is supposed to | ||
| 6668 | explicitly set the window's size due to the presence of a | ||
| 6669 | `window-height' or `window-width' entry in the alist used by | ||
| 6670 | `display-buffer'. Otherwise, this value is handled like nil. | ||
| 6671 | |||
| 6672 | `temp-buffer' means that splitting a window for displaying a temporary | ||
| 6673 | buffer always makes a new parent window. Otherwise, this value is | ||
| 6674 | handled like nil. | ||
| 6675 | |||
| 6676 | `display-buffer' means that splitting a window for displaying a buffer | ||
| 6677 | always makes a new parent window. Since temporary buffers are | ||
| 6678 | displayed by the function `display-buffer', this value is stronger | ||
| 6679 | than `temp-buffer'. Splitting a window for other purpose makes a | ||
| 6680 | new parent window only if needed. | ||
| 6681 | |||
| 6682 | t means that splitting a window always creates a new parent window. If | ||
| 6683 | all splits behave this way, each frame's window tree is a binary | ||
| 6684 | tree and every window but the frame's root window has exactly one | ||
| 6685 | sibling. | ||
| 6653 | 6686 | ||
| 6654 | The value of this variable is also assigned to the combination limit of | 6687 | Other values are reserved for future use. */); |
| 6655 | the new parent window. The combination limit of a window can be | 6688 | Vwindow_combination_limit = Qwindow_size; |
| 6656 | retrieved via the function `window-combination-limit' and altered by the | ||
| 6657 | function `set-window-combination-limit'. */); | ||
| 6658 | Vwindow_combination_limit = Qnil; | ||
| 6659 | 6689 | ||
| 6660 | DEFVAR_LISP ("window-persistent-parameters", Vwindow_persistent_parameters, | 6690 | DEFVAR_LISP ("window-persistent-parameters", Vwindow_persistent_parameters, |
| 6661 | doc: /* Alist of persistent window parameters. | 6691 | doc: /* Alist of persistent window parameters. |
| @@ -6686,6 +6716,7 @@ respectively are not installed by `window-state-put'. */); | |||
| 6686 | defsubr (&Sminibuffer_window); | 6716 | defsubr (&Sminibuffer_window); |
| 6687 | defsubr (&Swindow_minibuffer_p); | 6717 | defsubr (&Swindow_minibuffer_p); |
| 6688 | defsubr (&Swindowp); | 6718 | defsubr (&Swindowp); |
| 6719 | defsubr (&Swindow_valid_p); | ||
| 6689 | defsubr (&Swindow_live_p); | 6720 | defsubr (&Swindow_live_p); |
| 6690 | defsubr (&Swindow_frame); | 6721 | defsubr (&Swindow_frame); |
| 6691 | defsubr (&Sframe_root_window); | 6722 | defsubr (&Sframe_root_window); |
| @@ -6746,7 +6777,6 @@ respectively are not installed by `window-state-put'. */); | |||
| 6746 | defsubr (&Srun_window_configuration_change_hook); | 6777 | defsubr (&Srun_window_configuration_change_hook); |
| 6747 | defsubr (&Sselect_window); | 6778 | defsubr (&Sselect_window); |
| 6748 | defsubr (&Sforce_window_update); | 6779 | defsubr (&Sforce_window_update); |
| 6749 | defsubr (&Stemp_output_buffer_show); | ||
| 6750 | defsubr (&Ssplit_window_internal); | 6780 | defsubr (&Ssplit_window_internal); |
| 6751 | defsubr (&Sscroll_up); | 6781 | defsubr (&Sscroll_up); |
| 6752 | defsubr (&Sscroll_down); | 6782 | defsubr (&Sscroll_down); |