? nextstep
? remake
? update2.log
? admin/unidata/unidata.txt
? etc/Emacs.clr
? etc/OTHER.EMACSES
? etc/Xkeymap.txt
? etc/emacs.xbm
? etc/gnu.xpm
? etc/ms-7bkermit
? etc/ulimit.hack
? etc/images/gnus/bar.xbm
? etc/images/gnus/bar.xpm
? etc/images/gnus/dead.xpm
? etc/images/gnus/reverse-smile.xpm
? lib-src/mac-fix-env.m
? lisp/mic-paren.el
? lisp/ns-grabenv.el
? lisp/ns-mark-nav.el
? lisp/tumme.el
? lisp/erc/erc-nicklist.el
? lisp/net/tramp-util.el
? lisp/net/tramp-vc.el
? lisp/term/ns-win.el
? lispintro/Makefile
? lispref/Makefile
? man/Makefile
? man/back.texi
? man/ns-emacs.texi
? nt/icons/emacs21.ico
? nt/icons/sink.ico
? oldXMenu/Imakefile
? src/epaths.h-orig
? src/font.font
? src/nsfns.m
? src/nsfont
? src/nsfont.m
? src/nsgui.h
? src/nsimage.m
? src/nsmenu.m
? src/nsmenu_common.c
? src/nsselect.m
? src/nsterm.h
? src/nsterm.m
? src/remake
? src/bitmaps/stipple.png
? src/s/umips.h
Index: Makefile.in
===================================================================
RCS file: /cvsroot/emacs/emacs/Makefile.in,v
retrieving revision 1.281.2.29
diff -u -r1.281.2.29 Makefile.in
--- Makefile.in	11 Nov 2007 00:56:16 -0000	1.281.2.29
+++ Makefile.in	22 Nov 2007 11:51:54 -0000
@@ -140,7 +140,7 @@
 infodir=@infodir@
 INFO_FILES=ada-mode autotype calc ccmode cl dired-x ebrowse ediff efaq	\
            eintr elisp emacs emacs-mime erc eshell eudc flymake forms	\
-           gnus idlwave info message mh-e newsticker org pcl-cvs pgg	\
+           gnus idlwave info message mh-e newsticker ns-emacs org pcl-cvs pgg	\
            rcirc reftex remember sc ses sieve speedbar tramp vip viper	\
            widget woman smtpmail url
 
@@ -170,6 +170,9 @@
 # Location to install Emacs.app on Mac OS X
 carbon_appdir=@carbon_appdir@
 
+# Location to install Emacs.app under NeXT/Open/GNUstep / Cocoa
+ns_appdir=@ns_appdir@
+
 # ==================== Emacs-specific directories ====================
 
 # These variables hold the values Emacs will actually use.  They are
@@ -406,6 +409,14 @@
 		(cd $(DESTDIR)${carbon_appdir}/Emacs.app; umask 022; tar -xvf - \
 			&& cat > /dev/null))) || exit 1; \
 	fi
+	if test "${ns_appdir}" != ""; then \
+	  umask 022; mkdir -p ${ns_appdir}/Emacs.app; \
+	  (cd nextstep/build/Emacs.app; (tar -chf - . | \
+		(cd ${ns_appdir}/Emacs.app; umask 022; tar -xvf - \
+			&& cat > /dev/null))) || exit 1; \
+	  ( cd site-lisp ; tar chf - . ) | \
+	      ( cd ${datadir}/$(EMACSFULL)/site-lisp ; tar xf - ) \
+	fi
 
 ### Install the files that are machine-independent.
 ### Most of them come straight from the distribution;
@@ -674,6 +685,7 @@
 	-(cd doc/lispref &&   $(MAKE) $(MFLAGS) clean)
 	-(cd doc/lispintro &&   $(MAKE) $(MFLAGS) clean)
 	(cd leim;     $(MAKE) $(MFLAGS) clean)
+	(cd etc;     $(MAKE) $(MFLAGS) clean)
 
 ### `distclean'
 ###      Delete all files from the current directory that are created by
Index: configure.in
===================================================================
RCS file: /cvsroot/emacs/emacs/configure.in,v
retrieving revision 1.351.2.56
diff -u -r1.351.2.56 configure.in
--- configure.in	11 Nov 2007 00:56:16 -0000	1.351.2.56
+++ configure.in	22 Nov 2007 11:52:39 -0000
@@ -23,7 +23,7 @@
 dnl  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 dnl  Boston, MA 02110-1301, USA.
 
-AC_PREREQ(2.61)dnl
+dnl AC_PREREQ(2.61)dnl
 AC_INIT(src/lisp.h)
 AC_CONFIG_HEADER(src/config.h:src/config.in)
 
@@ -120,6 +120,22 @@
 EMACS_ARG_N([xaw3d],[don't use Xaw3d])
 EMACS_ARG_N([xim],[don't use X11 XIM])
 EMACS_ARG_N([carbon],[don't use Carbon GUI on Mac OS X])
+EMACS_ARG_Y([ns],[use nextstep (Cocoa or GNUstep) windowing system])
+
+AC_ARG_ENABLE(ns-app,
+[[  --enable-ns-app[=DIR]  [DIR=/Applications]
+                          specify install directory for Emacs.app under NS]],
+[ ns_appdir_x=${enableval}])
+
+AC_ARG_ENABLE(gnustep,
+[[  --enable-gnustep[=DIR]  [DIR=/usr/lib/GNUstep/System]
+                          specify system root for GNUstep toolkit under NS]],
+[ GNUSTEP_SYSROOT=${enableval}])
+
+AC_ARG_ENABLE(cocoa-experimental-ctrl-g,
+[  --enable-cocoa-experimental-ctrl-g        enable experimental improved ctrl-g recognition],
+   EN_COCOA_EXPERIMENTAL_CTRL_G=yes,
+   EN_COCOA_EXPERIMENTAL_CTRL_G=no)
 
 AC_ARG_ENABLE(carbon-app,
 [AS_HELP_STRING([--enable-carbon-app@<:@=DIR@:>@],
@@ -241,7 +257,7 @@
 case "${canonical}" in
 
   ## FreeBSD ports
-  *-*-freebsd* )
+  *-*-*freebsd* )
     opsys=freebsd
     case "${canonical}" in
       alpha*-*-freebsd*)	machine=alpha ;;
@@ -249,7 +265,8 @@
       sparc64-*-freebsd*)	machine=sparc ;;
       powerpc-*-freebsd*)	machine=macppc ;;
       i[3456]86-*-freebsd*)	machine=intel386 ;;
-      amd64-*-freebsd*|x86_64-*-freebsd*) machine=amdx86-64 ;;
+      amd64-*-*freebsd*|x86_64-*-*freebsd*) machine=amdx86-64 ;;
+      sparc-*-freebsd*)         machine=sparc ;;
     esac
   ;;
 
@@ -1884,6 +1901,46 @@
   window_system=mac
 fi
 
+HAVE_NS=no
+COCOA=no
+GNUSTEP=no
+tmp_CPPFLAGS="$CPPFLAGS"
+tmp_CFLAGS="$CFLAGS"
+CPPFLAGS="$CPPFLAGS -x objective-c"
+CFLAGS="$CFLAGS -x objective-c"
+if test "${GNUSTEP_SYSROOT+set}" = set; then
+   CPPFLAGS="$CPPFLAGS -I${GNUSTEP_SYSROOT}/Library/Headers"
+   CFLAGS="$CFLAGS -I${GNUSTEP_SYSROOT}/Library/Headers"
+fi
+if test "${with_ns}" != no; then
+  AC_CHECK_HEADER(AppKit/AppKit.h, HAVE_NS=yes)
+fi
+if test "${window_system}" = x11 && test "${HAVE_NS}" = yes; then
+  if test "${with_ns+set}" != set \
+     && test "${ns_appdir_x+set}" != set; then
+    HAVE_NS=no
+  fi
+fi
+
+if test "${window_system}" = mac && test "${HAVE_NS}" = yes; then
+  if test "${with_ns+set}" != set \
+     && test "${ns_appdir_x+set}" != set; then
+    HAVE_NS=no
+  else
+    HAVE_CARBON=no
+  fi
+fi
+if test "${HAVE_NS}" = yes; then
+  window_system=nextstep
+  if test "${opsys}" = darwin; then
+     COCOA=yes
+  else
+     GNUSTEP=yes
+  fi
+fi
+CFLAGS="$tmp_CFLAGS"
+CPPFLAGS="$tmp_CPPFLAGS"
+
 case "${window_system}" in
   x11 )
     HAVE_X_WINDOWS=yes
@@ -1907,7 +1964,7 @@
           ;;
     esac
   ;;
-  mac | none )
+  nextstep | mac | none )
     HAVE_X_WINDOWS=no
     HAVE_X11=no
     USE_X_TOOLKIT=none
@@ -2403,6 +2460,9 @@
   elif test "${HAVE_CARBON}" = "yes"; then
     AC_DEFINE(USE_TOOLKIT_SCROLL_BARS)
     USE_TOOLKIT_SCROLL_BARS=yes
+  elif test "${HAVE_NS}" = "yes"; then
+    AC_DEFINE(USE_TOOLKIT_SCROLL_BARS)
+    USE_TOOLKIT_SCROLL_BARS=yes
   fi
 fi
 
@@ -2708,6 +2768,30 @@
   # We also have mouse menus.
   HAVE_MENUS=yes
 fi
+### Use NeXTstep API to implement GUI.
+if test "${HAVE_NS}" = "yes"; then
+  AC_DEFINE(HAVE_NS, 1, [Define to 1 if you are using the NeXTstep API, either GNUstep or Cocoa on Mac OS X.])
+  ## Specify the install directory
+  ns_appdir=
+  if test "${ns_appdir_x}" != ""; then
+    case ${ns_appdir_x} in
+      y | ye | yes)  ns_appdir=/Applications ;;
+      * ) ns_appdir=${ns_appdir_x} ;;
+    esac
+  fi
+  if test "${COCOA}" = "yes"; then
+    AC_DEFINE(COCOA, 1, [Define to 1 if you are using NS windowing under MacOS X.])
+  fi
+  if test "${EN_COCOA_EXPERIMENTAL_CTRL_G}" = "yes"; then
+    AC_DEFINE(COCOA_EXPERIMENTAL_CTRL_G, 1, [Define to 1 if you are trying experimental enhanced Ctrl-g support using NS windowing under MacOS X.])
+  fi
+  if test "${GNUSTEP}" = "yes"; then
+    AC_DEFINE(GNUSTEP, 1, [Define to 1 if you are using NS windowing under GNUstep.])
+  fi
+  # We also have mouse menus.
+  HAVE_MENUS=yes
+fi
+
 
 ### Use session management (-lSM -lICE) if available
 HAVE_X_SM=no
@@ -3098,6 +3182,8 @@
 AC_SUBST(opsysfile)
 AC_SUBST(GETLOADAVG_LIBS)
 AC_SUBST(carbon_appdir)
+AC_SUBST(ns_appdir)
+AC_SUBST(GNUSTEP_SYSROOT)
 
 AC_DEFINE_UNQUOTED(EMACS_CONFIGURATION,  "${canonical}",
 		   [Define to the canonical Emacs configuration name.])
@@ -3187,13 +3273,22 @@
 ])dnl
 
 AH_BOTTOM([
-/* If we're using any sort of window system, define some consequences.  */
+/* If we're using X11, define some consequences.  */
 #ifdef HAVE_X_WINDOWS
 #define HAVE_WINDOW_SYSTEM
 #define MULTI_KBOARD
 #define HAVE_MOUSE
 #endif
 
+/* Likewise if we're using the Carbon or NeXTStep APIs on Mac OS X. */
+#ifdef HAVE_CARBON || defined(HAVE_NS)
+#define HAVE_WINDOW_SYSTEM
+#define HAVE_MOUSE
+#endif
+#ifdef HAVE_NS
+#define MULTI_KBOARD
+#endif
+
 /* Multi-tty support relies on MULTI_KBOARD.  It seems safe to turn it
    on unconditionally.  Note that src/s/darwin.h disables this at
    present.  */
@@ -3201,13 +3296,6 @@
 #define MULTI_KBOARD
 #endif
 
-/* If we're using the Carbon API on Mac OS X, define a few more
-   variables as well.  */
-#ifdef HAVE_CARBON
-#define HAVE_WINDOW_SYSTEM
-#define HAVE_MOUSE
-#endif
-
 /* Define USER_FULL_NAME to return a string
    that is the user's full name.
    It can assume that the variable `pw'
Index: lib-src/.cvsignore
===================================================================
RCS file: /cvsroot/emacs/emacs/lib-src/.cvsignore,v
retrieving revision 1.7.8.4
diff -u -r1.7.8.4 .cvsignore
--- lib-src/.cvsignore	1 Jan 2007 03:21:02 -0000	1.7.8.4
+++ lib-src/.cvsignore	22 Nov 2007 11:52:41 -0000
@@ -11,6 +11,7 @@
 fakemail
 getopt.h
 hexl
+mac-fix-env
 make-docfile
 movemail
 obj
Index: lib-src/Makefile.in
===================================================================
RCS file: /cvsroot/emacs/emacs/lib-src/Makefile.in,v
retrieving revision 1.136.4.16
diff -u -r1.136.4.16 Makefile.in
--- lib-src/Makefile.in	11 Oct 2007 16:21:30 -0000	1.136.4.16
+++ lib-src/Makefile.in	22 Nov 2007 11:52:42 -0000
@@ -146,6 +146,23 @@
 #define NOT_C_CODE
 #include "../src/config.h"
 
+#if defined(COCOA)
+/* Build these programs as universal binaries. */
+CFLAGS := $(CFLAGS) -universal
+/* Add mac-fix-env for OS X systems running NS version. */
+INSTALLABLES = etags${EXEEXT} ctags${EXEEXT} emacsclient${EXEEXT} b2m${EXEEXT} ebrowse${EXEEXT} mac-fix-env${EXEEXT}
+#endif
+
+/* Some platforms that the GNUstep port runs on put strip options in
+   INSTALL_PROGRAM which cause errors.  But, not being sure all other
+   platforms are setting this, we will only use the alternative
+   INSTALL_SCRIPT variable on GNUstep/Cocoa builds. */
+#ifndef HAVE_NS
+INSTALL_SCRIPT = @INSTALL_PROGRAM@
+#else
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+#endif
+
 /* Some machines don\'t find the standard C libraries in the usual place.  */
 #ifndef ORDINARY_LINK
 #ifndef LIB_STANDARD_LIBSRC
@@ -255,12 +272,22 @@
 BASE_CFLAGS = C_SWITCH_SYSTEM C_SWITCH_MACHINE -DHAVE_CONFIG_H \
    -I. -I../src -I${srcdir} -I${srcdir}/../src ${CPPFLAGS} ${CFLAGS}
 
+.SUFFIXES: .m
+
 /* This is the default compilation command.
    But we should never rely on it, because some make version
    failed to find it for getopt.o.
    Using an explicit command made it work.  */
 .c.o:
 	${CC} -c ${CPP_CFLAGS} $<
+#ifdef HAVE_NS
+.m.o:
+#ifdef GNUSTEP
+	$(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) -fgnu-runtime -Wno-import -fconstant-string-class=NSConstantString $<
+#else
+	$(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) $<
+#endif
+#endif
 
 all: ${DONT_INSTALL} ${UTILITIES} ${INSTALLABLES} ${SCRIPTS} ${INSTALLABLE_SCRIPTS}
 
@@ -462,3 +489,8 @@
 update-game-score.o: ${srcdir}/update-game-score.c ../src/config.h $(GETOPT_H)
 	$(CC) -c ${CPP_CFLAGS} ${srcdir}/update-game-score.c \
 	  -DHAVE_SHARED_GAME_DIR="\"$(gamedir)\""
+
+#if defined(COCOA)
+mac-fix-env: ${srcdir}/mac-fix-env.m
+	$(CC) -o mac-fix-env ${srcdir}/mac-fix-env.m -prebind -framework Foundation
+#endif
Index: lib-src/make-docfile.c
===================================================================
RCS file: /cvsroot/emacs/emacs/lib-src/make-docfile.c,v
retrieving revision 1.54.6.11
diff -u -r1.54.6.11 make-docfile.c
--- lib-src/make-docfile.c	27 Jul 2007 10:51:39 -0000	1.54.6.11
+++ lib-src/make-docfile.c	22 Nov 2007 11:52:43 -0000
@@ -538,7 +538,7 @@
 }
 
 /* Read through a c file.  If a .o file is named,
-   the corresponding .c file is read instead.
+   the corresponding .c or .m file is read instead.
    Looks for DEFUN constructs such as are defined in ../src/lisp.h.
    Accepts any word starting DEF... so it finds DEFSIMPLE and DEFPRED.  */
 
@@ -560,6 +560,15 @@
 
   infile = fopen (filename, mode);
 
+  if (infile == NULL && extension == 'o')
+    {
+      /* try .m */
+      filename[strlen (filename) - 1] = 'm';
+      infile = fopen (filename, mode);
+      if (infile == NULL)
+        filename[strlen (filename) - 1] = 'c'; /* don't confuse people */
+    }
+
   /* No error if non-ex input file */
   if (infile == NULL)
     {
Index: lisp/cus-edit.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/cus-edit.el,v
retrieving revision 1.185.2.64
diff -u -r1.185.2.64 cus-edit.el
--- lisp/cus-edit.el	11 Nov 2007 00:55:28 -0000	1.185.2.64
+++ lisp/cus-edit.el	22 Nov 2007 11:52:49 -0000
@@ -2017,7 +2017,7 @@
 ;;; The `custom' Widget.
 
 (defface custom-button
-  '((((type x w32 mac) (class color))		; Like default modeline
+  '((((type x w32 mac ns) (class color))	; Like default modeline
      (:box (:line-width 2 :style released-button)
 	   :background "lightgrey" :foreground "black"))
     (t
@@ -2029,7 +2029,7 @@
 (put 'custom-button-face 'face-alias 'custom-button)
 
 (defface custom-button-mouse
-  '((((type x w32 mac) (class color))
+  '((((type x w32 mac ns) (class color))
      (:box (:line-width 2 :style released-button)
 	   :background "grey90" :foreground "black"))
     (t
@@ -2051,7 +2051,7 @@
       (if custom-raised-buttons 'custom-button-mouse 'highlight))
 
 (defface custom-button-pressed
-  '((((type x w32 mac) (class color))
+  '((((type x w32 mac ns) (class color))
      (:box (:line-width 2 :style pressed-button)
 	   :background "lightgrey" :foreground "black"))
     (t
@@ -3080,8 +3080,12 @@
 					   w32)
 				    (const :format "MAC "
 					   :sibling-args (:help-echo "\
-Macintosh OS.")
+Macintosh OS (Carbon interface).")
 					   mac)
+				    (const :format "NS "
+					   :sibling-args (:help-echo "\
+GNUstep or Macintosh OS Cocoa interface.")
+					   ns)
 				    (const :format "DOS "
 					   :sibling-args (:help-echo "\
 Plain MS-DOS.")
Index: lisp/cus-face.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/cus-face.el,v
retrieving revision 1.32.6.14
diff -u -r1.32.6.14 cus-face.el
--- lisp/cus-face.el	11 Oct 2007 16:13:30 -0000	1.32.6.14
+++ lisp/cus-face.el	22 Nov 2007 11:52:49 -0000
@@ -47,7 +47,7 @@
 	  ;; Create frame-local faces
 	  (dolist (frame (frame-list))
 	    (face-spec-set face value frame)
-	    (when (memq (window-system frame) '(x w32 mac))
+	    (when (memq (window-system frame) '(x w32 mac ns))
 	      (setq have-window-system t)))
 	  ;; When making a face after frames already exist
 	  (if have-window-system
Index: lisp/disp-table.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/disp-table.el,v
retrieving revision 1.49.6.17
diff -u -r1.49.6.17 disp-table.el
--- lisp/disp-table.el	11 Nov 2007 00:55:46 -0000	1.49.6.17
+++ lisp/disp-table.el	22 Nov 2007 11:52:49 -0000
@@ -144,7 +144,7 @@
   "Display character C as character SC in the g1 character set.
 This function assumes that your terminal uses the SO/SI characters;
 it is meaningless for an X frame."
-  (if (memq window-system '(x w32 mac))
+  (if (memq window-system '(x w32 mac ns))
       (error "Cannot use string glyphs in a windowing system"))
   (or standard-display-table
       (setq standard-display-table (make-display-table)))
@@ -156,7 +156,7 @@
   "Display character C as character GC in graphics character set.
 This function assumes VT100-compatible escapes; it is meaningless for an
 X frame."
-  (if (memq window-system '(x w32 mac))
+  (if (memq window-system '(x w32 mac ns))
       (error "Cannot use string glyphs in a windowing system"))
   (or standard-display-table
       (setq standard-display-table (make-display-table)))
@@ -240,7 +240,7 @@
 	       (equal (aref standard-display-table 161) [161])))
       (progn
 	(standard-display-default 160 255)
-	(unless (or (memq window-system '(x w32 mac)))
+	(unless (or (memq window-system '(x w32 mac ns)))
 	  (and (terminal-coding-system)
 	       (set-terminal-coding-system nil))))
 
@@ -252,7 +252,7 @@
     ;; unless some other has been specified.
     (if (equal current-language-environment "English")
 	(set-language-environment "latin-1"))
-    (unless (or noninteractive (memq window-system '(x w32 mac)))
+    (unless (or noninteractive (memq window-system '(x w32 mac ns)))
       ;; Send those codes literally to a character-based terminal.
       ;; If we are using single-byte characters,
       ;; it doesn't matter which coding system we use.
Index: lisp/facemenu.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/facemenu.el,v
retrieving revision 1.70.6.18
diff -u -r1.70.6.18 facemenu.el
--- lisp/facemenu.el	11 Nov 2007 00:55:27 -0000	1.70.6.18
+++ lisp/facemenu.el	22 Nov 2007 11:52:50 -0000
@@ -493,10 +493,11 @@
 (defun facemenu-read-color (&optional prompt)
   "Read a color using the minibuffer."
   (let* ((completion-ignore-case t)
+	 (require-match (not (eq window-system 'ns)))
 	 (col (completing-read (or prompt "Color: ")
 			       (or facemenu-color-alist
 				   (defined-colors))
-			       nil t)))
+			       nil require-match)))
     (if (equal "" col)
 	nil
       col)))
Index: lisp/faces.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/faces.el,v
retrieving revision 1.279.4.55
diff -u -r1.279.4.55 faces.el
--- lisp/faces.el	11 Nov 2007 00:55:39 -0000	1.279.4.55
+++ lisp/faces.el	22 Nov 2007 11:52:54 -0000
@@ -391,7 +391,7 @@
 
 (defun set-face-attributes-from-resources (face frame)
   "Set attributes of FACE from X resources for FRAME."
-  (when (memq (framep frame) '(x w32 mac))
+  (when (memq (framep frame) '(x w32 mac ns))
     (dolist (definition face-x-resources)
       (let ((attribute (car definition)))
 	(dolist (entry (cdr definition))
@@ -1024,7 +1024,7 @@
            ((:height)
             'integerp)
            (:stipple
-            (and (memq (window-system frame) '(x w32 mac))
+            (and (memq (window-system frame) '(x w32 mac ns))
                  (mapcar #'list
                          (apply #'nconc
                                 (mapcar (lambda (dir)
@@ -1142,7 +1142,7 @@
 	       ;; explicitly in VALID, using color approximation code
 	       ;; in tty-colors.el.
 	       (when (and (memq attribute '(:foreground :background))
-			  (not (memq (window-system frame) '(x w32 mac)))
+			  (not (memq (window-system frame) '(x w32 mac ns)))
 			  (not (member new-value
 				       '("unspecified"
 					 "unspecified-fg" "unspecified-bg"))))
@@ -1599,7 +1599,7 @@
 The value may be different for frames on different display types.
 If FRAME doesn't support colors, the value is nil.
 If FRAME is nil, that stands for the selected frame."
-  (if (memq (framep (or frame (selected-frame))) '(x w32 mac))
+  (if (memq (framep (or frame (selected-frame))) '(x w32 mac ns))
       (xw-defined-colors frame)
     (mapcar 'car (tty-color-alist frame))))
 (defalias 'x-defined-colors 'defined-colors)
@@ -1611,7 +1611,7 @@
 \"unspecified-fg\" or \"unspecified-bg\", the value is nil."
   (if (member color '(unspecified "unspecified-bg" "unspecified-fg"))
       nil
-    (if (member (framep (or frame (selected-frame))) '(x w32 mac))
+    (if (member (framep (or frame (selected-frame))) '(x w32 mac ns))
 	(xw-color-defined-p color frame)
       (numberp (tty-color-translate color frame)))))
 (defalias 'x-color-defined-p 'color-defined-p)
@@ -1627,7 +1627,7 @@
 \"unspecified-fg\" or \"unspecified-bg\", the value is nil."
   (if (member color '(unspecified "unspecified-fg" "unspecified-bg"))
       nil
-    (if (memq (framep (or frame (selected-frame))) '(x w32 mac))
+    (if (memq (framep (or frame (selected-frame))) '(x w32 mac ns))
 	(xw-color-values color frame)
       (tty-color-values color frame))))
 (defalias 'x-color-values 'color-values)
@@ -1637,7 +1637,7 @@
 The optional argument DISPLAY specifies which display to ask about.
 DISPLAY should be either a frame or a display name (a string).
 If omitted or nil, that stands for the selected frame's display."
-  (if (memq (framep-on-display display) '(x w32 mac))
+  (if (memq (framep-on-display display) '(x w32 mac ns))
       (xw-display-color-p display)
     (tty-display-color-p display)))
 (defalias 'x-display-color-p 'display-color-p)
@@ -1646,7 +1646,7 @@
   "Return non-nil if frames on DISPLAY can display shades of gray."
   (let ((frame-type (framep-on-display display)))
     (cond
-     ((memq frame-type '(x w32 mac))
+     ((memq frame-type '(x w32 mac ns))
       (x-display-grayscale-p display))
      (t
       (> (tty-color-gray-shades display) 2)))))
@@ -2014,7 +2014,7 @@
       (condition-case ()
 	  (progn
 	    (face-spec-set face (face-user-default-spec face) frame)
-	    (if (memq (window-system frame) '(x w32 mac))
+	    (if (memq (window-system frame) '(x w32 mac ns))
 		(make-face-x-resource-internal face frame))
 	    (internal-merge-in-global-face face frame))
 	(error nil)))
@@ -2460,7 +2460,7 @@
   '((default
      :box (:line-width 1 :style released-button)
      :foreground "black")
-    (((type x w32 mac) (class color))
+    (((type x w32 mac ns) (class color))
      :background "grey75")
     (((type x) (class mono))
      :background "grey"))
Index: lisp/files.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/files.el,v
retrieving revision 1.666.2.95
diff -u -r1.666.2.95 files.el
--- lisp/files.el	11 Nov 2007 00:55:43 -0000	1.666.2.95
+++ lisp/files.el	22 Nov 2007 11:53:04 -0000
@@ -1768,6 +1768,16 @@
   (if (file-directory-p filename)
       (signal 'file-error (list "Opening input file" "file is a directory"
                                 filename)))
+  ;; Check whether the file is uncommonly large (see find-file-noselect):
+  (let (size)
+    (when (and large-file-warning-threshold
+	       (setq size (nth 7 (file-attributes filename)))
+	       (> size large-file-warning-threshold)
+	       (not (y-or-n-p
+		     (format "File %s is large (%dMB), really insert? "
+			     (file-name-nondirectory filename)
+			     (/ size 1048576)))))
+      (error "Aborted")))
   (let* ((buffer (find-buffer-visiting (abbreviate-file-name (file-truename filename))
                                        #'buffer-modified-p))
          (tem (funcall insert-func filename)))
Index: lisp/frame.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/frame.el,v
retrieving revision 1.203.2.32
diff -u -r1.203.2.32 frame.el
--- lisp/frame.el	15 Oct 2007 05:02:57 -0000	1.203.2.32
+++ lisp/frame.el	22 Nov 2007 11:53:06 -0000
@@ -603,12 +603,19 @@
   "Make a frame on X display DISPLAY.
 The optional second argument PARAMETERS specifies additional frame parameters."
   (interactive "sMake frame on display: ")
-  (or (string-match "\\`[^:]*:[0-9]+\\(\\.[0-9]+\\)?\\'" display)
-      (error "Invalid display, not HOST:SERVER or HOST:SERVER.SCREEN"))
-  (when (and (boundp 'x-initialized) (not x-initialized))
-    (setq x-display-name display)
-    (x-initialize-window-system))
-  (make-frame `((window-system . x) (display . ,display) . ,parameters)))
+  (if (featurep 'ns-windowing)
+      (progn
+	(when (and (boundp 'ns-initialized) (not ns-initialized))
+	  (setq ns-display-name display)
+	  (ns-initialize-window-system))
+	(make-frame `((window-system . ns) (display . ,display) . ,parameters)))
+    (progn
+      (or (string-match "\\`[^:]*:[0-9]+\\(\\.[0-9]+\\)?\\'" display)
+	  (error "Invalid display, not HOST:SERVER or HOST:SERVER.SCREEN"))
+      (when (and (boundp 'x-initialized) (not x-initialized))
+	(setq x-display-name display)
+	(x-initialize-window-system))
+      (make-frame `((window-system . x) (display . ,display) . ,parameters)))))
 
 (defun make-frame-on-tty (tty type &optional parameters)
   "Make a frame on terminal device TTY.
@@ -820,7 +827,7 @@
     (select-frame frame)
     (raise-frame frame)
     ;; Ensure, if possible, that frame gets input focus.
-    (when (memq (window-system frame) '(x mac w32))
+    (when (memq (window-system frame) '(x mac w32 ns))
       (x-focus-frame frame))
     (when focus-follows-mouse
       (set-mouse-position (selected-frame) (1- (frame-width)) 0)))
@@ -905,7 +912,7 @@
     (raise-frame frame)
     (select-frame frame)
     ;; Ensure, if possible, that frame gets input focus.
-    (cond ((memq (window-system frame) '(x w32))
+    (cond ((memq (window-system frame) '(x w32 ns))
 	   (x-focus-frame frame)))
     (when focus-follows-mouse
       (set-mouse-position frame (1- (frame-width frame)) 0))))
@@ -1137,8 +1144,8 @@
      ((eq system-type 'windows-nt)
       (with-no-warnings
        (> w32-num-mouse-buttons 0)))
-     ((memq frame-type '(x mac))
-      t)    ;; We assume X and Mac *always* have a pointing device
+     ((memq frame-type '(x mac ns))
+      t)    ;; We assume X, Mac, NeXTstep *always* have a pointing device
      (t
       (or (and (featurep 'xt-mouse)
 	       xterm-mouse-mode)
@@ -1153,7 +1160,7 @@
 Support for popup menus requires that the mouse be available."
   (and
    (let ((frame-type (framep-on-display display)))
-     (memq frame-type '(x w32 pc mac)))
+     (memq frame-type '(x w32 pc mac ns)))
    (display-mouse-p display)))
 
 (defun display-graphic-p (&optional display)
@@ -1163,7 +1170,7 @@
 that use a window system such as X, and false for text-only terminals.
 DISPLAY can be a display name, a frame, or nil (meaning the selected
 frame's display)."
-  (not (null (memq (framep-on-display display) '(x w32 mac)))))
+  (not (null (memq (framep-on-display display) '(x w32 mac ns)))))
 
 (defun display-images-p (&optional display)
   "Return non-nil if DISPLAY can display images.
@@ -1191,7 +1198,7 @@
       ;; the Windows' DOS Box.
       (with-no-warnings
        (not (null dos-windows-version))))
-     ((memq frame-type '(x w32 mac))
+     ((memq frame-type '(x w32 mac ns))
       t)    ;; FIXME?
      (t
       nil))))
@@ -1200,7 +1207,7 @@
   "Return the number of screens associated with DISPLAY."
   (let ((frame-type (framep-on-display display)))
     (cond
-     ((memq frame-type '(x w32 mac))
+     ((memq frame-type '(x w32 mac ns))
       (x-display-screens display))
      (t
       1))))
@@ -1210,7 +1217,7 @@
 For character terminals, each character counts as a single pixel."
   (let ((frame-type (framep-on-display display)))
     (cond
-     ((memq frame-type '(x w32 mac))
+     ((memq frame-type '(x w32 mac ns))
       (x-display-pixel-height display))
      (t
       (frame-height (if (framep display) display (selected-frame)))))))
@@ -1220,7 +1227,7 @@
 For character terminals, each character counts as a single pixel."
   (let ((frame-type (framep-on-display display)))
     (cond
-     ((memq frame-type '(x w32 mac))
+     ((memq frame-type '(x w32 mac ns))
       (x-display-pixel-width display))
      (t
       (frame-width (if (framep display) display (selected-frame)))))))
@@ -1247,7 +1254,7 @@
   "Return the height of DISPLAY's screen in millimeters.
 System values can be overriden by `display-mm-dimensions-alist'.
 If the information is unavailable, value is nil."
-  (and (memq (framep-on-display display) '(x w32 mac))
+  (and (memq (framep-on-display display) '(x w32 mac ns))
        (or (cddr (assoc (or display (frame-parameter nil 'display))
 			display-mm-dimensions-alist))
 	   (cddr (assoc t display-mm-dimensions-alist))
@@ -1257,7 +1264,7 @@
   "Return the width of DISPLAY's screen in millimeters.
 System values can be overriden by `display-mm-dimensions-alist'.
 If the information is unavailable, value is nil."
-  (and (memq (framep-on-display display) '(x w32 mac))
+  (and (memq (framep-on-display display) '(x w32 mac ns))
        (or (cadr (assoc (or display (frame-parameter nil 'display))
 			display-mm-dimensions-alist))
 	   (cadr (assoc t display-mm-dimensions-alist))
@@ -1269,7 +1276,7 @@
 the question is inapplicable to a certain kind of display."
   (let ((frame-type (framep-on-display display)))
     (cond
-     ((memq frame-type '(x w32 mac))
+     ((memq frame-type '(x w32 mac ns))
       (x-display-backing-store display))
      (t
       'not-useful))))
@@ -1278,7 +1285,7 @@
   "Return non-nil if DISPLAY's screen supports the SaveUnder feature."
   (let ((frame-type (framep-on-display display)))
     (cond
-     ((memq frame-type '(x w32 mac))
+     ((memq frame-type '(x w32 mac ns))
       (x-display-save-under display))
      (t
       'not-useful))))
@@ -1287,7 +1294,7 @@
   "Return the number of planes supported by DISPLAY."
   (let ((frame-type (framep-on-display display)))
     (cond
-     ((memq frame-type '(x w32 mac))
+     ((memq frame-type '(x w32 mac ns))
       (x-display-planes display))
      ((eq frame-type 'pc)
       4)
@@ -1298,7 +1305,7 @@
   "Return the number of color cells supported by DISPLAY."
   (let ((frame-type (framep-on-display display)))
     (cond
-     ((memq frame-type '(x w32 mac))
+     ((memq frame-type '(x w32 mac ns))
       (x-display-color-cells display))
      ((eq frame-type 'pc)
       16)
@@ -1311,7 +1318,7 @@
 `static-color', `pseudo-color', `true-color', or `direct-color'."
   (let ((frame-type (framep-on-display display)))
     (cond
-     ((memq frame-type '(x w32 mac))
+     ((memq frame-type '(x w32 mac ns))
       (x-display-visual-class display))
      ((and (memq frame-type '(pc t))
 	   (tty-display-color-p display))
Index: lisp/info.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/info.el,v
retrieving revision 1.367.2.57
diff -u -r1.367.2.57 info.el
--- lisp/info.el	11 Nov 2007 00:55:37 -0000	1.367.2.57
+++ lisp/info.el	22 Nov 2007 11:53:32 -0000
@@ -3830,7 +3830,7 @@
           ;; This is a serious problem for trying to handle multiple
           ;; frame types at once.  We want this text to be invisible
           ;; on frames that can display the font above.
-          (when (memq (framep (selected-frame)) '(x pc w32 mac))
+          (when (memq (framep (selected-frame)) '(x pc w32 mac ns))
             (add-text-properties (1- (match-beginning 2)) (match-end 2)
                                  '(invisible t front-sticky nil rear-nonsticky t)))))
 
Index: lisp/loadup.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/loadup.el,v
retrieving revision 1.131.2.25
diff -u -r1.131.2.25 loadup.el
--- lisp/loadup.el	11 Nov 2007 00:55:44 -0000	1.131.2.25
+++ lisp/loadup.el	22 Nov 2007 11:53:33 -0000
@@ -206,6 +206,18 @@
 (if (featurep 'mac-carbon)
     (progn
       (load "term/mac-win")))
+(if (featurep 'ns-windowing)
+    (progn
+      (load "emacs-lisp/easymenu")
+      (load "emacs-lisp/easy-mmode")
+      (load "view")
+      (load "help-mode")
+      (load "help-fns")
+      (load "emacs-lisp/advice")
+      (load "ns-mark-nav")
+      (load "paren")
+;      (load "emacs-lisp/cl")
+      (load "term/ns-win")))
 (if (fboundp 'atan)	; preload some constants and
     (progn		; floating pt. functions if we have float support.
       (load "emacs-lisp/float-sup")))
Index: lisp/mouse.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/mouse.el,v
retrieving revision 1.241.8.51
diff -u -r1.241.8.51 mouse.el
--- lisp/mouse.el	20 Oct 2007 02:22:47 -0000	1.241.8.51
+++ lisp/mouse.el	22 Nov 2007 11:53:40 -0000
@@ -679,7 +679,7 @@
     ;; If mark is highlighted, no need to bounce the cursor.
     ;; On X, we highlight while dragging, thus once again no need to bounce.
     (or transient-mark-mode
-	(memq (framep (selected-frame)) '(x pc w32 mac))
+	(memq (framep (selected-frame)) '(x pc w32 mac ns))
 	(sit-for 1))
     (push-mark)
     (set-mark (point))
Index: lisp/mwheel.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/mwheel.el,v
retrieving revision 1.30.2.10
diff -u -r1.30.2.10 mwheel.el
--- lisp/mwheel.el	27 Jul 2007 10:48:57 -0000	1.30.2.10
+++ lisp/mwheel.el	22 Nov 2007 11:53:40 -0000
@@ -59,7 +59,7 @@
                         'mouse-wheel-down-event)
 (defcustom mouse-wheel-down-event
   ;; In the latest versions of XEmacs, we could just use mouse-%s as well.
-  (if (memq window-system '(w32 mac))
+  (if (memq window-system '(w32 mac ns))
       'wheel-up
     (intern (format (if (featurep 'xemacs) "button%s" "mouse-%s")
 		    mouse-wheel-down-button)))
@@ -73,7 +73,7 @@
                         'mouse-wheel-up-event)
 (defcustom mouse-wheel-up-event
   ;; In the latest versions of XEmacs, we could just use mouse-%s as well.
-  (if (memq window-system '(w32 mac))
+  (if (memq window-system '(w32 mac ns))
       'wheel-down
     (intern (format (if (featurep 'xemacs) "button%s" "mouse-%s")
 		    mouse-wheel-up-button)))
Index: lisp/simple.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/simple.el,v
retrieving revision 1.616.2.100
diff -u -r1.616.2.100 simple.el
--- lisp/simple.el	11 Nov 2007 00:55:26 -0000	1.616.2.100
+++ lisp/simple.el	22 Nov 2007 11:53:53 -0000
@@ -5740,7 +5740,7 @@
     (set-terminal-parameter nil 'normal-erase-is-backspace
 			    (if enabled 1 0))
 
-    (cond ((or (memq window-system '(x w32 mac pc))
+    (cond ((or (memq window-system '(x w32 mac ns pc))
 	       (memq system-type '(ms-dos windows-nt)))
 	   (let* ((bindings
 		   `(([C-delete] [C-backspace])
Index: lisp/startup.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/startup.el,v
retrieving revision 1.321.2.68
diff -u -r1.321.2.68 startup.el
--- lisp/startup.el	27 Oct 2007 09:11:18 -0000	1.321.2.68
+++ lisp/startup.el	22 Nov 2007 11:53:57 -0000
@@ -183,6 +183,72 @@
 and VALUE is the value which is given to that frame parameter
 \(most options use the argument for this, so VALUE is not present).")
 
+(defconst command-line-ns-option-alist
+  '(("-NSAutoLaunch" 1 ns-ignore-1-arg)
+    ("-NXAutoLaunch" 1 ns-ignore-1-arg)
+    ("-macosx" 0 ns-ignore-0-arg)
+    ("-NSHost" 1 ns-ignore-1-arg)
+    ("-_NSMachLaunch" 1 ns-ignore-1-arg)
+    ("-MachLaunch" 1 ns-ignore-1-arg)
+    ("-NXOpen" 1 ns-ignore-1-arg)
+    ("-NSOpen" 1 ns-handle-nxopen)
+    ("-NXOpenTemp" 1 ns-ignore-1-arg)
+    ("-NSOpenTemp" 1 ns-handle-nxopentemp)
+    ("-GSFilePath" 1 ns-handle-nxopen)
+    ;;("-bw" .              x-handle-numeric-switch)
+    ;;("-d" .               x-handle-display)
+    ;;("-display" .         x-handle-display)
+    ("-name" 1 ns-handle-name-switch)
+    ("-title" 1 ns-handle-switch title)
+    ("-T" 1 ns-handle-switch title)
+    ("-r" 0 ns-handle-switch reverse t)
+    ("-rv" 0 ns-handle-switch reverse t)
+    ("-reverse" 0 ns-handle-switch reverse t)
+    ("-fn" 1 ns-handle-switch font)
+    ("-font" 1 ns-handle-switch font)
+    ("-ib" 1 ns-handle-numeric-switch internal-border-width)
+    ;;("-g" .               x-handle-geometry)
+    ;;("-geometry" .        x-handle-geometry)
+    ("-fg" 1 ns-handle-switch foreground-color)
+    ("-foreground" 1 ns-handle-switch foreground-color)
+    ("-bg" 1 ns-handle-switch background-color)
+    ("-background" 1 ns-handle-switch background-color)
+;    ("-ms" 1 ns-handle-switch mouse-color)
+    ("-itype" 0 ns-handle-switch icon-type t)
+    ("-i" 0 ns-handle-switch icon-type t)
+    ("-iconic" 0 ns-handle-iconic icon-type t)
+    ;;("-xrm" .             x-handle-xrm-switch)
+    ("-cr" 1 ns-handle-switch cursor-color)
+    ("-vb" 0 ns-handle-switch vertical-scroll-bars t)
+    ("-hb" 0 ns-handle-switch horizontal-scroll-bars t)
+    ("-bd" 1 ns-handle-switch) 
+    ;; ("--border-width" 1 ns-handle-numeric-switch border-width) 
+    ;; ("--display" 1 ns-handle-display)
+    ("--name" 1 ns-handle-name-switch)
+    ("--title" 1 ns-handle-switch title)
+    ("--reverse-video" 0 ns-handle-switch reverse t)
+    ("--font" 1 ns-handle-switch font)
+    ("--internal-border" 1 ns-handle-numeric-switch internal-border-width)
+    ;; ("--geometry" 1 ns-handle-geometry)
+    ("--foreground-color" 1 ns-handle-switch foreground-color)
+    ("--background-color" 1 ns-handle-switch background-color)
+    ("--mouse-color" 1 ns-handle-switch mouse-color)
+    ("--icon-type" 0 ns-handle-switch icon-type t)
+    ("--iconic" 0 ns-handle-iconic)
+    ;; ("--xrm" 1 ns-handle-xrm-switch)
+    ("--cursor-color" 1 ns-handle-switch cursor-color)
+    ("--vertical-scroll-bars" 0 ns-handle-switch vertical-scroll-bars t)
+    ("--border-color" 1 ns-handle-switch border-width))
+  "Alist of NS options.
+Each element has the form
+  (NAME NUMARGS HANDLER FRAME-PARAM VALUE)
+where NAME is the option name string, NUMARGS is the number of arguments
+that the option accepts, HANDLER is a function to call to handle the option.
+FRAME-PARAM (optional) is the frame parameter this option specifies,
+and VALUE is the value which is given to that frame parameter
+\(most options use the argument for this, so VALUE is not present).")
+
+
 (defvar before-init-hook nil
   "Normal hook run after handling urgent options but before loading init files.")
 
@@ -808,7 +874,7 @@
   ;; only because all other settings of no-blinking-cursor are here.
   (unless (or noninteractive
 	      emacs-basic-display
-	      (and (memq window-system '(x w32 mac))
+	      (and (memq window-system '(x w32 mac ns))
 		   (not (member (x-get-resource "cursorBlink" "CursorBlink")
 				'("off" "false")))))
     (setq no-blinking-cursor t))
@@ -2001,6 +2067,13 @@
 	  (if (string-match "^--" (car tem))
 	      (push (list (car tem)) longopts)))
 
+      ;; Add the long NS options to longopts.
+      (setq tem command-line-ns-option-alist)
+      (while tem
+	(if (string-match "^--" (car (car tem)))
+	    (setq longopts (cons (list (car (car tem))) longopts)))
+	(setq tem (cdr tem)))
+
 	;; Loop, processing options.
 	(while command-line-args-left
 	  (let* ((argi (car command-line-args-left))
@@ -2111,6 +2184,11 @@
 		   (setq command-line-args-left
 			 (nthcdr (nth 1 tem) command-line-args-left)))
 
+		((setq tem (assoc argi command-line-ns-option-alist))
+		 ;; Ignore NS-windows options and their args if not using NS.
+		 (setq command-line-args-left
+		       (nthcdr (nth 1 tem) command-line-args-left)))
+
 		  ((member argi '("-find-file" "-file" "-visit"))
 		   (setq inhibit-startup-screen t)
 		   ;; An explicit option to specify visiting a file.
Index: lisp/version.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/version.el,v
retrieving revision 2.32.6.15
diff -u -r2.32.6.15 version.el
--- lisp/version.el	12 Oct 2007 21:06:26 -0000	2.32.6.15
+++ lisp/version.el	22 Nov 2007 11:53:57 -0000
@@ -67,6 +67,8 @@
 		       ((featurep 'gtk)
 			(concat ", GTK+ Version " gtk-version-string))
 		       ((featurep 'x-toolkit) ", X toolkit")
+		       ((featurep 'ns-windowing)
+			(format ", *Step %s" ns-version-string))
 		       ((boundp 'mac-carbon-version-string)
 			(concat ", Carbon Version " mac-carbon-version-string))
 		       (t ""))
Index: lisp/woman.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/woman.el,v
retrieving revision 1.16.4.29
diff -u -r1.16.4.29 woman.el
--- lisp/woman.el	15 Oct 2007 05:02:57 -0000	1.16.4.29
+++ lisp/woman.el	22 Nov 2007 11:54:02 -0000
@@ -547,9 +547,11 @@
 
 (defcustom woman-man.conf-path
   (let ((path '("/usr/lib" "/etc")))
-    (if (eq system-type 'windows-nt)
-	(mapcar 'woman-Cyg-to-Win path)
-      path))
+    (cond ((eq system-type 'windows-nt)
+	   (mapcar 'woman-Cyg-to-Win path))
+	  ((eq system-type 'darwin)
+	   (cons "/usr/share/misc" path))
+	  (t path)))
   "List of dirs to search and/or files to try for man config file.
 A trailing separator (`/' for UNIX etc.) on directories is
 optional, and the filename is used if a directory specified is
@@ -808,7 +810,7 @@
 
 (defcustom woman-use-own-frame		; window-system
   (or (and (fboundp 'display-graphic-p) (display-graphic-p)) ; Emacs 21
-      (memq window-system '(x w32)))	; Emacs 20
+      (memq window-system '(x w32 ns)))	; Emacs 20
   "If non-nil then use a dedicated frame for displaying WoMan windows.
 Only useful when run on a graphic display such as X or MS-Windows."
   :type 'boolean
Index: lisp/emulation/viper-util.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/emulation/viper-util.el,v
retrieving revision 1.49.6.18
diff -u -r1.49.6.18 viper-util.el
--- lisp/emulation/viper-util.el	11 Nov 2007 00:56:41 -0000	1.49.6.18
+++ lisp/emulation/viper-util.el	22 Nov 2007 11:54:03 -0000
@@ -55,14 +55,6 @@
 (require 'viper-init)
 
 
-;; A fix for NeXT Step
-;; Should go away, when NS people fix the design flaw, which leaves the
-;; two x-* functions undefined.
-(if (and (not (fboundp 'x-display-color-p)) (fboundp 'ns-display-color-p))
-    (fset 'x-display-color-p (symbol-function 'ns-display-color-p)))
-(if (and (not (fboundp 'x-color-defined-p)) (fboundp 'ns-color-defined-p))
-      (fset 'x-color-defined-p (symbol-function 'ns-color-defined-p)))
-
 
 (defalias 'viper-overlay-p 
   (if (featurep 'xemacs) 'extentp 'overlayp))
Index: lisp/gnus/gnus-util.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/gnus/gnus-util.el,v
retrieving revision 1.18.6.29
diff -u -r1.18.6.29 gnus-util.el
--- lisp/gnus/gnus-util.el	11 Nov 2007 00:55:56 -0000	1.18.6.29
+++ lisp/gnus/gnus-util.el	22 Nov 2007 11:54:04 -0000
@@ -1532,7 +1532,9 @@
 	 (cond ((memq window-system '(x mac))
 		(x-focus-frame frame))
 	       ((eq window-system 'w32)
-		(w32-focus-frame frame)))
+		(w32-focus-frame frame))
+	       ((eq window-system 'ns)
+		(ns-focus-frame frame)))
 	 (when focus-follows-mouse
 	   (set-mouse-position frame (1- (frame-width frame)) 0)))))
 
Index: lisp/international/fontset.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/international/fontset.el,v
retrieving revision 1.60.2.28
diff -u -r1.60.2.28 fontset.el
--- lisp/international/fontset.el	27 Jul 2007 10:51:55 -0000	1.60.2.28
+++ lisp/international/fontset.el	22 Nov 2007 11:54:05 -0000
@@ -118,7 +118,7 @@
 
 (setq script-representative-chars
       '((latin ?A ?Z ?a ?z)
-	(greek #x3A9)
+	(greek #x397 #x3A9)
 	(coptic #x3E2)
 	(cyrillic #x42F)
 	(armenian #x531)
@@ -156,7 +156,9 @@
 	(kanbun #x319D)
 	(han #x5B57)
 	(yi #xA288)
-	(hangul #xAC00)))
+	(hangul #xAC00)
+	(kana #xff8a)
+	(symbol #x2295 #x2287 #x25a1)))
 
 (setq otf-script-alist
       '((arab . arabic)
@@ -814,7 +816,6 @@
 
     ;; Complement FONTLIST.
     (setq fontlist (x-complement-fontset-spec xlfd-fields fontlist))
-
     ;; Create a fontset.
     (new-fontset name (nreverse fontlist))))
 
Index: lisp/international/mule-cmds.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/international/mule-cmds.el,v
retrieving revision 1.242.2.52
diff -u -r1.242.2.52 mule-cmds.el
--- lisp/international/mule-cmds.el	11 Oct 2007 16:21:49 -0000	1.242.2.52
+++ lisp/international/mule-cmds.el	22 Nov 2007 11:54:08 -0000
@@ -151,7 +151,7 @@
   t)
 (define-key-after set-coding-system-map [set-terminal-coding-system]
   '(menu-item "For Terminal" set-terminal-coding-system
-	      :enable (null (memq initial-window-system '(x w32 mac)))
+	      :enable (null (memq initial-window-system '(x w32 mac ns)))
 	      :help "How to encode terminal output")
   t)
 (define-key-after set-coding-system-map [separator-3]
Index: lisp/international/uni-bidi.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/international/Attic/uni-bidi.el,v
retrieving revision 1.1.2.5
diff -u -r1.1.2.5 uni-bidi.el
Binary files /tmp/cvsypD5i2 and uni-bidi.el differ
Index: lisp/international/uni-category.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/international/Attic/uni-category.el,v
retrieving revision 1.1.2.5
diff -u -r1.1.2.5 uni-category.el
Binary files /tmp/cvsMTIURc and uni-category.el differ
Index: lisp/international/uni-combining.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/international/Attic/uni-combining.el,v
retrieving revision 1.1.2.5
diff -u -r1.1.2.5 uni-combining.el
Binary files /tmp/cvsmpe8qn and uni-combining.el differ
Index: lisp/international/uni-comment.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/international/Attic/uni-comment.el,v
retrieving revision 1.1.2.6
diff -u -r1.1.2.6 uni-comment.el
Binary files /tmp/cvsCAzE0x and uni-comment.el differ
Index: lisp/international/uni-decimal.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/international/Attic/uni-decimal.el,v
retrieving revision 1.1.2.5
diff -u -r1.1.2.5 uni-decimal.el
Binary files /tmp/cvsC1QqAI and uni-decimal.el differ
Index: lisp/international/uni-decomposition.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/international/Attic/uni-decomposition.el,v
retrieving revision 1.1.2.5
diff -u -r1.1.2.5 uni-decomposition.el
Binary files /tmp/cvsEXWEaT and uni-decomposition.el differ
Index: lisp/international/uni-digit.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/international/Attic/uni-digit.el,v
retrieving revision 1.1.2.5
diff -u -r1.1.2.5 uni-digit.el
Binary files /tmp/cvsQGylL3 and uni-digit.el differ
Index: lisp/international/uni-lowercase.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/international/Attic/uni-lowercase.el,v
retrieving revision 1.1.2.5
diff -u -r1.1.2.5 uni-lowercase.el
Binary files /tmp/cvsoZmgme and uni-lowercase.el differ
Index: lisp/international/uni-mirrored.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/international/Attic/uni-mirrored.el,v
retrieving revision 1.1.2.5
diff -u -r1.1.2.5 uni-mirrored.el
Binary files /tmp/cvsA4grXo and uni-mirrored.el differ
Index: lisp/international/uni-name.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/international/Attic/uni-name.el,v
retrieving revision 1.1.2.7
diff -u -r1.1.2.7 uni-name.el
Binary files /tmp/cvsIVAVzz and uni-name.el differ
Index: lisp/international/uni-numeric.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/international/Attic/uni-numeric.el,v
retrieving revision 1.1.2.5
diff -u -r1.1.2.5 uni-numeric.el
Binary files /tmp/cvsqliMdK and uni-numeric.el differ
Index: lisp/international/uni-old-name.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/international/Attic/uni-old-name.el,v
retrieving revision 1.1.2.6
diff -u -r1.1.2.6 uni-old-name.el
Binary files /tmp/cvseOmVRU and uni-old-name.el differ
Index: lisp/international/uni-titlecase.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/international/Attic/uni-titlecase.el,v
retrieving revision 1.1.2.5
diff -u -r1.1.2.5 uni-titlecase.el
Binary files /tmp/cvsUgNow5 and uni-titlecase.el differ
Index: lisp/international/uni-uppercase.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/international/Attic/uni-uppercase.el,v
retrieving revision 1.1.2.5
diff -u -r1.1.2.5 uni-uppercase.el
Binary files /tmp/cvs42A7ag and uni-uppercase.el differ
Index: lisp/url/url.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/url/url.el,v
retrieving revision 1.4.2.18
diff -u -r1.4.2.18 url.el
--- lisp/url/url.el	27 Jul 2007 10:50:24 -0000	1.4.2.18
+++ lisp/url/url.el	22 Nov 2007 11:54:41 -0000
@@ -173,6 +173,7 @@
   (unless (url-type url)
     (error "Bad url: %s" (url-recreate-url url)))
   (let ((loader (url-scheme-get-property (url-type url) 'loader))
+	(url-proxy-object nil)
 	(url-using-proxy (if (url-host url)
 			     (url-find-proxy-for-url url (url-host url))))
 	(buffer nil)
Index: man/Makefile.in
===================================================================
RCS file: /cvsroot/emacs/emacs/man/Attic/Makefile.in,v
retrieving revision 1.48.2.19
diff -u -r1.48.2.19 Makefile.in
--- man/Makefile.in	3 Aug 2007 05:20:42 -0000	1.48.2.19
+++ man/Makefile.in	22 Nov 2007 11:54:42 -0000
@@ -36,7 +36,7 @@
 INFO_TARGETS = ../info/emacs ../info/ccmode ../info/cl \
 	        ../info/dired-x ../info/ediff ../info/forms ../info/gnus \
 		../info/message ../info/sieve ../info/pgg ../info/emacs-mime \
-		../info/info ../info/mh-e ../info/reftex \
+		../info/info ../info/mh-e ../info/ns-emacs ../info/reftex \
 		../info/sc ../info/vip ../info/viper ../info/widget \
 		../info/efaq ../info/ada-mode ../info/autotype ../info/calc \
 		../info/idlwave ../info/eudc ../info/ebrowse ../info/pcl-cvs \
@@ -45,7 +45,7 @@
 		../info/flymake ../info/newsticker ../info/rcirc ../info/erc
 DVI_TARGETS = 	emacs.dvi calc.dvi cc-mode.dvi cl.dvi dired-x.dvi \
 		 ediff.dvi forms.dvi gnus.dvi message.dvi emacs-mime.dvi \
-                 gnus.dvi message.dvi sieve.dvi pgg.dvi mh-e.dvi \
+                 gnus.dvi message.dvi sieve.dvi pgg.dvi mh-e.dvi ns-emacs.dvi \
 		 reftex.dvi sc.dvi vip.dvi viper.dvi widget.dvi faq.dvi \
 		 ada-mode.dvi autotype.dvi idlwave.dvi eudc.dvi ebrowse.dvi \
 		 pcl-cvs.dvi woman.dvi eshell.dvi org.dvi url.dvi \
@@ -118,6 +118,7 @@
 	${srcdir}/glossary.texi \
 	${srcdir}/ack.texi \
 	${srcdir}/kmacro.texi \
+	${srcdir}/ns-emacs.texi \
 	$(EMACS_XTRA)
 
 info: $(top_srcdir)/info $(INFO_TARGETS)
@@ -232,6 +233,11 @@
 mh-e.dvi: mh-e.texi
 	$(ENVADD) $(TEXI2DVI) ${srcdir}/mh-e.texi
 
+../info/ns-emacs: ns-emacs.texi
+	cd $(srcdir); $(MAKEINFO) ns-emacs.texi
+ns-emacs.dvi: ns-emacs.texi
+	$(ENVADD) $(TEXI2DVI) ${srcdir}/ns-emacs.texi
+
 ../info/reftex: reftex.texi
 	cd $(srcdir); $(MAKEINFO) reftex.texi
 reftex.dvi: reftex.texi
Index: src/Makefile.in
===================================================================
RCS file: /cvsroot/emacs/emacs/src/Makefile.in,v
retrieving revision 1.279.2.56
diff -u -r1.279.2.56 Makefile.in
--- src/Makefile.in	11 Nov 2007 00:55:19 -0000	1.279.2.56
+++ src/Makefile.in	22 Nov 2007 11:54:43 -0000
@@ -263,6 +263,17 @@
 #endif
 #endif
 
+#ifdef GNUSTEP
+GNUSTEP_SYSROOT=@GNUSTEP_SYSROOT@
+/* Pull in stuff from GNUstep-make.  If you want to rewrite this to actually
+   _invoke_ gnustep-make, go right ahead! */
+FOUNDATION_LIB=gnu
+GUI_LIB=gnu
+include $(GNUSTEP_SYSROOT)/Library/Makefiles/Additional/base.make
+include $(GNUSTEP_SYSROOT)/Library/Makefiles/Additional/gui.make
+shared=no
+#endif
+
 /* DO NOT use -R.  There is a special hack described in lastfile.c
    which is used instead.  Some initialized data areas are modified
    at initial startup, then labeled as part of the text area when
@@ -277,8 +288,11 @@
 /* C_SWITCH_X_SITE must come before C_SWITCH_X_MACHINE and C_SWITCH_X_SYSTEM
    since it may have -I options that should override those two.  */
 ALL_CFLAGS=-Demacs -DHAVE_CONFIG_H $(TOOLKIT_DEFINES) $(MYCPPFLAGS) -I. -I${srcdir} C_SWITCH_MACHINE C_SWITCH_SYSTEM C_SWITCH_SITE C_SWITCH_X_SITE C_SWITCH_X_MACHINE C_SWITCH_X_SYSTEM C_SWITCH_SYSTEM_TEMACS ${CFLAGS_SOUND} ${RSVG_CFLAGS} ${CFLAGS} @FREETYPE_CFLAGS@ @FONTCONFIG_CFLAGS@ @LIBOTF_CFLAGS@
+.SUFFIXES: .m
 .c.o:
 	$(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) $<
+.m.o:
+	$(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) GNU_OBJC_CFLAGS $<
 
 #ifndef LIBX11_MACHINE
 #define LIBX11_MACHINE
@@ -292,13 +306,8 @@
 #define LIB_X11_LIB -lX11
 #endif
 
-/* xmenu.c should not be compiled on OSX.  */
-#ifndef HAVE_CARBON
-XMENU_OBJ = xmenu.o
-#endif
-
 #ifdef HAVE_X_WINDOWS
-
+XMENU_OBJ = xmenu.o
 XOBJ= xterm.o xfns.o xselect.o xrdb.o fontset.o xsmfns.o fringe.o image.o
 
 #ifdef HAVE_MENUS
@@ -585,6 +594,20 @@
 emacsappsrc = ${srcdir}/../mac/Emacs.app/
 #endif
 
+#ifdef HAVE_NS
+/* Object files for NeXTstep */
+NS_OBJ= nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o \
+	fontset.o fringe.o image.o
+emacsapp = $(PWD)/$(dot)$(dot)/nextstep/build/Emacs.app/
+#ifdef GNUSTEP
+emacsappsrc = ${srcdir}/$(dot)$(dot)/nextstep/GNUstep/Emacs.base
+emacsbindir = $(emacsapp)
+#else
+emacsappsrc = ${srcdir}/$(dot)$(dot)/nextstep/Cocoa/Emacs.base
+emacsbindir = $(emacsapp)/Contents/MacOS/
+#endif  /* GNUSTEP */
+#endif  /* HAVE_NS */
+
 #ifdef HAVE_WINDOW_SYSTEM
 #ifdef USE_FONT_BACKEND
 FONTSRC = font.h
@@ -617,7 +640,7 @@
 	process.o callproc.o \
 	region-cache.o sound.o atimer.o \
 	doprnt.o strftime.o intervals.o textprop.o composite.o md5.o \
-	$(MSDOS_OBJ) $(MAC_OBJ) $(CYGWIN_OBJ) $(FONTOBJ)
+	$(MSDOS_OBJ) $(MAC_OBJ) $(NS_OBJ) $(CYGWIN_OBJ) $(FONTOBJ)
 
 /* Object files used on some machine or other.
    These go in the DOC file on all machines
@@ -625,6 +648,7 @@
 SOME_MACHINE_OBJECTS = dosfns.o msdos.o \
   xterm.o xfns.o xmenu.o xselect.o xrdb.o xsmfns.o fringe.o image.o \
   mac.o macterm.o macfns.o macmenu.o macselect.o fontset.o \
+  nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o \
   w32.o w32bdf.o w32console.o w32fns.o w32heap.o w32inevt.o \
   w32menu.o w32proc.o w32reg.o w32select.o w32term.o w32xfns.o $(FONTOBJ)
 
@@ -941,11 +965,20 @@
    Note that SunOS needs -lm to come before -lc; otherwise, you get
    duplicated symbols.  If the standard libraries were compiled
    with GCC, we might need gnulib again after them.  */
+
+#ifdef GNUSTEP
+/* Drop STD_LIB off the link line. */
+LIBES = $(LOADLIBES) $(LIBS) $(LIBX) $(LIBSOUND) $(RSVG_LIBS) \
+   LIBRESOLV LIBS_SYSTEM LIBS_MACHINE LIBS_TERMCAP \
+   LIBS_DEBUG $(GETLOADAVG_LIBS) $(GNULIB_VAR) LIB_MATH $(GNULIB_VAR)
+
+#else /* !GNUSTEP */
 LIBES = $(LOADLIBES) $(LIBS) $(LIBX) $(LIBSOUND) $(RSVG_LIBS) LIBGPM \
    LIBRESOLV LIBS_SYSTEM LIBS_MACHINE LIBS_TERMCAP \
    LIBS_DEBUG $(GETLOADAVG_LIBS) \
    @FREETYPE_LIBS@ @FONTCONFIG_LIBS@ @LIBOTF_LIBS@ \
    $(GNULIB_VAR) LIB_MATH LIB_STANDARD $(GNULIB_VAR)
+#endif
 
 /* Enable recompilation of certain other files depending on system type.  */
 
@@ -972,7 +1005,10 @@
 #else
 	LC_ALL=C $(RUN_TEMACS) -batch -l loadup dump
 #endif /* ! defined (CANNOT_DUMP) */
+/* XXX: not working under NS currently due to path shenanigans.. */
+#ifndef HAVE_NS
 	-./emacs -q -batch -f list-load-path-shadows
+#endif
 
 /* We run make-docfile twice because the command line may get too long
    on some systems.  */
@@ -1007,9 +1043,13 @@
 
 temacs${EXEEXT}: MAKE_PARALLEL $(LOCALCPP) $(STARTFILES) stamp-oldxmenu ${obj} ${otherobj} OBJECTS_MACHINE prefix-args${EXEEXT}
 	echo "${obj} ${otherobj} " OBJECTS_MACHINE > buildobj.lst
+#ifdef GNUSTEP
+	$(CC) -rdynamic YMF_PASS_LDFLAGS (${TEMACS_LDFLAGS}) -o temacs ${obj} ${otherobj} OBJECTS_MACHINE ${LIBES}
+#else
 	$(LD) YMF_PASS_LDFLAGS (${STARTFLAGS} ${TEMACS_LDFLAGS}) $(LDFLAGS) \
     -o temacs ${STARTFILES} ${obj} ${otherobj}  \
     OBJECTS_MACHINE ${LIBES}
+#endif
 
 /* We do not use ALL_LDFLAGS because LD_SWITCH_SYSTEM and LD_SWITCH_MACHINE
    often contain options that have to do with using Emacs''s crt0,
@@ -1163,7 +1203,8 @@
    charset.h frame.h keyboard.h termhooks.h $(FONTSRC) $(config_h)
 getloadavg.o: getloadavg.c $(config_h)
 image.o: image.c frame.h window.h dispextern.h blockinput.h atimer.h \
-   systime.h xterm.h w32term.h w32gui.h macterm.h macgui.h $(config_h)
+   systime.h xterm.h w32term.h w32gui.h macterm.h macgui.h \
+   nsterm.h nsgui.h $(config_h)
 indent.o: indent.c frame.h window.h indent.h buffer.h $(config_h) termchar.h \
    termopts.h disptab.h region-cache.h character.h category.h composite.h \
    dispextern.h keyboard.h
@@ -1172,7 +1213,8 @@
 keyboard.o: keyboard.c termchar.h termhooks.h termopts.h buffer.h character.h \
    commands.h frame.h window.h macros.h disptab.h keyboard.h syssignal.h \
    systime.h dispextern.h syntax.h $(INTERVAL_SRC) blockinput.h \
-   atimer.h xterm.h puresize.h msdos.h keymap.h w32term.h macterm.h $(config_h)
+   atimer.h xterm.h puresize.h msdos.h keymap.h w32term.h macterm.h nsterm.h \
+   $(config_h)
 keymap.o: keymap.c buffer.h commands.h keyboard.h termhooks.h blockinput.h \
    atimer.h systime.h puresize.h character.h intervals.h keymap.h window.h \
    $(config_h)
@@ -1231,15 +1273,15 @@
 window.o: window.c indent.h commands.h frame.h window.h buffer.h termchar.h \
    disptab.h keyboard.h dispextern.h msdos.h composite.h \
    keymap.h blockinput.h atimer.h systime.h $(INTERVAL_SRC) \
-   xterm.h w32term.h macterm.h $(config_h)
+   xterm.h w32term.h macterm.h nsterm.h $(config_h)
 xdisp.o: xdisp.c macros.h commands.h process.h indent.h buffer.h dispextern.h \
    coding.h termchar.h frame.h window.h disptab.h termhooks.h character.h     \
    charset.h $(config_h) keyboard.h $(INTERVAL_SRC) region-cache.h xterm.h    \
-   w32term.h macterm.h msdos.h composite.h fontset.h blockinput.h atimer.h    \
-   systime.h keymap.h $(FONTSRC)
+   w32term.h macterm.h nsterm.h msdos.h composite.h fontset.h blockinput.h \
+   atimer.h systime.h keymap.h $(FONTSRC)
 xfaces.o: xfaces.c dispextern.h frame.h xterm.h buffer.h blockinput.h	\
    window.h character.h charset.h msdos.h dosfns.h composite.h atimer.h	\
-   systime.h keyboard.h fontset.h w32term.h macterm.h $(INTERVAL_SRC)	\
+   systime.h keyboard.h fontset.h w32term.h macterm.h nsterm.h $(INTERVAL_SRC) \
    termchar.h termhooks.h $(FONTSRC) $(config_h)
 xfns.o: xfns.c buffer.h frame.h window.h keyboard.h xterm.h dispextern.h \
    $(srcdir)/../lwlib/lwlib.h blockinput.h atimer.h systime.h epaths.h \
@@ -1345,7 +1387,38 @@
 ${emacsapp}Contents/MacOS/Emacs: emacs${EXEEXT}
 	mkdir -p ${emacsapp}Contents/MacOS/;
 	cd ${emacsapp}Contents/MacOS/; cp ../../../../src/emacs${EXEEXT} Emacs${EXEEXT}
-#endif
+#endif /* HAVE_CARBON */
+
+#ifdef HAVE_NS
+abbrev.o buffer.o callint.o cmds.o dispnew.o editfns.o fileio.o frame.o \
+  fontset.o indent.o insdel.o keyboard.o macros.o minibuf.o msdos.o process.o \
+  scroll.o sysdep.o term.o widget.o window.o xdisp.o xfaces.o xfns.o xmenu.o \
+  xterm.o xselect.o sound.o: nsgui.h
+nsfns.o: nsfns.m charset.h nsterm.h nsgui.h frame.h window.h buffer.h \
+  dispextern.h nsgui.h fontset.h $(INTERVAL_SRC) keyboard.h blockinput.h \
+  atimer.h systime.h epaths.h termhooks.h coding.h systime.h $(config_h)
+nsmenu.o: nsmenu.m nsmenu_common.c termhooks.h frame.h window.h dispextern.h \
+  nsgui.h keyboard.h blockinput.h atimer.h systime.h buffer.h \
+  nsterm.h $(config_h)
+nsterm.o: nsterm.m blockinput.h atimer.h systime.h syssignal.h nsterm.h \
+  nsgui.h frame.h charset.h ccl.h dispextern.h fontset.h termhooks.h \
+  termopts.h termchar.h gnu.h disptab.h buffer.h window.h keyboard.h \
+  $(INTERVAL_SRC) process.h coding.h $(config_h)
+nsselect.o: nsselect.m blockinput.h nsterm.h nsgui.h frame.h $(config_h)
+nsimage.o: nsimage.m nsterm.h
+nsfont.o: nsterm.h dispextern.h frame.h lisp.h $(config_h)
+
+${emacsapp}: ${emacsappsrc}
+	mkdir -p ${emacsapp}
+	( cd ${emacsappsrc} ; tar cfh - . ) | ( cd ${emacsapp} ; tar xf - )
+
+${emacsbindir}Emacs: emacs${EXEEXT}
+	mkdir -p ${emacsbindir}
+	cp -f emacs${EXEEXT} ${emacsbindir}Emacs
+
+ns-app: ${emacsapp} ${emacsbindir}Emacs
+
+#endif /* HAVE_NS */
 
 bootstrapclean:
 	rm -f bootstrap-emacs${EXEEXT} emacs-${version}${EXEEXT}
@@ -1356,6 +1429,9 @@
 	rm -f buildobj.lst
 clean: mostlyclean
 	rm -f emacs-*${EXEEXT} emacs${EXEEXT}
+#ifdef GNUSTEP
+	rm -f *.d
+#endif
 /**/# This is used in making a distribution.
 /**/# Do not use it on development directories!
 distclean: clean
Index: src/alloc.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/alloc.c,v
retrieving revision 1.318.2.52
diff -u -r1.318.2.52 alloc.c
--- src/alloc.c	29 Oct 2007 23:31:22 -0000	1.318.2.52
+++ src/alloc.c	22 Nov 2007 11:54:48 -0000
@@ -1247,8 +1247,12 @@
   BLOCK_INPUT_ALLOC;
   __malloc_hook = old_malloc_hook;
 #ifdef DOUG_LEA_MALLOC
+#ifndef GNUSTEP
+    /* The repeated calls to this seem to mess something up in conjunction
+       with objc's allocation and eventually cause a segfault here. */
   /* Segfaults on my system.  --lorentey */
   /* mallopt (M_TOP_PAD, malloc_hysteresis * 4096); */
+#endif
 #else
     __malloc_extra_blocks = malloc_hysteresis;
 #endif
@@ -4507,8 +4511,10 @@
      needed on ia64 too.  See mach_dep.c, where it also says inline
      assembler doesn't work with relevant proprietary compilers.  */
 #ifdef sparc
+#ifndef GNUSTEP
   asm ("ta 3");
 #endif
+#endif
 
   /* Save registers that we need to see on the stack.  We need to see
      registers used to hold register variables and registers used to
Index: src/config.in
===================================================================
RCS file: /cvsroot/emacs/emacs/src/config.in,v
retrieving revision 1.190.2.34
diff -u -r1.190.2.34 config.in
--- src/config.in	11 Nov 2007 00:55:19 -0000	1.190.2.34
+++ src/config.in	22 Nov 2007 11:54:50 -0000
@@ -102,6 +102,18 @@
 /* Define to 1 if you are using the Carbon API on Mac OS X. */
 #undef HAVE_CARBON
 
+/* Define to 1 to use NeXTstep instead of X windows. */
+#undef HAVE_NS
+
+/* Define to 1 if you are using NS windowing under MacOS X.  */
+#undef COCOA
+
+/* Define to 1 if you are trying experimental enhanced Ctrl-g support using NS windowing under MacOS X. */
+#undef COCOA_EXPERIMENTAL_CTRL_G
+
+/* Define to 1 if you are using NS windowing under GNUstep. */
+#undef GNUSTEP
+
 /* Define to 1 if you have the `cbrt' function. */
 #undef HAVE_CBRT
 
@@ -931,7 +943,8 @@
 #undef volatile
 
 
-/* If we're using any sort of window system, define some consequences.  */
+/* If we're using X11, define some consequences. */
+/* ABR: can the redundancy with ../configure.in be removed? */
 #ifdef HAVE_X_WINDOWS
 #define HAVE_WINDOW_SYSTEM
 #define MULTI_KBOARD
@@ -952,6 +965,19 @@
 #define HAVE_MOUSE
 #endif
 
+/* If we're using NeXTstep, define some consequences. */
+#ifdef HAVE_NS
+#define HAVE_WINDOW_SYSTEM
+#define MULTI_KBOARD
+#define HAVE_MOUSE
+#ifdef GNUSTEP
+#define CANNOT_DUMP
+#endif
+/* PENDING: These are used tor the Carbon port only. */
+#undef MAC_OS
+#undef MAC_OSX
+#endif
+
 /* Define USER_FULL_NAME to return a string
    that is the user's full name.
    It can assume that the variable `pw'
@@ -1004,6 +1030,27 @@
 #include config_opsysfile
 #include config_machfile
 
+/* Set up some defines, C and LD flags for NeXTstep interface on GNUstep.
+  (There's probably a better place to do this, but right now the Cocoa
+   side does this in s/darwin.h, following the Carbon port, and we can't
+   parallel this exactly since GNUstep is multi-OS. */
+#ifdef HAVE_NS
+#ifdef C_SWITCH_SYSTEM
+#undef C_SWITCH_SYSTEM
+#endif
+#define C_SWITCH_SYSTEM
+#ifdef GNUSTEP
+/* See also .m.o rule in Makefile.in */
+#define C_SWITCH_X_SYSTEM -MMD -MP -D_REENTRANT -fPIC -fno-strict-aliasing -I$(GNUSTEP_SYSROOT)/Library/Headers
+#define LD_SWITCH_SITE -L$(GNUSTEP_SYSROOT)/Library/Libraries -lgnustep-gui -lgnustep-base -lobjc $(CONFIG_SYSTEM_LIBS) -lpthread
+#define GNU_OBJC_CFLAGS -fgnu-runtime -Wno-import -fconstant-string-class=NSConstantString -DGNUSTEP_BASE_LIBRARY=1 -DGNU_GUI_LIBRARY=1 -DGNU_RUNTIME=1 -DGSWARN -DGSDIAGNOSE
+#define OTHER_FILES ns-app
+#else /* COCOA */
+#define C_SWITCH_X_SYSTEM
+#define GNU_OBJC_CFLAGS
+#endif
+#endif
+
 /* Load in the conversion definitions if this system
    needs them and the source file being compiled has not
    said to inhibit this.  There should be no need for you
Index: src/dispextern.h
===================================================================
RCS file: /cvsroot/emacs/emacs/src/dispextern.h,v
retrieving revision 1.153.4.48
diff -u -r1.153.4.48 dispextern.h
--- src/dispextern.h	11 Nov 2007 00:55:19 -0000	1.153.4.48
+++ src/dispextern.h	22 Nov 2007 11:54:54 -0000
@@ -70,6 +70,14 @@
 typedef XImagePtr XImagePtr_or_DC;
 #endif
 
+#ifdef HAVE_NS
+#include "nsgui.h"
+// the following typedef needed to accomodate the MSDOS port, believe it or not
+typedef struct ns_display_info Display_Info;
+typedef Pixmap XImagePtr;
+typedef XImagePtr XImagePtr_or_DC;
+#endif
+
 #ifndef NativeRectangle
 #define NativeRectangle int
 #endif
@@ -461,7 +469,7 @@
 
 #define SET_CHAR_GLYPH_FROM_GLYPH(GLYPH, FROM)			\
      SET_CHAR_GLYPH ((GLYPH),					\
-	 	     FAST_GLYPH_CHAR ((FROM)),			\
+		     FAST_GLYPH_CHAR ((FROM)),			\
 		     FAST_GLYPH_FACE ((FROM)),			\
 		     0)
 
@@ -1564,6 +1572,11 @@
   /* If non-zero, use overstrike (to simulate bold-face).  */
   unsigned overstrike : 1;
 
+#ifdef HAVE_NS
+  /* If non-zero, use geometric rotation (to simulate italic).  */
+  unsigned synth_ital : 1;
+#endif
+
   /* Next and previous face in hash collision list of face cache.  */
   struct face *next, *prev;
 
Index: src/dispnew.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/dispnew.c,v
retrieving revision 1.318.2.41
diff -u -r1.318.2.41 dispnew.c
--- src/dispnew.c	11 Nov 2007 00:55:24 -0000	1.318.2.41
+++ src/dispnew.c	22 Nov 2007 11:54:58 -0000
@@ -65,6 +65,10 @@
 #include "macterm.h"
 #endif /* MAC_OS */
 
+#ifdef HAVE_NS
+#include "nsterm.h"
+#endif
+
 /* Include systime.h after xterm.h to avoid double inclusion of time.h.  */
 
 #include "systime.h"
@@ -6886,6 +6890,20 @@
     }
 #endif /* MAC_OS */
 
+#ifdef HAVE_NS
+  if (!inhibit_window_system
+#ifndef CANNOT_DUMP
+     && initialized
+#endif
+      )
+    {
+      Vinitial_window_system = intern("ns");
+      Vwindow_system_version = make_number(10);
+      adjust_frame_glyphs_initially ();
+      return;
+    }
+#endif
+
   /* If no window system has been specified, try to use the terminal.  */
   if (! isatty (0))
     {
@@ -6994,8 +7012,8 @@
 	 are the foreground and background colors of the terminal.  */
       struct frame *sf = SELECTED_FRAME();
 
-      FRAME_FOREGROUND_PIXEL (sf) = FACE_TTY_DEFAULT_FG_COLOR;
-      FRAME_BACKGROUND_PIXEL (sf) = FACE_TTY_DEFAULT_BG_COLOR;
+      /* FRAME_FOREGROUND_PIXEL (sf) = FACE_TTY_DEFAULT_FG_COLOR; */
+      /* FRAME_BACKGROUND_PIXEL (sf) = FACE_TTY_DEFAULT_BG_COLOR; */
       call0 (intern ("tty-set-up-initial-frame-faces"));
     }
 }
Index: src/emacs.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/emacs.c,v
retrieving revision 1.328.4.51
diff -u -r1.328.4.51 emacs.c
--- src/emacs.c	11 Nov 2007 00:55:18 -0000	1.328.4.51
+++ src/emacs.c	22 Nov 2007 11:55:00 -0000
@@ -47,6 +47,10 @@
 #include "w32heap.h" /* for prototype of sbrk */
 #endif
 
+#ifdef GNUSTEP
+#include <GSConfig.h>
+#endif
+
 #include "lisp.h"
 #include "commands.h"
 #include "intervals.h"
@@ -194,7 +198,7 @@
 extern int inherited_pgroup;
 #endif
 
-#ifdef HAVE_X_WINDOWS
+#if defined(HAVE_X_WINDOWS) || defined(HAVE_NS)
 /* If non-zero, -d was specified, meaning we're using some window system.  */
 int display_arg;
 #endif
@@ -845,7 +849,7 @@
     run_time_remap (argv[0]);
 #endif
 
-#ifdef MAC_OSX
+#if defined (MAC_OSX) || defined (COCOA)
   if (!initialized)
     unexec_init_emacs_zone ();
 #endif
@@ -1443,6 +1447,45 @@
     enable_font_backend = 0;
 #endif	/* USE_FONT_BACKEND */
 
+#ifdef HAVE_NS
+  /* Enable font backend by default. */
+#ifdef USE_FONT_BACKEND
+  enable_font_backend = 1;
+  if (argmatch (argv, argc, "-disable-font-backend", "--disable-font-backend",
+		4, NULL, &skip_args))
+    enable_font_backend = 0;
+#endif
+  ns_alloc_autorelease_pool();
+  if (!noninteractive)
+    {
+      char *tmp;
+      display_arg = 4;
+#ifdef COCOA
+      if (skip_args < argc)
+        {
+          if (!strncmp(argv[skip_args], "-psn", 4))
+            {
+              skip_args += 1;
+            }
+          else
+            {
+              if (skip_args+1 < argc && !strncmp(argv[skip_args+1], "-psn", 4))
+                  skip_args += 2;
+            }
+        }
+#endif
+      /* This used for remote operation.. not fully implemented yet. */
+      if (argmatch (argv, argc, "-_NSMachLaunch", 0, 3, &tmp, &skip_args))
+          display_arg = 4;
+      else if (argmatch (argv, argc, "-MachLaunch", 0, 3, &tmp, &skip_args))
+          display_arg = 4;
+      else if (argmatch (argv, argc, "-macosx", 0, 2, NULL, &skip_args))
+          display_arg = 4;
+      else if (argmatch (argv, argc, "-NSHost", 0, 3, &tmp, &skip_args))
+          display_arg = 4;
+    }
+#endif /* HAVE_NS */
+
 #ifdef HAVE_X_WINDOWS
   /* Stupid kludge to catch command-line display spec.  We can't
      handle this argument entirely in window system dependent code
@@ -1520,6 +1563,13 @@
     init_mac_osx_environment ();
 #endif
 
+#ifdef HAVE_NS
+#ifndef CANNOT_DUMP
+  if (initialized)
+#endif
+    ns_init_paths ();
+#endif
+
   /* egetenv is a pretty low-level facility, which may get called in
      many circumstances; it seems flimsy to put off initializing it
      until calling init_callproc.  */
@@ -1643,12 +1693,10 @@
 #endif
 #endif /* HAVE_X_WINDOWS */
 
-#ifndef HAVE_NTGUI
-#ifndef MAC_OS
+#if !defined (HAVE_NTGUI) && !defined (MAC_OS) && !defined (HAVE_NS)
       /* Called before init_window_once for Mac OS Classic.  */
       syms_of_xmenu ();
 #endif
-#endif
 
 #ifdef HAVE_NTGUI
       syms_of_w32term ();
@@ -1666,6 +1714,14 @@
       syms_of_fontset ();
 #endif /* MAC_OSX && HAVE_CARBON */
 
+#ifdef HAVE_NS
+      syms_of_nsterm ();
+      syms_of_nsfns ();
+      syms_of_nsmenu ();
+      syms_of_nsselect ();
+      syms_of_fontset ();
+#endif /* HAVE_NS */
+
 #ifdef SYMS_SYSTEM
       SYMS_SYSTEM;
 #endif
@@ -1888,6 +1944,15 @@
   { "-color", "--color", 5, 0},
   { "-no-splash", "--no-splash", 3, 0 },
   { "-no-desktop", "--no-desktop", 3, 0 },
+#ifdef HAVE_NS
+  { "-NSAutoLaunch", 0, 5, 1 },
+  { "-NXAutoLaunch", 0, 5, 1 },
+  { "-disable-font-backend", "--disable-font-backend", 65, 0 },
+  { "-_NSMachLaunch", 0, 85, 1 },
+  { "-MachLaunch", 0, 85, 1 },
+  { "-macosx", 0, 85, 0 },
+  { "-NSHost", 0, 85, 1 },
+#endif
   /* These have the same priority as ordinary file name args,
      so they are not reordered with respect to those.  */
   { "-L", "--directory", 0, 1 },
@@ -1903,6 +1968,13 @@
   { "-visit", "--visit", 0, 1 },
   { "-file", "--file", 0, 1 },
   { "-insert", "--insert", 0, 1 },
+#ifdef HAVE_NS
+  { "-NXOpen", 0, 0, 1 },
+  { "-NXOpenTemp", 0, 0, 1 },
+  { "-NSOpen", 0, 0, 1 },
+  { "-NSOpenTemp", 0, 0, 1 },
+  { "-GSFilePath", 0, 0, 1 },
+#endif
   /* This should be processed after ordinary file name args and the like.  */
   { "-kill", "--kill", -10, 0 },
 };
@@ -2196,6 +2268,10 @@
 #ifdef MSDOS
   dos_cleanup ();
 #endif
+
+#ifdef HAVE_NS
+  ns_term_shutdown (sig);
+#endif
 }
 
 
Index: src/font.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/Attic/font.c,v
retrieving revision 1.1.2.32
diff -u -r1.1.2.32 font.c
--- src/font.c	5 Nov 2007 12:52:51 -0000	1.1.2.32
+++ src/font.c	22 Nov 2007 11:55:07 -0000
@@ -48,6 +48,10 @@
 #define xassert(X)	(void) 0
 #endif
 
+#ifdef HAVE_NS
+extern Lisp_Object Qfontsize;
+#endif
+
 int enable_font_backend;
 
 Lisp_Object Qfontp;
@@ -116,8 +120,7 @@
 static struct font_driver_list *font_driver_list;
 
 static int font_pixel_size P_ ((FRAME_PTR f, Lisp_Object));
-static Lisp_Object prop_name_to_numeric P_ ((enum font_property_index,
-					     Lisp_Object));
+Lisp_Object prop_name_to_numeric P_ ((enum font_property_index, Lisp_Object));
 static Lisp_Object prop_numeric_to_name P_ ((enum font_property_index, int));
 static Lisp_Object font_open_entity P_ ((FRAME_PTR, Lisp_Object, int));
 static void build_font_family_alist P_ ((void));
@@ -161,7 +164,7 @@
    NAME is not registered in font_style_table, return Qnil.  PROP must
    be one of FONT_{WEIGHT|SLANT|SWIDTH}_INDEX.  */
 
-static Lisp_Object
+Lisp_Object
 prop_name_to_numeric (prop, name)
      enum font_property_index prop;
      Lisp_Object name;
@@ -224,9 +227,11 @@
   if (! buf)
     return Fintern (null_string, Qnil);
   bcopy (str, buf, len);
+#ifndef HAVE_NS
   for (; i < len; i++)
     if (isascii (buf[i]))
       buf[i] = tolower (buf[i]);
+#endif
   return Fintern (make_unibyte_string (buf, len), Qnil);
 }
 
@@ -2675,7 +2680,11 @@
     {
       for (i = 0; i < FONT_SPEC_MAX; i++)
 	ASET (scratch_font_spec, i, Qnil);
+#ifndef HAVE_NS
       ASET (scratch_font_spec, FONT_REGISTRY_INDEX, Qiso8859_1);
+#else
+      ASET (scratch_font_spec, FONT_REGISTRY_INDEX, Qiso10646_1);
+#endif
 
       if (! NILP (lface[LFACE_FAMILY_INDEX]))
 	font_merge_old_spec (Qnil, lface[LFACE_FAMILY_INDEX], Qnil,
@@ -2703,7 +2712,11 @@
       for (i = 0; i < FONT_SPEC_MAX; i++)
 	ASET (scratch_font_spec, i, AREF (spec, i));
       if (NILP (AREF (spec, FONT_REGISTRY_INDEX)))
+#ifndef HAVE_NS
 	ASET (scratch_font_spec, FONT_REGISTRY_INDEX, Qiso8859_1);
+#else
+	ASET (scratch_font_spec, FONT_REGISTRY_INDEX, Qiso10646_1);
+#endif
       entities = font_list_entities (frame, scratch_font_spec);
     }
 
@@ -2773,7 +2786,7 @@
       Lisp_Object entity = font_find_for_lface (f, face->lface, Qnil);
 
       if (! NILP (entity))
-	font_object = font_open_for_lface (f, entity, face->lface, Qnil);
+        font_object = font_open_for_lface (f, entity, face->lface, Qnil);
     }
 
   if (! NILP (font_object))
@@ -2784,6 +2797,23 @@
       face->font_info = (struct font_info *) font;
       face->font_info_id = 0;
       face->font_name = font->font.full_name;
+
+#ifdef HAVE_NS
+      /* If lface wanted bold, but font does not have, mark for synthesis.
+         This restores functionality in xfaces.c: load_face_font;
+         could do this for italic as well, however slant affects the rbearings
+         which are currently stored in the font_info->font struct under NS. */
+      {
+        struct ns_font *nsfont = (struct ns_font *) face->font;
+        char bold = XINT(prop_name_to_numeric(FONT_WEIGHT_INDEX,
+                                              face->lface[LFACE_WEIGHT_INDEX]))
+          > XINT(prop_name_to_numeric(FONT_WEIGHT_INDEX, intern("medium")));
+
+        if (bold && !nsfont->bold)
+          face->overstrike = 1;
+      }
+#endif
+
     }
   else
     {
@@ -2863,12 +2893,24 @@
     }
   if (pixel_size == 0)
     {
+#ifndef HAVE_NS
       pixel_size = POINT_TO_PIXEL (12.0, f->resy);
+#else
+      pixel_size = POINT_TO_PIXEL (XINT (x_default_parameter
+          (f, f->param_alist, Qfontsize, make_number(0),
+           "fontSize", "FontSize", RES_TYPE_NUMBER)),
+                                   f->resy);
+#endif
       size = make_number (pixel_size);
     }
+
   ASET (prefer, FONT_SIZE_INDEX, size);
   if (NILP (AREF (spec, FONT_REGISTRY_INDEX)))
+#ifndef HAVE_NS
     ASET (spec, FONT_REGISTRY_INDEX, Qiso8859_1);
+#else
+    ASET (spec, FONT_REGISTRY_INDEX, Qiso10646_1);
+#endif
 
   entity_list = Flist_fonts (spec, frame, make_number (1), prefer);
   if (NILP (entity_list))
@@ -3845,6 +3887,7 @@
 extern void syms_of_bdffont P_ (());
 extern void syms_of_w32font P_ (());
 extern void syms_of_atmfont P_ (());
+extern void syms_of_nsfont P_ (());
 
 void
 syms_of_font ()
@@ -3955,6 +3998,9 @@
 #ifdef MAC_OS
   syms_of_atmfont ();
 #endif	/* MAC_OS */
+#ifdef HAVE_NS
+  syms_of_nsfont ();
+#endif	/* HAVE_NS */
 }
 
 /* arch-tag: 74c9475d-5976-4c93-a327-942ae3072846
Index: src/font.h
===================================================================
RCS file: /cvsroot/emacs/emacs/src/Attic/font.h,v
retrieving revision 1.1.2.22
diff -u -r1.1.2.22 font.h
--- src/font.h	16 Sep 2007 10:25:34 -0000	1.1.2.22
+++ src/font.h	22 Nov 2007 11:55:09 -0000
@@ -502,6 +502,9 @@
 #ifdef MAC_OS
 extern struct font_driver atmfont_driver;
 #endif	/* MAC_OS */
+#ifdef HAVE_NS
+extern struct font_driver nsfont_driver;
+#endif	/* HAVE_NS */
 
 #endif	/* not EMACS_FONT_H */
 
Index: src/fontset.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/fontset.c,v
retrieving revision 1.77.4.53
diff -u -r1.77.4.53 fontset.c
--- src/fontset.c	15 Oct 2007 05:03:15 -0000	1.77.4.53
+++ src/fontset.c	22 Nov 2007 11:55:13 -0000
@@ -55,6 +55,9 @@
 #ifdef MAC_OS
 #include "macterm.h"
 #endif
+#ifdef HAVE_NS
+#include "nsterm.h"
+#endif
 #include "termhooks.h"
 
 #ifdef USE_FONT_BACKEND
@@ -515,6 +518,9 @@
     return -1;
 
   if (NILP (AREF (font_def, 2))
+#ifdef HAVE_NS  /* PENDING.. avert crash until we can DTRT. */
+      && get_font_repertory_func
+#endif
       && NILP (Fassq (make_number (font_info->font_idx),
 		      FONTSET_REPERTORY (fontset))))
     {
@@ -1287,7 +1293,9 @@
   Lisp_Object tem;
   int i;
 
+#ifndef HAVE_NS
   name = Fdowncase (name);
+#endif
   if (name_pattern != 1)
     {
       tem = Frassoc (name, Vfontset_alias_alist);
@@ -1608,7 +1616,11 @@
 	if (! NILP (AREF (font_spec, j)))
 	  {
 	    CHECK_STRING (AREF (font_spec, j));
+#ifndef HAVE_NS
 	    ASET (font_spec, j, Fdowncase (AREF (font_spec, j)));
+#else
+	    ASET (font_spec, j, AREF (font_spec, j));
+#endif
 	  }
       family = AREF (font_spec, FONT_SPEC_FAMILY_INDEX);
       /* REGISTRY should not be omitted.  */
@@ -1623,10 +1635,14 @@
       if (! NILP (family))
 	{
 	  CHECK_STRING (family);
+#ifndef HAVE_NS
 	  family = Fdowncase (family);
+#endif
 	}
       CHECK_STRING (registry);
+#ifndef HAVE_NS
       registry = Fdowncase (registry);
+#endif
       font_spec = Fmake_vector (make_number (FONT_SPEC_MAX_INDEX), Qnil);
       ASET (font_spec, FONT_SPEC_FAMILY_INDEX, family);
       ASET (font_spec, FONT_SPEC_REGISTRY_INDEX, registry);
@@ -1634,7 +1650,9 @@
   else
     {
       CHECK_STRING (font_spec);
+#ifndef HAVE_NS
       font_spec = Fdowncase (font_spec);
+#endif
     }
 
   if (STRINGP (font_spec))
@@ -1778,7 +1796,9 @@
   id = fs_query_fontset (name, 0);
   if (id < 0)
     {
+#ifndef HAVE_NS
       name = Fdowncase (name);
+#endif
       val = split_font_name_into_vector (name);
       if (NILP (val) || NILP (AREF (val, 12)) || NILP (AREF (val, 13)))
 	error ("Fontset name must be in XLFD format");
@@ -1829,7 +1849,9 @@
   Lisp_Object vec;
   int id;
 
+#ifndef HAVE_NS
   fontname = Fdowncase (fontname);
+#endif
   val = Fassoc (fontname, auto_fontset_alist);
   if (CONSP (val))
     return XINT (XCDR (val));
@@ -1896,11 +1918,17 @@
 	abort ();
     }
   fontset = make_fontset (Qnil, name, Qnil);
+
   FONTSET_ASCII (fontset) = font_name;
   font_spec = Fcons (SYMBOL_NAME (AREF (font_spec, FONT_FAMILY_INDEX)),
 		     SYMBOL_NAME (AREF (font_spec, FONT_REGISTRY_INDEX)));
   Fset_fontset_font (name, Qlatin, font_spec, Qnil, Qnil);
   Fset_fontset_font (name, Qnil, font_spec, Qnil, Qnil);
+
+#ifdef HAVE_NS
+  nsfont_make_fontset_for_font(name, font_object);
+#endif
+
   return XINT (FONTSET_ID (fontset));
 }
 
@@ -1976,7 +2004,9 @@
   (*check_window_system_func) ();
 
   CHECK_STRING (name);
+#ifndef HAVE_NS
   name = Fdowncase (name);
+#endif
   if (NILP (frame))
     frame = selected_frame;
   CHECK_LIVE_FRAME (frame);
Index: src/frame.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/frame.c,v
retrieving revision 1.300.2.48
diff -u -r1.300.2.48 frame.c
--- src/frame.c	11 Nov 2007 00:55:17 -0000	1.300.2.48
+++ src/frame.c	22 Nov 2007 11:55:22 -0000
@@ -33,6 +33,9 @@
 #ifdef MAC_OS
 #include "macterm.h"
 #endif
+#ifdef HAVE_NS
+#include "nsterm.h"
+#endif
 #include "buffer.h"
 /* These help us bind and responding to switch-frame events.  */
 #include "commands.h"
@@ -72,7 +75,7 @@
 Lisp_Object Qframep, Qframe_live_p;
 Lisp_Object Qicon, Qmodeline;
 Lisp_Object Qonly;
-Lisp_Object Qx, Qw32, Qmac, Qpc;
+Lisp_Object Qx, Qw32, Qmac, Qpc, Qns;
 Lisp_Object Qvisible;
 Lisp_Object Qdisplay_type;
 Lisp_Object Qbackground_mode;
@@ -204,7 +207,8 @@
 Value is t for a termcap frame (a character-only terminal),
 `x' for an Emacs frame that is really an X window,
 `w32' for an Emacs frame that is a window on MS-Windows display,
-`mac' for an Emacs frame on a Macintosh display,
+`mac' for an Emacs frame on a Macintosh 8/9 X-Carbon display,
+`ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
 `pc' for a direct-write MS-DOS frame.
 See also `frame-live-p'.  */)
      (object)
@@ -225,6 +229,8 @@
       return Qpc;
     case output_mac:
       return Qmac;
+    case output_ns:
+      return Qns;
     default:
       abort ();
     }
@@ -903,6 +909,11 @@
     }
 #endif /* !WINDOWSNT */
 
+#ifdef COCOA
+  /* term gets no other notification of this */
+  Fraise_frame(Qnil);
+#endif
+
   /* We want to make sure that the next event generates a frame-switch
      event to the appropriate frame.  This seems kludgy to me, but
      before you take it out, make sure that evaluating something like
@@ -2991,8 +3002,9 @@
 
 	  old_value = get_frame_param (f, prop);
  	  fullscreen_is_being_set |= EQ (prop, Qfullscreen);
-
+#ifndef HAVE_NS  //PENDING: ensure font attrs change goes through
 	  if (NILP (Fequal (val, old_value)))
+#endif
 	    {
 	      /* For :font attributes, the frame_parm_handler
 		 x_set_font calls `face-set-after-frame-default'.
@@ -3954,6 +3966,9 @@
 	    case RES_TYPE_BOOLEAN:
 	      tem = Fdowncase (tem);
 	      if (!strcmp (SDATA (tem), "on")
+#ifdef HAVE_NS
+                  || !strcmp(SDATA(tem), "yes")
+#endif
 		  || !strcmp (SDATA (tem), "true"))
 		return Qt;
 	      else
@@ -3969,9 +3984,15 @@
 		Lisp_Object lower;
 		lower = Fdowncase (tem);
 		if (!strcmp (SDATA (lower), "on")
+#ifdef HAVE_NS
+                    || !strcmp(SDATA(lower), "yes")
+#endif
 		    || !strcmp (SDATA (lower), "true"))
 		  return Qt;
 		else if (!strcmp (SDATA (lower), "off")
+#ifdef HAVE_NS
+                      || !strcmp(SDATA(lower), "no")
+#endif
 		      || !strcmp (SDATA (lower), "false"))
 		  return Qnil;
 		else
@@ -4371,6 +4392,8 @@
   staticpro (&Qpc);
   Qmac = intern ("mac");
   staticpro (&Qmac);
+  Qns = intern ("ns");
+  staticpro (&Qns);
   Qvisible = intern ("visible");
   staticpro (&Qvisible);
   Qbuffer_predicate = intern ("buffer-predicate");
@@ -4473,8 +4496,8 @@
   DEFVAR_LISP ("default-frame-scroll-bars", &Vdefault_frame_scroll_bars,
 	       doc: /* Default position of scroll bars on this window-system.  */);
 #ifdef HAVE_WINDOW_SYSTEM
-#if defined(HAVE_NTGUI) || defined(MAC_OS)
-  /* MS-Windows has scroll bars on the right by default.  */
+#if defined(HAVE_NTGUI) || defined(MAC_OS) || defined(COCOA)
+  /* MS-Windows and Mac OS X have scroll bars on the right by default.  */
   Vdefault_frame_scroll_bars = Qright;
 #else
   Vdefault_frame_scroll_bars = Qleft;
@@ -4540,7 +4563,7 @@
 handles focus, since there is no way in general for Emacs to find out
 automatically.  */);
 #ifdef HAVE_WINDOW_SYSTEM
-#if defined(HAVE_NTGUI) || defined(MAC_OS)
+#if defined(HAVE_NTGUI) || defined(MAC_OS) || defined(HAVE_NS)
   focus_follows_mouse = 0;
 #else
   focus_follows_mouse = 1;
Index: src/frame.h
===================================================================
RCS file: /cvsroot/emacs/emacs/src/frame.h,v
retrieving revision 1.103.2.22
diff -u -r1.103.2.22 frame.h
--- src/frame.h	27 Oct 2007 09:11:44 -0000	1.103.2.22
+++ src/frame.h	22 Nov 2007 11:55:24 -0000
@@ -52,7 +52,8 @@
   output_x_window,
   output_msdos_raw,
   output_w32,
-  output_mac
+  output_mac,
+  output_ns
 };
 
 enum vertical_scroll_bar_type
@@ -230,7 +231,7 @@
      auto-resize-tool-bar is set to grow-only.  */
   unsigned minimize_tool_bar_window_p : 1;
 
-#if defined (USE_GTK) || defined (MAC_OS)
+#if defined (USE_GTK) || defined (HAVE_NS) || defined (MAC_OS)
   /* Nonzero means using a tool bar that comes from the toolkit.  */
   int external_tool_bar;
 #endif
@@ -320,6 +321,7 @@
     struct x_output *x;         /* xterm.h */
     struct w32_output *w32;     /* w32term.h */
     struct mac_output *mac;     /* macterm.h */
+    struct ns_output *ns;       /* nsterm.h */
     EMACS_INT nothing;
   }
   output_data;
@@ -346,7 +348,7 @@
   int menu_bar_lines;
 
 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (MAC_OS) \
-    || defined (USE_GTK)
+    || defined (HAVE_NS) || defined (USE_GTK)
   /* Nonzero means using a menu bar that comes from the X toolkit.  */
   int external_menu_bar;
 #endif
@@ -500,6 +502,7 @@
 #define FRAME_W32_P(f) ((f)->output_method == output_w32)
 #define FRAME_MSDOS_P(f) ((f)->output_method == output_msdos_raw)
 #define FRAME_MAC_P(f) ((f)->output_method == output_mac)
+#define FRAME_NS_P(f) ((f)->output_method == output_ns)
 
 /* FRAME_WINDOW_P tests whether the frame is a window, and is
    defined to be the predicate for the window system being used.  */
@@ -513,6 +516,9 @@
 #ifdef MAC_OS
 #define FRAME_WINDOW_P(f) FRAME_MAC_P (f)
 #endif
+#ifdef HAVE_NS
+#define FRAME_WINDOW_P(f) FRAME_NS_P(f)
+#endif
 #ifndef FRAME_WINDOW_P
 #define FRAME_WINDOW_P(f) (0)
 #endif
@@ -551,7 +557,7 @@
 
 /* Nonzero if this frame should display a tool bar
    in a way that does not use any text lines.  */
-#if defined (USE_GTK) || defined (MAC_OS)
+#if defined (USE_GTK) || defined (HAVE_NS) || defined (MAC_OS)
 #define FRAME_EXTERNAL_TOOL_BAR(f) (f)->external_tool_bar
 #else
 #define FRAME_EXTERNAL_TOOL_BAR(f) 0
@@ -570,7 +576,7 @@
 /* Nonzero if this frame should display a menu bar
    in a way that does not use any text lines.  */
 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (MAC_OS) \
-    || defined (USE_GTK)
+     || defined (HAVE_NS) || defined (USE_GTK)
 #define FRAME_EXTERNAL_MENU_BAR(f) (f)->external_menu_bar
 #else
 #define FRAME_EXTERNAL_MENU_BAR(f) 0
@@ -1023,7 +1029,7 @@
 extern Lisp_Object Qheight, Qwidth;
 extern Lisp_Object Qminibuffer, Qmodeline;
 extern Lisp_Object Qonly;
-extern Lisp_Object Qx, Qw32, Qmac, Qpc;
+extern Lisp_Object Qx, Qw32, Qmac, Qpc, Qns;
 extern Lisp_Object Qvisible;
 extern Lisp_Object Qdisplay_type;
 extern Lisp_Object Qbackground_mode;
Index: src/fringe.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/fringe.c,v
retrieving revision 1.10.2.23
diff -u -r1.10.2.23 fringe.c
--- src/fringe.c	11 Oct 2007 16:20:36 -0000	1.10.2.23
+++ src/fringe.c	22 Nov 2007 11:55:25 -0000
@@ -484,7 +484,7 @@
 static Lisp_Object *fringe_faces;
 static int max_fringe_bitmaps;
 
-static int max_used_fringe_bitmap = MAX_STANDARD_FRINGE_BITMAPS;
+int max_used_fringe_bitmap = MAX_STANDARD_FRINGE_BITMAPS;
 
 
 /* Lookup bitmap number for symbol BITMAP.
Index: src/getloadavg.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/getloadavg.c,v
retrieving revision 1.46.2.6
diff -u -r1.46.2.6 getloadavg.c
--- src/getloadavg.c	13 Aug 2007 13:48:11 -0000	1.46.2.6
+++ src/getloadavg.c	22 Nov 2007 11:55:26 -0000
@@ -420,7 +420,7 @@
 #  define host_self mach_host_self
 # endif
 
-# ifdef NeXT
+# if defined(NeXT) || defined(RHAPSODY) || defined(DARWIN) || defined(MAC_OSX)
 #  ifdef HAVE_MACH_MACH_H
 #   include <mach/mach.h>
 #  else
@@ -467,7 +467,7 @@
 
 /* Avoid static vars inside a function since in HPUX they dump as pure.  */
 
-# ifdef NeXT
+# if defined(NeXT) || defined(RHAPSODY) || defined(DARWIN) || defined(MAC_OSX)
 static processor_set_t default_set;
 static int getloadavg_initialized;
 # endif /* NeXT */
@@ -647,7 +647,8 @@
 
 # endif /* __NetBSD__ */
 
-# if !defined (LDAV_DONE) && defined (NeXT)
+# if !defined (LDAV_DONE) && ( defined (NeXT) || defined(RHAPSODY) \
+                              || defined(DARWIN) || defined(MAC_OSX) )
 #  define LDAV_DONE
   /* The NeXT code was adapted from iscreen 3.2.  */
 
Index: src/image.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/image.c,v
retrieving revision 1.6.4.49
diff -u -r1.6.4.49 image.c
--- src/image.c	11 Nov 2007 00:55:20 -0000	1.6.4.49
+++ src/image.c	22 Nov 2007 11:55:35 -0000
@@ -127,6 +127,33 @@
 #endif /* MAC_OS */
 
 
+#ifdef HAVE_NS
+#include "nsterm.h"
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#undef COLOR_TABLE_SUPPORT
+
+#define x_defined_color ns_defined_color
+#define FRAME_X_SCREEN(f) 0
+#define DefaultDepthOfScreen(screen) ns_display_list->n_planes
+
+typedef struct ns_bitmap_record Bitmap_Record;
+
+///TODO
+#define GET_PIXEL(ximg, x, y) XGetPixel(ximg, x, y)
+#define NO_PIXMAP 0
+
+#define RGB_PIXEL_COLOR unsigned long
+#define ZPixmap 0
+
+#define PIX_MASK_RETAIN	0
+#define PIX_MASK_DRAW	1
+
+#define FRAME_X_VISUAL FRAME_NS_DISPLAY_INFO(f)->visual
+#endif /* HAVE_NS */
+
+
 /* Search path for bitmap files.  */
 
 Lisp_Object Vx_bitmap_file_path;
@@ -324,6 +351,32 @@
 #endif /* USE_CG_DRAWING */
 #endif /* MAC_OS */
 
+#ifdef HAVE_NS
+XImagePtr
+XGetImage (Display *display, Pixmap pixmap, int x, int y,
+           unsigned int width, unsigned int height,
+           unsigned long plane_mask, int format)
+{
+  /* PENDING: not sure what this function is supposed to do.. */
+  ns_retain_object(pixmap);
+  return pixmap;
+}
+
+// use with imgs created by ns_image_for_XPM
+unsigned long
+XGetPixel (XImagePtr ximage, int x, int y)
+{
+  return ns_get_pixel(ximage, x, y);
+}
+
+// use with imgs created by ns_image_for_XPM; alpha set to 1
+void
+XPutPixel (XImagePtr ximage, int x, int y, unsigned long pixel)
+{
+  ns_put_pixel(ximage, x, y, pixel);
+}
+#endif /* HAVE_NS */
+
 
 /* Functions to access the contents of a bitmap, given an id.  */
 
@@ -440,12 +493,23 @@
     return -1;
 #endif
 
+#ifdef HAVE_NS
+  void *bitmap = ns_image_from_XBM(bits, width, height);
+  if (!bitmap)
+      return -1;
+#endif
+
   id = x_allocate_bitmap_record (f);
 #ifdef MAC_OS
   dpyinfo->bitmaps[id - 1].bitmap_data = (char *) xmalloc (height * width);
   bcopy (bits, dpyinfo->bitmaps[id - 1].bitmap_data, height * width);
 #endif  /* MAC_OS */
 
+#ifdef HAVE_NS
+  dpyinfo->bitmaps[id - 1].img = bitmap;
+  dpyinfo->bitmaps[id - 1].depth = 1;
+#endif
+
   dpyinfo->bitmaps[id - 1].file = NULL;
   dpyinfo->bitmaps[id - 1].height = height;
   dpyinfo->bitmaps[id - 1].width = width;
@@ -473,6 +537,8 @@
      struct frame *f;
      Lisp_Object file;
 {
+  Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
+
 #ifdef MAC_OS
   return -1;  /* MAC_TODO : bitmap support */
 #endif  /* MAC_OS */
@@ -481,8 +547,26 @@
   return -1;  /* W32_TODO : bitmap support */
 #endif /* HAVE_NTGUI */
 
+#ifdef HAVE_NS
+  int id;
+  void *bitmap = ns_image_from_file(file);
+
+  if (!bitmap)
+      return -1;
+
+
+  id = x_allocate_bitmap_record (f);
+  dpyinfo->bitmaps[id - 1].img = bitmap;
+  dpyinfo->bitmaps[id - 1].refcount = 1;
+  dpyinfo->bitmaps[id - 1].file = (char *) xmalloc (SBYTES (file) + 1);
+  dpyinfo->bitmaps[id - 1].depth = 1;
+  dpyinfo->bitmaps[id - 1].height = ns_image_width(bitmap);
+  dpyinfo->bitmaps[id - 1].width = ns_image_height(bitmap);
+  strcpy (dpyinfo->bitmaps[id - 1].file, SDATA (file));
+  return id;
+#endif
+
 #ifdef HAVE_X_WINDOWS
-  Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
   unsigned int width, height;
   Pixmap bitmap;
   int xhot, yhot, result, id;
@@ -551,6 +635,10 @@
   bm->bitmap_data = NULL;
 #endif  /* MAC_OS */
 
+#ifdef HAVE_NS
+  ns_release_object(bm->img);
+#endif
+
   if (bm->file)
     {
       xfree (bm->file);
@@ -1326,7 +1414,8 @@
 	     because a typical font is `top-heavy' (due to the presence
 	     uppercase letters), so the image placement should err towards
 	     being top-heavy too.  It also just generally looks better.  */
-	  ascent = (height + face->font->ascent - face->font->descent + 1) / 2;
+	  ascent = (height + FONT_BASE(face->font) - FONT_DESCENT(face->font)
+                    + 1) / 2;
 #endif /* HAVE_NTGUI */
 	}
       else
@@ -1395,6 +1484,14 @@
 #define Free_Pixmap(display, pixmap) \
   DeleteObject (pixmap)
 
+#elif defined (HAVE_NS)
+
+#define Destroy_Image(ximg, dummy) \
+  ns_release_object(ximg)
+
+#define Free_Pixmap(display, pixmap) \
+  ns_release_object(pixmap)
+
 #else
 
 #define Destroy_Image(ximg, dummy) \
@@ -1403,7 +1500,7 @@
 #define Free_Pixmap(display, pixmap) \
   XFreePixmap (display, pixmap)
 
-#endif /* HAVE_NTGUI */
+#endif /* !HAVE_NTGUI && !HAVE_NS */
 
 
 /* Return the `background' field of IMG.  If IMG doesn't have one yet,
@@ -1439,6 +1536,9 @@
 	}
 
       img->background = four_corners_best (ximg, img->corners, img->width, img->height);
+#ifdef HAVE_NS
+      ns_retain_object(img->background);
+#endif
 
       if (free_ximg)
 	Destroy_Image (ximg, prev);
@@ -1474,7 +1574,7 @@
 #ifndef HAVE_NTGUI
 	      mask = XGetImage (FRAME_X_DISPLAY (f), img->mask,
 				0, 0, img->width, img->height, ~0, ZPixmap);
-#else
+#else /* HAVE_NTGUI */
 	      HDC frame_dc = get_frame_dc (f);
 	      mask = CreateCompatibleDC (frame_dc);
 	      release_frame_dc (f, frame_dc);
@@ -1484,6 +1584,9 @@
 
 	  img->background_transparent
 	    = (four_corners_best (mask, img->corners, img->width, img->height) == PIX_MASK_RETAIN);
+#ifdef HAVE_NS
+          ns_retain_object(img->background_transparent);
+#endif
 
 	  if (free_mask)
 	    Destroy_Image (mask, prev);
@@ -1526,6 +1629,10 @@
     {
       Free_Pixmap (FRAME_X_DISPLAY (f), img->pixmap);
       img->pixmap = NO_PIXMAP;
+#ifdef HAVE_NS
+      if (img->background_valid)
+        ns_release_object(img->background);
+#endif
       img->background_valid = 0;
     }
 
@@ -1533,6 +1640,10 @@
     {
       Free_Pixmap (FRAME_X_DISPLAY (f), img->mask);
       img->mask = NO_PIXMAP;
+#ifdef HAVE_NS
+      if (img->background_transparent_valid)
+        ns_release_object(img->background_transparent);
+#endif
       img->background_transparent_valid = 0;
     }
 
@@ -2288,6 +2399,18 @@
   return 1;
 
 #endif  /* MAC_OS */
+
+#ifdef HAVE_NS
+  *pixmap = ns_image_for_XPM(width, height, depth);
+  if (*pixmap == 0)
+    {
+      *ximg = NULL;
+      image_error ("Unable to allocate NSImage for XPM pixmap", Qnil, Qnil);
+      return 0;
+    }
+  *ximg = *pixmap;
+  return 1;
+#endif
 }
 
 
@@ -2313,6 +2436,9 @@
 #ifdef MAC_OS
       XDestroyImage (ximg);
 #endif /* MAC_OS */
+#ifdef HAVE_NS
+      ns_release_object(ximg);
+#endif /* HAVE_NS */
     }
 }
 
@@ -2347,6 +2473,11 @@
 #ifdef MAC_OS
   xassert (ximg == pixmap);
 #endif  /* MAC_OS */
+
+#ifdef HAVE_NS
+  xassert (ximg == pixmap);
+  ns_retain_object(ximg);
+#endif
 }
 
 
@@ -3169,6 +3300,10 @@
   /* If colors were specified, transfer the bitmap to a color one.  */
   if (non_default_colors)
     convert_mono_to_color_image (f, img, fg, bg);
+
+#elif defined (HAVE_NS)
+  img->pixmap = ns_image_from_XBM(data, img->width, img->height);
+
 #else
   img->pixmap
     = XCreatePixmapFromBitmapData (FRAME_X_DISPLAY (f),
@@ -3177,7 +3312,7 @@
 				   img->width, img->height,
 				   fg, bg,
 				   DefaultDepthOfScreen (FRAME_X_SCREEN (f)));
-#endif /* HAVE_NTGUI */
+#endif /* !HAVE_NTGUI && !HAVE_NS */
 }
 
 
@@ -3548,13 +3683,13 @@
 			      XPM images
  ***********************************************************************/
 
-#if defined (HAVE_XPM) || defined (MAC_OS)
+#if defined (HAVE_XPM) || defined (MAC_OS) || defined (HAVE_NS)
 
 static int xpm_image_p P_ ((Lisp_Object object));
 static int xpm_load P_ ((struct frame *f, struct image *img));
 static int xpm_valid_color_symbols_p P_ ((Lisp_Object));
 
-#endif /* HAVE_XPM || MAC_OS */
+#endif /* HAVE_XPM || MAC_OS || HAVE_NS */
 
 #ifdef HAVE_XPM
 #ifdef HAVE_NTGUI
@@ -3577,7 +3712,7 @@
 #endif /* HAVE_NTGUI */
 #endif /* HAVE_XPM */
 
-#if defined (HAVE_XPM) || defined (MAC_OS)
+#if defined (HAVE_XPM) || defined (MAC_OS) || defined (HAVE_NS)
 /* The symbol `xpm' identifying XPM-format images.  */
 
 Lisp_Object Qxpm;
@@ -3904,7 +4039,7 @@
 	      || xpm_valid_color_symbols_p (fmt[XPM_COLOR_SYMBOLS].value)));
 }
 
-#endif /* HAVE_XPM || MAC_OS */
+#endif /* HAVE_XPM || MAC_OS || HAVE_NS */
 
 #if defined (HAVE_XPM) && defined (HAVE_X_WINDOWS)
 int
@@ -4183,7 +4318,7 @@
 
 #endif /* HAVE_XPM */
 
-#ifdef MAC_OS
+#if defined (MAC_OS) || ( defined (HAVE_NS) && !defined (HAVE_XPM) )
 
 /* XPM support functions for Mac OS where libxpm is not available.
    Only XPM version 3 (without any extensions) is supported.  */
@@ -4523,7 +4658,11 @@
 		color_val = Qt;
 	      else if (x_defined_color (f, SDATA (XCDR (specified_color)),
 					&cdef, 0))
+#ifndef HAVE_NS
 		color_val = make_number (cdef.pixel);
+#else
+                color_val = make_unibyte_string(&cdef.pixel, sizeof (void *));
+#endif
 	    }
 	}
       if (NILP (color_val) && max_key > 0)
@@ -4531,7 +4670,11 @@
 	  if (xstricmp (max_color, "None") == 0)
 	    color_val = Qt;
 	  else if (x_defined_color (f, max_color, &cdef, 0))
+#ifndef HAVE_NS
 	    color_val = make_number (cdef.pixel);
+#else
+            color_val = make_unibyte_string(&cdef.pixel, sizeof (void *));
+#endif
 	}
       if (!NILP (color_val))
 	(*put_color_table) (color_table, beg, chars_per_pixel, color_val);
@@ -4541,8 +4684,11 @@
 
   if (!x_create_x_image_and_pixmap (f, width, height, 0,
 				    &ximg, &img->pixmap)
+#ifndef HAVE_NS
       || !x_create_x_image_and_pixmap (f, width, height, 1,
-				       &mask_img, &img->mask))
+				       &mask_img, &img->mask)
+#endif
+      )
     {
       image_error ("Out of memory (%s)", img->spec, Qnil);
       goto error;
@@ -4559,12 +4705,22 @@
 	  Lisp_Object color_val =
 	    (*get_color_table) (color_table, str, chars_per_pixel);
 
+#ifndef HAVE_NS
 	  XPutPixel (ximg, x, y,
 		     (INTEGERP (color_val) ? XINT (color_val)
 		      : FRAME_FOREGROUND_PIXEL (f)));
+#else
+          if (STRINGP (color_val))
+            XPutPixel (ximg, x, y, *(void **)SDATA(color_val));
+#endif
+#ifndef HAVE_NS
 	  XPutPixel (mask_img, x, y,
 		     (!EQ (color_val, Qt) ? PIX_MASK_DRAW
 		      : (have_mask = 1, PIX_MASK_RETAIN)));
+#else
+          if (EQ(color_val, Qt))
+            ns_set_alpha(ximg, x, y, 0);
+#endif
 	}
       if (y + 1 < height)
 	expect (',');
@@ -4579,6 +4735,7 @@
 
   x_put_x_image (f, ximg, img->pixmap, width, height);
   x_destroy_x_image (ximg);
+#ifndef HAVE_NS
   if (have_mask)
     {
       /* Fill in the background_transparent field while we have the
@@ -4594,7 +4751,7 @@
       Free_Pixmap (FRAME_X_DISPLAY (f), img->mask);
       img->mask = NO_PIXMAP;
     }
-
+#endif
   return 1;
 
  failure:
@@ -4660,7 +4817,7 @@
   return success_p;
 }
 
-#endif /* MAC_OS */
+#endif /* MAC_OS || (HAVE_NS && !HAVE_XPM) */
 
 
 
@@ -4930,6 +5087,10 @@
   pixel = PALETTERGB (r >> 8, g >> 8, b >> 8);
 #endif /* HAVE_NTGUI */
 
+#ifdef HAVE_NS
+  pixel = ns_get_rgb_color((float)r / 65536.0, (float)g / 65536.0,
+                           (float)b / 65536.0 , 1.0);
+#endif /* HAVE_NS */
   return pixel;
 }
 
@@ -5045,6 +5206,11 @@
 	      p->green = 256 * GetGValue (p->pixel);
 	      p->blue = 256 * GetBValue (p->pixel);
 #endif /* HAVE_NTGUI */
+#ifdef HAVE_NS
+	      p->red = ns_get_red(p->pixel);
+	      p->green = ns_get_green(p->pixel);
+	      p->blue = ns_get_blue(p->pixel);
+#endif
 	    }
 	}
 #endif /* HAVE_X_WINDOWS */
@@ -5116,8 +5282,8 @@
      XColor *colors;
 {
   int x, y;
-  XImagePtr oimg;
-  Pixmap pixmap;
+  XImagePtr oimg = NULL;
+  Pixmap pixmap = NULL;
   XColor *p;
 
   init_color_table ();
@@ -5330,6 +5496,8 @@
       Display *dpy = FRAME_X_DISPLAY (f);
       GC gc;
 
+#ifndef HAVE_NS  //PENDING
+
 #ifdef MAC_OS
 #define MaskForeground(f)  PIX_MASK_DRAW
 #else
@@ -5354,6 +5522,7 @@
 		     img->width - 1, 0);
 	  XFreeGC (dpy, gc);
 	}
+#endif /* !HAVE_NS */
 #else
       HDC hdc, bmpdc;
       HGDIOBJ prev;
@@ -5419,11 +5588,13 @@
     }
 
 #ifndef HAVE_NTGUI
+#ifndef HAVE_NS
   /* Create an image and pixmap serving as mask.  */
   rc = x_create_x_image_and_pixmap (f, img->width, img->height, 1,
 				    &mask_img, &img->mask);
   if (!rc)
     return 0;
+#endif /* !HAVE_NS */
 
   /* Get the X image of IMG->pixmap.  */
   ximg = XGetImage (FRAME_X_DISPLAY (f), img->pixmap, 0, 0,
@@ -5477,16 +5648,21 @@
 #ifndef HAVE_NTGUI
   for (y = 0; y < img->height; ++y)
     for (x = 0; x < img->width; ++x)
+#ifndef HAVE_NS
       XPutPixel (mask_img, x, y, (XGetPixel (ximg, x, y) != bg
 				  ? PIX_MASK_DRAW : PIX_MASK_RETAIN));
-
+#else
+      if (XGetPixel (ximg, x, y) == bg)
+        ns_set_alpha(ximg, x, y, 0);
+#endif /* HAVE_NS */
+#ifndef HAVE_NS
   /* Fill in the background_transparent field while we have the mask handy. */
   image_background_transparent (img, f, mask_img);
 
   /* Put mask_img into img->mask.  */
   x_put_x_image (f, mask_img, img->mask, img->width, img->height);
   x_destroy_x_image (mask_img);
-
+#endif /* !HAVE_NS */
 #else
   for (y = 0; y < img->height; ++y)
     for (x = 0; x < img->width; ++x)
@@ -5917,7 +6093,7 @@
 				 PNG
  ***********************************************************************/
 
-#if defined (HAVE_PNG) || defined (MAC_OS)
+#if defined (HAVE_PNG) || defined (MAC_OS) || defined (HAVE_NS)
 
 /* Function prototypes.  */
 
@@ -5989,7 +6165,7 @@
   return fmt[PNG_FILE].count + fmt[PNG_DATA].count == 1;
 }
 
-#endif /* HAVE_PNG || MAC_OS */
+#endif /* HAVE_PNG || MAC_OS || HAVE_NS */
 
 
 #ifdef HAVE_PNG
@@ -6578,6 +6754,17 @@
 }
 #endif  /* MAC_OS */
 
+#ifdef HAVE_NS
+static int
+png_load (struct frame *f, struct image *img)
+{
+  return ns_load_image(f, img,
+                       image_spec_value (img->spec, QCfile, NULL),
+                       image_spec_value (img->spec, QCdata, NULL));
+}
+#endif  /* HAVE_NS */
+
+
 #endif /* !HAVE_PNG */
 
 
@@ -6586,7 +6773,7 @@
 				 JPEG
  ***********************************************************************/
 
-#if defined (HAVE_JPEG) || defined (MAC_OS)
+#if defined (HAVE_JPEG) || defined (MAC_OS) || defined (HAVE_NS)
 
 static int jpeg_image_p P_ ((Lisp_Object object));
 static int jpeg_load P_ ((struct frame *f, struct image *img));
@@ -6657,7 +6844,7 @@
   return fmt[JPEG_FILE].count + fmt[JPEG_DATA].count == 1;
 }
 
-#endif /* HAVE_JPEG || MAC_OS */
+#endif /* HAVE_JPEG || MAC_OS || HAVE_NS */
 
 #ifdef HAVE_JPEG
 
@@ -7155,6 +7342,16 @@
 }
 #endif  /* MAC_OS */
 
+#ifdef HAVE_NS
+static int
+jpeg_load (struct frame *f, struct image *img)
+{
+  return ns_load_image(f, img,
+                       image_spec_value (img->spec, QCfile, NULL),
+                       image_spec_value (img->spec, QCdata, NULL));
+}
+#endif  /* HAVE_NS */
+
 #endif /* !HAVE_JPEG */
 
 
@@ -7163,7 +7360,7 @@
 				 TIFF
  ***********************************************************************/
 
-#if defined (HAVE_TIFF) || defined (MAC_OS)
+#if defined (HAVE_TIFF) || defined (MAC_OS) || defined (HAVE_NS)
 
 static int tiff_image_p P_ ((Lisp_Object object));
 static int tiff_load P_ ((struct frame *f, struct image *img));
@@ -7233,7 +7430,7 @@
   return fmt[TIFF_FILE].count + fmt[TIFF_DATA].count == 1;
 }
 
-#endif /* HAVE_TIFF || MAC_OS */
+#endif /* HAVE_TIFF || MAC_OS || HAVE_NS */
 
 #ifdef HAVE_TIFF
 
@@ -7576,6 +7773,16 @@
 }
 #endif /* MAC_OS */
 
+#ifdef HAVE_NS
+static int
+tiff_load (struct frame *f, struct image *img)
+{
+  return ns_load_image(f, img,
+                       image_spec_value (img->spec, QCfile, NULL),
+                       image_spec_value (img->spec, QCdata, NULL));
+}
+#endif  /* HAVE_NS */
+
 #endif /* !HAVE_TIFF */
 
 
@@ -7584,7 +7791,7 @@
 				 GIF
  ***********************************************************************/
 
-#if defined (HAVE_GIF) || defined (MAC_OS)
+#if defined (HAVE_GIF) || defined (MAC_OS) || defined (HAVE_NS)
 
 static int gif_image_p P_ ((Lisp_Object object));
 static int gif_load P_ ((struct frame *f, struct image *img));
@@ -8209,6 +8416,16 @@
 }
 #endif /* MAC_OS */
 
+#ifdef HAVE_NS
+static int
+gif_load (struct frame *f, struct image *img)
+{
+  return ns_load_image(f, img,
+                       image_spec_value (img->spec, QCfile, NULL),
+                       image_spec_value (img->spec, QCdata, NULL));
+}
+#endif /* HAVE_NS */
+
 #endif /* HAVE_GIF */
 
 
@@ -8991,27 +9208,27 @@
   if (CONSP (tested))
     return XCDR (tested);
 
-#if defined (HAVE_XPM) || defined (MAC_OS)
+#if defined (HAVE_XPM) || defined (MAC_OS) || defined (HAVE_NS)
   if (EQ (type, Qxpm))
     return CHECK_LIB_AVAILABLE (&xpm_type, init_xpm_functions, libraries);
 #endif
 
-#if defined (HAVE_JPEG) || defined (MAC_OS)
+#if defined (HAVE_JPEG) || defined (MAC_OS) || defined (HAVE_NS)
   if (EQ (type, Qjpeg))
     return CHECK_LIB_AVAILABLE (&jpeg_type, init_jpeg_functions, libraries);
 #endif
 
-#if defined (HAVE_TIFF) || defined (MAC_OS)
+#if defined (HAVE_TIFF) || defined (MAC_OS) || defined (HAVE_NS)
   if (EQ (type, Qtiff))
     return CHECK_LIB_AVAILABLE (&tiff_type, init_tiff_functions, libraries);
 #endif
 
-#if defined (HAVE_GIF) || defined (MAC_OS)
+#if defined (HAVE_GIF) || defined (MAC_OS) || defined (HAVE_NS)
   if (EQ (type, Qgif))
     return CHECK_LIB_AVAILABLE (&gif_type, init_gif_functions, libraries);
 #endif
 
-#if defined (HAVE_PNG) || defined (MAC_OS)
+#if defined (HAVE_PNG) || defined (MAC_OS) || defined (HAVE_NS)
   if (EQ (type, Qpng))
     return CHECK_LIB_AVAILABLE (&png_type, init_png_functions, libraries);
 #endif
@@ -9136,31 +9353,31 @@
   staticpro (&QCpt_height);
 #endif /* HAVE_GHOSTSCRIPT */
 
-#if defined (HAVE_XPM) || defined (MAC_OS)
+#if defined (HAVE_XPM) || defined (MAC_OS) || defined (HAVE_NS)
   Qxpm = intern ("xpm");
   staticpro (&Qxpm);
   ADD_IMAGE_TYPE (Qxpm);
 #endif
 
-#if defined (HAVE_JPEG) || defined (MAC_OS)
+#if defined (HAVE_JPEG) || defined (MAC_OS) || defined (HAVE_NS)
   Qjpeg = intern ("jpeg");
   staticpro (&Qjpeg);
   ADD_IMAGE_TYPE (Qjpeg);
 #endif
 
-#if defined (HAVE_TIFF) || defined (MAC_OS)
+#if defined (HAVE_TIFF) || defined (MAC_OS) || defined (HAVE_NS)
   Qtiff = intern ("tiff");
   staticpro (&Qtiff);
   ADD_IMAGE_TYPE (Qtiff);
 #endif
 
-#if defined (HAVE_GIF) || defined (MAC_OS)
+#if defined (HAVE_GIF) || defined (MAC_OS) || defined (HAVE_NS)
   Qgif = intern ("gif");
   staticpro (&Qgif);
   ADD_IMAGE_TYPE (Qgif);
 #endif
 
-#if defined (HAVE_PNG) || defined (MAC_OS)
+#if defined (HAVE_PNG) || defined (MAC_OS) || defined (HAVE_NS)
   Qpng = intern ("png");
   staticpro (&Qpng);
   ADD_IMAGE_TYPE (Qpng);
Index: src/keyboard.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/keyboard.c,v
retrieving revision 1.753.2.77
diff -u -r1.753.2.77 keyboard.c
--- src/keyboard.c	11 Nov 2007 00:55:14 -0000	1.753.2.77
+++ src/keyboard.c	22 Nov 2007 11:55:55 -0000
@@ -82,6 +82,11 @@
 #include "macterm.h"
 #endif
 
+#ifdef HAVE_NS
+#include "nsterm.h"
+extern Lisp_Object Qsuper;
+#endif
+
 #ifndef USE_CRT_DLL
 extern int errno;
 #endif
@@ -4204,7 +4209,8 @@
 #endif
 	}
 
-#if defined (HAVE_X11) || defined (HAVE_NTGUI) || defined (MAC_OS)
+#if defined (HAVE_X11) || defined (HAVE_NTGUI) || defined (MAC_OS) \
+    || defined (HAVE_NS)
       else if (event->kind == DELETE_WINDOW_EVENT)
 	{
 	  /* Make an event (delete-frame (FRAME)).  */
@@ -4213,7 +4219,8 @@
 	  kbd_fetch_ptr = event + 1;
 	}
 #endif
-#if defined (HAVE_X11) || defined (HAVE_NTGUI) || defined (MAC_OS)
+#if defined (HAVE_X11) || defined (HAVE_NTGUI) || defined (MAC_OS) \
+    || defined (HAVE_NS)
       else if (event->kind == ICONIFY_EVENT)
 	{
 	  /* Make an event (iconify-frame (FRAME)).  */
@@ -4236,7 +4243,7 @@
 	  kbd_fetch_ptr = event + 1;
 	}
 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (MAC_OS) \
-    || defined (USE_GTK)
+    || defined(HAVE_NS) || defined (USE_GTK)
       else if (event->kind == MENU_BAR_ACTIVATE_EVENT)
 	{
 	  kbd_fetch_ptr = event + 1;
@@ -4339,7 +4346,7 @@
 	      obj = make_lispy_event (event);
 
 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined(MAC_OS) \
-    || defined (USE_GTK)
+    || defined(HAVE_NS) || defined (USE_GTK)
 	      /* If this was a menu selection, then set the flag to inhibit
 		 writing to last_nonmenu_event.  Don't do this if the event
 		 we're returning is (menu-bar), though; that indicates the
@@ -5687,7 +5694,7 @@
 	if (event->kind == MOUSE_CLICK_EVENT)
 	  {
 	    struct frame *f = XFRAME (event->frame_or_window);
-#if ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
+#if ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK) && ! defined (HAVE_NS)
 	    int row, column;
 #endif
 
@@ -5696,7 +5703,7 @@
 	    if (! FRAME_LIVE_P (f))
 	      return Qnil;
 
-#if ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
+#if ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK) && ! defined (HAVE_NS)
 	    /* EVENT->x and EVENT->y are frame-relative pixel
 	       coordinates at this place.  Under old redisplay, COLUMN
 	       and ROW are set to frame relative glyph coordinates
@@ -5756,7 +5763,7 @@
 
 		return Fcons (item, Fcons (position, Qnil));
 	      }
-#endif /* not USE_X_TOOLKIT && not USE_GTK */
+#endif /* not USE_X_TOOLKIT && not USE_GTK && not HAVE_NS */
 
 	    position = make_lispy_position (f, &event->x, &event->y,
 					    event->timestamp);
@@ -5854,10 +5861,13 @@
 	       release of the button that chose the menu item as a
 	       separate event.  */
 
+//#ifndef HAVE_NS  /* normal under NS */
 	    if (!CONSP (start_pos))
 	      return Qnil;
+//#endif
 
 	    event->modifiers &= ~up_modifier;
+
 #if 0 /* Formerly we treated an up with no down as a click event.  */
 	    if (!CONSP (start_pos))
 	      event->modifiers |= click_modifier;
@@ -6136,7 +6146,7 @@
 #endif /* HAVE_MOUSE */
 
 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (MAC_OS) \
-    || defined (USE_GTK)
+    || defined(HAVE_NS) || defined (USE_GTK)
     case MENU_BAR_EVENT:
       if (EQ (event->arg, event->frame_or_window))
 	/* This is the prefix key.  We translate this to
@@ -8060,7 +8070,12 @@
 	      && SYMBOLP (XSYMBOL (def)->function)
 	      && ! NILP (Fget (def, Qmenu_alias)))
 	    def = XSYMBOL (def)->function;
+#ifdef HAVE_NS
+          /* prefer 'super' bindings */
+	  tem = Fwhere_is_internal (def, Qnil, Qsuper, Qt, Qt);
+#else
 	  tem = Fwhere_is_internal (def, Qnil, Qt, Qnil, Qt);
+#endif
 	  XSETCAR (cachelist, tem);
 	  if (NILP (tem))
 	    {
Index: src/keymap.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/keymap.c,v
retrieving revision 1.282.4.61
diff -u -r1.282.4.61 keymap.c
--- src/keymap.c	18 Oct 2007 23:59:58 -0000	1.282.4.61
+++ src/keymap.c	22 Nov 2007 11:55:59 -0000
@@ -113,6 +113,11 @@
 
 extern Lisp_Object Voverriding_local_map;
 
+#ifdef HAVE_NS
+extern Lisp_Object Qsuper;
+extern int super_sequence_p (Lisp_Object seq);
+#endif
+
 /* Hash table used to cache a reverse-map to speed up calls to where-is.  */
 static Lisp_Object where_is_cache;
 /* Which keymaps are reverse-stored in the cache.  */
@@ -2580,6 +2585,23 @@
   return 1;
 }
 
+#ifdef HAVE_NS
+/* Return non-zero if SEQ starts with a character modified by super only. */
+int
+super_sequence_p (Lisp_Object seq)
+{
+  Lisp_Object idx, elt;
+
+  if (XINT (Flength (seq)) == 0)
+    return 0;
+  XSETFASTINT(idx, 0);
+  elt = Faref(seq, idx);
+
+  return (XUINT(elt) & (alt_modifier|hyper_modifier|super_modifier))
+    == super_modifier;
+}
+#endif
+
 
 /* where-is - finding a command in a set of keymaps.			*/
 
@@ -2762,7 +2784,14 @@
 	     we find.  */
 	  if (EQ (firstonly, Qnon_ascii))
 	    RETURN_UNGCPRO (sequence);
+#ifdef HAVE_NS
+          // respond to 'super' preference
+          else if (EQ (firstonly, Qsuper) && super_sequence_p(sequence))
+            RETURN_UNGCPRO (sequence);
+	  else if (EQ (firstonly, Qt) && ascii_sequence_p (sequence))
+#else
 	  else if (!NILP (firstonly) && ascii_sequence_p (sequence))
+#endif
 	    RETURN_UNGCPRO (sequence);
 
 	  if (CONSP (remapped))
@@ -2868,7 +2897,13 @@
       for (i = n - 1; i >= 0; --i)
 	if (EQ (shadow_lookup (keymaps, defns[i], Qnil), definition))
 	  {
+#ifdef HAVE_NS
+            if (EQ (firstonly, Qsuper) && super_sequence_p(defns[i]))
+              break;
+            else if (EQ (firstonly, Qt) && ascii_sequence_p (defns[i]))
+#else
 	    if (ascii_sequence_p (defns[i]))
+#endif
 	      break;
 	    else if (j < 0)
 	      j = i;
Index: src/lisp.h
===================================================================
RCS file: /cvsroot/emacs/emacs/src/lisp.h,v
retrieving revision 1.465.2.66
diff -u -r1.465.2.66 lisp.h
--- src/lisp.h	11 Nov 2007 00:55:17 -0000	1.465.2.66
+++ src/lisp.h	22 Nov 2007 11:56:03 -0000
@@ -29,6 +29,11 @@
 #define P_(proto) ()
 #endif
 
+#ifdef GNUSTEP
+/* This conflicts with functions in the GNUstep libraries. */
+#define hash_remove emacs_hash_remove
+#endif  /* GNUSTEP */
+
 #if 0
 /* Define this temporarily to hunt a bug.  If defined, the size of
    strings is redundantly recorded in sdata structures so that it can
@@ -160,7 +165,7 @@
 #endif
 
 /* Let's USE_LSB_TAG on systems where we know malloc returns mult-of-8.  */
-#if defined GNU_MALLOC || defined DOUG_LEA_MALLOC || defined __GLIBC__ || defined MAC_OSX
+#if defined GNU_MALLOC || defined DOUG_LEA_MALLOC || defined __GLIBC__ || defined MAC_OSX || defined(COCOA)
 /* We also need to be able to specify mult-of-8 alignment on static vars.  */
 # if defined DECL_ALIGN
 /* We currently do not support USE_LSB_TAG with a union Lisp_Object.  */
@@ -937,6 +942,7 @@
 
      The name "xname" is used to intentionally break code referring to
      the old field "name" of type pointer to struct Lisp_String.  */
+    /* (Use XSTRING(xname)->data now instead.) */
   Lisp_Object xname;
 
   /* Value of the symbol or Qunbound if unbound.  If this symbol is a
Index: src/lread.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/lread.c,v
retrieving revision 1.317.2.47
diff -u -r1.317.2.47 lread.c
--- src/lread.c	19 Oct 2007 00:00:00 -0000	1.317.2.47
+++ src/lread.c	22 Nov 2007 11:56:09 -0000
@@ -660,9 +660,15 @@
   EMACS_TIME end_time;
 
 #ifdef HAVE_WINDOW_SYSTEM
+/* PENDING: Everywhere else hourglass ops are wrapped by HAVE_X_WINDOWS.
+   However, mac and w32 each have partial hourglass impls and maybe they
+   are used.  In any event, NS manages a mouse spinner icon automatically,
+   so doesn't need Emacs to keep track (for now). */
+#ifndef HAVE_NS
   if (display_hourglass_p)
     cancel_hourglass ();
 #endif
+#endif
 
   delayed_switch_frame = Qnil;
 
@@ -4042,7 +4048,7 @@
     }
 #endif
 
-#if (!(defined(WINDOWSNT) || (defined(HAVE_CARBON))))
+#if (!(defined(WINDOWSNT) || (defined(HAVE_CARBON)) || (defined(HAVE_NS))))
   /* When Emacs is invoked over network shares on NT, PATH_LOADSEARCH is
      almost never correct, thereby causing a warning to be printed out that
      confuses users.  Since PATH_LOADSEARCH is always overridden by the
@@ -4072,7 +4078,7 @@
 	    }
 	}
     }
-#endif /* !(WINDOWSNT || HAVE_CARBON) */
+#endif /* !(WINDOWSNT || HAVE_CARBON || HAVE_NS) */
 
   /* If the EMACSLOADPATH environment variable is set, use its value.
      This doesn't apply if we're dumping.  */
Index: src/macmenu.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/macmenu.c,v
retrieving revision 1.11.2.38
diff -u -r1.11.2.38 macmenu.c
--- src/macmenu.c	15 Oct 2007 05:03:14 -0000	1.11.2.38
+++ src/macmenu.c	22 Nov 2007 11:56:11 -0000
@@ -1138,6 +1138,7 @@
   SInt32 menu_choice;
   SInt16 menu_id, menu_item;
   extern Point saved_menu_event_location;
+fprintf(stderr, "activate menubar\n");
 
   set_frame_menubar (f, 0, 1);
   BLOCK_INPUT;
Index: src/process.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/process.c,v
retrieving revision 1.408.2.62
diff -u -r1.408.2.62 process.c
--- src/process.c	27 Oct 2007 09:11:48 -0000	1.408.2.62
+++ src/process.c	22 Nov 2007 11:56:16 -0000
@@ -4611,8 +4611,12 @@
 	      process_output_skip = 0;
 	    }
 #endif
-
-	  nfds = select (max (max (max_process_desc, max_keyboard_desc),
+#ifdef HAVE_NS
+          nfds = ns_select
+#else
+          nfds = select
+#endif
+                        (max (max (max_process_desc, max_keyboard_desc),
 			      max_gpm_desc) + 1,
 			 &Available,
 #ifdef NON_BLOCKING_CONNECT
Index: src/syntax.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/syntax.c,v
retrieving revision 1.166.4.26
diff -u -r1.166.4.26 syntax.c
--- src/syntax.c	27 Jul 2007 10:48:40 -0000	1.166.4.26
+++ src/syntax.c	22 Nov 2007 11:56:18 -0000
@@ -1,3 +1,4 @@
+#include <stdio.h>
 /* GNU Emacs routines to deal with syntax tables; also word and list parsing.
    Copyright (C) 1985, 1987, 1993, 1994, 1995, 1997, 1998, 1999, 2001,
                  2002, 2003, 2004, 2005, 2006, 2007
@@ -300,6 +301,18 @@
   register int quoted = 0;
   int orig = charpos;
 
+#ifdef HAVE_NS
+  /* For some reason keeps getting called w/both 1, then segfaulting
+     due to the definitions of DEC_BOTH and DEC_POS in character.h,
+     which lead to decrementing below initial address and then examining
+     character there.  Need to investigate further.. */
+  if (charpos < 2 || bytepos < 2)
+    {
+      //fprintf(stderr,"Returning because charpos = %d, bytepos = %d\n",charpos, bytepos);
+      return 0;
+    }
+#endif
+
   DEC_BOTH (charpos, bytepos);
 
   while (charpos >= beg)
Index: src/sysdep.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/sysdep.c,v
retrieving revision 1.251.2.24
diff -u -r1.251.2.24 sysdep.c
--- src/sysdep.c	11 Oct 2007 16:20:34 -0000	1.251.2.24
+++ src/sysdep.c	22 Nov 2007 11:56:20 -0000
@@ -288,6 +288,15 @@
         return NULL;
       strcpy (buf, pwd);
     }
+#ifdef COCOA
+  else if ((pwd=getenv ("HOME")) != 0)
+    {
+      buf = (char *) malloc (strlen (pwd) + 1);
+      if (!buf)
+        return NULL;
+      strcpy (buf, pwd);
+    }
+#endif
 #ifdef HAVE_GETCWD
   else
     {
Index: src/sysselect.h
===================================================================
RCS file: /cvsroot/emacs/emacs/src/sysselect.h,v
retrieving revision 1.2.26.8
diff -u -r1.2.26.8 sysselect.h
--- src/sysselect.h	27 Jul 2007 10:48:17 -0000	1.2.26.8
+++ src/sysselect.h	22 Nov 2007 11:56:20 -0000
@@ -20,11 +20,11 @@
 Boston, MA 02110-1301, USA.  */
 
 #ifdef HAVE_SYS_SELECT_H
-#if defined (DARWIN) || defined (MAC_OSX)
+#if defined (DARWIN) || defined (MAC_OSX) || defined (COCOA)
 #undef init_process
 #endif
 #include <sys/select.h>
-#if defined (DARWIN) || defined (MAC_OSX)
+#if defined (DARWIN) || defined (MAC_OSX) || defined (COCOA)
 #define init_process emacs_init_process
 #endif
 #endif
Index: src/termhooks.h
===================================================================
RCS file: /cvsroot/emacs/emacs/src/termhooks.h,v
retrieving revision 1.65.2.15
diff -u -r1.65.2.15 termhooks.h
--- src/termhooks.h	11 Nov 2007 00:55:18 -0000	1.65.2.15
+++ src/termhooks.h	22 Nov 2007 11:56:20 -0000
@@ -366,6 +366,7 @@
     struct x_display_info *x;         /* xterm.h */
     struct w32_display_info *w32;     /* w32term.h */
     struct mac_display_info *mac;     /* macterm.h */
+    struct ns_display_info *ns;       /* nsterm.h */
   } display_info;
 
 
Index: src/terminal.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/terminal.c,v
retrieving revision 1.5.2.3
diff -u -r1.5.2.3 terminal.c
--- src/terminal.c	12 Oct 2007 21:06:19 -0000	1.5.2.3
+++ src/terminal.c	22 Nov 2007 11:56:21 -0000
@@ -383,6 +383,8 @@
       return Qpc;
     case output_mac:
       return Qmac;
+    case output_ns:
+      return Qns;
     default:
       abort ();
     }
Index: src/terminfo.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/terminfo.c,v
retrieving revision 1.16.6.6
diff -u -r1.16.6.6 terminfo.c
--- src/terminfo.c	27 Jul 2007 10:48:12 -0000	1.16.6.6
+++ src/terminfo.c	22 Nov 2007 11:56:21 -0000
@@ -26,7 +26,10 @@
    so that we do not need to conditionalize the places in Emacs
    that set them.  */
 
+/* PENDING: causes a conflict on OS X 10.3 .*/
+#ifndef COCOA
 char *UP, *BC, PC;
+#endif
 
 /* Interface to curses/terminfo library.
    Turns out that all of the terminfo-level routines look
Index: src/unexmacosx.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/unexmacosx.c,v
retrieving revision 1.6.2.14
diff -u -r1.6.2.14 unexmacosx.c
--- src/unexmacosx.c	11 Nov 2007 00:55:18 -0000	1.6.2.14
+++ src/unexmacosx.c	22 Nov 2007 11:56:21 -0000
@@ -578,7 +578,6 @@
       break;
     case LC_TWOLEVEL_HINTS:
       printf ("LC_TWOLEVEL_HINTS");
-      break;
 #ifdef LC_UUID
     case LC_UUID:
       printf ("LC_UUID          ");
Index: src/unexnext.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/unexnext.c,v
retrieving revision 1.8.6.6
diff -u -r1.8.6.6 unexnext.c
--- src/unexnext.c	27 Jul 2007 10:48:37 -0000	1.8.6.6
+++ src/unexnext.c	22 Nov 2007 11:56:22 -0000
@@ -36,6 +36,9 @@
    "Nelson H. F. Beebe" <beebe@math.utah.edu> says that doesn't work
    in system version 3.3.  */
 
+#ifdef COCOA
+#define NS_TARGET
+#endif
 
 int malloc_cookie;
 
@@ -163,7 +166,7 @@
 	address = (start_address + *size);
 	gapsize = end_address - address;
 	*size += gapsize;
-	if (vm_allocate(task_self(), &address, gapsize,
+	if (vm_allocate(mach_task_self(), &address, gapsize,
 			FALSE) != KERN_SUCCESS) {
 		fatal_unexec("cannot vm_allocate");
 	        return (0);
@@ -180,20 +183,25 @@
 	region_t region;
 	kern_return_t ret;
 	struct section *sect;
+        struct vm_region_basic_info info;
+        mach_msg_type_number_t info_count = VM_REGION_BASIC_INFO_COUNT;
 
 	sect = (struct section *) getsectbyname(SEG_DATA, SECT_DATA);
 	region.address = 0;
 	*address = 0;
 	for (;;) {
-		ret = vm_region(task_self(),
+		ret = vm_region(mach_task_self(),
 				&region.address,
 				&region.size,
-				&region.protection,
-				&region.max_protection,
-				&region.inheritance,
-				&region.shared,
-				&region.object_name,
-				&region.offset);
+                                VM_REGION_BASIC_INFO,
+                                (vm_region_info_t) &info,
+                                &info_count,
+/* 				&region.protection, */
+/* 				&region.max_protection, */
+/* 				&region.inheritance, */
+/* 				&region.shared, */
+				&region.object_name/*,
+ 				&region.offset */);
 		if (ret != KERN_SUCCESS || region.address >= VM_HIGHDATA) {
 			break;
 		}
@@ -223,7 +231,7 @@
 {
 	vm_address_t address;
 
-	if (vm_allocate(task_self(), &address, size, TRUE) != KERN_SUCCESS) {
+	if (vm_allocate(mach_task_self(), &address, size, TRUE) != KERN_SUCCESS) {
 		return (NULL);
 	}
 	return ((char *)address);
@@ -235,7 +243,7 @@
 	vm_size_t size
 	)
 {
-	vm_deallocate(task_self(), (vm_address_t)buf, size);
+	vm_deallocate(mach_task_self(), (vm_address_t)buf, size);
 }
 
 static int
@@ -470,7 +478,10 @@
 void
 unexec(
        char *outfile,
-       char *infile
+       char *infile,
+       void *start_data,
+       void *start_bss,
+       void *entry_address
        )
 {
 	int infd;
Index: src/window.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/window.c,v
retrieving revision 1.445.2.75
diff -u -r1.445.2.75 window.c
--- src/window.c	27 Oct 2007 09:11:50 -0000	1.445.2.75
+++ src/window.c	22 Nov 2007 11:56:26 -0000
@@ -50,6 +50,9 @@
 #ifdef MAC_OS
 #include "macterm.h"
 #endif
+#ifdef HAVE_NS
+#include "nsterm.h"
+#endif
 
 
 Lisp_Object Qwindowp, Qwindow_live_p, Qwindow_configuration_p;
Index: src/xdisp.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/xdisp.c,v
retrieving revision 1.843.2.144
diff -u -r1.843.2.144 xdisp.c
--- src/xdisp.c	11 Nov 2007 00:55:17 -0000	1.843.2.144
+++ src/xdisp.c	22 Nov 2007 11:56:40 -0000
@@ -201,6 +201,9 @@
 #ifdef MAC_OS
 #include "macterm.h"
 #endif
+#ifdef HAVE_NS
+#include "nsterm.h"
+#endif
 
 #ifdef HAVE_WINDOW_SYSTEM
 #ifdef USE_FONT_BACKEND
@@ -215,7 +218,7 @@
 #define INFINITY 10000000
 
 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (MAC_OS) \
-    || defined (USE_GTK)
+    || defined(HAVE_NS) || defined (USE_GTK)
 extern void set_frame_menubar P_ ((struct frame *f, int, int));
 extern int pending_menu_activation;
 #endif
@@ -9264,7 +9267,32 @@
       if (! STRINGP (f->name)
 	  || SBYTES (f->name) != len
 	  || bcmp (title, SDATA (f->name), len) != 0)
-	x_implicitly_set_name (f, make_string (title, len), Qnil);
+        {
+#ifdef HAVE_NS
+          if (FRAME_NS_P (f))
+            {
+              if (!MINI_WINDOW_P(XWINDOW(f->selected_window)))
+                {
+                  if (EQ (fmt, Qt))
+                    ns_set_name_as_filename (f);
+                  else
+                    x_implicitly_set_name (f, make_string(title, len),
+                                           Qnil);
+                }
+            }
+          else
+#endif
+	    x_implicitly_set_name (f, make_string (title, len), Qnil);
+        }
+#ifdef HAVE_NS
+      if (FRAME_NS_P (f))
+        {
+          /* do this also for frames with explicit names */
+          ns_implicitly_set_icon_type(f);
+          ns_set_doc_edited(f, Fbuffer_modified_p
+                            (XWINDOW (f->selected_window)->buffer), Qnil);
+        }
+#endif
     }
 }
 
@@ -9429,7 +9457,7 @@
   if (FRAME_WINDOW_P (f)
       ?
 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (MAC_OS) \
-    || defined (USE_GTK)
+    || defined (HAVE_NS) || defined (USE_GTK)
       FRAME_EXTERNAL_MENU_BAR (f)
 #else
       FRAME_MENU_BAR_LINES (f) > 0
@@ -9488,10 +9516,10 @@
 
 	  /* Redisplay the menu bar in case we changed it.  */
 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (MAC_OS) \
-    || defined (USE_GTK)
+    || defined (HAVE_NS) || defined (USE_GTK)
 	  if (FRAME_WINDOW_P (f))
-	    {
-#ifdef MAC_OS
+            {
+#if defined (MAC_OS) || defined (HAVE_NS)
               /* All frames on Mac OS share the same menubar.  So only
                  the selected frame should be allowed to set it.  */
               if (f == SELECTED_FRAME ())
@@ -9502,11 +9530,11 @@
 	    /* On a terminal screen, the menu bar is an ordinary screen
 	       line, and this makes it get updated.  */
 	    w->update_mode_line = Qt;
-#else /* ! (USE_X_TOOLKIT || HAVE_NTGUI || MAC_OS || USE_GTK) */
+#else /* ! (USE_X_TOOLKIT || HAVE_NTGUI || MAC_OS || HAVE_NS || USE_GTK) */
 	  /* In the non-toolkit version, the menu bar is an ordinary screen
 	     line, and this makes it get updated.  */
 	  w->update_mode_line = Qt;
-#endif /* ! (USE_X_TOOLKIT || HAVE_NTGUI || MAC_OS || USE_GTK) */
+#endif /* ! (USE_X_TOOLKIT || HAVE_NTGUI || MAC_OS || HAVE_NS || USE_GTK) */
 
 	  unbind_to (count, Qnil);
 	  set_buffer_internal_1 (prev);
@@ -9617,7 +9645,7 @@
      struct frame *f;
      int save_match_data;
 {
-#if defined (USE_GTK) || USE_MAC_TOOLBAR
+#if defined (USE_GTK) || defined (HAVE_NS) || USE_MAC_TOOLBAR
   int do_update = FRAME_EXTERNAL_TOOL_BAR (f);
 #else
   int do_update = WINDOWP (f->tool_bar_window)
@@ -10083,7 +10111,7 @@
   struct it it;
   struct glyph_row *row;
 
-#if defined (USE_GTK) || USE_MAC_TOOLBAR
+#if defined (USE_GTK) || defined (HAVE_NS) || USE_MAC_TOOLBAR
   if (FRAME_EXTERNAL_TOOL_BAR (f))
     update_frame_tool_bar (f);
   return 0;
@@ -11312,6 +11340,10 @@
       /* Resized active mini-window to fit the size of what it is
          showing if its contents might have changed.  */
       must_finish = 1;
+//PENDING(HAVE_NS): this causes all frames to be updated, which seems
+// unnecessary since only the current frame needs to be considered.  This
+// function needs to be rewritten with two variables, consider_all_windows
+// and consider_all_frames.
       consider_all_windows_p = 1;
       ++windows_or_buffers_changed;
       ++update_mode_lines;
@@ -13709,7 +13741,7 @@
       if (FRAME_WINDOW_P (f))
 	{
 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (MAC_OS) \
-    || defined (USE_GTK)
+    || defined (HAVE_NS) || defined (USE_GTK)
 	  redisplay_menu_p = FRAME_EXTERNAL_MENU_BAR (f);
 #else
 	  redisplay_menu_p = FRAME_MENU_BAR_LINES (f) > 0;
@@ -13724,7 +13756,7 @@
 #ifdef HAVE_WINDOW_SYSTEM
       if (FRAME_WINDOW_P (f))
         {
-#if defined (USE_GTK) || USE_MAC_TOOLBAR
+#if defined (USE_GTK) || defined (HAVE_NS) || USE_MAC_TOOLBAR
           redisplay_tool_bar_p = FRAME_EXTERNAL_TOOL_BAR (f);
 #else
           redisplay_tool_bar_p = WINDOWP (f->tool_bar_window)
@@ -16711,6 +16743,11 @@
     return;
 #endif
 
+#ifdef HAVE_NS
+  if (FRAME_NS_P (f))
+    return;
+#endif /* HAVE_NS */
+
 #ifdef USE_X_TOOLKIT
   xassert (!FRAME_WINDOW_P (f));
   init_iterator (&it, w, -1, -1, f->desired_matrix->rows, MENU_FACE_ID);
@@ -22233,11 +22270,15 @@
 /* Switch the display of W's cursor on or off, according to the value
    of ON.  */
 
-static void
+#ifndef HAVE_NS
+static
+#endif
+void
 update_window_cursor (w, on)
      struct window *w;
      int on;
 {
+//fprintf(stderr, "updateWindowCursor: %p\n",w);
   /* Don't update cursor in windows whose frame is in the process
      of being deleted.  */
   if (w->current_matrix)
Index: src/xfaces.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/xfaces.c,v
retrieving revision 1.281.2.67
diff -u -r1.281.2.67 xfaces.c
--- src/xfaces.c	11 Nov 2007 00:55:15 -0000	1.281.2.67
+++ src/xfaces.c	22 Nov 2007 11:56:45 -0000
@@ -242,6 +242,17 @@
 #define check_x check_mac
 #endif /* MAC_OS */
 
+#ifdef HAVE_NS
+#include "nsterm.h"
+#undef FRAME_X_DISPLAY_INFO
+#define FRAME_X_DISPLAY_INFO FRAME_NS_DISPLAY_INFO
+#define x_display_info ns_display_info
+#define FRAME_X_FONT_TABLE FRAME_NS_FONT_TABLE
+#define check_x check_ns
+#define x_list_fonts ns_list_fonts
+#define GCGraphicsExposures 0
+#endif /* HAVE_NS */
+
 #include "buffer.h"
 #include "dispextern.h"
 #include "blockinput.h"
@@ -580,6 +591,10 @@
 extern Lisp_Object w32_list_fonts P_ ((struct frame *, Lisp_Object, int, int));
 #endif /* WINDOWSNT */
 
+#ifdef HAVE_NS
+extern Lisp_Object ns_list_fonts P_ ((struct frame *, Lisp_Object, int, int));
+#endif /* HAVE_NS */
+
 #ifdef USE_X_TOOLKIT
 static void x_update_menu_appearance P_ ((struct frame *));
 
@@ -819,6 +834,33 @@
 
 #endif  /* MAC_OS */
 
+
+#ifdef HAVE_NS
+/* NS emulation of GCs */
+
+static INLINE GC
+x_create_gc (f, mask, xgcv)
+     struct frame *f;
+     unsigned long mask;
+     XGCValues *xgcv;
+{
+  GC gc = xmalloc (sizeof (*gc));
+  if (gc)
+      bcopy(xgcv, gc, sizeof(XGCValues));
+  return gc;
+}
+
+static INLINE void
+x_free_gc (f, gc)
+     struct frame *f;
+     GC gc;
+{
+  if (gc)
+      xfree (gc);
+}
+#endif  /* HAVE_NS */
+
+
 /* Like stricmp.  Used to compare parts of font names which are in
    ISO8859-1.  */
 
@@ -913,8 +955,11 @@
 #ifdef MAC_OS
   if (!FRAME_MAC_P (f) || FRAME_MAC_WINDOW (f))
 #endif
+#ifdef HAVE_NS
+  if (!FRAME_NS_P (f) || FRAME_NS_WINDOW (f))
+#endif
     if (!realize_basic_faces (f))
-      abort ();
+        abort ();
 }
 
 
@@ -1085,6 +1130,9 @@
 #ifdef MAC_OS
       mac_unload_font (dpyinfo, font_info->font);
 #endif
+#ifdef HAVE_NS
+      ns_unload_font (dpyinfo, font_info->font);
+#endif
       UNBLOCK_INPUT;
 
       /* Mark font table slot free.  */
@@ -1440,6 +1488,10 @@
   else if (FRAME_MAC_P (f))
     return mac_defined_color (f, color_name, color_def, alloc);
 #endif
+#ifdef HAVE_NS
+  else if (FRAME_NS_P (f))
+    return ns_defined_color (f, color_name, color_def, alloc);
+#endif
   else
     abort ();
 }
@@ -1723,6 +1775,10 @@
       UNBLOCK_INPUT;
     }
 #endif
+#ifdef HAVE_NS
+  if (pixel > 0)
+      ns_release_object((void *)pixel);
+#endif
 }
 
 
@@ -1733,6 +1789,7 @@
      struct frame *f;
      struct face *face;
 {
+//NS_TODO: need to do something here?
 #ifdef HAVE_X_WINDOWS
   if (face->colors_copied_bitwise_p)
     return;
@@ -2434,8 +2491,11 @@
 
   if (*font->name == '-')
     {
+#ifdef HAVE_NS
+      char *p = font->name + 1;
+#else
       char *p = xstrlwr (font->name) + 1;
-
+#endif
       while (i < XLFD_LAST)
 	{
 	  font->fields[i] = p;
@@ -2604,6 +2664,8 @@
   BLOCK_INPUT;
   lfonts = w32_list_fonts (f, lpattern, 0, nfonts);
   UNBLOCK_INPUT;
+#elif defined HAVE_NS
+  lfonts = ns_list_fonts (f, lpattern, 0, nfonts);
 #else
   lfonts = x_list_fonts (f, lpattern, -1, nfonts);
 #endif
@@ -2757,6 +2819,8 @@
   BLOCK_INPUT;
   fonts = w32_list_fonts (f, pattern, 0, 1);
   UNBLOCK_INPUT;
+#elif defined HAVE_NS
+  fonts = ns_list_fonts (f, pattern, 0, 1);
 #else
   fonts = x_list_fonts (f, pattern, -1, 1);
 #endif
@@ -3509,7 +3573,7 @@
    If FONTNAME is not available on frame F,
 	return 0 if MAY_FAIL_P is non-zero, otherwise abort.
    If the fullname is not in a valid XLFD format,
-   	return 0 if MAY_FAIL_P is non-zero, otherwise set normal values
+	return 0 if MAY_FAIL_P is non-zero, otherwise set normal values
 	in LFACE and return 1.
    Otherwise, return 1.  */
 
@@ -4013,7 +4077,7 @@
 		}
 	      else if (EQ (keyword, QCstipple))
 		{
-#ifdef HAVE_X_WINDOWS
+#if defined(HAVE_X_WINDOWS) || defined(HAVE_NS)
 		  Lisp_Object pixmap_p = Fbitmap_spec_p (value);
 		  if (!NILP (pixmap_p))
 		    to[LFACE_STIPPLE_INDEX] = value;
@@ -4508,14 +4572,14 @@
     }
   else if (EQ (attr, QCstipple))
     {
-#ifdef HAVE_X_WINDOWS
+#if defined(HAVE_X_WINDOWS) || defined(HAVE_NS)
       if (!UNSPECIFIEDP (value) && !IGNORE_DEFFACE_P (value)
 	  && !NILP (value)
 	  && NILP (Fbitmap_spec_p (value)))
 	signal_error ("Invalid stipple attribute", value);
       old_value = LFACE_STIPPLE (lface);
       LFACE_STIPPLE (lface) = value;
-#endif /* HAVE_X_WINDOWS */
+#endif /* HAVE_X_WINDOWS || HAVE_NS */
     }
   else if (EQ (attr, QCwidth))
     {
@@ -5619,11 +5683,7 @@
 	{
 #ifdef HAVE_X_WINDOWS
 	  xgcv.font = face->font->fid;
-#endif
-#ifdef WINDOWSNT
-	  xgcv.font = face->font;
-#endif
-#ifdef MAC_OS
+#elif defined (WINDOWSNT) || defined (MAC_OS) || defined (HAVE_NS)
 	  xgcv.font = face->font;
 #endif
 	  mask |= GCFont;
@@ -7747,7 +7807,6 @@
 	 foundry and family.  The other fields of font name pattern
 	 are constructed from ATTRS.  */
       int fontset = face_fontset (attrs);
-
       /* If we are realizing the default face, ATTRS should specify a
 	 fontset.  In other words, if FONTSET is -1, we are not
 	 realizing the default face, thus the default face should have
@@ -8292,7 +8351,7 @@
 
   /* Look up a realized face with the given face attributes,
      or realize a new one for ASCII characters.  */
-  return lookup_face (f, attrs, 0, NULL);
+  return lookup_face (f, attrs);
 }
 
 
Index: src/m/powermac.h
===================================================================
RCS file: /cvsroot/emacs/emacs/src/m/powermac.h,v
retrieving revision 1.3.6.7
diff -u -r1.3.6.7 powermac.h
--- src/m/powermac.h	13 Aug 2007 13:47:21 -0000	1.3.6.7
+++ src/m/powermac.h	22 Nov 2007 11:56:45 -0000
@@ -18,6 +18,7 @@
 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 Boston, MA 02110-1301, USA.  */
 
+/* PENDING: relation between this file and "powerpcle.h"? */
 
 /* The following line tells the configuration script what sort of
    operating system this machine is likely to run.
Index: src/s/darwin.h
===================================================================
RCS file: /cvsroot/emacs/emacs/src/s/darwin.h,v
retrieving revision 1.11.6.13
diff -u -r1.11.6.13 darwin.h
--- src/s/darwin.h	11 Oct 2007 16:21:53 -0000	1.11.6.13
+++ src/s/darwin.h	22 Nov 2007 11:56:45 -0000
@@ -239,7 +239,9 @@
 /* In Carbon, asynchronous I/O (using SIGIO) can't be used for window
    events because they don't come from sockets, even though it works
    fine on tty's.  */
-#ifdef HAVE_CARBON
+/* This seems to help in Ctrl-G detection under Cocoa, however at the cost
+   of some quirks that may or may not bother a given user. */
+#if defined (HAVE_CARBON) || defined (COCOA_EXPERIMENTAL_CTRL_G)
 #define NO_SOCK_SIGIO
 #endif
 
@@ -265,21 +267,31 @@
 
 /* Definitions for how to compile & link.  */
 
-/* Indicate that we are compiling for Mac OS X.  */
+/* This is for the Carbon port.  Under the NeXTstep port, this is still picked
+   up during preprocessing, but is undone in config.in. */
+#ifndef HAVE_NS
 #define C_SWITCH_SYSTEM -fpascal-strings -DMAC_OSX
+#endif
 
-/* Link in the Carbon lib. */
+/* Link in the Carbon or AppKit lib. */
+#ifdef HAVE_NS
+/* PENDING: lresolv is here because configure when testing #undefs res_init,
+            a macro in /usr/include/resolv.h for res_9_init, not in stdc lib. */
+#define LIBS_MACGUI -framework AppKit -lresolv
+#define SYSTEM_PURESIZE_EXTRA 200000
+#else
 #ifdef HAVE_CARBON
-#define LIBS_CARBON -framework Carbon -framework QuickTime
+#define LIBS_MACGUI -framework Carbon -framework QuickTime
 #else
-#define LIBS_CARBON
-#endif
+#define LIBS_MACGUI
+#endif /* !HAVE_CARBON */
+#endif /* !HAVE_NS */
 
 /* The -headerpad option tells ld (see man page) to leave room at the
    end of the header for adding load commands.  Needed for dumping.
    0x690 is the total size of 30 segment load commands (at 56
    each).  */
-#define LD_SWITCH_SYSTEM_TEMACS -prebind LIBS_CARBON -Xlinker -headerpad -Xlinker 690
+#define LD_SWITCH_SYSTEM_TEMACS -prebind LIBS_MACGUI -Xlinker -headerpad -Xlinker 690
 
 #define C_SWITCH_SYSTEM_TEMACS -Dtemacs
 
@@ -308,6 +320,11 @@
 #define OTHER_FILES macosx-app
 #endif
 
+/* PENDING: can this target be specified in a clearer way? */
+#ifdef HAVE_NS
+#define OTHER_FILES ns-app
+#endif
+
 
 /* Define the following so emacs symbols will not conflict with those
    in the System framework.  Otherwise -prebind will not work.  */
