Simplify redefinition of 'abort' (Bug#12316).
[bpt/emacs.git] / src / xterm.c
index ea74c2c..047b556 100644 (file)
@@ -50,7 +50,6 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include "systime.h"
 
 #include <fcntl.h>
-#include <ctype.h>
 #include <errno.h>
 #include <setjmp.h>
 #include <sys/stat.h>
@@ -166,13 +165,6 @@ struct x_display_info *x_display_list;
 
 Lisp_Object x_display_name_list;
 
-/* Frame being updated by update_frame.  This is declared in term.c.
-   This is set by update_begin and looked at by all the XT functions.
-   It is zero while not inside an update.  In that case, the XT
-   functions assume that `selected_frame' is the frame to apply to.  */
-
-extern struct frame *updating_frame;
-
 /* This is a frame waiting to be auto-raised, within XTread_socket.  */
 
 static struct frame *pending_autoraise_frame;
@@ -628,7 +620,7 @@ x_draw_vertical_window_border (struct window *w, int x, int y0, int y1)
 static void
 x_update_window_end (struct window *w, int cursor_on_p, int mouse_face_overwritten_p)
 {
-  Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (XFRAME (WVAR (w, frame)));
+  Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (XFRAME (w->frame));
 
   if (!w->pseudo_window_p)
     {
@@ -728,7 +720,7 @@ x_after_update_window_line (struct glyph_row *desired_row)
      overhead is very small.  */
   if (windows_or_buffers_changed
       && desired_row->full_width_p
-      && (f = XFRAME (WVAR (w, frame)),
+      && (f = XFRAME (w->frame),
          width = FRAME_INTERNAL_BORDER_WIDTH (f),
          width != 0)
       && (height = desired_row->visible_height,
@@ -1475,7 +1467,7 @@ x_frame_of_widget (Widget widget)
        && f->output_data.x->widget == widget)
       return f;
 
-  abort ();
+  emacs_abort ();
 }
 
 /* Allocate a color which is lighter or darker than *PIXEL by FACTOR
@@ -2704,7 +2696,7 @@ x_draw_underwave (struct glyph_string *s)
     y2 += dy;
 
   if (INT_MAX - dx < xmax)
-    abort ();
+    emacs_abort ();
 
   while (x1 <= xmax)
     {
@@ -2813,7 +2805,7 @@ x_draw_glyph_string (struct glyph_string *s)
       break;
 
     default:
-      abort ();
+      emacs_abort ();
     }
 
   if (!s->for_overlaps)
@@ -3013,7 +3005,7 @@ x_shift_glyphs_for_insert (struct frame *f, int x, int y, int width, int height,
 static void
 x_delete_glyphs (struct frame *f, register int n)
 {
-  abort ();
+  emacs_abort ();
 }
 
 
@@ -3286,7 +3278,7 @@ XTset_terminal_window (struct frame *f, int n)
 static void
 x_ins_del_lines (struct frame *f, int vpos, int n)
 {
-  abort ();
+  emacs_abort ();
 }
 
 
@@ -3295,7 +3287,7 @@ x_ins_del_lines (struct frame *f, int vpos, int n)
 static void
 x_scroll_run (struct window *w, struct run *run)
 {
-  struct frame *f = XFRAME (WVAR (w, frame));
+  struct frame *f = XFRAME (w->frame);
   int x, y, width, height, from_y, to_y, bottom_y;
 
   /* Get frame-relative bounding box of the text display area of W,
@@ -3585,7 +3577,7 @@ x_frame_rehighlight (struct x_display_info *dpyinfo)
           : dpyinfo->x_focus_frame);
       if (! FRAME_LIVE_P (dpyinfo->x_highlight_frame))
        {
-         FSET (dpyinfo->x_focus_frame, focus_frame, Qnil);
+         fset_focus_frame (dpyinfo->x_focus_frame, Qnil);
          dpyinfo->x_highlight_frame = dpyinfo->x_focus_frame;
        }
     }
@@ -4123,7 +4115,7 @@ x_window_to_scroll_bar (Display *display, Window window_id)
       frame = XCAR (tail);
       /* All elements of Vframe_list should be frames.  */
       if (! FRAMEP (frame))
-       abort ();
+       emacs_abort ();
 
       if (! FRAME_X_P (XFRAME (frame)))
         continue;
@@ -4244,9 +4236,9 @@ xt_action_hook (Widget widget, XtPointer client_data, String action_name,
                               scroll_bar_end_scroll, 0, 0);
       w = XWINDOW (window_being_scrolled);
 
-      if (!NILP (XSCROLL_BAR (WVAR (w, vertical_scroll_bar))->dragging))
+      if (!NILP (XSCROLL_BAR (w->vertical_scroll_bar)->dragging))
        {
-         XSCROLL_BAR (WVAR (w, vertical_scroll_bar))->dragging = Qnil;
+         XSCROLL_BAR (w->vertical_scroll_bar)->dragging = Qnil;
          /* The thumb size is incorrect while dragging: fix it.  */
          set_vertical_scroll_bar (w);
        }
@@ -4277,7 +4269,7 @@ x_send_scroll_bar_event (Lisp_Object window, int part, int portion, int whole)
   XEvent event;
   XClientMessageEvent *ev = (XClientMessageEvent *) &event;
   struct window *w = XWINDOW (window);
-  struct frame *f = XFRAME (WVAR (w, frame));
+  struct frame *f = XFRAME (w->frame);
   ptrdiff_t i;
 
   BLOCK_INPUT;
@@ -4353,7 +4345,7 @@ x_scroll_bar_to_input_event (XEvent *event, struct input_event *ievent)
   ievent->timestamp = CurrentTime;
 #else
   ievent->timestamp =
-    XtLastTimestampProcessed (FRAME_X_DISPLAY (XFRAME (WVAR (w, frame))));
+    XtLastTimestampProcessed (FRAME_X_DISPLAY (XFRAME (w->frame)));
 #endif
   ievent->part = ev->data.l[1];
   ievent->code = ev->data.l[2];
@@ -4954,7 +4946,7 @@ x_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar, int portion, int positio
 static struct scroll_bar *
 x_scroll_bar_create (struct window *w, int top, int left, int width, int height)
 {
-  struct frame *f = XFRAME (WVAR (w, frame));
+  struct frame *f = XFRAME (w->frame);
   struct scroll_bar *bar
     = ALLOCATE_PSEUDOVECTOR (struct scroll_bar, x_window, PVEC_OTHER);
   Lisp_Object barobj;
@@ -5019,7 +5011,7 @@ x_scroll_bar_create (struct window *w, int top, int left, int width, int height)
   bar->next = FRAME_SCROLL_BARS (f);
   bar->prev = Qnil;
   XSETVECTOR (barobj, bar);
-  FSET (f, scroll_bars, barobj);
+  fset_scroll_bars (f, barobj);
   if (!NILP (bar->next))
     XSETVECTOR (XSCROLL_BAR (bar->next)->prev, bar);
 
@@ -5182,7 +5174,7 @@ x_scroll_bar_remove (struct scroll_bar *bar)
 #endif
 
   /* Dissociate this scroll bar from its window.  */
-  WVAR (XWINDOW (bar->window), vertical_scroll_bar) = Qnil;
+  wset_vertical_scroll_bar (XWINDOW (bar->window), Qnil);
 
   UNBLOCK_INPUT;
 }
@@ -5196,7 +5188,8 @@ x_scroll_bar_remove (struct scroll_bar *bar)
 static void
 XTset_vertical_scroll_bar (struct window *w, int portion, int whole, int position)
 {
-  struct frame *f = XFRAME (WVAR (w, frame));
+  struct frame *f = XFRAME (w->frame);
+  Lisp_Object barobj;
   struct scroll_bar *bar;
   int top, height, left, sb_left, width, sb_width;
   int window_y, window_height;
@@ -5247,7 +5240,7 @@ XTset_vertical_scroll_bar (struct window *w, int portion, int whole, int positio
 #endif
 
   /* Does the scroll bar exist yet?  */
-  if (NILP (WVAR (w, vertical_scroll_bar)))
+  if (NILP (w->vertical_scroll_bar))
     {
       if (width > 0 && height > 0)
        {
@@ -5270,7 +5263,7 @@ XTset_vertical_scroll_bar (struct window *w, int portion, int whole, int positio
       /* It may just need to be moved and resized.  */
       unsigned int mask = 0;
 
-      bar = XSCROLL_BAR (WVAR (w, vertical_scroll_bar));
+      bar = XSCROLL_BAR (w->vertical_scroll_bar);
 
       BLOCK_INPUT;
 
@@ -5394,7 +5387,8 @@ XTset_vertical_scroll_bar (struct window *w, int portion, int whole, int positio
     }
 #endif /* not USE_TOOLKIT_SCROLL_BARS */
 
-  XSETVECTOR (WVAR (w, vertical_scroll_bar), bar);
+  XSETVECTOR (barobj, bar);
+  wset_vertical_scroll_bar (w, barobj);
 }
 
 
@@ -5418,12 +5412,12 @@ XTcondemn_scroll_bars (FRAME_PTR frame)
     {
       Lisp_Object bar;
       bar = FRAME_SCROLL_BARS (frame);
-      FSET (frame, scroll_bars, XSCROLL_BAR (bar)->next);
+      fset_scroll_bars (frame, XSCROLL_BAR (bar)->next);
       XSCROLL_BAR (bar)->next = FRAME_CONDEMNED_SCROLL_BARS (frame);
       XSCROLL_BAR (bar)->prev = Qnil;
       if (! NILP (FRAME_CONDEMNED_SCROLL_BARS (frame)))
        XSCROLL_BAR (FRAME_CONDEMNED_SCROLL_BARS (frame))->prev = bar;
-      FSET (frame, condemned_scroll_bars, bar);
+      fset_condemned_scroll_bars (frame, bar);
     }
 }
 
@@ -5439,10 +5433,10 @@ XTredeem_scroll_bar (struct window *window)
   Lisp_Object barobj;
 
   /* We can't redeem this window's scroll bar if it doesn't have one.  */
-  if (NILP (WVAR (window, vertical_scroll_bar)))
-    abort ();
+  if (NILP (window->vertical_scroll_bar))
+    emacs_abort ();
 
-  bar = XSCROLL_BAR (WVAR (window, vertical_scroll_bar));
+  bar = XSCROLL_BAR (window->vertical_scroll_bar);
 
   /* Unlink it from the condemned list.  */
   f = XFRAME (WINDOW_FRAME (window));
@@ -5450,16 +5444,16 @@ XTredeem_scroll_bar (struct window *window)
     {
       /* If the prev pointer is nil, it must be the first in one of
         the lists.  */
-      if (EQ (FRAME_SCROLL_BARS (f), WVAR (window, vertical_scroll_bar)))
+      if (EQ (FRAME_SCROLL_BARS (f), window->vertical_scroll_bar))
        /* It's not condemned.  Everything's fine.  */
        return;
       else if (EQ (FRAME_CONDEMNED_SCROLL_BARS (f),
-                  WVAR (window, vertical_scroll_bar)))
-       FSET (f, condemned_scroll_bars, bar->next);
+                  window->vertical_scroll_bar))
+       fset_condemned_scroll_bars (f, bar->next);
       else
        /* If its prev pointer is nil, it must be at the front of
           one or the other!  */
-       abort ();
+       emacs_abort ();
     }
   else
     XSCROLL_BAR (bar->prev)->next = bar->next;
@@ -5470,7 +5464,7 @@ XTredeem_scroll_bar (struct window *window)
   bar->next = FRAME_SCROLL_BARS (f);
   bar->prev = Qnil;
   XSETVECTOR (barobj, bar);
-  FSET (f, scroll_bars, barobj);
+  fset_scroll_bars (f, barobj);
   if (! NILP (bar->next))
     XSETVECTOR (XSCROLL_BAR (bar->next)->prev, bar);
 }
@@ -5487,7 +5481,7 @@ XTjudge_scroll_bars (FRAME_PTR f)
 
   /* Clear out the condemned list now so we won't try to process any
      more events on the hapless scroll bars.  */
-  FSET (f, condemned_scroll_bars, Qnil);
+  fset_condemned_scroll_bars (f, Qnil);
 
   for (; ! NILP (bar); bar = next)
     {
@@ -5557,7 +5551,7 @@ static void
 x_scroll_bar_handle_click (struct scroll_bar *bar, XEvent *event, struct input_event *emacs_event)
 {
   if (! WINDOWP (bar->window))
-    abort ();
+    emacs_abort ();
 
   emacs_event->kind = SCROLL_BAR_CLICK_EVENT;
   emacs_event->code = event->xbutton.button - Button1;
@@ -5614,7 +5608,7 @@ x_scroll_bar_handle_click (struct scroll_bar *bar, XEvent *event, struct input_e
 static void
 x_scroll_bar_note_movement (struct scroll_bar *bar, XEvent *event)
 {
-  FRAME_PTR f = XFRAME (WVAR (XWINDOW (bar->window), frame));
+  FRAME_PTR f = XFRAME (XWINDOW (bar->window)->frame);
 
   last_mouse_movement_time = event->xmotion.time;
 
@@ -6361,7 +6355,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
         mouse highlighting.  */
       if (!hlinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight)
          && (f == 0
-             || !EQ (FGET (f, tool_bar_window), hlinfo->mouse_face_window)))
+             || !EQ (f->tool_bar_window, hlinfo->mouse_face_window)))
         {
           clear_mouse_face (hlinfo);
           hlinfo->mouse_face_hidden = 1;
@@ -6463,7 +6457,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
                 }
               else if (status_return != XLookupKeySym
                        && status_return != XLookupBoth)
-                abort ();
+                emacs_abort ();
             }
           else
             nbytes = XLookupString (&event.xkey, (char *) copy_bufptr,
@@ -6788,8 +6782,8 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
                       create event iff we don't leave the
                       selected frame.  */
                    && (focus_follows_mouse
-                       || (EQ (WVAR (XWINDOW (window), frame),
-                               WVAR (XWINDOW (selected_window), frame)))))
+                       || (EQ (XWINDOW (window)->frame,
+                               XWINDOW (selected_window)->frame))))
                   {
                     inev.ie.kind = SELECT_WINDOW_EVENT;
                     inev.ie.frame_or_window = window;
@@ -6908,15 +6902,15 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
         if (f)
           {
             /* Is this in the tool-bar?  */
-            if (WINDOWP (FGET (f, tool_bar_window))
-                && WINDOW_TOTAL_LINES (XWINDOW (FGET (f, tool_bar_window))))
+            if (WINDOWP (f->tool_bar_window)
+                && WINDOW_TOTAL_LINES (XWINDOW (f->tool_bar_window)))
               {
                 Lisp_Object window;
                 int x = event.xbutton.x;
                 int y = event.xbutton.y;
 
                 window = window_from_coordinates (f, x, y, 0, 1);
-                tool_bar_p = EQ (window, FGET (f, tool_bar_window));
+                tool_bar_p = EQ (window, f->tool_bar_window);
 
                 if (tool_bar_p && event.xbutton.button < 4)
                   {
@@ -7338,7 +7332,7 @@ x_draw_hollow_cursor (struct window *w, struct glyph_row *row)
 static void
 x_draw_bar_cursor (struct window *w, struct glyph_row *row, int width, enum text_cursor_kinds kind)
 {
-  struct frame *f = XFRAME (WVAR (w, frame));
+  struct frame *f = XFRAME (w->frame);
   struct glyph *cursor_glyph;
 
   /* If cursor is out of bounds, don't draw garbage.  This can happen
@@ -7502,12 +7496,12 @@ x_draw_window_cursor (struct window *w, struct glyph_row *glyph_row, int x, int
              break;
 
            default:
-             abort ();
+             emacs_abort ();
            }
        }
 
 #ifdef HAVE_X_I18N
-      if (w == XWINDOW (FGET (f, selected_window)))
+      if (w == XWINDOW (f->selected_window))
        if (FRAME_XIC (f) && (FRAME_XIC_STYLE (f) & XIMPreeditPosition))
          xic_set_preeditarea (w, x, y);
 #endif
@@ -7833,7 +7827,7 @@ x_connection_closed (Display *dpy, const char *error_message)
       {
        /* Set this to t so that delete_frame won't get confused
           trying to find a replacement.  */
-       KVAR (FRAME_KBOARD (XFRAME (frame)), Vdefault_minibuffer_frame) = Qt;
+       kset_default_minibuffer_frame (FRAME_KBOARD (XFRAME (frame)), Qt);
        delete_frame (frame, Qnoelisp);
       }
 
@@ -7849,13 +7843,13 @@ x_connection_closed (Display *dpy, const char *error_message)
         (https://bugzilla.gnome.org/show_bug.cgi?id=85715).  Once,
         the resulting Glib error message loop filled a user's disk.
         To avoid this, kill Emacs unconditionally on disconnect.  */
-      shut_down_emacs (0, 0, Qnil);
+      shut_down_emacs (0, Qnil);
       fprintf (stderr, "%s\n\
 When compiled with GTK, Emacs cannot recover from X disconnects.\n\
 This is a GTK bug: https://bugzilla.gnome.org/show_bug.cgi?id=85715\n\
 For details, see etc/PROBLEMS.\n",
               error_msg);
-      abort ();
+      emacs_abort ();
 #endif /* USE_GTK */
 
       /* Indicate that this display is dead.  */
@@ -7865,7 +7859,7 @@ For details, see etc/PROBLEMS.\n",
       dpyinfo->terminal->reference_count--;
       if (dpyinfo->reference_count != 0)
         /* We have just closed all frames on this display. */
-        abort ();
+        emacs_abort ();
 
       {
        Lisp_Object tmp;
@@ -8158,7 +8152,7 @@ xim_instantiate_callback (Display *display, XPointer client_data, XPointer call_
                  xic_set_statusarea (f);
                if (FRAME_XIC_STYLE (f) & XIMPreeditPosition)
                  {
-                   struct window *w = XWINDOW (FGET (f, selected_window));
+                   struct window *w = XWINDOW (f->selected_window);
                    xic_set_preeditarea (w, w->cursor.x, w->cursor.y);
                  }
              }
@@ -8946,7 +8940,7 @@ x_set_window_size (struct frame *f, int change_gravity, int cols, int rows)
 #endif /* not USE_GTK */
 
   /* If cursor was outside the new size, mark it as off.  */
-  mark_window_cursors_off (XWINDOW (FGET (f, root_window)));
+  mark_window_cursors_off (XWINDOW (f->root_window));
 
   /* Clear out any recollection of where the mouse highlighting was,
      since it might be in a place that's outside the new frame size.
@@ -10113,7 +10107,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
       {
        terminal->kboard = xmalloc (sizeof *terminal->kboard);
        init_kboard (terminal->kboard);
-       KVAR (terminal->kboard, Vwindow_system) = Qx;
+       kset_window_system (terminal->kboard, Qx);
 
        /* Add the keyboard to the list before running Lisp code (via
            Qvendor_specific_keysyms below), since these are not traced
@@ -10121,7 +10115,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
        terminal->kboard->next_kboard = all_kboards;
        all_kboards = terminal->kboard;
 
-       if (!EQ (SVAR (XSYMBOL (Qvendor_specific_keysyms), function), Qunbound))
+       if (!EQ (XSYMBOL (Qvendor_specific_keysyms)->function, Qunbound))
          {
            char *vendor = ServerVendor (dpy);
 
@@ -10135,9 +10129,10 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
            /* Temporarily hide the partially initialized terminal.  */
            terminal_list = terminal->next_terminal;
            UNBLOCK_INPUT;
-           KVAR (terminal->kboard, Vsystem_key_alist)
-             = call1 (Qvendor_specific_keysyms,
-                      vendor ? build_string (vendor) : empty_unibyte_string);
+           kset_system_key_alist
+             (terminal->kboard,
+              call1 (Qvendor_specific_keysyms,
+                     vendor ? build_string (vendor) : empty_unibyte_string));
            BLOCK_INPUT;
            terminal->next_terminal = terminal_list;
            terminal_list = terminal;
@@ -10441,7 +10436,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
     to.addr = (XPointer)&font;
     x_catch_errors (dpy);
     if (!XtCallConverter (dpy, XtCvtStringToFont, &d, 1, &fr, &to, NULL))
-      abort ();
+      emacs_abort ();
     if (x_had_errors_p (dpy) || !XQueryFont (dpy, font))
       XrmPutLineResource (&xrdb, "Emacs.dialog.*.font: 9x15");
     x_uncatch_errors ();
@@ -10607,8 +10602,6 @@ x_activate_timeout_atimer (void)
 \f
 /* Set up use of X before we make the first connection.  */
 
-extern frame_parm_handler x_frame_parm_handlers[];
-
 static struct redisplay_interface x_redisplay_interface =
   {
     x_frame_parm_handlers,
@@ -10813,8 +10806,6 @@ x_initialize (void)
   XSetIOErrorHandler (x_io_error_quitter);
 
   signal (SIGPIPE, x_connection_signal);
-
-  xgselect_initialize ();
 }