aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartin Rudalics2012-08-16 09:58:24 +0200
committerMartin Rudalics2012-08-16 09:58:24 +0200
commit52162052fd8ccf8b74685e161530cc9324358a22 (patch)
tree20b1bc3285ad8b5fd3a106a108d08fc2c436a2e3 /src
parent2751c80fd3127c572462a2de82c2206d71a4e43e (diff)
downloademacs-52162052fd8ccf8b74685e161530cc9324358a22.tar.gz
emacs-52162052fd8ccf8b74685e161530cc9324358a22.zip
Consistently check windows for validity/liveness (Bug#11984, Bug#12025, Bug#12026).
* lisp.h (CHECK_VALID_WINDOW): New macro. * window.c (decode_window): Rename to decode_live_window. (decode_valid_window, Fwindow_valid_p): New functions. (Fwindow_frame, Fframe_root_window, Fwindow_minibuffer_p) (Fframe_first_window, Fframe_selected_window, Fwindow_parent) (Fwindow_top_child, Fwindow_left_child, Fwindow_next_sibling) (Fwindow_prev_sibling, Fwindow_combination_limit) (Fset_window_combination_limit, Fwindow_use_time) (Fwindow_total_height, Fwindow_total_width, Fwindow_new_total) (Fwindow_normal_size, Fwindow_new_normal, Fwindow_left_column) (Fwindow_top_line, Fwindow_body_height, Fwindow_body_width) (Fwindow_hscroll, Fset_window_hscroll) (Fwindow_redisplay_end_trigger) (Fset_window_redisplay_end_trigger, Fwindow_edges) (Fwindow_pixel_edges, Fwindow_absolute_pixel_edges) (Fwindow_inside_edges, Fwindow_inside_pixel_edges) (Fcoordinates_in_window_p, Fwindow_point, Fwindow_start) (Fwindow_end, Fset_window_point, Fset_window_start) (Fpos_visible_in_window_p, Fwindow_line_height) (Fwindow_dedicated_p, Fset_window_dedicated_p) (Fwindow_prev_buffers, Fset_window_prev_buffers) (Fwindow_next_buffers, Fwindow_parameters, Fwindow_parameter) (Fset_window_parameter, Fwindow_display_table) (Fset_window_display_table, Fdelete_other_windows_internal) (Fset_window_buffer, Fset_window_new_total) (Fset_window_new_normal, Fdelete_window_internal) (Fwindow_text_height, Fset_window_margins, Fwindow_margins) (Fset_window_fringes, Fwindow_fringes, Fset_window_scroll_bars) (Fwindow_scroll_bars): Check whether argument window is a valid or live window. Update doc-strings. (syms_of_window): New symbol Qwindow_valid_p. * keyboard.c (Fposn_at_x_y): Check whether argument frame_or_window denotes a valid window. * window.el (window-valid-p): Move to window.c.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog38
-rw-r--r--src/keyboard.c5
-rw-r--r--src/lisp.h21
-rw-r--r--src/window.c357
-rw-r--r--src/window.h11
5 files changed, 260 insertions, 172 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 3f2a46794a7..95140401eb2 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,41 @@
12012-08-16 Martin Rudalics <rudalics@gmx.at>
2
3 Consistently check windows for validity/liveness
4 (Bug#11984, Bug#12025, Bug#12026).
5 * lisp.h (CHECK_VALID_WINDOW): New macro.
6 * window.c (decode_window): Rename to decode_live_window.
7 (decode_valid_window, Fwindow_valid_p): New functions.
8 (Fwindow_frame, Fframe_root_window, Fwindow_minibuffer_p)
9 (Fframe_first_window, Fframe_selected_window, Fwindow_parent)
10 (Fwindow_top_child, Fwindow_left_child, Fwindow_next_sibling)
11 (Fwindow_prev_sibling, Fwindow_combination_limit)
12 (Fset_window_combination_limit, Fwindow_use_time)
13 (Fwindow_total_height, Fwindow_total_width, Fwindow_new_total)
14 (Fwindow_normal_size, Fwindow_new_normal, Fwindow_left_column)
15 (Fwindow_top_line, Fwindow_body_height, Fwindow_body_width)
16 (Fwindow_hscroll, Fset_window_hscroll)
17 (Fwindow_redisplay_end_trigger)
18 (Fset_window_redisplay_end_trigger, Fwindow_edges)
19 (Fwindow_pixel_edges, Fwindow_absolute_pixel_edges)
20 (Fwindow_inside_edges, Fwindow_inside_pixel_edges)
21 (Fcoordinates_in_window_p, Fwindow_point, Fwindow_start)
22 (Fwindow_end, Fset_window_point, Fset_window_start)
23 (Fpos_visible_in_window_p, Fwindow_line_height)
24 (Fwindow_dedicated_p, Fset_window_dedicated_p)
25 (Fwindow_prev_buffers, Fset_window_prev_buffers)
26 (Fwindow_next_buffers, Fwindow_parameters, Fwindow_parameter)
27 (Fset_window_parameter, Fwindow_display_table)
28 (Fset_window_display_table, Fdelete_other_windows_internal)
29 (Fset_window_buffer, Fset_window_new_total)
30 (Fset_window_new_normal, Fdelete_window_internal)
31 (Fwindow_text_height, Fset_window_margins, Fwindow_margins)
32 (Fset_window_fringes, Fwindow_fringes, Fset_window_scroll_bars)
33 (Fwindow_scroll_bars): Check whether argument window is a valid or
34 live window. Update doc-strings.
35 (syms_of_window): New symbol Qwindow_valid_p.
36 * keyboard.c (Fposn_at_x_y): Check whether argument
37 frame_or_window denotes a valid window.
38
12012-08-16 Dmitry Antipov <dmantipov@yandex.ru> 392012-08-16 Dmitry Antipov <dmantipov@yandex.ru>
2 40
3 Fix previous char table change. 41 Fix previous char table change.
diff --git a/src/keyboard.c b/src/keyboard.c
index 4d0c98f3529..b26a2c88e5d 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -11200,11 +11200,8 @@ The `posn-' functions access elements of such lists. */)
11200 11200
11201 if (WINDOWP (frame_or_window)) 11201 if (WINDOWP (frame_or_window))
11202 { 11202 {
11203 struct window *w; 11203 struct window *w = decode_valid_window (frame_or_window);
11204 11204
11205 CHECK_LIVE_WINDOW (frame_or_window);
11206
11207 w = XWINDOW (frame_or_window);
11208 XSETINT (x, (XINT (x) 11205 XSETINT (x, (XINT (x)
11209 + WINDOW_LEFT_EDGE_X (w) 11206 + WINDOW_LEFT_EDGE_X (w)
11210 + (NILP (whole) 11207 + (NILP (whole)
diff --git a/src/lisp.h b/src/lisp.h
index 426bcb263fd..fb0e44520d6 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -1758,15 +1758,18 @@ typedef struct {
1758#define CHECK_WINDOW_CONFIGURATION(x) \ 1758#define CHECK_WINDOW_CONFIGURATION(x) \
1759 CHECK_TYPE (WINDOW_CONFIGURATIONP (x), Qwindow_configuration_p, x) 1759 CHECK_TYPE (WINDOW_CONFIGURATIONP (x), Qwindow_configuration_p, x)
1760 1760
1761/* This macro rejects windows on the interior of the window tree as 1761/* A window of any sort, leaf or interior, is "valid" if one of its
1762 "dead", which is what we want; this is an argument-checking macro, and 1762 buffer, vchild, or hchild members is non-nil. */
1763 the user should never get access to interior windows. 1763#define CHECK_VALID_WINDOW(x) \
1764 1764 CHECK_TYPE (WINDOWP (x) \
1765 A window of any sort, leaf or interior, is dead if the buffer, 1765 && (!NILP (XWINDOW (x)->buffer) \
1766 vchild, and hchild members are all nil. */ 1766 || !NILP (XWINDOW (x)->vchild) \
1767 1767 || !NILP (XWINDOW (x)->hchild)), \
1768#define CHECK_LIVE_WINDOW(x) \ 1768 Qwindow_valid_p, x)
1769 CHECK_TYPE (WINDOWP (x) && !NILP (XWINDOW (x)->buffer), \ 1769
1770/* A window is "live" if and only if it shows a buffer. */
1771#define CHECK_LIVE_WINDOW(x) \
1772 CHECK_TYPE (WINDOWP (x) && !NILP (XWINDOW (x)->buffer), \
1770 Qwindow_live_p, x) 1773 Qwindow_live_p, x)
1771 1774
1772#define CHECK_PROCESS(x) \ 1775#define CHECK_PROCESS(x) \
diff --git a/src/window.c b/src/window.c
index f5622b217d7..7874105df1e 100644
--- a/src/window.c
+++ b/src/window.c
@@ -51,7 +51,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
51#include "nsterm.h" 51#include "nsterm.h"
52#endif 52#endif
53 53
54Lisp_Object Qwindowp, Qwindow_live_p; 54Lisp_Object Qwindowp, Qwindow_live_p, Qwindow_valid_p;
55static Lisp_Object Qwindow_configuration_p, Qrecord_window_buffer; 55static Lisp_Object Qwindow_configuration_p, Qrecord_window_buffer;
56static Lisp_Object Qwindow_deletable_p, Qdelete_window, Qdisplay_buffer; 56static Lisp_Object Qwindow_deletable_p, Qdelete_window, Qdisplay_buffer;
57static Lisp_Object Qreplace_buffer_in_windows, Qget_mru_window; 57static Lisp_Object Qreplace_buffer_in_windows, Qget_mru_window;
@@ -61,7 +61,6 @@ static Lisp_Object Qsafe, Qabove, Qbelow;
61static Lisp_Object Qauto_buffer_name, Qclone_of; 61static Lisp_Object Qauto_buffer_name, Qclone_of;
62 62
63static int displayed_window_lines (struct window *); 63static int displayed_window_lines (struct window *);
64static struct window *decode_window (Lisp_Object);
65static int count_windows (struct window *); 64static int count_windows (struct window *);
66static int get_leaf_windows (struct window *, struct window **, int); 65static int get_leaf_windows (struct window *, struct window **, int);
67static void window_scroll (Lisp_Object, EMACS_INT, int, int); 66static void window_scroll (Lisp_Object, EMACS_INT, int, int);
@@ -131,8 +130,8 @@ static int window_scroll_pixel_based_preserve_y;
131static EMACS_INT window_scroll_preserve_hpos; 130static EMACS_INT window_scroll_preserve_hpos;
132static EMACS_INT window_scroll_preserve_vpos; 131static EMACS_INT window_scroll_preserve_vpos;
133 132
134static struct window * 133struct window *
135decode_window (register Lisp_Object window) 134decode_live_window (register Lisp_Object window)
136{ 135{
137 if (NILP (window)) 136 if (NILP (window))
138 return XWINDOW (selected_window); 137 return XWINDOW (selected_window);
@@ -154,6 +153,19 @@ decode_any_window (register Lisp_Object window)
154 return w; 153 return w;
155} 154}
156 155
156struct window *
157decode_valid_window (register Lisp_Object window)
158{
159 struct window *w;
160
161 if (NILP (window))
162 return XWINDOW (selected_window);
163
164 CHECK_VALID_WINDOW (window);
165 w = XWINDOW (window);
166 return w;
167}
168
157DEFUN ("windowp", Fwindowp, Swindowp, 1, 1, 0, 169DEFUN ("windowp", Fwindowp, Swindowp, 1, 1, 0,
158 doc: /* Return t if OBJECT is a window and nil otherwise. */) 170 doc: /* Return t if OBJECT is a window and nil otherwise. */)
159 (Lisp_Object object) 171 (Lisp_Object object)
@@ -161,6 +173,15 @@ DEFUN ("windowp", Fwindowp, Swindowp, 1, 1, 0,
161 return WINDOWP (object) ? Qt : Qnil; 173 return WINDOWP (object) ? Qt : Qnil;
162} 174}
163 175
176DEFUN ("window-valid-p", Fwindow_valid_p, Swindow_valid_p, 1, 1, 0,
177 doc: /* Return t if OBJECT is a valid window and nil otherwise.
178A valid window is either a window that displays a buffer or an internal
179window. Deleted windows are not live. */)
180 (Lisp_Object object)
181{
182 return WINDOW_VALID_P (object) ? Qt : Qnil;
183}
184
164DEFUN ("window-live-p", Fwindow_live_p, Swindow_live_p, 1, 1, 0, 185DEFUN ("window-live-p", Fwindow_live_p, Swindow_live_p, 1, 1, 0,
165 doc: /* Return t if OBJECT is a live window and nil otherwise. 186 doc: /* Return t if OBJECT is a live window and nil otherwise.
166A live window is a window that displays a buffer. 187A live window is a window that displays a buffer.
@@ -173,10 +194,10 @@ Internal windows and deleted windows are not live. */)
173/* Frames and windows. */ 194/* Frames and windows. */
174DEFUN ("window-frame", Fwindow_frame, Swindow_frame, 1, 1, 0, 195DEFUN ("window-frame", Fwindow_frame, Swindow_frame, 1, 1, 0,
175 doc: /* Return the frame that window WINDOW is on. 196 doc: /* Return the frame that window WINDOW is on.
176If WINDOW is omitted or nil, it defaults to the selected window. */) 197WINDOW must be a valid window and defaults to the selected one. */)
177 (Lisp_Object window) 198 (Lisp_Object window)
178{ 199{
179 return decode_any_window (window)->frame; 200 return decode_valid_window (window)->frame;
180} 201}
181 202
182DEFUN ("frame-root-window", Fframe_root_window, Sframe_root_window, 0, 1, 0, 203DEFUN ("frame-root-window", Fframe_root_window, Sframe_root_window, 0, 1, 0,
@@ -190,8 +211,8 @@ With a window argument, return the root window of that window's frame. */)
190 211
191 if (NILP (frame_or_window)) 212 if (NILP (frame_or_window))
192 window = SELECTED_FRAME ()->root_window; 213 window = SELECTED_FRAME ()->root_window;
193 else if (WINDOWP (frame_or_window)) 214 else if (WINDOW_VALID_P (frame_or_window))
194 window = XFRAME (WINDOW_FRAME (XWINDOW (frame_or_window)))->root_window; 215 window = XFRAME (XWINDOW (frame_or_window)->frame)->root_window;
195 else 216 else
196 { 217 {
197 CHECK_LIVE_FRAME (frame_or_window); 218 CHECK_LIVE_FRAME (frame_or_window);
@@ -215,18 +236,18 @@ If FRAME is omitted or nil, it defaults to the selected frame. */)
215DEFUN ("window-minibuffer-p", Fwindow_minibuffer_p, 236DEFUN ("window-minibuffer-p", Fwindow_minibuffer_p,
216 Swindow_minibuffer_p, 0, 1, 0, 237 Swindow_minibuffer_p, 0, 1, 0,
217 doc: /* Return non-nil if WINDOW is a minibuffer window. 238 doc: /* Return non-nil if WINDOW is a minibuffer window.
218If WINDOW is omitted or nil, it defaults to the selected window. */) 239WINDOW must be a valid window and defaults to the selected one. */)
219 (Lisp_Object window) 240 (Lisp_Object window)
220{ 241{
221 return MINI_WINDOW_P (decode_any_window (window)) ? Qt : Qnil; 242 return MINI_WINDOW_P (decode_valid_window (window)) ? Qt : Qnil;
222} 243}
223 244
224/* Don't move this to window.el - this must be a safe routine. */ 245/* Don't move this to window.el - this must be a safe routine. */
225DEFUN ("frame-first-window", Fframe_first_window, Sframe_first_window, 0, 1, 0, 246DEFUN ("frame-first-window", Fframe_first_window, Sframe_first_window, 0, 1, 0,
226 doc: /* Return the topmost, leftmost live window on FRAME-OR-WINDOW. 247 doc: /* Return the topmost, leftmost live window on FRAME-OR-WINDOW.
227If omitted, FRAME-OR-WINDOW defaults to the currently selected frame. 248If omitted, FRAME-OR-WINDOW defaults to the currently selected frame.
228Else if FRAME-OR-WINDOW denotes any window, return the first window of 249Else if FRAME-OR-WINDOW denotes a valid window, return the first window
229that window's frame. If FRAME-OR-WINDOW denotes a live frame, return 250of that window's frame. If FRAME-OR-WINDOW denotes a live frame, return
230the first window of that frame. */) 251the first window of that frame. */)
231 (Lisp_Object frame_or_window) 252 (Lisp_Object frame_or_window)
232{ 253{
@@ -234,7 +255,7 @@ the first window of that frame. */)
234 255
235 if (NILP (frame_or_window)) 256 if (NILP (frame_or_window))
236 window = SELECTED_FRAME ()->root_window; 257 window = SELECTED_FRAME ()->root_window;
237 else if (WINDOWP (frame_or_window)) 258 else if (WINDOW_VALID_P (frame_or_window))
238 window = XFRAME (WINDOW_FRAME (XWINDOW (frame_or_window)))->root_window; 259 window = XFRAME (WINDOW_FRAME (XWINDOW (frame_or_window)))->root_window;
239 else 260 else
240 { 261 {
@@ -259,16 +280,16 @@ DEFUN ("frame-selected-window", Fframe_selected_window,
259 Sframe_selected_window, 0, 1, 0, 280 Sframe_selected_window, 0, 1, 0,
260 doc: /* Return the selected window of FRAME-OR-WINDOW. 281 doc: /* Return the selected window of FRAME-OR-WINDOW.
261If omitted, FRAME-OR-WINDOW defaults to the currently selected frame. 282If omitted, FRAME-OR-WINDOW defaults to the currently selected frame.
262Else if FRAME-OR-WINDOW denotes any window, return the selected window 283Else if FRAME-OR-WINDOW denotes a valid window, return the selected
263of that window's frame. If FRAME-OR-WINDOW denotes a live frame, return 284window of that window's frame. If FRAME-OR-WINDOW denotes a live frame,
264the selected window of that frame. */) 285return the selected window of that frame. */)
265 (Lisp_Object frame_or_window) 286 (Lisp_Object frame_or_window)
266{ 287{
267 Lisp_Object window; 288 Lisp_Object window;
268 289
269 if (NILP (frame_or_window)) 290 if (NILP (frame_or_window))
270 window = SELECTED_FRAME ()->selected_window; 291 window = SELECTED_FRAME ()->selected_window;
271 else if (WINDOWP (frame_or_window)) 292 else if (WINDOW_VALID_P (frame_or_window))
272 window = XFRAME (WINDOW_FRAME (XWINDOW (frame_or_window)))->selected_window; 293 window = XFRAME (WINDOW_FRAME (XWINDOW (frame_or_window)))->selected_window;
273 else 294 else
274 { 295 {
@@ -421,88 +442,92 @@ Return nil for an internal window or a deleted window. */)
421 442
422DEFUN ("window-parent", Fwindow_parent, Swindow_parent, 0, 1, 0, 443DEFUN ("window-parent", Fwindow_parent, Swindow_parent, 0, 1, 0,
423 doc: /* Return the parent window of window WINDOW. 444 doc: /* Return the parent window of window WINDOW.
424If WINDOW is omitted or nil, it defaults to the selected window. 445WINDOW must be a valid window and defaults to the selected one.
425Return nil for a window with no parent (e.g. a root window). */) 446Return nil for a window with no parent (e.g. a root window). */)
426 (Lisp_Object window) 447 (Lisp_Object window)
427{ 448{
428 return decode_any_window (window)->parent; 449 return decode_valid_window (window)->parent;
429} 450}
430 451
431DEFUN ("window-top-child", Fwindow_top_child, Swindow_top_child, 1, 1, 0, 452DEFUN ("window-top-child", Fwindow_top_child, Swindow_top_child, 1, 1, 0,
432 doc: /* Return the topmost child window of window WINDOW. 453 doc: /* Return the topmost child window of window WINDOW.
454WINDOW must be a valid window and defaults to the selected one.
433Return nil if WINDOW is a live window (live windows have no children). 455Return nil if WINDOW is a live window (live windows have no children).
434Return nil if WINDOW is an internal window whose children form a 456Return nil if WINDOW is an internal window whose children form a
435horizontal combination. */) 457horizontal combination. */)
436 (Lisp_Object window) 458 (Lisp_Object window)
437{ 459{
438 CHECK_WINDOW (window); 460 CHECK_WINDOW (window);
439 return decode_any_window (window)->vchild; 461 return decode_valid_window (window)->vchild;
440} 462}
441 463
442DEFUN ("window-left-child", Fwindow_left_child, Swindow_left_child, 1, 1, 0, 464DEFUN ("window-left-child", Fwindow_left_child, Swindow_left_child, 1, 1, 0,
443 doc: /* Return the leftmost child window of window WINDOW. 465 doc: /* Return the leftmost child window of window WINDOW.
466WINDOW must be a valid window and defaults to the selected one.
444Return nil if WINDOW is a live window (live windows have no children). 467Return nil if WINDOW is a live window (live windows have no children).
445Return nil if WINDOW is an internal window whose children form a 468Return nil if WINDOW is an internal window whose children form a
446vertical combination. */) 469vertical combination. */)
447 (Lisp_Object window) 470 (Lisp_Object window)
448{ 471{
449 CHECK_WINDOW (window); 472 CHECK_WINDOW (window);
450 return decode_any_window (window)->hchild; 473 return decode_valid_window (window)->hchild;
451} 474}
452 475
453DEFUN ("window-next-sibling", Fwindow_next_sibling, Swindow_next_sibling, 0, 1, 0, 476DEFUN ("window-next-sibling", Fwindow_next_sibling, Swindow_next_sibling, 0, 1, 0,
454 doc: /* Return the next sibling window of window WINDOW. 477 doc: /* Return the next sibling window of window WINDOW.
455If WINDOW is omitted or nil, it defaults to the selected window. 478WINDOW must be a valid window and defaults to the selected one.
456Return nil if WINDOW has no next sibling. */) 479Return nil if WINDOW has no next sibling. */)
457 (Lisp_Object window) 480 (Lisp_Object window)
458{ 481{
459 return decode_any_window (window)->next; 482 return decode_valid_window (window)->next;
460} 483}
461 484
462DEFUN ("window-prev-sibling", Fwindow_prev_sibling, Swindow_prev_sibling, 0, 1, 0, 485DEFUN ("window-prev-sibling", Fwindow_prev_sibling, Swindow_prev_sibling, 0, 1, 0,
463 doc: /* Return the previous sibling window of window WINDOW. 486 doc: /* Return the previous sibling window of window WINDOW.
464If WINDOW is omitted or nil, it defaults to the selected window. 487WINDOW must be a valid window and defaults to the selected one.
465Return nil if WINDOW has no previous sibling. */) 488Return nil if WINDOW has no previous sibling. */)
466 (Lisp_Object window) 489 (Lisp_Object window)
467{ 490{
468 return decode_any_window (window)->prev; 491 return decode_valid_window (window)->prev;
469} 492}
470 493
471DEFUN ("window-combination-limit", Fwindow_combination_limit, Swindow_combination_limit, 1, 1, 0, 494DEFUN ("window-combination-limit", Fwindow_combination_limit, Swindow_combination_limit, 1, 1, 0,
472 doc: /* Return combination limit of window WINDOW. 495 doc: /* Return combination limit of window WINDOW.
496WINDOW must be a valid window and defaults to the selected one.
473If the return value is nil, child windows of WINDOW can be recombined with 497If the return value is nil, child windows of WINDOW can be recombined with
474WINDOW's siblings. A return value of t means that child windows of 498WINDOW's siblings. A return value of t means that child windows of
475WINDOW are never \(re-)combined with WINDOW's siblings. */) 499WINDOW are never \(re-)combined with WINDOW's siblings. */)
476 (Lisp_Object window) 500 (Lisp_Object window)
477{ 501{
478 return decode_any_window (window)->combination_limit; 502 return decode_valid_window (window)->combination_limit;
479} 503}
480 504
481DEFUN ("set-window-combination-limit", Fset_window_combination_limit, Sset_window_combination_limit, 2, 2, 0, 505DEFUN ("set-window-combination-limit", Fset_window_combination_limit, Sset_window_combination_limit, 2, 2, 0,
482 doc: /* Set combination limit of window WINDOW to LIMIT; return LIMIT. 506 doc: /* Set combination limit of window WINDOW to LIMIT; return LIMIT.
507WINDOW must be a valid window and defaults to the selected one.
483If LIMIT is nil, child windows of WINDOW can be recombined with 508If LIMIT is nil, child windows of WINDOW can be recombined with
484WINDOW's siblings. LIMIT t means that child windows of WINDOW are 509WINDOW's siblings. LIMIT t means that child windows of WINDOW are
485never \(re-)combined with WINDOW's siblings. Other values are reserved 510never \(re-)combined with WINDOW's siblings. Other values are reserved
486for future use. */) 511for future use. */)
487 (Lisp_Object window, Lisp_Object limit) 512 (Lisp_Object window, Lisp_Object limit)
488{ 513{
489 return WSET (decode_any_window (window), combination_limit, limit); 514 return WSET (decode_valid_window (window), combination_limit, limit);
490} 515}
491 516
492DEFUN ("window-use-time", Fwindow_use_time, Swindow_use_time, 0, 1, 0, 517DEFUN ("window-use-time", Fwindow_use_time, Swindow_use_time, 0, 1, 0,
493 doc: /* Return the use time of window WINDOW. 518 doc: /* Return the use time of window WINDOW.
494If WINDOW is omitted or nil, it defaults to the selected window. 519WINDOW must be a live window and defaults to the selected one.
495The window with the highest use time is the most recently selected 520The window with the highest use time is the most recently selected
496one. The window with the lowest use time is the least recently 521one. The window with the lowest use time is the least recently
497selected one. */) 522selected one. */)
498 (Lisp_Object window) 523 (Lisp_Object window)
499{ 524{
500 return make_number (decode_window (window)->use_time); 525 return make_number (decode_live_window (window)->use_time);
501} 526}
502 527
503DEFUN ("window-total-height", Fwindow_total_height, Swindow_total_height, 0, 1, 0, 528DEFUN ("window-total-height", Fwindow_total_height, Swindow_total_height, 0, 1, 0,
504 doc: /* Return the total height, in lines, of window WINDOW. 529 doc: /* Return the total height, in lines, of window WINDOW.
505If WINDOW is omitted or nil, it defaults to the selected window. 530WINDOW must be a valid window and defaults to the selected one.
506 531
507The return value includes the mode line and header line, if any. 532The return value includes the mode line and header line, if any.
508If WINDOW is an internal window, the total height is the height 533If WINDOW is an internal window, the total height is the height
@@ -512,12 +537,12 @@ On a graphical display, this total height is reported as an
512integer multiple of the default character height. */) 537integer multiple of the default character height. */)
513 (Lisp_Object window) 538 (Lisp_Object window)
514{ 539{
515 return decode_any_window (window)->total_lines; 540 return decode_valid_window (window)->total_lines;
516} 541}
517 542
518DEFUN ("window-total-width", Fwindow_total_width, Swindow_total_width, 0, 1, 0, 543DEFUN ("window-total-width", Fwindow_total_width, Swindow_total_width, 0, 1, 0,
519 doc: /* Return the total width, in columns, of window WINDOW. 544 doc: /* Return the total width, in columns, of window WINDOW.
520If WINDOW is omitted or nil, it defaults to the selected window. 545WINDOW must be a valid window and defaults to the selected one.
521 546
522The return value includes any vertical dividers or scroll bars 547The return value includes any vertical dividers or scroll bars
523belonging to WINDOW. If WINDOW is an internal window, the total width 548belonging to WINDOW. If WINDOW is an internal window, the total width
@@ -527,34 +552,34 @@ On a graphical display, this total width is reported as an
527integer multiple of the default character width. */) 552integer multiple of the default character width. */)
528 (Lisp_Object window) 553 (Lisp_Object window)
529{ 554{
530 return decode_any_window (window)->total_cols; 555 return decode_valid_window (window)->total_cols;
531} 556}
532 557
533DEFUN ("window-new-total", Fwindow_new_total, Swindow_new_total, 0, 1, 0, 558DEFUN ("window-new-total", Fwindow_new_total, Swindow_new_total, 0, 1, 0,
534 doc: /* Return the new total size of window WINDOW. 559 doc: /* Return the new total size of window WINDOW.
535If WINDOW is omitted or nil, it defaults to the selected window. */) 560WINDOW must be a valid window and defaults to the selected one. */)
536 (Lisp_Object window) 561 (Lisp_Object window)
537{ 562{
538 return decode_any_window (window)->new_total; 563 return decode_valid_window (window)->new_total;
539} 564}
540 565
541DEFUN ("window-normal-size", Fwindow_normal_size, Swindow_normal_size, 0, 2, 0, 566DEFUN ("window-normal-size", Fwindow_normal_size, Swindow_normal_size, 0, 2, 0,
542 doc: /* Return the normal height of window WINDOW. 567 doc: /* Return the normal height of window WINDOW.
543If WINDOW is omitted or nil, it defaults to the selected window. 568WINDOW must be a valid window and defaults to the selected one.
544If HORIZONTAL is non-nil, return the normal width of WINDOW. */) 569If HORIZONTAL is non-nil, return the normal width of WINDOW. */)
545 (Lisp_Object window, Lisp_Object horizontal) 570 (Lisp_Object window, Lisp_Object horizontal)
546{ 571{
547 struct window *w = decode_any_window (window); 572 struct window *w = decode_valid_window (window);
548 573
549 return NILP (horizontal) ? w->normal_lines : w->normal_cols; 574 return NILP (horizontal) ? w->normal_lines : w->normal_cols;
550} 575}
551 576
552DEFUN ("window-new-normal", Fwindow_new_normal, Swindow_new_normal, 0, 1, 0, 577DEFUN ("window-new-normal", Fwindow_new_normal, Swindow_new_normal, 0, 1, 0,
553 doc: /* Return new normal size of window WINDOW. 578 doc: /* Return new normal size of window WINDOW.
554If WINDOW is omitted or nil, it defaults to the selected window. */) 579WINDOW must be a valid window and defaults to the selected one. */)
555 (Lisp_Object window) 580 (Lisp_Object window)
556{ 581{
557 return decode_any_window (window)->new_normal; 582 return decode_valid_window (window)->new_normal;
558} 583}
559 584
560DEFUN ("window-left-column", Fwindow_left_column, Swindow_left_column, 0, 1, 0, 585DEFUN ("window-left-column", Fwindow_left_column, Swindow_left_column, 0, 1, 0,
@@ -563,10 +588,10 @@ This is the distance, in columns, between the left edge of WINDOW and
563the left edge of the frame's window area. For instance, the return 588the left edge of the frame's window area. For instance, the return
564value is 0 if there is no window to the left of WINDOW. 589value is 0 if there is no window to the left of WINDOW.
565 590
566If WINDOW is omitted or nil, it defaults to the selected window. */) 591WINDOW must be a valid window and defaults to the selected one. */)
567 (Lisp_Object window) 592 (Lisp_Object window)
568{ 593{
569 return decode_any_window (window)->left_col; 594 return decode_valid_window (window)->left_col;
570} 595}
571 596
572DEFUN ("window-top-line", Fwindow_top_line, Swindow_top_line, 0, 1, 0, 597DEFUN ("window-top-line", Fwindow_top_line, Swindow_top_line, 0, 1, 0,
@@ -575,10 +600,10 @@ This is the distance, in lines, between the top of WINDOW and the top
575of the frame's window area. For instance, the return value is 0 if 600of the frame's window area. For instance, the return value is 0 if
576there is no window above WINDOW. 601there is no window above WINDOW.
577 602
578If WINDOW is omitted or nil, it defaults to the selected window. */) 603WINDOW must be a valid window and defaults to the selected one. */)
579 (Lisp_Object window) 604 (Lisp_Object window)
580{ 605{
581 return decode_any_window (window)->top_line; 606 return decode_valid_window (window)->top_line;
582} 607}
583 608
584/* Return the number of lines of W's body. Don't count any mode or 609/* Return the number of lines of W's body. Don't count any mode or
@@ -632,8 +657,7 @@ window_body_cols (struct window *w)
632 657
633DEFUN ("window-body-height", Fwindow_body_height, Swindow_body_height, 0, 1, 0, 658DEFUN ("window-body-height", Fwindow_body_height, Swindow_body_height, 0, 1, 0,
634 doc: /* Return the height, in lines, of WINDOW's text area. 659 doc: /* Return the height, in lines, of WINDOW's text area.
635If WINDOW is omitted or nil, it defaults to the selected window. 660WINDOW must be a live window and defaults to the selected one.
636Signal an error if the window is not live.
637 661
638The returned height does not include the mode line or header line. 662The returned height does not include the mode line or header line.
639On a graphical display, the height is expressed as an integer multiple 663On a graphical display, the height is expressed as an integer multiple
@@ -642,21 +666,20 @@ area is only partially visible, that counts as a whole line; to
642exclude partially-visible lines, use `window-text-height'. */) 666exclude partially-visible lines, use `window-text-height'. */)
643 (Lisp_Object window) 667 (Lisp_Object window)
644{ 668{
645 struct window *w = decode_window (window); 669 struct window *w = decode_live_window (window);
646 return make_number (window_body_lines (w)); 670 return make_number (window_body_lines (w));
647} 671}
648 672
649DEFUN ("window-body-width", Fwindow_body_width, Swindow_body_width, 0, 1, 0, 673DEFUN ("window-body-width", Fwindow_body_width, Swindow_body_width, 0, 1, 0,
650 doc: /* Return the width, in columns, of WINDOW's text area. 674 doc: /* Return the width, in columns, of WINDOW's text area.
651If WINDOW is omitted or nil, it defaults to the selected window. 675WINDOW must be a live window and defaults to the selected one.
652Signal an error if the window is not live.
653 676
654The return value does not include any vertical dividers, fringe or 677The return value does not include any vertical dividers, fringe or
655marginal areas, or scroll bars. On a graphical display, the width is 678marginal areas, or scroll bars. On a graphical display, the width is
656expressed as an integer multiple of the default character width. */) 679expressed as an integer multiple of the default character width. */)
657 (Lisp_Object window) 680 (Lisp_Object window)
658{ 681{
659 struct window *w = decode_window (window); 682 struct window *w = decode_live_window (window);
660 return make_number (window_body_cols (w)); 683 return make_number (window_body_cols (w));
661} 684}
662 685
@@ -665,7 +688,7 @@ DEFUN ("window-hscroll", Fwindow_hscroll, Swindow_hscroll, 0, 1, 0,
665WINDOW must be a live window and defaults to the selected one. */) 688WINDOW must be a live window and defaults to the selected one. */)
666 (Lisp_Object window) 689 (Lisp_Object window)
667{ 690{
668 return make_number (decode_window (window)->hscroll); 691 return make_number (decode_live_window (window)->hscroll);
669} 692}
670 693
671/* Set W's horizontal scroll amount to HSCROLL clipped to a reasonable 694/* Set W's horizontal scroll amount to HSCROLL clipped to a reasonable
@@ -692,7 +715,7 @@ set_window_hscroll (struct window *w, EMACS_INT hscroll)
692 715
693DEFUN ("set-window-hscroll", Fset_window_hscroll, Sset_window_hscroll, 2, 2, 0, 716DEFUN ("set-window-hscroll", Fset_window_hscroll, Sset_window_hscroll, 2, 2, 0,
694 doc: /* Set number of columns WINDOW is scrolled from left margin to NCOL. 717 doc: /* Set number of columns WINDOW is scrolled from left margin to NCOL.
695If WINDOW is nil, the selected window is used. 718WINDOW must be a live window and defaults to the selected one.
696Clip the number to a reasonable value if out of range. 719Clip the number to a reasonable value if out of range.
697Return the new number. NCOL should be zero or positive. 720Return the new number. NCOL should be zero or positive.
698 721
@@ -700,7 +723,7 @@ Note that if `automatic-hscrolling' is non-nil, you cannot scroll the
700window so that the location of point moves off-window. */) 723window so that the location of point moves off-window. */)
701 (Lisp_Object window, Lisp_Object ncol) 724 (Lisp_Object window, Lisp_Object ncol)
702{ 725{
703 struct window *w = decode_window (window); 726 struct window *w = decode_live_window (window);
704 727
705 CHECK_NUMBER (ncol); 728 CHECK_NUMBER (ncol);
706 return set_window_hscroll (w, XINT (ncol)); 729 return set_window_hscroll (w, XINT (ncol));
@@ -709,41 +732,43 @@ window so that the location of point moves off-window. */)
709DEFUN ("window-redisplay-end-trigger", Fwindow_redisplay_end_trigger, 732DEFUN ("window-redisplay-end-trigger", Fwindow_redisplay_end_trigger,
710 Swindow_redisplay_end_trigger, 0, 1, 0, 733 Swindow_redisplay_end_trigger, 0, 1, 0,
711 doc: /* Return WINDOW's redisplay end trigger value. 734 doc: /* Return WINDOW's redisplay end trigger value.
712WINDOW defaults to the selected window. 735WINDOW must be a live window and defaults to the selected one.
713See `set-window-redisplay-end-trigger' for more information. */) 736See `set-window-redisplay-end-trigger' for more information. */)
714 (Lisp_Object window) 737 (Lisp_Object window)
715{ 738{
716 return decode_window (window)->redisplay_end_trigger; 739 return decode_live_window (window)->redisplay_end_trigger;
717} 740}
718 741
719DEFUN ("set-window-redisplay-end-trigger", Fset_window_redisplay_end_trigger, 742DEFUN ("set-window-redisplay-end-trigger", Fset_window_redisplay_end_trigger,
720 Sset_window_redisplay_end_trigger, 2, 2, 0, 743 Sset_window_redisplay_end_trigger, 2, 2, 0,
721 doc: /* Set WINDOW's redisplay end trigger value to VALUE. 744 doc: /* Set WINDOW's redisplay end trigger value to VALUE.
722VALUE should be a buffer position (typically a marker) or nil. 745WINDOW must be a live window and defaults to the selected one. VALUE
723If it is a buffer position, then if redisplay in WINDOW reaches a position 746should be a buffer position (typically a marker) or nil. If it is a
724beyond VALUE, the functions in `redisplay-end-trigger-functions' are called 747buffer position, then if redisplay in WINDOW reaches a position beyond
725with two arguments: WINDOW, and the end trigger value. 748VALUE, the functions in `redisplay-end-trigger-functions' are called
726Afterwards the end-trigger value is reset to nil. */) 749with two arguments: WINDOW, and the end trigger value. Afterwards the
750end-trigger value is reset to nil. */)
727 (register Lisp_Object window, Lisp_Object value) 751 (register Lisp_Object window, Lisp_Object value)
728{ 752{
729 return WSET (decode_window (window), redisplay_end_trigger, value); 753 return WSET (decode_live_window (window), redisplay_end_trigger, value);
730} 754}
731 755
732DEFUN ("window-edges", Fwindow_edges, Swindow_edges, 0, 1, 0, 756DEFUN ("window-edges", Fwindow_edges, Swindow_edges, 0, 1, 0,
733 doc: /* Return a list of the edge coordinates of WINDOW. 757 doc: /* Return a list of the edge coordinates of WINDOW.
734The list has the form (LEFT TOP RIGHT BOTTOM). 758WINDOW must be a valid window and defaults to the selected one.
735TOP and BOTTOM count by lines, and LEFT and RIGHT count by columns, 759
736all relative to 0, 0 at top left corner of frame. 760The returned list has the form (LEFT TOP RIGHT BOTTOM). TOP and BOTTOM
737 761count by lines, and LEFT and RIGHT count by columns, all relative to 0,
738RIGHT is one more than the rightmost column occupied by WINDOW. 7620 at top left corner of frame.
739BOTTOM is one more than the bottommost row occupied by WINDOW. 763
740The edges include the space used by WINDOW's scroll bar, display 764RIGHT is one more than the rightmost column occupied by WINDOW. BOTTOM
741margins, fringes, header line, and/or mode line. For the edges of 765is one more than the bottommost row occupied by WINDOW. The edges
742just the text area, use `window-inside-edges'. */) 766include the space used by WINDOW's scroll bar, display margins, fringes,
767header line, and/or mode line. For the edges of just the text area, use
768`window-inside-edges'. */)
743 (Lisp_Object window) 769 (Lisp_Object window)
744{ 770{
745 register struct window *w = decode_any_window (window); 771 register struct window *w = decode_valid_window (window);
746 CHECK_LIVE_FRAME (w->frame);
747 772
748 return Fcons (make_number (WINDOW_LEFT_EDGE_COL (w)), 773 return Fcons (make_number (WINDOW_LEFT_EDGE_COL (w)),
749 Fcons (make_number (WINDOW_TOP_EDGE_LINE (w)), 774 Fcons (make_number (WINDOW_TOP_EDGE_LINE (w)),
@@ -754,8 +779,10 @@ just the text area, use `window-inside-edges'. */)
754 779
755DEFUN ("window-pixel-edges", Fwindow_pixel_edges, Swindow_pixel_edges, 0, 1, 0, 780DEFUN ("window-pixel-edges", Fwindow_pixel_edges, Swindow_pixel_edges, 0, 1, 0,
756 doc: /* Return a list of the edge pixel coordinates of WINDOW. 781 doc: /* Return a list of the edge pixel coordinates of WINDOW.
757The list has the form (LEFT TOP RIGHT BOTTOM), all relative to 0, 0 at 782WINDOW must be a valid window and defaults to the selected one.
758the top left corner of the frame. 783
784The returned list has the form (LEFT TOP RIGHT BOTTOM), all relative to
7850, 0 at the top left corner of the frame.
759 786
760RIGHT is one more than the rightmost x position occupied by WINDOW. 787RIGHT is one more than the rightmost x position occupied by WINDOW.
761BOTTOM is one more than the bottommost y position occupied by WINDOW. 788BOTTOM is one more than the bottommost y position occupied by WINDOW.
@@ -764,8 +791,7 @@ margins, fringes, header line, and/or mode line. For the pixel edges
764of just the text area, use `window-inside-pixel-edges'. */) 791of just the text area, use `window-inside-pixel-edges'. */)
765 (Lisp_Object window) 792 (Lisp_Object window)
766{ 793{
767 register struct window *w = decode_any_window (window); 794 register struct window *w = decode_valid_window (window);
768 CHECK_LIVE_FRAME (w->frame);
769 795
770 return Fcons (make_number (WINDOW_LEFT_EDGE_X (w)), 796 return Fcons (make_number (WINDOW_LEFT_EDGE_X (w)),
771 Fcons (make_number (WINDOW_TOP_EDGE_Y (w)), 797 Fcons (make_number (WINDOW_TOP_EDGE_Y (w)),
@@ -799,8 +825,10 @@ calc_absolute_offset (struct window *w, int *add_x, int *add_y)
799DEFUN ("window-absolute-pixel-edges", Fwindow_absolute_pixel_edges, 825DEFUN ("window-absolute-pixel-edges", Fwindow_absolute_pixel_edges,
800 Swindow_absolute_pixel_edges, 0, 1, 0, 826 Swindow_absolute_pixel_edges, 0, 1, 0,
801 doc: /* Return a list of the edge pixel coordinates of WINDOW. 827 doc: /* Return a list of the edge pixel coordinates of WINDOW.
802The list has the form (LEFT TOP RIGHT BOTTOM), all relative to 0, 0 at 828WINDOW must be a valid window and defaults to the selected one.
803the top left corner of the display. 829
830The returned list has the form (LEFT TOP RIGHT BOTTOM), all relative to
8310, 0 at the top left corner of the display.
804 832
805RIGHT is one more than the rightmost x position occupied by WINDOW. 833RIGHT is one more than the rightmost x position occupied by WINDOW.
806BOTTOM is one more than the bottommost y position occupied by WINDOW. 834BOTTOM is one more than the bottommost y position occupied by WINDOW.
@@ -809,10 +837,8 @@ margins, fringes, header line, and/or mode line. For the pixel edges
809of just the text area, use `window-inside-absolute-pixel-edges'. */) 837of just the text area, use `window-inside-absolute-pixel-edges'. */)
810 (Lisp_Object window) 838 (Lisp_Object window)
811{ 839{
812 register struct window *w = decode_any_window (window); 840 register struct window *w = decode_valid_window (window);
813 int add_x, add_y; 841 int add_x, add_y;
814
815 CHECK_LIVE_FRAME (w->frame);
816 calc_absolute_offset (w, &add_x, &add_y); 842 calc_absolute_offset (w, &add_x, &add_y);
817 843
818 return Fcons (make_number (WINDOW_LEFT_EDGE_X (w) + add_x), 844 return Fcons (make_number (WINDOW_LEFT_EDGE_X (w) + add_x),
@@ -824,17 +850,19 @@ of just the text area, use `window-inside-absolute-pixel-edges'. */)
824 850
825DEFUN ("window-inside-edges", Fwindow_inside_edges, Swindow_inside_edges, 0, 1, 0, 851DEFUN ("window-inside-edges", Fwindow_inside_edges, Swindow_inside_edges, 0, 1, 0,
826 doc: /* Return a list of the edge coordinates of WINDOW. 852 doc: /* Return a list of the edge coordinates of WINDOW.
827The list has the form (LEFT TOP RIGHT BOTTOM). 853WINDOW must be a live window and defaults to the selected one.
828TOP and BOTTOM count by lines, and LEFT and RIGHT count by columns, 854
829all relative to 0, 0 at top left corner of frame. 855The returned list has the form (LEFT TOP RIGHT BOTTOM). TOP and BOTTOM
856count by lines, and LEFT and RIGHT count by columns, all relative to 0,
8570 at top left corner of frame.
830 858
831RIGHT is one more than the rightmost column of WINDOW's text area. 859RIGHT is one more than the rightmost column of WINDOW's text area.
832BOTTOM is one more than the bottommost row of WINDOW's text area. 860BOTTOM is one more than the bottommost row of WINDOW's text area. The
833The inside edges do not include the space used by the WINDOW's scroll 861inside edges do not include the space used by the WINDOW's scroll bar,
834bar, display margins, fringes, header line, and/or mode line. */) 862display margins, fringes, header line, and/or mode line. */)
835 (Lisp_Object window) 863 (Lisp_Object window)
836{ 864{
837 register struct window *w = decode_window (window); 865 register struct window *w = decode_live_window (window);
838 866
839 return list4 (make_number (WINDOW_BOX_LEFT_EDGE_COL (w) 867 return list4 (make_number (WINDOW_BOX_LEFT_EDGE_COL (w)
840 + WINDOW_LEFT_MARGIN_COLS (w) 868 + WINDOW_LEFT_MARGIN_COLS (w)
@@ -850,8 +878,10 @@ bar, display margins, fringes, header line, and/or mode line. */)
850 878
851DEFUN ("window-inside-pixel-edges", Fwindow_inside_pixel_edges, Swindow_inside_pixel_edges, 0, 1, 0, 879DEFUN ("window-inside-pixel-edges", Fwindow_inside_pixel_edges, Swindow_inside_pixel_edges, 0, 1, 0,
852 doc: /* Return a list of the edge pixel coordinates of WINDOW's text area. 880 doc: /* Return a list of the edge pixel coordinates of WINDOW's text area.
853The list has the form (LEFT TOP RIGHT BOTTOM), all relative to (0,0) 881WINDOW must be a live window and defaults to the selected one.
854at the top left corner of the frame's window area. 882
883The returned list has the form (LEFT TOP RIGHT BOTTOM), all relative to
884(0,0) at the top left corner of the frame's window area.
855 885
856RIGHT is one more than the rightmost x position of WINDOW's text area. 886RIGHT is one more than the rightmost x position of WINDOW's text area.
857BOTTOM is one more than the bottommost y position of WINDOW's text area. 887BOTTOM is one more than the bottommost y position of WINDOW's text area.
@@ -859,7 +889,7 @@ The inside edges do not include the space used by WINDOW's scroll bar,
859display margins, fringes, header line, and/or mode line. */) 889display margins, fringes, header line, and/or mode line. */)
860 (Lisp_Object window) 890 (Lisp_Object window)
861{ 891{
862 register struct window *w = decode_window (window); 892 register struct window *w = decode_live_window (window);
863 893
864 return list4 (make_number (WINDOW_BOX_LEFT_EDGE_X (w) 894 return list4 (make_number (WINDOW_BOX_LEFT_EDGE_X (w)
865 + WINDOW_LEFT_MARGIN_WIDTH (w) 895 + WINDOW_LEFT_MARGIN_WIDTH (w)
@@ -877,8 +907,10 @@ DEFUN ("window-inside-absolute-pixel-edges",
877 Fwindow_inside_absolute_pixel_edges, 907 Fwindow_inside_absolute_pixel_edges,
878 Swindow_inside_absolute_pixel_edges, 0, 1, 0, 908 Swindow_inside_absolute_pixel_edges, 0, 1, 0,
879 doc: /* Return a list of the edge pixel coordinates of WINDOW's text area. 909 doc: /* Return a list of the edge pixel coordinates of WINDOW's text area.
880The list has the form (LEFT TOP RIGHT BOTTOM), all relative to (0,0) 910WINDOW must be a live window and defaults to the selected one.
881at the top left corner of the frame's window area. 911
912The returned list has the form (LEFT TOP RIGHT BOTTOM), all relative to
913(0,0) at the top left corner of the frame's window area.
882 914
883RIGHT is one more than the rightmost x position of WINDOW's text area. 915RIGHT is one more than the rightmost x position of WINDOW's text area.
884BOTTOM is one more than the bottommost y position of WINDOW's text area. 916BOTTOM is one more than the bottommost y position of WINDOW's text area.
@@ -886,7 +918,7 @@ The inside edges do not include the space used by WINDOW's scroll bar,
886display margins, fringes, header line, and/or mode line. */) 918display margins, fringes, header line, and/or mode line. */)
887 (Lisp_Object window) 919 (Lisp_Object window)
888{ 920{
889 register struct window *w = decode_window (window); 921 register struct window *w = decode_live_window (window);
890 int add_x, add_y; 922 int add_x, add_y;
891 calc_absolute_offset (w, &add_x, &add_y); 923 calc_absolute_offset (w, &add_x, &add_y);
892 924
@@ -1065,7 +1097,7 @@ window_relative_x_coord (struct window *w, enum window_part part, int x)
1065DEFUN ("coordinates-in-window-p", Fcoordinates_in_window_p, 1097DEFUN ("coordinates-in-window-p", Fcoordinates_in_window_p,
1066 Scoordinates_in_window_p, 2, 2, 0, 1098 Scoordinates_in_window_p, 2, 2, 0,
1067 doc: /* Return non-nil if COORDINATES are in WINDOW. 1099 doc: /* Return non-nil if COORDINATES are in WINDOW.
1068WINDOW must be a live window. 1100WINDOW must be a live window and defaults to the selected one.
1069COORDINATES is a cons of the form (X . Y), X and Y being distances 1101COORDINATES is a cons of the form (X . Y), X and Y being distances
1070measured in characters from the upper-left corner of the frame. 1102measured in characters from the upper-left corner of the frame.
1071\(0 . 0) denotes the character in the upper left corner of the 1103\(0 . 0) denotes the character in the upper left corner of the
@@ -1087,8 +1119,7 @@ If they are in the windows's left or right marginal areas, `left-margin'\n\
1087 int x, y; 1119 int x, y;
1088 Lisp_Object lx, ly; 1120 Lisp_Object lx, ly;
1089 1121
1090 CHECK_LIVE_WINDOW (window); 1122 w = decode_live_window (window);
1091 w = XWINDOW (window);
1092 f = XFRAME (w->frame); 1123 f = XFRAME (w->frame);
1093 CHECK_CONS (coordinates); 1124 CHECK_CONS (coordinates);
1094 lx = Fcar (coordinates); 1125 lx = Fcar (coordinates);
@@ -1266,7 +1297,7 @@ of point, outside of any save-excursion forms.
1266But that is hard to define. */) 1297But that is hard to define. */)
1267 (Lisp_Object window) 1298 (Lisp_Object window)
1268{ 1299{
1269 register struct window *w = decode_window (window); 1300 register struct window *w = decode_live_window (window);
1270 1301
1271 if (w == XWINDOW (selected_window) 1302 if (w == XWINDOW (selected_window)
1272 && current_buffer == XBUFFER (w->buffer)) 1303 && current_buffer == XBUFFER (w->buffer))
@@ -1280,7 +1311,7 @@ WINDOW must be a live window and defaults to the selected one.
1280This is updated by redisplay or by calling `set-window-start'. */) 1311This is updated by redisplay or by calling `set-window-start'. */)
1281 (Lisp_Object window) 1312 (Lisp_Object window)
1282{ 1313{
1283 return Fmarker_position (decode_window (window)->start); 1314 return Fmarker_position (decode_live_window (window)->start);
1284} 1315}
1285 1316
1286/* This is text temporarily removed from the doc string below. 1317/* This is text temporarily removed from the doc string below.
@@ -1307,7 +1338,7 @@ if it isn't already recorded. */)
1307 (Lisp_Object window, Lisp_Object update) 1338 (Lisp_Object window, Lisp_Object update)
1308{ 1339{
1309 Lisp_Object value; 1340 Lisp_Object value;
1310 struct window *w = decode_window (window); 1341 struct window *w = decode_live_window (window);
1311 Lisp_Object buf; 1342 Lisp_Object buf;
1312 struct buffer *b; 1343 struct buffer *b;
1313 1344
@@ -1374,10 +1405,11 @@ if it isn't already recorded. */)
1374 1405
1375DEFUN ("set-window-point", Fset_window_point, Sset_window_point, 2, 2, 0, 1406DEFUN ("set-window-point", Fset_window_point, Sset_window_point, 2, 2, 0,
1376 doc: /* Make point value in WINDOW be at position POS in WINDOW's buffer. 1407 doc: /* Make point value in WINDOW be at position POS in WINDOW's buffer.
1408WINDOW must be a live window and defaults to the selected one.
1377Return POS. */) 1409Return POS. */)
1378 (Lisp_Object window, Lisp_Object pos) 1410 (Lisp_Object window, Lisp_Object pos)
1379{ 1411{
1380 register struct window *w = decode_window (window); 1412 register struct window *w = decode_live_window (window);
1381 1413
1382 CHECK_NUMBER_COERCE_MARKER (pos); 1414 CHECK_NUMBER_COERCE_MARKER (pos);
1383 if (w == XWINDOW (selected_window) 1415 if (w == XWINDOW (selected_window)
@@ -1396,12 +1428,12 @@ Return POS. */)
1396 1428
1397DEFUN ("set-window-start", Fset_window_start, Sset_window_start, 2, 3, 0, 1429DEFUN ("set-window-start", Fset_window_start, Sset_window_start, 2, 3, 0,
1398 doc: /* Make display in WINDOW start at position POS in WINDOW's buffer. 1430 doc: /* Make display in WINDOW start at position POS in WINDOW's buffer.
1399If WINDOW is nil, the selected window is used. Return POS. 1431WINDOW must be a live window and defaults to the selected one. Return
1400Optional third arg NOFORCE non-nil inhibits next redisplay from 1432POS. Optional third arg NOFORCE non-nil inhibits next redisplay from
1401overriding motion of point in order to display at this exact start. */) 1433overriding motion of point in order to display at this exact start. */)
1402 (Lisp_Object window, Lisp_Object pos, Lisp_Object noforce) 1434 (Lisp_Object window, Lisp_Object pos, Lisp_Object noforce)
1403{ 1435{
1404 register struct window *w = decode_window (window); 1436 register struct window *w = decode_live_window (window);
1405 1437
1406 CHECK_NUMBER_COERCE_MARKER (pos); 1438 CHECK_NUMBER_COERCE_MARKER (pos);
1407 set_marker_restricted (w->start, pos, w->buffer); 1439 set_marker_restricted (w->start, pos, w->buffer);
@@ -1421,12 +1453,14 @@ overriding motion of point in order to display at this exact start. */)
1421DEFUN ("pos-visible-in-window-p", Fpos_visible_in_window_p, 1453DEFUN ("pos-visible-in-window-p", Fpos_visible_in_window_p,
1422 Spos_visible_in_window_p, 0, 3, 0, 1454 Spos_visible_in_window_p, 0, 3, 0,
1423 doc: /* Return non-nil if position POS is currently on the frame in WINDOW. 1455 doc: /* Return non-nil if position POS is currently on the frame in WINDOW.
1424Return nil if that position is scrolled vertically out of view. 1456WINDOW must be a live window and defaults to the selected one.
1425If a character is only partially visible, nil is returned, unless the 1457
1426optional argument PARTIALLY is non-nil. 1458Return nil if that position is scrolled vertically out of view. If a
1427If POS is only out of view because of horizontal scrolling, return non-nil. 1459character is only partially visible, nil is returned, unless the
1428If POS is t, it specifies the position of the last visible glyph in WINDOW. 1460optional argument PARTIALLY is non-nil. If POS is only out of view
1429POS defaults to point in WINDOW; WINDOW defaults to the selected window. 1461because of horizontal scrolling, return non-nil. If POS is t, it
1462specifies the position of the last visible glyph in WINDOW. POS
1463defaults to point in WINDOW; WINDOW defaults to the selected window.
1430 1464
1431If POS is visible, return t if PARTIALLY is nil; if PARTIALLY is non-nil, 1465If POS is visible, return t if PARTIALLY is nil; if PARTIALLY is non-nil,
1432return value is a list of 2 or 6 elements (X Y [RTOP RBOT ROWH VPOS]), 1466return value is a list of 2 or 6 elements (X Y [RTOP RBOT ROWH VPOS]),
@@ -1445,7 +1479,7 @@ display row, and VPOS is the row number (0-based) containing POS. */)
1445 int rtop, rbot, rowh, vpos, fully_p = 1; 1479 int rtop, rbot, rowh, vpos, fully_p = 1;
1446 int x, y; 1480 int x, y;
1447 1481
1448 w = decode_window (window); 1482 w = decode_live_window (window);
1449 buf = XBUFFER (w->buffer); 1483 buf = XBUFFER (w->buffer);
1450 SET_TEXT_POS_FROM_MARKER (top, w->start); 1484 SET_TEXT_POS_FROM_MARKER (top, w->start);
1451 1485
@@ -1487,7 +1521,7 @@ display row, and VPOS is the row number (0-based) containing POS. */)
1487DEFUN ("window-line-height", Fwindow_line_height, 1521DEFUN ("window-line-height", Fwindow_line_height,
1488 Swindow_line_height, 0, 2, 0, 1522 Swindow_line_height, 0, 2, 0,
1489 doc: /* Return height in pixels of text line LINE in window WINDOW. 1523 doc: /* Return height in pixels of text line LINE in window WINDOW.
1490WINDOW defaults to the selected window. 1524WINDOW must be a live window and defaults to the selected one.
1491 1525
1492Return height of current line if LINE is omitted or nil. Return height of 1526Return height of current line if LINE is omitted or nil. Return height of
1493header or mode line if LINE is `header-line' or `mode-line'. 1527header or mode line if LINE is `header-line' or `mode-line'.
@@ -1511,7 +1545,7 @@ Return nil if window display is not up-to-date. In that case, use
1511 int max_y, crop, i; 1545 int max_y, crop, i;
1512 EMACS_INT n; 1546 EMACS_INT n;
1513 1547
1514 w = decode_window (window); 1548 w = decode_live_window (window);
1515 1549
1516 if (noninteractive || w->pseudo_window_p) 1550 if (noninteractive || w->pseudo_window_p)
1517 return Qnil; 1551 return Qnil;
@@ -1599,8 +1633,8 @@ DEFUN ("window-dedicated-p", Fwindow_dedicated_p, Swindow_dedicated_p,
1599More precisely, return the value assigned by the last call of 1633More precisely, return the value assigned by the last call of
1600`set-window-dedicated-p' for WINDOW. Return nil if that function was 1634`set-window-dedicated-p' for WINDOW. Return nil if that function was
1601never called with WINDOW as its argument, or the value set by that 1635never called with WINDOW as its argument, or the value set by that
1602function was internally reset since its last call. WINDOW defaults to 1636function was internally reset since its last call. WINDOW must be a
1603the selected window. 1637live window and defaults to the selected one.
1604 1638
1605When a window is dedicated to its buffer, `display-buffer' will refrain 1639When a window is dedicated to its buffer, `display-buffer' will refrain
1606from displaying another buffer in it. `get-lru-window' and 1640from displaying another buffer in it. `get-lru-window' and
@@ -1613,7 +1647,7 @@ window, unless that window is "strongly" dedicated to its buffer, that
1613is the value returned by `window-dedicated-p' is t. */) 1647is the value returned by `window-dedicated-p' is t. */)
1614 (Lisp_Object window) 1648 (Lisp_Object window)
1615{ 1649{
1616 return decode_window (window)->dedicated; 1650 return decode_live_window (window)->dedicated;
1617} 1651}
1618 1652
1619DEFUN ("set-window-dedicated-p", Fset_window_dedicated_p, 1653DEFUN ("set-window-dedicated-p", Fset_window_dedicated_p,
@@ -1637,7 +1671,7 @@ buffer. If and when `set-window-buffer' displays another buffer in a
1637window, it also makes sure that the window is no more dedicated. */) 1671window, it also makes sure that the window is no more dedicated. */)
1638 (Lisp_Object window, Lisp_Object flag) 1672 (Lisp_Object window, Lisp_Object flag)
1639{ 1673{
1640 return WSET (decode_window (window), dedicated, flag); 1674 return WSET (decode_live_window (window), dedicated, flag);
1641} 1675}
1642 1676
1643DEFUN ("window-prev-buffers", Fwindow_prev_buffers, Swindow_prev_buffers, 1677DEFUN ("window-prev-buffers", Fwindow_prev_buffers, Swindow_prev_buffers,
@@ -1650,7 +1684,7 @@ where BUFFER is a buffer, WINDOW-START is the start position of the
1650window for that buffer, and POS is a window-specific point value. */) 1684window for that buffer, and POS is a window-specific point value. */)
1651 (Lisp_Object window) 1685 (Lisp_Object window)
1652{ 1686{
1653 return decode_window (window)->prev_buffers; 1687 return decode_live_window (window)->prev_buffers;
1654} 1688}
1655 1689
1656DEFUN ("set-window-prev-buffers", Fset_window_prev_buffers, 1690DEFUN ("set-window-prev-buffers", Fset_window_prev_buffers,
@@ -1663,7 +1697,7 @@ where BUFFER is a buffer, WINDOW-START is the start position of the
1663window for that buffer, and POS is a window-specific point value. */) 1697window for that buffer, and POS is a window-specific point value. */)
1664 (Lisp_Object window, Lisp_Object prev_buffers) 1698 (Lisp_Object window, Lisp_Object prev_buffers)
1665{ 1699{
1666 return WSET (decode_window (window), prev_buffers, prev_buffers); 1700 return WSET (decode_live_window (window), prev_buffers, prev_buffers);
1667} 1701}
1668 1702
1669DEFUN ("window-next-buffers", Fwindow_next_buffers, Swindow_next_buffers, 1703DEFUN ("window-next-buffers", Fwindow_next_buffers, Swindow_next_buffers,
@@ -1672,7 +1706,7 @@ DEFUN ("window-next-buffers", Fwindow_next_buffers, Swindow_next_buffers,
1672WINDOW must be a live window and defaults to the selected one. */) 1706WINDOW must be a live window and defaults to the selected one. */)
1673 (Lisp_Object window) 1707 (Lisp_Object window)
1674{ 1708{
1675 return decode_window (window)->next_buffers; 1709 return decode_live_window (window)->next_buffers;
1676} 1710}
1677 1711
1678DEFUN ("set-window-next-buffers", Fset_window_next_buffers, 1712DEFUN ("set-window-next-buffers", Fset_window_next_buffers,
@@ -1682,38 +1716,39 @@ WINDOW must be a live window and defaults to the selected one.
1682NEXT-BUFFERS should be a list of buffers. */) 1716NEXT-BUFFERS should be a list of buffers. */)
1683 (Lisp_Object window, Lisp_Object next_buffers) 1717 (Lisp_Object window, Lisp_Object next_buffers)
1684{ 1718{
1685 return WSET (decode_window (window), next_buffers, next_buffers); 1719 return WSET (decode_live_window (window), next_buffers, next_buffers);
1686} 1720}
1687 1721
1688DEFUN ("window-parameters", Fwindow_parameters, Swindow_parameters, 1722DEFUN ("window-parameters", Fwindow_parameters, Swindow_parameters,
1689 0, 1, 0, 1723 0, 1, 0,
1690 doc: /* Return the parameters of WINDOW and their values. 1724 doc: /* Return the parameters of WINDOW and their values.
1691WINDOW defaults to the selected window. The return value is a list of 1725WINDOW must be a valid window and defaults to the selected one. The
1692elements of the form (PARAMETER . VALUE). */) 1726return value is a list of elements of the form (PARAMETER . VALUE). */)
1693 (Lisp_Object window) 1727 (Lisp_Object window)
1694{ 1728{
1695 return Fcopy_alist (decode_any_window (window)->window_parameters); 1729 return Fcopy_alist (decode_valid_window (window)->window_parameters);
1696} 1730}
1697 1731
1698DEFUN ("window-parameter", Fwindow_parameter, Swindow_parameter, 1732DEFUN ("window-parameter", Fwindow_parameter, Swindow_parameter,
1699 2, 2, 0, 1733 2, 2, 0,
1700 doc: /* Return WINDOW's value for PARAMETER. 1734 doc: /* Return WINDOW's value for PARAMETER.
1701WINDOW defaults to the selected window. */) 1735WINDOW must be a valid window and defaults to the selected one. */)
1702 (Lisp_Object window, Lisp_Object parameter) 1736 (Lisp_Object window, Lisp_Object parameter)
1703{ 1737{
1704 Lisp_Object result; 1738 Lisp_Object result;
1705 1739
1706 result = Fassq (parameter, decode_any_window (window)->window_parameters); 1740 result = Fassq (parameter, decode_valid_window (window)->window_parameters);
1707 return CDR_SAFE (result); 1741 return CDR_SAFE (result);
1708} 1742}
1709 1743
1710DEFUN ("set-window-parameter", Fset_window_parameter, 1744DEFUN ("set-window-parameter", Fset_window_parameter,
1711 Sset_window_parameter, 3, 3, 0, 1745 Sset_window_parameter, 3, 3, 0,
1712 doc: /* Set WINDOW's value of PARAMETER to VALUE. 1746 doc: /* Set WINDOW's value of PARAMETER to VALUE.
1713WINDOW defaults to the selected window. Return VALUE. */) 1747WINDOW must be a valid window and defaults to the selected one.
1748Return VALUE. */)
1714 (Lisp_Object window, Lisp_Object parameter, Lisp_Object value) 1749 (Lisp_Object window, Lisp_Object parameter, Lisp_Object value)
1715{ 1750{
1716 register struct window *w = decode_any_window (window); 1751 register struct window *w = decode_valid_window (window);
1717 Lisp_Object old_alist_elt; 1752 Lisp_Object old_alist_elt;
1718 1753
1719 old_alist_elt = Fassq (parameter, w->window_parameters); 1754 old_alist_elt = Fassq (parameter, w->window_parameters);
@@ -1728,10 +1763,10 @@ WINDOW defaults to the selected window. Return VALUE. */)
1728DEFUN ("window-display-table", Fwindow_display_table, Swindow_display_table, 1763DEFUN ("window-display-table", Fwindow_display_table, Swindow_display_table,
1729 0, 1, 0, 1764 0, 1, 0,
1730 doc: /* Return the display-table that WINDOW is using. 1765 doc: /* Return the display-table that WINDOW is using.
1731WINDOW defaults to the selected window. */) 1766WINDOW must be a live window and defaults to the selected one. */)
1732 (Lisp_Object window) 1767 (Lisp_Object window)
1733{ 1768{
1734 return decode_window (window)->display_table; 1769 return decode_live_window (window)->display_table;
1735} 1770}
1736 1771
1737/* Get the display table for use on window W. This is either W's 1772/* Get the display table for use on window W. This is either W's
@@ -1760,10 +1795,11 @@ window_display_table (struct window *w)
1760} 1795}
1761 1796
1762DEFUN ("set-window-display-table", Fset_window_display_table, Sset_window_display_table, 2, 2, 0, 1797DEFUN ("set-window-display-table", Fset_window_display_table, Sset_window_display_table, 2, 2, 0,
1763 doc: /* Set WINDOW's display-table to TABLE. */) 1798 doc: /* Set WINDOW's display-table to TABLE.
1799WINDOW must be a live window and defaults to the selected one. */)
1764 (register Lisp_Object window, Lisp_Object table) 1800 (register Lisp_Object window, Lisp_Object table)
1765{ 1801{
1766 return WSET (decode_window (window), display_table, table); 1802 return WSET (decode_live_window (window), display_table, table);
1767} 1803}
1768 1804
1769/* Record info on buffer window W is displaying 1805/* Record info on buffer window W is displaying
@@ -2559,8 +2595,8 @@ resize_root_window (Lisp_Object window, Lisp_Object delta, Lisp_Object horizonta
2559DEFUN ("delete-other-windows-internal", Fdelete_other_windows_internal, 2595DEFUN ("delete-other-windows-internal", Fdelete_other_windows_internal,
2560 Sdelete_other_windows_internal, 0, 2, "", 2596 Sdelete_other_windows_internal, 0, 2, "",
2561 doc: /* Make WINDOW fill its frame. 2597 doc: /* Make WINDOW fill its frame.
2562Only the frame WINDOW is on is affected. WINDOW may be any window and 2598Only the frame WINDOW is on is affected. WINDOW must be a valid window
2563defaults to the selected one. 2599and defaults to the selected one.
2564 2600
2565Optional argument ROOT, if non-nil, must specify an internal window such 2601Optional argument ROOT, if non-nil, must specify an internal window such
2566that WINDOW is in its window subtree. If this is the case, replace ROOT 2602that WINDOW is in its window subtree. If this is the case, replace ROOT
@@ -2579,8 +2615,7 @@ window-start value is reasonable when this function is called. */)
2579 ptrdiff_t startpos IF_LINT (= 0); 2615 ptrdiff_t startpos IF_LINT (= 0);
2580 int top IF_LINT (= 0), new_top, resize_failed; 2616 int top IF_LINT (= 0), new_top, resize_failed;
2581 2617
2582 w = decode_any_window (window); 2618 w = decode_valid_window (window);
2583 CHECK_LIVE_FRAME (w->frame);
2584 XSETWINDOW (window, w); 2619 XSETWINDOW (window, w);
2585 f = XFRAME (w->frame); 2620 f = XFRAME (w->frame);
2586 2621
@@ -2593,8 +2628,7 @@ window-start value is reasonable when this function is called. */)
2593 else 2628 else
2594 /* ROOT must be an ancestor of WINDOW. */ 2629 /* ROOT must be an ancestor of WINDOW. */
2595 { 2630 {
2596 r = decode_any_window (root); 2631 r = decode_valid_window (root);
2597 CHECK_LIVE_FRAME (r->frame);
2598 pwindow = XWINDOW (window)->parent; 2632 pwindow = XWINDOW (window)->parent;
2599 while (!NILP (pwindow)) 2633 while (!NILP (pwindow))
2600 if (EQ (pwindow, root)) 2634 if (EQ (pwindow, root))
@@ -3079,7 +3113,7 @@ set_window_buffer (Lisp_Object window, Lisp_Object buffer, int run_hooks_p, int
3079 3113
3080DEFUN ("set-window-buffer", Fset_window_buffer, Sset_window_buffer, 2, 3, 0, 3114DEFUN ("set-window-buffer", Fset_window_buffer, Sset_window_buffer, 2, 3, 0,
3081 doc: /* Make WINDOW display BUFFER-OR-NAME as its contents. 3115 doc: /* Make WINDOW display BUFFER-OR-NAME as its contents.
3082WINDOW has to be a live window and defaults to the selected one. 3116WINDOW must be a live window and defaults to the selected one.
3083BUFFER-OR-NAME must be a buffer or the name of an existing buffer. 3117BUFFER-OR-NAME must be a buffer or the name of an existing buffer.
3084 3118
3085Optional third argument KEEP-MARGINS non-nil means that WINDOW's current 3119Optional third argument KEEP-MARGINS non-nil means that WINDOW's current
@@ -3096,7 +3130,7 @@ This function runs `window-scroll-functions' before running
3096 (register Lisp_Object window, Lisp_Object buffer_or_name, Lisp_Object keep_margins) 3130 (register Lisp_Object window, Lisp_Object buffer_or_name, Lisp_Object keep_margins)
3097{ 3131{
3098 register Lisp_Object tem, buffer; 3132 register Lisp_Object tem, buffer;
3099 register struct window *w = decode_window (window); 3133 register struct window *w = decode_live_window (window);
3100 3134
3101 XSETWINDOW (window, w); 3135 XSETWINDOW (window, w);
3102 buffer = Fget_buffer (buffer_or_name); 3136 buffer = Fget_buffer (buffer_or_name);
@@ -3318,6 +3352,7 @@ make_window (void)
3318 3352
3319DEFUN ("set-window-new-total", Fset_window_new_total, Sset_window_new_total, 2, 3, 0, 3353DEFUN ("set-window-new-total", Fset_window_new_total, Sset_window_new_total, 2, 3, 0,
3320 doc: /* Set new total size of WINDOW to SIZE. 3354 doc: /* Set new total size of WINDOW to SIZE.
3355WINDOW must be a valid window and defaults to the selected one.
3321Return SIZE. 3356Return SIZE.
3322 3357
3323Optional argument ADD non-nil means add SIZE to the new total size of 3358Optional argument ADD non-nil means add SIZE to the new total size of
@@ -3326,7 +3361,7 @@ WINDOW and return the sum.
3326Note: This function does not operate on any child windows of WINDOW. */) 3361Note: This function does not operate on any child windows of WINDOW. */)
3327 (Lisp_Object window, Lisp_Object size, Lisp_Object add) 3362 (Lisp_Object window, Lisp_Object size, Lisp_Object add)
3328{ 3363{
3329 struct window *w = decode_any_window (window); 3364 struct window *w = decode_valid_window (window);
3330 3365
3331 CHECK_NUMBER (size); 3366 CHECK_NUMBER (size);
3332 if (NILP (add)) 3367 if (NILP (add))
@@ -3339,12 +3374,13 @@ Note: This function does not operate on any child windows of WINDOW. */)
3339 3374
3340DEFUN ("set-window-new-normal", Fset_window_new_normal, Sset_window_new_normal, 1, 2, 0, 3375DEFUN ("set-window-new-normal", Fset_window_new_normal, Sset_window_new_normal, 1, 2, 0,
3341 doc: /* Set new normal size of WINDOW to SIZE. 3376 doc: /* Set new normal size of WINDOW to SIZE.
3377WINDOW must be a valid window and defaults to the selected one.
3342Return SIZE. 3378Return SIZE.
3343 3379
3344Note: This function does not operate on any child windows of WINDOW. */) 3380Note: This function does not operate on any child windows of WINDOW. */)
3345 (Lisp_Object window, Lisp_Object size) 3381 (Lisp_Object window, Lisp_Object size)
3346{ 3382{
3347 return WSET (decode_any_window (window), new_normal, size); 3383 return WSET (decode_valid_window (window), new_normal, size);
3348} 3384}
3349 3385
3350/* Return 1 if setting w->total_lines (w->total_cols if HORFLAG is 3386/* Return 1 if setting w->total_lines (w->total_cols if HORFLAG is
@@ -3838,8 +3874,6 @@ Signal an error when WINDOW is the only window on its frame. */)
3838 int before_sibling = 0; 3874 int before_sibling = 0;
3839 3875
3840 w = decode_any_window (window); 3876 w = decode_any_window (window);
3841 CHECK_LIVE_FRAME (w->frame);
3842
3843 XSETWINDOW (window, w); 3877 XSETWINDOW (window, w);
3844 if (NILP (w->buffer) 3878 if (NILP (w->buffer)
3845 && NILP (w->hchild) && NILP (w->vchild)) 3879 && NILP (w->hchild) && NILP (w->vchild))
@@ -5201,13 +5235,13 @@ and redisplay normally--don't erase and redraw the frame. */)
5201DEFUN ("window-text-height", Fwindow_text_height, Swindow_text_height, 5235DEFUN ("window-text-height", Fwindow_text_height, Swindow_text_height,
5202 0, 1, 0, 5236 0, 1, 0,
5203 doc: /* Return the height in lines of the text display area of WINDOW. 5237 doc: /* Return the height in lines of the text display area of WINDOW.
5204If WINDOW is omitted or nil, it defaults to the selected window. 5238WINDOW must be a live window and defaults to the selected one.
5205 5239
5206The returned height does not include the mode line, any header line, 5240The returned height does not include the mode line, any header line,
5207nor any partial-height lines at the bottom of the text area. */) 5241nor any partial-height lines at the bottom of the text area. */)
5208 (Lisp_Object window) 5242 (Lisp_Object window)
5209{ 5243{
5210 struct window *w = decode_window (window); 5244 struct window *w = decode_live_window (window);
5211 int pixel_height = window_box_height (w); 5245 int pixel_height = window_box_height (w);
5212 int line_height = pixel_height / FRAME_LINE_HEIGHT (XFRAME (w->frame)); 5246 int line_height = pixel_height / FRAME_LINE_HEIGHT (XFRAME (w->frame));
5213 return make_number (line_height); 5247 return make_number (line_height);
@@ -6034,14 +6068,15 @@ saved by this function. */)
6034DEFUN ("set-window-margins", Fset_window_margins, Sset_window_margins, 6068DEFUN ("set-window-margins", Fset_window_margins, Sset_window_margins,
6035 2, 3, 0, 6069 2, 3, 0,
6036 doc: /* Set width of marginal areas of window WINDOW. 6070 doc: /* Set width of marginal areas of window WINDOW.
6037If WINDOW is nil, set margins of the currently selected window. 6071WINDOW must be a live window and defaults to the selected one.
6072
6038Second arg LEFT-WIDTH specifies the number of character cells to 6073Second arg LEFT-WIDTH specifies the number of character cells to
6039reserve for the left marginal area. Optional third arg RIGHT-WIDTH 6074reserve for the left marginal area. Optional third arg RIGHT-WIDTH
6040does the same for the right marginal area. A nil width parameter 6075does the same for the right marginal area. A nil width parameter
6041means no margin. */) 6076means no margin. */)
6042 (Lisp_Object window, Lisp_Object left_width, Lisp_Object right_width) 6077 (Lisp_Object window, Lisp_Object left_width, Lisp_Object right_width)
6043{ 6078{
6044 struct window *w = decode_window (window); 6079 struct window *w = decode_live_window (window);
6045 6080
6046 /* Translate negative or zero widths to nil. 6081 /* Translate negative or zero widths to nil.
6047 Margins that are too wide have to be checked elsewhere. */ 6082 Margins that are too wide have to be checked elsewhere. */
@@ -6079,13 +6114,14 @@ means no margin. */)
6079DEFUN ("window-margins", Fwindow_margins, Swindow_margins, 6114DEFUN ("window-margins", Fwindow_margins, Swindow_margins,
6080 0, 1, 0, 6115 0, 1, 0,
6081 doc: /* Get width of marginal areas of window WINDOW. 6116 doc: /* Get width of marginal areas of window WINDOW.
6082If WINDOW is omitted or nil, it defaults to the selected window. 6117WINDOW must be a live window and defaults to the selected one.
6118
6083Value is a cons of the form (LEFT-WIDTH . RIGHT-WIDTH). 6119Value is a cons of the form (LEFT-WIDTH . RIGHT-WIDTH).
6084If a marginal area does not exist, its width will be returned 6120If a marginal area does not exist, its width will be returned
6085as nil. */) 6121as nil. */)
6086 (Lisp_Object window) 6122 (Lisp_Object window)
6087{ 6123{
6088 struct window *w = decode_window (window); 6124 struct window *w = decode_live_window (window);
6089 return Fcons (w->left_margin_cols, w->right_margin_cols); 6125 return Fcons (w->left_margin_cols, w->right_margin_cols);
6090} 6126}
6091 6127
@@ -6098,8 +6134,8 @@ as nil. */)
6098DEFUN ("set-window-fringes", Fset_window_fringes, Sset_window_fringes, 6134DEFUN ("set-window-fringes", Fset_window_fringes, Sset_window_fringes,
6099 2, 4, 0, 6135 2, 4, 0,
6100 doc: /* Set the fringe widths of window WINDOW. 6136 doc: /* Set the fringe widths of window WINDOW.
6101If WINDOW is nil, set the fringe widths of the currently selected 6137WINDOW must be a live window and defaults to the selected one.
6102window. 6138
6103Second arg LEFT-WIDTH specifies the number of pixels to reserve for 6139Second arg LEFT-WIDTH specifies the number of pixels to reserve for
6104the left fringe. Optional third arg RIGHT-WIDTH specifies the right 6140the left fringe. Optional third arg RIGHT-WIDTH specifies the right
6105fringe width. If a fringe width arg is nil, that means to use the 6141fringe width. If a fringe width arg is nil, that means to use the
@@ -6110,7 +6146,7 @@ outside of the display margins. By default, fringes are drawn between
6110display marginal areas and the text area. */) 6146display marginal areas and the text area. */)
6111 (Lisp_Object window, Lisp_Object left_width, Lisp_Object right_width, Lisp_Object outside_margins) 6147 (Lisp_Object window, Lisp_Object left_width, Lisp_Object right_width, Lisp_Object outside_margins)
6112{ 6148{
6113 struct window *w = decode_window (window); 6149 struct window *w = decode_live_window (window);
6114 int outside = !NILP (outside_margins); 6150 int outside = !NILP (outside_margins);
6115 6151
6116 if (!NILP (left_width)) 6152 if (!NILP (left_width))
@@ -6144,11 +6180,12 @@ display marginal areas and the text area. */)
6144DEFUN ("window-fringes", Fwindow_fringes, Swindow_fringes, 6180DEFUN ("window-fringes", Fwindow_fringes, Swindow_fringes,
6145 0, 1, 0, 6181 0, 1, 0,
6146 doc: /* Get width of fringes of window WINDOW. 6182 doc: /* Get width of fringes of window WINDOW.
6147If WINDOW is omitted or nil, it defaults to the selected window. 6183WINDOW must be a live window and defaults to the selected one.
6184
6148Value is a list of the form (LEFT-WIDTH RIGHT-WIDTH OUTSIDE-MARGINS). */) 6185Value is a list of the form (LEFT-WIDTH RIGHT-WIDTH OUTSIDE-MARGINS). */)
6149 (Lisp_Object window) 6186 (Lisp_Object window)
6150{ 6187{
6151 struct window *w = decode_window (window); 6188 struct window *w = decode_live_window (window);
6152 6189
6153 return Fcons (make_number (WINDOW_LEFT_FRINGE_WIDTH (w)), 6190 return Fcons (make_number (WINDOW_LEFT_FRINGE_WIDTH (w)),
6154 Fcons (make_number (WINDOW_RIGHT_FRINGE_WIDTH (w)), 6191 Fcons (make_number (WINDOW_RIGHT_FRINGE_WIDTH (w)),
@@ -6165,7 +6202,8 @@ Value is a list of the form (LEFT-WIDTH RIGHT-WIDTH OUTSIDE-MARGINS). */)
6165DEFUN ("set-window-scroll-bars", Fset_window_scroll_bars, 6202DEFUN ("set-window-scroll-bars", Fset_window_scroll_bars,
6166 Sset_window_scroll_bars, 2, 4, 0, 6203 Sset_window_scroll_bars, 2, 4, 0,
6167 doc: /* Set width and type of scroll bars of window WINDOW. 6204 doc: /* Set width and type of scroll bars of window WINDOW.
6168If window is nil, set scroll bars of the currently selected window. 6205WINDOW must be a live window and defaults to the selected one.
6206
6169Second parameter WIDTH specifies the pixel width for the scroll bar; 6207Second parameter WIDTH specifies the pixel width for the scroll bar;
6170this is automatically adjusted to a multiple of the frame column width. 6208this is automatically adjusted to a multiple of the frame column width.
6171Third parameter VERTICAL-TYPE specifies the type of the vertical scroll 6209Third parameter VERTICAL-TYPE specifies the type of the vertical scroll
@@ -6175,7 +6213,7 @@ If VERTICAL-TYPE is t, use the frame's scroll-bar type.
6175Fourth parameter HORIZONTAL-TYPE is currently unused. */) 6213Fourth parameter HORIZONTAL-TYPE is currently unused. */)
6176 (Lisp_Object window, Lisp_Object width, Lisp_Object vertical_type, Lisp_Object horizontal_type) 6214 (Lisp_Object window, Lisp_Object width, Lisp_Object vertical_type, Lisp_Object horizontal_type)
6177{ 6215{
6178 struct window *w = decode_window (window); 6216 struct window *w = decode_live_window (window);
6179 6217
6180 if (!NILP (width)) 6218 if (!NILP (width))
6181 { 6219 {
@@ -6213,13 +6251,14 @@ Fourth parameter HORIZONTAL-TYPE is currently unused. */)
6213DEFUN ("window-scroll-bars", Fwindow_scroll_bars, Swindow_scroll_bars, 6251DEFUN ("window-scroll-bars", Fwindow_scroll_bars, Swindow_scroll_bars,
6214 0, 1, 0, 6252 0, 1, 0,
6215 doc: /* Get width and type of scroll bars of window WINDOW. 6253 doc: /* Get width and type of scroll bars of window WINDOW.
6216If WINDOW is omitted or nil, it defaults to the selected window. 6254WINDOW must be a live window and defaults to the selected one.
6255
6217Value is a list of the form (WIDTH COLS VERTICAL-TYPE HORIZONTAL-TYPE). 6256Value is a list of the form (WIDTH COLS VERTICAL-TYPE HORIZONTAL-TYPE).
6218If WIDTH is nil or TYPE is t, the window is using the frame's corresponding 6257If WIDTH is nil or TYPE is t, the window is using the frame's corresponding
6219value. */) 6258value. */)
6220 (Lisp_Object window) 6259 (Lisp_Object window)
6221{ 6260{
6222 struct window *w = decode_window (window); 6261 struct window *w = decode_live_window (window);
6223 return Fcons (make_number ((WINDOW_CONFIG_SCROLL_BAR_WIDTH (w) 6262 return Fcons (make_number ((WINDOW_CONFIG_SCROLL_BAR_WIDTH (w)
6224 ? WINDOW_CONFIG_SCROLL_BAR_WIDTH (w) 6263 ? WINDOW_CONFIG_SCROLL_BAR_WIDTH (w)
6225 : WINDOW_SCROLL_BAR_AREA_WIDTH (w))), 6264 : WINDOW_SCROLL_BAR_AREA_WIDTH (w))),
@@ -6513,6 +6552,7 @@ syms_of_window (void)
6513 DEFSYM (Qwindowp, "windowp"); 6552 DEFSYM (Qwindowp, "windowp");
6514 DEFSYM (Qwindow_configuration_p, "window-configuration-p"); 6553 DEFSYM (Qwindow_configuration_p, "window-configuration-p");
6515 DEFSYM (Qwindow_live_p, "window-live-p"); 6554 DEFSYM (Qwindow_live_p, "window-live-p");
6555 DEFSYM (Qwindow_valid_p, "window-valid-p");
6516 DEFSYM (Qwindow_deletable_p, "window-deletable-p"); 6556 DEFSYM (Qwindow_deletable_p, "window-deletable-p");
6517 DEFSYM (Qdelete_window, "delete-window"); 6557 DEFSYM (Qdelete_window, "delete-window");
6518 DEFSYM (Qwindow_resize_root_window, "window--resize-root-window"); 6558 DEFSYM (Qwindow_resize_root_window, "window--resize-root-window");
@@ -6665,6 +6705,7 @@ respectively are not installed by `window-state-put'. */);
6665 defsubr (&Sminibuffer_window); 6705 defsubr (&Sminibuffer_window);
6666 defsubr (&Swindow_minibuffer_p); 6706 defsubr (&Swindow_minibuffer_p);
6667 defsubr (&Swindowp); 6707 defsubr (&Swindowp);
6708 defsubr (&Swindow_valid_p);
6668 defsubr (&Swindow_live_p); 6709 defsubr (&Swindow_live_p);
6669 defsubr (&Swindow_frame); 6710 defsubr (&Swindow_frame);
6670 defsubr (&Sframe_root_window); 6711 defsubr (&Sframe_root_window);
diff --git a/src/window.h b/src/window.h
index 3e6f4f82b0a..77b31dafd8b 100644
--- a/src/window.h
+++ b/src/window.h
@@ -885,8 +885,15 @@ extern void check_frame_size (struct frame *frame, int *rows, int *cols);
885 885
886struct glyph *get_phys_cursor_glyph (struct window *w); 886struct glyph *get_phys_cursor_glyph (struct window *w);
887 887
888/* Value is non-zero if WINDOW is a live window. */ 888/* Value is non-zero if WINDOW is a valid window. */
889#define WINDOW_VALID_P(WINDOW) \
890 (WINDOWP (WINDOW) \
891 && (!NILP (XWINDOW (WINDOW)->buffer) \
892 || !NILP (XWINDOW (WINDOW)->vchild) \
893 || !NILP (XWINDOW (WINDOW)->hchild)))
894
889 895
896/* Value is non-zero if WINDOW is a live window. */
890#define WINDOW_LIVE_P(WINDOW) \ 897#define WINDOW_LIVE_P(WINDOW) \
891 (WINDOWP (WINDOW) && !NILP (XWINDOW (WINDOW)->buffer)) 898 (WINDOWP (WINDOW) && !NILP (XWINDOW (WINDOW)->buffer))
892 899
@@ -895,6 +902,8 @@ struct glyph *get_phys_cursor_glyph (struct window *w);
895extern Lisp_Object Qwindowp, Qwindow_live_p; 902extern Lisp_Object Qwindowp, Qwindow_live_p;
896extern Lisp_Object Vwindow_list; 903extern Lisp_Object Vwindow_list;
897 904
905extern struct window *decode_valid_window (Lisp_Object);
906extern struct window *decode_live_window (Lisp_Object);
898extern int compare_window_configurations (Lisp_Object, Lisp_Object, int); 907extern int compare_window_configurations (Lisp_Object, Lisp_Object, int);
899extern void mark_window_cursors_off (struct window *); 908extern void mark_window_cursors_off (struct window *);
900extern int window_internal_height (struct window *); 909extern int window_internal_height (struct window *);