* frame.h (decode_live_frame, decode_any_frame): Add prototypes.
* frame.c (decode_live_frame, decode_any_frame): New functions.
(delete_frame, Fredirect_frame_focus, Fframe_parameters)
(Fframe_parameter, Fframe_char_height, Fframe_char_width)
(Fframe_pixel_height, Fframe_pixel_width, Ftool_bar_pixel_width)
(Fframe_pointer_visible_p): Use decode_any_frame.
(Fmake_frame_visible, Fmake_frame_invisible, Ficonify_frame)
(Fraise_frame, Flower_frame, Fmodify_frame_parameters)
(Fset_frame_height, Fset_frame_width): Use decode_live_frame.
(Fframe_focus): Likewise. Allow zero number of arguments.
Adjust docstring.
(frame_buffer_list, frame_buffer_predicate): Remove.
* lisp.h (frame_buffer_predicate): Remove prototype.
* buffer.c (Fother_buffer): Use decode_any_frame.
* xdisp.c (Ftool_bar_lines_needed): Likewise.
* xfaces.c (Fcolor_gray_p, Fcolor_supported_p): Likewise.
* font.c (Ffont_face_attributes, Ffont_family_list, Fopen_font)
(Fclose_font, Ffont_info): Use decode_live_frame.
* fontset.c (check_fontset_name): Likewise.
* terminal.c (Fframe_terminal): Likewise.
* w32fns.c (check_x_frame): Likewise.
* window.c (Fminibuffer_window, Fwindow_at)
(Fcurrent_window_configuration): Likewise.
(Frun_window_configuration_change_hook, Fwindow_resize_apply):
Likewise. Allow zero number of arguments. Adjust docstring.
* dispnew.c (Fredraw_frame): Likewise.
* xfaces.c (frame_or_selected_frame): Remove.
(Fx_list_fonts, Finternal_get_lisp_face_attribute, Fface_font)
(Finternal_lisp_face_equal_p, Finternal_lisp_face_empty_p)
(Fframe_face_alist): Use decode_live_frame.
* xfns.c (check_x_frame): Likewise.
+2012-11-06 Dmitry Antipov <dmantipov@yandex.ru>
+
+ Widely used frame validity and checking functions.
+ * frame.h (decode_live_frame, decode_any_frame): Add prototypes.
+ * frame.c (decode_live_frame, decode_any_frame): New functions.
+ (delete_frame, Fredirect_frame_focus, Fframe_parameters)
+ (Fframe_parameter, Fframe_char_height, Fframe_char_width)
+ (Fframe_pixel_height, Fframe_pixel_width, Ftool_bar_pixel_width)
+ (Fframe_pointer_visible_p): Use decode_any_frame.
+ (Fmake_frame_visible, Fmake_frame_invisible, Ficonify_frame)
+ (Fraise_frame, Flower_frame, Fmodify_frame_parameters)
+ (Fset_frame_height, Fset_frame_width): Use decode_live_frame.
+ (Fframe_focus): Likewise. Allow zero number of arguments.
+ Adjust docstring.
+ (frame_buffer_list, frame_buffer_predicate): Remove.
+ * lisp.h (frame_buffer_predicate): Remove prototype.
+ * buffer.c (Fother_buffer): Use decode_any_frame.
+ * xdisp.c (Ftool_bar_lines_needed): Likewise.
+ * xfaces.c (Fcolor_gray_p, Fcolor_supported_p): Likewise.
+ * font.c (Ffont_face_attributes, Ffont_family_list, Fopen_font)
+ (Fclose_font, Ffont_info): Use decode_live_frame.
+ * fontset.c (check_fontset_name): Likewise.
+ * terminal.c (Fframe_terminal): Likewise.
+ * w32fns.c (check_x_frame): Likewise.
+ * window.c (Fminibuffer_window, Fwindow_at)
+ (Fcurrent_window_configuration): Likewise.
+ (Frun_window_configuration_change_hook, Fwindow_resize_apply):
+ Likewise. Allow zero number of arguments. Adjust docstring.
+ * dispnew.c (Fredraw_frame): Likewise.
+ * xfaces.c (frame_or_selected_frame): Remove.
+ (Fx_list_fonts, Finternal_get_lisp_face_attribute, Fface_font)
+ (Finternal_lisp_face_equal_p, Finternal_lisp_face_empty_p)
+ (Fframe_face_alist): Use decode_live_frame.
+ * xfns.c (check_x_frame): Likewise.
+
2012-11-06 Dmitry Antipov <dmantipov@yandex.ru>
* window.c (quad): New function.
exists, return the buffer `*scratch*' (creating it if necessary). */)
(register Lisp_Object buffer, Lisp_Object visible_ok, Lisp_Object frame)
{
- Lisp_Object tail, buf, pred;
- Lisp_Object notsogood = Qnil;
+ struct frame *f = decode_any_frame (frame);
+ Lisp_Object tail = f->buffer_list, pred = f->buffer_predicate;
+ Lisp_Object buf, notsogood = Qnil;
- if (NILP (frame))
- frame = selected_frame;
-
- CHECK_FRAME (frame);
-
- pred = frame_buffer_predicate (frame);
/* Consider buffers that have been seen in the frame first. */
- tail = XFRAME (frame)->buffer_list;
for (; CONSP (tail); tail = XCDR (tail))
{
buf = XCAR (tail);
Redrawing Frames
**********************************************************************/
-DEFUN ("redraw-frame", Fredraw_frame, Sredraw_frame, 1, 1, 0,
- doc: /* Clear frame FRAME and output again what is supposed to appear on it. */)
+DEFUN ("redraw-frame", Fredraw_frame, Sredraw_frame, 0, 1, 0,
+ doc: /* Clear frame FRAME and output again what is supposed to appear on it.
+If FRAME is omitted or nil, the selected frame is used. */)
(Lisp_Object frame)
{
- struct frame *f;
-
- CHECK_LIVE_FRAME (frame);
- f = XFRAME (frame);
+ struct frame *f = decode_live_frame (frame);
/* Ignore redraw requests, if frame has no glyphs yet.
(Implementation note: It still has to be checked why we are
are to be displayed on. If omitted, the selected frame is used. */)
(Lisp_Object font, Lisp_Object frame)
{
- struct frame *f;
+ struct frame *f = decode_live_frame (frame);
Lisp_Object plist[10];
Lisp_Object val;
int n = 0;
- if (NILP (frame))
- frame = selected_frame;
- CHECK_LIVE_FRAME (frame);
- f = XFRAME (frame);
-
if (STRINGP (font))
{
int fontset = fs_query_fontset (font, 0);
DEFUN ("font-family-list", Ffont_family_list, Sfont_family_list, 0, 1, 0,
doc: /* List available font families on the current frame.
-Optional argument FRAME, if non-nil, specifies the target frame. */)
+If FRAME is omitted or nil, the selected frame is used. */)
(Lisp_Object frame)
{
- FRAME_PTR f;
+ struct frame *f = decode_live_frame (frame);
struct font_driver_list *driver_list;
- Lisp_Object list;
+ Lisp_Object list = Qnil;
+
+ XSETFRAME (frame, f);
- if (NILP (frame))
- frame = selected_frame;
- CHECK_LIVE_FRAME (frame);
- f = XFRAME (frame);
- list = Qnil;
for (driver_list = f->font_driver_list; driver_list;
driver_list = driver_list->next)
if (driver_list->driver->list_family)
(Lisp_Object font_entity, Lisp_Object size, Lisp_Object frame)
{
EMACS_INT isize;
+ struct frame *f = decode_live_frame (frame);
CHECK_FONT_ENTITY (font_entity);
- if (NILP (frame))
- frame = selected_frame;
- CHECK_LIVE_FRAME (frame);
if (NILP (size))
isize = XINT (AREF (font_entity, FONT_SIZE_INDEX));
{
CHECK_NUMBER_OR_FLOAT (size);
if (FLOATP (size))
- isize = POINT_TO_PIXEL (XFLOAT_DATA (size), XFRAME (frame)->resy);
+ isize = POINT_TO_PIXEL (XFLOAT_DATA (size), f->resy);
else
isize = XINT (size);
if (! (INT_MIN <= isize && isize <= INT_MAX))
if (isize == 0)
isize = 120;
}
- return font_open_entity (XFRAME (frame), font_entity, isize);
+ return font_open_entity (f, font_entity, isize);
}
DEFUN ("close-font", Fclose_font, Sclose_font, 1, 2, 0,
(Lisp_Object font_object, Lisp_Object frame)
{
CHECK_FONT_OBJECT (font_object);
- if (NILP (frame))
- frame = selected_frame;
- CHECK_LIVE_FRAME (frame);
- font_close_object (XFRAME (frame), font_object);
+ font_close_object (decode_live_frame (frame), font_object);
return Qnil;
}
If the named font is not yet loaded, return nil. */)
(Lisp_Object name, Lisp_Object frame)
{
- FRAME_PTR f;
+ struct frame *f;
struct font *font;
Lisp_Object info;
Lisp_Object font_object;
if (! FONTP (name))
CHECK_STRING (name);
- if (NILP (frame))
- frame = selected_frame;
- CHECK_LIVE_FRAME (frame);
- f = XFRAME (frame);
+ f = decode_live_frame (frame);
if (STRINGP (name))
{
check_fontset_name (Lisp_Object name, Lisp_Object *frame)
{
int id;
+ struct frame *f = decode_live_frame (*frame);
- if (NILP (*frame))
- *frame = selected_frame;
- CHECK_LIVE_FRAME (*frame);
+ XSETFRAME (*frame, f);
if (EQ (name, Qt))
return Vdefault_fontset;
if (NILP (name))
- {
- id = FRAME_FONTSET (XFRAME (*frame));
- }
+ id = FRAME_FONTSET (f);
else
{
CHECK_STRING (name);
f->minibuffer_window = val;
}
-\f
+struct frame *
+decode_live_frame (register Lisp_Object frame)
+{
+ if (NILP (frame))
+ frame = selected_frame;
+ CHECK_LIVE_FRAME (frame);
+ return XFRAME (frame);
+}
+
+struct frame *
+decode_any_frame (register Lisp_Object frame)
+{
+ if (NILP (frame))
+ frame = selected_frame;
+ CHECK_FRAME (frame);
+ return XFRAME (frame);
+}
+
static void
set_menu_bar_lines_1 (Lisp_Object window, int n)
{
Lisp_Object
delete_frame (Lisp_Object frame, Lisp_Object force)
{
- struct frame *f;
+ struct frame *f = decode_any_frame (frame);
struct frame *sf = SELECTED_FRAME ();
struct kboard *kb;
int minibuffer_selected, is_tooltip_frame;
- if (EQ (frame, Qnil))
- {
- f = sf;
- XSETFRAME (frame, f);
- }
- else
- {
- CHECK_FRAME (frame);
- f = XFRAME (frame);
- }
-
if (! FRAME_LIVE_P (f))
return Qnil;
if (NILP (XCDR (Vframe_list)) && !EQ (force, Qnoelisp))
error ("Attempt to delete the only frame");
+ XSETFRAME (frame, f);
+
/* Does this frame have a minibuffer, and is it the surrogate
minibuffer for any other frame? */
- if (FRAME_HAS_MINIBUF_P (XFRAME (frame)))
+ if (FRAME_HAS_MINIBUF_P (f))
{
Lisp_Object frames;
If omitted, FRAME defaults to the currently selected frame. */)
(Lisp_Object frame)
{
- if (NILP (frame))
- frame = selected_frame;
-
- CHECK_LIVE_FRAME (frame);
+ struct frame *f = decode_live_frame (frame);
/* I think this should be done with a hook. */
#ifdef HAVE_WINDOW_SYSTEM
- if (FRAME_WINDOW_P (XFRAME (frame)))
+ if (FRAME_WINDOW_P (f))
{
- FRAME_SAMPLE_VISIBILITY (XFRAME (frame));
- x_make_frame_visible (XFRAME (frame));
+ FRAME_SAMPLE_VISIBILITY (f);
+ x_make_frame_visible (f);
}
#endif
- make_frame_visible_1 (XFRAME (frame)->root_window);
+ make_frame_visible_1 (f->root_window);
/* Make menu bar update for the Buffers and Frames menus. */
windows_or_buffers_changed++;
+ XSETFRAME (frame, f);
return frame;
}
displayed in the terminal. */)
(Lisp_Object frame, Lisp_Object force)
{
- if (NILP (frame))
- frame = selected_frame;
+ struct frame *f = decode_live_frame (frame);
- CHECK_LIVE_FRAME (frame);
-
- if (NILP (force) && !other_visible_frames (XFRAME (frame)))
+ if (NILP (force) && !other_visible_frames (f))
error ("Attempt to make invisible the sole visible or iconified frame");
/* Don't allow minibuf_window to remain on a deleted frame. */
- if (EQ (XFRAME (frame)->minibuffer_window, minibuf_window))
+ if (EQ (f->minibuffer_window, minibuf_window))
{
struct frame *sf = XFRAME (selected_frame);
/* Use set_window_buffer instead of Fset_window_buffer (see
/* I think this should be done with a hook. */
#ifdef HAVE_WINDOW_SYSTEM
- if (FRAME_WINDOW_P (XFRAME (frame)))
- x_make_frame_invisible (XFRAME (frame));
+ if (FRAME_WINDOW_P (f))
+ x_make_frame_invisible (f);
#endif
/* Make menu bar update for the Buffers and Frames menus. */
If omitted, FRAME defaults to the currently selected frame. */)
(Lisp_Object frame)
{
- if (NILP (frame))
- frame = selected_frame;
-
- CHECK_LIVE_FRAME (frame);
-
-#if 0 /* This isn't logically necessary, and it can do GC. */
- /* Don't let the frame remain selected. */
- if (EQ (frame, selected_frame))
- Fhandle_switch_frame (next_frame (frame, Qt));
-#endif
+ struct frame *f = decode_live_frame (frame);
/* Don't allow minibuf_window to remain on an iconified frame. */
- if (EQ (XFRAME (frame)->minibuffer_window, minibuf_window))
+ if (EQ (f->minibuffer_window, minibuf_window))
{
struct frame *sf = XFRAME (selected_frame);
/* Use set_window_buffer instead of Fset_window_buffer (see
/* I think this should be done with a hook. */
#ifdef HAVE_WINDOW_SYSTEM
- if (FRAME_WINDOW_P (XFRAME (frame)))
- x_iconify_frame (XFRAME (frame));
+ if (FRAME_WINDOW_P (f))
+ x_iconify_frame (f);
#endif
/* Make menu bar update for the Buffers and Frames menus. */
doesn't support multiple overlapping frames, this function selects FRAME. */)
(Lisp_Object frame)
{
- struct frame *f;
- if (NILP (frame))
- frame = selected_frame;
+ struct frame *f = decode_live_frame (frame);
- CHECK_LIVE_FRAME (frame);
-
- f = XFRAME (frame);
+ XSETFRAME (frame, f);
if (FRAME_TERMCAP_P (f))
/* On a text terminal select FRAME. */
doesn't support multiple overlapping frames, this function does nothing. */)
(Lisp_Object frame)
{
- struct frame *f;
-
- if (NILP (frame))
- frame = selected_frame;
-
- CHECK_LIVE_FRAME (frame);
-
- f = XFRAME (frame);
+ struct frame *f = decode_live_frame (frame);
if (FRAME_TERMINAL (f)->frame_raise_lower_hook)
(*FRAME_TERMINAL (f)->frame_raise_lower_hook) (f, 0);
The redirection lasts until `redirect-frame-focus' is called to change it. */)
(Lisp_Object frame, Lisp_Object focus_frame)
{
- struct frame *f;
-
/* Note that we don't check for a live frame here. It's reasonable
to redirect the focus of a frame you're about to delete, if you
know what other frame should receive those keystrokes. */
- CHECK_FRAME (frame);
+ struct frame *f = decode_any_frame (frame);
if (! NILP (focus_frame))
CHECK_LIVE_FRAME (focus_frame);
- f = XFRAME (frame);
-
fset_focus_frame (f, focus_frame);
if (FRAME_TERMINAL (f)->frame_rehighlight_hook)
}
-DEFUN ("frame-focus", Fframe_focus, Sframe_focus, 1, 1, 0,
+DEFUN ("frame-focus", Fframe_focus, Sframe_focus, 0, 1, 0,
doc: /* Return the frame to which FRAME's keystrokes are currently being sent.
-This returns nil if FRAME's focus is not redirected.
+If FRAME is omitted or nil, the selected frame is used.
+Return nil if FRAME's focus is not redirected.
See `redirect-frame-focus'. */)
(Lisp_Object frame)
{
- CHECK_LIVE_FRAME (frame);
-
- return FRAME_FOCUS_FRAME (XFRAME (frame));
+ return FRAME_FOCUS_FRAME (decode_live_frame (frame));
}
}
#endif
-/* Return the buffer-predicate of the selected frame. */
-
-Lisp_Object
-frame_buffer_predicate (Lisp_Object frame)
-{
- return XFRAME (frame)->buffer_predicate;
-}
-
-/* Return the buffer-list of the selected frame. */
-
-static Lisp_Object
-frame_buffer_list (Lisp_Object frame)
-{
- return XFRAME (frame)->buffer_list;
-}
-
/* Discard BUFFER from the buffer-list and buried-buffer-list of each frame. */
void
doc: /* Return the parameters-alist of frame FRAME.
It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.
The meaningful PARMs depend on the kind of frame.
-If FRAME is omitted, return information on the currently selected frame. */)
+If FRAME is omitted or nil, return information on the currently selected frame. */)
(Lisp_Object frame)
{
Lisp_Object alist;
- FRAME_PTR f;
+ struct frame *f = decode_any_frame (frame);
int height, width;
struct gcpro gcpro1;
- if (NILP (frame))
- frame = selected_frame;
-
- CHECK_FRAME (frame);
- f = XFRAME (frame);
-
if (!FRAME_LIVE_P (f))
return Qnil;
: FRAME_MINIBUF_ONLY_P (f) ? Qonly
: FRAME_MINIBUF_WINDOW (f)));
store_in_alist (&alist, Qunsplittable, (FRAME_NO_SPLIT_P (f) ? Qt : Qnil));
- store_in_alist (&alist, Qbuffer_list, frame_buffer_list (frame));
- store_in_alist (&alist, Qburied_buffer_list,
- XFRAME (frame)->buried_buffer_list);
+ store_in_alist (&alist, Qbuffer_list, f->buffer_list);
+ store_in_alist (&alist, Qburied_buffer_list, f->buried_buffer_list);
/* I think this should be done with a hook. */
#ifdef HAVE_WINDOW_SYSTEM
If FRAME is nil, describe the currently selected frame. */)
(Lisp_Object frame, Lisp_Object parameter)
{
- struct frame *f;
- Lisp_Object value;
+ struct frame *f = decode_any_frame (frame);
+ Lisp_Object value = Qnil;
- if (NILP (frame))
- frame = selected_frame;
- else
- CHECK_FRAME (frame);
CHECK_SYMBOL (parameter);
- f = XFRAME (frame);
- value = Qnil;
+ XSETFRAME (frame, f);
if (FRAME_LIVE_P (f))
{
use is not recommended. Explicitly check for a frame-parameter instead. */)
(Lisp_Object frame, Lisp_Object alist)
{
- FRAME_PTR f;
+ struct frame *f = decode_live_frame (frame);
register Lisp_Object tail, prop, val;
- if (EQ (frame, Qnil))
- frame = selected_frame;
- CHECK_LIVE_FRAME (frame);
- f = XFRAME (frame);
-
/* I think this should be done with a hook. */
#ifdef HAVE_WINDOW_SYSTEM
if (FRAME_WINDOW_P (f))
DEFUN ("frame-char-height", Fframe_char_height, Sframe_char_height,
0, 1, 0,
doc: /* Height in pixels of a line in the font in frame FRAME.
-If FRAME is omitted, the selected frame is used.
+If FRAME is omitted or nil, the selected frame is used.
For a terminal frame, the value is always 1. */)
(Lisp_Object frame)
{
- struct frame *f;
-
- if (NILP (frame))
- frame = selected_frame;
- CHECK_FRAME (frame);
- f = XFRAME (frame);
-
#ifdef HAVE_WINDOW_SYSTEM
+ struct frame *f = decode_any_frame (frame);
+
if (FRAME_WINDOW_P (f))
return make_number (x_char_height (f));
else
DEFUN ("frame-char-width", Fframe_char_width, Sframe_char_width,
0, 1, 0,
doc: /* Width in pixels of characters in the font in frame FRAME.
-If FRAME is omitted, the selected frame is used.
+If FRAME is omitted or nil, the selected frame is used.
On a graphical screen, the width is the standard width of the default font.
For a terminal screen, the value is always 1. */)
(Lisp_Object frame)
{
- struct frame *f;
-
- if (NILP (frame))
- frame = selected_frame;
- CHECK_FRAME (frame);
- f = XFRAME (frame);
-
#ifdef HAVE_WINDOW_SYSTEM
+ struct frame *f = decode_any_frame (frame);
+
if (FRAME_WINDOW_P (f))
return make_number (x_char_width (f));
else
DEFUN ("frame-pixel-height", Fframe_pixel_height,
Sframe_pixel_height, 0, 1, 0,
doc: /* Return a FRAME's height in pixels.
-If FRAME is omitted, the selected frame is used. The exact value
+If FRAME is omitted or nil, the selected frame is used. The exact value
of the result depends on the window-system and toolkit in use:
In the Gtk+ version of Emacs, it includes only any window (including
to `frame-height'). */)
(Lisp_Object frame)
{
- struct frame *f;
-
- if (NILP (frame))
- frame = selected_frame;
- CHECK_FRAME (frame);
- f = XFRAME (frame);
+ struct frame *f = decode_any_frame (frame);
#ifdef HAVE_WINDOW_SYSTEM
if (FRAME_WINDOW_P (f))
Sframe_pixel_width, 0, 1, 0,
doc: /* Return FRAME's width in pixels.
For a terminal frame, the result really gives the width in characters.
-If FRAME is omitted, the selected frame is used. */)
+If FRAME is omitted or nil, the selected frame is used. */)
(Lisp_Object frame)
{
- struct frame *f;
-
- if (NILP (frame))
- frame = selected_frame;
- CHECK_FRAME (frame);
- f = XFRAME (frame);
+ struct frame *f = decode_any_frame (frame);
#ifdef HAVE_WINDOW_SYSTEM
if (FRAME_WINDOW_P (f))
Stool_bar_pixel_width, 0, 1, 0,
doc: /* Return width in pixels of FRAME's tool bar.
The result is greater than zero only when the tool bar is on the left
-or right side of FRAME. If FRAME is omitted, the selected frame is
-used. */)
+or right side of FRAME. If FRAME is omitted or nil, the selected frame
+is used. */)
(Lisp_Object frame)
{
- if (NILP (frame))
- frame = selected_frame;
- CHECK_FRAME (frame);
-
#ifdef FRAME_TOOLBAR_WIDTH
- if (FRAME_WINDOW_P (XFRAME (frame)))
- return make_number (FRAME_TOOLBAR_WIDTH (XFRAME (frame)));
+ struct frame *f = decode_any_frame (frame);
+
+ if (FRAME_WINDOW_P (f))
+ return make_number (FRAME_TOOLBAR_WIDTH (f));
#endif
return make_number (0);
}
but that the idea of the actual height of the frame should not be changed. */)
(Lisp_Object frame, Lisp_Object lines, Lisp_Object pretend)
{
- register struct frame *f;
+ register struct frame *f = decode_live_frame (frame);
CHECK_TYPE_RANGED_INTEGER (int, lines);
- if (NILP (frame))
- frame = selected_frame;
- CHECK_LIVE_FRAME (frame);
- f = XFRAME (frame);
/* I think this should be done with a hook. */
#ifdef HAVE_WINDOW_SYSTEM
but that the idea of the actual width of the frame should not be changed. */)
(Lisp_Object frame, Lisp_Object cols, Lisp_Object pretend)
{
- register struct frame *f;
+ register struct frame *f = decode_live_frame (frame);
+
CHECK_TYPE_RANGED_INTEGER (int, cols);
- if (NILP (frame))
- frame = selected_frame;
- CHECK_LIVE_FRAME (frame);
- f = XFRAME (frame);
/* I think this should be done with a hook. */
#ifdef HAVE_WINDOW_SYSTEM
selected frame. This is useful when `make-pointer-invisible' is set. */)
(Lisp_Object frame)
{
- if (NILP (frame))
- frame = selected_frame;
-
- CHECK_FRAME (frame);
-
- return (XFRAME (frame)->pointer_invisible ? Qnil : Qt);
+ return decode_any_frame (frame)->pointer_invisible ? Qnil : Qt;
}
\f
extern struct frame *last_nonminibuf_frame;
extern void set_menu_bar_lines (struct frame *, Lisp_Object, Lisp_Object);
+extern struct frame *decode_live_frame (Lisp_Object);
+extern struct frame *decode_any_frame (Lisp_Object);
extern struct frame *make_initial_frame (void);
extern struct frame *make_frame (int);
#ifdef HAVE_WINDOW_SYSTEM
#if HAVE_NS
extern Lisp_Object get_frame_param (struct frame *, Lisp_Object);
#endif
-extern Lisp_Object frame_buffer_predicate (Lisp_Object);
extern void frames_discard_buffer (Lisp_Object);
extern void syms_of_frame (void);
The terminal device is represented by its integer identifier. */)
(Lisp_Object frame)
{
- struct terminal *t;
-
- if (NILP (frame))
- frame = selected_frame;
-
- CHECK_LIVE_FRAME (frame);
-
- t = FRAME_TERMINAL (XFRAME (frame));
+ struct terminal *t = FRAME_TERMINAL (decode_live_frame (frame));
if (!t)
return Qnil;
FRAME_PTR
check_x_frame (Lisp_Object frame)
{
- FRAME_PTR f;
+ struct frame *f = decode_live_frame (frame);
- if (NILP (frame))
- frame = selected_frame;
- CHECK_LIVE_FRAME (frame);
- f = XFRAME (frame);
if (! FRAME_W32_P (f))
error ("Non-W32 frame used");
return f;
If FRAME is omitted or nil, it defaults to the selected frame. */)
(Lisp_Object frame)
{
- if (NILP (frame))
- frame = selected_frame;
- CHECK_LIVE_FRAME (frame);
- return FRAME_MINIBUF_WINDOW (XFRAME (frame));
+ return FRAME_MINIBUF_WINDOW (decode_live_frame (frame));
}
DEFUN ("window-minibuffer-p", Fwindow_minibuffer_p,
column 0. */)
(Lisp_Object x, Lisp_Object y, Lisp_Object frame)
{
- struct frame *f;
-
- if (NILP (frame))
- frame = selected_frame;
- CHECK_LIVE_FRAME (frame);
- f = XFRAME (frame);
+ struct frame *f = decode_live_frame (frame);
/* Check that arguments are integers or floats. */
CHECK_NUMBER_OR_FLOAT (x);
}
DEFUN ("run-window-configuration-change-hook", Frun_window_configuration_change_hook,
- Srun_window_configuration_change_hook, 1, 1, 0,
- doc: /* Run `window-configuration-change-hook' for FRAME. */)
+ Srun_window_configuration_change_hook, 0, 1, 0,
+ doc: /* Run `window-configuration-change-hook' for FRAME.
+If FRAME is omitted or nil, it defaults to the selected frame. */)
(Lisp_Object frame)
{
- CHECK_LIVE_FRAME (frame);
- run_window_configuration_change_hook (XFRAME (frame));
+ run_window_configuration_change_hook (decode_live_frame (frame));
return Qnil;
}
}
-DEFUN ("window-resize-apply", Fwindow_resize_apply, Swindow_resize_apply, 1, 2, 0,
+DEFUN ("window-resize-apply", Fwindow_resize_apply, Swindow_resize_apply, 0, 2, 0,
doc: /* Apply requested size values for window-tree of FRAME.
-Optional argument HORIZONTAL omitted or nil means apply requested height
-values. HORIZONTAL non-nil means apply requested width values.
+If FRAME is omitted or nil, it defaults to the selected frame.
+
+Optional argument HORIZONTAL omitted or nil means apply requested
+height values. HORIZONTAL non-nil means apply requested width values.
This function checks whether the requested values sum up to a valid
window layout, recursively assigns the new sizes of all child windows
be applied on the Elisp level. */)
(Lisp_Object frame, Lisp_Object horizontal)
{
- struct frame *f;
- struct window *r;
+ struct frame *f = decode_live_frame (frame);
+ struct window *r = XWINDOW (FRAME_ROOT_WINDOW (f));
int horflag = !NILP (horizontal);
- if (NILP (frame))
- frame = selected_frame;
- CHECK_LIVE_FRAME (frame);
-
- f = XFRAME (frame);
- r = XWINDOW (FRAME_ROOT_WINDOW (f));
-
if (!window_resize_check (r, horflag)
|| ! EQ (r->new_total,
(horflag ? r->total_cols : r->total_lines)))
register int n_windows;
register struct save_window_data *data;
register int i;
- FRAME_PTR f;
-
- if (NILP (frame))
- frame = selected_frame;
- CHECK_LIVE_FRAME (frame);
- f = XFRAME (frame);
+ struct frame *f = decode_live_frame (frame);
n_windows = count_windows (XWINDOW (FRAME_ROOT_WINDOW (f)));
data = ALLOCATE_PSEUDOVECTOR (struct save_window_data, frame_cols,
DEFUN ("tool-bar-lines-needed", Ftool_bar_lines_needed, Stool_bar_lines_needed,
0, 1, 0,
- doc: /* Return the number of lines occupied by the tool bar of FRAME. */)
+ doc: /* Return the number of lines occupied by the tool bar of FRAME.
+If FRAME is nil or omitted, use the selected frame. */)
(Lisp_Object frame)
{
- struct frame *f;
+ struct frame *f = decode_any_frame (frame);
struct window *w;
int nlines = 0;
- if (NILP (frame))
- frame = selected_frame;
- else
- CHECK_FRAME (frame);
- f = XFRAME (frame);
-
if (WINDOWP (f->tool_bar_window)
&& (w = XWINDOW (f->tool_bar_window),
WINDOW_TOTAL_LINES (w) > 0))
}
#endif /* HAVE_NS */
-/* If FRAME is nil, return a pointer to the selected frame.
- Otherwise, check that FRAME is a live frame, and return a pointer
- to it. NPARAM is the parameter number of FRAME, for
- CHECK_LIVE_FRAME. This is here because it's a frequent pattern in
- Lisp function definitions. */
-
-static struct frame *
-frame_or_selected_frame (Lisp_Object frame, int nparam)
-{
- if (NILP (frame))
- frame = selected_frame;
-
- CHECK_LIVE_FRAME (frame);
- return XFRAME (frame);
-}
-
-\f
/***********************************************************************
Frames and faces
***********************************************************************/
If FRAME is nil or omitted, use the selected frame. */)
(Lisp_Object color, Lisp_Object frame)
{
- struct frame *f;
-
CHECK_STRING (color);
- if (NILP (frame))
- frame = selected_frame;
- else
- CHECK_FRAME (frame);
- f = XFRAME (frame);
- return face_color_gray_p (f, SSDATA (color)) ? Qt : Qnil;
+ return (face_color_gray_p (decode_any_frame (frame), SSDATA (color))
+ ? Qt : Qnil);
}
COLOR must be a valid color name. */)
(Lisp_Object color, Lisp_Object frame, Lisp_Object background_p)
{
- struct frame *f;
-
CHECK_STRING (color);
- if (NILP (frame))
- frame = selected_frame;
- else
- CHECK_FRAME (frame);
- f = XFRAME (frame);
- if (face_color_supported_p (f, SSDATA (color), !NILP (background_p)))
- return Qt;
- return Qnil;
+ return (face_color_supported_p (decode_any_frame (frame),
+ SSDATA (color), !NILP (background_p))
+ ? Qt : Qnil);
}
/* We can't simply call check_x_frame because this function may be
called before any frame is created. */
- if (NILP (frame))
- frame = selected_frame;
- f = frame_or_selected_frame (frame, 2);
+ f = decode_live_frame (frame);
if (! FRAME_WINDOW_P (f))
{
/* Perhaps we have not yet created any frame. */
frame = Qnil;
face = Qnil;
}
+ else
+ XSETFRAME (frame, f);
/* Determine the width standard for comparison with the fonts we find. */
frames). If FRAME is omitted or nil, use the selected frame. */)
(Lisp_Object symbol, Lisp_Object keyword, Lisp_Object frame)
{
- Lisp_Object lface, value = Qnil;
+ struct frame *f = EQ (frame, Qt) ? NULL : decode_live_frame (frame);
+ Lisp_Object lface = lface_from_face_name (f, symbol, 1), value = Qnil;
CHECK_SYMBOL (symbol);
CHECK_SYMBOL (keyword);
- if (EQ (frame, Qt))
- lface = lface_from_face_name (NULL, symbol, 1);
- else
- {
- if (NILP (frame))
- frame = selected_frame;
- CHECK_LIVE_FRAME (frame);
- lface = lface_from_face_name (XFRAME (frame), symbol, 1);
- }
-
if (EQ (keyword, QCfamily))
value = LFACE_FAMILY (lface);
else if (EQ (keyword, QCfoundry))
}
else
{
- struct frame *f = frame_or_selected_frame (frame, 1);
+ struct frame *f = decode_live_frame (frame);
int face_id = lookup_named_face (f, face, 1);
struct face *fface = FACE_FROM_ID (f, face_id);
struct frame *f;
Lisp_Object lface1, lface2;
- if (EQ (frame, Qt))
- f = NULL;
- else
- /* Don't use check_x_frame here because this function is called
- before X frames exist. At that time, if FRAME is nil,
- selected_frame will be used which is the frame dumped with
- Emacs. That frame is not an X frame. */
- f = frame_or_selected_frame (frame, 2);
+ /* Don't use check_x_frame here because this function is called
+ before X frames exist. At that time, if FRAME is nil,
+ selected_frame will be used which is the frame dumped with
+ Emacs. That frame is not an X frame. */
+ f = EQ (frame, Qt) ? NULL : decode_live_frame (frame);
lface1 = lface_from_face_name (f, face1, 1);
lface2 = lface_from_face_name (f, face2, 1);
If FRAME is omitted or nil, use the selected frame. */)
(Lisp_Object face, Lisp_Object frame)
{
- struct frame *f;
- Lisp_Object lface;
+ struct frame *f = EQ (frame, Qt) ? NULL : decode_live_frame (frame);
+ Lisp_Object lface = lface_from_face_name (f, face, 1);
int i;
- if (NILP (frame))
- frame = selected_frame;
- CHECK_LIVE_FRAME (frame);
- f = XFRAME (frame);
-
- if (EQ (frame, Qt))
- lface = lface_from_face_name (NULL, face, 1);
- else
- lface = lface_from_face_name (f, face, 1);
-
for (i = 1; i < LFACE_VECTOR_SIZE; ++i)
if (!UNSPECIFIEDP (AREF (lface, i)))
break;
For internal use only. */)
(Lisp_Object frame)
{
- struct frame *f = frame_or_selected_frame (frame, 0);
- return f->face_alist;
+ return decode_live_frame (frame)->face_alist;
}
If FRAME is unspecified or nil, the current frame is used. */)
(Lisp_Object color1, Lisp_Object color2, Lisp_Object frame)
{
- struct frame *f;
+ struct frame *f = decode_live_frame (frame);
XColor cdef1, cdef2;
- if (NILP (frame))
- frame = selected_frame;
- CHECK_LIVE_FRAME (frame);
- f = XFRAME (frame);
-
if (!(CONSP (color1) && parse_rgb_list (color1, &cdef1))
&& !(STRINGP (color1) && defined_color (f, SSDATA (color1), &cdef1, 0)))
signal_error ("Invalid color", color1);
FRAME_PTR
check_x_frame (Lisp_Object frame)
{
- FRAME_PTR f;
+ struct frame *f = decode_live_frame (frame);
- if (NILP (frame))
- frame = selected_frame;
- CHECK_LIVE_FRAME (frame);
- f = XFRAME (frame);
if (! FRAME_X_P (f))
error ("Non-X frame used");
return f;