(window_loop): New alternative CHECK_ALL_WINDOWS.
authorRichard M. Stallman <rms@gnu.org>
Sat, 10 Oct 1998 14:49:28 +0000 (14:49 +0000)
committerRichard M. Stallman <rms@gnu.org>
Sat, 10 Oct 1998 14:49:28 +0000 (14:49 +0000)
(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.

src/window.c

index bd0668d..41bb492 100644 (file)
@@ -35,7 +35,7 @@ Boston, MA 02111-1307, USA.  */
 #include "xterm.h"
 #endif
 
-Lisp_Object Qwindowp, Qwindow_live_p;
+Lisp_Object Qwindowp, Qwindow_live_p, Qwindow_configuration_p;
 
 static struct window *decode_window P_ ((Lisp_Object));
 
@@ -1307,7 +1307,8 @@ enum window_loop
   DELETE_OTHER_WINDOWS,                /* Arg is window not to delete */
   DELETE_BUFFER_WINDOWS,       /* Arg is buffer */
   GET_LARGEST_WINDOW,
-  UNSHOW_BUFFER                /* Arg is buffer */
+  UNSHOW_BUFFER,               /* Arg is buffer */
+  CHECK_ALL_WINDOWS
 };
 
 static Lisp_Object
@@ -1516,6 +1517,12 @@ window_loop (type, obj, mini, frames)
                  }
              }
            break;
+
+           /* Check for a window that has a killed buffer.  */
+         case CHECK_ALL_WINDOWS:
+           if (! NILP (XWINDOW (w)->buffer)
+               && NILP (XBUFFER (XWINDOW (w)->buffer)->name))
+             abort ();
          }
 
       if (EQ (w, last_window))
@@ -1527,6 +1534,13 @@ window_loop (type, obj, mini, frames)
   return best_window;
 }
 
+/* Used for debugging.  Abort if any window has a dead buffer.  */
+
+check_all_windows ()
+{
+  window_loop (CHECK_ALL_WINDOWS, Qnil, 1, Qt);
+}
+
 DEFUN ("get-lru-window", Fget_lru_window, Sget_lru_window, 0, 1, 0,
   "Return the window least recently selected or used for display.\n\
 If optional argument FRAME is `visible', search all visible frames.\n\
@@ -3278,12 +3292,31 @@ DEFUN ("window-configuration-p", Fwindow_configuration_p, Swindow_configuration_
   return Qnil;
 }
 
+DEFUN ("window-configuration-frame", Fwindow_configuration_frame, Swindow_configuration_frame, 1, 1, 0,
+  "Return the frame that CONFIG, a window-configuration object, is about.")
+  (config)
+     Lisp_Object config;
+{
+  register struct save_window_data *data;
+  struct Lisp_Vector *saved_windows;
+
+  if (! WINDOW_CONFIGURATIONP (config))
+    wrong_type_argument (Qwindow_configuration_p, config);
+
+  data = (struct save_window_data *) XVECTOR (config);
+  saved_windows = XVECTOR (data->saved_windows);
+  return XWINDOW (SAVED_WINDOW_N (saved_windows, 0)->window)->frame;
+}
+
 DEFUN ("set-window-configuration", Fset_window_configuration,
   Sset_window_configuration, 1, 1, 0,
   "Set the configuration of windows and buffers as specified by CONFIGURATION.\n\
 CONFIGURATION must be a value previously returned\n\
-by `current-window-configuration' (which see).")
-     (configuration)
+by `current-window-configuration' (which see).\n\
+If CONFIGURATION was made from a frame that is now deleted,\n\
+only frame-independent values can be restored.  In this case,\n\
+the return value is nil.  Otherwise the value is t.")
+  (configuration)
      Lisp_Object configuration;
 {
   register struct save_window_data *data;
@@ -3294,10 +3327,7 @@ by `current-window-configuration' (which see).")
   int old_point = -1;
 
   while (!WINDOW_CONFIGURATIONP (configuration))
-    {
-      configuration = wrong_type_argument (intern ("window-configuration-p"),
-                                          configuration);
-    }
+    wrong_type_argument (Qwindow_configuration_p, configuration);
 
   data = (struct save_window_data *) XVECTOR (configuration);
   saved_windows = XVECTOR (data->saved_windows);
@@ -3529,7 +3559,7 @@ by `current-window-configuration' (which see).")
 
   Vminibuf_scroll_window = data->minibuf_scroll_window;
 
-  return Qnil;
+  return (FRAME_LIVE_P (f) ? Qt : Qnil);
 }
 
 /* Mark all windows now on frame as deleted
@@ -3857,6 +3887,9 @@ syms_of_window ()
   Qwindowp = intern ("windowp");
   staticpro (&Qwindowp);
 
+  Qwindow_configuration_p = intern ("window-configuration-p");
+  staticpro (&Qwindow_configuration_p);
+
   Qwindow_live_p = intern ("window-live-p");
   staticpro (&Qwindow_live_p);
 
@@ -4061,6 +4094,7 @@ The selected frame is the one whose configuration has changed.");
   defsubr (&Srecenter);
   defsubr (&Smove_to_window_line);
   defsubr (&Swindow_configuration_p);
+  defsubr (&Swindow_configuration_frame);
   defsubr (&Sset_window_configuration);
   defsubr (&Scurrent_window_configuration);
   defsubr (&Ssave_window_excursion);