diff -aruN emacs.compiled.orig/src/buffer.c emacs.compiled/src/buffer.c --- emacs.compiled.orig/src/buffer.c 2012-09-06 09:52:34.000000000 +0200 +++ emacs.compiled/src/buffer.c 2012-09-06 09:49:55.000000000 +0200 @@ -1351,7 +1351,7 @@ A non-nil FLAG means mark the buffer modified. */) (Lisp_Object flag) { - Lisp_Object fn, buffer, window; + Lisp_Object fn, buffer; #ifdef CLASH_DETECTION /* If buffer becoming modified, lock the file. @@ -1401,8 +1401,7 @@ buffers without "modifying" buffers, or redisplay should be smarter about updating the `*' in mode lines. --gerd */ XSETBUFFER (buffer, current_buffer); - window = Fget_buffer_window (buffer, Qt); - if (WINDOWP (window)) + if (!NILP (Fget_buffer_window (buffer, Qt))) { ++update_mode_lines; current_buffer->prevent_redisplay_optimizations_p = 1; @@ -3179,7 +3178,7 @@ Lisp_Object window; window = Foverlay_get (overlay, Qwindow); - if (WINDOWP (window) && XWINDOW (window) != w) + if (WINDOW_LIVE_P (window) && XWINDOW (window) != w) continue; } @@ -3321,7 +3320,7 @@ if (endpos != pos && startpos != pos) continue; window = Foverlay_get (overlay, Qwindow); - if (WINDOWP (window) && XWINDOW (window) != w) + if (WINDOW_LIVE_P (window) && XWINDOW (window) != w) continue; if (startpos == pos && (str = Foverlay_get (overlay, Qbefore_string), STRINGP (str))) @@ -3349,7 +3348,7 @@ if (endpos != pos && startpos != pos) continue; window = Foverlay_get (overlay, Qwindow); - if (WINDOWP (window) && XWINDOW (window) != w) + if (WINDOW_LIVE_P (window) && XWINDOW (window) != w) continue; if (startpos == pos && (str = Foverlay_get (overlay, Qbefore_string), STRINGP (str))) diff -aruN emacs.compiled.orig/src/editfns.c emacs.compiled/src/editfns.c --- emacs.compiled.orig/src/editfns.c 2012-09-06 09:52:34.000000000 +0200 +++ emacs.compiled/src/editfns.c 2012-09-06 09:49:55.000000000 +0200 @@ -360,7 +360,7 @@ if (NILP (object)) XSETBUFFER (object, current_buffer); - else if (WINDOWP (object)) + else if (WINDOW_LIVE_P (object)) object = XWINDOW (object)->buffer; if (!BUFFERP (object)) diff -aruN emacs.compiled.orig/src/frame.c emacs.compiled/src/frame.c --- emacs.compiled.orig/src/frame.c 2012-09-06 09:52:34.000000000 +0200 +++ emacs.compiled/src/frame.c 2012-09-06 09:49:55.000000000 +0200 @@ -942,7 +942,7 @@ || FRAME_ICONIFIED_P (XFRAME (f))) return f; } - else if (WINDOWP (minibuf)) + else if (WINDOW_LIVE_P (minibuf)) { if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f)), minibuf) || EQ (WINDOW_FRAME (XWINDOW (minibuf)), f) @@ -1001,7 +1001,7 @@ if (! FRAME_MINIBUF_ONLY_P (XFRAME (f))) prev = f; } - else if (WINDOWP (minibuf)) + else if (WINDOW_LIVE_P (minibuf)) { if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f)), minibuf) || EQ (WINDOW_FRAME (XWINDOW (minibuf)), f) @@ -2141,7 +2141,7 @@ set_term_frame_name (f, val); } - if (EQ (prop, Qminibuffer) && WINDOWP (val)) + if (EQ (prop, Qminibuffer) && WINDOW_LIVE_P (val)) { if (! MINI_WINDOW_P (XWINDOW (val))) error ("Surrogate minibuffer windows must be minibuffer windows"); diff -aruN emacs.compiled.orig/src/keyboard.c emacs.compiled/src/keyboard.c --- emacs.compiled.orig/src/keyboard.c 2012-09-06 09:52:34.000000000 +0200 +++ emacs.compiled/src/keyboard.c 2012-09-06 09:49:55.000000000 +0200 @@ -3509,7 +3509,7 @@ frame = event->frame_or_window; if (CONSP (frame)) frame = XCAR (frame); - else if (WINDOWP (frame)) + else if (WINDOW_LIVE_P (frame)) frame = WINDOW_FRAME (XWINDOW (frame)); /* There are still some events that don't set this field. @@ -3726,7 +3726,7 @@ event.kind = HELP_EVENT; event.frame_or_window = frame; event.arg = object; - event.x = WINDOWP (window) ? window : frame; + event.x = WINDOW_LIVE_P (window) ? window : frame; event.y = help; event.code = pos; kbd_buffer_store_event (&event); @@ -4052,7 +4052,7 @@ clear_event (event); kbd_fetch_ptr = event + 1; - if (!WINDOWP (window)) + if (!WINDOW_LIVE_P (window)) window = Qnil; obj = Fcons (Qhelp_echo, list5 (frame, help, window, object, position)); @@ -4097,7 +4097,7 @@ frame = event->frame_or_window; if (CONSP (frame)) frame = XCAR (frame); - else if (WINDOWP (frame)) + else if (WINDOW_LIVE_P (frame)) frame = WINDOW_FRAME (XWINDOW (frame)); focus = FRAME_FOCUS_FRAME (XFRAME (frame)); @@ -5179,7 +5179,7 @@ ? window_from_coordinates (f, XINT (x), XINT (y), &part, 0) : Qnil; - if (WINDOWP (window)) + if (WINDOW_LIVE_P (window)) { /* It's a click in window WINDOW at frame coordinates (X,Y) */ struct window *w = XWINDOW (window); @@ -5608,7 +5608,7 @@ struct frame *f; int fuzz; - if (WINDOWP (event->frame_or_window)) + if (WINDOW_LIVE_P (event->frame_or_window)) f = XFRAME (XWINDOW (event->frame_or_window)->frame); else if (FRAMEP (event->frame_or_window)) f = XFRAME (event->frame_or_window); @@ -5776,7 +5776,7 @@ int symbol_num; int is_double; - if (WINDOWP (event->frame_or_window)) + if (WINDOW_LIVE_P (event->frame_or_window)) fr = XFRAME (XWINDOW (event->frame_or_window)->frame); else if (FRAMEP (event->frame_or_window)) fr = XFRAME (event->frame_or_window); @@ -9543,7 +9543,7 @@ read using the keymaps in the buffer clicked on, not the current buffer. If we're at the beginning of a key sequence, switch buffers. */ - if (WINDOWP (window) + if (WINDOW_LIVE_P (window) && BUFFERP (XWINDOW (window)->buffer) && XBUFFER (XWINDOW (window)->buffer) != current_buffer) { @@ -11235,7 +11235,7 @@ if (NILP (frame_or_window)) frame_or_window = selected_window; - if (WINDOWP (frame_or_window)) + if (WINDOW_LIVE_P (frame_or_window)) { struct window *w = decode_live_window (frame_or_window); diff -aruN emacs.compiled.orig/src/keymap.c emacs.compiled/src/keymap.c --- emacs.compiled.orig/src/keymap.c 2012-09-06 09:52:34.000000000 +0200 +++ emacs.compiled/src/keymap.c 2012-09-06 09:49:55.000000000 +0200 @@ -1559,7 +1559,7 @@ window = POSN_WINDOW (position); - if (WINDOWP (window) + if (WINDOW_LIVE_P (window) && BUFFERP (XWINDOW (window)->buffer) && XBUFFER (XWINDOW (window)->buffer) != current_buffer) { diff -aruN emacs.compiled.orig/src/textprop.c emacs.compiled/src/textprop.c --- emacs.compiled.orig/src/textprop.c 2012-09-06 09:52:34.000000000 +0200 +++ emacs.compiled/src/textprop.c 2012-09-06 09:49:55.000000000 +0200 @@ -584,7 +584,7 @@ if (NILP (object)) XSETBUFFER (object, current_buffer); - if (WINDOWP (object)) + if (WINDOW_LIVE_P (object)) { w = XWINDOW (object); object = w->buffer; diff -aruN emacs.compiled.orig/src/w32inevt.c emacs.compiled/src/w32inevt.c --- emacs.compiled.orig/src/w32inevt.c 2012-09-06 09:52:34.000000000 +0200 +++ emacs.compiled/src/w32inevt.c 2012-09-06 09:49:55.000000000 +0200 @@ -650,7 +650,7 @@ selected now, and the last mouse movement event was not in it. A minibuffer window will be selected iff it is active. */ - if (WINDOWP (mouse_window) + if (WINDOW_LIVE_P (mouse_window) && !EQ (mouse_window, last_mouse_window) && !EQ (mouse_window, selected_window)) { diff -aruN emacs.compiled.orig/src/w32term.c emacs.compiled/src/w32term.c --- emacs.compiled.orig/src/w32term.c 2012-09-06 09:52:34.000000000 +0200 +++ emacs.compiled/src/w32term.c 2012-09-06 09:50:51.000000000 +0200 @@ -3927,7 +3927,7 @@ w32_scroll_bar_handle_click (struct scroll_bar *bar, W32Msg *msg, struct input_event *emacs_event) { - if (! WINDOWP (bar->window)) + if (! WINDOW_LIVE_P (bar->window)) emacs_abort (); emacs_event->kind = SCROLL_BAR_CLICK_EVENT; @@ -4420,7 +4420,7 @@ selected now and last mouse movement event was not in it. Minibuffer window will be selected only when it is active. */ - if (WINDOWP (window) + if (WINDOW_LIVE_P (window) && !EQ (window, last_window) && !EQ (window, selected_window) /* For click-to-focus window managers diff -aruN emacs.compiled.orig/src/window.c emacs.compiled/src/window.c --- emacs.compiled.orig/src/window.c 2012-09-06 09:52:34.000000000 +0200 +++ emacs.compiled/src/window.c 2012-09-06 09:49:55.000000000 +0200 @@ -1973,7 +1973,7 @@ useful in connection with bug#12208). && XBUFFER (buf) != current_buffer */ /* This line helps to fix Horsley's testbug.el bug. */ - && !(WINDOWP (BVAR (b, last_selected_window)) + && !(WINDOW_LIVE_P (BVAR (b, last_selected_window)) && w != XWINDOW (BVAR (b, last_selected_window)) && EQ (buf, XWINDOW (BVAR (b, last_selected_window))->buffer))) temp_set_point_both (b, @@ -1984,7 +1984,7 @@ marker_byte_position (w->pointm), BUF_ZV_BYTE (b))); - if (WINDOWP (BVAR (b, last_selected_window)) + if (WINDOW_LIVE_P (BVAR (b, last_selected_window)) && w == XWINDOW (BVAR (b, last_selected_window))) bset_last_selected_window (b, Qnil); } @@ -2209,7 +2209,7 @@ candidate_p = 0; else if (MINI_WINDOW_P (w) && (EQ (minibuf, Qlambda) - || (WINDOWP (minibuf) && !EQ (minibuf, window)))) + || (WINDOW_LIVE_P (minibuf) && !EQ (minibuf, window)))) { /* If MINIBUF is `lambda' don't consider any mini-windows. If it is a window, consider only that one. */ @@ -2219,7 +2219,7 @@ candidate_p = 1; else if (NILP (all_frames)) { - eassert (WINDOWP (owindow)); + eassert (WINDOW_LIVE_P (owindow)); candidate_p = EQ (w->frame, XWINDOW (owindow)->frame); } else if (EQ (all_frames, Qvisible)) @@ -2248,7 +2248,7 @@ && (FRAME_TERMINAL (XFRAME (w->frame)) == FRAME_TERMINAL (XFRAME (selected_frame))); } - else if (WINDOWP (all_frames)) + else if (WINDOW_LIVE_P (all_frames)) candidate_p = (EQ (FRAME_MINIBUF_WINDOW (f), all_frames) || EQ (XWINDOW (all_frames)->frame, w->frame) || EQ (XWINDOW (all_frames)->frame, FRAME_FOCUS_FRAME (f))); @@ -2352,7 +2352,7 @@ { if (EQ (XCAR (list), window)) { - if (WINDOWP (candidate)) + if (WINDOW_LIVE_P (candidate)) break; } else if (candidate_window_p (XCAR (list), window, minibuf, @@ -2360,7 +2360,7 @@ candidate = XCAR (list); } - if (WINDOWP (candidate)) + if (WINDOW_LIVE_P (candidate)) window = candidate; } @@ -2584,7 +2584,7 @@ or Qt otherwise. */ /* Pick a window to start with. */ - if (WINDOWP (obj)) + if (WINDOW_LIVE_P (obj)) window = obj; else if (f) window = FRAME_SELECTED_WINDOW (f); @@ -3325,7 +3325,7 @@ return Qt; } - if (WINDOWP (object)) + if (WINDOW_LIVE_P (object)) { struct window *w = XWINDOW (object); mark_window_display_accurate (object, 0); @@ -5565,7 +5565,7 @@ the current-selected-window. So we have to be careful which point of the current-buffer we copy into old_point. */ if (EQ (XWINDOW (data->current_window)->buffer, new_current_buffer) - && WINDOWP (selected_window) + && WINDOW_LIVE_P (selected_window) && EQ (XWINDOW (selected_window)->buffer, new_current_buffer) && !EQ (selected_window, data->current_window)) old_point = XMARKER (XWINDOW (data->current_window)->pointm)->charpos; @@ -6507,7 +6507,7 @@ void *user_data) { /* delete_frame may set FRAME_ROOT_WINDOW (f) to Qnil. */ - if (WINDOWP (FRAME_ROOT_WINDOW (f))) + if (WINDOW_VALID_P (FRAME_ROOT_WINDOW (f))) foreach_window_1 (XWINDOW (FRAME_ROOT_WINDOW (f)), fn, user_data); } @@ -6546,7 +6546,7 @@ freeze_window_start (struct window *w, void *freeze_p) { if (MINI_WINDOW_P (w) - || (WINDOWP (selected_window) /* Can be nil in corner cases. */ + || (WINDOW_LIVE_P (selected_window) /* Can be nil in corner cases. */ && (w == XWINDOW (selected_window) || (MINI_WINDOW_P (XWINDOW (selected_window)) && ! NILP (Vminibuf_scroll_window) diff -aruN emacs.compiled.orig/src/xdisp.c emacs.compiled/src/xdisp.c --- emacs.compiled.orig/src/xdisp.c 2012-09-06 09:52:34.000000000 +0200 +++ emacs.compiled/src/xdisp.c 2012-09-06 09:49:55.000000000 +0200 @@ -2715,7 +2715,7 @@ /* Or show the region if we are in the mini-buffer and W is the window the mini-buffer refers to. */ || (MINI_WINDOW_P (XWINDOW (selected_window)) - && WINDOWP (minibuf_selected_window) + && WINDOW_LIVE_P (minibuf_selected_window) && w == XWINDOW (minibuf_selected_window)))) { ptrdiff_t markpos = marker_position (BVAR (current_buffer, mark)); @@ -10083,7 +10083,7 @@ Vdeactivate_mark = AREF (vector, 1); windows_or_buffers_changed = XFASTINT (AREF (vector, 2)); - if (WINDOWP (AREF (vector, 3))) + if (WINDOW_LIVE_P (AREF (vector, 3))) { struct window *w; Lisp_Object buffer, charpos, bytepos; @@ -10252,7 +10252,7 @@ resize_echo_area_exactly (void) { if (BUFFERP (echo_area_buffer[0]) - && WINDOWP (echo_area_window)) + && WINDOW_LIVE_P (echo_area_window)) { struct window *w = XWINDOW (echo_area_window); int resized_p; @@ -13067,7 +13067,8 @@ /* do_pending_window_change could change the selected_window due to frame resizing which makes the selected window too small. */ - if (WINDOWP (selected_window) && (w = XWINDOW (selected_window)) != sw) + if (WINDOW_LIVE_P (selected_window) + && (w = XWINDOW (selected_window)) != sw) { sw = w; reconsider_clip_changes (w, current_buffer); @@ -13346,7 +13347,7 @@ { do_pending_window_change (1); /* If selected_window changed, redisplay again. */ - if (WINDOWP (selected_window) + if (WINDOW_LIVE_P (selected_window) && (w = XWINDOW (selected_window)) != sw) goto retry; @@ -13657,7 +13658,8 @@ /* If we just did a pending size change, or have additional visible frames, or selected_window changed, redisplay again. */ if ((windows_or_buffers_changed && !pending) - || (WINDOWP (selected_window) && (w = XWINDOW (selected_window)) != sw)) + || (WINDOW_LIVE_P (selected_window) + && (w = XWINDOW (selected_window)) != sw)) goto retry; /* Clear the face and image caches. @@ -26361,7 +26363,7 @@ Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (XFRAME (w->frame)); /* Quickly resolve the easy cases. */ - if (!(WINDOWP (hlinfo->mouse_face_window) + if (!(WINDOW_LIVE_P (hlinfo->mouse_face_window) && XWINDOW (hlinfo->mouse_face_window) == w)) return 0; if (vpos < hlinfo->mouse_face_beg_row @@ -27663,7 +27665,7 @@ clear_mouse_face (hlinfo); /* Not on a window -> return. */ - if (!WINDOWP (window)) + if (!WINDOW_LIVE_P (window)) return; /* Reset help_echo_string. It will get recomputed below. */ diff -aruN emacs.compiled.orig/src/xfaces.c emacs.compiled/src/xfaces.c --- emacs.compiled.orig/src/xfaces.c 2012-09-06 09:52:34.000000000 +0200 +++ emacs.compiled/src/xfaces.c 2012-09-06 09:49:55.000000000 +0200 @@ -4309,7 +4309,7 @@ matrices as invalid because they will reference faces freed above. This function is also called when a frame is destroyed. In this case, the root window of F is nil. */ - if (WINDOWP (f->root_window)) + if (WINDOW_VALID_P (f->root_window)) { clear_current_matrices (f); ++windows_or_buffers_changed; diff -aruN emacs.compiled.orig/src/xterm.c emacs.compiled/src/xterm.c --- emacs.compiled.orig/src/xterm.c 2012-09-06 09:52:34.000000000 +0200 +++ emacs.compiled/src/xterm.c 2012-09-06 09:51:30.000000000 +0200 @@ -4228,7 +4228,7 @@ if (scroll_bar_p && strcmp (action_name, end_action) == 0 - && WINDOWP (window_being_scrolled)) + && WINDOW_LIVE_P (window_being_scrolled)) { struct window *w; @@ -4505,7 +4505,7 @@ { struct scroll_bar *bar = (struct scroll_bar *) user_data; bar->dragging = Qnil; - if (WINDOWP (window_being_scrolled)) + if (WINDOW_LIVE_P (window_being_scrolled)) { x_send_scroll_bar_event (window_being_scrolled, scroll_bar_end_scroll, 0, 0); @@ -5550,7 +5550,7 @@ static void x_scroll_bar_handle_click (struct scroll_bar *bar, XEvent *event, struct input_event *emacs_event) { - if (! WINDOWP (bar->window)) + if (! WINDOW_LIVE_P (bar->window)) emacs_abort (); emacs_event->kind = SCROLL_BAR_CLICK_EVENT; @@ -6775,7 +6775,7 @@ /* Window will be selected only when it is not selected now and last mouse movement event was not in it. Minibuffer window will be selected only when it is active. */ - if (WINDOWP (window) + if (WINDOW_LIVE_P (window) && !EQ (window, last_window) && !EQ (window, selected_window) /* For click-to-focus window managers