diff options
| author | Tom Tromey | 2012-09-04 10:10:06 -0600 |
|---|---|---|
| committer | Tom Tromey | 2012-09-04 10:10:06 -0600 |
| commit | bf69f522a9e135f9aa483cedd53e71e915f2bf75 (patch) | |
| tree | 3f73c47fb863ef87f420de1d30858da821072bd9 /src/window.c | |
| parent | 303324a9232dbc89369faceb6b3530740d0fc1bd (diff) | |
| parent | 6ec9a5a7b5efb129807f567709ca858211ed7840 (diff) | |
| download | emacs-bf69f522a9e135f9aa483cedd53e71e915f2bf75.tar.gz emacs-bf69f522a9e135f9aa483cedd53e71e915f2bf75.zip | |
merge from trunk
Diffstat (limited to 'src/window.c')
| -rw-r--r-- | src/window.c | 103 |
1 files changed, 62 insertions, 41 deletions
diff --git a/src/window.c b/src/window.c index 20325711e73..732d5060d29 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -54,14 +54,15 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 54 | #include "nsterm.h" | 54 | #include "nsterm.h" |
| 55 | #endif | 55 | #endif |
| 56 | 56 | ||
| 57 | Lisp_Object Qwindowp, Qwindow_live_p, Qwindow_valid_p; | 57 | Lisp_Object Qwindowp, Qwindow_live_p; |
| 58 | static Lisp_Object Qwindow_valid_p; | ||
| 58 | static Lisp_Object Qwindow_configuration_p, Qrecord_window_buffer; | 59 | static Lisp_Object Qwindow_configuration_p, Qrecord_window_buffer; |
| 59 | static Lisp_Object Qwindow_deletable_p, Qdelete_window, Qdisplay_buffer; | 60 | static Lisp_Object Qwindow_deletable_p, Qdelete_window, Qdisplay_buffer; |
| 60 | static Lisp_Object Qreplace_buffer_in_windows, Qget_mru_window; | 61 | static Lisp_Object Qreplace_buffer_in_windows, Qget_mru_window; |
| 61 | 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; |
| 62 | static Lisp_Object Qscroll_up, Qscroll_down, Qscroll_command; | 63 | static Lisp_Object Qscroll_up, Qscroll_down, Qscroll_command; |
| 63 | static Lisp_Object Qsafe, Qabove, Qbelow; | 64 | static Lisp_Object Qsafe, Qabove, Qbelow; |
| 64 | static Lisp_Object Qauto_buffer_name, Qclone_of; | 65 | static Lisp_Object Qclone_of; |
| 65 | 66 | ||
| 66 | static int displayed_window_lines (struct window *); | 67 | static int displayed_window_lines (struct window *); |
| 67 | static int count_windows (struct window *); | 68 | static int count_windows (struct window *); |
| @@ -268,7 +269,7 @@ decode_any_window (register Lisp_Object window) | |||
| 268 | return w; | 269 | return w; |
| 269 | } | 270 | } |
| 270 | 271 | ||
| 271 | struct window * | 272 | static struct window * |
| 272 | decode_valid_window (register Lisp_Object window) | 273 | decode_valid_window (register Lisp_Object window) |
| 273 | { | 274 | { |
| 274 | struct window *w; | 275 | struct window *w; |
| @@ -1407,22 +1408,21 @@ DEFUN ("window-point", Fwindow_point, Swindow_point, 0, 1, 0, | |||
| 1407 | doc: /* Return current value of point in WINDOW. | 1408 | doc: /* Return current value of point in WINDOW. |
| 1408 | WINDOW must be a live window and defaults to the selected one. | 1409 | WINDOW must be a live window and defaults to the selected one. |
| 1409 | 1410 | ||
| 1410 | For a nonselected window, this is the value point would have | 1411 | For a nonselected window, this is the value point would have if that |
| 1411 | if that window were selected. | 1412 | window were selected. |
| 1412 | 1413 | ||
| 1413 | Note that, when WINDOW is the selected window and its buffer | 1414 | Note that, when WINDOW is selected, the value returned is the same as |
| 1414 | is also currently selected, the value returned is the same as (point). | 1415 | that returned by `point' for WINDOW's buffer. It would be more strictly |
| 1415 | It would be more strictly correct to return the `top-level' value | 1416 | correct to return the `top-level' value of `point', outside of any |
| 1416 | of point, outside of any save-excursion forms. | 1417 | `save-excursion' forms. But that is hard to define. */) |
| 1417 | But that is hard to define. */) | ||
| 1418 | (Lisp_Object window) | 1418 | (Lisp_Object window) |
| 1419 | { | 1419 | { |
| 1420 | register struct window *w = decode_live_window (window); | 1420 | register struct window *w = decode_live_window (window); |
| 1421 | 1421 | ||
| 1422 | if (w == XWINDOW (selected_window) | 1422 | if (w == XWINDOW (selected_window)) |
| 1423 | && current_buffer == XBUFFER (w->buffer)) | 1423 | return make_number (BUF_PT (XBUFFER (w->buffer))); |
| 1424 | return Fpoint (); | 1424 | else |
| 1425 | return Fmarker_position (w->pointm); | 1425 | return Fmarker_position (w->pointm); |
| 1426 | } | 1426 | } |
| 1427 | 1427 | ||
| 1428 | DEFUN ("window-start", Fwindow_start, Swindow_start, 0, 1, 0, | 1428 | DEFUN ("window-start", Fwindow_start, Swindow_start, 0, 1, 0, |
| @@ -1532,16 +1532,27 @@ Return POS. */) | |||
| 1532 | register struct window *w = decode_live_window (window); | 1532 | register struct window *w = decode_live_window (window); |
| 1533 | 1533 | ||
| 1534 | CHECK_NUMBER_COERCE_MARKER (pos); | 1534 | CHECK_NUMBER_COERCE_MARKER (pos); |
| 1535 | if (w == XWINDOW (selected_window) | ||
| 1536 | && XBUFFER (w->buffer) == current_buffer) | ||
| 1537 | Fgoto_char (pos); | ||
| 1538 | else | ||
| 1539 | set_marker_restricted (w->pointm, pos, w->buffer); | ||
| 1540 | 1535 | ||
| 1541 | /* We have to make sure that redisplay updates the window to show | 1536 | if (w == XWINDOW (selected_window)) |
| 1542 | the new value of point. */ | 1537 | { |
| 1543 | if (!EQ (window, selected_window)) | 1538 | if (XBUFFER (w->buffer) == current_buffer) |
| 1544 | ++windows_or_buffers_changed; | 1539 | Fgoto_char (pos); |
| 1540 | else | ||
| 1541 | { | ||
| 1542 | struct buffer *old_buffer = current_buffer; | ||
| 1543 | |||
| 1544 | set_buffer_internal (XBUFFER (w->buffer)); | ||
| 1545 | Fgoto_char (pos); | ||
| 1546 | set_buffer_internal (old_buffer); | ||
| 1547 | } | ||
| 1548 | } | ||
| 1549 | else | ||
| 1550 | { | ||
| 1551 | set_marker_restricted (w->pointm, pos, w->buffer); | ||
| 1552 | /* We have to make sure that redisplay updates the window to show | ||
| 1553 | the new value of point. */ | ||
| 1554 | ++windows_or_buffers_changed; | ||
| 1555 | } | ||
| 1545 | 1556 | ||
| 1546 | return pos; | 1557 | return pos; |
| 1547 | } | 1558 | } |
| @@ -1958,6 +1969,9 @@ unshow_buffer (register struct window *w) | |||
| 1958 | is actually stored in that buffer, and the window's pointm isn't used. | 1969 | is actually stored in that buffer, and the window's pointm isn't used. |
| 1959 | So don't clobber point in that buffer. */ | 1970 | So don't clobber point in that buffer. */ |
| 1960 | if (! EQ (buf, XWINDOW (selected_window)->buffer) | 1971 | if (! EQ (buf, XWINDOW (selected_window)->buffer) |
| 1972 | /* Don't clobber point in current buffer either (this could be | ||
| 1973 | useful in connection with bug#12208). | ||
| 1974 | && XBUFFER (buf) != current_buffer */ | ||
| 1961 | /* This line helps to fix Horsley's testbug.el bug. */ | 1975 | /* This line helps to fix Horsley's testbug.el bug. */ |
| 1962 | && !(WINDOWP (BVAR (b, last_selected_window)) | 1976 | && !(WINDOWP (BVAR (b, last_selected_window)) |
| 1963 | && w != XWINDOW (BVAR (b, last_selected_window)) | 1977 | && w != XWINDOW (BVAR (b, last_selected_window)) |
| @@ -3087,7 +3101,7 @@ run_window_configuration_change_hook (struct frame *f) | |||
| 3087 | /* Use the right buffer. Matters when running the local hooks. */ | 3101 | /* Use the right buffer. Matters when running the local hooks. */ |
| 3088 | if (current_buffer != XBUFFER (Fwindow_buffer (Qnil))) | 3102 | if (current_buffer != XBUFFER (Fwindow_buffer (Qnil))) |
| 3089 | { | 3103 | { |
| 3090 | record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); | 3104 | record_unwind_current_buffer (); |
| 3091 | Fset_buffer (Fwindow_buffer (Qnil)); | 3105 | Fset_buffer (Fwindow_buffer (Qnil)); |
| 3092 | } | 3106 | } |
| 3093 | 3107 | ||
| @@ -3124,7 +3138,7 @@ run_window_configuration_change_hook (struct frame *f) | |||
| 3124 | DEFUN ("run-window-configuration-change-hook", Frun_window_configuration_change_hook, | 3138 | DEFUN ("run-window-configuration-change-hook", Frun_window_configuration_change_hook, |
| 3125 | Srun_window_configuration_change_hook, 1, 1, 0, | 3139 | Srun_window_configuration_change_hook, 1, 1, 0, |
| 3126 | doc: /* Run `window-configuration-change-hook' for FRAME. */) | 3140 | doc: /* Run `window-configuration-change-hook' for FRAME. */) |
| 3127 | (Lisp_Object frame) | 3141 | (Lisp_Object frame) |
| 3128 | { | 3142 | { |
| 3129 | CHECK_LIVE_FRAME (frame); | 3143 | CHECK_LIVE_FRAME (frame); |
| 3130 | run_window_configuration_change_hook (XFRAME (frame)); | 3144 | run_window_configuration_change_hook (XFRAME (frame)); |
| @@ -3191,7 +3205,7 @@ set_window_buffer (Lisp_Object window, Lisp_Object buffer, int run_hooks_p, int | |||
| 3191 | because that might itself be a local variable. */ | 3205 | because that might itself be a local variable. */ |
| 3192 | if (window_initialized) | 3206 | if (window_initialized) |
| 3193 | { | 3207 | { |
| 3194 | record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); | 3208 | record_unwind_current_buffer (); |
| 3195 | Fset_buffer (buffer); | 3209 | Fset_buffer (buffer); |
| 3196 | } | 3210 | } |
| 3197 | 3211 | ||
| @@ -5526,7 +5540,6 @@ the return value is nil. Otherwise the value is t. */) | |||
| 5526 | struct Lisp_Vector *saved_windows; | 5540 | struct Lisp_Vector *saved_windows; |
| 5527 | Lisp_Object new_current_buffer; | 5541 | Lisp_Object new_current_buffer; |
| 5528 | Lisp_Object frame; | 5542 | Lisp_Object frame; |
| 5529 | Lisp_Object auto_buffer_name; | ||
| 5530 | FRAME_PTR f; | 5543 | FRAME_PTR f; |
| 5531 | ptrdiff_t old_point = -1; | 5544 | ptrdiff_t old_point = -1; |
| 5532 | 5545 | ||
| @@ -5602,6 +5615,21 @@ the return value is nil. Otherwise the value is t. */) | |||
| 5602 | int previous_frame_menu_bar_lines = FRAME_MENU_BAR_LINES (f); | 5615 | int previous_frame_menu_bar_lines = FRAME_MENU_BAR_LINES (f); |
| 5603 | int previous_frame_tool_bar_lines = FRAME_TOOL_BAR_LINES (f); | 5616 | int previous_frame_tool_bar_lines = FRAME_TOOL_BAR_LINES (f); |
| 5604 | 5617 | ||
| 5618 | /* Don't do this within the main loop below: This may call Lisp | ||
| 5619 | code and is thus potentially unsafe while input is blocked. */ | ||
| 5620 | for (k = 0; k < saved_windows->header.size; k++) | ||
| 5621 | { | ||
| 5622 | p = SAVED_WINDOW_N (saved_windows, k); | ||
| 5623 | window = p->window; | ||
| 5624 | w = XWINDOW (window); | ||
| 5625 | if (!NILP (w->buffer) | ||
| 5626 | && !EQ (w->buffer, p->buffer) | ||
| 5627 | && !NILP (BVAR (XBUFFER (p->buffer), name))) | ||
| 5628 | /* If a window we restore gets another buffer, record the | ||
| 5629 | window's old buffer. */ | ||
| 5630 | call1 (Qrecord_window_buffer, window); | ||
| 5631 | } | ||
| 5632 | |||
| 5605 | /* The mouse highlighting code could get screwed up | 5633 | /* The mouse highlighting code could get screwed up |
| 5606 | if it runs during this. */ | 5634 | if it runs during this. */ |
| 5607 | BLOCK_INPUT; | 5635 | BLOCK_INPUT; |
| @@ -5780,18 +5808,6 @@ the return value is nil. Otherwise the value is t. */) | |||
| 5780 | BUF_PT_BYTE (XBUFFER (w->buffer))); | 5808 | BUF_PT_BYTE (XBUFFER (w->buffer))); |
| 5781 | w->start_at_line_beg = 1; | 5809 | w->start_at_line_beg = 1; |
| 5782 | } | 5810 | } |
| 5783 | else if (STRINGP (auto_buffer_name = | ||
| 5784 | Fwindow_parameter (window, Qauto_buffer_name)) | ||
| 5785 | && SCHARS (auto_buffer_name) != 0 | ||
| 5786 | && (wset_buffer (w, Fget_buffer_create (auto_buffer_name)), | ||
| 5787 | !NILP (w->buffer))) | ||
| 5788 | { | ||
| 5789 | set_marker_restricted (w->start, | ||
| 5790 | make_number (0), w->buffer); | ||
| 5791 | set_marker_restricted (w->pointm, | ||
| 5792 | make_number (0), w->buffer); | ||
| 5793 | w->start_at_line_beg = 1; | ||
| 5794 | } | ||
| 5795 | else | 5811 | else |
| 5796 | /* Window has no live buffer, get one. */ | 5812 | /* Window has no live buffer, get one. */ |
| 5797 | { | 5813 | { |
| @@ -5889,7 +5905,13 @@ the return value is nil. Otherwise the value is t. */) | |||
| 5889 | } | 5905 | } |
| 5890 | 5906 | ||
| 5891 | if (!NILP (new_current_buffer)) | 5907 | if (!NILP (new_current_buffer)) |
| 5892 | Fset_buffer (new_current_buffer); | 5908 | { |
| 5909 | Fset_buffer (new_current_buffer); | ||
| 5910 | /* If the new current buffer doesn't appear in the selected | ||
| 5911 | window, go to its old point (see bug#12208). */ | ||
| 5912 | if (!EQ (XWINDOW (data->current_window)->buffer, new_current_buffer)) | ||
| 5913 | Fgoto_char (make_number (old_point)); | ||
| 5914 | } | ||
| 5893 | 5915 | ||
| 5894 | Vminibuf_scroll_window = data->minibuf_scroll_window; | 5916 | Vminibuf_scroll_window = data->minibuf_scroll_window; |
| 5895 | minibuf_selected_window = data->minibuf_selected_window; | 5917 | minibuf_selected_window = data->minibuf_selected_window; |
| @@ -6691,7 +6713,6 @@ syms_of_window (void) | |||
| 6691 | DEFSYM (Qtemp_buffer_show_hook, "temp-buffer-show-hook"); | 6713 | DEFSYM (Qtemp_buffer_show_hook, "temp-buffer-show-hook"); |
| 6692 | DEFSYM (Qabove, "above"); | 6714 | DEFSYM (Qabove, "above"); |
| 6693 | DEFSYM (Qbelow, "below"); | 6715 | DEFSYM (Qbelow, "below"); |
| 6694 | DEFSYM (Qauto_buffer_name, "auto-buffer-name"); | ||
| 6695 | DEFSYM (Qclone_of, "clone-of"); | 6716 | DEFSYM (Qclone_of, "clone-of"); |
| 6696 | 6717 | ||
| 6697 | staticpro (&Vwindow_list); | 6718 | staticpro (&Vwindow_list); |