aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartin Rudalics2011-06-06 15:57:49 +0200
committerMartin Rudalics2011-06-06 15:57:49 +0200
commit727e958ef0548f3d8ce02a4a971247f52cc548ce (patch)
tree2b1eb83cafeb3b8c6b337d8fc41451db86f24e98 /src
parentbf60a96bc62eb465a482f5f95859a1147d0003d8 (diff)
downloademacs-727e958ef0548f3d8ce02a4a971247f52cc548ce.tar.gz
emacs-727e958ef0548f3d8ce02a4a971247f52cc548ce.zip
Move some window-related functions from frame.c to window.c.
* lisp.h: Move EXFUNS for Fframe_root_window, Fframe_first_window and Fset_frame_selected_window to window.h. * window.h: Move EXFUNS for Fframe_root_window, Fframe_first_window and Fset_frame_selected_window here from lisp.h. * frame.c (Fwindow_frame, Fframe_first_window) (Fframe_root_window, Fframe_selected_window) (Fset_frame_selected_window): Move to window.c. (Factive_minibuffer_window): Move to minibuf.c. (Fother_visible_frames_p): New function. * minibuf.c (Factive_minibuffer_window): Move here from frame.c. * window.c (Fwindow_frame): Move here from frame.c. Accept any window as argument. (Fframe_root_window, Fframe_first_window) (Fframe_selected_window): Move here from frame.c. Accept frame or arbitrary window as argument. Update doc-strings. (Fminibuffer_window): Move up in code. (Fwindow_minibuffer_p): Move up in code and simplify. (Fset_frame_selected_window): Move here from frame.c. Marginal rewrite. (Fselected_window, select_window, Fselect_window): Move up in code. Minor doc-string fixes.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog26
-rw-r--r--src/frame.c123
-rw-r--r--src/lisp.h4
-rw-r--r--src/minibuf.c9
-rw-r--r--src/window.c376
-rw-r--r--src/window.h9
6 files changed, 299 insertions, 248 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index e3ae905bac6..37fd595e270 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,11 +1,37 @@
12011-06-06 Martin Rudalics <rudalics@gmx.at> 12011-06-06 Martin Rudalics <rudalics@gmx.at>
2 2
3 * lisp.h: Move EXFUNS for Fframe_root_window,
4 Fframe_first_window and Fset_frame_selected_window to window.h.
5
6 * window.h: Move EXFUNS for Fframe_root_window,
7 Fframe_first_window and Fset_frame_selected_window here from
8 lisp.h.
9
10 * frame.c (Fwindow_frame, Fframe_first_window)
11 (Fframe_root_window, Fframe_selected_window)
12 (Fset_frame_selected_window): Move to window.c.
13 (Factive_minibuffer_window): Move to minibuf.c.
14 (Fother_visible_frames_p): New function.
15
16 * minibuf.c (Factive_minibuffer_window): Move here from frame.c.
17
3 * window.c (decode_window, decode_any_window): Move up in code. 18 * window.c (decode_window, decode_any_window): Move up in code.
4 (Fwindowp, Fwindow_live_p): Rewrite doc-strings. 19 (Fwindowp, Fwindow_live_p): Rewrite doc-strings.
5 (inhibit_frame_unsplittable): Remove unused variable. 20 (inhibit_frame_unsplittable): Remove unused variable.
6 (Fwindow_buffer): Move up and rewrite doc-string. 21 (Fwindow_buffer): Move up and rewrite doc-string.
7 (Fwindow_parent, Fwindow_vchild, Fwindow_hchild, Fwindow_next) 22 (Fwindow_parent, Fwindow_vchild, Fwindow_hchild, Fwindow_next)
8 (Fwindow_prev): New functions. 23 (Fwindow_prev): New functions.
24 (Fwindow_frame): Move here from frame.c. Accept any window as
25 argument.
26 (Fframe_root_window, Fframe_first_window)
27 (Fframe_selected_window): Move here from frame.c. Accept frame
28 or arbitrary window as argument. Update doc-strings.
29 (Fminibuffer_window): Move up in code.
30 (Fwindow_minibuffer_p): Move up in code and simplify.
31 (Fset_frame_selected_window): Move here from frame.c. Marginal
32 rewrite.
33 (Fselected_window, select_window, Fselect_window): Move up in
34 code. Minor doc-string fixes.
9 35
102011-06-06 Paul Eggert <eggert@cs.ucla.edu> 362011-06-06 Paul Eggert <eggert@cs.ucla.edu>
11 37
diff --git a/src/frame.c b/src/frame.c
index 6008ba9567a..68984a68d52 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -904,111 +904,6 @@ DEFUN ("selected-frame", Fselected_frame, Sselected_frame, 0, 0, 0,
904 return selected_frame; 904 return selected_frame;
905} 905}
906 906
907DEFUN ("window-frame", Fwindow_frame, Swindow_frame, 1, 1, 0,
908 doc: /* Return the frame object that window WINDOW is on. */)
909 (Lisp_Object window)
910{
911 CHECK_LIVE_WINDOW (window);
912 return XWINDOW (window)->frame;
913}
914
915DEFUN ("frame-first-window", Fframe_first_window, Sframe_first_window, 0, 1, 0,
916 doc: /* Returns the topmost, leftmost window of FRAME.
917If omitted, FRAME defaults to the currently selected frame. */)
918 (Lisp_Object frame)
919{
920 Lisp_Object w;
921
922 if (NILP (frame))
923 w = SELECTED_FRAME ()->root_window;
924 else
925 {
926 CHECK_LIVE_FRAME (frame);
927 w = XFRAME (frame)->root_window;
928 }
929 while (NILP (XWINDOW (w)->buffer))
930 {
931 if (! NILP (XWINDOW (w)->hchild))
932 w = XWINDOW (w)->hchild;
933 else if (! NILP (XWINDOW (w)->vchild))
934 w = XWINDOW (w)->vchild;
935 else
936 abort ();
937 }
938 return w;
939}
940
941DEFUN ("active-minibuffer-window", Factive_minibuffer_window,
942 Sactive_minibuffer_window, 0, 0, 0,
943 doc: /* Return the currently active minibuffer window, or nil if none. */)
944 (void)
945{
946 return minibuf_level ? minibuf_window : Qnil;
947}
948
949DEFUN ("frame-root-window", Fframe_root_window, Sframe_root_window, 0, 1, 0,
950 doc: /* Returns the root-window of FRAME.
951If omitted, FRAME defaults to the currently selected frame. */)
952 (Lisp_Object frame)
953{
954 Lisp_Object window;
955
956 if (NILP (frame))
957 window = SELECTED_FRAME ()->root_window;
958 else
959 {
960 CHECK_LIVE_FRAME (frame);
961 window = XFRAME (frame)->root_window;
962 }
963
964 return window;
965}
966
967DEFUN ("frame-selected-window", Fframe_selected_window,
968 Sframe_selected_window, 0, 1, 0,
969 doc: /* Return the selected window of FRAME.
970FRAME defaults to the currently selected frame. */)
971 (Lisp_Object frame)
972{
973 Lisp_Object window;
974
975 if (NILP (frame))
976 window = SELECTED_FRAME ()->selected_window;
977 else
978 {
979 CHECK_LIVE_FRAME (frame);
980 window = XFRAME (frame)->selected_window;
981 }
982
983 return window;
984}
985
986DEFUN ("set-frame-selected-window", Fset_frame_selected_window,
987 Sset_frame_selected_window, 2, 3, 0,
988 doc: /* Set selected window of FRAME to WINDOW.
989If FRAME is nil, use the selected frame. If FRAME is the
990selected frame, this makes WINDOW the selected window.
991Optional argument NORECORD non-nil means to neither change the
992order of recently selected windows nor the buffer list.
993Return WINDOW. */)
994 (Lisp_Object frame, Lisp_Object window, Lisp_Object norecord)
995{
996 if (NILP (frame))
997 frame = selected_frame;
998
999 CHECK_LIVE_FRAME (frame);
1000 CHECK_LIVE_WINDOW (window);
1001
1002 if (! EQ (frame, WINDOW_FRAME (XWINDOW (window))))
1003 error ("In `set-frame-selected-window', WINDOW is not on FRAME");
1004
1005 if (EQ (frame, selected_frame))
1006 return Fselect_window (window, norecord);
1007
1008 return XFRAME (frame)->selected_window = window;
1009}
1010
1011
1012DEFUN ("frame-list", Fframe_list, Sframe_list, 907DEFUN ("frame-list", Fframe_list, Sframe_list,
1013 0, 0, 0, 908 0, 0, 0,
1014 doc: /* Return a list of all live frames. */) 909 doc: /* Return a list of all live frames. */)
@@ -1265,6 +1160,17 @@ other_visible_frames (FRAME_PTR f)
1265 return 1; 1160 return 1;
1266} 1161}
1267 1162
1163DEFUN ("other-visible-frames-p", Fother_visible_frames_p, Sother_visible_frames_p, 0, 1, 0,
1164 doc: /* Return t if there are other visible frames beside FRAME.
1165FRAME defaults to the selected frame. */)
1166 (Lisp_Object frame)
1167{
1168 if (NILP (frame))
1169 frame = selected_frame;
1170 CHECK_LIVE_FRAME (frame);
1171 return other_visible_frames (XFRAME (frame)) ? Qt : Qnil;
1172}
1173
1268/* Delete FRAME. When FORCE equals Qnoelisp, delete FRAME 1174/* Delete FRAME. When FORCE equals Qnoelisp, delete FRAME
1269 unconditionally. x_connection_closed and delete_terminal use 1175 unconditionally. x_connection_closed and delete_terminal use
1270 this. Any other value of FORCE implements the semantics 1176 this. Any other value of FORCE implements the semantics
@@ -4605,7 +4511,6 @@ automatically. See also `mouse-autoselect-window'. */);
4605 4511
4606 staticpro (&Vframe_list); 4512 staticpro (&Vframe_list);
4607 4513
4608 defsubr (&Sactive_minibuffer_window);
4609 defsubr (&Sframep); 4514 defsubr (&Sframep);
4610 defsubr (&Sframe_live_p); 4515 defsubr (&Sframe_live_p);
4611 defsubr (&Swindow_system); 4516 defsubr (&Swindow_system);
@@ -4613,14 +4518,10 @@ automatically. See also `mouse-autoselect-window'. */);
4613 defsubr (&Shandle_switch_frame); 4518 defsubr (&Shandle_switch_frame);
4614 defsubr (&Sselect_frame); 4519 defsubr (&Sselect_frame);
4615 defsubr (&Sselected_frame); 4520 defsubr (&Sselected_frame);
4616 defsubr (&Swindow_frame);
4617 defsubr (&Sframe_root_window);
4618 defsubr (&Sframe_first_window);
4619 defsubr (&Sframe_selected_window);
4620 defsubr (&Sset_frame_selected_window);
4621 defsubr (&Sframe_list); 4521 defsubr (&Sframe_list);
4622 defsubr (&Snext_frame); 4522 defsubr (&Snext_frame);
4623 defsubr (&Sprevious_frame); 4523 defsubr (&Sprevious_frame);
4524 defsubr (&Sother_visible_frames_p);
4624 defsubr (&Sdelete_frame); 4525 defsubr (&Sdelete_frame);
4625 defsubr (&Smouse_position); 4526 defsubr (&Smouse_position);
4626 defsubr (&Smouse_pixel_position); 4527 defsubr (&Smouse_pixel_position);
diff --git a/src/lisp.h b/src/lisp.h
index a9e7354f9fc..7145c1a689b 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -3181,16 +3181,12 @@ extern Lisp_Object get_frame_param (struct frame *, Lisp_Object);
3181extern Lisp_Object frame_buffer_predicate (Lisp_Object); 3181extern Lisp_Object frame_buffer_predicate (Lisp_Object);
3182EXFUN (Fselect_frame, 2); 3182EXFUN (Fselect_frame, 2);
3183EXFUN (Fselected_frame, 0); 3183EXFUN (Fselected_frame, 0);
3184EXFUN (Fwindow_frame, 1);
3185EXFUN (Fframe_root_window, 1);
3186EXFUN (Fframe_first_window, 1);
3187EXFUN (Fmake_frame_visible, 1); 3184EXFUN (Fmake_frame_visible, 1);
3188EXFUN (Ficonify_frame, 1); 3185EXFUN (Ficonify_frame, 1);
3189EXFUN (Fframe_parameter, 2); 3186EXFUN (Fframe_parameter, 2);
3190EXFUN (Fmodify_frame_parameters, 2); 3187EXFUN (Fmodify_frame_parameters, 2);
3191EXFUN (Fraise_frame, 1); 3188EXFUN (Fraise_frame, 1);
3192EXFUN (Fredirect_frame_focus, 2); 3189EXFUN (Fredirect_frame_focus, 2);
3193EXFUN (Fset_frame_selected_window, 3);
3194extern Lisp_Object frame_buffer_list (Lisp_Object); 3190extern Lisp_Object frame_buffer_list (Lisp_Object);
3195extern void frames_discard_buffer (Lisp_Object); 3191extern void frames_discard_buffer (Lisp_Object);
3196extern void set_frame_buffer_list (Lisp_Object, Lisp_Object); 3192extern void set_frame_buffer_list (Lisp_Object, Lisp_Object);
diff --git a/src/minibuf.c b/src/minibuf.c
index ba8729bdff2..8f1987298b3 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -143,6 +143,14 @@ choose_minibuf_frame_1 (Lisp_Object ignore)
143 return Qnil; 143 return Qnil;
144} 144}
145 145
146DEFUN ("active-minibuffer-window", Factive_minibuffer_window,
147 Sactive_minibuffer_window, 0, 0, 0,
148 doc: /* Return the currently active minibuffer window, or nil if none. */)
149 (void)
150{
151 return minibuf_level ? minibuf_window : Qnil;
152}
153
146DEFUN ("set-minibuffer-window", Fset_minibuffer_window, 154DEFUN ("set-minibuffer-window", Fset_minibuffer_window,
147 Sset_minibuffer_window, 1, 1, 0, 155 Sset_minibuffer_window, 1, 1, 0,
148 doc: /* Specify which minibuffer window to use for the minibuffer. 156 doc: /* Specify which minibuffer window to use for the minibuffer.
@@ -2181,6 +2189,7 @@ properties. */);
2181 doc: /* Minibuffer keymap used for reading Lisp expressions. */); 2189 doc: /* Minibuffer keymap used for reading Lisp expressions. */);
2182 Vread_expression_map = Qnil; 2190 Vread_expression_map = Qnil;
2183 2191
2192 defsubr (&Sactive_minibuffer_window);
2184 defsubr (&Sset_minibuffer_window); 2193 defsubr (&Sset_minibuffer_window);
2185 defsubr (&Sread_from_minibuffer); 2194 defsubr (&Sread_from_minibuffer);
2186 defsubr (&Seval_minibuffer); 2195 defsubr (&Seval_minibuffer);
diff --git a/src/window.c b/src/window.c
index 894775d6aa3..4e8b98a3237 100644
--- a/src/window.c
+++ b/src/window.c
@@ -168,7 +168,248 @@ A live window is a window that displays a buffer. */)
168{ 168{
169 return WINDOW_LIVE_P (object) ? Qt : Qnil; 169 return WINDOW_LIVE_P (object) ? Qt : Qnil;
170} 170}
171
172/* Frames and windows. */
173DEFUN ("window-frame", Fwindow_frame, Swindow_frame, 1, 1, 0,
174 doc: /* Return the frame that window WINDOW is on.
175WINDOW can be any window and defaults to the selected one. */)
176 (Lisp_Object window)
177{
178 return decode_any_window (window)->frame;
179}
180
181DEFUN ("frame-root-window", Fframe_root_window, Sframe_root_window, 0, 1, 0,
182 doc: /* Return the root window of FRAME_OR_WINDOW.
183If omitted, FRAME_OR_WINDOW defaults to the currently selected frame.
184Else if FRAME_OR_WINDOW denotes any window, return the root window of
185that window's frame. If FRAME_OR_WINDOW denotes a live frame, return
186the root window of that frame. */)
187 (Lisp_Object frame_or_window)
188{
189 Lisp_Object window;
190
191 if (NILP (frame_or_window))
192 window = SELECTED_FRAME ()->root_window;
193 else if (WINDOWP (frame_or_window))
194 window = XFRAME (WINDOW_FRAME (XWINDOW (frame_or_window)))->root_window;
195 else
196 {
197 CHECK_LIVE_FRAME (frame_or_window);
198 window = XFRAME (frame_or_window)->root_window;
199 }
200
201 return window;
202}
203
204DEFUN ("minibuffer-window", Fminibuffer_window, Sminibuffer_window, 0, 1, 0,
205 doc: /* Return the window used now for minibuffers.
206If the optional argument FRAME is specified, return the minibuffer window
207used by that frame. */)
208 (Lisp_Object frame)
209{
210 if (NILP (frame))
211 frame = selected_frame;
212 CHECK_LIVE_FRAME (frame);
213 return FRAME_MINIBUF_WINDOW (XFRAME (frame));
214}
215
216DEFUN ("window-minibuffer-p", Fwindow_minibuffer_p,
217 Swindow_minibuffer_p, 0, 1, 0,
218 doc: /* Return non-nil if WINDOW is a minibuffer window.
219WINDOW can be any window and defaults to the selected one. */)
220 (Lisp_Object window)
221{
222 return MINI_WINDOW_P (decode_any_window (window)) ? Qt : Qnil;
223}
224
225/* Don't move this to window.el - this must be a safe routine. */
226DEFUN ("frame-first-window", Fframe_first_window, Sframe_first_window, 0, 1, 0,
227 doc: /* Return the topmost, leftmost live window on FRAME_OR_WINDOW.
228If omitted, FRAME_OR_WINDOW defaults to the currently selected frame.
229Else if FRAME_OR_WINDOW denotes any window, return the first window of
230that window's frame. If FRAME_OR_WINDOW denotes a live frame, return
231the first window of that frame. */)
232 (Lisp_Object frame_or_window)
233{
234 Lisp_Object window;
235
236 if (NILP (frame_or_window))
237 window = SELECTED_FRAME ()->root_window;
238 else if (WINDOWP (frame_or_window))
239 window = XFRAME (WINDOW_FRAME (XWINDOW (frame_or_window)))->root_window;
240 else
241 {
242 CHECK_LIVE_FRAME (frame_or_window);
243 window = XFRAME (frame_or_window)->root_window;
244 }
245
246 while (NILP (XWINDOW (window)->buffer))
247 {
248 if (! NILP (XWINDOW (window)->hchild))
249 window = XWINDOW (window)->hchild;
250 else if (! NILP (XWINDOW (window)->vchild))
251 window = XWINDOW (window)->vchild;
252 else
253 abort ();
254 }
255
256 return window;
257}
258
259DEFUN ("frame-selected-window", Fframe_selected_window,
260 Sframe_selected_window, 0, 1, 0,
261 doc: /* Return the selected window of FRAME_OR_WINDOW.
262If omitted, FRAME_OR_WINDOW defaults to the currently selected frame.
263Else if FRAME_OR_WINDOW denotes any window, return the selected window
264of that window's frame. If FRAME_OR_WINDOW denotes a live frame, return
265the selected window of that frame. */)
266 (Lisp_Object frame_or_window)
267{
268 Lisp_Object window;
269
270 if (NILP (frame_or_window))
271 window = SELECTED_FRAME ()->selected_window;
272 else if (WINDOWP (frame_or_window))
273 window = XFRAME (WINDOW_FRAME (XWINDOW (frame_or_window)))->selected_window;
274 else
275 {
276 CHECK_LIVE_FRAME (frame_or_window);
277 window = XFRAME (frame_or_window)->selected_window;
278 }
279
280 return window;
281}
282
283DEFUN ("set-frame-selected-window", Fset_frame_selected_window,
284 Sset_frame_selected_window, 2, 3, 0,
285 doc: /* Set selected window of FRAME to WINDOW.
286FRAME must be a live frame and defaults to the selected one. If FRAME
287is the selected frame, this makes WINDOW the selected window. Optional
288argument NORECORD non-nil means to neither change the order of recently
289selected windows nor the buffer list. WINDOW must denote a live window.
290Return WINDOW. */)
291 (Lisp_Object frame, Lisp_Object window, Lisp_Object norecord)
292{
293 if (NILP (frame))
294 frame = selected_frame;
295
296 CHECK_LIVE_FRAME (frame);
297 CHECK_LIVE_WINDOW (window);
298
299 if (! EQ (frame, WINDOW_FRAME (XWINDOW (window))))
300 error ("In `set-frame-selected-window', WINDOW is not on FRAME");
301
302 if (EQ (frame, selected_frame))
303 return Fselect_window (window, norecord);
304 else
305 return XFRAME (frame)->selected_window = window;
306}
307
308DEFUN ("selected-window", Fselected_window, Sselected_window, 0, 0, 0,
309 doc: /* Return the selected window.
310The selected window is the window in which the standard cursor for
311selected windows appears and to which many commands apply. */)
312 (void)
313{
314 return selected_window;
315}
316
317/* If select_window is called with inhibit_point_swap non-zero it will
318 not store point of the old selected window's buffer back into that
319 window's pointm slot. This is needed by Fset_window_configuration to
320 avoid that the display routine is called with selected_window set to
321 Qnil causing a subsequent crash. */
322static Lisp_Object
323select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap)
324{
325 register struct window *w;
326 register struct window *ow;
327 struct frame *sf;
328
329 CHECK_LIVE_WINDOW (window);
330
331 w = XWINDOW (window);
332 w->frozen_window_start_p = 0;
333
334 if (NILP (norecord))
335 {
336 ++window_select_count;
337 XSETFASTINT (w->use_time, window_select_count);
338 record_buffer (w->buffer);
339 }
340
341 if (EQ (window, selected_window) && !inhibit_point_swap)
342 return window;
343
344 sf = SELECTED_FRAME ();
345 if (XFRAME (WINDOW_FRAME (w)) != sf)
346 {
347 XFRAME (WINDOW_FRAME (w))->selected_window = window;
348 /* Use this rather than Fhandle_switch_frame
349 so that FRAME_FOCUS_FRAME is moved appropriately as we
350 move around in the state where a minibuffer in a separate
351 frame is active. */
352 Fselect_frame (WINDOW_FRAME (w), norecord);
353 /* Fselect_frame called us back so we've done all the work already. */
354 eassert (EQ (window, selected_window));
355 return window;
356 }
357 else
358 sf->selected_window = window;
359
360 /* Store the current buffer's actual point into the
361 old selected window. It belongs to that window,
362 and when the window is not selected, must be in the window. */
363 if (!inhibit_point_swap)
364 {
365 ow = XWINDOW (selected_window);
366 if (! NILP (ow->buffer))
367 set_marker_both (ow->pointm, ow->buffer,
368 BUF_PT (XBUFFER (ow->buffer)),
369 BUF_PT_BYTE (XBUFFER (ow->buffer)));
370 }
371
372 selected_window = window;
373
374 Fset_buffer (w->buffer);
375
376 BVAR (XBUFFER (w->buffer), last_selected_window) = window;
377
378 /* Go to the point recorded in the window.
379 This is important when the buffer is in more
380 than one window. It also matters when
381 redisplay_window has altered point after scrolling,
382 because it makes the change only in the window. */
383 {
384 register EMACS_INT new_point = marker_position (w->pointm);
385 if (new_point < BEGV)
386 SET_PT (BEGV);
387 else if (new_point > ZV)
388 SET_PT (ZV);
389 else
390 SET_PT (new_point);
391 }
392
393 windows_or_buffers_changed++;
394 return window;
395}
396
397DEFUN ("select-window", Fselect_window, Sselect_window, 1, 2, 0,
398 doc: /* Select WINDOW. Most editing will apply to WINDOW's buffer.
399Also make WINDOW's buffer current and make WINDOW the frame's selected
400window. Return WINDOW.
401
402Optional second arg NORECORD non-nil means do not put this buffer at the
403front of the buffer list and do not make this window the most recently
404selected one.
171 405
406Note that the main editor command loop sets the current buffer to the
407buffer of the selected window before each command. */)
408 (register Lisp_Object window, Lisp_Object norecord)
409{
410 return select_window (window, norecord, 0);
411}
412
172DEFUN ("window-buffer", Fwindow_buffer, Swindow_buffer, 0, 1, 0, 413DEFUN ("window-buffer", Fwindow_buffer, Swindow_buffer, 0, 1, 0,
173 doc: /* Return the buffer that WINDOW is displaying. 414 doc: /* Return the buffer that WINDOW is displaying.
174WINDOW can be any window and defaults to the selected one. 415WINDOW can be any window and defaults to the selected one.
@@ -276,36 +517,6 @@ make_window (void)
276 return val; 517 return val;
277} 518}
278 519
279DEFUN ("selected-window", Fselected_window, Sselected_window, 0, 0, 0,
280 doc: /* Return the window that the cursor now appears in and commands apply to. */)
281 (void)
282{
283 return selected_window;
284}
285
286DEFUN ("minibuffer-window", Fminibuffer_window, Sminibuffer_window, 0, 1, 0,
287 doc: /* Return the window used now for minibuffers.
288If the optional argument FRAME is specified, return the minibuffer window
289used by that frame. */)
290 (Lisp_Object frame)
291{
292 if (NILP (frame))
293 frame = selected_frame;
294 CHECK_LIVE_FRAME (frame);
295 return FRAME_MINIBUF_WINDOW (XFRAME (frame));
296}
297
298DEFUN ("window-minibuffer-p", Fwindow_minibuffer_p,
299 Swindow_minibuffer_p, 0, 1, 0,
300 doc: /* Return non-nil if WINDOW is a minibuffer window.
301WINDOW defaults to the selected window. */)
302 (Lisp_Object window)
303{
304 struct window *w = decode_window (window);
305 return MINI_WINDOW_P (w) ? Qt : Qnil;
306}
307
308
309DEFUN ("pos-visible-in-window-p", Fpos_visible_in_window_p, 520DEFUN ("pos-visible-in-window-p", Fpos_visible_in_window_p,
310 Spos_visible_in_window_p, 0, 3, 0, 521 Spos_visible_in_window_p, 0, 3, 0,
311 doc: /* Return non-nil if position POS is currently on the frame in WINDOW. 522 doc: /* Return non-nil if position POS is currently on the frame in WINDOW.
@@ -3527,106 +3738,6 @@ This function runs `window-scroll-functions' before running
3527 return Qnil; 3738 return Qnil;
3528} 3739}
3529 3740
3530/* If select_window is called with inhibit_point_swap non-zero it will
3531 not store point of the old selected window's buffer back into that
3532 window's pointm slot. This is needed by Fset_window_configuration to
3533 avoid that the display routine is called with selected_window set to
3534 Qnil causing a subsequent crash. */
3535
3536static Lisp_Object
3537select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap)
3538{
3539 register struct window *w;
3540 register struct window *ow;
3541 struct frame *sf;
3542
3543 CHECK_LIVE_WINDOW (window);
3544
3545 w = XWINDOW (window);
3546 w->frozen_window_start_p = 0;
3547
3548 if (NILP (norecord))
3549 {
3550 ++window_select_count;
3551 XSETFASTINT (w->use_time, window_select_count);
3552 record_buffer (w->buffer);
3553 }
3554
3555 if (EQ (window, selected_window) && !inhibit_point_swap)
3556 return window;
3557
3558 sf = SELECTED_FRAME ();
3559 if (XFRAME (WINDOW_FRAME (w)) != sf)
3560 {
3561 XFRAME (WINDOW_FRAME (w))->selected_window = window;
3562 /* Use this rather than Fhandle_switch_frame
3563 so that FRAME_FOCUS_FRAME is moved appropriately as we
3564 move around in the state where a minibuffer in a separate
3565 frame is active. */
3566 Fselect_frame (WINDOW_FRAME (w), norecord);
3567 /* Fselect_frame called us back so we've done all the work already. */
3568 eassert (EQ (window, selected_window));
3569 return window;
3570 }
3571 else
3572 sf->selected_window = window;
3573
3574 /* Store the current buffer's actual point into the
3575 old selected window. It belongs to that window,
3576 and when the window is not selected, must be in the window. */
3577 if (!inhibit_point_swap)
3578 {
3579 ow = XWINDOW (selected_window);
3580 if (! NILP (ow->buffer))
3581 set_marker_both (ow->pointm, ow->buffer,
3582 BUF_PT (XBUFFER (ow->buffer)),
3583 BUF_PT_BYTE (XBUFFER (ow->buffer)));
3584 }
3585
3586 selected_window = window;
3587
3588 Fset_buffer (w->buffer);
3589
3590 BVAR (XBUFFER (w->buffer), last_selected_window) = window;
3591
3592 /* Go to the point recorded in the window.
3593 This is important when the buffer is in more
3594 than one window. It also matters when
3595 redisplay_window has altered point after scrolling,
3596 because it makes the change only in the window. */
3597 {
3598 register EMACS_INT new_point = marker_position (w->pointm);
3599 if (new_point < BEGV)
3600 SET_PT (BEGV);
3601 else if (new_point > ZV)
3602 SET_PT (ZV);
3603 else
3604 SET_PT (new_point);
3605 }
3606
3607 windows_or_buffers_changed++;
3608 return window;
3609}
3610
3611
3612/* Note that selected_window can be nil when this is called from
3613 Fset_window_configuration. */
3614
3615DEFUN ("select-window", Fselect_window, Sselect_window, 1, 2, 0,
3616 doc: /* Select WINDOW. Most editing will apply to WINDOW's buffer.
3617If WINDOW is not already selected, make WINDOW's buffer current
3618and make WINDOW the frame's selected window. Return WINDOW.
3619Optional second arg NORECORD non-nil means do not put this buffer
3620at the front of the list of recently selected ones and do not
3621make this window the most recently selected one.
3622
3623Note that the main editor command loop selects the buffer of the
3624selected window before each command. */)
3625 (register Lisp_Object window, Lisp_Object norecord)
3626{
3627 return select_window (window, norecord, 0);
3628}
3629
3630static Lisp_Object 3741static Lisp_Object
3631select_window_norecord (Lisp_Object window) 3742select_window_norecord (Lisp_Object window)
3632{ 3743{
@@ -7156,6 +7267,11 @@ frame to be redrawn only if it is a tty frame. */);
7156 defsubr (&Swindow_minibuffer_p); 7267 defsubr (&Swindow_minibuffer_p);
7157 defsubr (&Swindowp); 7268 defsubr (&Swindowp);
7158 defsubr (&Swindow_live_p); 7269 defsubr (&Swindow_live_p);
7270 defsubr (&Swindow_frame);
7271 defsubr (&Sframe_root_window);
7272 defsubr (&Sframe_first_window);
7273 defsubr (&Sframe_selected_window);
7274 defsubr (&Sset_frame_selected_window);
7159 defsubr (&Spos_visible_in_window_p); 7275 defsubr (&Spos_visible_in_window_p);
7160 defsubr (&Swindow_line_height); 7276 defsubr (&Swindow_line_height);
7161 defsubr (&Swindow_buffer); 7277 defsubr (&Swindow_buffer);
diff --git a/src/window.h b/src/window.h
index b1f6560445e..ac3335bfba4 100644
--- a/src/window.h
+++ b/src/window.h
@@ -844,11 +844,14 @@ struct glyph *get_phys_cursor_glyph (struct window *w);
844extern Lisp_Object Qwindowp, Qwindow_live_p; 844extern Lisp_Object Qwindowp, Qwindow_live_p;
845extern Lisp_Object Vwindow_list; 845extern Lisp_Object Vwindow_list;
846 846
847EXFUN (Fselected_window, 0);
848EXFUN (Fwindow_minibuffer_p, 1);
849EXFUN (Fdelete_window, 1);
850EXFUN (Fwindow_buffer, 1); 847EXFUN (Fwindow_buffer, 1);
851EXFUN (Fget_buffer_window, 2); 848EXFUN (Fget_buffer_window, 2);
849EXFUN (Fwindow_minibuffer_p, 1);
850EXFUN (Fselected_window, 0);
851EXFUN (Fframe_root_window, 1);
852EXFUN (Fframe_first_window, 1);
853EXFUN (Fset_frame_selected_window, 3);
854EXFUN (Fdelete_window, 1);
852EXFUN (Fset_window_configuration, 1); 855EXFUN (Fset_window_configuration, 1);
853EXFUN (Fcurrent_window_configuration, 1); 856EXFUN (Fcurrent_window_configuration, 1);
854extern int compare_window_configurations (Lisp_Object, Lisp_Object, int); 857extern int compare_window_configurations (Lisp_Object, Lisp_Object, int);