return Qnil;
}
-
-/* Evaluate SEXPR and return the result, or nil if something went
+/* Call function FUNC with the rest of NARGS - 1 arguments
+ following. Return the result, or nil if something went
wrong. Prevent redisplay during the evaluation. */
-/* Call function ARGS[0] with arguments ARGS[1] to ARGS[NARGS - 1].
- Return the result, or nil if something went wrong. Prevent
- redisplay during the evaluation. */
-
Lisp_Object
-safe_call (ptrdiff_t nargs, Lisp_Object *args)
+safe_call (ptrdiff_t nargs, Lisp_Object func, ...)
{
Lisp_Object val;
val = Qnil;
else
{
+ va_list ap;
+ ptrdiff_t i;
ptrdiff_t count = SPECPDL_INDEX ();
struct gcpro gcpro1;
+ Lisp_Object *args = alloca (nargs * sizeof (Lisp_Object));
+
+ args[0] = func;
+ va_start (ap, func);
+ for (i = 1; i < nargs; i++)
+ args[i] = va_arg (ap, Lisp_Object);
+ va_end (ap);
GCPRO1 (args[0]);
gcpro1.nvars = nargs;
Lisp_Object
safe_call1 (Lisp_Object fn, Lisp_Object arg)
{
- Lisp_Object args[2];
- args[0] = fn;
- args[1] = arg;
- return safe_call (2, args);
+ return safe_call (2, fn, arg);
}
static Lisp_Object Qeval;
return safe_call1 (Qeval, sexpr);
}
-/* Call function FN with one argument ARG.
+/* Call function FN with two arguments ARG1 and ARG2.
Return the result, or nil if something went wrong. */
Lisp_Object
safe_call2 (Lisp_Object fn, Lisp_Object arg1, Lisp_Object arg2)
{
- Lisp_Object args[3];
- args[0] = fn;
- args[1] = arg1;
- args[2] = arg2;
- return safe_call (3, args);
+ return safe_call (3, fn, arg1, arg2);
}
frames when the fringes are turned off. But leave the dimensions
zero for tooltip frames, as these glyphs look ugly there and also
sabotage calculations of tooltip dimensions in x-show-tip. */
- if (!(FRAMEP (tip_frame) && it->f == XFRAME (tip_frame)))
+#ifdef HAVE_WINDOW_SYSTEM
+ if (!(FRAME_WINDOW_P (it->f)
+ && FRAMEP (tip_frame)
+ && it->f == XFRAME (tip_frame)))
+#endif
{
if (it->line_wrap == TRUNCATE)
{
/* Similarly to `with-selected-window', if the operation selects
a window on another frame, we must restore that frame's
selected window, and (for a tty) the top-frame. */
- ASET (vector, 8, target_frame->selected_window);
+ ASET (vector, 8, FVAR (target_frame, selected_window));
if (FRAME_TERMCAP_P (target_frame))
ASET (vector, 9, FRAME_TTY (target_frame)->top_frame);
}
format_mode_line_unwind_data
(f, current_buffer, selected_window, 0));
- Fselect_window (f->selected_window, Qt);
- set_buffer_internal_1 (XBUFFER (XWINDOW (f->selected_window)->buffer));
+ Fselect_window (FVAR (f, selected_window), Qt);
+ set_buffer_internal_1 (XBUFFER (XWINDOW (FVAR (f, selected_window))->buffer));
fmt = FRAME_ICONIFIED_P (f) ? Vicon_title_format : Vframe_title_format;
mode_line_target = MODE_LINE_TITLE;
title_start = MODE_LINE_NOPROP_LEN (0);
- init_iterator (&it, XWINDOW (f->selected_window), -1, -1,
+ init_iterator (&it, XWINDOW (FVAR (f, selected_window)), -1, -1,
NULL, DEFAULT_FACE_ID);
display_mode_element (&it, 0, -1, -1, fmt, Qnil, 0);
len = MODE_LINE_NOPROP_LEN (title_start);
already wasted too much time by walking through the list with
display_mode_element, then we might need to optimize at a
higher level than this.) */
- if (! STRINGP (f->name)
- || SBYTES (f->name) != len
- || memcmp (title, SDATA (f->name), len) != 0)
+ if (! STRINGP (FVAR (f, name))
+ || SBYTES (FVAR (f, name)) != len
+ || memcmp (title, SDATA (FVAR (f, name)), len) != 0)
x_implicitly_set_name (f, make_string (title, len), Qnil);
}
}
if (windows_or_buffers_changed
&& FRAME_NS_P (f))
ns_set_doc_edited (f, Fbuffer_modified_p
- (XWINDOW (f->selected_window)->buffer));
+ (XWINDOW (FVAR (f, selected_window))->buffer));
#endif
UNGCPRO;
}
#if defined (USE_GTK) || defined (HAVE_NS)
int do_update = FRAME_EXTERNAL_TOOL_BAR (f);
#else
- int do_update = WINDOWP (f->tool_bar_window)
- && WINDOW_TOTAL_LINES (XWINDOW (f->tool_bar_window)) > 0;
+ int do_update = WINDOWP (FVAR (f, tool_bar_window))
+ && WINDOW_TOTAL_LINES (XWINDOW (FVAR (f, tool_bar_window))) > 0;
#endif
if (do_update)
selected_frame = frame;
/* Build desired tool-bar items from keymaps. */
- new_tool_bar = tool_bar_items (Fcopy_sequence (f->tool_bar_items),
- &new_n_tool_bar);
+ new_tool_bar = tool_bar_items
+ (Fcopy_sequence (FVAR (f, tool_bar_items)), &new_n_tool_bar);
/* Redisplay the tool-bar if we changed it. */
if (new_n_tool_bar != f->n_tool_bar_items
- || NILP (Fequal (new_tool_bar, f->tool_bar_items)))
+ || NILP (Fequal (new_tool_bar, FVAR (f, tool_bar_items))))
{
/* Redisplay that happens asynchronously due to an expose event
may access f->tool_bar_items. Make sure we update both
variables within BLOCK_INPUT so no such event interrupts. */
BLOCK_INPUT;
- f->tool_bar_items = new_tool_bar;
+ FVAR (f, tool_bar_items) = new_tool_bar;
f->n_tool_bar_items = new_n_tool_bar;
w->update_mode_line = 1;
UNBLOCK_INPUT;
Otherwise, make a new string. */
/* The size of the string we might be able to reuse. */
- size = (STRINGP (f->desired_tool_bar_string)
- ? SCHARS (f->desired_tool_bar_string)
+ size = (STRINGP (FVAR (f, desired_tool_bar_string))
+ ? SCHARS (FVAR (f, desired_tool_bar_string))
: 0);
/* We need one space in the string for each image. */
size_needed = f->n_tool_bar_items;
/* Reuse f->desired_tool_bar_string, if possible. */
- if (size < size_needed || NILP (f->desired_tool_bar_string))
- f->desired_tool_bar_string = Fmake_string (make_number (size_needed),
- make_number (' '));
+ if (size < size_needed || NILP (FVAR (f, desired_tool_bar_string)))
+ FVAR (f, desired_tool_bar_string)
+ = Fmake_string (make_number (size_needed), make_number (' '));
else
{
props = list4 (Qdisplay, Qnil, Qmenu_item, Qnil);
Fremove_text_properties (make_number (0), make_number (size),
- props, f->desired_tool_bar_string);
+ props, FVAR (f, desired_tool_bar_string));
}
/* Put a `display' property on the string for the images to display,
is the index of the item in F's tool-bar item vector. */
for (i = 0; i < f->n_tool_bar_items; ++i)
{
-#define PROP(IDX) AREF (f->tool_bar_items, i * TOOL_BAR_ITEM_NSLOTS + (IDX))
+#define PROP(IDX) \
+ AREF (FVAR (f, tool_bar_items), i * TOOL_BAR_ITEM_NSLOTS + (IDX))
int enabled_p = !NILP (PROP (TOOL_BAR_ITEM_ENABLED_P));
int selected_p = !NILP (PROP (TOOL_BAR_ITEM_SELECTED_P));
string. The string can be longer than needed when we reuse a
previous string. */
if (i + 1 == f->n_tool_bar_items)
- end = SCHARS (f->desired_tool_bar_string);
+ end = SCHARS (FVAR (f, desired_tool_bar_string));
else
end = i + 1;
Fadd_text_properties (make_number (i), make_number (end),
- props, f->desired_tool_bar_string);
+ props, FVAR (f, desired_tool_bar_string));
#undef PROP
}
static int
tool_bar_lines_needed (struct frame *f, int *n_rows)
{
- struct window *w = XWINDOW (f->tool_bar_window);
+ struct window *w = XWINDOW (FVAR (f, tool_bar_window));
struct it it;
/* tool_bar_lines_needed is called from redisplay_tool_bar after building
the desired matrix, so use (unused) mode-line row as temporary row to
init_iterator (&it, w, -1, -1, temp_row, TOOL_BAR_FACE_ID);
it.first_visible_x = 0;
it.last_visible_x = FRAME_TOTAL_COLS (f) * FRAME_COLUMN_WIDTH (f);
- reseat_to_string (&it, NULL, f->desired_tool_bar_string, 0, 0, 0, -1);
+ reseat_to_string (&it, NULL, FVAR (f, desired_tool_bar_string), 0, 0, 0, -1);
it.paragraph_embedding = L2R;
while (!ITERATOR_AT_END_P (&it))
CHECK_FRAME (frame);
f = XFRAME (frame);
- if (WINDOWP (f->tool_bar_window)
- && (w = XWINDOW (f->tool_bar_window),
+ if (WINDOWP (FVAR (f, tool_bar_window))
+ && (w = XWINDOW (FVAR (f, tool_bar_window)),
WINDOW_TOTAL_LINES (w) > 0))
{
update_tool_bar (f, 1);
do anything. This means you must start with tool-bar-lines
non-zero to get the auto-sizing effect. Or in other words, you
can turn off tool-bars by specifying tool-bar-lines zero. */
- if (!WINDOWP (f->tool_bar_window)
- || (w = XWINDOW (f->tool_bar_window),
+ if (!WINDOWP (FVAR (f, tool_bar_window))
+ || (w = XWINDOW (FVAR (f, tool_bar_window)),
WINDOW_TOTAL_LINES (w) == 0))
return 0;
/* Build a string that represents the contents of the tool-bar. */
build_desired_tool_bar_string (f);
- reseat_to_string (&it, NULL, f->desired_tool_bar_string, 0, 0, 0, -1);
+ reseat_to_string (&it, NULL, FVAR (f, desired_tool_bar_string), 0, 0, 0, -1);
/* FIXME: This should be controlled by a user option. But it
doesn't make sense to have an R2L tool bar if the menu bar cannot
be drawn also R2L, and making the menu bar R2L is tricky due
/* This function can be called asynchronously, which means we must
exclude any possibility that Fget_text_property signals an
error. */
- charpos = min (SCHARS (f->current_tool_bar_string), glyph->charpos);
+ charpos = min (SCHARS (FVAR (f, current_tool_bar_string)), glyph->charpos);
charpos = max (0, charpos);
/* Get the text property `menu-item' at pos. The value of that
property is the start index of this item's properties in
F->tool_bar_items. */
prop = Fget_text_property (make_number (charpos),
- Qmenu_item, f->current_tool_bar_string);
+ Qmenu_item, FVAR (f, current_tool_bar_string));
if (INTEGERP (prop))
{
*prop_idx = XINT (prop);
int *hpos, int *vpos, int *prop_idx)
{
Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
- struct window *w = XWINDOW (f->tool_bar_window);
+ struct window *w = XWINDOW (FVAR (f, tool_bar_window));
int area;
/* Find the glyph under X/Y. */
return -1;
/* Is mouse on the highlighted item? */
- if (EQ (f->tool_bar_window, hlinfo->mouse_face_window)
+ if (EQ (FVAR (f, tool_bar_window), hlinfo->mouse_face_window)
&& *vpos >= hlinfo->mouse_face_beg_row
&& *vpos <= hlinfo->mouse_face_end_row
&& (*vpos > hlinfo->mouse_face_beg_row
int modifiers)
{
Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
- struct window *w = XWINDOW (f->tool_bar_window);
+ struct window *w = XWINDOW (FVAR (f, tool_bar_window));
int hpos, vpos, prop_idx;
struct glyph *glyph;
Lisp_Object enabled_p;
return;
/* If item is disabled, do nothing. */
- enabled_p = AREF (f->tool_bar_items, prop_idx + TOOL_BAR_ITEM_ENABLED_P);
+ enabled_p = AREF (FVAR (f, tool_bar_items), prop_idx + TOOL_BAR_ITEM_ENABLED_P);
if (NILP (enabled_p))
return;
show_mouse_face (hlinfo, DRAW_IMAGE_RAISED);
hlinfo->mouse_face_image_state = DRAW_IMAGE_RAISED;
- key = AREF (f->tool_bar_items, prop_idx + TOOL_BAR_ITEM_KEY);
+ key = AREF (FVAR (f, tool_bar_items), prop_idx + TOOL_BAR_ITEM_KEY);
XSETFRAME (frame, f);
event.kind = TOOL_BAR_EVENT;
static void
note_tool_bar_highlight (struct frame *f, int x, int y)
{
- Lisp_Object window = f->tool_bar_window;
+ Lisp_Object window = FVAR (f, tool_bar_window);
struct window *w = XWINDOW (window);
Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
draw = mouse_down_p ? DRAW_IMAGE_SUNKEN : DRAW_IMAGE_RAISED;
/* If tool-bar item is not enabled, don't highlight it. */
- enabled_p = AREF (f->tool_bar_items, prop_idx + TOOL_BAR_ITEM_ENABLED_P);
+ enabled_p = AREF (FVAR (f, tool_bar_items), prop_idx + TOOL_BAR_ITEM_ENABLED_P);
if (!NILP (enabled_p))
{
/* Compute the x-position of the glyph. In front and past the
XTread_socket does the rest. */
help_echo_object = help_echo_window = Qnil;
help_echo_pos = -1;
- help_echo_string = AREF (f->tool_bar_items, prop_idx + TOOL_BAR_ITEM_HELP);
+ help_echo_string = AREF (FVAR (f, tool_bar_items), prop_idx + TOOL_BAR_ITEM_HELP);
if (NILP (help_echo_string))
- help_echo_string = AREF (f->tool_bar_items, prop_idx + TOOL_BAR_ITEM_CAPTION);
+ help_echo_string = AREF (FVAR (f, tool_bar_items), prop_idx + TOOL_BAR_ITEM_CAPTION);
}
#endif /* HAVE_WINDOW_SYSTEM */
selected_frame = frame;
do {
- for (tail = XFRAME (frame)->param_alist; CONSP (tail); tail = XCDR (tail))
+ for (tail = FVAR (XFRAME (frame), param_alist);
+ CONSP (tail); tail = XCDR (tail))
if (CONSP (XCAR (tail))
&& (tem = XCAR (XCAR (tail)),
SYMBOLP (tem))
if (!f->already_hscrolled_p)
{
f->already_hscrolled_p = 1;
- if (hscroll_windows (f->root_window))
+ if (hscroll_windows (FVAR (f, root_window)))
goto retry;
}
STOP_POLLING;
/* Update the display. */
- set_window_update_flags (XWINDOW (f->root_window), 1);
+ set_window_update_flags (XWINDOW (FVAR (f, root_window)), 1);
pending |= update_frame (f, 0, 0);
f->updated_p = 1;
}
and selected_window to be temporarily out-of-sync but let's make
sure this stays contained. */
select_frame_for_redisplay (old_frame);
- eassert (EQ (XFRAME (selected_frame)->selected_window, selected_window));
+ eassert (EQ (FVAR (XFRAME (selected_frame), selected_window),
+ selected_window));
if (!pending)
{
struct frame *f = XFRAME (frame);
if (f->updated_p)
{
- mark_window_display_accurate (f->root_window, 1);
+ mark_window_display_accurate (FVAR (f, root_window), 1);
if (FRAME_TERMINAL (f)->frame_up_to_date_hook)
FRAME_TERMINAL (f)->frame_up_to_date_hook (f);
}
if (FRAME_EXTERNAL_TOOL_BAR (f))
redisplay_tool_bar (f);
#else
- if (WINDOWP (f->tool_bar_window)
+ if (WINDOWP (FVAR (f, tool_bar_window))
&& (FRAME_TOOL_BAR_LINES (f) > 0
|| !NILP (Vauto_resize_tool_bars))
&& redisplay_tool_bar (f))
(Lisp_Object row, Lisp_Object glyphs)
{
struct frame *sf = SELECTED_FRAME ();
- struct glyph_matrix *m = XWINDOW (sf->tool_bar_window)->current_matrix;
+ struct glyph_matrix *m = XWINDOW (FVAR (sf, tool_bar_window))->current_matrix;
EMACS_INT vpos;
CHECK_NUMBER (row);
/* Menu bar lines are displayed in the desired matrix of the
dummy window menu_bar_window. */
struct window *menu_w;
- eassert (WINDOWP (f->menu_bar_window));
- menu_w = XWINDOW (f->menu_bar_window);
+ eassert (WINDOWP (FVAR (f, menu_bar_window)));
+ menu_w = XWINDOW (FVAR (f, menu_bar_window));
init_iterator (&it, menu_w, -1, -1, menu_w->desired_matrix->rows,
MENU_FACE_ID);
it.first_visible_x = 0;
depth++;
- switch (SWITCH_ENUM_CAST (XTYPE (elt)))
+ switch (XTYPE (elt))
{
case Lisp_String:
{
case 'F':
/* %F displays the frame name. */
- if (!NILP (f->title))
- return SSDATA (f->title);
+ if (!NILP (FVAR (f, title)))
+ return SSDATA (FVAR (f, title));
if (f->explicit_name || ! FRAME_WINDOW_P (f))
- return SSDATA (f->name);
+ return SSDATA (FVAR (f, name));
return "Emacs";
case 'f':
}
/* Detect a nonselected window or nonselected frame. */
- else if (w != XWINDOW (f->selected_window)
+ else if (w != XWINDOW (FVAR (f, selected_window))
|| f != FRAME_X_DISPLAY_INFO (f)->x_highlight_frame)
{
*active_cursor = 0;
void
x_update_cursor (struct frame *f, int on_p)
{
- update_cursor_in_window_tree (XWINDOW (f->root_window), on_p);
+ update_cursor_in_window_tree (XWINDOW (FVAR (f, root_window)), on_p);
}
if (FRAME_WINDOW_P (f))
{
if (draw == DRAW_NORMAL_TEXT
- && !EQ (hlinfo->mouse_face_window, f->tool_bar_window))
+ && !EQ (hlinfo->mouse_face_window, FVAR (f, tool_bar_window)))
FRAME_RIF (f)->define_frame_cursor (f, FRAME_X_OUTPUT (f)->text_cursor);
else if (draw == DRAW_MOUSE_FACE)
FRAME_RIF (f)->define_frame_cursor (f, FRAME_X_OUTPUT (f)->hand_cursor);
#ifdef HAVE_WINDOW_SYSTEM
/* Handle tool-bar window differently since it doesn't display a
buffer. */
- if (EQ (window, f->tool_bar_window))
+ if (EQ (window, FVAR (f, tool_bar_window)))
{
note_tool_bar_highlight (f, x, y);
return;
}
TRACE ((stderr, "(%d, %d, %d, %d)\n", r.x, r.y, r.width, r.height));
- mouse_face_overwritten_p = expose_window_tree (XWINDOW (f->root_window), &r);
+ mouse_face_overwritten_p = expose_window_tree (XWINDOW (FVAR (f, root_window)), &r);
- if (WINDOWP (f->tool_bar_window))
+ if (WINDOWP (FVAR (f, tool_bar_window)))
mouse_face_overwritten_p
- |= expose_window (XWINDOW (f->tool_bar_window), &r);
+ |= expose_window (XWINDOW (FVAR (f, tool_bar_window)), &r);
#ifdef HAVE_X_WINDOWS
#ifndef MSDOS
#ifndef USE_X_TOOLKIT
- if (WINDOWP (f->menu_bar_window))
+ if (WINDOWP (FVAR (f, menu_bar_window)))
mouse_face_overwritten_p
- |= expose_window (XWINDOW (f->menu_bar_window), &r);
+ |= expose_window (XWINDOW (FVAR (f, menu_bar_window)), &r);
#endif /* not USE_X_TOOLKIT */
#endif
#endif
\(see `modify-frame-parameters'). */);
Vicon_title_format
= Vframe_title_format
- = listn (PURE, 3,
+ = listn (CONSTYPE_PURE, 3,
intern_c_string ("multiple-frames"),
build_pure_c_string ("%b"),
- listn (PURE, 4,
+ listn (CONSTYPE_PURE, 4,
empty_unibyte_string,
intern_c_string ("invocation-name"),
build_pure_c_string ("@"),