Yoshiaki Kasahara <kasahara(a)nc.kyushu-u.ac.jp> writes:
> > tty frame, sometimes the window of the BUFFER on the tty
frame wasn't
> ^^^
> You mean, X.
No, I really meant tty...
I just found a simple method to produce the problem.
xemacs -vanilla (make an X frame #1)
C-x 5 2 (to create another X frame #2)
C-x b test (on the X frame #1)
C-x b test (on the X frame #2)
M-x make-frame-on-tty (to create a tty frame)
the frame automatically display the buffer "test"
M-: (delete-windows-on "test") (on the tty frame)
The buffer "test" on the tty frame won't disappear. Additional
argument ("nil 'all") didn't help.
I can't reproduce it. However, I wrote a patch to fix the
problems I found. Could you test and see whether this makes
any difference?
This patch is difficult to read because I moved list_windows
and list_all_windows upward. But the idea is same as my
previous patch.
2000-12-20 Yoshiki Hayashi <yoshiki(a)xemacs.org>
* window.c (window_loop): Remove DELTETE_BUFFER_WINDOWS_CODE.
* window.c (Fdelete_windows_on): Rewrite to use list_all_windows.
Index: window.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/window.c,v
retrieving revision 1.41.2.69
diff -u -r1.41.2.69 window.c
--- window.c 2000/12/20 04:50:48 1.41.2.69
+++ window.c 2000/12/20 06:58:19
@@ -2534,7 +2534,6 @@
GET_BUFFER_WINDOW, /* Arg is buffer */
GET_LRU_WINDOW, /* Arg is t for full-width windows only */
DELETE_OTHER_WINDOWS, /* Arg is window not to delete */
- DELETE_BUFFER_WINDOWS, /* Arg is buffer */
GET_LARGEST_WINDOW,
GET_BUFFER_WINDOW_COUNT, /* Arg is buffer */
GET_BUFFER_MRU_WINDOW /* Arg is buffer */
@@ -2548,7 +2547,6 @@
int dedicated_too,
Lisp_Object which_devices)
{
- /* This function can GC if type == DELETE_BUFFER_WINDOWS */
Lisp_Object w;
Lisp_Object best_window = Qnil;
Lisp_Object next_window;
@@ -2697,59 +2695,6 @@
break;
}
- case DELETE_BUFFER_WINDOWS:
- {
- if (EQ (p->buffer, obj))
- {
- struct frame *f = XFRAME (WINDOW_FRAME (p));
-
- /* If this window is dedicated, and in a frame
- of its own, kill the frame. */
- if (EQ (w, FRAME_ROOT_WINDOW (f))
- && !NILP (p->dedicated)
- && other_visible_frames (f))
- {
- /* Skip the other windows on this frame.
- There might be one, the minibuffer! */
- if (! EQ (w, last_window))
- while (f == XFRAME (WINDOW_FRAME
- (XWINDOW (next_window))))
- {
- /* As we go, check for the end of the
- loop. We mustn't start going
- around a second time. */
- if (EQ (next_window, last_window))
- {
- last_window = w;
- break;
- }
- next_window = Fnext_window (next_window,
- mini ? Qt : Qnil,
- frame_arg, Qt);
- }
- /* Now we can safely delete the frame. */
- Fdelete_frame (WINDOW_FRAME (p), Qnil);
- }
- else
- /* If we're deleting the buffer displayed in
- the only window on the frame, find a new
- buffer to display there. */
- if (NILP (p->parent))
- {
- Lisp_Object new_buffer;
- new_buffer = Fother_buffer (obj, Qnil, Qnil);
- if (NILP (new_buffer))
- new_buffer = Fget_buffer_create (QSscratch);
- Fset_window_buffer (w, new_buffer, Qnil);
- if (EQ (w, Fselected_window (Qnil)))
- Fset_buffer (p->buffer);
- }
- else
- Fdelete_window (w, Qnil);
- }
- break;
- }
-
case GET_LARGEST_WINDOW:
{
/* Ignore dedicated windows and minibuffers. */
@@ -2813,6 +2758,63 @@
#endif
+static Lisp_Object
+list_windows (struct window *w, Lisp_Object value)
+{
+ for (;;)
+ {
+ if (!NILP (w->hchild))
+ value = list_windows (XWINDOW (w->hchild), value);
+ else if (!NILP (w->vchild))
+ value = list_windows (XWINDOW (w->vchild), value);
+ else
+ {
+ Lisp_Object window;
+ XSETWINDOW (window, w);
+ value = Fcons (window, value);
+ }
+ if (NILP (w->next))
+ break;
+ w = XWINDOW (w->next);
+ }
+ return value;
+}
+
+static Lisp_Object
+list_all_windows (Lisp_Object frame_spec, Lisp_Object device_spec)
+{
+ Lisp_Object devcons, concons;
+ Lisp_Object retval = Qnil;
+
+ DEVICE_LOOP_NO_BREAK (devcons, concons)
+ {
+ Lisp_Object frame_list, the_window;
+ Lisp_Object device, tail;
+
+ device = XCAR (devcons);
+ frame_list = DEVICE_FRAME_LIST (XDEVICE (device));
+
+ LIST_LOOP (tail, frame_list)
+ {
+ if ((NILP (frame_spec)
+ && !EQ (XCAR (tail), DEVICE_SELECTED_FRAME (XDEVICE (device))))
+ || (EQ (frame_spec, Qvisible)
+ && !FRAME_VISIBLE_P (XFRAME (XCAR (tail))))
+ || (FRAMEP (frame_spec)
+ && !EQ (frame_spec, XCAR (tail)))
+ || (!NILP (frame_spec)
+ && !device_matches_device_spec (device,
+ NILP (device_spec) ?
+ Vselected_console :
+ device_spec)))
+ continue;
+ the_window = FRAME_ROOT_WINDOW (XFRAME (XCAR (tail)));
+ retval = list_windows (XWINDOW (the_window), retval);
+ }
+ }
+ return Fnreverse (retval);
+}
+
DEFUN ("get-lru-window", Fget_lru_window, 0, 2, 0, /*
Return the window least recently selected or used for display.
@@ -3030,6 +3032,10 @@
(buffer, which_frames, which_devices))
{
/* This function can GC */
+ Lisp_Object window_list;
+ Lisp_Object tail;
+ struct gcpro gcpro1, gcpro2;
+
buffer = Fget_buffer (buffer);
CHECK_BUFFER (buffer);
@@ -3040,67 +3046,43 @@
else if (EQ (which_frames, Qt))
which_frames = Qnil;
+ window_list = list_all_windows (which_frames, which_devices);
/* Ignore dedicated windows. */
- window_loop (DELETE_BUFFER_WINDOWS, buffer, 0,
- which_frames, 0, which_devices);
- return Qnil;
-}
-
-static Lisp_Object
-list_windows (struct window *w, Lisp_Object value)
-{
- for (;;)
- {
- if (!NILP (w->hchild))
- value = list_windows (XWINDOW (w->hchild), value);
- else if (!NILP (w->vchild))
- value = list_windows (XWINDOW (w->vchild), value);
- else
- {
- Lisp_Object window;
- XSETWINDOW (window, w);
- value = Fcons (window, value);
- }
- if (NILP (w->next))
- break;
- w = XWINDOW (w->next);
- }
- return value;
-}
-
-static Lisp_Object
-list_all_windows (Lisp_Object frame_spec, Lisp_Object device_spec)
-{
- Lisp_Object devcons, concons;
- Lisp_Object retval = Qnil;
-
- DEVICE_LOOP_NO_BREAK (devcons, concons)
+ GCPRO2 (window_list, buffer);
+ LIST_LOOP (tail, window_list)
{
- Lisp_Object frame_list, the_window;
- Lisp_Object device, tail;
-
- device = XCAR (devcons);
- frame_list = DEVICE_FRAME_LIST (XDEVICE (device));
-
- LIST_LOOP (tail, frame_list)
+ Lisp_Object window = XCAR (tail);
+ if (!MINI_WINDOW_P (XWINDOW (window))
+ && EQ (XWINDOW (window)->buffer, buffer))
{
- if ((NILP (frame_spec)
- && !EQ (XCAR (tail), DEVICE_SELECTED_FRAME (XDEVICE (device))))
- || (EQ (frame_spec, Qvisible)
- && !FRAME_VISIBLE_P (XFRAME (XCAR (tail))))
- || (FRAMEP (frame_spec)
- && !EQ (frame_spec, XCAR (tail)))
- || (!NILP (frame_spec)
- && !device_matches_device_spec (device,
- NILP (device_spec) ?
- Vselected_console :
- device_spec)))
- continue;
- the_window = FRAME_ROOT_WINDOW (XFRAME (XCAR (tail)));
- retval = list_windows (XWINDOW (the_window), retval);
+ Lisp_Object frame = WINDOW_FRAME (XWINDOW (window));
+ if (!NILP (XWINDOW (window)->dedicated)
+ && EQ (window, FRAME_ROOT_WINDOW (XFRAME (frame)))
+ && other_visible_frames (XFRAME (frame)))
+ {
+ Fdelete_frame (frame, Qnil); /* GC */
+ }
+ else
+ {
+ /* If we're deleting the buffer displayed in the only
+ window on the frame, find a new buffer to display
+ there. */
+ if (NILP (XWINDOW (window)->parent))
+ {
+ Lisp_Object another_buffer = Fother_buffer (buffer, Qnil, Qnil);
+ if (NILP (another_buffer))
+ another_buffer = Fget_buffer_create (QSscratch);
+ Fset_window_buffer (window, another_buffer, Qnil);
+ if (EQ (window, Fselected_window (Qnil)))
+ Fset_buffer (XWINDOW (window)->buffer);
+ }
+ else
+ Fdelete_window (window, Qnil);
+ }
}
}
- return Fnreverse (retval);
+ UNGCPRO;
+ return Qnil;
}
DEFUN ("replace-buffer-in-windows", Freplace_buffer_in_windows, 1, 3,
--
Yoshiki Hayashi