Mercurial > emacs
comparison src/window.c @ 112422:e99b4c7a3af4
Rework 2011-01-15 changes to window.c.
* src/window.c (select_window): New function.
(Fselect_window): Call it.
(inhibit_point_swap): Variable deleted.
(Fset_window_configuration): Call select_window directly.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Fri, 21 Jan 2011 21:44:53 -0500 |
parents | bee0a8fef127 |
children | 550574f08669 |
comparison
equal
deleted
inserted
replaced
112421:36dcbf24a6f1 | 112422:e99b4c7a3af4 |
---|---|
83 Lisp_Object *)); | 83 Lisp_Object *)); |
84 static int foreach_window_1 P_ ((struct window *, | 84 static int foreach_window_1 P_ ((struct window *, |
85 int (* fn) (struct window *, void *), | 85 int (* fn) (struct window *, void *), |
86 void *)); | 86 void *)); |
87 static Lisp_Object window_list_1 P_ ((Lisp_Object, Lisp_Object, Lisp_Object)); | 87 static Lisp_Object window_list_1 P_ ((Lisp_Object, Lisp_Object, Lisp_Object)); |
88 static Lisp_Object select_window _P ((Lisp_Object, Lisp_Object, int)); | |
88 | 89 |
89 /* This is the window in which the terminal's cursor should | 90 /* This is the window in which the terminal's cursor should |
90 be left when nothing is being done with it. This must | 91 be left when nothing is being done with it. This must |
91 always be a leaf window, and its buffer is selected by | 92 always be a leaf window, and its buffer is selected by |
92 the top level editing loop at the end of each command. | 93 the top level editing loop at the end of each command. |
155 static int sequence_number; | 156 static int sequence_number; |
156 | 157 |
157 /* Nonzero after init_window_once has finished. */ | 158 /* Nonzero after init_window_once has finished. */ |
158 | 159 |
159 static int window_initialized; | 160 static int window_initialized; |
160 | |
161 /* Set in `set-window-configuration' to prevent "swapping out point" | |
162 in the old selected window. */ | |
163 | |
164 static int inhibit_point_swap; | |
165 | 161 |
166 /* Hook to run when window config changes. */ | 162 /* Hook to run when window config changes. */ |
167 | 163 |
168 static Lisp_Object Qwindow_configuration_change_hook; | 164 static Lisp_Object Qwindow_configuration_change_hook; |
169 static Lisp_Object Vwindow_configuration_change_hook; | 165 static Lisp_Object Vwindow_configuration_change_hook; |
3583 | 3579 |
3584 set_window_buffer (window, buffer, 1, !NILP (keep_margins)); | 3580 set_window_buffer (window, buffer, 1, !NILP (keep_margins)); |
3585 return Qnil; | 3581 return Qnil; |
3586 } | 3582 } |
3587 | 3583 |
3588 /* Note that selected_window can be nil when this is called from | 3584 /* If select_window is called with inhibit_point_swap non-zero it will |
3589 Fset_window_configuration. */ | 3585 not store point of the old selected window's buffer back into that |
3590 | 3586 window's pointm slot. This is needed by Fset_window_configuration to |
3591 DEFUN ("select-window", Fselect_window, Sselect_window, 1, 2, 0, | 3587 avoid that the display routine is called with selected_window set to |
3592 doc: /* Select WINDOW. Most editing will apply to WINDOW's buffer. | 3588 Qnil causing a subsequent crash. */ |
3593 If WINDOW is not already selected, make WINDOW's buffer current | 3589 |
3594 and make WINDOW the frame's selected window. Return WINDOW. | 3590 static Lisp_Object |
3595 Optional second arg NORECORD non-nil means do not put this buffer | 3591 select_window (window, norecord, inhibit_point_swap) |
3596 at the front of the list of recently selected ones and do not | 3592 Lisp_Object window, norecord; |
3597 make this window the most recently selected one. | 3593 int inhibit_point_swap; |
3598 | |
3599 Note that the main editor command loop selects the buffer of the | |
3600 selected window before each command. */) | |
3601 (window, norecord) | |
3602 register Lisp_Object window, norecord; | |
3603 { | 3594 { |
3604 register struct window *w; | 3595 register struct window *w; |
3605 register struct window *ow; | 3596 register struct window *ow; |
3606 struct frame *sf; | 3597 struct frame *sf; |
3607 | 3598 |
3636 sf->selected_window = window; | 3627 sf->selected_window = window; |
3637 | 3628 |
3638 /* Store the current buffer's actual point into the | 3629 /* Store the current buffer's actual point into the |
3639 old selected window. It belongs to that window, | 3630 old selected window. It belongs to that window, |
3640 and when the window is not selected, must be in the window. */ | 3631 and when the window is not selected, must be in the window. */ |
3641 if (inhibit_point_swap) | 3632 if (!inhibit_point_swap) |
3642 inhibit_point_swap = 0; | |
3643 else | |
3644 { | 3633 { |
3645 ow = XWINDOW (selected_window); | 3634 ow = XWINDOW (selected_window); |
3646 if (! NILP (ow->buffer)) | 3635 if (! NILP (ow->buffer)) |
3647 set_marker_both (ow->pointm, ow->buffer, | 3636 set_marker_both (ow->pointm, ow->buffer, |
3648 BUF_PT (XBUFFER (ow->buffer)), | 3637 BUF_PT (XBUFFER (ow->buffer)), |
3672 SET_PT (new_point); | 3661 SET_PT (new_point); |
3673 } | 3662 } |
3674 | 3663 |
3675 windows_or_buffers_changed++; | 3664 windows_or_buffers_changed++; |
3676 return window; | 3665 return window; |
3666 } | |
3667 | |
3668 | |
3669 /* Note that selected_window can be nil when this is called from | |
3670 Fset_window_configuration. */ | |
3671 | |
3672 DEFUN ("select-window", Fselect_window, Sselect_window, 1, 2, 0, | |
3673 doc: /* Select WINDOW. Most editing will apply to WINDOW's buffer. | |
3674 If WINDOW is not already selected, make WINDOW's buffer current | |
3675 and make WINDOW the frame's selected window. Return WINDOW. | |
3676 Optional second arg NORECORD non-nil means do not put this buffer | |
3677 at the front of the list of recently selected ones and do not | |
3678 make this window the most recently selected one. | |
3679 | |
3680 Note that the main editor command loop selects the buffer of the | |
3681 selected window before each command. */) | |
3682 (window, norecord) | |
3683 register Lisp_Object window, norecord; | |
3684 { | |
3685 select_window (window, norecord, 0); | |
3677 } | 3686 } |
3678 | 3687 |
3679 static Lisp_Object | 3688 static Lisp_Object |
3680 select_window_norecord (window) | 3689 select_window_norecord (window) |
3681 Lisp_Object window; | 3690 Lisp_Object window; |
6253 | 6262 |
6254 /* In the following call to `select-window, prevent "swapping | 6263 /* In the following call to `select-window, prevent "swapping |
6255 out point" in the old selected window using the buffer that | 6264 out point" in the old selected window using the buffer that |
6256 has been restored into it. We already swapped out that point | 6265 has been restored into it. We already swapped out that point |
6257 from that window's old buffer. */ | 6266 from that window's old buffer. */ |
6258 inhibit_point_swap = 1; | 6267 select_window (data->current_window, Qnil, 1); |
6259 Fselect_window (data->current_window, Qnil); | |
6260 XBUFFER (XWINDOW (selected_window)->buffer)->last_selected_window | 6268 XBUFFER (XWINDOW (selected_window)->buffer)->last_selected_window |
6261 = selected_window; | 6269 = selected_window; |
6262 | 6270 |
6263 if (NILP (data->focus_frame) | 6271 if (NILP (data->focus_frame) |
6264 || (FRAMEP (data->focus_frame) | 6272 || (FRAMEP (data->focus_frame) |
7211 | 7219 |
7212 window_scroll_pixel_based_preserve_x = -1; | 7220 window_scroll_pixel_based_preserve_x = -1; |
7213 window_scroll_pixel_based_preserve_y = -1; | 7221 window_scroll_pixel_based_preserve_y = -1; |
7214 window_scroll_preserve_hpos = -1; | 7222 window_scroll_preserve_hpos = -1; |
7215 window_scroll_preserve_vpos = -1; | 7223 window_scroll_preserve_vpos = -1; |
7216 | |
7217 inhibit_point_swap = 0; | |
7218 | 7224 |
7219 DEFVAR_LISP ("temp-buffer-show-function", &Vtemp_buffer_show_function, | 7225 DEFVAR_LISP ("temp-buffer-show-function", &Vtemp_buffer_show_function, |
7220 doc: /* Non-nil means call as function to display a help buffer. | 7226 doc: /* Non-nil means call as function to display a help buffer. |
7221 The function is called with one argument, the buffer to be displayed. | 7227 The function is called with one argument, the buffer to be displayed. |
7222 Used by `with-output-to-temp-buffer'. | 7228 Used by `with-output-to-temp-buffer'. |