-*- indented-text -*-
 to 21.2.18 "Toshima"
+-- miscellaneous fixes from Steve Baur
+-- miscellaneous fixes from Didier Verna
+-- various bug fixes from Karl Hegbloom
+-- miscellaneous fixes from Bob Weiner
+-- fix for XIM server crashing and taking down XEmacs from Kazuyuki IENAGA
 -- valid-image-instantiator-format-p tightened up by Andy Piper.
 -- glyph widget support under X/Motif from Andy Piper
 -- Make docdir configurable, update package searching rules from Michael
 
+1999-07-13  XEmacs Build Bot <builds@cvs.xemacs.org>
+
+       * XEmacs 21.2.18 is released
+
+1999-07-06  SL Baur  <steve@miho.m17n.org>
+
+       * config.guess (main): Synch with newer config.guess for HP
+       support.
+       From Marcus Thiessel <marcus@xemacs.org>
+
 1999-06-25  Michael Sperber [Mr. Preprocessor]  <sperber@informatik.uni-tuebingen.de>
 
        * configure.in (with_prefix): Added --with-prefix, defaults to
 
        case "${UNAME_MACHINE}" in
            9000/31? )            HP_ARCH=m68000 ;;
            9000/[34]?? )         HP_ARCH=m68k ;;
-           9000/6?? | 9000/7?? | 9000/80[24] | 9000/8?[13679] | 9000/892 )
+           9000/[678][0-9][0-9])
               sed 's/^              //' << EOF >dummy.c
               #include <stdlib.h>
               #include <unistd.h>
 
  * Mountain View, California 94043
  */
 
-#pragma ident  "@(#) $Id: _dynodump.h,v 1.3 1997/05/29 04:22:29 steve Exp $ - SMI"
+#pragma ident  "@(#) $Id: _dynodump.h,v 1.5 1996/05/23 18:39:07 georgn Exp $ - SMI"
 
 #ifndef        _DYNODUMP_DOT_H
 #define        _DYNODUMP_DOT_H
 
  * N.B. The above commentary is not quite correct in the flags have been hardwired
  *      to RTLD_SAVREL.
  */
-#pragma ident  "@(#) $Id: dynodump.c,v 1.6 1998/03/31 20:10:55 steve Exp $ - SMI"
+#pragma ident  "@(#) $Id: dynodump.c,v 1.8 1996/05/23 18:39:21 georgn Exp $ - SMI"
 
 #define __EXTENSIONS__ 1
 
 
  * Mountain View, California 94043
  */
 
-#pragma ident  "@(#) $Id: _relocate.c,v 1.3 1997/05/29 04:23:02 steve Exp $ - SMI"
+#pragma ident  "@(#) $Id: _relocate.c,v 1.4 1995/06/26 20:12:41 georgn Exp $ - SMI"
 
 /* LINTLIBRARY */
 
 
  * Mountain View, California 94043
  */
 
-#pragma ident  "@(#) $Id: machdep.h,v 1.3 1997/05/29 04:23:02 steve Exp $ - SMI"
+#pragma ident  "@(#) $Id: machdep.h,v 1.2 1995/02/16 22:58:43 georgn Exp $ - SMI"
 
 /*
  * Global include file for all sgs Intel machine dependent macros, constants
 
  * Mountain View, California 94043
  */
 
-#pragma ident "@(#) $Id: _relocate.c,v 1.4 1998/03/31 20:10:55 steve Exp $ - SMI"
+#pragma ident "@(#) $Id: _relocate.c,v 1.3 1995/06/26 20:16:39 georgn Exp $ - SMI"
 
 /* LINTLIBRARY */
 
 
  * Mountain View, California 94043
  */
 
-#pragma ident "@(#) $Id: machdep.h,v 1.3 1997/05/29 04:23:20 steve Exp $ - SMI"
+#pragma ident "@(#) $Id: machdep.h,v 1.2 1995/02/16 22:58:49 georgn Exp $ - SMI"
 
 /*
  * Global include file for all sgs PowerPC machine dependent macros, constants
 
 /*
  * Update the value of the `_edata' and `_end' symbols.
  */
-#pragma ident  "@(#) $Id: _relocate.c,v 1.4 1998/03/31 20:10:55 steve Exp $ - SMI"
+#pragma ident  "@(#) $Id: _relocate.c,v 1.4 1995/06/26 20:13:26 georgn Exp $ - SMI"
 
 #include       <libelf.h>
 #include       <string.h>
 
  * Mountain View, California 94043
  */
 
-#pragma ident  "@(#) $Id: machdep.h,v 1.3 1997/05/29 04:23:26 steve Exp $ - SMI"
+#pragma ident  "@(#) $Id: machdep.h,v 1.2 1995/02/16 22:58:55 georgn Exp $ - SMI"
 
 /*
  * Global include file for all sgs SPARC machine dependent macros, constants
 
 /*
  * Update the value of the `_edata' and `_end' symbols.
  */
-#pragma ident  "@(#) $Id: syms.c,v 1.3 1997/05/29 04:22:30 steve Exp $ - SMI"
+#pragma ident  "@(#) $Id: syms.c,v 1.2 1995/03/06 22:39:22 georgn Exp $ - SMI"
 
 #include       <libelf.h>
 #include       <string.h>
 
 writing, and sharing free software!
 
 // ÚÁÍÅÞÁÎÉÑ, ÉÓÐÒÁ×ÌÅÎÉÑ ÏÛÉÂÏË Ó ÎÅÔÅÒÐÅÎÉÅÍ ÖÄÕ ÐÏ ÁÄÒÅÓÕ bor@vb.dn.ua
-// Vladimir Bormotov.
\ No newline at end of file
+// Vladimir Bormotov.
 
+1999-07-13  XEmacs Build Bot <builds@cvs.xemacs.org>
+
+       * XEmacs 21.2.18 is released
+
 1999-06-22  XEmacs Build Bot <builds@cvs.xemacs.org>
 
        * XEmacs 21.2.17 is released
 
 
 Report bugs to <bug-gnu-emacs@prep.ai.mit.edu>.'
 
-Id='$Id: rcs2log,v 1.2 1997/07/09 04:31:03 steve Exp $'
+Id='$Id: rcs2log,v 1.37 1997/03/21 22:19:30 eggert Exp $'
 
 # Copyright 1992, 1993, 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
 
 
+1999-07-13  XEmacs Build Bot <builds@cvs.xemacs.org>
+
+       * XEmacs 21.2.18 is released
+
+1999-07-13  SL Baur  <steve@miho>
+
+       * lib-complete.el (read-library-name): Revert previous change.
+       (read-library): Ditto.
+
+1999-06-24  Karl M. Hegbloom  <karlheg@debian.org>
+
+       * packages.el (packages-package-list): Capitalize docstring.
+
+       * packages.el (packages-find-package-library-path): Use #'nconc
+       rather than #'append to reduce consing -- #'mapcar uses Flist,
+       which returns a freshly consed list.  #'append would create yet
+       another fresh list, using Fmake_list in concat.
+
+       * packages.el (package-provide): Use setq with remassq like it
+       says in its docstring.
+
+1999-07-06  SL Baur  <steve@miho.m17n.org>
+
+       * lib-complete.el (progn-with-message): Fix typo.
+
+1999-07-06  SL Baur  <steve@miho.m17n.org>
+
+       * mule/mule-misc.el (char-octet): Make function match docstring.
+       From Katsumi Yamaoka <yamaoka@jpl.org>
+       
+1999-06-15  Karl M. Hegbloom  <karlheg@debian.org>
+
+       * wid-edit.el (widget-documentation): corrected spelling error.
+
+1999-06-23  Jonathan Marten <jonathan.marten@uk.sun.com>
+
+       * x-win-sun.el (x-win-init-sun): Don't rebind Find and Sh-find
+       keys if already bound
+
+1999-07-06  SL Baur  <steve@miho.m17n.org>
+
+       * lib-complete.el (progn-with-message): Revert previous changes.
+
 1999-06-24  Bob Weiner  <weiner@beopen.com>
 
        * lib-complete.el (find-library): 
 
 ;; Author: Oscar Figueiredo <Oscar.Figueiredo@di.epfl.ch>
 ;; Maintainer: Oscar Figueiredo <Oscar.Figueiredo@di.epfl.ch>
 ;; Created: Jan 1998
-;; Version: $Revision: 1.7.2.5 $
+;; Version: $Revision: 1.7.2.3 $
 ;; Keywords: help comm
 
 ;; This file is part of XEmacs
 
 
 ;;=== Utilities ===========================================================
 
-(defmacro progn-with-message (MESSAGE &rest FORMS)
+(defmacro progn-with-message (message &rest forms)
   "(progn-with-message MESSAGE FORMS ...)
 Display MESSAGE and evaluate FORMS, returning value of the last one."
   ;; based on Hallvard Furuseth's funcall-with-message
-  (` 
-   (if (eq (selected-window) (minibuffer-window))
+  `(if (eq (selected-window) (minibuffer-window))
        (save-excursion
         (goto-char (point-max))
         (let ((orig-pmax (point-max)))
           (unwind-protect
               (progn
-                (insert " " (, MESSAGE)) (goto-char orig-pmax)
+                (insert " " ,message) (goto-char orig-pmax)
                 (sit-for 0)            ; Redisplay
-                (,@ FORMS))
+                ,@forms)
             (delete-region orig-pmax (point-max)))))
      (prog2
-        (message "%s" (, MESSAGE))
-        (progn (,@ FORMS))
-       (message "")))))
+        (message "%s" ,message)
+        (progn ,@forms)
+       (message ""))))
 
 (put 'progn-with-message 'lisp-indent-hook 1)
 
     (cond 
      ((equal library "") DEFAULT)
      (FULL (locate-file library read-library-internal-search-path
-                       ;; decompression doesn't work with Mule -slb
-                       (if (featurep 'mule)
-                           ".el:.elc"
-                         ".el:.el.gz:.el.Z:.elc")))
+                        '(".el" ".el.gz" ".elc")))
      (t library))))
 
 (defun read-library-name (prompt)
                     'read-library-internal 
                     (lambda (fn) 
                       (cond
-                       ;; decompression doesn't work with mule -slb
-                       ((string-match (if (featurep 'mule)
-                                          "\\.el$"
-                                        "\\.el\\(\\.gz\\|\\.Z\\)?$") fn)
+                       ((string-match "\\.el\\(\\.gz\\|\\.Z\\)?$" fn)
                         (substring fn 0 (match-beginning 0)))))
                     t nil)))
 
 
   "Return the octet numbered N (should be 0 or 1) of char CH.
 N defaults to 0 if omitted."
   (let ((split (split-char ch)))
+    (setq n (or n 0))
     (cond ((eq n 0)
           (nth 1 split))
          ((eq n 1)
 
 ;;; Package versioning
 
 (defvar packages-package-list nil
-  "database of loaded packages and version numbers")
+  "Database of loaded packages and version numbers")
 
 (defvar packages-hierarchy-depth 1
   "Depth of package hierarchies.")
   (let ((info (if (and attributes (floatp (car attributes)))
                  (list :version (car attributes))
                attributes)))
-    (remassq name packages-package-list)
     (setq packages-package-list
-         (cons (cons name info) packages-package-list))))
+         (cons (cons name info) (remassq name packages-package-list)))))
 
 (defun package-require (name version)
   (let ((pkg (assq name packages-package-list)))
 SUFFIXES is a list of names of package subdirectories to look for."
   (let ((directories
         (apply
-         #'append
+         #'nconc
          (mapcar #'(lambda (package)
                      (mapcar #'(lambda (suffix)
                                  (file-name-as-directory (concat package suffix)))
 
   :group 'hypermedia)
 
 (defgroup widget-documentation nil
-  "Options controling the display of documentation strings."
+  "Options controlling the display of documentation strings."
   :group 'widgets)
 
 (defgroup widget-faces nil
 
 ;;; themselves are in x-win.el in case someone wants to use them when
 ;;; not running on a Sun display.)
 
-  (define-key global-map 'find         'ow-find)
-  (define-key global-map '(shift find) 'ow-find-backward)
+  (or (lookup-key global-map 'find)
+      (define-key global-map 'find 'ow-find))
+  (or (lookup-key global-map '(shift find))
+       (define-key global-map '(shift find) 'ow-find-backward))
 
   )
 
 
+1999-07-13  XEmacs Build Bot <builds@cvs.xemacs.org>
+
+       * XEmacs 21.2.18 is released
+
 1999-07-05  Didier Verna  <verna@inf.enst.fr>
 
        * lwlib-Xm.c (xm_update_one_widget): add missing #ifdefs around
 
+1999-07-13  XEmacs Build Bot <builds@cvs.xemacs.org>
+
+       * XEmacs 21.2.18 is released
+
 1999-06-22  XEmacs Build Bot <builds@cvs.xemacs.org>
 
        * XEmacs 21.2.17 is released
 
 @setfilename ../info/info.info
 @settitle Info 1.0
 @comment %**end of header 
-@comment $Id: info.texi,v 1.4 1998/06/30 06:35:28 steve Exp $
+@comment $Id: info.texi,v 1.4 1997/07/10 21:58:11 karl Exp $
 
 @dircategory Texinfo documentation system
 @direntry
 
 % texinfo.tex -- TeX macros to handle Texinfo files.
-% $Id: texinfo.tex,v 1.5 1998/06/13 04:28:12 steve Exp $
+% $Id: texinfo.tex,v 2.227 1998/02/25 22:54:34 karl Exp $
 %
 % Copyright (C) 1985, 86, 88, 90, 91, 92, 93, 94, 95, 96, 97, 98
 % Free Software Foundation, Inc.
 
 % This automatically updates the version number based on RCS.
 \def\deftexinfoversion$#1: #2 ${\def\texinfoversion{#2}}
-\deftexinfoversion$Revision: 1.5 $
+\deftexinfoversion$Revision: 2.227 $
 \message{Loading texinfo package [Version \texinfoversion]:}
 
 % If in a .fmt file, print the version number
 
 \input texinfo.tex    @c -*-texinfo-*-
-@c $Id: texinfo.texi,v 1.8.2.1 1999/03/04 15:48:24 steveb Exp $
+@c $Id: texinfo.txi,v 1.50 1998/02/27 21:21:34 karl Exp $
 @c %**start of header
 
 @c All text is ignored before the setfilename.
 
 @finalout
 @titlepage
 @title XEmacs FAQ
-@subtitle Frequently asked questions about XEmacs @* Last Modified: $Date: 1999/05/13 12:26:40 $
+@subtitle Frequently asked questions about XEmacs @* Last Modified: $Date: 1999/03/04 15:48:25 $
 @sp 1
 @author Tony Rossini <arossini@@stat.sc.edu>
 @author Ben Wing <wing@@666.com>
 
+1999-07-13  XEmacs Build Bot <builds@cvs.xemacs.org>
+
+       * XEmacs 21.2.18 is released
+
 1999-06-22  XEmacs Build Bot <builds@cvs.xemacs.org>
 
        * XEmacs 21.2.17 is released
 
+1999-07-13  XEmacs Build Bot <builds@cvs.xemacs.org>
+
+       * XEmacs 21.2.18 is released
+
+1999-07-08  SL Baur  <steve@mule.m17n.org>
+
+       * event-Xt.c (handle_focus_event_1): Guard FRAME_X_XIC with
+       XIM_XLIB.
+       (emacs_Xt_handle_magic_event): Ditto.
+       * redisplay-x.c (x_output_string): Ditto.
+       (x_output_eol_cursor): Ditto.
+
+1999-06-30  Kazuyuki IENAGA <kazz@imasy.or.jp>
+
+       *  event-Xt.c, input-method-xlib.c, redisplay-x.c: Avoid the
+       problem that when XIM is destroyed or missed with some reason,
+       xemacs will die.  Now xim=xlib waits the XIM will be ready and
+       endures the case of XIM end up.
+
+1999-07-03  Gunnar Evermann  <ge204@eng.cam.ac.uk>
+
+        * tooltalk.c (init_tooltalk): save signal actions for SIGQUIT,
+        SIGINT and SIGCHLD before calling tt_open and restore the
+        afterwards. This fixes e.g. the zombie subprocesses on Solaris
+
+1999-07-06  SL Baur  <steve@xemacs.org>
+
+       * s/linux.h: gcc-2.8 changes for powerpc
+       From Justin Vallon <vallon@mindspring.com>
+
 1999-07-05  Didier Verna  <verna@inf.enst.fr>
 
        * indent.c: new symbol Qcoerce.
 
   len = XmImMbLookupString (XtWindowToWidget (event->display, event->window),
                            event, bufptr, bufsiz, &keysym, &status);
 #else /* XIM_XLIB */
-  len = XmbLookupString (xic, event, bufptr, bufsiz, &keysym, &status);
+  if (xic)
+    len = XmbLookupString (xic, event, bufptr, bufsiz, &keysym, &status);
 #endif /* HAVE_XIM */
 
 #ifdef DEBUG_XEMACS
 #if XtSpecificationRelease > 5
   Widget focus_widget = XtGetKeyboardFocusWidget (FRAME_X_TEXT_WIDGET (f));
 #endif
-#ifdef HAVE_XIM
-  XIM_focus_event (f, in_p);
+#if defined(HAVE_XIM) && defined(XIM_XLIB)
+  if (FRAME_X_XIC(f))
+    XIM_focus_event (f, in_p);
 #endif /* HAVE_XIM */
 
   /* On focus change, clear all memory of sticky modifiers
       break;
 
     case ConfigureNotify:
-#ifdef HAVE_XIM
-      XIM_SetGeometry (f);
+#if defined(HAVE_XIM) && defined(XIM_XLIB)
+      if (FRAME_X_XIC(f))
+       XIM_SetGeometry (f);
 #endif
       break;
 
 
 #include "EmacsFrame.h"
 #include "events.h"
 
+#include <X11/IntrinsicP.h>
+#include <X11/Xaw/XawImP.h>
+
 #ifndef XIM_XLIB
 #error  XIM_XLIB is not defined??
 #endif
 "XIMPreeditNone|XIMStatusNothing\n"
 "XIMPreeditNone|XIMStatusNone";
 
+static Boolean xim_initted = False;
+
 static XIMStyle best_style (XIMStyles *user, XIMStyles *xim);
 
 void
     }
 }
 
-/* Create X input method for device */
-void
-XIM_init_device (struct device *d)
-{
-  Display *dpy = DEVICE_X_DISPLAY (d);
-  char *name, *class;
-  XIM xim;
+/******************************************************************/
+/*                     Input method using xlib                    */
+/******************************************************************/
 
-  XtGetApplicationNameAndClass (dpy, &name, &class);
-
-  DEVICE_X_XIM (d) = xim = XOpenIM (dpy, XtDatabase (dpy), name, class);
+/*
+ * called from when XIM is destroying
+ */
+static void
+IMDestroyCallback (XIM im, XPointer client_data, XPointer call_data)
+{
+  struct frame *f = (struct frame *)client_data;
+  struct device *d = XDEVICE (FRAME_DEVICE ((struct frame *)client_data));
+  Lisp_Object frame_list = DEVICE_FRAME_LIST (XDEVICE (FRAME_DEVICE (f)));
+  Lisp_Object tail;
+  struct frame *target_frame = NULL;
 
-  if (xim == NULL)
+  LIST_LOOP (tail, frame_list)
     {
-      stderr_out ("Warning: XOpenIM() failed...no input server available\n");
-      return;
+      if (target_frame = XFRAME (XCAR (tail)))
+       {
+         if ( FRAME_X_XIC(target_frame) )
+           {
+             XDestroyIC (FRAME_X_XIC(target_frame));
+             FRAME_X_XIC (target_frame) = NULL;
+           }
+       }
     }
-  else
+
+#if 0
+  if ( DEVICE_X_XIM (d) )
     {
-      /* Get supported styles */
-      XGetIMValues (xim, XNQueryInputStyle, &DEVICE_X_XIM_STYLES (d), NULL);
-#ifdef DEBUG_XIM
-      describe_XIM (xim);
-#endif
+      stderr_out ("NULLing d->xim...\n");
+      /* DEVICE_X_XIM (d) = NULL; */
     }
+#endif
+
+  xim_initted = False;
+  return;
 }
 
-/* Create an X input context for this frame. */
-void
-XIM_init_frame (struct frame *f)
+/*
+ * called from when FRAME is initializing
+ */
+static void
+IMInstantiateCallback (Display *dpy, XPointer client_data, XPointer call_data)
 {
-  struct device *d = XDEVICE (FRAME_DEVICE (f));
-  XIM xim = DEVICE_X_XIM (d);
-  XIC xic;
-  Widget w = FRAME_X_TEXT_WIDGET (f);
+  struct frame *f = (struct frame *)client_data;
+  struct device *d = XDEVICE (FRAME_DEVICE ((struct frame *)client_data));
+  XIM xim;
+  Widget w = FRAME_X_TEXT_WIDGET ((struct frame *)client_data);
   Window win = XtWindow (w);
-  XRectangle p_area = {0,0,1,1}, s_area={0,0,1,1};
+  XRectangle p_area = {0,0,1,1}, s_area = {0,0,1,1};
   XPoint spot = {0,0};
   XIMStyle style;
   XVaNestedList p_list, s_list;
-
+  char *name, *class;
   typedef struct
   {
     XIMStyles styles;
     XFontSet  fontset;
     Pixel     fg;
     Pixel     bg;
+    char      *inputmethod;
   } xic_vars_t;
-
   xic_vars_t xic_vars;
-
-  /* mrb: #### Fix so that background and foreground is set from
-     default face, rather than foreground and background resources, or
-     that the user can use set-frame-parameters to set xic attributes */
+  XIMCallback ximcallback;
+  XIC xic;
 
 #define res(name, class, representation, field, default_value) \
   { name, class, representation, sizeof(xic_vars.field), \
     res(XtNximStyles,     XtCXimStyles,  XtRXimStyles, styles,  (XtPointer) DefaultXIMStyles),
     res(XtNfontSet,       XtCFontSet,    XtRFontSet,   fontset, (XtPointer) XtDefaultFontSet),
     res(XtNximForeground, XtCForeground, XtRPixel,     fg,      (XtPointer) XtDefaultForeground),
-    res(XtNximBackground, XtCBackground, XtRPixel,     bg,      (XtPointer) XtDefaultBackground)
+    res(XtNximBackground, XtCBackground, XtRPixel,     bg,      (XtPointer) XtDefaultBackground),
+    res(XtNinputMethod,   XtCInputMethod, XtRString,   inputmethod, (XtPointer) NULL)
   };
 
-  assert (win != 0 && w != NULL && d != NULL);
+  /* ---------- beginning of the action ---------- */
 
-  if (!xim)
-    {                   /* No input method? */
-      FRAME_X_XIC (f) = NULL;
-      return;
+  /*
+   * if no xim is presented, initialize xim ...
+   */
+  if ( xim_initted == False )
+    {
+      xim_initted = True;
+      XtGetApplicationNameAndClass (dpy, &name, &class);
+      DEVICE_X_XIM (d) = xim = XOpenIM (dpy, XtDatabase (dpy), name, class);
+
+      /* destroy callback for im */
+      ximcallback.callback = IMDestroyCallback;
+      ximcallback.client_data = (XPointer)f;
+      XSetIMValues (xim, XNDestroyCallback, &ximcallback, NULL);
+    }
+  else
+    {
+      xim = DEVICE_X_XIM (d);
     }
 
+  w = FRAME_X_TEXT_WIDGET (f);
+
+  /*
+   * initialize XIC
+   */
+  if ( FRAME_X_XIC (f) ) return;
   XtGetApplicationResources (w, &xic_vars,
                             resources, XtNumber (resources),
                             NULL, 0);
-
   if (!xic_vars.fontset)
     {
       stderr_out ("Can't get fontset resource for Input Method\n");
       return;
     }
 
+  /* construct xic */
+  XGetIMValues (xim, XNQueryInputStyle, &DEVICE_X_XIM_STYLES(d), NULL);
   FRAME_X_XIC_STYLE (f) = style =
-    best_style (&xic_vars.styles, DEVICE_X_XIM_STYLES (d));
+    best_style (&xic_vars.styles, (XIMStyles *)DEVICE_X_XIM_STYLES(d));
 
-  /* Hopefully we don't have to conditionalize the following based on
-     style; the IM should ignore values it doesn't use */
   p_list = XVaCreateNestedList (0,
-                                XNArea,         &p_area,
-                                XNSpotLocation, &spot,
-                                XNForeground,   xic_vars.fg,
-                                XNBackground,   xic_vars.bg,
-                                XNFontSet,      xic_vars.fontset,
-                                NULL);
+                               XNArea,         &p_area,
+                               XNSpotLocation, &spot,
+                               XNForeground,   xic_vars.fg,
+                               XNBackground,   xic_vars.bg,
+                               XNFontSet,      xic_vars.fontset,
+                               NULL);
 
   s_list = XVaCreateNestedList (0,
-                                XNArea,         &s_area,
-                                XNForeground,   xic_vars.fg,
-                                XNBackground,   xic_vars.bg,
-                                XNFontSet,      xic_vars.fontset,
-                                NULL);
+                               XNArea,         &s_area,
+                               XNForeground,   xic_vars.fg,
+                               XNBackground,   xic_vars.bg,
+                               XNFontSet,      xic_vars.fontset,
+                               NULL);
+
   FRAME_X_XIC (f) = xic =
     XCreateIC (xim,
-               XNInputStyle,        style,
-               XNClientWindow,      win,
-               XNFocusWindow,       win,
-               XNPreeditAttributes, p_list,
-               XNStatusAttributes,  s_list,
-               NULL);
+              XNInputStyle, style,
+              XNClientWindow, win,
+              XNFocusWindow, win,
+              XNPreeditAttributes, p_list,
+              XNStatusAttributes, s_list,
+              NULL);
   XFree (p_list);
   XFree (s_list);
 
   if (!xic)
     {
-      stderr_out ("Warning: XCreateIC failed\n");
+      stderr_out ("Warning: XCreateIC failed.\n");
       return;
     }
 
   if (style & XIMPreeditPosition)
-    { /* Init spot to invalid values */
-      XPoint *frame_spot = &(FRAME_X_XIC_SPOT (f));
+    {
+      XPoint *frame_spot = &(FRAME_X_XIC_SPOT(f));
       frame_spot->x = frame_spot->y = -1;
     }
 
 
   XSetICFocus (xic);
 
-#ifdef DEBUG_XIM
-  describe_XIC (xic);
+  return;
+}
+
+/* Create X input method for device */
+void
+XIM_init_device (struct device *d)
+{
+  /* do nothing here */
+  return;
+}
+
+/* Callback for when the frame was deleted (closed) */
+static void
+XIM_delete_frame (Widget w, XtPointer client_data, XtPointer call_data)
+{
+  struct frame *f = (struct frame *)client_data;
+  struct device *d = XDEVICE (FRAME_DEVICE ((struct frame *)client_data));
+  Display *dpy = DEVICE_X_DISPLAY (d);
+
+  XUnregisterIMInstantiateCallback (dpy, NULL, NULL, NULL,
+                                   IMInstantiateCallback, (XtPointer)f);
+
+  if ( FRAME_X_XIC (f) )
+    {
+      XDestroyIC (FRAME_X_XIC(f));
+      FRAME_X_XIC (f) = NULL;
+    }
+  return;
+}
+
+/* Create an X input context for this frame.
+   -  Register the IM to be initiated later using XRegisterIMInstantiateCallback
+ */
+void
+XIM_init_frame (struct frame *f)
+{
+  struct device *d = XDEVICE (FRAME_DEVICE (f));
+
+  XRegisterIMInstantiateCallback (DEVICE_X_DISPLAY (d), NULL, NULL, NULL,
+                                 IMInstantiateCallback, (XtPointer)f);
+
+#if 0
+  if ( FRAME_X_XIC (f) )
+    return;
 #endif
+  if ( ! DEVICE_X_XIM (d) )
+    {
+      stderr_out ("X Input Method open failed. Waiting IM to be enabled.\n");
+    }
+
+  /* when frame is going to be destroyed (closed) */
+  XtAddCallback (FRAME_X_TEXT_WIDGET(f), XNDestroyCallback,
+                XIM_delete_frame, (XtPointer)f);
+  return;
 }
 
+
 void
 XIM_SetGeometry (struct frame *f)
 {
 void
 XIM_focus_event (struct frame *f, int in_p)
 {
-  if (FRAME_X_XIC (f))
+  if (FRAME_X_XIC (f) /* && FRAME_X_XIM_REGISTERED(f) */)
     (in_p ? XSetICFocus : XUnsetICFocus) (FRAME_X_XIC (f));
 }
 
 
       cachel = WINDOW_FACE_CACHEL (w, findex);
     }
 
-#ifdef HAVE_XIM
+#if defined(HAVE_XIM) && defined(XIM_XLIB)
   if (cursor && focus && (cursor_start == clip_start) && cursor_height)
-    XIM_SetSpotLocation (f, xpos - 2, dl->ypos + dl->descent - 2);
-#endif /* HAVE_XIM */
+    if (FRAME_X_XIC(f))
+      XIM_SetSpotLocation (f, xpos - 2, dl->ypos + dl->descent - 2);
+#endif /* HAVE_XIM && XIM_XLIB */
 
   bg_pmap = cachel->background_pixmap;
   if (!IMAGE_INSTANCEP (bg_pmap)
 
   if (focus)
     {
-#ifdef HAVE_XIM
-      XIM_SetSpotLocation (f, x - 2 , cursor_y + cursor_height - 2);
+#if defined(HAVE_XIM) && defined(XIM_XLIB)
+      if (FRAME_X_XIC(f))
+       XIM_SetSpotLocation (f, x - 2 , cursor_y + cursor_height - 2);
 #endif /* HAVE_XIM */
 
       if (NILP (bar_cursor_value))
 
 #define USG
 #define LINUX
 
+/* powerpc gcc 2.8.0 doesn't define __ELF__, but it is */
+
+#if defined(__ELF__) || defined(powerpc)
+#define LINUX_ELF
+#endif
+
 /* SYSTEM_TYPE should indicate the kind of system you are using.
  It sets the Lisp variable system-type.  */
 
 /* Ask GCC where to find libgcc.a.  */
 #define LIB_GCC "`$(CC) $(C_SWITCH_X_SITE) -print-libgcc-file-name`"
 
-#ifndef __ELF__
+#ifndef LINUX_ELF
 /* Linux has crt0.o in a non-standard place */
 #define START_FILES "pre-crt0.o /usr/lib/crt0.o"
 #else
 /* Best not to include -lg, unless it is last on the command line */
 #define LIBS_DEBUG
 #define LIBS_TERMCAP "-ltermcap -lcurses" /* save some space with shared libs*/
-#ifndef __ELF__
+#ifndef LINUX_ELF
 #define LIB_STANDARD "-lc" /* avoid -lPW */
 #else
 /*#undef LIB_GCC
 #define LIBS_SYSTEM
 #endif
 
-#ifdef __ELF__
+#ifdef LINUX_ELF
 #define UNEXEC "unexelf.o"
 #define UNEXEC_USE_MAP_PRIVATE
 #if 0
 #undef START_FILES
 #undef LIB_GCC
 #endif
-#endif /* __ELF__ */
+#endif /* LINUX_ELF */
 
 #ifdef LINUX_QMAGIC
 
 
   Lisp_Object lp;
   Lisp_Object fil;
 
+
+  /* tt_open() messes with our signal handler flags (at least when no 
+     ttsessions is running on the machine), therefore we save the 
+     actions and restore them after the call */
+#ifdef HAVE_SIGPROCMASK
+  {
+    struct sigaction ActSIGQUIT;
+    struct sigaction ActSIGINT;
+    struct sigaction ActSIGCHLD;
+    sigaction (SIGQUIT, NULL, &ActSIGQUIT);
+    sigaction (SIGINT, NULL, &ActSIGINT);
+    sigaction (SIGCHLD, NULL, &ActSIGCHLD);
+#endif
   retval = tt_open ();
+#ifdef HAVE_SIGPROCMASK
+    sigaction (SIGQUIT, &ActSIGQUIT, NULL);
+    sigaction (SIGINT, &ActSIGINT, NULL);
+    sigaction (SIGCHLD, &ActSIGCHLD, NULL);
+  }
+#endif
+
+
   if (tt_ptr_error (retval) != TT_OK)
     return;
 
 
 
 /* Synched up with: Not in FSF. */
 
-/* #pragma ident "@(#) $Id: unexsol2.c,v 1.3 1997/10/13 03:35:33 steve Exp $" */
+/* #pragma ident "@(#) $Id: unexsol2.c,v 1.2 1995/01/25 20:39:16 georgn Exp $" */
 
 #include <stdlib.h>
 #include <stdio.h>
 
+1999-07-13  XEmacs Build Bot <builds@cvs.xemacs.org>
+
+       * XEmacs 21.2.18 is released
+
 1999-06-22  XEmacs Build Bot <builds@cvs.xemacs.org>
 
        * XEmacs 21.2.17 is released
 
 emacs_is_beta=t
 emacs_major_version=21
 emacs_minor_version=2
-emacs_beta_version=17
-xemacs_codename="Chiyoda"
+emacs_beta_version=18
+xemacs_codename="Toshima"
 infodock_major_version=4
 infodock_minor_version=0
 infodock_build_version=7