changeset 96759:1e2f7aab70ba

* Makefile.in: Undef LIB_STANDARD before defining it to silence warning in case it was defined already. USE @GNUSTEP_MAKEFILES@ rather than envvars. * nsterm.m (ns_term_init): Pass Qt and Qnil rather than YES/NO to ns_default. (applicationShouldTerminate, setValuesFromPanel): Use EQ to compare Lisp_Objects. * nsterm.h (Fx_display_grayscale_p, Fx_display_planes) (ns_defined_color, ns_color_to_lisp): Declare. * nsselect.m (ns_handle_selection_request, ns_handle_selection_clear) (Fns_own_selection_internal): Make the big ugly hack more explicit, so it's accepted even with USE_LISP_UNION_TYPE. * nsmenu.m (ns_update_menubar): Use EQ to compare Lisp_Objects. (update_frame_tool_bar): Remove apparently obsolete tests for non-integerness of f->tool_bar_lines. (windowShouldClose, addButton, clicked, runDialogAt): Make the big ugly hack more explicit, so it's accepted even with USE_LISP_UNION_TYPE. * nsfont.m (nsfont_driver): Use just 0 rather than an invalid cast. (nsfont_open): Don't confuse NULL for Qnil. * nsfns.m (ns_implicitly_set_icon_type): Use EQ to compare Lisp_Objects. * menu.h (find_and_call_menu_selection): * menu.c (find_and_call_menu_selection): Use just int for vector size. (find_and_return_menu_selection): Always return something. * frame.h: Include dispextern.h for Display_Info. (display_x_get_resource): Declare. * configure.in: Extract and substitute GNUSTEP_MAKEFILES.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Thu, 17 Jul 2008 03:33:59 +0000
parents 4962b860277b
children b056a93eb26f
files ChangeLog configure configure.in src/.cvsignore src/ChangeLog src/Makefile.in src/frame.h src/menu.c src/menu.h src/nsfns.m src/nsfont.m src/nsmenu.m src/nsselect.m src/nsterm.h src/nsterm.m
diffstat 15 files changed, 305 insertions(+), 229 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Jul 17 02:36:16 2008 +0000
+++ b/ChangeLog	Thu Jul 17 03:33:59 2008 +0000
@@ -1,3 +1,7 @@
+2008-07-17  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* configure.in: Extract and substitute GNUSTEP_MAKEFILES.
+
 2008-07-16  Adrian Robert <Adrian.B.Robert@gmail.com>
 
 	* configure.in: Change GNUSTEP to NS_IMPL_GNUSTEP, COCOA to
--- a/configure	Thu Jul 17 02:36:16 2008 +0000
+++ b/configure	Thu Jul 17 03:33:59 2008 +0000
@@ -735,6 +735,7 @@
 opsysfile
 carbon_appdir
 ns_appdir
+GNUSTEP_MAKEFILES
 LTLIBOBJS'
 ac_subst_files=''
       ac_precious_vars='build_alias
@@ -9337,6 +9338,7 @@
      NS_IMPL_GNUSTEP=yes
      GNUSTEP_SYSTEM_HEADERS="$(source /etc/GNUstep/GNUstep.conf; echo $GNUSTEP_SYSTEM_HEADERS)"
      GNUSTEP_SYSTEM_LIBRARIES="$(source /etc/GNUstep/GNUstep.conf; echo $GNUSTEP_SYSTEM_LIBRARIES)"
+     GNUSTEP_MAKEFILES="$(source /etc/GNUstep/GNUstep.conf; echo $GNUSTEP_MAKEFILES)"
      CPPFLAGS="$CPPFLAGS -I${GNUSTEP_SYSTEM_HEADERS}"
      CFLAGS="$CFLAGS -I${GNUSTEP_SYSTEM_HEADERS}"
      REAL_CFLAGS="$REAL_CFLAGS -I${GNUSTEP_SYSTEM_HEADERS}"
@@ -16905,6 +16907,7 @@
 # endif
 #endif
 
+#include <limits.h>
 #include <stdlib.h>
 
 #ifdef HAVE_UNISTD_H
@@ -17053,12 +17056,15 @@
      isn't worth using anyway.  */
   alarm (60);
 
-  for (time_t_max = 1; 0 < time_t_max; time_t_max *= 2)
-    continue;
-  time_t_max--;
-  if ((time_t) -1 < 0)
-    for (time_t_min = -1; (time_t) (time_t_min * 2) < 0; time_t_min *= 2)
-      continue;
+  for (;;)
+    {
+      t = (time_t_max << 1) + 1;
+      if (t <= time_t_max)
+	break;
+      time_t_max = t;
+    }
+  time_t_min = - ((time_t) ~ (time_t) 0 == (time_t) -1) - time_t_max;
+
   delta = time_t_max / 997; /* a suitable prime number */
   for (i = 0; i < N_STRINGS; i++)
     {
@@ -17073,10 +17079,12 @@
 	     && mktime_test ((time_t) (60 * 60 * 24))))
 	return 1;
 
-      for (j = 1; 0 < j; j *= 2)
+      for (j = 1; ; j <<= 1)
 	if (! bigtime_test (j))
 	  return 1;
-      if (! bigtime_test (j - 1))
+	else if (INT_MAX / 2 < j)
+	  break;
+      if (! bigtime_test (INT_MAX))
 	return 1;
     }
   return ! (irix_6_4_bug () && spring_forward_gap () && year_2050_test ());
@@ -18985,11 +18993,13 @@
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-#include <stdio.h>
-int
-main ()
-{
-return fseeko (stdin, 0, 0) && (fseeko) (stdin, 0, 0);
+#include <sys/types.h> /* for off_t */
+     #include <stdio.h>
+int
+main ()
+{
+int (*fp) (FILE *, off_t, int) = fseeko;
+     return fseeko (stdin, 0, 0) && fp (stdin, 0, 0);
   ;
   return 0;
 }
@@ -19029,11 +19039,13 @@
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 #define _LARGEFILE_SOURCE 1
-#include <stdio.h>
-int
-main ()
-{
-return fseeko (stdin, 0, 0) && (fseeko) (stdin, 0, 0);
+#include <sys/types.h> /* for off_t */
+     #include <stdio.h>
+int
+main ()
+{
+int (*fp) (FILE *, off_t, int) = fseeko;
+     return fseeko (stdin, 0, 0) && fp (stdin, 0, 0);
   ;
   return 0;
 }
@@ -24171,6 +24183,7 @@
 
 
 
+
 cat >>confdefs.h <<_ACEOF
 #define EMACS_CONFIGURATION "${canonical}"
 _ACEOF
@@ -25193,10 +25206,11 @@
 opsysfile!$opsysfile$ac_delim
 carbon_appdir!$carbon_appdir$ac_delim
 ns_appdir!$ns_appdir$ac_delim
+GNUSTEP_MAKEFILES!$GNUSTEP_MAKEFILES$ac_delim
 LTLIBOBJS!$LTLIBOBJS$ac_delim
 _ACEOF
 
-  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 23; then
+  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 24; then
     break
   elif $ac_last_try; then
     { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
--- a/configure.in	Thu Jul 17 02:36:16 2008 +0000
+++ b/configure.in	Thu Jul 17 03:33:59 2008 +0000
@@ -1234,6 +1234,7 @@
      NS_IMPL_GNUSTEP=yes
      GNUSTEP_SYSTEM_HEADERS="$(source /etc/GNUstep/GNUstep.conf; echo $GNUSTEP_SYSTEM_HEADERS)"
      GNUSTEP_SYSTEM_LIBRARIES="$(source /etc/GNUstep/GNUstep.conf; echo $GNUSTEP_SYSTEM_LIBRARIES)"
+     GNUSTEP_MAKEFILES="$(source /etc/GNUstep/GNUstep.conf; echo $GNUSTEP_MAKEFILES)"
      CPPFLAGS="$CPPFLAGS -I${GNUSTEP_SYSTEM_HEADERS}"
      CFLAGS="$CFLAGS -I${GNUSTEP_SYSTEM_HEADERS}"
      REAL_CFLAGS="$REAL_CFLAGS -I${GNUSTEP_SYSTEM_HEADERS}"
@@ -2471,6 +2472,7 @@
 AC_SUBST(GETLOADAVG_LIBS)
 AC_SUBST(carbon_appdir)
 AC_SUBST(ns_appdir)
+AC_SUBST(GNUSTEP_MAKEFILES)
 
 AC_DEFINE_UNQUOTED(EMACS_CONFIGURATION,  "${canonical}",
 		   [Define to the canonical Emacs configuration name.])
--- a/src/.cvsignore	Thu Jul 17 02:36:16 2008 +0000
+++ b/src/.cvsignore	Thu Jul 17 03:33:59 2008 +0000
@@ -1,5 +1,6 @@
 *-spd
 *.core
+*.d
 *.pdb
 .gdb_history
 Makefile
--- a/src/ChangeLog	Thu Jul 17 02:36:16 2008 +0000
+++ b/src/ChangeLog	Thu Jul 17 03:33:59 2008 +0000
@@ -1,3 +1,35 @@
+2008-07-17  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	Use SDATA.  Follow coding convention of placing operators at
+	beginning of next line rather than end of previous line, and placing
+	spaces around infix operators.
+
+	* Makefile.in: Undef LIB_STANDARD before defining it to silence warning
+	in case it was defined already.
+	USE @GNUSTEP_MAKEFILES@ rather than envvars.
+	* nsterm.m (ns_term_init): Pass Qt and Qnil rather than YES/NO to
+	ns_default.
+	(applicationShouldTerminate, setValuesFromPanel): Use EQ to compare
+	Lisp_Objects.
+	* nsterm.h (Fx_display_grayscale_p, Fx_display_planes)
+	(ns_defined_color, ns_color_to_lisp): Declare.
+	* nsselect.m (ns_handle_selection_request, ns_handle_selection_clear)
+	(Fns_own_selection_internal): Make the big ugly hack more explicit, so
+	it's accepted even with USE_LISP_UNION_TYPE.
+	* nsmenu.m (ns_update_menubar): Use EQ to compare Lisp_Objects.
+	(update_frame_tool_bar): Remove apparently obsolete tests for
+	non-integerness of f->tool_bar_lines.
+	(windowShouldClose, addButton, clicked, runDialogAt): Make the big ugly
+	hack more explicit, so it's accepted even with USE_LISP_UNION_TYPE.
+	* nsfont.m (nsfont_driver): Use just 0 rather than an invalid cast.
+	(nsfont_open): Don't confuse NULL for Qnil.
+	* nsfns.m (ns_implicitly_set_icon_type): Use EQ to compare Lisp_Objects.
+	* menu.h (find_and_call_menu_selection):
+	* menu.c (find_and_call_menu_selection): Use just int for vector size.
+	(find_and_return_menu_selection): Always return something.
+	* frame.h: Include dispextern.h for Display_Info.
+	(display_x_get_resource): Declare.
+
 2008-07-16  Adrian Robert <Adrian.B.Robert@gmail.com>
 
 	* syntax.c: Remove stdio.h include accidentally introduced in
--- a/src/Makefile.in	Thu Jul 17 02:36:16 2008 +0000
+++ b/src/Makefile.in	Thu Jul 17 03:33:59 2008 +0000
@@ -114,6 +114,7 @@
 
 /* Under GNUstep, putting libc on the link line causes problems. */
 #ifdef NS_IMPL_GNUSTEP
+#undef LIB_STANDARD
 #define LIB_STANDARD
 #endif
 
@@ -238,8 +239,8 @@
 /* Pull in stuff from GNUstep-make. */
 FOUNDATION_LIB=gnu
 GUI_LIB=gnu
-include $(GNUSTEP_MAKEFILES)/Additional/base.make
-include $(GNUSTEP_MAKEFILES)/Additional/gui.make
+include @GNUSTEP_MAKEFILES@/Additional/base.make
+include @GNUSTEP_MAKEFILES@/Additional/gui.make
 shared=no
 #endif
 
@@ -899,8 +900,7 @@
   ../lisp/mouse.elc \
   ../lisp/term/x-win.elc \
   ../lisp/term/ns-win.elc \
-  ../lisp/ns-carbon-compat.elc \
-  ../lisp/emacs-lisp/easymenu.elc
+  ../lisp/ns-carbon-compat.elc
 
 /* Construct full set of libraries to be linked.
    Note that SunOS needs -lm to come before -lc; otherwise, you get
--- a/src/frame.h	Thu Jul 17 02:36:16 2008 +0000
+++ b/src/frame.h	Thu Jul 17 03:33:59 2008 +0000
@@ -24,6 +24,8 @@
 #ifndef EMACS_FRAME_H
 #define EMACS_FRAME_H
 
+#include "dispextern.h"
+
 
 /* Miscellanea.  */
 
@@ -1114,6 +1116,13 @@
 
 extern void validate_x_resource_name P_ ((void));
 
+extern Lisp_Object display_x_get_resource (Display_Info *,
+					   Lisp_Object attribute,
+					   Lisp_Object class,
+					   Lisp_Object component,
+					   Lisp_Object subclass);
+
+
 #endif /* HAVE_WINDOW_SYSTEM */
 
 #endif /* not EMACS_FRAME_H */
--- a/src/menu.c	Thu Jul 17 02:36:16 2008 +0000
+++ b/src/menu.c	Thu Jul 17 03:33:59 2008 +0000
@@ -881,7 +881,7 @@
 void
 find_and_call_menu_selection (f, menu_bar_items_used, vector, client_data)
      FRAME_PTR f;
-     EMACS_INT menu_bar_items_used;
+     int menu_bar_items_used;
      Lisp_Object vector;
      void *client_data;
 {
@@ -1023,6 +1023,7 @@
           i += MENU_ITEMS_ITEM_LENGTH;
         }
     }
+  return Qnil;
 }
 #endif
 
--- a/src/menu.h	Thu Jul 17 02:36:16 2008 +0000
+++ b/src/menu.h	Thu Jul 17 03:33:59 2008 +0000
@@ -29,7 +29,7 @@
 #if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NTGUI)
 extern void free_menubar_widget_value_tree P_ ((widget_value *));
 extern void update_submenu_strings P_ ((widget_value *));
-extern void find_and_call_menu_selection P_ ((FRAME_PTR, EMACS_INT,
+extern void find_and_call_menu_selection P_ ((FRAME_PTR, int,
 					      Lisp_Object, void *));
 #endif
 
--- a/src/nsfns.m	Thu Jul 17 02:36:16 2008 +0000
+++ b/src/nsfns.m	Thu Jul 17 03:33:59 2008 +0000
@@ -268,7 +268,7 @@
   dpyinfo = ns_display_list;
 
   if (dpyinfo == 0)
-    error ("OpenStep on %s not responding.\n", XSTRING (name)->data);
+    error ("OpenStep on %s not responding.\n", SDATA (name));
 
   return dpyinfo;
 }
@@ -401,8 +401,8 @@
       if (face)
         {
           col = NS_FACE_BACKGROUND (face);
-          face->background =
-            (EMACS_UINT) [[col colorWithAlphaComponent: alpha] retain];
+          face->background
+	     = (EMACS_UINT) [[col colorWithAlphaComponent: alpha] retain];
           [col release];
 
           update_face_from_frame_parameter (f, Qbackground_color, arg);
@@ -478,11 +478,11 @@
   if ([[view window] miniwindowTitle] &&
       ([[[view window] miniwindowTitle]
              isEqualToString: [NSString stringWithUTF8String:
-                                           XSTRING (arg)->data]]))
+                                           SDATA (arg)]]))
     return;
 
   [[view window] setMiniwindowTitle:
-        [NSString stringWithUTF8String: XSTRING (arg)->data]];
+        [NSString stringWithUTF8String: SDATA (arg)]];
 }
 
 
@@ -527,11 +527,11 @@
   if ([[view window] miniwindowTitle] &&
       ([[[view window] miniwindowTitle]
              isEqualToString: [NSString stringWithUTF8String:
-                                           XSTRING (name)->data]]))
+                                           SDATA (name)]]))
     return;
 
   [[view window] setMiniwindowTitle:
-        [NSString stringWithUTF8String: XSTRING (name)->data]];
+        [NSString stringWithUTF8String: SDATA (name)]];
 }
 
 
@@ -573,10 +573,10 @@
   /* Don't change the name if it's already NAME.  */
   if ([[[view window] title]
             isEqualToString: [NSString stringWithUTF8String:
-                                          XSTRING (name)->data]])
+                                          SDATA (name)]])
     return;
   [[view window] setTitle: [NSString stringWithUTF8String:
-                                        XSTRING (name)->data]];
+                                        SDATA (name)]];
 }
 
 
@@ -660,7 +660,7 @@
   title = FRAME_ICONIFIED_P (f) ? [[[view window] miniwindowTitle] UTF8String]
                                 : [[[view window] title] UTF8String];
 
-  if (title && (! strcmp (title, XSTRING (name)->data)))
+  if (title && (! strcmp (title, SDATA (name))))
     {
       [pool release];
       UNBLOCK_INPUT;
@@ -673,7 +673,7 @@
       /* work around a bug observed on 10.3 where
          setTitleWithRepresentedFilename does not clear out previous state
          if given filename does not exist */
-      NSString *str = [NSString stringWithUTF8String: XSTRING (name)->data];
+      NSString *str = [NSString stringWithUTF8String: SDATA (name)];
       if (![[NSFileManager defaultManager] fileExistsAtPath: str])
         {
           [[view window] setTitleWithRepresentedFilename: @""];
@@ -685,14 +685,14 @@
         }
 #else
       [[view window] setTitleWithRepresentedFilename:
-                         [NSString stringWithUTF8String: XSTRING (name)->data]];
+                         [NSString stringWithUTF8String: SDATA (name)]];
 #endif
       f->name = name;
     }
   else
     {
       [[view window] setMiniwindowTitle:
-            [NSString stringWithUTF8String: XSTRING (name)->data]];
+            [NSString stringWithUTF8String: SDATA (name)]];
     }
   [pool release];
   UNBLOCK_INPUT;
@@ -806,7 +806,7 @@
   BLOCK_INPUT;
   pool = [[NSAutoreleasePool alloc] init];
   if (f->output_data.ns->miniimage
-      && [[NSString stringWithUTF8String: XSTRING (f->name)->data]
+      && [[NSString stringWithUTF8String: SDATA (f->name)]
                isEqualToString: [(NSImage *)f->output_data.ns->miniimage name]])
     {
       [pool release];
@@ -828,10 +828,10 @@
     {
       elt = XCAR (chain);
       /* special case: 't' means go by file type */
-      if (SYMBOLP (elt) && elt == Qt && XSTRING (f->name)->data[0] == '/')
+      if (SYMBOLP (elt) && EQ (elt, Qt) && SDATA (f->name)[0] == '/')
         {
-          NSString *str =
-            [NSString stringWithUTF8String: XSTRING (f->name)->data];
+          NSString *str
+	     = [NSString stringWithUTF8String: SDATA (f->name)];
           if ([[NSFileManager defaultManager] fileExistsAtPath: str])
             image = [[[NSWorkspace sharedWorkspace] iconForFile: str] retain];
         }
@@ -844,7 +844,7 @@
           if (image == nil)
             image = [[NSImage imageNamed:
                                [NSString stringWithUTF8String:
-                                           XSTRING (XCDR (elt))->data]] retain];
+					    SDATA (XCDR (elt))]] retain];
         }
     }
 
@@ -873,7 +873,7 @@
 
   if (!NILP (arg) && SYMBOLP (arg))
     {
-      arg =build_string (XSTRING (XSYMBOL (arg)->xname)->data);
+      arg =build_string (SDATA (SYMBOL_NAME (arg)));
       store_frame_param (f, Qicon_type, arg);
     }
 
@@ -889,7 +889,7 @@
   image = [EmacsImage allocInitFromFile: arg];
   if (image == nil)
     image =[NSImage imageNamed: [NSString stringWithUTF8String:
-                                            XSTRING (arg)->data]];
+                                            SDATA (arg)]];
 
   if (image == nil)
     {
@@ -918,9 +918,9 @@
 {
   char *str;
   if (XTYPE (arg) == Lisp_String)
-    str =XSTRING (arg)->data;
+    str = SDATA (arg);
   else if (XTYPE (arg) == Lisp_Symbol)
-    str =XSTRING (XSYMBOL (arg)->xname)->data;
+    str = SDATA (SYMBOL_NAME (arg));
   else return -1;
   if (!strcmp (str, "box"))	 return filled_box;
   if (!strcmp (str, "hollow"))	 return hollow_box;
@@ -1125,8 +1125,8 @@
      be set.  */
   if (EQ (name, Qunbound) || NILP (name) || (XTYPE (name) != Lisp_String))
     {
-      f->name =
-          build_string ([[[NSProcessInfo processInfo] processName] UTF8String]);
+      f->name
+	 = build_string ([[[NSProcessInfo processInfo] processName] UTF8String]);
       f->explicit_name =0;
     }
   else
@@ -1197,15 +1197,15 @@
 
   /* default scrollbars on right on Mac */
   {
-      Lisp_Object spos = 
+      Lisp_Object spos
 #ifdef NS_IMPL_GNUSTEP
-          Qt;
+          = Qt;
 #else
-          Qright;
+          = Qright;
 #endif
-          x_default_parameter (f, parms, Qvertical_scroll_bars, spos,
-                              "verticalScrollBars", "VerticalScrollBars",
-                              RES_TYPE_SYMBOL);
+      x_default_parameter (f, parms, Qvertical_scroll_bars, spos,
+			   "verticalScrollBars", "VerticalScrollBars",
+			   RES_TYPE_SYMBOL);
   }
   x_default_parameter (f, parms, Qforeground_color, build_string ("Black"),
                       "foreground", "Foreground", RES_TYPE_STRING);
@@ -1236,30 +1236,31 @@
 /*PENDING: other terms seem to get away w/o this complexity.. */
   if (NILP (Fassq (Qwidth, parms)))
     {
-      Lisp_Object value =
-          x_get_arg (dpyinfo, parms, Qwidth, "width", "Width", RES_TYPE_NUMBER);
+      Lisp_Object value
+	 = x_get_arg (dpyinfo, parms, Qwidth, "width", "Width",
+		      RES_TYPE_NUMBER);
       if (! EQ (value, Qunbound))
 	parms = Fcons (Fcons (Qwidth, value), parms);
     }
   if (NILP (Fassq (Qheight, parms)))
     {
-      Lisp_Object value =
-          x_get_arg (dpyinfo, parms, Qheight, "height", "Height",
-                     RES_TYPE_NUMBER);
+      Lisp_Object value
+	 = x_get_arg (dpyinfo, parms, Qheight, "height", "Height",
+		      RES_TYPE_NUMBER);
       if (! EQ (value, Qunbound))
 	parms = Fcons (Fcons (Qheight, value), parms);
     }
   if (NILP (Fassq (Qleft, parms)))
     {
-      Lisp_Object value =
-          x_get_arg (dpyinfo, parms, Qleft, "left", "Left", RES_TYPE_NUMBER);
+      Lisp_Object value
+	 = x_get_arg (dpyinfo, parms, Qleft, "left", "Left", RES_TYPE_NUMBER);
       if (! EQ (value, Qunbound))
 	parms = Fcons (Fcons (Qleft, value), parms);
     }
   if (NILP (Fassq (Qtop, parms)))
     {
-      Lisp_Object value =
-          x_get_arg (dpyinfo, parms, Qtop, "top", "Top", RES_TYPE_NUMBER);
+      Lisp_Object value
+	 = x_get_arg (dpyinfo, parms, Qtop, "top", "Top", RES_TYPE_NUMBER);
       if (! EQ (value, Qunbound))
 	parms = Fcons (Fcons (Qtop, value), parms);
     }
@@ -1277,8 +1278,8 @@
   f->output_data.ns->hand_cursor = [NSCursor pointingHandCursor];
   f->output_data.ns->hourglass_cursor = [NSCursor disappearingItemCursor];
   f->output_data.ns->horizontal_drag_cursor = [NSCursor resizeLeftRightCursor];
-  FRAME_NS_DISPLAY_INFO (f)->vertical_scroll_bar_cursor =
-    [NSCursor arrowCursor];
+  FRAME_NS_DISPLAY_INFO (f)->vertical_scroll_bar_cursor
+     = [NSCursor arrowCursor];
   f->output_data.ns->current_pointer = f->output_data.ns->text_cursor;
 
   [[EmacsView alloc] initFrameFromEmacs: f];
@@ -1435,12 +1436,12 @@
   NSString *fname;
 
   NSString *promptS = NILP (prompt) || !STRINGP (prompt) ? nil :
-    [NSString stringWithUTF8String: XSTRING (prompt)->data];
+    [NSString stringWithUTF8String: SDATA (prompt)];
   NSString *dirS = NILP (dir) || !STRINGP (dir) ?
-    [NSString stringWithUTF8String: XSTRING (current_buffer->directory)->data] :
-    [NSString stringWithUTF8String: XSTRING (dir)->data];
+    [NSString stringWithUTF8String: SDATA (current_buffer->directory)] :
+    [NSString stringWithUTF8String: SDATA (dir)];
   NSString *initS = NILP (init) || !STRINGP (init) ? nil :
-    [NSString stringWithUTF8String: XSTRING (init)->data];
+    [NSString stringWithUTF8String: SDATA (init)];
 
   check_ns ();
 
@@ -1502,12 +1503,12 @@
 /*fprintf (stderr, "ns-get-resource checking resource '%s'\n", SDATA (name)); */
 
   value =[[[NSUserDefaults standardUserDefaults]
-            objectForKey: [NSString stringWithUTF8String: XSTRING (name)->data]]
+            objectForKey: [NSString stringWithUTF8String: SDATA (name)]]
            UTF8String];
 
   if (value)
     return build_string (value);
-/*fprintf (stderr, "Nothing found for NS resource '%s'.\n", XSTRING (name)->data); */
+/*fprintf (stderr, "Nothing found for NS resource '%s'.\n", SDATA (name)); */
   return Qnil;
 }
 
@@ -1521,22 +1522,22 @@
 {
   check_ns ();
   if (NILP (owner))
-    owner =
-        build_string ([[[NSProcessInfo processInfo] processName] UTF8String]);
+    owner
+       = build_string ([[[NSProcessInfo processInfo] processName] UTF8String]);
   CHECK_STRING (owner);
   CHECK_STRING (name);
   if (NILP (value))
     {
       [[NSUserDefaults standardUserDefaults] removeObjectForKey:
-                         [NSString stringWithUTF8String: XSTRING (name)->data]];
+                         [NSString stringWithUTF8String: SDATA (name)]];
     }
   else
     {
       CHECK_STRING (value);
       [[NSUserDefaults standardUserDefaults] setObject:
-                [NSString stringWithUTF8String: XSTRING (value)->data]
+                [NSString stringWithUTF8String: SDATA (value)]
                                         forKey: [NSString stringWithUTF8String:
-                                                         XSTRING (name)->data]];
+                                                         SDATA (name)]];
     }
 
   return Qnil;
@@ -1763,10 +1764,10 @@
     {
       if (!NILP (must_succeed))
         fatal ("OpenStep on %s not responding.\n",
-               XSTRING (display)->data);
+               SDATA (display));
       else
         error ("OpenStep on %s not responding.\n",
-               XSTRING (display)->data);
+               SDATA (display));
     }
 
   /* Register our external input/output types, used for determining
@@ -1858,17 +1859,17 @@
 
 
 DEFUN ("x-list-fonts", Fns_list_fonts, Sns_list_fonts, 1, 4, 0,
-       "Return a list of the names of available fonts matching PATTERN.\n\
-If optional arguments FACE and FRAME are specified, return only fonts\n\
-the same size as FACE on FRAME.\n\
-If optional argument MAX is specified, return at most MAX matches.\n\
-\n\
-PATTERN is a regular expression; FACE is a face name - a symbol.\n\
-\n\
-The return value is a list of strings, suitable as arguments to\n\
-set-face-font.\n\
-\n\
-The font names are _NOT_ X names.")
+       doc: /* Return a list of the names of available fonts matching PATTERN.
+If optional arguments FACE and FRAME are specified, return only fonts
+the same size as FACE on FRAME.
+If optional argument MAX is specified, return at most MAX matches.
+
+PATTERN is a regular expression; FACE is a face name - a symbol.
+
+The return value is a list of strings, suitable as arguments to
+set-face-font.
+
+The font names are _NOT_ X names.  */)
      (pattern, face, frame, max)
      Lisp_Object pattern, face, frame, max;
 {
@@ -1906,7 +1907,7 @@
   for (tem = flist; CONSP (tem); tem = XCDR (tem))
     {
       Lisp_Object fname = XCAR (tem);
-      olist = Fcons (build_string (ns_xlfd_to_fontname (XSTRING (fname)->data)),
+      olist = Fcons (build_string (ns_xlfd_to_fontname (SDATA (fname))),
                     olist);
     }
 
@@ -2039,7 +2040,7 @@
   CHECK_STRING (service);
   check_ns ();
 
-  utfStr = XSTRING (service)->data;
+  utfStr = SDATA (service);
   svcName = [NSString stringWithUTF8String: utfStr];
 
   pb =[NSPasteboard pasteboardWithUniqueName];
@@ -2063,7 +2064,7 @@
   NSString *utfStr;
 
   CHECK_STRING (str);
-  utfStr = [[NSString stringWithUTF8String: XSTRING (str)->data]
+  utfStr = [[NSString stringWithUTF8String: SDATA (str)]
              precomposedStringWithCanonicalMapping];
   return build_string ([utfStr UTF8String]);
 }
@@ -2448,7 +2449,7 @@
   GCPRO4 (string, parms, frame, timeout);
 
   CHECK_STRING (string);
-  str = XSTRING (string)->data;
+  str = SDATA (string);
   f = check_x_frame (frame);
   if (NILP (timeout))
     timeout = make_number (5);
--- a/src/nsfont.m	Thu Jul 17 02:36:16 2008 +0000
+++ b/src/nsfont.m	Thu Jul 17 03:33:59 2008 +0000
@@ -234,7 +234,7 @@
 
 struct font_driver nsfont_driver =
   {
-    (Lisp_Object) NULL,		/* Qns */
+    0,				/* Qns */
     1,				/* case sensitive */
     nsfont_get_cache,
     nsfont_list,
@@ -518,7 +518,7 @@
   font_info = (struct nsfont_info *) XFONT_OBJECT (font_object);
   font = (struct font *)font_info;
   if (!font)
-    return NULL; /*PENDING: this copies w32, but causes a segfault */
+    return Qnil; /*PENDING: this copies w32, but causes a segfault */
 
   if (NSFONT_TRACE)
     {
@@ -571,7 +571,7 @@
       if (!nsfont)
         {
           fprintf (stderr, "*** Emacs.app: unable to load backup font\n");
-          return NULL;
+          return Qnil;
         }
     }
 
@@ -601,7 +601,7 @@
   font_info->metrics = (struct font_metrics *)
     xmalloc (0x100 * sizeof (struct font_metrics *));
   if (!font_info->glyphs || !font_info->metrics)
-    return NULL;
+    return Qnil;
   bzero (font_info->glyphs, 0x100 * sizeof (unsigned short *));
   bzero (font_info->metrics, 0x100 * sizeof (struct font_metrics *));
 
--- a/src/nsmenu.m	Thu Jul 17 02:36:16 2008 +0000
+++ b/src/nsmenu.m	Thu Jul 17 03:33:59 2008 +0000
@@ -401,9 +401,9 @@
         {
           for (i = 0; i<n; i++)
             {
-              string = XVECTOR (items)->contents[4*i+1];
+	      string = AREF (items, 4*i+1);
 
-              if (!string)
+              if (EQ (string, make_number (0))) // FIXME: Why???  --Stef
                 continue;
               if (NILP (string))
                 if (previous_strings[i][0])
@@ -691,10 +691,10 @@
 - (EmacsMenu *)addSubmenuWithTitle: (char *)title forFrame: (struct frame *)f
 {
   NSString *titleStr = [NSString stringWithUTF8String: title];
-  id <NSMenuItem> item =
-    [self addItemWithTitle: titleStr
-                    action: nil /*@selector (menuDown:) */
-             keyEquivalent: @""];
+  id <NSMenuItem> item
+      = [self addItemWithTitle: titleStr
+                        action: nil /*@selector (menuDown:) */
+	         keyEquivalent: @""];
   EmacsMenu *submenu = [[EmacsMenu alloc] initWithTitle: titleStr frame: f];
   [self setSubmenu: submenu forItem: item];
   [submenu release];
@@ -724,8 +724,9 @@
   [NSMenu popUpContextMenu: self withEvent: event forView: view];
   retVal = context_menu_value;
   context_menu_value = 0;
-  return retVal > 0 ?
-    find_and_return_menu_selection (f, keymaps, (void *)retVal) : Qnil;
+  return retVal > 0
+      ? find_and_return_menu_selection (f, keymaps, (void *)retVal)
+      : Qnil;
 }
 
 @end  /* EmacsMenu */
@@ -1061,8 +1062,8 @@
 	  /* If this item has a null value,
 	     make the call_data null so that it won't display a box
 	     when the mouse is on it.  */
-	  wv->call_data =
-            !NILP (def) ? (void *) &XVECTOR (menu_items)->contents[i] : 0;
+	  wv->call_data
+	      = !NILP (def) ? (void *) &XVECTOR (menu_items)->contents[i] : 0;
 	  wv->enabled = !NILP (enable);
 
 	  if (NILP (type))
@@ -1157,9 +1158,6 @@
   int i;
   EmacsToolbar *toolbar = [FRAME_NS_VIEW (f) toolbar];
 
-  if (NILP (f->tool_bar_lines) || !INTEGERP (f->tool_bar_lines))
-    return;
-
   [toolbar clearActive];
 
   /* update EmacsToolbar as in GtkUtils, build items list */
@@ -1294,8 +1292,8 @@
                         helpText: (char *)help enabled: (BOOL)enabled
 {
   /* 1) come up w/identifier */
-  NSString *identifier =
-    [NSString stringWithFormat: @"%u", [img hash]];
+  NSString *identifier
+      = [NSString stringWithFormat: @"%u", [img hash]];
 
   /* 2) create / reuse item */
   NSToolbarItem *item = [identifierToItem objectForKey: identifier];
@@ -1557,7 +1555,7 @@
   NSSize spacing = {SPACER, SPACER};
   NSRect area;
   char this_cmd_name[80];
-  id cell, tem;
+  id cell;
   static NSImageView *imgView;
   static FlippedView *contentView;
 
@@ -1649,7 +1647,7 @@
 
 - (BOOL)windowShouldClose: (id)sender
 {
-  [NSApp stopModalWithCode: Qnil];
+  [NSApp stopModalWithCode: XHASH (Qnil)]; // FIXME: BIG UGLY HACK!!
   return NO;
 }
 
@@ -1693,7 +1691,7 @@
   [cell setTarget: self];
   [cell setAction: @selector (clicked: )];
   [cell setTitle: [NSString stringWithUTF8String: str]];
-  [cell setTag: (int)val];
+  [cell setTag: XHASH (val)];	// FIXME: BIG UGLY HACK!!
   [cell setBordered: YES];
   [cell setEnabled: YES];
 
@@ -1730,14 +1728,14 @@
 - clicked: sender
 {
   NSArray *sellist = nil;
-  Lisp_Object seltag;
+  EMACS_INT seltag;
 
   sellist = [sender selectedCells];
   if ([sellist count]<1) 
     return self;
 
-  seltag = (Lisp_Object)[[sellist objectAtIndex: 0] tag];
-  if (! EQ (seltag, Qundefined))
+  seltag = [[sellist objectAtIndex: 0] tag];
+  if (seltag == XHASH (Qundefined)) // FIXME: BIG UGLY HACK!!
     [NSApp stopModalWithCode: seltag];
   return self;
 }
@@ -1844,7 +1842,11 @@
     }
   [NSApp endModalSession: session];
 
-  return (Lisp_Object)ret;
+  {				// FIXME: BIG UGLY HACK!!!
+      Lisp_Object tmp;
+      *(EMACS_INT*)(&tmp) = ret;
+      return tmp;
+  }
 }
 
 @end
--- a/src/nsselect.m	Thu Jul 17 02:36:16 2008 +0000
+++ b/src/nsselect.m	Thu Jul 17 03:33:59 2008 +0000
@@ -108,15 +108,14 @@
   if (VECTORP (obj))
     {
       int i;
-      int size = XVECTOR (obj)->size;
+      int size = ASIZE (obj);
       Lisp_Object copy;
 
       if (size == 1)
-        return clean_local_selection_data (XVECTOR (obj)->contents [0]);
-      copy = Fmake_vector (size, Qnil);
+        return clean_local_selection_data (AREF (obj, 0));
+      copy = Fmake_vector (make_number (size), Qnil);
       for (i = 0; i < size; i++)
-        XVECTOR (copy)->contents [i]
-          = clean_local_selection_data (XVECTOR (obj)->contents [i]);
+        AREF (copy, i) = clean_local_selection_data (AREF (obj, i));
       return copy;
     }
 
@@ -188,13 +187,13 @@
   CHECK_SYMBOL (target_type);
   handler_fn = Fcdr (Fassq (target_type, Vselection_converter_alist));
   if (!NILP (handler_fn))
-    value =call3 (handler_fn, selection_name, target_type,
+    value = call3 (handler_fn, selection_name, target_type,
                 XCAR (XCDR (local_value)));
   else
-    value =Qnil;
+    value = Qnil;
   unbind_to (count, Qnil);
 
-  check =value;
+  check = value;
   if (CONSP (value) && SYMBOLP (XCAR (value)))
     {
       type = XCAR (value);
@@ -213,9 +212,12 @@
            && NILP (XCDR (XCDR (check))))))
     return value;
 
+  // FIXME: Why `quit' rather than `error'?
   Fsignal (Qquit, Fcons (build_string (
       "invalid data returned by selection-conversion function"),
                         Fcons (handler_fn, Fcons (value, Qnil))));
+  // FIXME: Beware, `quit' can return!!
+  return Qnil;
 }
 
 
@@ -231,15 +233,16 @@
 static void
 ns_handle_selection_request (struct input_event *event)
 {
-  id pb =(id)event->x;
-  NSString *type =(NSString *)event->y;
+  // FIXME: BIG UGLY HACK!!!
+  id pb = (id)*(EMACS_INT*)&(event->x);
+  NSString *type = (NSString *)*(EMACS_INT*)&(event->y);
   Lisp_Object selection_name, selection_data, target_symbol, data;
   Lisp_Object successful_p, rest;
 
-  selection_name =ns_string_to_symbol ([(NSPasteboard *)pb name]);
-  target_symbol =ns_string_to_symbol (type);
+  selection_name = ns_string_to_symbol ([(NSPasteboard *)pb name]);
+  target_symbol = ns_string_to_symbol (type);
   selection_data = assq_no_quit (selection_name, Vselection_alist);
-  successful_p =Qnil;
+  successful_p = Qnil;
 
   if (!NILP (selection_data))
     {
@@ -248,13 +251,13 @@
         {
           if (STRINGP (data))
             ns_string_to_pasteboard_internal (pb, data, type);
-          successful_p =Qt;
+          successful_p = Qt;
         }
     }
 
   if (!EQ (Vns_sent_selection_hooks, Qunbound))
     {
-      for (rest =Vns_sent_selection_hooks;CONSP (rest); rest =Fcdr (rest))
+      for (rest = Vns_sent_selection_hooks; CONSP (rest); rest = Fcdr (rest))
         call3 (Fcar (rest), selection_name, target_symbol, successful_p);
     }
 }
@@ -263,11 +266,11 @@
 static void
 ns_handle_selection_clear (struct input_event *event)
 {
-  id pb = (id)event->x;
+  id pb = (id)*(EMACS_INT*)&(event->x);
   Lisp_Object selection_name, selection_data, rest;
 
-  selection_name =ns_string_to_symbol ([(NSPasteboard *)pb name]);
-  selection_data =assq_no_quit (selection_name, Vselection_alist);
+  selection_name = ns_string_to_symbol ([(NSPasteboard *)pb name]);
+  selection_data = assq_no_quit (selection_name, Vselection_alist);
   if (NILP (selection_data)) return;
 
   if (EQ (selection_data, Fcar (Vselection_alist)))
@@ -281,7 +284,7 @@
 
   if (!EQ (Vns_lost_selection_hooks, Qunbound))
     {
-      for (rest =Vns_lost_selection_hooks;CONSP (rest); rest =Fcdr (rest))
+      for (rest = Vns_lost_selection_hooks;CONSP (rest); rest = Fcdr (rest))
         call1 (Fcar (rest), selection_name);
     }
 }
@@ -384,10 +387,10 @@
       error ("selection-value may not be nil.");
   pb =[NSPasteboard pasteboardWithName: symbol_to_nsstring (selection_name)];
   ns_declare_pasteboard (pb);
-  old_value =assq_no_quit (selection_name, Vselection_alist);
+  old_value = assq_no_quit (selection_name, Vselection_alist);
   new_value = Fcons (selection_name, Fcons (selection_value, Qnil));
   if (NILP (old_value))
-    Vselection_alist =Fcons (new_value, Vselection_alist);
+    Vselection_alist = Fcons (new_value, Vselection_alist);
   else
     Fsetcdr (old_value, Fcdr (new_value));
   /* XXX An evil hack, but a necessary one I fear XXX */
@@ -396,8 +399,8 @@
     ev.kind = SELECTION_REQUEST_EVENT;
     ev.modifiers = 0;
     ev.code = 0;
-    ev.x = (int)pb;
-    ev.y = (int)NSStringPboardType;
+    *(EMACS_INT*)(&(ev.x)) = (EMACS_INT)pb; // FIXME: BIG UGLY HACK!!
+    *(EMACS_INT*)(&(ev.y)) = (EMACS_INT)NSStringPboardType;
     ns_handle_selection_request (&ev);
   }
   return selection_value;
--- a/src/nsterm.h	Thu Jul 17 02:36:16 2008 +0000
+++ b/src/nsterm.h	Thu Jul 17 03:33:59 2008 +0000
@@ -717,6 +717,9 @@
 #define NS_DUMPGLYPH_MOUSEFACE          3
 
 
+EXFUN (Fx_display_grayscale_p, 1);
+EXFUN (Fx_display_planes, 1);
+
 /* In nsfont, called from fontset.c */
 extern void nsfont_make_fontset_for_font (Lisp_Object name,
                                          Lisp_Object font_object);
@@ -747,11 +750,13 @@
 extern Lisp_Object Qnone;
 
 /* XColor defined in dispextern.h (we use color_def->pixel = NSColor id), but
-   this causes an #include snafu, so we can't declare it.
-    extern int ns_defined_color (struct frame *f, char *name, XColor *color_def,
-                                int alloc); */
+   this causes an #include snafu, so we can't declare it.  */
+extern int
+ns_defined_color (struct frame *f, char *name, XColor *color_def, int alloc,
+                  char makeIndex);
 
 #ifdef __OBJC__
+extern Lisp_Object ns_color_to_lisp (NSColor *col);
 extern int ns_lisp_to_color (Lisp_Object color, NSColor **col);
 extern NSColor *ns_lookup_indexed_color (unsigned long idx, struct frame *f);
 extern unsigned long ns_index_color (NSColor *color, struct frame *f);
--- a/src/nsterm.m	Thu Jul 17 02:36:16 2008 +0000
+++ b/src/nsterm.m	Thu Jul 17 03:33:59 2008 +0000
@@ -367,10 +367,10 @@
             if (isDir)
               {
                 if ([resourcePaths length] > 0)
-                  resourcePaths =
-                    [resourcePaths stringByAppendingString: pathSeparator];
-                resourcePaths =
-                  [resourcePaths stringByAppendingString: resourcePath];
+                  resourcePaths
+		    = [resourcePaths stringByAppendingString: pathSeparator];
+                resourcePaths
+		  = [resourcePaths stringByAppendingString: resourcePath];
               }
         }
       if ([resourcePaths length] > 0)
@@ -391,10 +391,10 @@
             if (isDir)
               {
                 if ([resourcePaths length] > 0)
-                  resourcePaths =
-                    [resourcePaths stringByAppendingString: pathSeparator];
-                resourcePaths =
-                  [resourcePaths stringByAppendingString: resourcePath];
+                  resourcePaths
+		    = [resourcePaths stringByAppendingString: pathSeparator];
+                resourcePaths
+		  = [resourcePaths stringByAppendingString: resourcePath];
               }
         }
       if ([resourcePaths length] > 0)
@@ -949,8 +949,8 @@
   NSTRACE (ns_frame_rehighlight);
   if (dpyinfo->ns_focus_frame)
     {
-      dpyinfo->ns_highlight_frame =
-        (FRAMEP (FRAME_FOCUS_FRAME (dpyinfo->ns_focus_frame))
+      dpyinfo->ns_highlight_frame
+	= (FRAMEP (FRAME_FOCUS_FRAME (dpyinfo->ns_focus_frame))
            ? XFRAME (FRAME_FOCUS_FRAME (dpyinfo->ns_focus_frame))
            : dpyinfo->ns_focus_frame);
       if (!FRAME_LIVE_P (dpyinfo->ns_highlight_frame))
@@ -1161,10 +1161,10 @@
     /* PENDING: GNUstep has not yet implemented the first method below, added
                 in Panther, however the second is incorrect under Cocoa. */
 #ifdef NS_IMPL_GNUSTEP
-    FRAME_NS_TOOLBAR_HEIGHT (f) =
-      NSHeight ([NSWindow frameRectForContentRect: NSMakeRect (0, 0, 0, 0)
-                                       styleMask: [window styleMask]])
-          - FRAME_NS_TITLEBAR_HEIGHT (f);
+    FRAME_NS_TOOLBAR_HEIGHT (f)
+      = NSHeight ([NSWindow frameRectForContentRect: NSMakeRect (0, 0, 0, 0)
+			    styleMask: [window styleMask]])
+        - FRAME_NS_TITLEBAR_HEIGHT (f);
 #else
     FRAME_NS_TOOLBAR_HEIGHT (f) = 32;
       /* actually get wrong result here if toolbar not yet displayed
@@ -1260,8 +1260,8 @@
     {
       color_table->size = NS_COLOR_CAPACITY;
       color_table->avail = 1; /* skip idx=0 as marker */
-      color_table->colors =
-        (NSColor **)xmalloc (color_table->size * sizeof (NSColor *));
+      color_table->colors
+	= (NSColor **)xmalloc (color_table->size * sizeof (NSColor *));
       color_table->empty_indices = [[NSMutableSet alloc] init];
     }
 
@@ -1289,9 +1289,9 @@
       if (color_table->avail == color_table->size)
         {
           color_table->size += NS_COLOR_CAPACITY;
-          color_table->colors = 
-            (NSColor **)xrealloc (color_table->colors,
-                                  color_table->size * sizeof (NSColor *));
+          color_table->colors
+	    = (NSColor **)xrealloc (color_table->colors,
+				    color_table->size * sizeof (NSColor *));
         }
       idx = color_table->avail++;
       index = [NSNumber numberWithUnsignedInt: idx];
@@ -1590,9 +1590,9 @@
   color_def->blue  = b * 256;
 
   if (!makeIndex)
-    color_def->pixel =
-      ARGB_TO_ULONG((int)(a*256),
-                    color_def->red, color_def->green, color_def->blue);
+    color_def->pixel
+      = ARGB_TO_ULONG((int)(a*256),
+		      color_def->red, color_def->green, color_def->blue);
 
   return 1;
 }
@@ -1945,8 +1945,8 @@
   {
     /* clip out the resize handle */
     NSWindow *window = [FRAME_NS_VIEW (f) window];
-    NSRect ir =
-      [view convertRect: ns_resize_handle_rect (window) fromView: nil];
+    NSRect ir
+      = [view convertRect: ns_resize_handle_rect (window) fromView: nil];
 
     ir = NSIntersectionRect (r, ir);
     if (NSIsEmptyRect (ir))
@@ -2137,8 +2137,9 @@
 
       font->driver->text_extents (font, codes, 2, &metrics);
       s->left_overhang = -metrics.lbearing;
-      s->right_overhang =
-        metrics.rbearing > metrics.width ? metrics.rbearing - metrics.width : 0;
+      s->right_overhang
+	= metrics.rbearing > metrics.width
+	? metrics.rbearing - metrics.width : 0;
     }
   else
     {
@@ -2173,11 +2174,11 @@
   /* NS-specific: move internal border inside fringe */
   int x = p->bx < 0 ? p->x : p->bx;
   int wd = p->bx < 0 ? p->wd : p->nx;
-  BOOL fringeOnVeryLeft =
-      x - WINDOW_LEFT_SCROLL_BAR_COLS (w) * WINDOW_FRAME_COLUMN_WIDTH (w)
+  BOOL fringeOnVeryLeft
+    = x - WINDOW_LEFT_SCROLL_BAR_COLS (w) * WINDOW_FRAME_COLUMN_WIDTH (w)
       - FRAME_INTERNAL_BORDER_WIDTH (f) < 10;
-  BOOL fringeOnVeryRight =
-      FRAME_PIXEL_WIDTH (f) - x - wd - FRAME_INTERNAL_BORDER_WIDTH (f)
+  BOOL fringeOnVeryRight
+    = FRAME_PIXEL_WIDTH (f) - x - wd - FRAME_INTERNAL_BORDER_WIDTH (f)
       - WINDOW_RIGHT_SCROLL_BAR_COLS (w) * WINDOW_FRAME_COLUMN_WIDTH (w) < 10;
   int xAdjust = FRAME_INTERNAL_BORDER_WIDTH (f) *
     (fringeOnVeryLeft ? -1 : (fringeOnVeryRight ? 1 : 0));
@@ -2185,8 +2186,8 @@
   /* grow bimgs if needed */
   if (nBimgs < max_used_fringe_bitmap)
     {
-      EmacsImage **newBimgs =
-        xmalloc (max_used_fringe_bitmap * sizeof (EmacsImage *));
+      EmacsImage **newBimgs
+	= xmalloc (max_used_fringe_bitmap * sizeof (EmacsImage *));
       bzero (newBimgs, max_used_fringe_bitmap * sizeof (EmacsImage *));
 
       if (nBimgs)
@@ -2321,8 +2322,8 @@
   /* PENDING: 23: use emacs stored f->cursor_type instead of ns-specific */
   oldCursorType = FRAME_CURSOR (f);
   cursorType = FRAME_CURSOR (f) = FRAME_NEW_CURSOR (f);
-  f->output_data.ns->current_cursor_color =
-     f->output_data.ns->desired_cursor_color;
+  f->output_data.ns->current_cursor_color
+    = f->output_data.ns->desired_cursor_color;
 
   /* PENDING: only needed in rare cases with last-resort font in HELLO..
      should we do this more efficiently? */
@@ -3192,10 +3193,10 @@
       cursor_blink_entry = 0;
       if (dpyinfo->ns_highlight_frame)
         {
-          Lisp_Object tem = 
-            get_frame_param (dpyinfo->ns_highlight_frame, Qcursor_type);
-          dpyinfo->ns_highlight_frame->output_data.ns->desired_cursor =
-            ns_lisp_to_cursor_type (tem);
+          Lisp_Object tem
+	    = get_frame_param (dpyinfo->ns_highlight_frame, Qcursor_type);
+          dpyinfo->ns_highlight_frame->output_data.ns->desired_cursor
+	    = ns_lisp_to_cursor_type (tem);
         }
     }
 
@@ -3543,8 +3544,8 @@
                                                  NSColorSpaceFromDepth (depth)];
     dpyinfo->n_planes = NSBitsPerPixelFromDepth (depth);
     dpyinfo->image_cache = make_image_cache ();
-    dpyinfo->color_table =
-      (struct ns_color_table *)xmalloc (sizeof (struct ns_color_table));
+    dpyinfo->color_table
+      = (struct ns_color_table *)xmalloc (sizeof (struct ns_color_table));
     dpyinfo->color_table->colors = NULL;
     dpyinfo->root_window = 42; /* a placeholder.. */
 
@@ -3799,15 +3800,15 @@
   ns_default ("ExpandSpace", &ns_expand_space,
              make_float (0.5), make_float (0.0), YES, NO);
   ns_default ("GSFontAntiAlias", &ns_antialias_text,
-             YES, NO, NO, NO);
+             Qt, Qnil, NO, NO);
   tmp = Qnil;
   ns_default ("AppleAntiAliasingThreshold", &tmp,
              make_float (10.0), make_float (6.0), YES, NO);
   ns_antialias_threshold = NILP (tmp) ? 10.0 : XFLOATINT (tmp);
   ns_default ("UseQuickdrawSmoothing", &ns_use_qd_smoothing,
-             YES, NO, NO, NO);
+             Qt, Qnil, NO, NO);
   ns_default ("UseSystemHighlightColor", &ns_use_system_highlight_color,
-             YES, NO, NO, NO);
+             Qt, Qnil, NO, NO);
   if (ns_use_system_highlight_color == YES)
     {
       ns_selection_color = [[NSUserDefaults standardUserDefaults]
@@ -3829,17 +3830,17 @@
       {
         /* first try data_dir, then invocation-dir
            and finally source-directory/etc */
-        tem1 = tem =
-          Fexpand_file_name (build_string ("Emacs.clr"), Vdata_directory);
+        tem1 = tem
+	  = Fexpand_file_name (build_string ("Emacs.clr"), Vdata_directory);
         if (NILP (Ffile_exists_p (tem)))
           {
             tem = Fexpand_file_name (build_string ("Emacs.clr"),
                                      Vinvocation_directory);
             if (NILP (Ffile_exists_p (tem)))
               {
-                Lisp_Object newdir =
-                  Fexpand_file_name (build_string ("etc/"),
-                                     Vsource_directory);
+                Lisp_Object newdir
+		  = Fexpand_file_name (build_string ("etc/"),
+				       Vsource_directory);
                 tem = Fexpand_file_name (build_string ("Emacs.clr"),
                                          newdir);
               }
@@ -4211,8 +4212,8 @@
       Fcons (build_string ("Cancel"), Qnil),
       Fcons (build_string ("Save and Exit"), Qt));
   Lisp_Object res = ns_popup_dialog (Qt, contents, Qnil);
-fprintf (stderr, "res = %d\n", res ==Qt);
-  if (res == Qt)
+fprintf (stderr, "res = %d\n", EQ (res, Qt)); // FIXME
+  if (EQ (res, Qt))
     {
       Feval (Fcons (intern ("save-buffers-kill-emacs"), Qnil));
       return NSTerminateNow;
@@ -4671,8 +4672,8 @@
       if (code == 0x2DC)
         code = '~'; /* 0x7E */
       emacs_event->modifiers = 0;
-      emacs_event->kind =
-        code > 0xFF ? MULTIBYTE_CHAR_KEYSTROKE_EVENT : ASCII_KEYSTROKE_EVENT;
+      emacs_event->kind
+	= code > 0xFF ? MULTIBYTE_CHAR_KEYSTROKE_EVENT : ASCII_KEYSTROKE_EVENT;
       emacs_event->code = code;
       EV_TRAILER ((id)nil);
     }
@@ -4920,8 +4921,8 @@
   NSTRACE (mouseMoved);
 
   last_mouse_movement_time = EV_TIMESTAMP (e);
-  last_mouse_motion_position =
-    [self convertPoint: [e locationInWindow] fromView: nil];
+  last_mouse_motion_position
+    = [self convertPoint: [e locationInWindow] fromView: nil];
 
   /* update any mouse face */
   if (dpyinfo->mouse_face_hidden)
@@ -5361,8 +5362,8 @@
 {
   NSPoint p = [self convertPoint: [theEvent locationInWindow] fromView: nil];
   NSRect r;
-  struct ns_display_info *dpyinfo =
-      emacsframe ? FRAME_NS_DISPLAY_INFO (emacsframe) : NULL;
+  struct ns_display_info *dpyinfo
+    = emacsframe ? FRAME_NS_DISPLAY_INFO (emacsframe) : NULL;
 
   NSTRACE (mouseExited);
 
@@ -5924,14 +5925,14 @@
         if (inKnob)
           return self;
 
-        scroll_repeat_entry =
-          [[NSTimer scheduledTimerWithTimeInterval:
-                      SCROLL_BAR_CONTINUOUS_DELAY
+        scroll_repeat_entry
+	  = [[NSTimer scheduledTimerWithTimeInterval:
+			SCROLL_BAR_CONTINUOUS_DELAY
                                             target: self
                                           selector: @selector (repeatScroll:)
                                           userInfo: 0
                                            repeats: YES]
-            retain];
+	      retain];
     }
 
   [self sendScrollEventAtLoc: 0 fromEvent: e];
@@ -5975,13 +5976,13 @@
       pos = 0;      /* ignored */
 
       /* set a timer to repeat, as we can't let superclass do this modally */
-      scroll_repeat_entry =
-        [[NSTimer scheduledTimerWithTimeInterval: 0.5
-                                          target: self
-                                        selector: @selector (repeatScroll:)
-                                        userInfo: 0
-                                         repeats: YES]
-          retain];
+      scroll_repeat_entry
+	= [[NSTimer scheduledTimerWithTimeInterval: 0.5
+                                            target: self
+                                          selector: @selector (repeatScroll:)
+                                          userInfo: 0
+                                           repeats: YES]
+	    retain];
     }
   else
     {
@@ -6133,8 +6134,8 @@
 
 - (void) setPanelFromValues
 {
-  int cursorType =
-    ns_lisp_to_cursor_type (get_frame_param (frame, Qcursor_type));
+  int cursorType
+    = ns_lisp_to_cursor_type (get_frame_param (frame, Qcursor_type));
   prevExpandSpace = XFLOATINT (ns_expand_space);
   prevBlinkRate = NILP (ns_cursor_blink_rate)
     ? 0 : XFLOATINT (ns_cursor_blink_rate);
@@ -6199,7 +6200,7 @@
           ns_cursor_blink_rate = make_float (blinkRate);
           ns_cursor_blink_mode = Qt;
         }
-      if (ns_cursor_blink_mode != old_cursor_blink_mode)
+      if (!EQ (ns_cursor_blink_mode, old_cursor_blink_mode))
           Feval (Fcons (intern ("blink-cursor-mode"), Qnil));
 
       if (blinkRate != 0.0 && prevBlinkRate != 0.0)
@@ -6210,18 +6211,18 @@
           cursor_blink_entry = 0;
           if (dpyinfo->ns_highlight_frame)
             {
-              Lisp_Object tem =
-                get_frame_param (dpyinfo->ns_highlight_frame, Qcursor_type);
-              dpyinfo->ns_highlight_frame->output_data.ns->desired_cursor =
-                ns_lisp_to_cursor_type (tem);
+              Lisp_Object tem
+		= get_frame_param (dpyinfo->ns_highlight_frame, Qcursor_type);
+              dpyinfo->ns_highlight_frame->output_data.ns->desired_cursor
+		= ns_lisp_to_cursor_type (tem);
             }
         }
       prevBlinkRate = blinkRate;
     }
-  FRAME_NEW_CURSOR (frame) =
-                         (cursorTag == 1 ? filled_box :
-                          (cursorTag == 2 ? bar :
-                           (cursorTag == 3 ? underscore : hollow_box)));
+  FRAME_NEW_CURSOR (frame)
+    = (cursorTag == 1 ? filled_box
+       : cursorTag == 2 ? bar
+       : cursorTag == 3 ? underscore : hollow_box);
   store_frame_param (frame, Qcursor_type,
                     ns_cursor_type_to_lisp (FRAME_NEW_CURSOR (frame)));
   ns_alternate_modifier = ns_mod_to_lisp (altTag);
@@ -6446,14 +6447,15 @@
           synthItalFont = NULL;
           while (membInfo = [senum nextObject])
             {
-              xlfdName =
-                ns_fontname_to_xlfd ([[membInfo objectAtIndex: 0] UTF8String]);
+              xlfdName
+		= ns_fontname_to_xlfd ([[membInfo objectAtIndex: 0]
+					 UTF8String]);
               list = Fcons (build_string (xlfdName), list);
               if (!synthItalFont)
                 {
-                  NSString *synthName =
-                    [[membInfo objectAtIndex: 0]
-                      stringByAppendingString: @"-synthItal"];
+                  NSString *synthName
+		    = [[membInfo objectAtIndex: 0]
+			stringByAppendingString: @"-synthItal"];
                   synthItalFont = [synthName UTF8String];
                 }
               else if ([[membInfo objectAtIndex: 3] intValue]