diff options
| author | Joakim Verona | 2012-12-11 12:02:20 +0100 |
|---|---|---|
| committer | Joakim Verona | 2012-12-11 12:02:20 +0100 |
| commit | 5ccd4f20470d8e216ca3eae26339100a5eab52f1 (patch) | |
| tree | 70caca485fbaef0dcce16a811908c4b9b121ee1e /src/window.c | |
| parent | c0b95835acf65071ac1d740d15f7bcaa55c2a04b (diff) | |
| parent | c6afe371b0218154957bbef17c3f8bda5377b7c8 (diff) | |
| download | emacs-5ccd4f20470d8e216ca3eae26339100a5eab52f1.tar.gz emacs-5ccd4f20470d8e216ca3eae26339100a5eab52f1.zip | |
some conflict resolution
Diffstat (limited to 'src/window.c')
| -rw-r--r-- | src/window.c | 81 |
1 files changed, 58 insertions, 23 deletions
diff --git a/src/window.c b/src/window.c index 0340044ca21..4631a898d3e 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -271,6 +271,35 @@ decode_valid_window (register Lisp_Object window) | |||
| 271 | return w; | 271 | return w; |
| 272 | } | 272 | } |
| 273 | 273 | ||
| 274 | /* Called when W's buffer slot is changed. ARG -1 means that W is about to | ||
| 275 | cease its buffer, and 1 means that W is about to set up the new one. */ | ||
| 276 | |||
| 277 | static void | ||
| 278 | adjust_window_count (struct window *w, int arg) | ||
| 279 | { | ||
| 280 | eassert (eabs (arg) == 1); | ||
| 281 | if (BUFFERP (w->buffer)) | ||
| 282 | { | ||
| 283 | struct buffer *b = XBUFFER (w->buffer); | ||
| 284 | |||
| 285 | if (b->base_buffer) | ||
| 286 | b = b->base_buffer; | ||
| 287 | b->window_count += arg; | ||
| 288 | eassert (b->window_count >= 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 | |||
| 274 | /* Build a frequently used 4-integer (X Y W H) list. */ | 303 | /* Build a frequently used 4-integer (X Y W H) list. */ |
| 275 | 304 | ||
| 276 | static Lisp_Object | 305 | static Lisp_Object |
| @@ -1464,6 +1493,7 @@ if it isn't already recorded. */) | |||
| 1464 | && !noninteractive) | 1493 | && !noninteractive) |
| 1465 | { | 1494 | { |
| 1466 | struct text_pos startp; | 1495 | struct text_pos startp; |
| 1496 | ptrdiff_t charpos = marker_position (w->start); | ||
| 1467 | struct it it; | 1497 | struct it it; |
| 1468 | struct buffer *old_buffer = NULL; | 1498 | struct buffer *old_buffer = NULL; |
| 1469 | void *itdata = NULL; | 1499 | void *itdata = NULL; |
| @@ -1481,9 +1511,9 @@ if it isn't already recorded. */) | |||
| 1481 | `-l' containing a call to `rmail' with subsequent other | 1511 | `-l' containing a call to `rmail' with subsequent other |
| 1482 | commands. At the end, W->start happened to be BEG, while | 1512 | commands. At the end, W->start happened to be BEG, while |
| 1483 | rmail had already narrowed the buffer. */ | 1513 | rmail had already narrowed the buffer. */ |
| 1484 | if (XMARKER (w->start)->charpos < BEGV) | 1514 | if (charpos < BEGV) |
| 1485 | SET_TEXT_POS (startp, BEGV, BEGV_BYTE); | 1515 | SET_TEXT_POS (startp, BEGV, BEGV_BYTE); |
| 1486 | else if (XMARKER (w->start)->charpos > ZV) | 1516 | else if (charpos > ZV) |
| 1487 | SET_TEXT_POS (startp, ZV, ZV_BYTE); | 1517 | SET_TEXT_POS (startp, ZV, ZV_BYTE); |
| 1488 | else | 1518 | else |
| 1489 | SET_TEXT_POS_FROM_MARKER (startp, w->start); | 1519 | SET_TEXT_POS_FROM_MARKER (startp, w->start); |
| @@ -1606,7 +1636,7 @@ display row, and VPOS is the row number (0-based) containing POS. */) | |||
| 1606 | else if (w == XWINDOW (selected_window)) | 1636 | else if (w == XWINDOW (selected_window)) |
| 1607 | posint = PT; | 1637 | posint = PT; |
| 1608 | else | 1638 | else |
| 1609 | posint = XMARKER (w->pointm)->charpos; | 1639 | posint = marker_position (w->pointm); |
| 1610 | 1640 | ||
| 1611 | /* If position is above window start or outside buffer boundaries, | 1641 | /* If position is above window start or outside buffer boundaries, |
| 1612 | or if window start is out of range, position is not visible. */ | 1642 | or if window start is out of range, position is not visible. */ |
| @@ -1952,7 +1982,7 @@ unshow_buffer (register struct window *w) | |||
| 1952 | && EQ (buf, XWINDOW (BVAR (b, last_selected_window))->buffer))) | 1982 | && EQ (buf, XWINDOW (BVAR (b, last_selected_window))->buffer))) |
| 1953 | temp_set_point_both (b, | 1983 | temp_set_point_both (b, |
| 1954 | clip_to_bounds (BUF_BEGV (b), | 1984 | clip_to_bounds (BUF_BEGV (b), |
| 1955 | XMARKER (w->pointm)->charpos, | 1985 | marker_position (w->pointm), |
| 1956 | BUF_ZV (b)), | 1986 | BUF_ZV (b)), |
| 1957 | clip_to_bounds (BUF_BEGV_BYTE (b), | 1987 | clip_to_bounds (BUF_BEGV_BYTE (b), |
| 1958 | marker_byte_position (w->pointm), | 1988 | marker_byte_position (w->pointm), |
| @@ -2959,22 +2989,24 @@ replace_buffer_in_windows (Lisp_Object buffer) | |||
| 2959 | call1 (Qreplace_buffer_in_windows, buffer); | 2989 | call1 (Qreplace_buffer_in_windows, buffer); |
| 2960 | } | 2990 | } |
| 2961 | 2991 | ||
| 2962 | 2992 | /* If BUFFER is shown in a window, safely replace it with some other | |
| 2963 | /* 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. */ |
| 2964 | frames, even those on other keyboards. */ | ||
| 2965 | 2994 | ||
| 2966 | void | 2995 | void |
| 2967 | replace_buffer_in_windows_safely (Lisp_Object buffer) | 2996 | replace_buffer_in_windows_safely (Lisp_Object buffer) |
| 2968 | { | 2997 | { |
| 2969 | Lisp_Object tail, frame; | 2998 | if (buffer_window_count (XBUFFER (buffer))) |
| 2999 | { | ||
| 3000 | Lisp_Object tail, frame; | ||
| 2970 | 3001 | ||
| 2971 | /* 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 |
| 2972 | considers frames on the current keyboard. So loop manually over | 3003 | considers frames on the current keyboard. So loop manually over |
| 2973 | frames, and handle each one. */ | 3004 | frames, and handle each one. */ |
| 2974 | FOR_EACH_FRAME (tail, frame) | 3005 | FOR_EACH_FRAME (tail, frame) |
| 2975 | window_loop (REPLACE_BUFFER_IN_WINDOWS_SAFELY, buffer, 1, frame); | 3006 | window_loop (REPLACE_BUFFER_IN_WINDOWS_SAFELY, buffer, 1, frame); |
| 3007 | } | ||
| 2976 | } | 3008 | } |
| 2977 | 3009 | ||
| 2978 | /* 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 |
| 2979 | minimum allowable size. */ | 3011 | minimum allowable size. */ |
| 2980 | 3012 | ||
| @@ -3309,11 +3341,11 @@ displaying that buffer. */) | |||
| 3309 | 3341 | ||
| 3310 | if (STRINGP (object)) | 3342 | if (STRINGP (object)) |
| 3311 | object = Fget_buffer (object); | 3343 | object = Fget_buffer (object); |
| 3312 | if (BUFFERP (object) && BUFFER_LIVE_P (XBUFFER (object))) | 3344 | if (BUFFERP (object) && BUFFER_LIVE_P (XBUFFER (object)) |
| 3345 | && buffer_window_count (XBUFFER (object))) | ||
| 3313 | { | 3346 | { |
| 3314 | /* Walk all windows looking for buffer, and force update | 3347 | /* If buffer is live and shown in at least one window, find |
| 3315 | of each of those windows. */ | 3348 | all windows showing this buffer and force update of them. */ |
| 3316 | |||
| 3317 | object = window_loop (REDISPLAY_BUFFER_WINDOWS, object, 0, Qvisible); | 3349 | object = window_loop (REDISPLAY_BUFFER_WINDOWS, object, 0, Qvisible); |
| 3318 | return NILP (object) ? Qnil : Qt; | 3350 | return NILP (object) ? Qnil : Qt; |
| 3319 | } | 3351 | } |
| @@ -3392,6 +3424,8 @@ make_parent_window (Lisp_Object window, int horflag) | |||
| 3392 | memcpy ((char *) p + sizeof (struct vectorlike_header), | 3424 | memcpy ((char *) p + sizeof (struct vectorlike_header), |
| 3393 | (char *) o + sizeof (struct vectorlike_header), | 3425 | (char *) o + sizeof (struct vectorlike_header), |
| 3394 | 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); | ||
| 3395 | XSETWINDOW (parent, p); | 3429 | XSETWINDOW (parent, p); |
| 3396 | 3430 | ||
| 3397 | p->sequence_number = ++sequence_number; | 3431 | p->sequence_number = ++sequence_number; |
| @@ -4589,7 +4623,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror) | |||
| 4589 | /* Set the window start, and set up the window for redisplay. */ | 4623 | /* Set the window start, and set up the window for redisplay. */ |
| 4590 | set_marker_restricted (w->start, make_number (pos), | 4624 | set_marker_restricted (w->start, make_number (pos), |
| 4591 | w->buffer); | 4625 | w->buffer); |
| 4592 | bytepos = XMARKER (w->start)->bytepos; | 4626 | bytepos = marker_byte_position (w->start); |
| 4593 | w->start_at_line_beg = (pos == BEGV || FETCH_BYTE (bytepos - 1) == '\n'); | 4627 | w->start_at_line_beg = (pos == BEGV || FETCH_BYTE (bytepos - 1) == '\n'); |
| 4594 | w->update_mode_line = 1; | 4628 | w->update_mode_line = 1; |
| 4595 | w->last_modified = 0; | 4629 | w->last_modified = 0; |
| @@ -5089,6 +5123,7 @@ displayed_window_lines (struct window *w) | |||
| 5089 | { | 5123 | { |
| 5090 | struct it it; | 5124 | struct it it; |
| 5091 | struct text_pos start; | 5125 | struct text_pos start; |
| 5126 | ptrdiff_t charpos = marker_position (w->start); | ||
| 5092 | int height = window_box_height (w); | 5127 | int height = window_box_height (w); |
| 5093 | struct buffer *old_buffer; | 5128 | struct buffer *old_buffer; |
| 5094 | int bottom_y; | 5129 | int bottom_y; |
| @@ -5105,9 +5140,9 @@ displayed_window_lines (struct window *w) | |||
| 5105 | /* In case W->start is out of the accessible range, do something | 5140 | /* In case W->start is out of the accessible range, do something |
| 5106 | reasonable. This happens in Info mode when Info-scroll-down | 5141 | reasonable. This happens in Info mode when Info-scroll-down |
| 5107 | calls (recenter -1) while W->start is 1. */ | 5142 | calls (recenter -1) while W->start is 1. */ |
| 5108 | if (XMARKER (w->start)->charpos < BEGV) | 5143 | if (charpos < BEGV) |
| 5109 | SET_TEXT_POS (start, BEGV, BEGV_BYTE); | 5144 | SET_TEXT_POS (start, BEGV, BEGV_BYTE); |
| 5110 | else if (XMARKER (w->start)->charpos > ZV) | 5145 | else if (charpos > ZV) |
| 5111 | SET_TEXT_POS (start, ZV, ZV_BYTE); | 5146 | SET_TEXT_POS (start, ZV, ZV_BYTE); |
| 5112 | else | 5147 | else |
| 5113 | SET_TEXT_POS_FROM_MARKER (start, w->start); | 5148 | SET_TEXT_POS_FROM_MARKER (start, w->start); |
| @@ -5535,7 +5570,7 @@ the return value is nil. Otherwise the value is t. */) | |||
| 5535 | && WINDOWP (selected_window) | 5570 | && WINDOWP (selected_window) |
| 5536 | && EQ (XWINDOW (selected_window)->buffer, new_current_buffer) | 5571 | && EQ (XWINDOW (selected_window)->buffer, new_current_buffer) |
| 5537 | && !EQ (selected_window, data->current_window)) | 5572 | && !EQ (selected_window, data->current_window)) |
| 5538 | old_point = XMARKER (XWINDOW (data->current_window)->pointm)->charpos; | 5573 | old_point = marker_position (XWINDOW (data->current_window)->pointm); |
| 5539 | else | 5574 | else |
| 5540 | old_point = PT; | 5575 | old_point = PT; |
| 5541 | else | 5576 | else |
| @@ -5550,7 +5585,7 @@ the return value is nil. Otherwise the value is t. */) | |||
| 5550 | if (EQ (XWINDOW (data->current_window)->buffer, new_current_buffer) | 5585 | if (EQ (XWINDOW (data->current_window)->buffer, new_current_buffer) |
| 5551 | /* If current_window = selected_window, its point is in BUF_PT. */ | 5586 | /* If current_window = selected_window, its point is in BUF_PT. */ |
| 5552 | && !EQ (selected_window, data->current_window)) | 5587 | && !EQ (selected_window, data->current_window)) |
| 5553 | old_point = XMARKER (XWINDOW (data->current_window)->pointm)->charpos; | 5588 | old_point = marker_position (XWINDOW (data->current_window)->pointm); |
| 5554 | else | 5589 | else |
| 5555 | old_point = BUF_PT (XBUFFER (new_current_buffer)); | 5590 | old_point = BUF_PT (XBUFFER (new_current_buffer)); |
| 5556 | } | 5591 | } |