(Fdocumentation, Fdocumentation_property, Fsubstitute_command_keys):
[bpt/emacs.git] / src / xfns.c
index 31cee63..95e52e0 100644 (file)
@@ -35,11 +35,18 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "dispextern.h"
 #include "keyboard.h"
 #include "blockinput.h"
-#include "paths.h"
+#include <paths.h>
 
 #ifdef HAVE_X_WINDOWS
 extern void abort ();
 
+/* On some systems, the character-composition stuff is broken in X11R5.  */
+#if defined (HAVE_X11R5) && ! defined (HAVE_X11R6)
+#ifdef X11R5_INHIBIT_I18N
+#undef HAVE_X_I18N
+#endif
+#endif
+
 #ifndef VMS
 #if 1 /* Used to be #ifdef EMACS_BITMAP_FILES, but this should always work.  */
 #include "bitmaps/gray.xbm"
@@ -70,8 +77,9 @@ extern void abort ();
 
 #include "../lwlib/lwlib.h"
 
-/* Do the EDITRES protocol if running X11R5 */
-#if (XtSpecificationRelease >= 5)
+/* Do the EDITRES protocol if running X11R5
+   Exception: HP-UX (at least version A.09.05) has X11R5 without EditRes */
+#if (XtSpecificationRelease >= 5) && !defined(NO_EDITRES)
 #define HACK_EDITRES
 extern void _XEditResCheckMessages ();
 #endif /* R5 + Athena */
@@ -187,7 +195,7 @@ Lisp_Object Qdisplay;
 
 /* The below are defined in frame.c.  */
 extern Lisp_Object Qheight, Qminibuffer, Qname, Qonly, Qwidth;
-extern Lisp_Object Qunsplittable, Qmenu_bar_lines;
+extern Lisp_Object Qunsplittable, Qmenu_bar_lines, Qbuffer_predicate;
 
 extern Lisp_Object Vwindow_system_version;
 
@@ -200,10 +208,11 @@ check_x ()
     error ("X windows are not in use or not initialized");
 }
 
-/* Nonzero if using X for display.  */
+/* Nonzero if we can use mouse menus.
+   You should not call this unless HAVE_MENUS is defined.  */
 
 int
-using_x_p ()
+have_menus_p ()
 {
   return x_in_use;
 }
@@ -225,7 +234,7 @@ check_x_frame (frame)
       f = XFRAME (frame);
     }
   if (! FRAME_X_P (f))
-    error ("non-X frame used");
+    error ("Non-X frame used");
   return f;
 }
 
@@ -255,7 +264,7 @@ check_x_display_info (frame)
       CHECK_LIVE_FRAME (frame, 0);
       f = XFRAME (frame);
       if (! FRAME_X_P (f))
-       error ("non-X frame used");
+       error ("Non-X frame used");
       return FRAME_X_DISPLAY_INFO (f);
     }
 }
@@ -1165,8 +1174,8 @@ x_decode_color (f, arg, def)
   if (defined_color (f, XSTRING (arg)->data, &cdef, 1))
     return cdef.pixel;
 
-  /* defined_color failed; return an ultimate default.  */
-  return def;
+  Fsignal (Qerror, Fcons (build_string ("undefined color"),
+                         Fcons (arg, Qnil)));
 }
 \f
 /* Functions called only from `x_set_frame_param'
@@ -1576,7 +1585,7 @@ x_set_font (f, arg, oldval)
   UNBLOCK_INPUT;
   
   if (EQ (result, Qnil))
-    error ("Font \"%s\" is not defined", XSTRING (arg)->data);
+    error ("Font `%s' is not defined", XSTRING (arg)->data);
   else if (EQ (result, Qt))
     error ("the characters of the given font have varying widths");
   else if (STRINGP (result))
@@ -1696,7 +1705,7 @@ x_set_menu_bar_lines (f, value, oldval)
   if (nlines)
     {
       FRAME_EXTERNAL_MENU_BAR (f) = 1;
-      if (f->output_data.x->menubar_widget == 0)
+      if (FRAME_X_P (f) && f->output_data.x->menubar_widget == 0)
        /* Make sure next redisplay shows the menu bar.  */
        XWINDOW (FRAME_SELECTED_WINDOW (f))->update_mode_line = Qt;
     }
@@ -1705,7 +1714,8 @@ x_set_menu_bar_lines (f, value, oldval)
       if (FRAME_EXTERNAL_MENU_BAR (f) == 1)
        free_frame_menubar (f);
       FRAME_EXTERNAL_MENU_BAR (f) = 0;
-      f->output_data.x->menubar_widget = 0;
+      if (FRAME_X_P (f))
+       f->output_data.x->menubar_widget = 0;
     }
 #else /* not USE_X_TOOLKIT */
   FRAME_MENU_BAR_LINES (f) = nlines;
@@ -2581,6 +2591,28 @@ x_window (f, window_prompting, minibuffer_only)
   class_hints.res_class = EMACS_CLASS;
   XSetClassHint (FRAME_X_DISPLAY (f), XtWindow (shell_widget), &class_hints);
 
+#ifdef HAVE_X_I18N
+  { 
+    XIM xim;
+    XIC xic = NULL;
+
+    xim = XOpenIM (FRAME_X_DISPLAY (f), NULL, NULL, NULL);
+
+    if (xim)
+      {
+       xic = XCreateIC (xim,  
+                        XNInputStyle,   XIMPreeditNothing | XIMStatusNothing,
+                        XNClientWindow, FRAME_X_WINDOW(f),
+                        XNFocusWindow,  FRAME_X_WINDOW(f),
+                        NULL);
+
+       if (xic == 0)
+         XCloseIM (xim);
+      }
+    FRAME_XIC (f) = xic;
+  }
+#endif
+
   f->output_data.x->wm_hints.input = True;
   f->output_data.x->wm_hints.flags |= InputHint;
   XSetWMHints (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
@@ -2672,6 +2704,28 @@ x_window (f)
                     InputOutput, /* class */
                     FRAME_X_DISPLAY_INFO (f)->visual,
                     attribute_mask, &attributes);
+#ifdef HAVE_X_I18N
+  { 
+    XIM xim;
+    XIC xic = NULL;
+
+    xim = XOpenIM (FRAME_X_DISPLAY(f), NULL, NULL, NULL);
+
+    if (xim)
+      {
+       xic = XCreateIC (xim,  
+                        XNInputStyle,   XIMPreeditNothing | XIMStatusNothing,
+                        XNClientWindow, FRAME_X_WINDOW(f),
+                        XNFocusWindow,  FRAME_X_WINDOW(f),
+                        NULL);
+
+       if (!xic)
+         XCloseIM (xim);
+      }
+
+    FRAME_XIC (f) = xic;
+  }
+#endif
 
   validate_x_resource_name ();
 
@@ -3037,6 +3091,8 @@ This function is an internal primitive--use `make-frame' instead.")
                       "menuBar", "MenuBar", number);
   x_default_parameter (f, parms, Qscroll_bar_width, Qnil,
                       "scrollBarWidth", "ScrollBarWidth", number);
+  x_default_parameter (f, parms, Qbuffer_predicate, Qnil,
+                      "bufferPredicate", "BufferPredicate", symbol);
 
   f->output_data.x->parent_desc = FRAME_X_DISPLAY_INFO (f)->root_window;
   window_prompting = x_figure_window_size (f, parms);
@@ -3207,7 +3263,7 @@ even if they match PATTERN and FACE.")
 
       /* Don't die if we get called with a terminal frame.  */
       if (! FRAME_X_P (f))
-       error ("non-X frame used in `x-list-fonts'");
+       error ("Non-X frame used in `x-list-fonts'");
 
       face_id = face_name_id_number (f, face);