Mercurial > emacs
comparison src/window.c @ 23410:02cc44ea2455
(window_loop): New alternative CHECK_ALL_WINDOWS.
(check_all_windows): New function for debugging tests.
(syms_of_window): Initialize it.
(Qwindow_configuration_p): New variable.
(Fwindow_configuration_frame): New function.
(syms_of_window): defsubr it.
(Fset_window_configuration): Return t if frame is live.
Use Qwindow_configuration_p.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 10 Oct 1998 14:49:28 +0000 |
parents | 970b3bad71fd |
children | 0d1a0ded9aa1 |
comparison
equal
deleted
inserted
replaced
23409:b9c1f9b1dac9 | 23410:02cc44ea2455 |
---|---|
33 #include "dispextern.h" | 33 #include "dispextern.h" |
34 #ifdef HAVE_X_WINDOWS | 34 #ifdef HAVE_X_WINDOWS |
35 #include "xterm.h" | 35 #include "xterm.h" |
36 #endif | 36 #endif |
37 | 37 |
38 Lisp_Object Qwindowp, Qwindow_live_p; | 38 Lisp_Object Qwindowp, Qwindow_live_p, Qwindow_configuration_p; |
39 | 39 |
40 static struct window *decode_window P_ ((Lisp_Object)); | 40 static struct window *decode_window P_ ((Lisp_Object)); |
41 | 41 |
42 static Lisp_Object select_window_1 P_ ((Lisp_Object, int)); | 42 static Lisp_Object select_window_1 P_ ((Lisp_Object, int)); |
43 | 43 |
1305 GET_BUFFER_WINDOW, /* Arg is buffer */ | 1305 GET_BUFFER_WINDOW, /* Arg is buffer */ |
1306 GET_LRU_WINDOW, /* Arg is t for full-width windows only */ | 1306 GET_LRU_WINDOW, /* Arg is t for full-width windows only */ |
1307 DELETE_OTHER_WINDOWS, /* Arg is window not to delete */ | 1307 DELETE_OTHER_WINDOWS, /* Arg is window not to delete */ |
1308 DELETE_BUFFER_WINDOWS, /* Arg is buffer */ | 1308 DELETE_BUFFER_WINDOWS, /* Arg is buffer */ |
1309 GET_LARGEST_WINDOW, | 1309 GET_LARGEST_WINDOW, |
1310 UNSHOW_BUFFER /* Arg is buffer */ | 1310 UNSHOW_BUFFER, /* Arg is buffer */ |
1311 CHECK_ALL_WINDOWS | |
1311 }; | 1312 }; |
1312 | 1313 |
1313 static Lisp_Object | 1314 static Lisp_Object |
1314 window_loop (type, obj, mini, frames) | 1315 window_loop (type, obj, mini, frames) |
1315 enum window_loop type; | 1316 enum window_loop type; |
1514 if (EQ (w, selected_window)) | 1515 if (EQ (w, selected_window)) |
1515 Fset_buffer (XWINDOW (w)->buffer); | 1516 Fset_buffer (XWINDOW (w)->buffer); |
1516 } | 1517 } |
1517 } | 1518 } |
1518 break; | 1519 break; |
1520 | |
1521 /* Check for a window that has a killed buffer. */ | |
1522 case CHECK_ALL_WINDOWS: | |
1523 if (! NILP (XWINDOW (w)->buffer) | |
1524 && NILP (XBUFFER (XWINDOW (w)->buffer)->name)) | |
1525 abort (); | |
1519 } | 1526 } |
1520 | 1527 |
1521 if (EQ (w, last_window)) | 1528 if (EQ (w, last_window)) |
1522 break; | 1529 break; |
1523 | 1530 |
1524 w = next_window; | 1531 w = next_window; |
1525 } | 1532 } |
1526 | 1533 |
1527 return best_window; | 1534 return best_window; |
1535 } | |
1536 | |
1537 /* Used for debugging. Abort if any window has a dead buffer. */ | |
1538 | |
1539 check_all_windows () | |
1540 { | |
1541 window_loop (CHECK_ALL_WINDOWS, Qnil, 1, Qt); | |
1528 } | 1542 } |
1529 | 1543 |
1530 DEFUN ("get-lru-window", Fget_lru_window, Sget_lru_window, 0, 1, 0, | 1544 DEFUN ("get-lru-window", Fget_lru_window, Sget_lru_window, 0, 1, 0, |
1531 "Return the window least recently selected or used for display.\n\ | 1545 "Return the window least recently selected or used for display.\n\ |
1532 If optional argument FRAME is `visible', search all visible frames.\n\ | 1546 If optional argument FRAME is `visible', search all visible frames.\n\ |
3276 if (WINDOW_CONFIGURATIONP (object)) | 3290 if (WINDOW_CONFIGURATIONP (object)) |
3277 return Qt; | 3291 return Qt; |
3278 return Qnil; | 3292 return Qnil; |
3279 } | 3293 } |
3280 | 3294 |
3295 DEFUN ("window-configuration-frame", Fwindow_configuration_frame, Swindow_configuration_frame, 1, 1, 0, | |
3296 "Return the frame that CONFIG, a window-configuration object, is about.") | |
3297 (config) | |
3298 Lisp_Object config; | |
3299 { | |
3300 register struct save_window_data *data; | |
3301 struct Lisp_Vector *saved_windows; | |
3302 | |
3303 if (! WINDOW_CONFIGURATIONP (config)) | |
3304 wrong_type_argument (Qwindow_configuration_p, config); | |
3305 | |
3306 data = (struct save_window_data *) XVECTOR (config); | |
3307 saved_windows = XVECTOR (data->saved_windows); | |
3308 return XWINDOW (SAVED_WINDOW_N (saved_windows, 0)->window)->frame; | |
3309 } | |
3310 | |
3281 DEFUN ("set-window-configuration", Fset_window_configuration, | 3311 DEFUN ("set-window-configuration", Fset_window_configuration, |
3282 Sset_window_configuration, 1, 1, 0, | 3312 Sset_window_configuration, 1, 1, 0, |
3283 "Set the configuration of windows and buffers as specified by CONFIGURATION.\n\ | 3313 "Set the configuration of windows and buffers as specified by CONFIGURATION.\n\ |
3284 CONFIGURATION must be a value previously returned\n\ | 3314 CONFIGURATION must be a value previously returned\n\ |
3285 by `current-window-configuration' (which see).") | 3315 by `current-window-configuration' (which see).\n\ |
3286 (configuration) | 3316 If CONFIGURATION was made from a frame that is now deleted,\n\ |
3317 only frame-independent values can be restored. In this case,\n\ | |
3318 the return value is nil. Otherwise the value is t.") | |
3319 (configuration) | |
3287 Lisp_Object configuration; | 3320 Lisp_Object configuration; |
3288 { | 3321 { |
3289 register struct save_window_data *data; | 3322 register struct save_window_data *data; |
3290 struct Lisp_Vector *saved_windows; | 3323 struct Lisp_Vector *saved_windows; |
3291 Lisp_Object new_current_buffer; | 3324 Lisp_Object new_current_buffer; |
3292 Lisp_Object frame; | 3325 Lisp_Object frame; |
3293 FRAME_PTR f; | 3326 FRAME_PTR f; |
3294 int old_point = -1; | 3327 int old_point = -1; |
3295 | 3328 |
3296 while (!WINDOW_CONFIGURATIONP (configuration)) | 3329 while (!WINDOW_CONFIGURATIONP (configuration)) |
3297 { | 3330 wrong_type_argument (Qwindow_configuration_p, configuration); |
3298 configuration = wrong_type_argument (intern ("window-configuration-p"), | |
3299 configuration); | |
3300 } | |
3301 | 3331 |
3302 data = (struct save_window_data *) XVECTOR (configuration); | 3332 data = (struct save_window_data *) XVECTOR (configuration); |
3303 saved_windows = XVECTOR (data->saved_windows); | 3333 saved_windows = XVECTOR (data->saved_windows); |
3304 | 3334 |
3305 new_current_buffer = data->current_buffer; | 3335 new_current_buffer = data->current_buffer; |
3527 window_min_height = XINT (data->min_height); | 3557 window_min_height = XINT (data->min_height); |
3528 window_min_width = XINT (data->min_width); | 3558 window_min_width = XINT (data->min_width); |
3529 | 3559 |
3530 Vminibuf_scroll_window = data->minibuf_scroll_window; | 3560 Vminibuf_scroll_window = data->minibuf_scroll_window; |
3531 | 3561 |
3532 return Qnil; | 3562 return (FRAME_LIVE_P (f) ? Qt : Qnil); |
3533 } | 3563 } |
3534 | 3564 |
3535 /* Mark all windows now on frame as deleted | 3565 /* Mark all windows now on frame as deleted |
3536 by setting their buffers to nil. */ | 3566 by setting their buffers to nil. */ |
3537 | 3567 |
3854 Qwindow_configuration_change_hook | 3884 Qwindow_configuration_change_hook |
3855 = intern ("window-configuration-change-hook"); | 3885 = intern ("window-configuration-change-hook"); |
3856 | 3886 |
3857 Qwindowp = intern ("windowp"); | 3887 Qwindowp = intern ("windowp"); |
3858 staticpro (&Qwindowp); | 3888 staticpro (&Qwindowp); |
3889 | |
3890 Qwindow_configuration_p = intern ("window-configuration-p"); | |
3891 staticpro (&Qwindow_configuration_p); | |
3859 | 3892 |
3860 Qwindow_live_p = intern ("window-live-p"); | 3893 Qwindow_live_p = intern ("window-live-p"); |
3861 staticpro (&Qwindow_live_p); | 3894 staticpro (&Qwindow_live_p); |
3862 | 3895 |
3863 Qtemp_buffer_show_hook = intern ("temp-buffer-show-hook"); | 3896 Qtemp_buffer_show_hook = intern ("temp-buffer-show-hook"); |
4059 defsubr (&Sother_window_for_scrolling); | 4092 defsubr (&Sother_window_for_scrolling); |
4060 defsubr (&Sscroll_other_window); | 4093 defsubr (&Sscroll_other_window); |
4061 defsubr (&Srecenter); | 4094 defsubr (&Srecenter); |
4062 defsubr (&Smove_to_window_line); | 4095 defsubr (&Smove_to_window_line); |
4063 defsubr (&Swindow_configuration_p); | 4096 defsubr (&Swindow_configuration_p); |
4097 defsubr (&Swindow_configuration_frame); | |
4064 defsubr (&Sset_window_configuration); | 4098 defsubr (&Sset_window_configuration); |
4065 defsubr (&Scurrent_window_configuration); | 4099 defsubr (&Scurrent_window_configuration); |
4066 defsubr (&Ssave_window_excursion); | 4100 defsubr (&Ssave_window_excursion); |
4067 defsubr (&Scompare_window_configurations); | 4101 defsubr (&Scompare_window_configurations); |
4068 } | 4102 } |