diff options
| author | Bill Wohler | 2013-02-18 10:11:43 -0800 |
|---|---|---|
| committer | Bill Wohler | 2013-02-18 10:11:43 -0800 |
| commit | 21733e4f154f8830fa568a347a0d6dbd59793c2b (patch) | |
| tree | 3170dbbcdfafeb42f6c381d6b80b251e9f31b788 /src/window.c | |
| parent | 6d14beddb06b5ae86f9dd770a1661ebd24846f28 (diff) | |
| parent | 587feed443522f738b65b57b22a31cc8a25525c5 (diff) | |
| download | emacs-21733e4f154f8830fa568a347a0d6dbd59793c2b.tar.gz emacs-21733e4f154f8830fa568a347a0d6dbd59793c2b.zip | |
Merge from trunk; up to 2013-02-18T01:30:27Z!monnier@iro.umontreal.ca.
Diffstat (limited to 'src/window.c')
| -rw-r--r-- | src/window.c | 198 |
1 files changed, 115 insertions, 83 deletions
diff --git a/src/window.c b/src/window.c index d7c2e8b236e..ea1dd93711c 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 | ||
| @@ -87,6 +87,7 @@ static Lisp_Object window_list_1 (Lisp_Object, Lisp_Object, Lisp_Object); | |||
| 87 | static int window_resize_check (struct window *, int); | 87 | static int window_resize_check (struct window *, int); |
| 88 | static void window_resize_apply (struct window *, int); | 88 | static void window_resize_apply (struct window *, int); |
| 89 | static Lisp_Object select_window (Lisp_Object, Lisp_Object, int); | 89 | static Lisp_Object select_window (Lisp_Object, Lisp_Object, int); |
| 90 | static void select_window_1 (Lisp_Object, bool); | ||
| 90 | 91 | ||
| 91 | /* This is the window in which the terminal's cursor should | 92 | /* This is the window in which the terminal's cursor should |
| 92 | be left when nothing is being done with it. This must | 93 | be left when nothing is being done with it. This must |
| @@ -115,9 +116,6 @@ Lisp_Object minibuf_selected_window; | |||
| 115 | /* Hook run at end of temp_output_buffer_show. */ | 116 | /* Hook run at end of temp_output_buffer_show. */ |
| 116 | static Lisp_Object Qtemp_buffer_show_hook; | 117 | static Lisp_Object Qtemp_buffer_show_hook; |
| 117 | 118 | ||
| 118 | /* Incremented for each window created. */ | ||
| 119 | static int sequence_number; | ||
| 120 | |||
| 121 | /* Nonzero after init_window_once has finished. */ | 119 | /* Nonzero after init_window_once has finished. */ |
| 122 | static int window_initialized; | 120 | static int window_initialized; |
| 123 | 121 | ||
| @@ -270,6 +268,38 @@ decode_valid_window (register Lisp_Object window) | |||
| 270 | return w; | 268 | return w; |
| 271 | } | 269 | } |
| 272 | 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->buffer)) | ||
| 279 | { | ||
| 280 | struct buffer *b = XBUFFER (w->buffer); | ||
| 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 | w->buffer = val; | ||
| 300 | adjust_window_count (w, 1); | ||
| 301 | } | ||
| 302 | |||
| 273 | /* Build a frequently used 4-integer (X Y W H) list. */ | 303 | /* Build a frequently used 4-integer (X Y W H) list. */ |
| 274 | 304 | ||
| 275 | static Lisp_Object | 305 | static Lisp_Object |
| @@ -458,7 +488,6 @@ static Lisp_Object | |||
| 458 | select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap) | 488 | select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap) |
| 459 | { | 489 | { |
| 460 | register struct window *w; | 490 | register struct window *w; |
| 461 | register struct window *ow; | ||
| 462 | struct frame *sf; | 491 | struct frame *sf; |
| 463 | 492 | ||
| 464 | CHECK_LIVE_WINDOW (window); | 493 | CHECK_LIVE_WINDOW (window); |
| @@ -494,12 +523,25 @@ select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap) | |||
| 494 | else | 523 | else |
| 495 | fset_selected_window (sf, window); | 524 | fset_selected_window (sf, window); |
| 496 | 525 | ||
| 526 | select_window_1 (window, inhibit_point_swap); | ||
| 527 | |||
| 528 | bset_last_selected_window (XBUFFER (w->buffer), window); | ||
| 529 | windows_or_buffers_changed++; | ||
| 530 | return window; | ||
| 531 | } | ||
| 532 | |||
| 533 | /* Select window with a minimum of fuss, i.e. don't record the change anywhere | ||
| 534 | (not even for redisplay's benefit), and assume that the window's frame is | ||
| 535 | already selected. */ | ||
| 536 | static void | ||
| 537 | select_window_1 (Lisp_Object window, bool inhibit_point_swap) | ||
| 538 | { | ||
| 497 | /* Store the old selected window's buffer's point in pointm of the old | 539 | /* Store the old selected window's buffer's point in pointm of the old |
| 498 | selected window. It belongs to that window, and when the window is | 540 | selected window. It belongs to that window, and when the window is |
| 499 | not selected, must be in the window. */ | 541 | not selected, must be in the window. */ |
| 500 | if (!inhibit_point_swap) | 542 | if (!inhibit_point_swap) |
| 501 | { | 543 | { |
| 502 | ow = XWINDOW (selected_window); | 544 | struct window *ow = XWINDOW (selected_window); |
| 503 | if (! NILP (ow->buffer)) | 545 | if (! NILP (ow->buffer)) |
| 504 | set_marker_both (ow->pointm, ow->buffer, | 546 | set_marker_both (ow->pointm, ow->buffer, |
| 505 | BUF_PT (XBUFFER (ow->buffer)), | 547 | BUF_PT (XBUFFER (ow->buffer)), |
| @@ -507,7 +549,6 @@ select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap) | |||
| 507 | } | 549 | } |
| 508 | 550 | ||
| 509 | selected_window = window; | 551 | selected_window = window; |
| 510 | bset_last_selected_window (XBUFFER (w->buffer), window); | ||
| 511 | 552 | ||
| 512 | /* Go to the point recorded in the window. | 553 | /* Go to the point recorded in the window. |
| 513 | This is important when the buffer is in more | 554 | This is important when the buffer is in more |
| @@ -515,7 +556,7 @@ select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap) | |||
| 515 | redisplay_window has altered point after scrolling, | 556 | redisplay_window has altered point after scrolling, |
| 516 | because it makes the change only in the window. */ | 557 | because it makes the change only in the window. */ |
| 517 | { | 558 | { |
| 518 | register ptrdiff_t new_point = marker_position (w->pointm); | 559 | register ptrdiff_t new_point = marker_position (XWINDOW (window)->pointm); |
| 519 | if (new_point < BEGV) | 560 | if (new_point < BEGV) |
| 520 | SET_PT (BEGV); | 561 | SET_PT (BEGV); |
| 521 | else if (new_point > ZV) | 562 | else if (new_point > ZV) |
| @@ -523,15 +564,14 @@ select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap) | |||
| 523 | else | 564 | else |
| 524 | SET_PT (new_point); | 565 | SET_PT (new_point); |
| 525 | } | 566 | } |
| 526 | |||
| 527 | windows_or_buffers_changed++; | ||
| 528 | return window; | ||
| 529 | } | 567 | } |
| 530 | 568 | ||
| 531 | DEFUN ("select-window", Fselect_window, Sselect_window, 1, 2, 0, | 569 | DEFUN ("select-window", Fselect_window, Sselect_window, 1, 2, 0, |
| 532 | doc: /* Select WINDOW. Most editing will apply to WINDOW's buffer. | 570 | doc: /* Select WINDOW which must be a live window. |
| 533 | Also make WINDOW's buffer current and make WINDOW the frame's selected | 571 | Also make WINDOW's frame the selected frame and WINDOW that frame's |
| 534 | window. Return WINDOW. | 572 | selected window. In addition, make WINDOW's buffer current and set that |
| 573 | buffer's value of `point' to the value of WINDOW's `window-point'. | ||
| 574 | Return WINDOW. | ||
| 535 | 575 | ||
| 536 | Optional second arg NORECORD non-nil means do not put this buffer at the | 576 | Optional second arg NORECORD non-nil means do not put this buffer at the |
| 537 | front of the buffer list and do not make this window the most recently | 577 | front of the buffer list and do not make this window the most recently |
| @@ -762,12 +802,12 @@ window_body_cols (struct window *w) | |||
| 762 | occupies one column only. */ | 802 | occupies one column only. */ |
| 763 | width -= 1; | 803 | width -= 1; |
| 764 | 804 | ||
| 805 | /* Display margins cannot be used for normal text. */ | ||
| 806 | width -= WINDOW_LEFT_MARGIN_COLS (w) + WINDOW_RIGHT_MARGIN_COLS (w); | ||
| 807 | |||
| 765 | if (FRAME_WINDOW_P (f)) | 808 | if (FRAME_WINDOW_P (f)) |
| 766 | /* On window-systems, fringes and display margins cannot be | 809 | /* On window-systems, fringes cannot be used for normal text. */ |
| 767 | used for normal text. */ | 810 | width -= WINDOW_FRINGE_COLS (w); |
| 768 | width -= (WINDOW_FRINGE_COLS (w) | ||
| 769 | + WINDOW_LEFT_MARGIN_COLS (w) | ||
| 770 | + WINDOW_RIGHT_MARGIN_COLS (w)); | ||
| 771 | 811 | ||
| 772 | return width; | 812 | return width; |
| 773 | } | 813 | } |
| @@ -1396,7 +1436,7 @@ window were selected. | |||
| 1396 | 1436 | ||
| 1397 | Note that, when WINDOW is selected, the value returned is the same as | 1437 | Note that, when WINDOW is selected, the value returned is the same as |
| 1398 | that returned by `point' for WINDOW's buffer. It would be more strictly | 1438 | that returned by `point' for WINDOW's buffer. It would be more strictly |
| 1399 | correct to return the `top-level' value of `point', outside of any | 1439 | correct to return the top-level value of `point', outside of any |
| 1400 | `save-excursion' forms. But that is hard to define. */) | 1440 | `save-excursion' forms. But that is hard to define. */) |
| 1401 | (Lisp_Object window) | 1441 | (Lisp_Object window) |
| 1402 | { | 1442 | { |
| @@ -1449,20 +1489,12 @@ if it isn't already recorded. */) | |||
| 1449 | CHECK_BUFFER (buf); | 1489 | CHECK_BUFFER (buf); |
| 1450 | b = XBUFFER (buf); | 1490 | b = XBUFFER (buf); |
| 1451 | 1491 | ||
| 1452 | #if 0 /* This change broke some things. We should make it later. */ | ||
| 1453 | /* If we don't know the end position, return nil. | ||
| 1454 | The user can compute it with vertical-motion if he wants to. | ||
| 1455 | It would be nicer to do it automatically, | ||
| 1456 | but that's so slow that it would probably bother people. */ | ||
| 1457 | if (NILP (w->window_end_valid)) | ||
| 1458 | return Qnil; | ||
| 1459 | #endif | ||
| 1460 | |||
| 1461 | if (! NILP (update) | 1492 | if (! NILP (update) |
| 1462 | && (windows_or_buffers_changed || NILP (w->window_end_valid)) | 1493 | && (windows_or_buffers_changed || !w->window_end_valid) |
| 1463 | && !noninteractive) | 1494 | && !noninteractive) |
| 1464 | { | 1495 | { |
| 1465 | struct text_pos startp; | 1496 | struct text_pos startp; |
| 1497 | ptrdiff_t charpos = marker_position (w->start); | ||
| 1466 | struct it it; | 1498 | struct it it; |
| 1467 | struct buffer *old_buffer = NULL; | 1499 | struct buffer *old_buffer = NULL; |
| 1468 | void *itdata = NULL; | 1500 | void *itdata = NULL; |
| @@ -1480,9 +1512,9 @@ if it isn't already recorded. */) | |||
| 1480 | `-l' containing a call to `rmail' with subsequent other | 1512 | `-l' containing a call to `rmail' with subsequent other |
| 1481 | commands. At the end, W->start happened to be BEG, while | 1513 | commands. At the end, W->start happened to be BEG, while |
| 1482 | rmail had already narrowed the buffer. */ | 1514 | rmail had already narrowed the buffer. */ |
| 1483 | if (XMARKER (w->start)->charpos < BEGV) | 1515 | if (charpos < BEGV) |
| 1484 | SET_TEXT_POS (startp, BEGV, BEGV_BYTE); | 1516 | SET_TEXT_POS (startp, BEGV, BEGV_BYTE); |
| 1485 | else if (XMARKER (w->start)->charpos > ZV) | 1517 | else if (charpos > ZV) |
| 1486 | SET_TEXT_POS (startp, ZV, ZV_BYTE); | 1518 | SET_TEXT_POS (startp, ZV, ZV_BYTE); |
| 1487 | else | 1519 | else |
| 1488 | SET_TEXT_POS_FROM_MARKER (startp, w->start); | 1520 | SET_TEXT_POS_FROM_MARKER (startp, w->start); |
| @@ -1512,7 +1544,7 @@ Return POS. */) | |||
| 1512 | { | 1544 | { |
| 1513 | register struct window *w = decode_live_window (window); | 1545 | register struct window *w = decode_live_window (window); |
| 1514 | 1546 | ||
| 1515 | CHECK_NUMBER_COERCE_MARKER (pos); | 1547 | /* Type of POS is checked by Fgoto_char or set_marker_restricted ... */ |
| 1516 | 1548 | ||
| 1517 | if (w == XWINDOW (selected_window)) | 1549 | if (w == XWINDOW (selected_window)) |
| 1518 | { | 1550 | { |
| @@ -1522,6 +1554,8 @@ Return POS. */) | |||
| 1522 | { | 1554 | { |
| 1523 | struct buffer *old_buffer = current_buffer; | 1555 | struct buffer *old_buffer = current_buffer; |
| 1524 | 1556 | ||
| 1557 | /* ... but here we want to catch type error before buffer change. */ | ||
| 1558 | CHECK_NUMBER_COERCE_MARKER (pos); | ||
| 1525 | set_buffer_internal (XBUFFER (w->buffer)); | 1559 | set_buffer_internal (XBUFFER (w->buffer)); |
| 1526 | Fgoto_char (pos); | 1560 | Fgoto_char (pos); |
| 1527 | set_buffer_internal (old_buffer); | 1561 | set_buffer_internal (old_buffer); |
| @@ -1547,9 +1581,8 @@ overriding motion of point in order to display at this exact start. */) | |||
| 1547 | { | 1581 | { |
| 1548 | register struct window *w = decode_live_window (window); | 1582 | register struct window *w = decode_live_window (window); |
| 1549 | 1583 | ||
| 1550 | CHECK_NUMBER_COERCE_MARKER (pos); | ||
| 1551 | set_marker_restricted (w->start, pos, w->buffer); | 1584 | set_marker_restricted (w->start, pos, w->buffer); |
| 1552 | /* this is not right, but much easier than doing what is right. */ | 1585 | /* This is not right, but much easier than doing what is right. */ |
| 1553 | w->start_at_line_beg = 0; | 1586 | w->start_at_line_beg = 0; |
| 1554 | if (NILP (noforce)) | 1587 | if (NILP (noforce)) |
| 1555 | w->force_start = 1; | 1588 | w->force_start = 1; |
| @@ -1605,7 +1638,7 @@ display row, and VPOS is the row number (0-based) containing POS. */) | |||
| 1605 | else if (w == XWINDOW (selected_window)) | 1638 | else if (w == XWINDOW (selected_window)) |
| 1606 | posint = PT; | 1639 | posint = PT; |
| 1607 | else | 1640 | else |
| 1608 | posint = XMARKER (w->pointm)->charpos; | 1641 | posint = marker_position (w->pointm); |
| 1609 | 1642 | ||
| 1610 | /* If position is above window start or outside buffer boundaries, | 1643 | /* If position is above window start or outside buffer boundaries, |
| 1611 | or if window start is out of range, position is not visible. */ | 1644 | or if window start is out of range, position is not visible. */ |
| @@ -1665,7 +1698,7 @@ Return nil if window display is not up-to-date. In that case, use | |||
| 1665 | b = XBUFFER (w->buffer); | 1698 | b = XBUFFER (w->buffer); |
| 1666 | 1699 | ||
| 1667 | /* Fail if current matrix is not up-to-date. */ | 1700 | /* Fail if current matrix is not up-to-date. */ |
| 1668 | if (NILP (w->window_end_valid) | 1701 | if (!w->window_end_valid |
| 1669 | || current_buffer->clip_changed | 1702 | || current_buffer->clip_changed |
| 1670 | || current_buffer->prevent_redisplay_optimizations_p | 1703 | || current_buffer->prevent_redisplay_optimizations_p |
| 1671 | || w->last_modified < BUF_MODIFF (b) | 1704 | || w->last_modified < BUF_MODIFF (b) |
| @@ -1951,7 +1984,7 @@ unshow_buffer (register struct window *w) | |||
| 1951 | && EQ (buf, XWINDOW (BVAR (b, last_selected_window))->buffer))) | 1984 | && EQ (buf, XWINDOW (BVAR (b, last_selected_window))->buffer))) |
| 1952 | temp_set_point_both (b, | 1985 | temp_set_point_both (b, |
| 1953 | clip_to_bounds (BUF_BEGV (b), | 1986 | clip_to_bounds (BUF_BEGV (b), |
| 1954 | XMARKER (w->pointm)->charpos, | 1987 | marker_position (w->pointm), |
| 1955 | BUF_ZV (b)), | 1988 | BUF_ZV (b)), |
| 1956 | clip_to_bounds (BUF_BEGV_BYTE (b), | 1989 | clip_to_bounds (BUF_BEGV_BYTE (b), |
| 1957 | marker_byte_position (w->pointm), | 1990 | marker_byte_position (w->pointm), |
| @@ -1997,7 +2030,7 @@ replace_window (Lisp_Object old, Lisp_Object new, int setflag) | |||
| 1997 | n->pseudo_window_p = 0; | 2030 | n->pseudo_window_p = 0; |
| 1998 | wset_window_end_vpos (n, make_number (0)); | 2031 | wset_window_end_vpos (n, make_number (0)); |
| 1999 | wset_window_end_pos (n, make_number (0)); | 2032 | wset_window_end_pos (n, make_number (0)); |
| 2000 | wset_window_end_valid (n, Qnil); | 2033 | n->window_end_valid = 0; |
| 2001 | n->frozen_window_start_p = 0; | 2034 | n->frozen_window_start_p = 0; |
| 2002 | } | 2035 | } |
| 2003 | 2036 | ||
| @@ -2197,7 +2230,6 @@ candidate_window_p (Lisp_Object window, Lisp_Object owindow, Lisp_Object minibuf | |||
| 2197 | } | 2230 | } |
| 2198 | else if (EQ (all_frames, Qvisible)) | 2231 | else if (EQ (all_frames, Qvisible)) |
| 2199 | { | 2232 | { |
| 2200 | FRAME_SAMPLE_VISIBILITY (f); | ||
| 2201 | candidate_p = FRAME_VISIBLE_P (f) | 2233 | candidate_p = FRAME_VISIBLE_P (f) |
| 2202 | && (FRAME_TERMINAL (XFRAME (w->frame)) | 2234 | && (FRAME_TERMINAL (XFRAME (w->frame)) |
| 2203 | == FRAME_TERMINAL (XFRAME (selected_frame))); | 2235 | == FRAME_TERMINAL (XFRAME (selected_frame))); |
| @@ -2205,7 +2237,6 @@ candidate_window_p (Lisp_Object window, Lisp_Object owindow, Lisp_Object minibuf | |||
| 2205 | } | 2237 | } |
| 2206 | else if (INTEGERP (all_frames) && XINT (all_frames) == 0) | 2238 | else if (INTEGERP (all_frames) && XINT (all_frames) == 0) |
| 2207 | { | 2239 | { |
| 2208 | FRAME_SAMPLE_VISIBILITY (f); | ||
| 2209 | candidate_p = (FRAME_VISIBLE_P (f) || FRAME_ICONIFIED_P (f) | 2240 | candidate_p = (FRAME_VISIBLE_P (f) || FRAME_ICONIFIED_P (f) |
| 2210 | #ifdef HAVE_X_WINDOWS | 2241 | #ifdef HAVE_X_WINDOWS |
| 2211 | /* Yuck!! If we've just created the frame and the | 2242 | /* Yuck!! If we've just created the frame and the |
| @@ -2932,7 +2963,7 @@ window-start value is reasonable when this function is called. */) | |||
| 2932 | pos = *vmotion (startpos, -top, w); | 2963 | pos = *vmotion (startpos, -top, w); |
| 2933 | 2964 | ||
| 2934 | set_marker_both (w->start, w->buffer, pos.bufpos, pos.bytepos); | 2965 | set_marker_both (w->start, w->buffer, pos.bufpos, pos.bytepos); |
| 2935 | wset_window_end_valid (w, Qnil); | 2966 | w->window_end_valid = 0; |
| 2936 | w->start_at_line_beg = (pos.bytepos == BEGV_BYTE | 2967 | w->start_at_line_beg = (pos.bytepos == BEGV_BYTE |
| 2937 | || FETCH_BYTE (pos.bytepos - 1) == '\n'); | 2968 | || FETCH_BYTE (pos.bytepos - 1) == '\n'); |
| 2938 | /* We need to do this, so that the window-scroll-functions | 2969 | /* We need to do this, so that the window-scroll-functions |
| @@ -2958,22 +2989,24 @@ replace_buffer_in_windows (Lisp_Object buffer) | |||
| 2958 | call1 (Qreplace_buffer_in_windows, buffer); | 2989 | call1 (Qreplace_buffer_in_windows, buffer); |
| 2959 | } | 2990 | } |
| 2960 | 2991 | ||
| 2961 | 2992 | /* If BUFFER is shown in a window, safely replace it with some other | |
| 2962 | /* Safely replace BUFFER with some other buffer in all windows of all | 2993 | buffer in all windows of all frames, even those on other keyboards. */ |
| 2963 | frames, even those on other keyboards. */ | ||
| 2964 | 2994 | ||
| 2965 | void | 2995 | void |
| 2966 | replace_buffer_in_windows_safely (Lisp_Object buffer) | 2996 | replace_buffer_in_windows_safely (Lisp_Object buffer) |
| 2967 | { | 2997 | { |
| 2968 | Lisp_Object tail, frame; | 2998 | if (buffer_window_count (XBUFFER (buffer))) |
| 2999 | { | ||
| 3000 | Lisp_Object tail, frame; | ||
| 2969 | 3001 | ||
| 2970 | /* A single call to window_loop won't do the job because it only | 3002 | /* A single call to window_loop won't do the job because it only |
| 2971 | considers frames on the current keyboard. So loop manually over | 3003 | considers frames on the current keyboard. So loop manually over |
| 2972 | frames, and handle each one. */ | 3004 | frames, and handle each one. */ |
| 2973 | FOR_EACH_FRAME (tail, frame) | 3005 | FOR_EACH_FRAME (tail, frame) |
| 2974 | window_loop (REPLACE_BUFFER_IN_WINDOWS_SAFELY, buffer, 1, frame); | 3006 | window_loop (REPLACE_BUFFER_IN_WINDOWS_SAFELY, buffer, 1, frame); |
| 3007 | } | ||
| 2975 | } | 3008 | } |
| 2976 | 3009 | ||
| 2977 | /* If *ROWS or *COLS are too small a size for FRAME, set them to the | 3010 | /* If *ROWS or *COLS are too small a size for FRAME, set them to the |
| 2978 | minimum allowable size. */ | 3011 | minimum allowable size. */ |
| 2979 | 3012 | ||
| @@ -3146,7 +3179,7 @@ set_window_buffer (Lisp_Object window, Lisp_Object buffer, int run_hooks_p, int | |||
| 3146 | wset_window_end_pos (w, make_number (0)); | 3179 | wset_window_end_pos (w, make_number (0)); |
| 3147 | wset_window_end_vpos (w, make_number (0)); | 3180 | wset_window_end_vpos (w, make_number (0)); |
| 3148 | memset (&w->last_cursor, 0, sizeof w->last_cursor); | 3181 | memset (&w->last_cursor, 0, sizeof w->last_cursor); |
| 3149 | wset_window_end_valid (w, Qnil); | 3182 | |
| 3150 | if (!(keep_margins_p && samebuf)) | 3183 | if (!(keep_margins_p && samebuf)) |
| 3151 | { /* If we're not actually changing the buffer, don't reset hscroll and | 3184 | { /* If we're not actually changing the buffer, don't reset hscroll and |
| 3152 | vscroll. This case happens for example when called from | 3185 | vscroll. This case happens for example when called from |
| @@ -3308,11 +3341,11 @@ displaying that buffer. */) | |||
| 3308 | 3341 | ||
| 3309 | if (STRINGP (object)) | 3342 | if (STRINGP (object)) |
| 3310 | object = Fget_buffer (object); | 3343 | object = Fget_buffer (object); |
| 3311 | if (BUFFERP (object) && BUFFER_LIVE_P (XBUFFER (object))) | 3344 | if (BUFFERP (object) && BUFFER_LIVE_P (XBUFFER (object)) |
| 3345 | && buffer_window_count (XBUFFER (object))) | ||
| 3312 | { | 3346 | { |
| 3313 | /* Walk all windows looking for buffer, and force update | 3347 | /* If buffer is live and shown in at least one window, find |
| 3314 | of each of those windows. */ | 3348 | all windows showing this buffer and force update of them. */ |
| 3315 | |||
| 3316 | object = window_loop (REDISPLAY_BUFFER_WINDOWS, object, 0, Qvisible); | 3349 | object = window_loop (REDISPLAY_BUFFER_WINDOWS, object, 0, Qvisible); |
| 3317 | return NILP (object) ? Qnil : Qt; | 3350 | return NILP (object) ? Qnil : Qt; |
| 3318 | } | 3351 | } |
| @@ -3391,10 +3424,10 @@ make_parent_window (Lisp_Object window, int horflag) | |||
| 3391 | memcpy ((char *) p + sizeof (struct vectorlike_header), | 3424 | memcpy ((char *) p + sizeof (struct vectorlike_header), |
| 3392 | (char *) o + sizeof (struct vectorlike_header), | 3425 | (char *) o + sizeof (struct vectorlike_header), |
| 3393 | word_size * VECSIZE (struct window)); | 3426 | word_size * VECSIZE (struct window)); |
| 3427 | /* P's buffer slot may change from nil to a buffer. */ | ||
| 3428 | adjust_window_count (p, 1); | ||
| 3394 | XSETWINDOW (parent, p); | 3429 | XSETWINDOW (parent, p); |
| 3395 | 3430 | ||
| 3396 | p->sequence_number = ++sequence_number; | ||
| 3397 | |||
| 3398 | replace_window (window, parent, 1); | 3431 | replace_window (window, parent, 1); |
| 3399 | 3432 | ||
| 3400 | wset_next (o, Qnil); | 3433 | wset_next (o, Qnil); |
| @@ -3443,7 +3476,7 @@ make_window (void) | |||
| 3443 | w->nrows_scale_factor = w->ncols_scale_factor = 1; | 3476 | w->nrows_scale_factor = w->ncols_scale_factor = 1; |
| 3444 | w->phys_cursor_type = -1; | 3477 | w->phys_cursor_type = -1; |
| 3445 | w->phys_cursor_width = -1; | 3478 | w->phys_cursor_width = -1; |
| 3446 | w->sequence_number = ++sequence_number; | 3479 | w->column_number_displayed = -1; |
| 3447 | 3480 | ||
| 3448 | /* Reset window_list. */ | 3481 | /* Reset window_list. */ |
| 3449 | Vwindow_list = Qnil; | 3482 | Vwindow_list = Qnil; |
| @@ -3913,7 +3946,7 @@ set correctly. See the code of `split-window' for how this is done. */) | |||
| 3913 | wset_next (o, new); | 3946 | wset_next (o, new); |
| 3914 | } | 3947 | } |
| 3915 | 3948 | ||
| 3916 | wset_window_end_valid (n, Qnil); | 3949 | n->window_end_valid = 0; |
| 3917 | memset (&n->last_cursor, 0, sizeof n->last_cursor); | 3950 | memset (&n->last_cursor, 0, sizeof n->last_cursor); |
| 3918 | 3951 | ||
| 3919 | /* Get special geometry settings from reference window. */ | 3952 | /* Get special geometry settings from reference window. */ |
| @@ -4583,9 +4616,9 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror) | |||
| 4583 | } | 4616 | } |
| 4584 | 4617 | ||
| 4585 | /* Set the window start, and set up the window for redisplay. */ | 4618 | /* Set the window start, and set up the window for redisplay. */ |
| 4586 | set_marker_restricted (w->start, make_number (pos), | 4619 | set_marker_restricted_both (w->start, w->buffer, IT_CHARPOS (it), |
| 4587 | w->buffer); | 4620 | IT_BYTEPOS (it)); |
| 4588 | bytepos = XMARKER (w->start)->bytepos; | 4621 | bytepos = marker_byte_position (w->start); |
| 4589 | w->start_at_line_beg = (pos == BEGV || FETCH_BYTE (bytepos - 1) == '\n'); | 4622 | w->start_at_line_beg = (pos == BEGV || FETCH_BYTE (bytepos - 1) == '\n'); |
| 4590 | w->update_mode_line = 1; | 4623 | w->update_mode_line = 1; |
| 4591 | w->last_modified = 0; | 4624 | w->last_modified = 0; |
| @@ -5085,6 +5118,7 @@ displayed_window_lines (struct window *w) | |||
| 5085 | { | 5118 | { |
| 5086 | struct it it; | 5119 | struct it it; |
| 5087 | struct text_pos start; | 5120 | struct text_pos start; |
| 5121 | ptrdiff_t charpos = marker_position (w->start); | ||
| 5088 | int height = window_box_height (w); | 5122 | int height = window_box_height (w); |
| 5089 | struct buffer *old_buffer; | 5123 | struct buffer *old_buffer; |
| 5090 | int bottom_y; | 5124 | int bottom_y; |
| @@ -5101,9 +5135,9 @@ displayed_window_lines (struct window *w) | |||
| 5101 | /* In case W->start is out of the accessible range, do something | 5135 | /* In case W->start is out of the accessible range, do something |
| 5102 | reasonable. This happens in Info mode when Info-scroll-down | 5136 | reasonable. This happens in Info mode when Info-scroll-down |
| 5103 | calls (recenter -1) while W->start is 1. */ | 5137 | calls (recenter -1) while W->start is 1. */ |
| 5104 | if (XMARKER (w->start)->charpos < BEGV) | 5138 | if (charpos < BEGV) |
| 5105 | SET_TEXT_POS (start, BEGV, BEGV_BYTE); | 5139 | SET_TEXT_POS (start, BEGV, BEGV_BYTE); |
| 5106 | else if (XMARKER (w->start)->charpos > ZV) | 5140 | else if (charpos > ZV) |
| 5107 | SET_TEXT_POS (start, ZV, ZV_BYTE); | 5141 | SET_TEXT_POS (start, ZV, ZV_BYTE); |
| 5108 | else | 5142 | else |
| 5109 | SET_TEXT_POS_FROM_MARKER (start, w->start); | 5143 | SET_TEXT_POS_FROM_MARKER (start, w->start); |
| @@ -5312,8 +5346,8 @@ and redisplay normally--don't erase and redraw the frame. */) | |||
| 5312 | iarg += ht; | 5346 | iarg += ht; |
| 5313 | 5347 | ||
| 5314 | /* Don't let it get into the margin at either top or bottom. */ | 5348 | /* Don't let it get into the margin at either top or bottom. */ |
| 5315 | iarg = max (iarg, this_scroll_margin); | 5349 | iarg = clip_to_bounds (this_scroll_margin, iarg, |
| 5316 | iarg = min (iarg, ht - this_scroll_margin - 1); | 5350 | ht - this_scroll_margin - 1); |
| 5317 | 5351 | ||
| 5318 | pos = *vmotion (PT, - iarg, w); | 5352 | pos = *vmotion (PT, - iarg, w); |
| 5319 | charpos = pos.bufpos; | 5353 | charpos = pos.bufpos; |
| @@ -5322,7 +5356,7 @@ and redisplay normally--don't erase and redraw the frame. */) | |||
| 5322 | 5356 | ||
| 5323 | /* Set the new window start. */ | 5357 | /* Set the new window start. */ |
| 5324 | set_marker_both (w->start, w->buffer, charpos, bytepos); | 5358 | set_marker_both (w->start, w->buffer, charpos, bytepos); |
| 5325 | wset_window_end_valid (w, Qnil); | 5359 | w->window_end_valid = 0; |
| 5326 | 5360 | ||
| 5327 | w->optional_new_start = 1; | 5361 | w->optional_new_start = 1; |
| 5328 | 5362 | ||
| @@ -5531,7 +5565,7 @@ the return value is nil. Otherwise the value is t. */) | |||
| 5531 | && WINDOWP (selected_window) | 5565 | && WINDOWP (selected_window) |
| 5532 | && EQ (XWINDOW (selected_window)->buffer, new_current_buffer) | 5566 | && EQ (XWINDOW (selected_window)->buffer, new_current_buffer) |
| 5533 | && !EQ (selected_window, data->current_window)) | 5567 | && !EQ (selected_window, data->current_window)) |
| 5534 | old_point = XMARKER (XWINDOW (data->current_window)->pointm)->charpos; | 5568 | old_point = marker_position (XWINDOW (data->current_window)->pointm); |
| 5535 | else | 5569 | else |
| 5536 | old_point = PT; | 5570 | old_point = PT; |
| 5537 | else | 5571 | else |
| @@ -5546,7 +5580,7 @@ the return value is nil. Otherwise the value is t. */) | |||
| 5546 | if (EQ (XWINDOW (data->current_window)->buffer, new_current_buffer) | 5580 | if (EQ (XWINDOW (data->current_window)->buffer, new_current_buffer) |
| 5547 | /* If current_window = selected_window, its point is in BUF_PT. */ | 5581 | /* If current_window = selected_window, its point is in BUF_PT. */ |
| 5548 | && !EQ (selected_window, data->current_window)) | 5582 | && !EQ (selected_window, data->current_window)) |
| 5549 | old_point = XMARKER (XWINDOW (data->current_window)->pointm)->charpos; | 5583 | old_point = marker_position (XWINDOW (data->current_window)->pointm); |
| 5550 | else | 5584 | else |
| 5551 | old_point = BUF_PT (XBUFFER (new_current_buffer)); | 5585 | old_point = BUF_PT (XBUFFER (new_current_buffer)); |
| 5552 | } | 5586 | } |
| @@ -5762,8 +5796,7 @@ the return value is nil. Otherwise the value is t. */) | |||
| 5762 | { | 5796 | { |
| 5763 | /* Set window markers at start of visible range. */ | 5797 | /* Set window markers at start of visible range. */ |
| 5764 | if (XMARKER (w->start)->buffer == 0) | 5798 | if (XMARKER (w->start)->buffer == 0) |
| 5765 | set_marker_restricted (w->start, make_number (0), | 5799 | set_marker_restricted_both (w->start, w->buffer, 0, 0); |
| 5766 | w->buffer); | ||
| 5767 | if (XMARKER (w->pointm)->buffer == 0) | 5800 | if (XMARKER (w->pointm)->buffer == 0) |
| 5768 | set_marker_restricted_both | 5801 | set_marker_restricted_both |
| 5769 | (w->pointm, w->buffer, | 5802 | (w->pointm, w->buffer, |
| @@ -5781,10 +5814,8 @@ the return value is nil. Otherwise the value is t. */) | |||
| 5781 | wset_buffer (w, other_buffer_safely (Fcurrent_buffer ())); | 5814 | wset_buffer (w, other_buffer_safely (Fcurrent_buffer ())); |
| 5782 | /* This will set the markers to beginning of visible | 5815 | /* This will set the markers to beginning of visible |
| 5783 | range. */ | 5816 | range. */ |
| 5784 | set_marker_restricted (w->start, | 5817 | set_marker_restricted_both (w->start, w->buffer, 0, 0); |
| 5785 | make_number (0), w->buffer); | 5818 | set_marker_restricted_both (w->pointm, w->buffer, 0, 0); |
| 5786 | set_marker_restricted (w->pointm, | ||
| 5787 | make_number (0), w->buffer); | ||
| 5788 | w->start_at_line_beg = 1; | 5819 | w->start_at_line_beg = 1; |
| 5789 | if (!NILP (w->dedicated)) | 5820 | if (!NILP (w->dedicated)) |
| 5790 | /* Record this window as dead. */ | 5821 | /* Record this window as dead. */ |
| @@ -6157,11 +6188,11 @@ saved by this function. */) | |||
| 6157 | data->minibuf_selected_window = minibuf_level > 0 ? minibuf_selected_window : Qnil; | 6188 | data->minibuf_selected_window = minibuf_level > 0 ? minibuf_selected_window : Qnil; |
| 6158 | data->root_window = FRAME_ROOT_WINDOW (f); | 6189 | data->root_window = FRAME_ROOT_WINDOW (f); |
| 6159 | data->focus_frame = FRAME_FOCUS_FRAME (f); | 6190 | data->focus_frame = FRAME_FOCUS_FRAME (f); |
| 6160 | tem = Fmake_vector (make_number (n_windows), Qnil); | 6191 | tem = make_uninit_vector (n_windows); |
| 6161 | data->saved_windows = tem; | 6192 | data->saved_windows = tem; |
| 6162 | for (i = 0; i < n_windows; i++) | 6193 | for (i = 0; i < n_windows; i++) |
| 6163 | ASET (tem, i, | 6194 | ASET (tem, i, |
| 6164 | Fmake_vector (make_number (VECSIZE (struct saved_window)), Qnil)); | 6195 | Fmake_vector (make_number (VECSIZE (struct saved_window)), Qnil)); |
| 6165 | save_window_save (FRAME_ROOT_WINDOW (f), XVECTOR (tem), 0); | 6196 | save_window_save (FRAME_ROOT_WINDOW (f), XVECTOR (tem), 0); |
| 6166 | XSETWINDOW_CONFIGURATION (tem, data); | 6197 | XSETWINDOW_CONFIGURATION (tem, data); |
| 6167 | return (tem); | 6198 | return (tem); |
| @@ -6273,7 +6304,7 @@ display marginal areas and the text area. */) | |||
| 6273 | adjust_window_margins (w); | 6304 | adjust_window_margins (w); |
| 6274 | 6305 | ||
| 6275 | clear_glyph_matrix (w->current_matrix); | 6306 | clear_glyph_matrix (w->current_matrix); |
| 6276 | wset_window_end_valid (w, Qnil); | 6307 | w->window_end_valid = 0; |
| 6277 | 6308 | ||
| 6278 | ++windows_or_buffers_changed; | 6309 | ++windows_or_buffers_changed; |
| 6279 | adjust_glyphs (XFRAME (WINDOW_FRAME (w))); | 6310 | adjust_glyphs (XFRAME (WINDOW_FRAME (w))); |
| @@ -6343,7 +6374,7 @@ Fourth parameter HORIZONTAL-TYPE is currently unused. */) | |||
| 6343 | adjust_window_margins (w); | 6374 | adjust_window_margins (w); |
| 6344 | 6375 | ||
| 6345 | clear_glyph_matrix (w->current_matrix); | 6376 | clear_glyph_matrix (w->current_matrix); |
| 6346 | wset_window_end_valid (w, Qnil); | 6377 | w->window_end_valid = 0; |
| 6347 | 6378 | ||
| 6348 | ++windows_or_buffers_changed; | 6379 | ++windows_or_buffers_changed; |
| 6349 | adjust_glyphs (XFRAME (WINDOW_FRAME (w))); | 6380 | adjust_glyphs (XFRAME (WINDOW_FRAME (w))); |
| @@ -6747,7 +6778,8 @@ same combination. | |||
| 6747 | 6778 | ||
| 6748 | Other values are reserved for future use. | 6779 | Other values are reserved for future use. |
| 6749 | 6780 | ||
| 6750 | This variable takes no effect if `window-combination-limit' is non-nil. */); | 6781 | This variable takes no effect if the variable `window-combination-limit' is |
| 6782 | non-nil. */); | ||
| 6751 | Vwindow_combination_resize = Qnil; | 6783 | Vwindow_combination_resize = Qnil; |
| 6752 | 6784 | ||
| 6753 | DEFVAR_LISP ("window-combination-limit", Vwindow_combination_limit, | 6785 | DEFVAR_LISP ("window-combination-limit", Vwindow_combination_limit, |