From b9e9df47f2886bb4b6b67aea8eeb0b015258a063 Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Fri, 2 Nov 2012 14:34:26 +0400 Subject: [PATCH] Window-related stuff cleanup here and there. * dispnew.c (Finternal_show_cursor, Finternal_show_cursor_p): Use decode_any_window. * fringe.c (Ffringe_bitmaps_at_pos): Likewise. * xdisp.c (Fformat_mode_line): Likewise. * font.c (Ffont_at): Use decode_live_window. * indent.c (Fcompute_motion, Fvertical_motion): Likewise. * window.c (decode_next_window_args): Likewise. (decode_any_window): Remove static. * window.h (decode_any_window): Add prototype. * lisp.h (CHECK_VALID_WINDOW, CHECK_LIVE_WINDOW): Move from here... * window.h: ...to here, redefine via WINDOW_VALID_P and WINDOW_LIVE_P, respectively. --- src/ChangeLog | 16 ++++++++++++++++ src/dispnew.c | 20 ++------------------ src/font.c | 6 +----- src/fringe.c | 6 ++---- src/indent.c | 15 +++------------ src/lisp.h | 14 -------------- src/window.c | 9 +++------ src/window.h | 9 +++++++++ src/xdisp.c | 8 +++----- 9 files changed, 39 insertions(+), 64 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index bcbc455dba..25cb1e76fa 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,19 @@ +2012-11-02 Dmitry Antipov + + Window-related stuff cleanup here and there. + * dispnew.c (Finternal_show_cursor, Finternal_show_cursor_p): + Use decode_any_window. + * fringe.c (Ffringe_bitmaps_at_pos): Likewise. + * xdisp.c (Fformat_mode_line): Likewise. + * font.c (Ffont_at): Use decode_live_window. + * indent.c (Fcompute_motion, Fvertical_motion): Likewise. + * window.c (decode_next_window_args): Likewise. + (decode_any_window): Remove static. + * window.h (decode_any_window): Add prototype. + * lisp.h (CHECK_VALID_WINDOW, CHECK_LIVE_WINDOW): Move from here... + * window.h: ...to here, redefine via WINDOW_VALID_P and WINDOW_LIVE_P, + respectively. + 2012-11-02 Dmitry Antipov Remove pad from struct input_event. diff --git a/src/dispnew.c b/src/dispnew.c index 9f0e22fcdc..e99387d2f6 100644 --- a/src/dispnew.c +++ b/src/dispnew.c @@ -6375,15 +6375,7 @@ don't show a cursor. */) /* Don't change cursor state while redisplaying. This could confuse output routines. */ if (!redisplaying_p) - { - if (NILP (window)) - window = selected_window; - else - CHECK_WINDOW (window); - - XWINDOW (window)->cursor_off_p = NILP (show); - } - + decode_any_window (window)->cursor_off_p = NILP (show); return Qnil; } @@ -6394,15 +6386,7 @@ DEFUN ("internal-show-cursor-p", Finternal_show_cursor_p, WINDOW nil or omitted means report on the selected window. */) (Lisp_Object window) { - struct window *w; - - if (NILP (window)) - window = selected_window; - else - CHECK_WINDOW (window); - - w = XWINDOW (window); - return w->cursor_off_p ? Qnil : Qt; + return decode_any_window (window)->cursor_off_p ? Qnil : Qt; } DEFUN ("last-nonminibuffer-frame", Flast_nonminibuf_frame, diff --git a/src/font.c b/src/font.c index e79ce5d80b..87932b0e44 100644 --- a/src/font.c +++ b/src/font.c @@ -4765,13 +4765,9 @@ Optional third arg STRING, if non-nil, is a string containing the target character at index specified by POSITION. */) (Lisp_Object position, Lisp_Object window, Lisp_Object string) { - struct window *w; + struct window *w = decode_live_window (window); ptrdiff_t pos; - if (NILP (window)) - window = selected_window; - CHECK_LIVE_WINDOW (window); - w = XWINDOW (window); if (NILP (string)) { if (XBUFFER (w->buffer) != current_buffer) diff --git a/src/fringe.c b/src/fringe.c index d788503e91..a126292e1f 100644 --- a/src/fringe.c +++ b/src/fringe.c @@ -1731,10 +1731,8 @@ Return nil if POS is not visible in WINDOW. */) struct glyph_row *row; ptrdiff_t textpos; - if (NILP (window)) - window = selected_window; - CHECK_WINDOW (window); - w = XWINDOW (window); + w = decode_any_window (window); + XSETWINDOW (window, w); if (!NILP (pos)) { diff --git a/src/indent.c b/src/indent.c index bbc944d251..eee96061e2 100644 --- a/src/indent.c +++ b/src/indent.c @@ -1764,11 +1764,7 @@ visible section of the buffer, and pass LINE and COL as TOPOS. */) else hscroll = tab_offset = 0; - if (NILP (window)) - window = Fselected_window (); - else - CHECK_LIVE_WINDOW (window); - w = XWINDOW (window); + w = decode_live_window (window); if (XINT (from) < BEGV || XINT (from) > ZV) args_out_of_range_3 (from, make_number (BEGV), make_number (ZV)); @@ -1790,8 +1786,7 @@ visible section of the buffer, and pass LINE and COL as TOPOS. */) 1)) : XINT (XCAR (topos))), (NILP (width) ? -1 : XINT (width)), - hscroll, tab_offset, - XWINDOW (window)); + hscroll, tab_offset, w); XSETFASTINT (bufpos, pos->bufpos); XSETINT (hpos, pos->hpos); @@ -1988,11 +1983,7 @@ whether or not it is currently displayed in some window. */) } CHECK_NUMBER (lines); - if (! NILP (window)) - CHECK_WINDOW (window); - else - window = selected_window; - w = XWINDOW (window); + w = decode_live_window (window); old_buffer = Qnil; GCPRO3 (old_buffer, old_charpos, old_bytepos); diff --git a/src/lisp.h b/src/lisp.h index 3ec188b67c..61671bdaf2 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -1791,20 +1791,6 @@ typedef struct { #define CHECK_WINDOW_CONFIGURATION(x) \ CHECK_TYPE (WINDOW_CONFIGURATIONP (x), Qwindow_configuration_p, x) -/* A window of any sort, leaf or interior, is "valid" if one of its - buffer, vchild, or hchild members is non-nil. */ -#define CHECK_VALID_WINDOW(x) \ - CHECK_TYPE (WINDOWP (x) \ - && (!NILP (XWINDOW (x)->buffer) \ - || !NILP (XWINDOW (x)->vchild) \ - || !NILP (XWINDOW (x)->hchild)), \ - Qwindow_valid_p, x) - -/* A window is "live" if and only if it shows a buffer. */ -#define CHECK_LIVE_WINDOW(x) \ - CHECK_TYPE (WINDOWP (x) && !NILP (XWINDOW (x)->buffer), \ - Qwindow_live_p, x) - #define CHECK_PROCESS(x) \ CHECK_TYPE (PROCESSP (x), Qprocessp, x) diff --git a/src/window.c b/src/window.c index dfcabda59b..8dbecf9c81 100644 --- a/src/window.c +++ b/src/window.c @@ -244,7 +244,7 @@ decode_live_window (register Lisp_Object window) return XWINDOW (window); } -static struct window * +struct window * decode_any_window (register Lisp_Object window) { struct window *w; @@ -2252,10 +2252,7 @@ candidate_window_p (Lisp_Object window, Lisp_Object owindow, Lisp_Object minibuf static void decode_next_window_args (Lisp_Object *window, Lisp_Object *minibuf, Lisp_Object *all_frames) { - if (NILP (*window)) - *window = selected_window; - else - CHECK_LIVE_WINDOW (*window); + struct window *w = decode_live_window (*window); /* MINIBUF nil may or may not include minibuffers. Decide if it does. */ @@ -2272,7 +2269,7 @@ decode_next_window_args (Lisp_Object *window, Lisp_Object *minibuf, Lisp_Object if (NILP (*all_frames)) *all_frames = (!EQ (*minibuf, Qlambda) - ? FRAME_MINIBUF_WINDOW (XFRAME (XWINDOW (*window)->frame)) + ? FRAME_MINIBUF_WINDOW (XFRAME (w->frame)) : Qnil); else if (EQ (*all_frames, Qvisible)) ; diff --git a/src/window.h b/src/window.h index 115b361194..2a12226c0a 100644 --- a/src/window.h +++ b/src/window.h @@ -970,17 +970,26 @@ struct glyph *get_phys_cursor_glyph (struct window *w); || !NILP (XWINDOW (WINDOW)->vchild) \ || !NILP (XWINDOW (WINDOW)->hchild))) +/* A window of any sort, leaf or interior, is "valid" if one + of its buffer, vchild, or hchild members is non-nil. */ +#define CHECK_VALID_WINDOW(WINDOW) \ + CHECK_TYPE (WINDOW_VALID_P (WINDOW), Qwindow_valid_p, WINDOW) /* Value is non-zero if WINDOW is a live window. */ #define WINDOW_LIVE_P(WINDOW) \ (WINDOWP (WINDOW) && !NILP (XWINDOW (WINDOW)->buffer)) +/* A window is "live" if and only if it shows a buffer. */ +#define CHECK_LIVE_WINDOW(WINDOW) \ + CHECK_TYPE (WINDOW_LIVE_P (WINDOW), Qwindow_live_p, WINDOW) + /* These used to be in lisp.h. */ extern Lisp_Object Qwindowp, Qwindow_live_p; extern Lisp_Object Vwindow_list; extern struct window *decode_live_window (Lisp_Object); +extern struct window *decode_any_window (Lisp_Object); extern bool compare_window_configurations (Lisp_Object, Lisp_Object, bool); extern void mark_window_cursors_off (struct window *); extern int window_internal_height (struct window *); diff --git a/src/xdisp.c b/src/xdisp.c index b3b08edcd0..b235f92edf 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -21018,10 +21018,8 @@ are the selected window and the WINDOW's buffer). */) Lisp_Object str; int string_start = 0; - if (NILP (window)) - window = selected_window; - CHECK_WINDOW (window); - w = XWINDOW (window); + w = decode_any_window (window); + XSETWINDOW (window, w); if (NILP (buffer)) buffer = w->buffer; @@ -21050,7 +21048,7 @@ are the selected window and the WINDOW's buffer). */) and set that to nil so that we don't alter the outer value. */ record_unwind_protect (unwind_format_mode_line, format_mode_line_unwind_data - (XFRAME (WINDOW_FRAME (XWINDOW (window))), + (XFRAME (WINDOW_FRAME (w)), old_buffer, selected_window, 1)); mode_line_proptrans_alist = Qnil; -- 2.20.1