Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
authorAndrew Choi <akochoi@shaw.ca>
Fri, 26 Apr 2002 23:39:06 +0000 (23:39 +0000)
committerAndrew Choi <akochoi@shaw.ca>
Fri, 26 Apr 2002 23:39:06 +0000 (23:39 +0000)
lisp/ChangeLog, and src/ChangeLog for list of changes.

73 files changed:
ChangeLog
configure
configure.in
lisp/ChangeLog
lisp/cus-load.el
lisp/finder-inf.el
lisp/loaddefs.el
lisp/term/mac-win.el
mac/ChangeLog
mac/Emacs.app/Contents/Info.plist [new file with mode: 0644]
mac/Emacs.app/Contents/PkgInfo [new file with mode: 0644]
mac/Emacs.app/Contents/Resources/Emacs.rsrc [new file with mode: 0644]
mac/Emacs.app/Contents/Resources/English.lproj/InfoPlist.strings [new file with mode: 0644]
mac/INSTALL
mac/README
mac/cw5-mcp.xml [deleted file]
mac/cw6-mcp.xml
mac/inc/alloca.h
mac/inc/config.h
mac/inc/defs-cw5.h [deleted file]
mac/inc/defs-cw6.h
mac/inc/dirent.h
mac/inc/epaths.h
mac/inc/m-mac.h
mac/inc/pwd.h
mac/inc/s-mac.h
mac/inc/sys/file.h
mac/inc/sys/ioctl.h
mac/inc/sys/param.h
mac/inc/sys/stat.h
mac/inc/sys/time.h
mac/inc/sys/types.h
mac/inc/termio.h
mac/inc/utime.h
mac/inc/utsname.h
mac/make-bin-dist [new file with mode: 0755]
mac/makefile.MPW
mac/osx-install [new file with mode: 0755]
mac/src/Emacs.r
mac/src/EmacsMPW.r
mac/src/chdir.c
make-dist
man/macos.texi
src/ChangeLog
src/Makefile.in
src/alloc.c
src/callproc.c
src/config.in
src/dispextern.h
src/dispnew.c
src/editfns.c
src/emacs.c
src/fontset.c
src/frame.c
src/frame.h
src/keyboard.c
src/m/powermac.h [new file with mode: 0644]
src/mac.c [moved from mac/src/mac.c with 91% similarity]
src/macfns.c [moved from mac/src/macfns.c with 94% similarity]
src/macgui.h [moved from mac/inc/macgui.h with 92% similarity]
src/macmenu.c [moved from mac/src/macmenu.c with 78% similarity]
src/macterm.c [moved from mac/src/macterm.c with 82% similarity]
src/macterm.h [moved from mac/inc/macterm.h with 91% similarity]
src/process.c
src/s/darwin.h [new file with mode: 0644]
src/sysdep.c
src/term.c
src/termcap.c
src/tparam.c
src/unexmacosx.c [new file with mode: 0644]
src/window.c
src/xdisp.c
src/xfaces.c

index e7789d8..3385a59 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2002-04-26  Andrew Choi  <akochoi@shaw.ca>
+
+       * configure.in: Add support for powerpc-apple-darwin*.
+       (HAVE_CARBON): Add.
+
+       * make-dist: create directories in mac/Emacs.app.       
+
 2002-04-25  Pavel Jan\e,Bm\e(Bk  <Pavel@Janik.cz>
 
        * make-dist: lwlib-Xol* are removed.
index ccf2903..91d1446 100755 (executable)
--- a/configure
+++ b/configure
@@ -1,19 +1,11 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.53.
+# Generated by GNU Autoconf 2.53a.
 #
 # Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002
 # Free Software Foundation, Inc.
 # This configure script is free software; the Free Software Foundation
 # gives unlimited permission to copy, distribute and modify it.
-
-if expr a : '\(a\)' >/dev/null 2>&1; then
-  as_expr=expr
-else
-  as_expr=false
-fi
-
-
 ## --------------------- ##
 ## M4sh Initialization.  ##
 ## --------------------- ##
@@ -22,6 +14,9 @@ fi
 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
   emulate sh
   NULLCMD=:
+  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
 elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
   set -o posix
 fi
@@ -60,8 +55,22 @@ fi
       { LC_MESSAGES=C; export LC_MESSAGES; }
 
 
+# Required to use basename.
+if expr a : '\(a\)' >/dev/null 2>&1; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
+  as_basename=basename
+else
+  as_basename=false
+fi
+
+
 # Name of the executable.
-as_me=`(basename "$0") 2>/dev/null ||
+as_me=`$as_basename "$0" ||
 $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
         X"$0" : 'X\(//\)$' \| \
         X"$0" : 'X\(/\)$' \| \
@@ -72,6 +81,7 @@ echo X/"$0" |
          /^X\/\(\/\).*/{ s//\1/; q; }
          s/.*/./; q'`
 
+
 # PATH needs CR, and LINENO needs CR and PATH.
 # Avoid depending upon Character Ranges.
 as_cr_letters='abcdefghijklmnopqrstuvwxyz'
@@ -138,6 +148,8 @@ do
   as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
   test "x$as_lineno_1" != "x$as_lineno_2" &&
   test "x$as_lineno_3"  = "x$as_lineno_2" ') 2>/dev/null; then
+            $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
+            $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
             CONFIG_SHELL=$as_dir/$as_base
             export CONFIG_SHELL
             exec "$CONFIG_SHELL" "$0" ${1+"$@"}
@@ -210,6 +222,12 @@ else
 fi
 rm -f conf$$ conf$$.exe conf$$.file
 
+if mkdir -p . 2>/dev/null; then
+  as_mkdir_p=:
+else
+  as_mkdir_p=false
+fi
+
 as_executable_p="test -f"
 
 # Sed expression to map a string onto a valid CPP name.
@@ -857,6 +875,7 @@ Optional Packages:
   --without-toolkit-scroll-bars
                           don't use Motif or Xaw3d scroll bars
   --without-xim           don't use X11 XIM
+  --without-carbon        don't use Carbon GUI on Mac OS X
   --with-x                use the X Window System
 
 Some influential environment variables:
@@ -947,7 +966,7 @@ This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
 It was created by $as_me, which was
-generated by GNU Autoconf 2.53.  Invocation command line was
+generated by GNU Autoconf 2.53a.  Invocation command line was
 
   $ $0 $@
 
@@ -1216,7 +1235,8 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
 
-ac_config_headers="$ac_config_headers src/config.h:src/config.in"
+
+          ac_config_headers="$ac_config_headers src/config.h:src/config.in"
 
 
 test "$program_prefix" != NONE &&
@@ -1403,6 +1423,12 @@ if test "${with_xim+set}" = set; then
 
 fi;
 
+# Check whether --with-carbon or --without-carbon was given.
+if test "${with_carbon+set}" = set; then
+  withval="$with_carbon"
+
+fi;
+
 #### Make srcdir absolute, if it isn't already.  It's important to
 #### avoid running the path through pwd unnecessarily, since pwd can
 #### give you automounter prefixes, which can go away.  We do all this
@@ -2459,6 +2485,13 @@ case "${canonical}" in
     machine=f301 opsys=uxpv
   ;;
 
+  ## Darwin / Mac OS X
+  powerpc-apple-darwin* )
+    machine=powermac opsys=darwin
+    # Define CPP as follows to make autoconf work correctly.
+    CPP="cc -E -traditional-cpp"
+  ;;
+
   * )
     unported=yes
   ;;
@@ -2901,7 +2934,7 @@ for ac_file in `ls a_out.exe a.exe conftest.exe 2>/dev/null;
                 ls a.out conftest 2>/dev/null;
                 ls a.* conftest.* 2>/dev/null`; do
   case $ac_file in
-    *.$ac_ext | *.o | *.obj | *.xcoff | *.tds | *.d | *.pdb | *.xSYM ) ;;
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;;
     a.out ) # We found the default executable, but exeext='' is most
             # certainly right.
             break;;
@@ -2975,7 +3008,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
 # `rm'.
 for ac_file in `(ls conftest.exe; ls conftest; ls conftest.*) 2>/dev/null`; do
   case $ac_file in
-    *.$ac_ext | *.o | *.obj | *.xcoff | *.tds | *.d | *.pdb ) ;;
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;;
     *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
           export ac_cv_exeext
           break;;
@@ -3026,7 +3059,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
   (exit $ac_status); }; then
   for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do
   case $ac_file in
-    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb ) ;;
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;;
     *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
        break;;
   esac
@@ -3159,6 +3192,103 @@ else
     CFLAGS=
   fi
 fi
+echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5
+echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6
+if test "${ac_cv_prog_cc_stdc+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_cv_prog_cc_stdc=no
+ac_save_CC=$CC
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+#include "confdefs.h"
+#include <stdarg.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+/* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
+struct buf { int x; };
+FILE * (*rcsopen) (struct buf *, struct stat *, int);
+static char *e (p, i)
+     char **p;
+     int i;
+{
+  return p[i];
+}
+static char *f (char * (*g) (char **, int), char **p, ...)
+{
+  char *s;
+  va_list v;
+  va_start (v,p);
+  s = g (p, va_arg (v,int));
+  va_end (v);
+  return s;
+}
+int test (int i, double x);
+struct s1 {int (*f) (int a);};
+struct s2 {int (*f) (double a);};
+int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
+int argc;
+char **argv;
+#ifdef F77_DUMMY_MAIN
+#  ifdef __cplusplus
+     extern "C"
+#  endif
+   int F77_DUMMY_MAIN() { return 1; }
+#endif
+int
+main ()
+{
+return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
+  ;
+  return 0;
+}
+_ACEOF
+# Don't try gcc -ansi; that turns off useful extensions and
+# breaks some systems' header files.
+# AIX                  -qlanglvl=ansi
+# Ultrix and OSF/1     -std1
+# HP-UX 10.20 and later        -Ae
+# HP-UX older versions -Aa -D_HPUX_SOURCE
+# SVR4                 -Xc -D__EXTENSIONS__
+for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+do
+  CC="$ac_save_CC $ac_arg"
+  rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_prog_cc_stdc=$ac_arg
+break
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+fi
+rm -f conftest.$ac_objext
+done
+rm -f conftest.$ac_ext conftest.$ac_objext
+CC=$ac_save_CC
+
+fi
+
+case "x$ac_cv_prog_cc_stdc" in
+  x|xno)
+    echo "$as_me:$LINENO: result: none needed" >&5
+echo "${ECHO_T}none needed" >&6 ;;
+  *)
+    echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5
+echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6
+    CC="$CC $ac_cv_prog_cc_stdc" ;;
+esac
+
 # Some people use a C++ compiler to compile C.  Since we use `exit',
 # in C++ we need to declare it.  In case someone uses the same compiler
 # for both compiling C and C++ we need to have the C++ compiler decide
@@ -5594,103 +5724,6 @@ fi
 
 
 
-echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5
-echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6
-if test "${ac_cv_prog_cc_stdc+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_cv_prog_cc_stdc=no
-ac_save_CC=$CC
-cat >conftest.$ac_ext <<_ACEOF
-#line $LINENO "configure"
-#include "confdefs.h"
-#include <stdarg.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-/* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
-struct buf { int x; };
-FILE * (*rcsopen) (struct buf *, struct stat *, int);
-static char *e (p, i)
-     char **p;
-     int i;
-{
-  return p[i];
-}
-static char *f (char * (*g) (char **, int), char **p, ...)
-{
-  char *s;
-  va_list v;
-  va_start (v,p);
-  s = g (p, va_arg (v,int));
-  va_end (v);
-  return s;
-}
-int test (int i, double x);
-struct s1 {int (*f) (int a);};
-struct s2 {int (*f) (double a);};
-int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
-int argc;
-char **argv;
-#ifdef F77_DUMMY_MAIN
-#  ifdef __cplusplus
-     extern "C"
-#  endif
-   int F77_DUMMY_MAIN() { return 1; }
-#endif
-int
-main ()
-{
-return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
-  ;
-  return 0;
-}
-_ACEOF
-# Don't try gcc -ansi; that turns off useful extensions and
-# breaks some systems' header files.
-# AIX                  -qlanglvl=ansi
-# Ultrix and OSF/1     -std1
-# HP-UX 10.20 and later        -Ae
-# HP-UX older versions -Aa -D_HPUX_SOURCE
-# SVR4                 -Xc -D__EXTENSIONS__
-for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
-do
-  CC="$ac_save_CC $ac_arg"
-  rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_prog_cc_stdc=$ac_arg
-break
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-fi
-rm -f conftest.$ac_objext
-done
-rm -f conftest.$ac_ext conftest.$ac_objext
-CC=$ac_save_CC
-
-fi
-
-case "x$ac_cv_prog_cc_stdc" in
-  x|xno)
-    echo "$as_me:$LINENO: result: none needed" >&5
-echo "${ECHO_T}none needed" >&6 ;;
-  *)
-    echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5
-echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6
-    CC="$CC $ac_cv_prog_cc_stdc" ;;
-esac
-
 echo "$as_me:$LINENO: checking for function prototypes" >&5
 echo $ECHO_N "checking for function prototypes... $ECHO_C" >&6
 if test "$ac_cv_prog_cc_stdc" != no; then
@@ -9060,6 +9093,124 @@ _ACEOF
   fi
 fi
 
+### Use Mac OS X Carbon API to implement GUI.
+HAVE_CARBON=no
+if test "${with_carbon}" != "no"; then
+  if test "${ac_cv_header_Carbon_Carbon_h+set}" = set; then
+  echo "$as_me:$LINENO: checking for Carbon/Carbon.h" >&5
+echo $ECHO_N "checking for Carbon/Carbon.h... $ECHO_C" >&6
+if test "${ac_cv_header_Carbon_Carbon_h+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+echo "$as_me:$LINENO: result: $ac_cv_header_Carbon_Carbon_h" >&5
+echo "${ECHO_T}$ac_cv_header_Carbon_Carbon_h" >&6
+else
+  # Is the header compilable?
+echo "$as_me:$LINENO: checking Carbon/Carbon.h usability" >&5
+echo $ECHO_N "checking Carbon/Carbon.h usability... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+#include "confdefs.h"
+$ac_includes_default
+#include <Carbon/Carbon.h>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_header_compiler=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6
+
+# Is the header present?
+echo "$as_me:$LINENO: checking Carbon/Carbon.h presence" >&5
+echo $ECHO_N "checking Carbon/Carbon.h presence... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+#include "confdefs.h"
+#include <Carbon/Carbon.h>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  egrep -v '^ *\+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  ac_header_preproc=no
+fi
+rm -f conftest.err conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc in
+  yes:no )
+    { echo "$as_me:$LINENO: WARNING: Carbon/Carbon.h: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: Carbon/Carbon.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: Carbon/Carbon.h: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: Carbon/Carbon.h: proceeding with the preprocessor's result" >&2;};;
+  no:yes )
+    { echo "$as_me:$LINENO: WARNING: Carbon/Carbon.h: present but cannot be compiled" >&5
+echo "$as_me: WARNING: Carbon/Carbon.h: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: Carbon/Carbon.h: check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: Carbon/Carbon.h: check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: Carbon/Carbon.h: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: Carbon/Carbon.h: proceeding with the preprocessor's result" >&2;};;
+esac
+echo "$as_me:$LINENO: checking for Carbon/Carbon.h" >&5
+echo $ECHO_N "checking for Carbon/Carbon.h... $ECHO_C" >&6
+if test "${ac_cv_header_Carbon_Carbon_h+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_cv_header_Carbon_Carbon_h=$ac_header_preproc
+fi
+echo "$as_me:$LINENO: result: $ac_cv_header_Carbon_Carbon_h" >&5
+echo "${ECHO_T}$ac_cv_header_Carbon_Carbon_h" >&6
+
+fi
+if test $ac_cv_header_Carbon_Carbon_h = yes; then
+  HAVE_CARBON=yes
+fi
+
+
+fi
+
+if test "${HAVE_CARBON}" = "yes"; then
+  cat >>confdefs.h <<\_ACEOF
+#define HAVE_CARBON 1
+_ACEOF
+
+fi
+
 ### Use session management (-lSM -lICE) if available
 HAVE_X_SM=no
 if test "${HAVE_X11}" = "yes"; then
@@ -16005,8 +16156,8 @@ fi
 rm -f conftest*
 
 
-ac_config_files="$ac_config_files Makefile lib-src/Makefile.c:lib-src/Makefile.in oldXMenu/Makefile man/Makefile lwlib/Makefile src/Makefile.c:src/Makefile.in lisp/Makefile lispref/Makefile lispintro/Makefile leim/Makefile"
-ac_config_commands="$ac_config_commands default"
+                                                                                                    ac_config_files="$ac_config_files Makefile lib-src/Makefile.c:lib-src/Makefile.in oldXMenu/Makefile man/Makefile lwlib/Makefile src/Makefile.c:src/Makefile.in lisp/Makefile lispref/Makefile lispintro/Makefile leim/Makefile"
+          ac_config_commands="$ac_config_commands default"
 cat >confcache <<\_ACEOF
 # This file is a shell script that caches the results of configure
 # tests run on this system so they can be shared between configure
@@ -16101,7 +16252,6 @@ SHELL=\${CONFIG_SHELL-$SHELL}
 _ACEOF
 
 cat >>$CONFIG_STATUS <<\_ACEOF
-
 ## --------------------- ##
 ## M4sh Initialization.  ##
 ## --------------------- ##
@@ -16110,6 +16260,9 @@ cat >>$CONFIG_STATUS <<\_ACEOF
 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
   emulate sh
   NULLCMD=:
+  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
 elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
   set -o posix
 fi
       { LC_MESSAGES=C; export LC_MESSAGES; }
 
 
+# Required to use basename.
+if expr a : '\(a\)' >/dev/null 2>&1; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
+  as_basename=basename
+else
+  as_basename=false
+fi
+
+
 # Name of the executable.
-as_me=`(basename "$0") 2>/dev/null ||
+as_me=`$as_basename "$0" ||
 $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
         X"$0" : 'X\(//\)$' \| \
         X"$0" : 'X\(/\)$' \| \
@@ -16160,6 +16327,7 @@ echo X/"$0" |
          /^X\/\(\/\).*/{ s//\1/; q; }
          s/.*/./; q'`
 
+
 # PATH needs CR, and LINENO needs CR and PATH.
 # Avoid depending upon Character Ranges.
 as_cr_letters='abcdefghijklmnopqrstuvwxyz'
@@ -16227,6 +16395,8 @@ do
   as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
   test "x$as_lineno_1" != "x$as_lineno_2" &&
   test "x$as_lineno_3"  = "x$as_lineno_2" ') 2>/dev/null; then
+            $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
+            $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
             CONFIG_SHELL=$as_dir/$as_base
             export CONFIG_SHELL
             exec "$CONFIG_SHELL" "$0" ${1+"$@"}
@@ -16300,6 +16470,12 @@ else
 fi
 rm -f conf$$ conf$$.exe conf$$.file
 
+if mkdir -p . 2>/dev/null; then
+  as_mkdir_p=:
+else
+  as_mkdir_p=false
+fi
+
 as_executable_p="test -f"
 
 # Sed expression to map a string onto a valid CPP name.
@@ -16333,7 +16509,7 @@ _ASBOX
 cat >&5 <<_CSEOF
 
 This file was extended by $as_me, which was
-generated by GNU Autoconf 2.53.  Invocation command line was
+generated by GNU Autoconf 2.53a.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
   CONFIG_HEADERS  = $CONFIG_HEADERS
@@ -16395,7 +16571,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF
 ac_cs_version="\\
 config.status
-configured by $0, generated by GNU Autoconf 2.53,
+configured by $0, generated by GNU Autoconf 2.53a,
   with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
 
 Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001
@@ -16705,25 +16881,30 @@ echo X"$ac_file" |
          /^X\(\/\/\)$/{ s//\1/; q; }
          /^X\(\/\).*/{ s//\1/; q; }
          s/.*/./; q'`
-  { case "$ac_dir" in
-  [\\/]* | ?:[\\/]* ) as_incr_dir=;;
-  *)                      as_incr_dir=.;;
-esac
-as_dummy="$ac_dir"
-for as_mkdir_dir in `IFS='/\\'; set X $as_dummy; shift; echo "$@"`; do
-  case $as_mkdir_dir in
-    # Skip DOS drivespec
-    ?:) as_incr_dir=$as_mkdir_dir ;;
-    *)
-      as_incr_dir=$as_incr_dir/$as_mkdir_dir
-      test -d "$as_incr_dir" ||
-        mkdir "$as_incr_dir" ||
-       { { echo "$as_me:$LINENO: error: cannot create \"$ac_dir\"" >&5
-echo "$as_me: error: cannot create \"$ac_dir\"" >&2;}
-   { (exit 1); exit 1; }; }
-    ;;
-  esac
-done; }
+  { if $as_mkdir_p; then
+    mkdir -p "$ac_dir"
+  else
+    as_dir="$ac_dir"
+    as_dirs=
+    while test ! -d "$as_dir"; do
+      as_dirs="$as_dir $as_dirs"
+      as_dir=`(dirname "$as_dir") 2>/dev/null ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+         X"$as_dir" : 'X\(//\)[^/]' \| \
+         X"$as_dir" : 'X\(//\)$' \| \
+         X"$as_dir" : 'X\(/\)' \| \
+         .     : '\(.\)' 2>/dev/null ||
+echo X"$as_dir" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+         /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+         /^X\(\/\/\)$/{ s//\1/; q; }
+         /^X\(\/\).*/{ s//\1/; q; }
+         s/.*/./; q'`
+    done
+    test ! -n "$as_dirs" || mkdir $as_dirs
+  fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
+echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
+   { (exit 1); exit 1; }; }; }
 
   ac_builddir=.
 
@@ -17023,25 +17204,30 @@ echo X"$ac_file" |
          /^X\(\/\/\)$/{ s//\1/; q; }
          /^X\(\/\).*/{ s//\1/; q; }
          s/.*/./; q'`
-      { case "$ac_dir" in
-  [\\/]* | ?:[\\/]* ) as_incr_dir=;;
-  *)                      as_incr_dir=.;;
-esac
-as_dummy="$ac_dir"
-for as_mkdir_dir in `IFS='/\\'; set X $as_dummy; shift; echo "$@"`; do
-  case $as_mkdir_dir in
-    # Skip DOS drivespec
-    ?:) as_incr_dir=$as_mkdir_dir ;;
-    *)
-      as_incr_dir=$as_incr_dir/$as_mkdir_dir
-      test -d "$as_incr_dir" ||
-        mkdir "$as_incr_dir" ||
-       { { echo "$as_me:$LINENO: error: cannot create \"$ac_dir\"" >&5
-echo "$as_me: error: cannot create \"$ac_dir\"" >&2;}
-   { (exit 1); exit 1; }; }
-    ;;
-  esac
-done; }
+      { if $as_mkdir_p; then
+    mkdir -p "$ac_dir"
+  else
+    as_dir="$ac_dir"
+    as_dirs=
+    while test ! -d "$as_dir"; do
+      as_dirs="$as_dir $as_dirs"
+      as_dir=`(dirname "$as_dir") 2>/dev/null ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+         X"$as_dir" : 'X\(//\)[^/]' \| \
+         X"$as_dir" : 'X\(//\)$' \| \
+         X"$as_dir" : 'X\(/\)' \| \
+         .     : '\(.\)' 2>/dev/null ||
+echo X"$as_dir" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+         /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+         /^X\(\/\/\)$/{ s//\1/; q; }
+         /^X\(\/\).*/{ s//\1/; q; }
+         s/.*/./; q'`
+    done
+    test ! -n "$as_dirs" || mkdir $as_dirs
+  fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
+echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
+   { (exit 1); exit 1; }; }; }
 
       rm -f $ac_file
       mv $tmp/config.h $ac_file
index ec584e9..054a556 100644 (file)
@@ -128,6 +128,8 @@ AC_ARG_WITH(toolkit-scroll-bars,
                           don't use Motif or Xaw3d scroll bars])
 AC_ARG_WITH(xim,
 [  --without-xim           don't use X11 XIM])
+AC_ARG_WITH(carbon,
+[  --without-carbon        don't use Carbon GUI on Mac OS X])
 
 #### Make srcdir absolute, if it isn't already.  It's important to
 #### avoid running the path through pwd unnecessarily, since pwd can
@@ -1104,6 +1106,13 @@ case "${canonical}" in
     machine=f301 opsys=uxpv
   ;;
 
+  ## Darwin / Mac OS X
+  powerpc-apple-darwin* )
+    machine=powermac opsys=darwin
+    # Define CPP as follows to make autoconf work correctly.
+    CPP="cc -E -traditional-cpp"
+  ;;
+
   * )
     unported=yes
   ;;
@@ -1997,6 +2006,16 @@ if test "${HAVE_X11}" = "yes"; then
   fi
 fi
 
+### Use Mac OS X Carbon API to implement GUI.
+HAVE_CARBON=no
+if test "${with_carbon}" != "no"; then
+  AC_CHECK_HEADER(Carbon/Carbon.h, HAVE_CARBON=yes)
+fi
+
+if test "${HAVE_CARBON}" = "yes"; then
+  AC_DEFINE(HAVE_CARBON)
+fi
+
 ### Use session management (-lSM -lICE) if available
 HAVE_X_SM=no
 if test "${HAVE_X11}" = "yes"; then
index 9239974..17f3060 100644 (file)
@@ -1,3 +1,8 @@
+2002-04-26  Andrew Choi  <akochoi@shaw.ca>
+
+       * term/mac-win.el: Don't call ediff-toggle-multiframe.  Set
+       default directory.  Set process-connection-type to nil.
+
 2002-04-26  Richard M. Stallman  <rms@gnu.org>
 
        * cus-edit.el (customize-face): Use read-face-name
index b386b57..6d7a97c 100644 (file)
@@ -36,9 +36,9 @@
 (put 'woman-faces 'custom-loads '("woman"))
 (put 'ps-print-vertical 'custom-loads '("ps-print"))
 (put 'supercite-hooks 'custom-loads '("supercite"))
-(put 'chinese-calendar 'custom-loads '("cal-china"))
 (put 'vhdl-menu 'custom-loads '("vhdl-mode"))
 (put 'gnus-newsrc 'custom-loads '("gnus-start"))
+(put 'chinese-calendar 'custom-loads '("cal-china"))
 (put 'expand 'custom-loads '("expand"))
 (put 'bookmark 'custom-loads '("bookmark"))
 (put 'icon 'custom-loads '("icon"))
@@ -62,7 +62,7 @@
 (put 'dirtrack 'custom-loads '("dirtrack"))
 (put 'ediff-window 'custom-loads '("ediff-help" "ediff-wind"))
 (put 'bruce 'custom-loads '("bruce"))
-(put 'windows 'custom-loads '("scroll-all" "window" "follow" "windmove"))
+(put 'windows 'custom-loads '("hscroll" "scroll-all" "window" "follow" "windmove"))
 (put 'gnus-exit 'custom-loads '("gnus-group" "gnus"))
 (put 'speedbar 'custom-loads '("speedbar"))
 (put 'etags 'custom-loads '("etags"))
 (put 'mh-hook 'custom-loads '("mh-e"))
 (put 'yow 'custom-loads '("yow"))
 (put 'reftex-defining-label-environments 'custom-loads '("reftex-vars"))
-(put 'asm 'custom-loads '("asm-mode" "cc-vars"))
+(put 'asm 'custom-loads '("asm-mode"))
 (put 'gnus-score-files 'custom-loads '("gnus-score" "gnus"))
 (put 'mail-abbrev 'custom-loads '("mailabbrev"))
 (put 'feedmail 'custom-loads '("feedmail"))
 (put 'iso-acc 'custom-loads '("iso-acc"))
 (put 'gnus-summary-pick 'custom-loads '("gnus-salt"))
 (put 'gnus-thread 'custom-loads '("gnus-sum"))
-(put 'languages 'custom-loads '("cus-edit" "info-look" "ada-mode" "antlr-mode" "asm-mode" "cperl-mode" "dcl-mode" "delphi" "f90" "fortran" "hideshow" "icon" "idlwave" "m4-mode" "meta-mode" "modula2" "octave-mod" "pascal" "perl-mode" "prolog" "ps-mode" "sh-script" "simula" "tcl" "vhdl-mode" "sgml-mode" "xml-lite"))
+(put 'languages 'custom-loads '("cus-edit" "info-look" "ada-mode" "antlr-mode" "asm-mode" "cperl-mode" "dcl-mode" "delphi" "f90" "fortran" "hideshow" "icon" "idlwave" "m4-mode" "meta-mode" "modula2" "octave-mod" "pascal" "perl-mode" "prolog" "ps-mode" "sh-script" "simula" "tcl" "vhdl-mode" "sgml-mode"))
 (put 'reftex-miscellaneous-configurations 'custom-loads '("reftex-vars"))
 (put 'pong 'custom-loads '("pong"))
 (put 'ediff-ptch 'custom-loads '("ediff-ptch"))
 (put 'smiley 'custom-loads '("smiley-ems"))
 (put 'extensions 'custom-loads '("generic" "time-stamp" "wid-edit" "cust-print" "eldoc" "page-ext"))
 (put 'tetris 'custom-loads '("tetris"))
-(put 'appt 'custom-loads '("appt"))
 (put 'ebnf-displacement 'custom-loads '("ebnf2ps"))
+(put 'appt 'custom-loads '("appt"))
 (put 'snmp 'custom-loads '("snmp-mode"))
 (put 'speedbar-faces 'custom-loads '("speedbar" "vhdl-mode"))
 (put 'rmail 'custom-loads '("paths" "rmail" "undigest"))
 (put 'auto-save 'custom-loads '("files" "startup"))
 (put 'tpu 'custom-loads '("tpu-edt" "tpu-extras"))
 (put 'w32 'custom-loads '("w32-vars"))
-(put 'viper-hooks 'custom-loads '("viper-init"))
 (put 'gnus-cite 'custom-loads '("gnus-cite"))
+(put 'viper-hooks 'custom-loads '("viper-init"))
 (put 'gnus-demon 'custom-loads '("gnus-demon"))
 (put 'reftex-optimizations-for-large-documents 'custom-loads '("reftex-vars"))
 (put 'viper-misc 'custom-loads '("viper-cmd" "viper-init" "viper"))
 (put 'cperl-indentation-details 'custom-loads '("cperl-mode"))
 (put 'mail-extr 'custom-loads '("mail-extr"))
 (put 'double 'custom-loads '("double"))
-(put 'xml-lite 'custom-loads '("xml-lite"))
 (put 'imenu 'custom-loads '("imenu"))
 (put 'eshell-var 'custom-loads '("esh-var"))
 (put 'scribe 'custom-loads '("scribe"))
 (put 'generic-x 'custom-loads '("generic-x"))
 (put 'partial-completion 'custom-loads '("complete"))
 (put 'whitespace 'custom-loads '("whitespace"))
-(put 'maint 'custom-loads '("emacsbug" "gulp" "lisp-mnt"))
+(put 'maint 'custom-loads '("gulp" "lisp-mnt" "emacsbug"))
 (put 'pages 'custom-loads '("page-ext"))
 (put 'message-interface 'custom-loads '("message"))
-(put 'diary 'custom-loads '("calendar" "diary-lib"))
+(put 'diary 'custom-loads '("calendar" "diary-lib" "solar"))
 (put 'custom-magic-faces 'custom-loads '("cus-edit"))
 (put 'emacsbug 'custom-loads '("emacsbug"))
 (put 'mh-compose 'custom-loads '("mh-comp"))
 (put 'apropos 'custom-loads '("apropos"))
 (put 'gomoku 'custom-loads '("gomoku"))
 (put 'eshell-pred 'custom-loads '("em-pred"))
-(put 'tools 'custom-loads '("add-log" "calculator" "compare-w" "diff-mode" "diff" "ediff" "elide-head" "emerge" "gud" "pcvs-defs" "smerge-mode" "speedbar" "tempo" "tooltip" "vc" "which-func" "rcompile" "copyright" "compile" "ebrowse" "etags" "glasses" "make-mode"))
+(put 'tools 'custom-loads '("add-log" "calculator" "compare-w" "diff-mode" "diff" "ediff" "elide-head" "emerge" "gud" "pcvs-defs" "smerge-mode" "speedbar" "tempo" "tooltip" "vc" "which-func" "copyright" "rcompile" "compile" "ebrowse" "etags" "glasses" "make-mode"))
 (put 'gnus-topic 'custom-loads '("gnus-topic"))
 (put 'sgml 'custom-loads '("sgml-mode"))
 (put 'keyboard 'custom-loads '("mule" "chistory" "type-break"))
 (put 'nnmail-retrieve 'custom-loads '("nnmail"))
 (put 'gnus-duplicate 'custom-loads '("gnus-dup"))
 (put 'find-function 'custom-loads '("find-func"))
-(put 'menu 'custom-loads '("faces" "tmm" "easymenu"))
+(put 'menu 'custom-loads '("faces" "menu-bar" "tmm" "easymenu"))
 (put 'eshell-test 'custom-loads '("esh-test"))
 (put 'vhdl-highlight 'custom-loads '("vhdl-mode"))
 (put 'widgets 'custom-loads '("wid-browse" "wid-edit"))
 (put 'log-view 'custom-loads '("log-view"))
 (put 'PostScript 'custom-loads '("ps-mode"))
 (put 'abbrev-mode 'custom-loads '("abbrev" "cus-edit" "mailabbrev"))
-(put 'eshell-term 'custom-loads '("em-term"))
 (put 'earcon 'custom-loads '("earcon"))
+(put 'eshell-term 'custom-loads '("em-term"))
 (put 'feedmail-headers 'custom-loads '("feedmail"))
 (put 'hypermedia 'custom-loads '("wid-edit" "metamail" "browse-url" "goto-addr"))
 (put 'image 'custom-loads '("image-file"))
 (put 'reftex-index-support 'custom-loads '("reftex-vars"))
 (put 'pascal 'custom-loads '("pascal"))
 (put 'rmail-retrieve 'custom-loads '("rmail" "rmailsum"))
-(put 'data 'custom-loads '("text-mode" "arc-mode" "forms" "hexl" "jka-compr" "saveplace" "sort" "tar-mode" "time-stamp" "snmp-mode" "timeclock"))
+(put 'data 'custom-loads '("text-mode" "arc-mode" "forms" "hexl" "jka-compr" "saveplace" "sort" "tar-mode" "time-stamp" "timeclock" "snmp-mode"))
 (put 'mail 'custom-loads '("simple" "startup" "time" "gnus" "mail-utils" "mm-decode" "message" "imap" "starttls" "emacsbug" "feedmail" "mail-extr" "mail-hist" "mailalias" "metamail" "mh-e" "mspools" "rmail" "sendmail" "smtpmail" "supercite" "uce" "eudc-vars" "fortune"))
 (put 'paren-blinking 'custom-loads '("simple"))
 (put 'gnus-summary-sort 'custom-loads '("gnus-sum"))
 (custom-put-if-not 'change-log-conditionals-face 'group-documentation nil)
 (custom-put-if-not 'mail-source 'custom-version "21.1")
 (custom-put-if-not 'mail-source 'group-documentation "The mail-fetching library.")
-(custom-put-if-not 'smtpmail-auth-credentials 'custom-version "21.1")
+(custom-put-if-not 'smtpmail-auth-credentials 'custom-version "21.3")
 (custom-put-if-not 'smtpmail-auth-credentials 'standard-value t)
 (custom-put-if-not 'minibuffer-prompt 'custom-version "21.3")
 (custom-put-if-not 'minibuffer-prompt 'group-documentation nil)
@@ -777,6 +776,8 @@ the tasks accomplished by such tools.")
 (custom-put-if-not 'tildify 'group-documentation "Adding missing hard spaces or other text fragments into texts.")
 (custom-put-if-not 'normal-erase-is-backspace 'custom-version "21.1")
 (custom-put-if-not 'normal-erase-is-backspace 'standard-value t)
+(custom-put-if-not 'vc-cvs-global-switches 'custom-version "21.3")
+(custom-put-if-not 'vc-cvs-global-switches 'standard-value t)
 (custom-put-if-not 'gnus-article-banner-alist 'custom-version "21.1")
 (custom-put-if-not 'gnus-article-banner-alist 'standard-value t)
 (custom-put-if-not 'region 'custom-version "21.1")
@@ -840,6 +841,8 @@ as a PDF file <URL:http://www.ecma.ch/ecma1/STAND/ECMA-048.HTM>.")
 (custom-put-if-not 'message-buffer-naming-style 'standard-value t)
 (custom-put-if-not 'ps-footer-font-size 'custom-version "21.1")
 (custom-put-if-not 'ps-footer-font-size 'standard-value t)
+(custom-put-if-not 'hscroll-margin 'custom-version "21.3")
+(custom-put-if-not 'hscroll-margin 'standard-value t)
 (custom-put-if-not 'tags-apropos-additional-actions 'custom-version "21.1")
 (custom-put-if-not 'tags-apropos-additional-actions 'standard-value t)
 (custom-put-if-not 'generic-x 'custom-version "20.3")
@@ -858,6 +861,8 @@ as a PDF file <URL:http://www.ecma.ch/ecma1/STAND/ECMA-048.HTM>.")
 (custom-put-if-not 'vcursor-interpret-input 'standard-value t)
 (custom-put-if-not 'gnus-audio 'custom-version "21.1")
 (custom-put-if-not 'gnus-audio 'group-documentation "Playing sound in Gnus.")
+(custom-put-if-not 'diary-sabbath-candles-minutes 'custom-version "21.1")
+(custom-put-if-not 'diary-sabbath-candles-minutes 'standard-value t)
 (custom-put-if-not 'trailing-whitespace 'custom-version "21.1")
 (custom-put-if-not 'trailing-whitespace 'group-documentation nil)
 (custom-put-if-not 'fortran-comment-line-start 'custom-version "21.1")
@@ -946,6 +951,8 @@ as a PDF file <URL:http://www.ecma.ch/ecma1/STAND/ECMA-048.HTM>.")
 (custom-put-if-not 'change-log-version-number-regexp-list 'standard-value t)
 (custom-put-if-not 'menu 'custom-version "21.1")
 (custom-put-if-not 'menu 'group-documentation "Input from the menus.")
+(custom-put-if-not 'dired-view-command-alist 'custom-version 21.4)
+(custom-put-if-not 'dired-view-command-alist 'standard-value t)
 (custom-put-if-not 'gnus-nocem-check-from 'custom-version "21.1")
 (custom-put-if-not 'gnus-nocem-check-from 'standard-value t)
 (custom-put-if-not 'sgml-validate-command 'custom-version "21.1")
@@ -988,6 +995,8 @@ as a PDF file <URL:http://www.ecma.ch/ecma1/STAND/ECMA-048.HTM>.")
 (custom-put-if-not 'message-forward-ignored-headers 'standard-value t)
 (custom-put-if-not 'eudc 'custom-version "21.1")
 (custom-put-if-not 'eudc 'group-documentation "Emacs Unified Directory Client.")
+(custom-put-if-not 'yank-excluded-properties 'custom-version 21.4)
+(custom-put-if-not 'yank-excluded-properties 'standard-value t)
 (custom-put-if-not 'scrolling 'custom-version "21.1")
 (custom-put-if-not 'scrolling 'group-documentation "Scrolling windows.")
 (custom-put-if-not 'ps-paragraph-regexp 'custom-version "21.1")
@@ -1020,8 +1029,6 @@ as a PDF file <URL:http://www.ecma.ch/ecma1/STAND/ECMA-048.HTM>.")
 (custom-put-if-not 'custom-comment-face 'group-documentation nil)
 (custom-put-if-not 'custom-raised-buttons 'custom-version "21.1")
 (custom-put-if-not 'custom-raised-buttons 'standard-value t)
-(custom-put-if-not 'gnus-article-x-face-command 'custom-version "21.1")
-(custom-put-if-not 'gnus-article-x-face-command 'standard-value t)
 (custom-put-if-not 'gnus-inhibit-user-auto-expire 'custom-version "21.1")
 (custom-put-if-not 'gnus-inhibit-user-auto-expire 'standard-value t)
 (custom-put-if-not 'show-paren-ring-bell-on-mismatch 'custom-version "20.3")
@@ -1034,6 +1041,8 @@ as a PDF file <URL:http://www.ecma.ch/ecma1/STAND/ECMA-048.HTM>.")
 (custom-put-if-not 'gnus-emphasize-whitespace-regexp 'standard-value t)
 (custom-put-if-not 'gnus-summary-show-article-charset-alist 'custom-version "21.1")
 (custom-put-if-not 'gnus-summary-show-article-charset-alist 'standard-value t)
+(custom-put-if-not 'mail-use-dsn 'custom-version "21.3")
+(custom-put-if-not 'mail-use-dsn 'standard-value t)
 (custom-put-if-not 'xscheme-start-hook 'custom-version 20.3)
 (custom-put-if-not 'xscheme-start-hook 'standard-value t)
 (custom-put-if-not 'vc-dired-listing-switches 'custom-version "21.1")
@@ -1151,7 +1160,7 @@ as a PDF file <URL:http://www.ecma.ch/ecma1/STAND/ECMA-048.HTM>.")
 (custom-put-if-not 'eval-expression-print-level 'custom-version "21.1")
 (custom-put-if-not 'eval-expression-print-level 'standard-value t)
 
-(defvar custom-versions-load-alist '((20.3 "xscheme") ("20.3.3" "dos-vars") (21.1 "ange-ftp") ("20.4" "files" "help" "sh-script" "compile") ("21.2" "add-log" "sgml-mode") ("21.3" "vc-cvs" "replace" "ange-ftp") (21.3 "ange-ftp") ("20.3" "desktop" "easymenu" "hscroll" "dabbrev" "ffap" "rmail" "paren" "mailabbrev" "frame" "uce" "mouse" "diary-lib" "sendmail" "simple" "debug" "hexl" "vcursor" "vc" "compile" "etags" "help-mode" "browse-url" "add-log" "find-func" "cus-edit" "replace") ("21.1" "server" "debug" "rmailedit" "dabbrev" "isearch" "gnus-start" "mule" "hideshow" "sendmail" "paths" "sgml-mode" "net-utils" "cperl-mode" "rmail" "font-lock" "gnus-nocem" "vc-hooks" "paren" "faces" "vc-rcs" "fortran" "vc" "etags" "cus-edit" "vc-sccs" "gnus-group" "gnus-sum" "add-log" "find-func" "frame" "wid-edit" "smtpmail" "files" "nnmail" "message" "ps-print" "vc-cvs" "simple" "gnus-agent" "flyspell" "gnus-art" "browse-url" "speedbar") ("20.8" "sql"))
+(defvar custom-versions-load-alist '((20.3 "xscheme") (21.4 "simple" "dired") ("20.3.3" "dos-vars") (21.1 "ange-ftp") ("20.4" "files" "help" "sh-script" "compile") ("21.2" "add-log" "sgml-mode") (21.3 "ange-ftp") ("21.3" "sendmail" "replace" "hscroll" "vc-cvs" "ange-ftp" "smtpmail") ("20.3" "desktop" "easymenu" "hscroll" "dabbrev" "ffap" "rmail" "paren" "mailabbrev" "frame" "uce" "mouse" "diary-lib" "sendmail" "simple" "debug" "hexl" "vcursor" "vc" "compile" "etags" "help-mode" "browse-url" "add-log" "find-func" "cus-edit" "replace") ("21.1" "server" "debug" "rmailedit" "dabbrev" "isearch" "gnus-start" "mule" "hideshow" "sendmail" "paths" "sgml-mode" "net-utils" "cperl-mode" "rmail" "font-lock" "gnus-nocem" "vc-hooks" "paren" "faces" "vc-rcs" "fortran" "solar" "vc" "etags" "cus-edit" "vc-sccs" "gnus-group" "gnus-sum" "smtpmail" "add-log" "find-func" "frame" "wid-edit" "files" "nnmail" "message" "ps-print" "vc-cvs" "simple" "gnus-agent" "flyspell" "gnus-art" "browse-url" "speedbar") ("20.8" "sql"))
  "For internal use by custom.")
 
 (provide 'cus-load)
index 7172fea..ac6e7d5 100644 (file)
         "highlight the current line"
         (faces  frames  emulation))
     ("ibuf-ext.el"
-        "extensions for ibuffer"
+        "extensions for ibuffer "
         (buffer  convenience))
     ("ibuf-macs.el"
         "macros for ibuffer"
     ("calcsel2.el"
         "selection functions for Calc"
         nil)
-    ("binhex.el"
-        "elisp native binhex decode"
-        (binhex news))
-    ("earcon.el"
-        "sound effects for messages"
-        nil)
-    ("flow-fill.el"
-        "interprete RFC2646 \"flowed\" text"
-        (mail))
-    ("format-spec.el"
-        "functions for formatting arbitrary formatting strings"
-        (tools))
-    ("gnus-agent.el"
-        "unplugged support for Gnus"
-        nil)
-    ("gnus-art.el"
-        "article mode commands for Gnus"
-        (news))
-    ("gnus-async.el"
-        "asynchronous support for Gnus"
-        (news))
-    ("gnus-audio.el"
-        "sound effects for Gnus"
-        (news  mail  multimedia))
-    ("gnus-bcklg.el"
-        "backlog functions for Gnus"
-        (news))
-    ("gnus-cache.el"
-        "cache interface for Gnus"
-        (news))
-    ("gnus-cite.el"
-        "parse citations in articles for Gnus"
-        nil)
-    ("gnus-cus.el"
-        "customization commands for Gnus"
-        (news))
-    ("gnus-demon.el"
-        "daemonic Gnus behaviour"
-        (news))
-    ("gnus-draft.el"
-        "draft message support for Gnus"
-        (news))
-    ("gnus-dup.el"
-        "suppression of duplicate articles in Gnus"
-        (news))
-    ("gnus-eform.el"
-        "a mode for editing forms for Gnus"
-        (news))
-    ("gnus-ems.el"
-        "functions for making Gnus work under different Emacsen"
-        (news))
-    ("gnus-gl.el"
-        "an interface to GroupLens for Gnus"
-        (news  score))
-    ("gnus-group.el"
-        "group mode commands for Gnus"
-        (news))
-    ("gnus-int.el"
-        "backend interface functions for Gnus"
-        (news))
-    ("gnus-kill.el"
-        "kill commands for Gnus"
-        (news))
-    ("gnus-logic.el"
-        "advanced scoring code for Gnus"
-        (news))
-    ("gnus-mh.el"
-        "mh-e interface for Gnus"
-        (news))
-    ("gnus-ml.el"
-        "mailing list minor mode for Gnus"
-        (news))
-    ("gnus-mlspl.el"
-        "a group params-based mail splitting mechanism"
-        (news  mail))
-    ("gnus-move.el"
-        "commands for moving Gnus from one server to another"
-        (news))
-    ("gnus-msg.el"
-        "mail and post interface for Gnus"
-        (news))
-    ("gnus-mule.el"
-        "provide backward compatibility function to GNUS"
-        (news  i18n))
-    ("gnus-nocem.el"
-        "NoCeM pseudo-cancellation treatment"
-        (news))
-    ("gnus-range.el"
-        "range and sequence functions for Gnus"
-        (news))
-    ("gnus-salt.el"
-        "alternate summary mode interfaces for Gnus"
-        (news))
-    ("gnus-score.el"
-        "scoring code for Gnus"
-        (news))
-    ("gnus-setup.el"
-        "initialization & setup for Gnus 5"
-        (news))
-    ("gnus-soup.el"
-        "SOUP packet writing support for Gnus"
-        (news  mail))
-    ("gnus-spec.el"
-        "format spec functions for Gnus"
-        (news))
-    ("gnus-srvr.el"
-        "virtual server support for Gnus"
-        (news))
-    ("gnus-start.el"
-        "startup functions for Gnus"
-        (news))
-    ("gnus-sum.el"
-        "summary mode commands for Gnus"
-        (news))
-    ("gnus-topic.el"
-        "a folding minor mode for Gnus group buffers"
-        (news))
-    ("gnus-undo.el"
-        "minor mode for undoing in Gnus"
-        (news))
-    ("gnus-util.el"
-        "utility functions for Gnus"
-        (news))
-    ("gnus-uu.el"
-        "extract (uu)encoded files in Gnus"
-        nil)
-    ("gnus-vm.el"
-        "vm interface for Gnus"
-        (news  mail))
-    ("gnus-win.el"
-        "window configuration functions for Gnus"
-        (news))
-    ("gnus.el"
-        "a newsreader for GNU Emacs"
-        (news  mail))
-    ("ietf-drums.el"
-        "functions for parsing RFC822bis headers"
-        nil)
-    ("imap.el"
-        "imap library"
-        (mail))
-    ("mail-parse.el"
-        "interface functions for parsing mail"
-        nil)
-    ("mail-prsvr.el"
-        "interface variables for parsing mail"
-        nil)
-    ("mail-source.el"
-        "functions for fetching mail"
-        (news  mail))
-    ("mailcap.el"
-        "MIME media types configuration"
-        (news  mail  multimedia))
-    ("message.el"
-        "composing mail and news messages"
-        (mail  news))
-    ("messcompat.el"
-        "making message mode compatible with mail mode"
-        (mail  news))
-    ("mm-bodies.el"
-        "functions for decoding MIME things"
-        nil)
-    ("mm-decode.el"
-        "functions for decoding MIME things"
-        nil)
-    ("mm-encode.el"
-        "functions for encoding MIME things "
-        nil)
-    ("mm-partial.el"
-        "showing message/partial"
-        (message partial))
-    ("mm-util.el"
-        "Utility functions for Mule and low level things"
-        nil)
-    ("mm-uu.el"
-        "return uu stuff as mm handles"
-        (postscript uudecode binhex shar forward news))
-    ("mm-view.el"
-        "functions for viewing MIME objects"
-        nil)
-    ("mml.el"
-        "package for parsing and validating MML documents"
-        nil)
-    ("nnagent.el"
-        "offline backend for Gnus"
-        (news  mail))
-    ("nnbabyl.el"
-        "rmail mbox access for Gnus"
-        (news  mail))
-    ("nndir.el"
-        "single directory newsgroup access for Gnus"
-        (news))
-    ("nndoc.el"
-        "single file access for Gnus"
-        (news))
-    ("nndraft.el"
-        "draft article access for Gnus"
-        (news))
-    ("nneething.el"
-        "arbitrary file access for Gnus"
-        (news  mail))
-    ("nnfolder.el"
-        "mail folder access for Gnus"
-        (mail))
-    ("nngateway.el"
-        "posting news via mail gateways"
-        (news  mail))
-    ("nnheader.el"
-        "header access macros for Gnus and its backends"
-        (news))
-    ("nnimap.el"
-        "imap backend for Gnus"
-        (mail))
-    ("nnkiboze.el"
-        "select virtual news access for Gnus"
-        (news))
-    ("nnlistserv.el"
-        "retrieving articles via web mailing list archives"
-        (news  mail))
-    ("nnmail.el"
-        "mail support functions for the Gnus mail backends"
-        (news  mail))
-    ("nnmbox.el"
-        "mail mbox access for Gnus"
-        (news  mail))
-    ("nnmh.el"
-        "mhspool access for Gnus"
-        (news  mail))
-    ("nnml.el"
-        "mail spool access for Gnus"
-        (news  mail))
-    ("nnoo.el"
-        "OO Gnus Backends"
-        (news))
-    ("nnslashdot.el"
-        "interfacing with Slashdot"
-        (news))
-    ("nnsoup.el"
-        "SOUP access for Gnus"
-        (news  mail))
-    ("nnspool.el"
-        "spool access for GNU Emacs"
-        (news))
-    ("nntp.el"
-        "nntp access for Gnus"
-        (news))
-    ("nnultimate.el"
-        "interfacing with the Ultimate Bulletin Board system"
-        (news))
-    ("nnvirtual.el"
-        "virtual newsgroups access for Gnus"
-        (news))
-    ("nnwarchive.el"
-        "interfacing with web archives"
-        (news egroups mail-archive))
-    ("nnweb.el"
-        "retrieving articles via web search engines"
-        (news))
-    ("pop3.el"
-        "Post Office Protocol (RFC 1460) interface"
-        (mail))
-    ("qp.el"
-        "Quoted-Printable functions"
-        (mail  extensions))
-    ("rfc1843.el"
-        "HZ (rfc1843) decoding"
-        (news hz hz+ mail i18n))
-    ("rfc2045.el"
-        "functions for decoding rfc2045 headers"
-        nil)
-    ("rfc2047.el"
-        "functions for encoding and decoding rfc2047 messages"
-        nil)
-    ("rfc2104.el"
-        "RFC2104 Hashed Message Authentication Codes"
-        (mail))
-    ("rfc2231.el"
-        "functions for decoding rfc2231 headers"
-        nil)
-    ("score-mode.el"
-        "mode for editing Gnus score files"
-        (news  mail))
-    ("smiley-ems.el"
-        "displaying smiley faces"
-        (news mail multimedia))
-    ("starttls.el"
-        "STARTTLS functions"
-        (tls  ssl  openssl  mail  news))
-    ("utf7.el"
-        "UTF-7 encoding/decoding for Emacs"
-        (mail))
-    ("uudecode.el"
-        "elisp native uudecode"
-        (uudecode news))
-    ("webmail.el"
-        "interface of web mail"
-        (hotmail netaddress my-deja netscape))
     ("appt.el"
         "appointment notification functions"
         (calendar))
     ("em-xtra.el"
         "extra alias functions"
         nil)
-    ("esh-arg.el"
-        "argument processing"
+    ("esh-arg.el"
+        "argument processing"
+        nil)
+    ("esh-cmd.el"
+        "command invocation"
+        nil)
+    ("esh-ext.el"
+        "commands external to Eshell"
+        nil)
+    ("esh-groups.el"
+        nil
+        nil)
+    ("esh-io.el"
+        "I/O management"
+        nil)
+    ("esh-maint.el"
+        "init code for building eshell"
+        nil)
+    ("esh-mode.el"
+        "user interface"
+        nil)
+    ("esh-module.el"
+        "Eshell modules"
+        (processes))
+    ("esh-opt.el"
+        "command options processing"
+        nil)
+    ("esh-proc.el"
+        "process management"
+        nil)
+    ("esh-test.el"
+        "Eshell test suite"
+        nil)
+    ("esh-util.el"
+        "general utilities"
+        nil)
+    ("esh-var.el"
+        "handling of variables"
+        nil)
+    ("eshell.el"
+        "the Emacs command shell"
+        (processes))
+    ("binhex.el"
+        "elisp native binhex decode"
+        (binhex news))
+    ("earcon.el"
+        "sound effects for messages"
+        nil)
+    ("flow-fill.el"
+        "interprete RFC2646 \"flowed\" text"
+        (mail))
+    ("format-spec.el"
+        "functions for formatting arbitrary formatting strings"
+        (tools))
+    ("gnus-agent.el"
+        "unplugged support for Gnus"
+        nil)
+    ("gnus-art.el"
+        "article mode commands for Gnus"
+        (news))
+    ("gnus-async.el"
+        "asynchronous support for Gnus"
+        (news))
+    ("gnus-audio.el"
+        "sound effects for Gnus"
+        (news  mail  multimedia))
+    ("gnus-bcklg.el"
+        "backlog functions for Gnus"
+        (news))
+    ("gnus-cache.el"
+        "cache interface for Gnus"
+        (news))
+    ("gnus-cite.el"
+        "parse citations in articles for Gnus"
+        nil)
+    ("gnus-cus.el"
+        "customization commands for Gnus"
+        (news))
+    ("gnus-demon.el"
+        "daemonic Gnus behaviour"
+        (news))
+    ("gnus-draft.el"
+        "draft message support for Gnus"
+        (news))
+    ("gnus-dup.el"
+        "suppression of duplicate articles in Gnus"
+        (news))
+    ("gnus-eform.el"
+        "a mode for editing forms for Gnus"
+        (news))
+    ("gnus-ems.el"
+        "functions for making Gnus work under different Emacsen"
+        (news))
+    ("gnus-gl.el"
+        "an interface to GroupLens for Gnus"
+        (news  score))
+    ("gnus-group.el"
+        "group mode commands for Gnus"
+        (news))
+    ("gnus-int.el"
+        "backend interface functions for Gnus"
+        (news))
+    ("gnus-kill.el"
+        "kill commands for Gnus"
+        (news))
+    ("gnus-logic.el"
+        "advanced scoring code for Gnus"
+        (news))
+    ("gnus-mh.el"
+        "mh-e interface for Gnus"
+        (news))
+    ("gnus-ml.el"
+        "mailing list minor mode for Gnus"
+        (news))
+    ("gnus-mlspl.el"
+        "a group params-based mail splitting mechanism"
+        (news  mail))
+    ("gnus-move.el"
+        "commands for moving Gnus from one server to another"
+        (news))
+    ("gnus-msg.el"
+        "mail and post interface for Gnus"
+        (news))
+    ("gnus-mule.el"
+        "provide backward compatibility function to GNUS"
+        (news  i18n))
+    ("gnus-nocem.el"
+        "NoCeM pseudo-cancellation treatment"
+        (news))
+    ("gnus-range.el"
+        "range and sequence functions for Gnus"
+        (news))
+    ("gnus-salt.el"
+        "alternate summary mode interfaces for Gnus"
+        (news))
+    ("gnus-score.el"
+        "scoring code for Gnus"
+        (news))
+    ("gnus-setup.el"
+        "initialization & setup for Gnus 5"
+        (news))
+    ("gnus-soup.el"
+        "SOUP packet writing support for Gnus"
+        (news  mail))
+    ("gnus-spec.el"
+        "format spec functions for Gnus"
+        (news))
+    ("gnus-srvr.el"
+        "virtual server support for Gnus"
+        (news))
+    ("gnus-start.el"
+        "startup functions for Gnus"
+        (news))
+    ("gnus-sum.el"
+        "summary mode commands for Gnus"
+        (news))
+    ("gnus-topic.el"
+        "a folding minor mode for Gnus group buffers"
+        (news))
+    ("gnus-undo.el"
+        "minor mode for undoing in Gnus"
+        (news))
+    ("gnus-util.el"
+        "utility functions for Gnus"
+        (news))
+    ("gnus-uu.el"
+        "extract (uu)encoded files in Gnus"
+        nil)
+    ("gnus-vm.el"
+        "vm interface for Gnus"
+        (news  mail))
+    ("gnus-win.el"
+        "window configuration functions for Gnus"
+        (news))
+    ("gnus.el"
+        "a newsreader for GNU Emacs"
+        (news  mail))
+    ("ietf-drums.el"
+        "functions for parsing RFC822bis headers"
         nil)
-    ("esh-cmd.el"
-        "command invocation"
+    ("imap.el"
+        "imap library"
+        (mail))
+    ("mail-parse.el"
+        "interface functions for parsing mail"
         nil)
-    ("esh-ext.el"
-        "commands external to Eshell"
+    ("mail-prsvr.el"
+        "interface variables for parsing mail"
         nil)
-    ("esh-groups.el"
-        nil
+    ("mail-source.el"
+        "functions for fetching mail"
+        (news  mail))
+    ("mailcap.el"
+        "MIME media types configuration"
+        (news  mail  multimedia))
+    ("message.el"
+        "composing mail and news messages"
+        (mail  news))
+    ("messcompat.el"
+        "making message mode compatible with mail mode"
+        (mail  news))
+    ("mm-bodies.el"
+        "functions for decoding MIME things"
         nil)
-    ("esh-io.el"
-        "I/O management"
+    ("mm-decode.el"
+        "functions for decoding MIME things"
         nil)
-    ("esh-maint.el"
-        "init code for building eshell"
+    ("mm-encode.el"
+        "functions for encoding MIME things "
         nil)
-    ("esh-mode.el"
-        "user interface"
+    ("mm-partial.el"
+        "showing message/partial"
+        (message partial))
+    ("mm-util.el"
+        "Utility functions for Mule and low level things"
         nil)
-    ("esh-module.el"
-        "Eshell modules"
-        (processes))
-    ("esh-opt.el"
-        "command options processing"
+    ("mm-uu.el"
+        "return uu stuff as mm handles"
+        (postscript uudecode binhex shar forward news))
+    ("mm-view.el"
+        "functions for viewing MIME objects"
         nil)
-    ("esh-proc.el"
-        "process management"
+    ("mml.el"
+        "package for parsing and validating MML documents"
         nil)
-    ("esh-test.el"
-        "Eshell test suite"
+    ("nnagent.el"
+        "offline backend for Gnus"
+        (news  mail))
+    ("nnbabyl.el"
+        "rmail mbox access for Gnus"
+        (news  mail))
+    ("nndir.el"
+        "single directory newsgroup access for Gnus"
+        (news))
+    ("nndoc.el"
+        "single file access for Gnus"
+        (news))
+    ("nndraft.el"
+        "draft article access for Gnus"
+        (news))
+    ("nneething.el"
+        "arbitrary file access for Gnus"
+        (news  mail))
+    ("nnfolder.el"
+        "mail folder access for Gnus"
+        (mail))
+    ("nngateway.el"
+        "posting news via mail gateways"
+        (news  mail))
+    ("nnheader.el"
+        "header access macros for Gnus and its backends"
+        (news))
+    ("nnimap.el"
+        "imap backend for Gnus"
+        (mail))
+    ("nnkiboze.el"
+        "select virtual news access for Gnus"
+        (news))
+    ("nnlistserv.el"
+        "retrieving articles via web mailing list archives"
+        (news  mail))
+    ("nnmail.el"
+        "mail support functions for the Gnus mail backends"
+        (news  mail))
+    ("nnmbox.el"
+        "mail mbox access for Gnus"
+        (news  mail))
+    ("nnmh.el"
+        "mhspool access for Gnus"
+        (news  mail))
+    ("nnml.el"
+        "mail spool access for Gnus"
+        (news  mail))
+    ("nnoo.el"
+        "OO Gnus Backends"
+        (news))
+    ("nnslashdot.el"
+        "interfacing with Slashdot"
+        (news))
+    ("nnsoup.el"
+        "SOUP access for Gnus"
+        (news  mail))
+    ("nnspool.el"
+        "spool access for GNU Emacs"
+        (news))
+    ("nntp.el"
+        "nntp access for Gnus"
+        (news))
+    ("nnultimate.el"
+        "interfacing with the Ultimate Bulletin Board system"
+        (news))
+    ("nnvirtual.el"
+        "virtual newsgroups access for Gnus"
+        (news))
+    ("nnwarchive.el"
+        "interfacing with web archives"
+        (news egroups mail-archive))
+    ("nnweb.el"
+        "retrieving articles via web search engines"
+        (news))
+    ("pop3.el"
+        "Post Office Protocol (RFC 1460) interface"
+        (mail))
+    ("qp.el"
+        "Quoted-Printable functions"
+        (mail  extensions))
+    ("rfc1843.el"
+        "HZ (rfc1843) decoding"
+        (news hz hz+ mail i18n))
+    ("rfc2045.el"
+        "functions for decoding rfc2045 headers"
         nil)
-    ("esh-util.el"
-        "general utilities"
+    ("rfc2047.el"
+        "functions for encoding and decoding rfc2047 messages"
         nil)
-    ("esh-var.el"
-        "handling of variables"
+    ("rfc2104.el"
+        "RFC2104 Hashed Message Authentication Codes"
+        (mail))
+    ("rfc2231.el"
+        "functions for decoding rfc2231 headers"
         nil)
-    ("eshell.el"
-        "the Emacs command shell"
-        (processes))
+    ("score-mode.el"
+        "mode for editing Gnus score files"
+        (news  mail))
+    ("smiley-ems.el"
+        "displaying smiley faces"
+        (news mail multimedia))
+    ("starttls.el"
+        "STARTTLS functions"
+        (tls  ssl  openssl  mail  news))
+    ("utf7.el"
+        "UTF-7 encoding/decoding for Emacs"
+        (mail))
+    ("uudecode.el"
+        "elisp native uudecode"
+        (uudecode news))
+    ("webmail.el"
+        "interface of web mail"
+        (hotmail netaddress my-deja netscape))
     ("ccl.el"
         "CCL (Code Conversion Language) compiler"
         (ccl  mule  multilingual  character set  coding-system))
         "translation of untranslatable utf-8 to CJK"
         (i18n))
     ("utf-8.el"
-        "Limited UTF-8 decoding/encoding support"
+        "limited UTF-8 decoding/encoding support"
         (multilingual  unicode  utf-8  i18n))
     ("china-util.el"
         "utilities for Chinese"
     ("net-utils.el"
         "network functions"
         (network comm))
+    ("netrc.el"
+        ".netrc parsing functionality"
+        (news))
     ("quickurl.el"
         "insert an URL based on text at point in buffer"
         (hypermedia))
     ("underline.el"
         "insert/remove underlining (done by overstriking) in Emacs"
         (wp))
-    ("xml-lite.el"
-        "an indentation-engine for XML"
-        (xml))
     ("tool-bar.el"
         "setting up the tool bar"
         (mouse frames))
index c210a63..e5da51e 100644 (file)
@@ -2705,7 +2705,7 @@ See the documentation of that function for more information." t nil)
 
 ;;;***
 \f
-;;;### (autoloads nil "cc-langs" "progmodes/cc-langs.el" (15556 56060))
+;;;### (autoloads nil "cc-langs" "progmodes/cc-langs.el" (15557 64404))
 ;;; Generated autoloads from progmodes/cc-langs.el
 
 (defvar c-mode-syntax-table nil "\
@@ -2730,7 +2730,7 @@ Syntax table used in pike-mode buffers.")
 \f
 ;;;### (autoloads (pike-mode idl-mode java-mode objc-mode c++-mode
 ;;;;;;  c-mode c-initialize-cc-mode) "cc-mode" "progmodes/cc-mode.el"
-;;;;;;  (15556 56060))
+;;;;;;  (15557 64405))
 ;;; Generated autoloads from progmodes/cc-mode.el
 
 (autoload (quote c-initialize-cc-mode) "cc-mode" nil nil nil)
@@ -2841,7 +2841,7 @@ Key bindings:
 ;;;***
 \f
 ;;;### (autoloads (c-set-offset c-add-style c-set-style) "cc-styles"
-;;;;;;  "progmodes/cc-styles.el" (15556 56060))
+;;;;;;  "progmodes/cc-styles.el" (15557 64405))
 ;;; Generated autoloads from progmodes/cc-styles.el
 
 (autoload (quote c-set-style) "cc-styles" "\
@@ -2882,7 +2882,7 @@ and exists only for compatibility reasons." t nil)
 
 ;;;***
 \f
-;;;### (autoloads nil "cc-vars" "progmodes/cc-vars.el" (15556 56060))
+;;;### (autoloads nil "cc-vars" "progmodes/cc-vars.el" (15557 64405))
 ;;; Generated autoloads from progmodes/cc-vars.el
 
 (defconst c-emacs-features (let ((infodock-p (boundp (quote infodock-version))) (comments (let ((table (copy-syntax-table)) entry) (modify-syntax-entry 97 ". 12345678" table) (cond ((arrayp table) (setq entry (aref table 97)) (if (consp entry) (setq entry (car entry)))) ((fboundp (quote get-char-table)) (setq entry (get-char-table 97 table))) ((and (fboundp (quote char-table-p)) (char-table-p table)) (setq entry (car (char-table-range table [97])))) (t (error "CC Mode is incompatible with this version of Emacs"))) (if (= (logand (lsh entry -16) 255) 255) (quote 8-bit) (quote 1-bit))))) (if infodock-p (list comments (quote infodock)) (list comments))) "\
@@ -4198,7 +4198,7 @@ INHERIT-INPUT-METHOD." nil nil)
 ;;;;;;  customize-face customize-option-other-window customize-changed-options
 ;;;;;;  customize-option customize-group-other-window customize-group
 ;;;;;;  customize customize-save-variable customize-set-variable
-;;;;;;  customize-set-value) "cus-edit" "cus-edit.el" (15552 23095))
+;;;;;;  customize-set-value) "cus-edit" "cus-edit.el" (15561 31158))
 ;;; Generated autoloads from cus-edit.el
  (add-hook 'same-window-regexps "\\`\\*Customiz.*\\*\\'")
 
@@ -4284,10 +4284,16 @@ Show the buffer in another window, but don't select it." t nil)
 
 (autoload (quote customize-face) "cus-edit" "\
 Customize SYMBOL, which should be a face name or nil.
-If SYMBOL is nil, customize all faces." t nil)
+If SYMBOL is nil, customize all faces.
+
+Interactively, when point is on text which has a face specified,
+suggest to customized that face, if it's customizable." t nil)
 
 (autoload (quote customize-face-other-window) "cus-edit" "\
-Show customization buffer for face SYMBOL in other window." t nil)
+Show customization buffer for face SYMBOL in other window.
+
+Interactively, when point is on text which has a face specified,
+suggest to customized that face, if it's customizable." t nil)
 
 (autoload (quote customize-customized) "cus-edit" "\
 Customize all user options set since the last save in this session." t nil)
@@ -4840,7 +4846,7 @@ to provide correct modes for autoloaded files." nil nil)
 ;;;***
 \f
 ;;;### (autoloads (diary-mail-entries diary) "diary-lib" "calendar/diary-lib.el"
-;;;;;;  (15556 56042))
+;;;;;;  (15557 64393))
 ;;; Generated autoloads from calendar/diary-lib.el
 
 (autoload (quote diary) "diary-lib" "\
@@ -4918,7 +4924,7 @@ Minor mode for viewing/editing context diffs.
 ;;;;;;  dired dired-copy-preserve-time dired-dwim-target dired-keep-marker-symlink
 ;;;;;;  dired-keep-marker-hardlink dired-keep-marker-copy dired-keep-marker-rename
 ;;;;;;  dired-trivial-filenames dired-ls-F-marks-symlinks dired-listing-switches)
-;;;;;;  "dired" "dired.el" (15556 56031))
+;;;;;;  "dired" "dired.el" (15557 64385))
 ;;; Generated autoloads from dired.el
 
 (defvar dired-listing-switches "-al" "\
@@ -5505,8 +5511,8 @@ CSS contains a list of syntax specifications of the form (CHAR . SYNTAX)." nil (
 ;;;***
 \f
 ;;;### (autoloads (easy-menu-change easy-menu-create-menu easy-menu-do-define
-;;;;;;  easy-menu-define) "easymenu" "emacs-lisp/easymenu.el" (15400
-;;;;;;  1475))
+;;;;;;  easy-menu-define) "easymenu" "emacs-lisp/easymenu.el" (15561
+;;;;;;  31234))
 ;;; Generated autoloads from emacs-lisp/easymenu.el
 
 (put (quote easy-menu-define) (quote lisp-indent-function) (quote defun))
@@ -6073,6 +6079,20 @@ With optional NODE, goes to that node." t nil)
 
 ;;;***
 \f
+;;;### (autoloads (ediff-cond-compile-for-xemacs-or-emacs) "ediff-hook"
+;;;;;;  "ediff-hook.el" (15561 31164))
+;;; Generated autoloads from ediff-hook.el
+
+(defvar ediff-window-setup-function)
+
+(autoload (quote ediff-cond-compile-for-xemacs-or-emacs) "ediff-hook" nil nil (quote macro))
+
+(ediff-cond-compile-for-xemacs-or-emacs (defun ediff-xemacs-init-menus nil (if (featurep (quote menubar)) (progn (add-submenu (quote ("Tools")) ediff-menu "OO-Browser...") (add-submenu (quote ("Tools")) ediff-merge-menu "OO-Browser...") (add-submenu (quote ("Tools")) epatch-menu "OO-Browser...") (add-submenu (quote ("Tools")) ediff-misc-menu "OO-Browser...") (add-menu-button (quote ("Tools")) "-------" "OO-Browser...")))) nil)
+
+(ediff-cond-compile-for-xemacs-or-emacs (progn (defvar ediff-menu (quote ("Compare" ["Two Files..." ediff-files t] ["Two Buffers..." ediff-buffers t] ["Three Files..." ediff-files3 t] ["Three Buffers..." ediff-buffers3 t] "---" ["Two Directories..." ediff-directories t] ["Three Directories..." ediff-directories3 t] "---" ["File with Revision..." ediff-revision t] ["Directory Revisions..." ediff-directory-revisions t] "---" ["Windows Word-by-word..." ediff-windows-wordwise t] ["Windows Line-by-line..." ediff-windows-linewise t] "---" ["Regions Word-by-word..." ediff-regions-wordwise t] ["Regions Line-by-line..." ediff-regions-linewise t]))) (defvar ediff-merge-menu (quote ("Merge" ["Files..." ediff-merge-files t] ["Files with Ancestor..." ediff-merge-files-with-ancestor t] ["Buffers..." ediff-merge-buffers t] ["Buffers with Ancestor..." ediff-merge-buffers-with-ancestor t] "---" ["Directories..." ediff-merge-directories t] ["Directories with Ancestor..." ediff-merge-directories-with-ancestor t] "---" ["Revisions..." ediff-merge-revisions t] ["Revisions with Ancestor..." ediff-merge-revisions-with-ancestor t] ["Directory Revisions..." ediff-merge-directory-revisions t] ["Directory Revisions with Ancestor..." ediff-merge-directory-revisions-with-ancestor t]))) (defvar epatch-menu (quote ("Apply Patch" ["To a file..." ediff-patch-file t] ["To a buffer..." ediff-patch-buffer t]))) (defvar ediff-misc-menu (quote ("Ediff Miscellanea" ["Ediff Manual..." ediff-documentation t] ["Customize Ediff..." ediff-customize t] ["List Ediff Sessions..." ediff-show-registry t] ["Use separate frame for Ediff control buffer..." ediff-toggle-multiframe :style toggle :selected (if (and (featurep (quote ediff-util)) (boundp (quote ediff-window-setup-function))) (eq ediff-window-setup-function (quote ediff-setup-windows-multiframe)))] ["Use a toolbar with Ediff control buffer" ediff-toggle-use-toolbar :style toggle :selected (if (featurep (quote ediff-tbar)) (ediff-use-toolbar-p))]))) (if (and (featurep (quote menubar)) (not (featurep (quote infodock))) (not (featurep (quote ediff-hook)))) (ediff-xemacs-init-menus))) (if (featurep (quote menu-bar)) (progn (defvar menu-bar-ediff-misc-menu (make-sparse-keymap "Ediff Miscellanea")) (fset (quote menu-bar-ediff-misc-menu) (symbol-value (quote menu-bar-ediff-misc-menu))) (defvar menu-bar-epatch-menu (make-sparse-keymap "Apply Patch")) (fset (quote menu-bar-epatch-menu) (symbol-value (quote menu-bar-epatch-menu))) (defvar menu-bar-ediff-merge-menu (make-sparse-keymap "Merge")) (fset (quote menu-bar-ediff-merge-menu) (symbol-value (quote menu-bar-ediff-merge-menu))) (defvar menu-bar-ediff-menu (make-sparse-keymap "Compare")) (fset (quote menu-bar-ediff-menu) (symbol-value (quote menu-bar-ediff-menu))) (define-key menu-bar-ediff-menu [window] (quote ("This Window and Next Window" . compare-windows))) (define-key menu-bar-ediff-menu [ediff-windows-linewise] (quote ("Windows Line-by-line..." . ediff-windows-linewise))) (define-key menu-bar-ediff-menu [ediff-windows-wordwise] (quote ("Windows Word-by-word..." . ediff-windows-wordwise))) (define-key menu-bar-ediff-menu [separator-ediff-windows] (quote ("--"))) (define-key menu-bar-ediff-menu [ediff-regions-linewise] (quote ("Regions Line-by-line..." . ediff-regions-linewise))) (define-key menu-bar-ediff-menu [ediff-regions-wordwise] (quote ("Regions Word-by-word..." . ediff-regions-wordwise))) (define-key menu-bar-ediff-menu [separator-ediff-regions] (quote ("--"))) (define-key menu-bar-ediff-menu [ediff-dir-revision] (quote ("Directory Revisions..." . ediff-directory-revisions))) (define-key menu-bar-ediff-menu [ediff-revision] (quote ("File with Revision..." . ediff-revision))) (define-key menu-bar-ediff-menu [separator-ediff-directories] (quote ("--"))) (define-key menu-bar-ediff-menu [ediff-directories3] (quote ("Three Directories..." . ediff-directories3))) (define-key menu-bar-ediff-menu [ediff-directories] (quote ("Two Directories..." . ediff-directories))) (define-key menu-bar-ediff-menu [separator-ediff-files] (quote ("--"))) (define-key menu-bar-ediff-menu [ediff-buffers3] (quote ("Three Buffers..." . ediff-buffers3))) (define-key menu-bar-ediff-menu [ediff-files3] (quote ("Three Files..." . ediff-files3))) (define-key menu-bar-ediff-menu [ediff-buffers] (quote ("Two Buffers..." . ediff-buffers))) (define-key menu-bar-ediff-menu [ediff-files] (quote ("Two Files..." . ediff-files))) (define-key menu-bar-ediff-merge-menu [ediff-merge-dir-revisions-with-ancestor] (quote ("Directory Revisions with Ancestor..." . ediff-merge-directory-revisions-with-ancestor))) (define-key menu-bar-ediff-merge-menu [ediff-merge-dir-revisions] (quote ("Directory Revisions..." . ediff-merge-directory-revisions))) (define-key menu-bar-ediff-merge-menu [ediff-merge-revisions-with-ancestor] (quote ("Revisions with Ancestor..." . ediff-merge-revisions-with-ancestor))) (define-key menu-bar-ediff-merge-menu [ediff-merge-revisions] (quote ("Revisions..." . ediff-merge-revisions))) (define-key menu-bar-ediff-merge-menu [separator-ediff-merge] (quote ("--"))) (define-key menu-bar-ediff-merge-menu [ediff-merge-directories-with-ancestor] (quote ("Directories with Ancestor..." . ediff-merge-directories-with-ancestor))) (define-key menu-bar-ediff-merge-menu [ediff-merge-directories] (quote ("Directories..." . ediff-merge-directories))) (define-key menu-bar-ediff-merge-menu [separator-ediff-merge-dirs] (quote ("--"))) (define-key menu-bar-ediff-merge-menu [ediff-merge-buffers-with-ancestor] (quote ("Buffers with Ancestor..." . ediff-merge-buffers-with-ancestor))) (define-key menu-bar-ediff-merge-menu [ediff-merge-buffers] (quote ("Buffers..." . ediff-merge-buffers))) (define-key menu-bar-ediff-merge-menu [ediff-merge-files-with-ancestor] (quote ("Files with Ancestor..." . ediff-merge-files-with-ancestor))) (define-key menu-bar-ediff-merge-menu [ediff-merge-files] (quote ("Files..." . ediff-merge-files))) (define-key menu-bar-epatch-menu [ediff-patch-buffer] (quote ("To a Buffer..." . ediff-patch-buffer))) (define-key menu-bar-epatch-menu [ediff-patch-file] (quote ("To a File..." . ediff-patch-file))) (define-key menu-bar-ediff-misc-menu [emultiframe] (quote ("Toggle use of separate control buffer frame..." . ediff-toggle-multiframe))) (define-key menu-bar-ediff-misc-menu [eregistry] (quote ("List Ediff Sessions..." . ediff-show-registry))) (define-key menu-bar-ediff-misc-menu [ediff-cust] (quote ("Customize Ediff..." . ediff-customize))) (define-key menu-bar-ediff-misc-menu [ediff-doc] (quote ("Ediff Manual..." . ediff-documentation))))))
+
+;;;***
+\f
 ;;;### (autoloads (ediff-show-registry) "ediff-mult" "ediff-mult.el"
 ;;;;;;  (15517 64421))
 ;;; Generated autoloads from ediff-mult.el
@@ -6988,15 +7008,15 @@ This is used only in conjunction with `expand-add-abbrevs'." t nil)
 
 ;;;***
 \f
-;;;### (autoloads (f90-mode) "f90" "progmodes/f90.el" (15552 23097))
+;;;### (autoloads (f90-mode) "f90" "progmodes/f90.el" (15561 31347))
 ;;; Generated autoloads from progmodes/f90.el
 
 (autoload (quote f90-mode) "f90" "\
-Major mode for editing Fortran 90 code in free format.
+Major mode for editing Fortran 90,95 code in free format.
 
 \\[f90-indent-new-line] corrects current indentation and creates new indented line.
-\\[f90-indent-line] indents the current line correctly. 
-\\[f90-indent-subprogram] indents the current subprogram. 
+\\[f90-indent-line] indents the current line correctly.
+\\[f90-indent-subprogram] indents the current subprogram.
 
 Type `? or `\\[help-command] to display a list of built-in abbrevs for F90 keywords.
 
@@ -7005,46 +7025,44 @@ Key definitions:
 
 Variables controlling indentation style and extra features:
 
- f90-do-indent
+ `f90-do-indent'
     Extra indentation within do blocks.  (default 3)
- f90-if-indent
-    Extra indentation within if/select case/where/forall blocks. (default 3)
- f90-type-indent
+ `f90-if-indent'
+    Extra indentation within if/select case/where/forall blocks.  (default 3)
+ `f90-type-indent'
     Extra indentation within type/interface/block-data blocks.  (default 3)
- f90-program-indent
+ `f90-program-indent'
     Extra indentation within program/module/subroutine/function blocks.
-      (default 2)
- f90-continuation-indent
+    (default 2)
+ `f90-continuation-indent'
     Extra indentation applied to continuation lines.  (default 5)
- f90-comment-region
+ `f90-comment-region'
     String inserted by \\[f90-comment-region] at start of each line in 
     region.  (default \"!!!$\")
- f90-indented-comment-re
+ `f90-indented-comment-re'
     Regexp determining the type of comment to be intended like code.
     (default \"!\")
- f90-directive-comment-re
+ `f90-directive-comment-re'
     Regexp of comment-like directive like \"!HPF\\\\$\", not to be indented.
     (default \"!hpf\\\\$\")
- f90-break-delimiters
+ `f90-break-delimiters'
     Regexp holding list of delimiters at which lines may be broken.
     (default \"[-+*/><=,% \\t]\")
- f90-break-before-delimiters
+ `f90-break-before-delimiters'
     Non-nil causes `f90-do-auto-fill' to break lines before delimiters.
     (default t)
- f90-beginning-ampersand 
+ `f90-beginning-ampersand'
     Automatic insertion of & at beginning of continuation lines. (default t)
- f90-smart-end 
+ `f90-smart-end'
     From an END statement, check and fill the end using matching block start.
     Allowed values are 'blink, 'no-blink, and nil, which determine
-    whether to blink the matching beginning.) (default 'blink)
- f90-auto-keyword-case
-    Automatic change of case of keywords. (default nil)
+    whether to blink the matching beginning.  (default 'blink)
+ `f90-auto-keyword-case'
+    Automatic change of case of keywords.  (default nil)
     The possibilities are 'downcase-word, 'upcase-word, 'capitalize-word.
- f90-leave-line-no
-    Do not left-justify line numbers. (default nil)
- f90-startup-message
-    Set to nil to inhibit message first time F90 mode is used. (default t)
- f90-keywords-re
+ `f90-leave-line-no'
+    Do not left-justify line numbers.  (default nil)
+ `f90-keywords-re'
     List of keywords used for highlighting/upcase-keywords etc.
 
 Turning on F90 mode calls the value of the variable `f90-mode-hook'
@@ -7056,7 +7074,7 @@ with no args, if that value is non-nil." t nil)
 ;;;;;;  facemenu-remove-special facemenu-remove-all facemenu-remove-face-props
 ;;;;;;  facemenu-set-read-only facemenu-set-intangible facemenu-set-invisible
 ;;;;;;  facemenu-set-face-from-menu facemenu-set-background facemenu-set-foreground
-;;;;;;  facemenu-set-face) "facemenu" "facemenu.el" (15552 23095))
+;;;;;;  facemenu-set-face) "facemenu" "facemenu.el" (15557 64385))
 ;;; Generated autoloads from facemenu.el
  (define-key global-map "\M-g" 'facemenu-keymap)
  (autoload 'facemenu-keymap "facemenu" "Keymap for face-changing commands." t 'keymap)
@@ -7338,7 +7356,7 @@ the name is considered already unique; only the second substitution
 ;;;***
 \f
 ;;;### (autoloads (find-grep-dired find-name-dired find-dired find-grep-options
-;;;;;;  find-ls-option) "find-dired" "find-dired.el" (15505 59086))
+;;;;;;  find-ls-option) "find-dired" "find-dired.el" (15561 31174))
 ;;; Generated autoloads from find-dired.el
 
 (defvar find-ls-option (if (eq system-type (quote berkeley-unix)) (quote ("-ls" . "-gilsb")) (quote ("-exec ls -ld {} \\;" . "-ld"))) "\
@@ -7381,7 +7399,7 @@ Thus ARG can also contain additional grep options." t nil)
 \f
 ;;;### (autoloads (ff-mouse-find-other-file-other-window ff-mouse-find-other-file
 ;;;;;;  ff-find-other-file ff-get-other-file) "find-file" "find-file.el"
-;;;;;;  (15400 1472))
+;;;;;;  (15561 31174))
 ;;; Generated autoloads from find-file.el
 
 (autoload (quote ff-get-other-file) "find-file" "\
@@ -7913,7 +7931,7 @@ Visit a file in Forms mode in other window." t nil)
 ;;;***
 \f
 ;;;### (autoloads (fortran-mode fortran-tab-mode-default) "fortran"
-;;;;;;  "progmodes/fortran.el" (15555 1627))
+;;;;;;  "progmodes/fortran.el" (15557 64405))
 ;;; Generated autoloads from progmodes/fortran.el
 
 (defvar fortran-tab-mode-default nil "\
@@ -8999,7 +9017,7 @@ Key bindings:
 ;;;### (autoloads (global-highlight-changes highlight-compare-with-file
 ;;;;;;  highlight-changes-rotate-faces highlight-changes-previous-change
 ;;;;;;  highlight-changes-next-change highlight-changes-mode highlight-changes-remove-highlight)
-;;;;;;  "hilit-chg" "hilit-chg.el" (15556 56033))
+;;;;;;  "hilit-chg" "hilit-chg.el" (15557 64386))
 ;;; Generated autoloads from hilit-chg.el
 
 (defvar highlight-changes-mode nil)
@@ -9236,12 +9254,15 @@ Also see `automatic-hscrolling'." t nil)
 ;;;;;;  ibuffer-add-saved-filters ibuffer-delete-saved-filters ibuffer-save-filters
 ;;;;;;  ibuffer-or-filter ibuffer-negate-filter ibuffer-exchange-filters
 ;;;;;;  ibuffer-decompose-filter ibuffer-pop-filter ibuffer-filter-disable
-;;;;;;  ibuffer-jump-to-filter-group ibuffer-pop-filter-group ibuffer-filters-to-filter-group
-;;;;;;  ibuffer-included-in-filters-p ibuffer-backward-filter-group
-;;;;;;  ibuffer-forward-filter-group ibuffer-toggle-filter-group
-;;;;;;  ibuffer-mouse-toggle-filter-group ibuffer-interactive-filter-by-mode
-;;;;;;  ibuffer-mouse-filter-by-mode ibuffer-auto-mode) "ibuf-ext"
-;;;;;;  "ibuf-ext.el" (15559 5574))
+;;;;;;  ibuffer-switch-to-saved-filter-groups ibuffer-delete-saved-filter-groups
+;;;;;;  ibuffer-save-filter-groups ibuffer-yank ibuffer-kill-line
+;;;;;;  ibuffer-kill-filter-group ibuffer-jump-to-filter-group ibuffer-clear-filter-groups
+;;;;;;  ibuffer-pop-filter-group ibuffer-set-filter-groups-by-mode
+;;;;;;  ibuffer-filters-to-filter-group ibuffer-included-in-filters-p
+;;;;;;  ibuffer-backward-filter-group ibuffer-forward-filter-group
+;;;;;;  ibuffer-toggle-filter-group ibuffer-mouse-toggle-filter-group
+;;;;;;  ibuffer-interactive-filter-by-mode ibuffer-mouse-filter-by-mode
+;;;;;;  ibuffer-auto-mode) "ibuf-ext" "ibuf-ext.el" (15561 31179))
 ;;; Generated autoloads from ibuf-ext.el
 
 (autoload (quote ibuffer-auto-mode) "ibuf-ext" "\
@@ -9282,12 +9303,40 @@ Move point backwards by COUNT filtering groups." t nil)
 (autoload (quote ibuffer-filters-to-filter-group) "ibuf-ext" "\
 Make the current filters into a filtering group." t nil)
 
+(autoload (quote ibuffer-set-filter-groups-by-mode) "ibuf-ext" "\
+Set the current filter groups to filter by mode." t nil)
+
 (autoload (quote ibuffer-pop-filter-group) "ibuf-ext" "\
 Remove the first filtering group." t nil)
 
+(autoload (quote ibuffer-clear-filter-groups) "ibuf-ext" "\
+Remove all filtering groups." t nil)
+
 (autoload (quote ibuffer-jump-to-filter-group) "ibuf-ext" "\
 Move point to the filter group whose name is NAME." t nil)
 
+(autoload (quote ibuffer-kill-filter-group) "ibuf-ext" "\
+Delete the filtering group named NAME." t nil)
+
+(autoload (quote ibuffer-kill-line) "ibuf-ext" nil t nil)
+
+(autoload (quote ibuffer-yank) "ibuf-ext" nil t nil)
+
+(autoload (quote ibuffer-save-filter-groups) "ibuf-ext" "\
+Save all active filter groups GROUPS as NAME.
+They are added to `ibuffer-saved-filter-groups'.  Interactively,
+prompt for NAME, and use the current filters." t nil)
+
+(autoload (quote ibuffer-delete-saved-filter-groups) "ibuf-ext" "\
+Delete saved filter groups with NAME.
+They are removed from `ibuffer-saved-filter-groups'." t nil)
+
+(autoload (quote ibuffer-switch-to-saved-filter-groups) "ibuf-ext" "\
+Set this buffer's filter groups to saved version with NAME.
+The value from `ibuffer-saved-filters' is used.
+If prefix argument ADD is non-nil, then add the saved filters instead
+of replacing the current filters." t nil)
+
 (autoload (quote ibuffer-filter-disable) "ibuf-ext" "\
 Disable all filters currently in effect in this buffer." t nil)
 
@@ -9442,8 +9491,8 @@ defaults to one." t nil)
 ;;;***
 \f
 ;;;### (autoloads (define-ibuffer-filter define-ibuffer-op define-ibuffer-sorter
-;;;;;;  define-ibuffer-column) "ibuf-macs" "ibuf-macs.el" (15559
-;;;;;;  4758))
+;;;;;;  define-ibuffer-column) "ibuf-macs" "ibuf-macs.el" (15561
+;;;;;;  31179))
 ;;; Generated autoloads from ibuf-macs.el
 
 (autoload (quote define-ibuffer-column) "ibuf-macs" "\
@@ -9519,7 +9568,7 @@ bound to the current value of the filter." nil (quote macro))
 ;;;***
 \f
 ;;;### (autoloads (ibuffer ibuffer-other-window ibuffer-list-buffers)
-;;;;;;  "ibuffer" "ibuffer.el" (15559 12617))
+;;;;;;  "ibuffer" "ibuffer.el" (15561 31180))
 ;;; Generated autoloads from ibuffer.el
 
 (autoload (quote ibuffer-list-buffers) "ibuffer" "\
@@ -9545,7 +9594,7 @@ Optional argument NOSELECT means don't select the Ibuffer buffer.
 Optional argument SHRINK means shrink the buffer to minimal size.  The
 special value `onewindow' means always use another window.
 Optional argument FILTER-GROUPS is an initial set of filtering
-groups to use; see `ibuffer-filtering-groups'." t nil)
+groups to use; see `ibuffer-filter-groups'." t nil)
 
 ;;;***
 \f
@@ -11371,7 +11420,7 @@ If 4th arg LIST is non-nil, return a list of all such fields." nil nil)
 ;;;***
 \f
 ;;;### (autoloads (define-mail-abbrev build-mail-abbrevs mail-abbrevs-setup)
-;;;;;;  "mailabbrev" "mail/mailabbrev.el" (15552 23097))
+;;;;;;  "mailabbrev" "mail/mailabbrev.el" (15557 64401))
 ;;; Generated autoloads from mail/mailabbrev.el
 
 (autoload (quote mail-abbrevs-setup) "mailabbrev" "\
@@ -12077,7 +12126,7 @@ different buffer menu using the function `msb'." t nil)
 ;;;;;;  describe-current-coding-system describe-current-coding-system-briefly
 ;;;;;;  describe-coding-system describe-char-after describe-character-set
 ;;;;;;  list-charset-chars read-charset list-character-sets) "mule-diag"
-;;;;;;  "international/mule-diag.el" (15556 56053))
+;;;;;;  "international/mule-diag.el" (15557 64400))
 ;;; Generated autoloads from international/mule-diag.el
 
 (autoload (quote list-character-sets) "mule-diag" "\
@@ -13950,8 +13999,8 @@ were operated on recently." t nil)
 ;;;### (autoloads (clear-rectangle string-insert-rectangle string-rectangle
 ;;;;;;  delete-whitespace-rectangle open-rectangle insert-rectangle
 ;;;;;;  yank-rectangle kill-rectangle extract-rectangle delete-extract-rectangle
-;;;;;;  delete-rectangle move-to-column-force) "rect" "rect.el" (15552
-;;;;;;  23097))
+;;;;;;  delete-rectangle move-to-column-force) "rect" "rect.el" (15557
+;;;;;;  64391))
 ;;; Generated autoloads from rect.el
 
 (autoload (quote move-to-column-force) "rect" "\
@@ -15233,7 +15282,7 @@ Interesting variables:
 ;;;***
 \f
 ;;;### (autoloads (scroll-all-mode scroll-all-mode) "scroll-all"
-;;;;;;  "scroll-all.el" (15559 7260))
+;;;;;;  "scroll-all.el" (15561 31204))
 ;;; Generated autoloads from scroll-all.el
 
 (defvar scroll-all-mode nil "\
@@ -15256,7 +15305,7 @@ Toggle Scroll-All minor mode." t nil)
 ;;;;;;  mail-archive-file-name mail-header-separator send-mail-function
 ;;;;;;  mail-yank-ignored-headers mail-interactive mail-self-blind
 ;;;;;;  mail-specify-envelope-from mail-from-style) "sendmail" "mail/sendmail.el"
-;;;;;;  (15505 59088))
+;;;;;;  (15561 31320))
 ;;; Generated autoloads from mail/sendmail.el
 
 (defvar mail-from-style (quote angles) "\
@@ -15871,7 +15920,7 @@ which smileys to operate on and which images to use for them." t nil)
 ;;;***
 \f
 ;;;### (autoloads (smtpmail-send-it) "smtpmail" "mail/smtpmail.el"
-;;;;;;  (15417 7425))
+;;;;;;  (15561 31320))
 ;;; Generated autoloads from mail/smtpmail.el
 
 (autoload (quote smtpmail-send-it) "smtpmail" nil nil nil)
@@ -17695,7 +17744,7 @@ To get complete usage, invoke \"emacs -batch -f batch-titdic-convert -h\"." nil
 ;;;***
 \f
 ;;;### (autoloads (tmm-prompt tmm-menubar-mouse tmm-menubar) "tmm"
-;;;;;;  "tmm.el" (15556 56039))
+;;;;;;  "tmm.el" (15557 64393))
 ;;; Generated autoloads from tmm.el
  (define-key global-map "\M-`" 'tmm-menubar)
  (define-key global-map [f10] 'tmm-menubar)
@@ -17775,7 +17824,7 @@ Show TODO list." t nil)
 \f
 ;;;### (autoloads (tool-bar-local-item-from-menu tool-bar-add-item-from-menu
 ;;;;;;  tool-bar-local-item tool-bar-add-item tool-bar-mode) "tool-bar"
-;;;;;;  "toolbar/tool-bar.el" (15552 23097))
+;;;;;;  "toolbar/tool-bar.el" (15557 64408))
 ;;; Generated autoloads from toolbar/tool-bar.el
 
 (defvar tool-bar-mode nil "\
@@ -19532,7 +19581,8 @@ Zone-mode does two things:
 
 ;;;***
 \f
-;;;### (autoloads nil nil ("international/mule-cmds.el" "eshell/esh-ext.el"
+;;;### (autoloads nil nil ("term/x-win.el" "progmodes/cc-cmds.el"
+;;;;;;  "replace.el" "menu-bar.el" "international/mule-cmds.el" "eshell/esh-ext.el"
 ;;;;;;  "emulation/viper-ex.el" "calc/calc-bin.el" "loadup.el" "frame.el"
 ;;;;;;  "faces.el" "ediff-init.el" "bindings.el" "international/mule-conf.el"
 ;;;;;;  "calendar/cal-french.el" "textmodes/texnfo-upd.el" "language/slovak.el"
@@ -19545,21 +19595,21 @@ Zone-mode does two things:
 ;;;;;;  "eshell/em-glob.el" "eshell/em-dirs.el" "eshell/em-cmpl.el"
 ;;;;;;  "eshell/em-alias.el" "emacs-lisp/lisp.el" "mail/uce.el" "gnus/mm-encode.el"
 ;;;;;;  "tempo.el" "emulation/viper-util.el" "gnus/mml.el" "gnus/mm-view.el"
-;;;;;;  "calendar/cal-menu.el" "indent.el" "ediff-wind.el" "ediff-hook.el"
-;;;;;;  "term/sun-mouse.el" "emacs-lisp/lisp-mode.el" "progmodes/mantemp.el"
-;;;;;;  "progmodes/idlw-toolbar.el" "progmodes/ebnf-yac.el" "progmodes/ebnf-otz.el"
-;;;;;;  "progmodes/ebnf-iso.el" "progmodes/ebnf-bnf.el" "play/meese.el"
-;;;;;;  "play/gametree.el" "obsolete/x-menu.el" "obsolete/x-apollo.el"
-;;;;;;  "obsolete/uncompress.el" "obsolete/sun-fns.el" "obsolete/sun-curs.el"
-;;;;;;  "obsolete/sc.el" "obsolete/rnews.el" "obsolete/profile.el"
-;;;;;;  "obsolete/ooutline.el" "obsolete/c-mode.el" "mail/vms-pmail.el"
-;;;;;;  "mail/rfc822.el" "mail/rfc2368.el" "mail/mspools.el" "mail/mh-seq.el"
-;;;;;;  "mail/mh-funcs.el" "mail/mailpost.el" "mail/mailheader.el"
-;;;;;;  "mail/blessmail.el" "language/romanian.el" "language/misc-lang.el"
-;;;;;;  "language/ethiopic.el" "language/english.el" "language/devanagari.el"
-;;;;;;  "international/swedish.el" "international/latin-9.el" "international/latin-8.el"
-;;;;;;  "international/latin-5.el" "international/latin-4.el" "international/latin-3.el"
-;;;;;;  "international/latin-2.el" "international/latin-1.el" "international/ja-dic-utl.el"
+;;;;;;  "calendar/cal-menu.el" "indent.el" "ediff-wind.el" "term/sun-mouse.el"
+;;;;;;  "emacs-lisp/lisp-mode.el" "progmodes/mantemp.el" "progmodes/idlw-toolbar.el"
+;;;;;;  "progmodes/ebnf-yac.el" "progmodes/ebnf-otz.el" "progmodes/ebnf-iso.el"
+;;;;;;  "progmodes/ebnf-bnf.el" "play/meese.el" "play/gametree.el"
+;;;;;;  "obsolete/x-menu.el" "obsolete/x-apollo.el" "obsolete/uncompress.el"
+;;;;;;  "obsolete/sun-fns.el" "obsolete/sun-curs.el" "obsolete/sc.el"
+;;;;;;  "obsolete/rnews.el" "obsolete/profile.el" "obsolete/ooutline.el"
+;;;;;;  "obsolete/c-mode.el" "mail/vms-pmail.el" "mail/rfc822.el"
+;;;;;;  "mail/rfc2368.el" "mail/mspools.el" "mail/mh-seq.el" "mail/mh-funcs.el"
+;;;;;;  "mail/mailpost.el" "mail/mailheader.el" "mail/blessmail.el"
+;;;;;;  "language/romanian.el" "language/misc-lang.el" "language/ethiopic.el"
+;;;;;;  "language/english.el" "language/devanagari.el" "international/swedish.el"
+;;;;;;  "international/latin-9.el" "international/latin-8.el" "international/latin-5.el"
+;;;;;;  "international/latin-4.el" "international/latin-3.el" "international/latin-2.el"
+;;;;;;  "international/latin-1.el" "international/ja-dic-utl.el"
 ;;;;;;  "international/ja-dic-cnv.el" "international/iso-swed.el"
 ;;;;;;  "international/iso-ascii.el" "calc/calcsel2.el" "calc/calccomp.el"
 ;;;;;;  "calc/calc-yank.el" "calc/calc-vec.el" "calc/calc-units.el"
@@ -19639,19 +19689,18 @@ Zone-mode does two things:
 ;;;;;;  "calc/calc-graph.el" "ediff-diff.el" "ediff-ptch.el" "pcvs-parse.el"
 ;;;;;;  "gnus/mail-source.el" "gnus/mm-decode.el" "gnus/mm-util.el"
 ;;;;;;  "gnus/nneething.el" "international/ucs-tables.el" "allout.el"
-;;;;;;  "cus-load.el" "cus-start.el" "finder-inf.el" "format.el"
-;;;;;;  "help.el" "isearch.el" "mouse.el" "pcvs-info.el" "window.el"
-;;;;;;  "calc/calc-misc.el" "gnus/gnus-ems.el" "gnus/gnus-sum.el"
-;;;;;;  "gnus/gnus-uu.el" "gnus/nnimap.el" "gnus/nnmbox.el" "gnus/nnwarchive.el"
-;;;;;;  "gnus/pop3.el" "calendar/cal-tex.el" "emacs-lisp/byte-opt.el"
-;;;;;;  "emacs-lisp/lucid.el" "international/utf-8.el" "progmodes/ada-prj.el"
-;;;;;;  "progmodes/idlw-rinfo.el" "textmodes/fill.el" "custom.el"
-;;;;;;  "files.el" "menu-bar.el" "register.el" "replace.el" "simple.el"
-;;;;;;  "startup.el" "subr.el" "net/netrc.el" "play/gamegrid.el"
-;;;;;;  "progmodes/cc-align.el" "progmodes/cc-bytecomp.el" "progmodes/cc-cmds.el"
-;;;;;;  "progmodes/cc-compat.el" "progmodes/cc-defs.el" "progmodes/cc-engine.el"
-;;;;;;  "progmodes/cc-menus.el" "term/x-win.el" "subdirs.el" "eshell/esh-groups.el")
-;;;;;;  (15559 13260 596690))
+;;;;;;  "cus-start.el" "format.el" "help.el" "isearch.el" "mouse.el"
+;;;;;;  "pcvs-info.el" "window.el" "calc/calc-misc.el" "gnus/gnus-ems.el"
+;;;;;;  "gnus/gnus-sum.el" "gnus/gnus-uu.el" "gnus/nnimap.el" "gnus/nnmbox.el"
+;;;;;;  "gnus/nnwarchive.el" "gnus/pop3.el" "calendar/cal-tex.el"
+;;;;;;  "emacs-lisp/byte-opt.el" "emacs-lisp/lucid.el" "international/utf-8.el"
+;;;;;;  "progmodes/ada-prj.el" "progmodes/idlw-rinfo.el" "textmodes/fill.el"
+;;;;;;  "custom.el" "files.el" "register.el" "simple.el" "startup.el"
+;;;;;;  "subr.el" "net/netrc.el" "play/gamegrid.el" "progmodes/cc-align.el"
+;;;;;;  "progmodes/cc-bytecomp.el" "progmodes/cc-compat.el" "progmodes/cc-defs.el"
+;;;;;;  "progmodes/cc-engine.el" "progmodes/cc-menus.el" "cus-load.el"
+;;;;;;  "finder-inf.el" "subdirs.el" "eshell/esh-groups.el") (15561
+;;;;;;  41889 615042))
 
 ;;;***
 \f
index 48c210d..53f6cde 100644 (file)
@@ -2,7 +2,7 @@
 
 ;; Copyright (C) 1999, 2000 Free Software Foundation, Inc.
 
-;; Author: Andrew Choi <akochoi@i-cable.com>
+;; Author: Andrew Choi <akochoi@mac.com>
 
 ;; This file is part of GNU Emacs.
 
 ;; X Window emulation in macterm.c is not complete enough to start a
 ;; frame without a minibuffer properly.  Call this to tell ediff
 ;; library to use a single frame.
-(ediff-toggle-multiframe)
+(ediff-toggle-multiframe)
 
 ;; Setup to use the Mac clipboard.  The functions mac-cut-function and
 ;; mac-paste-function are defined in mac.c.
@@ -215,6 +215,16 @@ ascii:-*-Monaco-*-*-*-*-12-*-*-*-*-*-mac-roman")
 ;; big5 or sjis
 (setq file-name-coding-system 'mac-roman)
 
+;; If Emacs is started from the Finder, change the default directory
+;; to the user's home directory.
+(if (string= default-directory "/")
+    (cd "~"))
+
+;; Tell Emacs to use pipes instead of pty's for processes because the
+;; latter sometimes lose characters.  Pty support is compiled in since
+;; ange-ftp will not work without it.
+(setq process-connection-type nil)
+
 ;; (prefer-coding-system 'mac-roman)
 
 ;;
index bcae176..186a856 100644 (file)
@@ -1,3 +1,136 @@
+2002-04-13  Andrew Choi  <akochoi@shaw.ca>
+
+       * Emacs.app/Contents/Info.plist: New file.
+
+       * Emacs.app/Contents/PkgInfo: New file.
+
+       * Emacs.app/Contents/Resources/English.lproj/InfoPlist.strings:
+       New file.
+
+       * cw5-mcp.xml: Remove file.
+
+       * inc/defs-cw5.h: Remove file.
+
+       * cw6-mcp.xml: Update with new version.
+
+       * mac/inc/defs-cw6.h: New constant MAC_OS8.  Remove definition
+       of constant CODEWARRIOR_VERSION_6.
+
+       * mac/src/mac.c:
+       * mac/src/macmenu.c:
+       * mac/src/macterm.c:
+       Test constant __MSL__ instead of CODEWARRIOR_VERSION_6.
+
+       * src/Carbon.r: New File.
+
+       * makefile.MPW: Define MAC_OS and MAC_OS8.  Update with change of
+       locations for mac.c, macfns.c, macgui.h, macmenu.c, macterm.c, and
+       macterm.h.  Generate DOC from .el instead of .elc versions of
+       files listed in DONTCOMPILE in lisp/Makefile.in.
+       
+       * INSTALL: Add installation instructions for Mac OS X.
+
+       * README: Add information for Mac OS X.
+
+       * src/mac.c, inc/macgui.h, src/macfns.c, src/macmenu.c,
+       src/macterm.c, inc/macterm.h: Remove from here and move to src.
+
+2002-04-12  Andrew Choi  <akochoi@shaw.ca>
+
+       * src/mac.c (select): Under Carbon, always return true so
+       XTread_socket is called to poll input.
+       (run_mac_command): Not implemented under Carbon.
+       (get_wd): Call PBHGetVolSync and path_from_vol_dir_name to
+       establish pathname.
+       (do_applescript): Use Carbon routines AEGetDescDatASize and
+       AEGetDescData.
+       (Fmac_paste_function): Use Carbon routines GetCurrentScrap,
+       GetScrapFlavorFlags, GetScrapFlavorSize, and GetScrapFlavorData.
+       (Fmac_cut_function): Use Carbon routines ClearCurrentScrap,
+       GetCurrentScrap, and PutScrapFlavor.
+       (Fx_selection_exists_p): Use Carbon routines GetCurrentScrap and
+       GetScrapFlavorFlags.
+
+       * src/macfns.c: Synchronize with changes in w32fns.c.
+       [MAC_OSX]: Include Carbon headers.
+       (x_real_positions): Use Carbon routine GetWindowPortBounds.
+       (x_set_scroll_bar_width): Set width of scroll bar to 16.
+       (x_make_gc): Remove static qualifier.
+
+       * src/macmenu.c: Synchronize with changes in w32menu.c.
+       [MAC_OSX]: Include Carbon headers.
+       (set_frame_menubar): Check equality of vector representation of
+       scroll bars using Fequal instead of EQ.
+       (mac_menu_show): Use Carbon routine GetWindowPort.
+       (mac_dialog): Likewise.
+       (add_menu_item): Use Carbon routines CountMenuItems,
+       EnableMenuItem, and DisableMenuItem.
+
+       * src/macterm.c: Synchronize with changes in w32term.c.
+       [MAC_OSX]: Include Carbon headers.
+       (XDrawLine): Use Carbon routine GetWindowPort.
+       (XClearArea): Likewise.
+       (XClearWindow): Use Carbon routines GetWindowPort and
+       GetWindowPortBounds.
+       (mac_draw_bitmap): Use Carbon routines GetWindowPort and
+       GetPortPixMap.
+       (mac_set_clip_rectangle): Use Carbon routine GetWindowPort.
+       (mac_reset_clipping): Use Carbon routine GetWindowPort.
+       (XFillRectangle): Likewise.
+       (mac_draw_rectangle): Likewise.
+       (mac_draw_rectangle_to_pixmap): Likewise.
+       (mac_draw_string_common): Likewise.
+       (mac_copy_area): Use Carbon routines GetWindowPort and
+       GetPortPixMap.
+       (mac_scroll_area): Use Carbon routines GetWindowPort and
+       GetQDGlobalsScreenBits.
+       (x_flush): Call Carbon routine QDFlushPortBuffer.
+       (x_update_end): Use Carbon routine GetWindowPort; call x_flush.
+       (x_draw_fringe_bitmap): Call mac_reset_clipping before returning.
+       (x_draw_image_glyph_string): Likewise.
+       (x_draw_stretch_glyph_string): Likewise.
+       (construct_mouse_click): Call Carbon routine GetWindowPort.
+       (note_mouse_movement): Call Carbon routine GetWindowPortBounds.
+       (XTmouse_position): Call Carbon routine GetWindowPort.
+       (x_scroll_bar_create): Create scroll bar with proc
+       kControlScrollBarProc.
+       (XTset_vertical_scroll_bar) [MAC_OSX]: Set width to 16.
+       (activate_scroll_bar): Call ActivateControl instead of
+       SetControlMaximum.
+       (deactivate_scroll_bar): Call DeactivateControl instead of
+       SetControlMaximum.
+       (x_scroll_bar_handle_click): Use default case for scroll
+       indicator.
+       (x_scroll_bar_report_motion): Call Carbon routine GetWindowPort.
+       (x_calc_absolute_position): Call Carbon routines GetWindowPort and
+       GetWindowPortBounds.
+       (init_font_name_table): Call Carbon Font Manager routines to
+       iterate through all fonts.
+       (XLoadQueryFont): Call Carbon routines GetPortTextFont,
+       GetPortTextSize, and GetPortTextFace.
+       (do_init_managers): Do not initialize Mac Toolbox under Carbon.
+       (is_emacs_window): New function to filter out non-Emacs windows
+       passed back by WaitNextEvent.
+       (do_mouse_moved): Call Carbon routine GetWindowPort.
+       (do_apple_menu): No apple menu handler under Carbon.
+       (do_zoom_window): Call Carbon routines GetWindowPort,
+       GetQDGlobalsScreenBits, SetWindowStandardState, and
+       GetWindowPortBounds.
+       (init_required_apple_events): Use UPP procedure type converter.
+       (main): Don't define for Carbon version.
+       (XTread_socket): Don't check interrupt_input_blocked.  Don't call
+       check_alarm.  Call Carbon routines GetWindowPort,
+       GetQDGlobalScreenBits, GetWindowPortBounds, and InvalWindowRect.
+       (NewMacWindow): Set making_terminal_window to 0.  Call Carbon
+       routine GetWindowPort.
+       (mac_initialize): Rename from x_initialize.  Use new Doc string
+       format.
+
+       * inc/macterm.h: Synchronize with changes in w32term.h.
+
+       * inc/macgui.h [MAC_OSX]: Use OpaqueWindowPtr* instead of
+       WindowPtr.
+
 2002-01-28  Kim F. Storm  <storm@cua.dk>
 
        * src/macterm.c (x_erase_phys_cursor): Don't erase cursor if
diff --git a/mac/Emacs.app/Contents/Info.plist b/mac/Emacs.app/Contents/Info.plist
new file mode 100644 (file)
index 0000000..4d51100
--- /dev/null
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
+<plist version="0.9">
+<dict>
+       <key>CFBundleDevelopmentRegion</key>
+       <string>English</string>
+       <key>CFBundleExecutable</key>
+       <string>Emacs</string>
+       <key>CFBundleInfoDictionaryVersion</key>
+       <string>6.0</string>
+       <key>CFBundlePackageType</key>
+       <string>APPL</string>
+       <key>CFBundleSignature</key>
+       <string>????</string>
+       <key>CFBundleVersion</key>
+       <string>0.1</string>
+</dict>
+</plist>
diff --git a/mac/Emacs.app/Contents/PkgInfo b/mac/Emacs.app/Contents/PkgInfo
new file mode 100644 (file)
index 0000000..bd04210
--- /dev/null
@@ -0,0 +1 @@
+APPL????
\ No newline at end of file
diff --git a/mac/Emacs.app/Contents/Resources/Emacs.rsrc b/mac/Emacs.app/Contents/Resources/Emacs.rsrc
new file mode 100644 (file)
index 0000000..1a017ac
Binary files /dev/null and b/mac/Emacs.app/Contents/Resources/Emacs.rsrc differ
diff --git a/mac/Emacs.app/Contents/Resources/English.lproj/InfoPlist.strings b/mac/Emacs.app/Contents/Resources/English.lproj/InfoPlist.strings
new file mode 100644 (file)
index 0000000..b111726
--- /dev/null
@@ -0,0 +1,5 @@
+/* Localized versions of Info.plist keys */
+
+CFBundleName = "Emacs";
+CFBundleShortVersionString = "Emacs version 21";
+CFBundleGetInfoString = "Emacs version 21, Copyright 2002 FSF.";
index ae2916b..13c127c 100644 (file)
@@ -1,6 +1,6 @@
-* BUILDING EMACS ON THE MAC OS     -*- outline -*-
+* BUILDING EMACS ON MAC OS 8/9 AND MAC OS X     -*- outline -*-
 
-Copyright (c) 2001 Free Software Foundation, Inc.
+Copyright (c) 2001, 2002 Free Software Foundation, Inc.
 
    Permission is granted to anyone to make or distribute verbatim
    copies of this document as received, in any medium, provided that
@@ -13,37 +13,123 @@ Copyright (c) 2001 Free Software Foundation, Inc.
    provided also that they carry prominent notices stating who last
    changed them.
 
-You can use either Metrowerks CodeWarrior Pro 5 or 6 or MPW-GM
-(Aug. 2000) to build Emacs.
+* BUILDING EMACS ON MAC OS X
 
-You will need MPW-GM to build the make-docfile utility and to generate
-the doc string file DOC.
+You should be able to build Emacs on Mac OS X by typing the following
+commands at the top-level directory after the source distribution is
+un-tarred.
 
-To decompress files, you can use MacGzip from
+  ./configure
+  make
+  make install
 
-  http://persephone.cps.unizar.es/~spd/gzip
+The last step must be performed as root.
 
-and to untar them, you can use tar 4.0 from
+If you have X Window installed, you need to type `./configure
+--without-x' instead of `./configure'.
 
-  http://hyperarchive.lcs.mit.edu/HyperArchive/Archive/cmp/tar-40b.hqx
+You can type `make bootstrap' instead of `make' to rebuild everything,
+including byte-compiling the Lisp files.
 
-(Optional) If you wish to fetch files from the Emacs CVS repository
-directly to your Mac, you can use the CVS client MacCVS, which can be
-downloaded from
+If you have not installed the GNU texinfo package on your system, the
+build will complain that makeinfo cannot be found.  Instructions for
+installing the GNU texinfo package are given below.  Alternatively,
+you can type `make -k' instead of `make' and safely ignore the error
+messages and use the existing info files.
 
-  http://www.wincvs.org/
+After Emacs is installed, you can run it by typing `emacs -nw' from a
+terminal (make sure your path contains /usr/local/bin) or by
+double-clicking on mac/Emacs.app in the Finder.  At present,
+command-line options cannot be passed to Emacs running under the Aqua
+GUI.  This should soon be fixed.
 
-(Optional) A subset of the fonts from the GNU intlfonts-1.2
-distribution converted to NFNT format can be obtained from
+To use colors in a terminal, put the following lines in the file
+~/.termcap and log in again.
 
-  ftp://mac-emacs.sourceforge.net/pub/mac-emacs/GNU-fonts.smi.bin
+-----
+# added ANSI color
+vt100|vt100-am|vt100am|dec vt100:\
+    :pa#64:Co#8:Sf=\E[3%dm:Sb=\E[4%dm:op=\E[m:AF=\E[3%dm:AB=\E[4%dm:\
+    :do=^J:co#80:li#24:cl=\E[;H\E[2J:sf=2*\ED:\
+    :le=^H:bs:am:cm=5\E[%i%d;%dH:nd=2\E[C:up=2\E[A:\
+    :ce=3\E[K:cd=50\E[J:so=2\E[7m:se=2\E[m:us=2\E[4m:ue=2\E[m:\
+    :md=2\E[1m:mr=2\E[7m:mb=2\E[5m:me=2\E[m:\
+    :rf=/usr/share/tabset/vt100:\
+    :rs=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h\E[;r\E[0m\E(B\E)B\E[2J:\
+    :ks=\E[?1h\E=:ke=\E[?1l\E>:\
+    :ku=\EOA:kd=\EOB:kr=\EOC:kl=\EOD:kb=^H:\
+    :ho=\E[H:k1=\EOP:k2=\EOQ:k3=\EOR:k4=\EOS:pt:sr=2*\EM:vt#3:xn:\
+    :sc=\E7:rc=\E8:cs=\E[%i%d;%dr:
+-----
+
+To build a binary distribution of Emacs for Mac OS X, run the shell
+script make-bin-dist in the `mac' directory.  This will create a file
+emacs-21.xx.yy-mac-bin.tar.gz.
+
+To install the binary distribution, untar the file and run the shell
+script osx-install in its top-level directory.
+
+To build the `info' files, you need to install the texinfo software.
+
+To install from source, obtain texinfo-4.2.tar.gz from ftp.gnu.org or
+a mirror.  Un-tar it, enter its directory and type
+
+  ./configure
+  make
+  make install
+
+The last step needs to be performed as root.
+
+You may also like to install ispell, which will allow you to use
+ispell and flyspell-mode.  To install ispell from source, you first
+need to install GNU textutils.
+
+To do so, download textutils-2.0.tar.gz from ftp.gnu.org or a mirror.
+Un-tar it, enter its directory, type
+
+  ./configure --host=powerpc-apple-bsd
+  make
+  make install
+    
+Again, the last step needs to be performed as root.  Note that if you
+run `make check', the test for `pr' will fail.
+
+Get and un-tar ispell-3.2.06.tar.gz.  Look for it here:
+
+  http://fmg-www.cs.ucla.edu/geoff/ispell.html
+
+Go into its directory, type
 
-### IMPORTANT ### If you use StuffIf Expander to decompress and untar
-the distribution, you *must* set the radio button in the
+  cp local.h.samp local.h
+
+Add a line `#define TERMLIB ""' to the end of local.h.
+
+Set the environment variable TMPDIR to an existing directory.  For
+example since `/tmp' exists on my machine and I am using `bash', I
+typed
+
+  export TMPDIR=/tmp
+
+Run `make' and `make install', the latter as root.
+
+
+* BUILDING EMACS ON MAC OS 8/9
+
+You can use either Metrowerks CodeWarrior Pro 6 or MPW-GM (Aug. 2001)
+to build Emacs.  MPW-GM can be downloaded free of charge from Apple.
+
+In either case, you will need MPW-GM to build the make-docfile utility
+and to generate the doc string file DOC.
+
+### IMPORTANT ### You can use StuffIf Expander to decompress and untar
+the distribution.  However, you *must* set the radio button in the
 Preferences->Cross Platform->Convert text files to Macintosh format to
 "Never".  Otherwise the compiled Lisp files will be corrupted.
 
-* BUILDING EMACS
+(Optional) A subset of the fonts from the GNU intlfonts-1.2
+distribution converted to NFNT format can be obtained from
+
+  ftp://mac-emacs.sourceforge.net/pub/mac-emacs/GNU-fonts.smi.bin
 
 To build Emacs in the MPW Shell, simply set the directory to
 ...:emacs:mac: and build the target Emacs of the make file
@@ -53,13 +139,11 @@ makefile.mpw.  I.e., execute the commands
   Emacs.MakeScript
 
 To build Emacs using CodeWarrior, start up the CodeWarrior IDE, choose
-File->Import Project...  and select the file cw5-mcp.xml or
-cw6-mcp.xml, depending on which verison of CodeWarrior used.  When
+File->Import Project...  and select the file cw6-mcp.xml.  When
 prompted to save the project, navigate to same directory as the file
-cw[56]-mcp.xml, name it emacs-cw5.mcp or emacs-cw6.mcp, and save it
-there.  Then choose Project->Make.  Note that this does not build the
-DOC file.  To do so, use MPW and build the target "Doc" in
-makefile.MPW.
+cw6-mcp.xml, name the project emacs-cw6.mcp, and save it there.  Then
+choose Project->Make.  Note that this does not build the DOC file.  To
+do so, use MPW and build the target "Doc" in makefile.MPW.
 
 Once built, the Emacs application (Emacs CW or Emacs MPW) can be
 launched where it is created.
@@ -70,35 +154,29 @@ dialog.  To build a version for profiling, check the Profiler
 Information box in the Emacs Settings->Code Generation->PPC Processor
 dialog and include the Profiler PPC.Lib library.
 
-To build optimized or debugging version of Emacs in MPW, follow the
-comment in makefile.MPW to enable the -opt speed or -sym on option
-(see note below).
-
 * NOTES
 
-Emacs should build and run on a PowerMac running Mac OS 8.1 - 9.0.
+Emacs should build and run on a PowerMac running Mac OS 8.6 - 10.1.
 
 You will need around 100 MB of disk space for the source files and
 intermediate files.
 
-It will not run on machines with more than 256 MB of physical or
-virtual memory.
-
-Currently there is no support for building the LEIM directory on the
-Mac.  However, it can be built on another platform and transferred to
-the Mac.
+It will not run on machines running Mac OS 8/9 with more than 256 MB
+of physical or virtual memory.  It does not have this restriction when
+it is run under Mac OS X.  But the usual 128MB buffer limit of a
+32-bit Emacs still exists.
 
-When Emacs is built with "-opt speed" enabled in makefile.MPW,
-optimization causes the functions reset_buffer_local_variables in
-buffer.c, syms_of_lread in lread.c, and x_draw_hollow_cursor in
-macterm.c to crash.  Avoid this by enclosing them in the following
-pragmas.
+Under Mac OS 8/9, there is no support for building the LEIM directory.
+However, it can be built on Mac OS X or another platform and
+transferred to the Mac.
 
-  #pragma options opt off
+On Mac OS 8/9, to use the same icon as when Emacs is built on Windows
+NT, define GNU_ICON in mac/src/Emacs.r.  Currently Emacs uses a
+generic application icon on the Mac OS X.  A better looking one is
+coming soon.
 
-  <function definition...>
 
-  #pragma options opt reset
+Enjoy!
 
-To use the same icon as when Emacs is built on Windows NT, define
-GNU_ICON in mac/src/Emacs.r.
+Andrew.
+<akochoi@mac.com>
index a1c51f9..8d1a264 100644 (file)
@@ -1,6 +1,6 @@
-GNU Emacs for Mac OS
+Emacs for Mac OS 8/9 and Mac OS X
 
-Copyright (c) 2001 Free Software Foundation, Inc.
+Copyright (c) 2001, 2002 Free Software Foundation, Inc.
 
    Permission is granted to anyone to make or distribute verbatim
    copies of this document as received, in any medium, provided that
@@ -13,8 +13,8 @@ Copyright (c) 2001 Free Software Foundation, Inc.
    provided also that they carry prominent notices stating who last
    changed them.
 
-This directory contains the files needed to build GNU Emacs on the Mac
-OS (8.1-9.0).  Many of the major features of the Unix version are
+This directory contains the files needed to build Emacs on the Mac OS
+8/9 and Mac OS X.  Many of the major features of the Unix version are
 supported: multiple frames, colors, scroll bars, menu bars, use of the
 mouse, fontsets, international characters, input methods, and coding
 systems.
@@ -23,24 +23,42 @@ Mac OS specific support includes document drag-and-drop in the Finder,
 transfer of text to and from other applications via the clipboard, and
 sending AppleScript commands to other applications from Emacs.
 
-The following are not yet supported: unexec (dump-emacs), asynchronous
-subprocesses (start-process), and networking
-(open-network-stream).
+The following are not supported on Mac OS 8/9 : unexec (dump-emacs),
+asynchronous subprocesses (start-process), and networking
+(open-network-stream).  These features work fine on Mac OS X.
 
-There is basic support for synchronous subprocesses (call-process)
-although Unix commands that are used will need to be ported to the
-Mac.
+There is basic support for synchronous subprocesses (call-process) on
+Mac OS 8/9 although Unix commands that are used will need to be
+ported.
 
-Metrowerks CodeWarrior Pro 5 or Pro 6 or MPW-GM (August 2000) can be
-used to build Emacs on the Mac OS.  See the INSTALL file in this
-directory for instructions on building Emacs.
+Metrowerks CodeWarrior Pro 6 or MPW-GM (August 2001) can be used to
+build Emacs on the Mac OS 8/9.  On Mac OS X, Emacs can be built using
+the Developer Tools.  See the INSTALL file in this directory for
+instructions on building Emacs.
 
-Binary distributions are available in
+Binary distributions will be available in
 
   ftp://ftp.gnu.org/gnu/mac/emacs/
 
-At this site you can also find an FAQ related to running GNU Emacs on
-Mac OS.
+Read the Mac OS section of the on-line help to find out about how to
+use Emacs on the Mac.
+
+A number of things do not work yet:
+
++ On Mac OS X, environment variables are not set up correctly when
+  Emacs is started from the Finder.
+
++ Emacs does not respond correctly to C-g when it is not reading
+  input.
+
++ No image support yet.
+
++ There is no mouse-2 and mouse-3 emulation yet.
+
+If your Mac is connected to the Internet, report bugs by typing `M-x
+report-emacs-bug' or by choosing the entry `Send Bug Report...'  in
+the `Help' menu.  This will send the bug report to the address
+emacs-pretest-bug@gnu.org.
 
 Andrew.
-<akochoi@i-cable.com>
+<akochoi@mac.com>
diff --git a/mac/cw5-mcp.xml b/mac/cw5-mcp.xml
deleted file mode 100644 (file)
index 42cb874..0000000
+++ /dev/null
@@ -1,2084 +0,0 @@
-<!--
-Copyright (C) 2001 Free Software Foundation, Inc.
-
-This file is part of GNU Emacs.
-
-GNU Emacs is free software; you can redistribute it and/or modify it
-under the terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option) any
-later version.
-
-GNU Emacs is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Emacs; see the file COPYING.  If not, write to the Free
-Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-02111-1307, USA.
-
-
-Contributed by Andrew Choi (akochoi@i-cable.com).
-
-Exported from the emacs-cw5.mcp project in Metrowerks CodeWarrior Pro
-5 for distribution.  This copyright notice was then added by hand.
-Choose the command File->Import Project... to recreate the
-emacs-cw5.mcp project.
-
--->
-
-<?xml version="1.0"?>
-<?codewarrior exportversion="1.0" ideversion="4.0"?>
-<!DOCTYPE PROJECT [
-
-<!ELEMENT PROJECT (TARGETLIST, TARGETORDER, GROUPLIST, DESIGNLIST?)>
-<!ELEMENT TARGETLIST (TARGET+)>
-<!ELEMENT TARGET (NAME, SETTINGLIST, FILELIST?, LINKORDER?, SEGMENTLIST?, OVERLAYGROUPLIST?, SUBTARGETLIST?, SUBPROJECTLIST?)>
-<!ELEMENT NAME (#PCDATA)>
-<!ELEMENT USERSOURCETREETYPE (#PCDATA)>
-<!ELEMENT PATH (#PCDATA)>
-<!ELEMENT FILELIST (FILE*)>
-<!ELEMENT FILE (PATHTYPE, PATHROOT?, ACCESSPATH?, PATH, PATHFORMAT?, ROOTFILEREF?, FILEKIND?, FILEFLAGS?)>
-<!ELEMENT PATHTYPE (#PCDATA)>
-<!ELEMENT PATHROOT (#PCDATA)>
-<!ELEMENT ACCESSPATH (#PCDATA)>
-<!ELEMENT PATHFORMAT (#PCDATA)>
-<!ELEMENT ROOTFILEREF (PATHTYPE, PATHROOT?, ACCESSPATH?, PATH, PATHFORMAT?)>
-<!ELEMENT FILEKIND (#PCDATA)>
-<!ELEMENT FILEFLAGS (#PCDATA)>
-<!ELEMENT FILEREF (TARGETNAME?, PATHTYPE, PATHROOT?, ACCESSPATH?, PATH, PATHFORMAT?)>
-<!ELEMENT TARGETNAME (#PCDATA)>
-<!ELEMENT SETTINGLIST ((SETTING|PANELDATA)+)>
-<!ELEMENT SETTING (NAME?, (VALUE|(SETTING+)))>
-<!ELEMENT PANELDATA (NAME, VALUE)>
-<!ELEMENT VALUE (#PCDATA)>
-<!ELEMENT LINKORDER (FILEREF*)>
-<!ELEMENT SEGMENTLIST (SEGMENT+)>
-<!ELEMENT SEGMENT (NAME, ATTRIBUTES?, FILEREF*)>
-<!ELEMENT ATTRIBUTES (#PCDATA)>
-<!ELEMENT OVERLAYGROUPLIST (OVERLAYGROUP+)>
-<!ELEMENT OVERLAYGROUP (NAME, BASEADDRESS, OVERLAY*)>
-<!ELEMENT BASEADDRESS (#PCDATA)>
-<!ELEMENT OVERLAY (NAME, FILEREF*)>
-<!ELEMENT SUBTARGETLIST (SUBTARGET+)>
-<!ELEMENT SUBTARGET (TARGETNAME, ATTRIBUTES?)>
-<!ELEMENT SUBPROJECTLIST (SUBPROJECT+)>
-<!ELEMENT SUBPROJECT (FILEREF, SUBPROJECTTARGETLIST)>
-<!ELEMENT SUBPROJECTTARGETLIST (SUBPROJECTTARGET*)>
-<!ELEMENT SUBPROJECTTARGET (TARGETNAME, ATTRIBUTES?)>
-<!ELEMENT TARGETORDER (ORDEREDTARGET|ORDEREDDESIGN)*>
-<!ELEMENT ORDEREDTARGET (NAME)>
-<!ELEMENT ORDEREDDESIGN (NAME, ORDEREDTARGET+)>
-<!ELEMENT GROUPLIST (GROUP|FILEREF)*>
-<!ELEMENT GROUP (NAME, (GROUP|FILEREF)*)>
-<!ELEMENT DESIGNLIST (DESIGN+)>
-<!ELEMENT DESIGN (NAME, DESIGNDATA)>
-<!ELEMENT DESIGNDATA (#PCDATA)>
-]>
-<PROJECT>
-    <TARGETLIST>
-        <TARGET>
-            <NAME>Emacs</NAME>
-            <SETTINGLIST>
-
-                <!-- Settings for "Source Trees" panel -->
-                <SETTING><NAME>UserSourceTrees</NAME><VALUE></VALUE></SETTING>
-
-                <!-- Settings for "Custom Keywords" panel -->
-                <SETTING><NAME>CustomColor1</NAME>
-                    <SETTING><NAME>Red</NAME><VALUE>6168</VALUE></SETTING>
-                    <SETTING><NAME>Green</NAME><VALUE>24672</VALUE></SETTING>
-                    <SETTING><NAME>Blue</NAME><VALUE>23130</VALUE></SETTING>
-                </SETTING>
-                <SETTING><NAME>CustomColor2</NAME>
-                    <SETTING><NAME>Red</NAME><VALUE>0</VALUE></SETTING>
-                    <SETTING><NAME>Green</NAME><VALUE>32767</VALUE></SETTING>
-                    <SETTING><NAME>Blue</NAME><VALUE>0</VALUE></SETTING>
-                </SETTING>
-                <SETTING><NAME>CustomColor3</NAME>
-                    <SETTING><NAME>Red</NAME><VALUE>0</VALUE></SETTING>
-                    <SETTING><NAME>Green</NAME><VALUE>32767</VALUE></SETTING>
-                    <SETTING><NAME>Blue</NAME><VALUE>0</VALUE></SETTING>
-                </SETTING>
-                <SETTING><NAME>CustomColor4</NAME>
-                    <SETTING><NAME>Red</NAME><VALUE>0</VALUE></SETTING>
-                    <SETTING><NAME>Green</NAME><VALUE>32767</VALUE></SETTING>
-                    <SETTING><NAME>Blue</NAME><VALUE>0</VALUE></SETTING>
-                </SETTING>
-                <SETTING><NAME>CustomKeywordList1</NAME><VALUE>DEFUN</VALUE></SETTING>
-
-                <!-- Settings for "Access Paths" panel -->
-                <SETTING><NAME>AlwaysSearchUserPaths</NAME><VALUE>true</VALUE></SETTING>
-                <SETTING><NAME>InterpretDOSAndUnixPaths</NAME><VALUE>true</VALUE></SETTING>
-                <SETTING><NAME>UserSearchPaths</NAME>
-                    <SETTING>
-                        <SETTING><NAME>SearchPath</NAME>
-                            <SETTING><NAME>Path</NAME><VALUE>:inc:</VALUE></SETTING>
-                            <SETTING><NAME>PathFormat</NAME><VALUE>MacOS</VALUE></SETTING>
-                            <SETTING><NAME>PathRoot</NAME><VALUE>Project</VALUE></SETTING>
-                        </SETTING>
-                        <SETTING><NAME>Recursive</NAME><VALUE>true</VALUE></SETTING>
-                        <SETTING><NAME>HostFlags</NAME><VALUE>All</VALUE></SETTING>
-                    </SETTING>
-                    <SETTING>
-                        <SETTING><NAME>SearchPath</NAME>
-                            <SETTING><NAME>Path</NAME><VALUE>:src:</VALUE></SETTING>
-                            <SETTING><NAME>PathFormat</NAME><VALUE>MacOS</VALUE></SETTING>
-                            <SETTING><NAME>PathRoot</NAME><VALUE>Project</VALUE></SETTING>
-                        </SETTING>
-                        <SETTING><NAME>Recursive</NAME><VALUE>true</VALUE></SETTING>
-                        <SETTING><NAME>HostFlags</NAME><VALUE>All</VALUE></SETTING>
-                    </SETTING>
-                    <SETTING>
-                        <SETTING><NAME>SearchPath</NAME>
-                            <SETTING><NAME>Path</NAME><VALUE>::src:</VALUE></SETTING>
-                            <SETTING><NAME>PathFormat</NAME><VALUE>MacOS</VALUE></SETTING>
-                            <SETTING><NAME>PathRoot</NAME><VALUE>Project</VALUE></SETTING>
-                        </SETTING>
-                        <SETTING><NAME>Recursive</NAME><VALUE>true</VALUE></SETTING>
-                        <SETTING><NAME>HostFlags</NAME><VALUE>All</VALUE></SETTING>
-                    </SETTING>
-                </SETTING>
-                <SETTING><NAME>SystemSearchPaths</NAME>
-                    <SETTING>
-                        <SETTING><NAME>SearchPath</NAME>
-                            <SETTING><NAME>Path</NAME><VALUE>:inc:</VALUE></SETTING>
-                            <SETTING><NAME>PathFormat</NAME><VALUE>MacOS</VALUE></SETTING>
-                            <SETTING><NAME>PathRoot</NAME><VALUE>Project</VALUE></SETTING>
-                        </SETTING>
-                        <SETTING><NAME>Recursive</NAME><VALUE>true</VALUE></SETTING>
-                        <SETTING><NAME>HostFlags</NAME><VALUE>All</VALUE></SETTING>
-                    </SETTING>
-                    <SETTING>
-                        <SETTING><NAME>SearchPath</NAME>
-                            <SETTING><NAME>Path</NAME><VALUE>:</VALUE></SETTING>
-                            <SETTING><NAME>PathFormat</NAME><VALUE>MacOS</VALUE></SETTING>
-                            <SETTING><NAME>PathRoot</NAME><VALUE>CodeWarrior</VALUE></SETTING>
-                        </SETTING>
-                        <SETTING><NAME>Recursive</NAME><VALUE>true</VALUE></SETTING>
-                        <SETTING><NAME>HostFlags</NAME><VALUE>All</VALUE></SETTING>
-                    </SETTING>
-                </SETTING>
-
-                <!-- Settings for "Target Settings" panel -->
-                <SETTING><NAME>Linker</NAME><VALUE>MacOS PPC Linker</VALUE></SETTING>
-                <SETTING><NAME>PreLinker</NAME><VALUE></VALUE></SETTING>
-                <SETTING><NAME>PostLinker</NAME><VALUE></VALUE></SETTING>
-                <SETTING><NAME>Targetname</NAME><VALUE>Emacs</VALUE></SETTING>
-                <SETTING><NAME>OutputDirectory</NAME>
-                    <SETTING><NAME>Path</NAME><VALUE>:</VALUE></SETTING>
-                    <SETTING><NAME>PathFormat</NAME><VALUE>MacOS</VALUE></SETTING>
-                    <SETTING><NAME>PathRoot</NAME><VALUE>Project</VALUE></SETTING>
-                </SETTING>
-                <SETTING><NAME>SaveEntriesUsingRelativePaths</NAME><VALUE>false</VALUE></SETTING>
-
-                <!-- Settings for "File Mappings" panel -->
-                <SETTING><NAME>FileMappings</NAME>
-                    <SETTING>
-                        <SETTING><NAME>FileType</NAME><VALUE>APPL</VALUE></SETTING>
-                        <SETTING><NAME>FileExtension</NAME><VALUE></VALUE></SETTING>
-                        <SETTING><NAME>Compiler</NAME><VALUE></VALUE></SETTING>
-                        <SETTING><NAME>Precompile</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>Launchable</NAME><VALUE>true</VALUE></SETTING>
-                        <SETTING><NAME>ResourceFile</NAME><VALUE>true</VALUE></SETTING>
-                        <SETTING><NAME>IgnoredByMake</NAME><VALUE>false</VALUE></SETTING>
-                    </SETTING>
-                    <SETTING>
-                        <SETTING><NAME>FileType</NAME><VALUE>Appl</VALUE></SETTING>
-                        <SETTING><NAME>FileExtension</NAME><VALUE></VALUE></SETTING>
-                        <SETTING><NAME>Compiler</NAME><VALUE></VALUE></SETTING>
-                        <SETTING><NAME>Precompile</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>Launchable</NAME><VALUE>true</VALUE></SETTING>
-                        <SETTING><NAME>ResourceFile</NAME><VALUE>true</VALUE></SETTING>
-                        <SETTING><NAME>IgnoredByMake</NAME><VALUE>false</VALUE></SETTING>
-                    </SETTING>
-                    <SETTING>
-                        <SETTING><NAME>FileType</NAME><VALUE>MMLB</VALUE></SETTING>
-                        <SETTING><NAME>FileExtension</NAME><VALUE></VALUE></SETTING>
-                        <SETTING><NAME>Compiler</NAME><VALUE>Lib Import PPC</VALUE></SETTING>
-                        <SETTING><NAME>Precompile</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>Launchable</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>ResourceFile</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>IgnoredByMake</NAME><VALUE>false</VALUE></SETTING>
-                    </SETTING>
-                    <SETTING>
-                        <SETTING><NAME>FileType</NAME><VALUE>MPLF</VALUE></SETTING>
-                        <SETTING><NAME>FileExtension</NAME><VALUE></VALUE></SETTING>
-                        <SETTING><NAME>Compiler</NAME><VALUE>Lib Import PPC</VALUE></SETTING>
-                        <SETTING><NAME>Precompile</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>Launchable</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>ResourceFile</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>IgnoredByMake</NAME><VALUE>false</VALUE></SETTING>
-                    </SETTING>
-                    <SETTING>
-                        <SETTING><NAME>FileType</NAME><VALUE>MWCD</VALUE></SETTING>
-                        <SETTING><NAME>FileExtension</NAME><VALUE></VALUE></SETTING>
-                        <SETTING><NAME>Compiler</NAME><VALUE></VALUE></SETTING>
-                        <SETTING><NAME>Precompile</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>Launchable</NAME><VALUE>true</VALUE></SETTING>
-                        <SETTING><NAME>ResourceFile</NAME><VALUE>true</VALUE></SETTING>
-                        <SETTING><NAME>IgnoredByMake</NAME><VALUE>false</VALUE></SETTING>
-                    </SETTING>
-                    <SETTING>
-                        <SETTING><NAME>FileType</NAME><VALUE>RSRC</VALUE></SETTING>
-                        <SETTING><NAME>FileExtension</NAME><VALUE></VALUE></SETTING>
-                        <SETTING><NAME>Compiler</NAME><VALUE></VALUE></SETTING>
-                        <SETTING><NAME>Precompile</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>Launchable</NAME><VALUE>true</VALUE></SETTING>
-                        <SETTING><NAME>ResourceFile</NAME><VALUE>true</VALUE></SETTING>
-                        <SETTING><NAME>IgnoredByMake</NAME><VALUE>false</VALUE></SETTING>
-                    </SETTING>
-                    <SETTING>
-                        <SETTING><NAME>FileType</NAME><VALUE>TEXT</VALUE></SETTING>
-                        <SETTING><NAME>FileExtension</NAME><VALUE>.bh</VALUE></SETTING>
-                        <SETTING><NAME>Compiler</NAME><VALUE>Balloon Help</VALUE></SETTING>
-                        <SETTING><NAME>Precompile</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>Launchable</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>ResourceFile</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>IgnoredByMake</NAME><VALUE>false</VALUE></SETTING>
-                    </SETTING>
-                    <SETTING>
-                        <SETTING><NAME>FileType</NAME><VALUE>TEXT</VALUE></SETTING>
-                        <SETTING><NAME>FileExtension</NAME><VALUE>.c</VALUE></SETTING>
-                        <SETTING><NAME>Compiler</NAME><VALUE>MW C/C++ PPC</VALUE></SETTING>
-                        <SETTING><NAME>Precompile</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>Launchable</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>ResourceFile</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>IgnoredByMake</NAME><VALUE>false</VALUE></SETTING>
-                    </SETTING>
-                    <SETTING>
-                        <SETTING><NAME>FileType</NAME><VALUE>TEXT</VALUE></SETTING>
-                        <SETTING><NAME>FileExtension</NAME><VALUE>.c++</VALUE></SETTING>
-                        <SETTING><NAME>Compiler</NAME><VALUE>MW C/C++ PPC</VALUE></SETTING>
-                        <SETTING><NAME>Precompile</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>Launchable</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>ResourceFile</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>IgnoredByMake</NAME><VALUE>false</VALUE></SETTING>
-                    </SETTING>
-                    <SETTING>
-                        <SETTING><NAME>FileType</NAME><VALUE>TEXT</VALUE></SETTING>
-                        <SETTING><NAME>FileExtension</NAME><VALUE>.cc</VALUE></SETTING>
-                        <SETTING><NAME>Compiler</NAME><VALUE>MW C/C++ PPC</VALUE></SETTING>
-                        <SETTING><NAME>Precompile</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>Launchable</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>ResourceFile</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>IgnoredByMake</NAME><VALUE>false</VALUE></SETTING>
-                    </SETTING>
-                    <SETTING>
-                        <SETTING><NAME>FileType</NAME><VALUE>TEXT</VALUE></SETTING>
-                        <SETTING><NAME>FileExtension</NAME><VALUE>.cp</VALUE></SETTING>
-                        <SETTING><NAME>Compiler</NAME><VALUE>MW C/C++ PPC</VALUE></SETTING>
-                        <SETTING><NAME>Precompile</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>Launchable</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>ResourceFile</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>IgnoredByMake</NAME><VALUE>false</VALUE></SETTING>
-                    </SETTING>
-                    <SETTING>
-                        <SETTING><NAME>FileType</NAME><VALUE>TEXT</VALUE></SETTING>
-                        <SETTING><NAME>FileExtension</NAME><VALUE>.cpp</VALUE></SETTING>
-                        <SETTING><NAME>Compiler</NAME><VALUE>MW C/C++ PPC</VALUE></SETTING>
-                        <SETTING><NAME>Precompile</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>Launchable</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>ResourceFile</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>IgnoredByMake</NAME><VALUE>false</VALUE></SETTING>
-                    </SETTING>
-                    <SETTING>
-                        <SETTING><NAME>FileType</NAME><VALUE>TEXT</VALUE></SETTING>
-                        <SETTING><NAME>FileExtension</NAME><VALUE>.exp</VALUE></SETTING>
-                        <SETTING><NAME>Compiler</NAME><VALUE></VALUE></SETTING>
-                        <SETTING><NAME>Precompile</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>Launchable</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>ResourceFile</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>IgnoredByMake</NAME><VALUE>false</VALUE></SETTING>
-                    </SETTING>
-                    <SETTING>
-                        <SETTING><NAME>FileType</NAME><VALUE>TEXT</VALUE></SETTING>
-                        <SETTING><NAME>FileExtension</NAME><VALUE>.gc</VALUE></SETTING>
-                        <SETTING><NAME>Compiler</NAME><VALUE>GameCode Converter</VALUE></SETTING>
-                        <SETTING><NAME>Precompile</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>Launchable</NAME><VALUE>true</VALUE></SETTING>
-                        <SETTING><NAME>ResourceFile</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>IgnoredByMake</NAME><VALUE>false</VALUE></SETTING>
-                    </SETTING>
-                    <SETTING>
-                        <SETTING><NAME>FileType</NAME><VALUE>TEXT</VALUE></SETTING>
-                        <SETTING><NAME>FileExtension</NAME><VALUE>.h</VALUE></SETTING>
-                        <SETTING><NAME>Compiler</NAME><VALUE>MW C/C++ PPC</VALUE></SETTING>
-                        <SETTING><NAME>Precompile</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>Launchable</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>ResourceFile</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>IgnoredByMake</NAME><VALUE>true</VALUE></SETTING>
-                    </SETTING>
-                    <SETTING>
-                        <SETTING><NAME>FileType</NAME><VALUE>TEXT</VALUE></SETTING>
-                        <SETTING><NAME>FileExtension</NAME><VALUE>.l</VALUE></SETTING>
-                        <SETTING><NAME>Compiler</NAME><VALUE>Flex Preprocessor</VALUE></SETTING>
-                        <SETTING><NAME>Precompile</NAME><VALUE>true</VALUE></SETTING>
-                        <SETTING><NAME>Launchable</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>ResourceFile</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>IgnoredByMake</NAME><VALUE>false</VALUE></SETTING>
-                    </SETTING>
-                    <SETTING>
-                        <SETTING><NAME>FileType</NAME><VALUE>TEXT</VALUE></SETTING>
-                        <SETTING><NAME>FileExtension</NAME><VALUE>.p</VALUE></SETTING>
-                        <SETTING><NAME>Compiler</NAME><VALUE>MW Pascal PPC</VALUE></SETTING>
-                        <SETTING><NAME>Precompile</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>Launchable</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>ResourceFile</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>IgnoredByMake</NAME><VALUE>false</VALUE></SETTING>
-                    </SETTING>
-                    <SETTING>
-                        <SETTING><NAME>FileType</NAME><VALUE>TEXT</VALUE></SETTING>
-                        <SETTING><NAME>FileExtension</NAME><VALUE>.pas</VALUE></SETTING>
-                        <SETTING><NAME>Compiler</NAME><VALUE>MW Pascal PPC</VALUE></SETTING>
-                        <SETTING><NAME>Precompile</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>Launchable</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>ResourceFile</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>IgnoredByMake</NAME><VALUE>false</VALUE></SETTING>
-                    </SETTING>
-                    <SETTING>
-                        <SETTING><NAME>FileType</NAME><VALUE>TEXT</VALUE></SETTING>
-                        <SETTING><NAME>FileExtension</NAME><VALUE>.pch</VALUE></SETTING>
-                        <SETTING><NAME>Compiler</NAME><VALUE>MW C/C++ PPC</VALUE></SETTING>
-                        <SETTING><NAME>Precompile</NAME><VALUE>true</VALUE></SETTING>
-                        <SETTING><NAME>Launchable</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>ResourceFile</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>IgnoredByMake</NAME><VALUE>false</VALUE></SETTING>
-                    </SETTING>
-                    <SETTING>
-                        <SETTING><NAME>FileType</NAME><VALUE>TEXT</VALUE></SETTING>
-                        <SETTING><NAME>FileExtension</NAME><VALUE>.pch++</VALUE></SETTING>
-                        <SETTING><NAME>Compiler</NAME><VALUE>MW C/C++ PPC</VALUE></SETTING>
-                        <SETTING><NAME>Precompile</NAME><VALUE>true</VALUE></SETTING>
-                        <SETTING><NAME>Launchable</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>ResourceFile</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>IgnoredByMake</NAME><VALUE>false</VALUE></SETTING>
-                    </SETTING>
-                    <SETTING>
-                        <SETTING><NAME>FileType</NAME><VALUE>TEXT</VALUE></SETTING>
-                        <SETTING><NAME>FileExtension</NAME><VALUE>.ppu</VALUE></SETTING>
-                        <SETTING><NAME>Compiler</NAME><VALUE>MW Pascal PPC</VALUE></SETTING>
-                        <SETTING><NAME>Precompile</NAME><VALUE>true</VALUE></SETTING>
-                        <SETTING><NAME>Launchable</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>ResourceFile</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>IgnoredByMake</NAME><VALUE>false</VALUE></SETTING>
-                    </SETTING>
-                    <SETTING>
-                        <SETTING><NAME>FileType</NAME><VALUE>TEXT</VALUE></SETTING>
-                        <SETTING><NAME>FileExtension</NAME><VALUE>.r</VALUE></SETTING>
-                        <SETTING><NAME>Compiler</NAME><VALUE>Rez</VALUE></SETTING>
-                        <SETTING><NAME>Precompile</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>Launchable</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>ResourceFile</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>IgnoredByMake</NAME><VALUE>false</VALUE></SETTING>
-                    </SETTING>
-                    <SETTING>
-                        <SETTING><NAME>FileType</NAME><VALUE>TEXT</VALUE></SETTING>
-                        <SETTING><NAME>FileExtension</NAME><VALUE>.s</VALUE></SETTING>
-                        <SETTING><NAME>Compiler</NAME><VALUE>PPCAsm</VALUE></SETTING>
-                        <SETTING><NAME>Precompile</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>Launchable</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>ResourceFile</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>IgnoredByMake</NAME><VALUE>false</VALUE></SETTING>
-                    </SETTING>
-                    <SETTING>
-                        <SETTING><NAME>FileType</NAME><VALUE>TEXT</VALUE></SETTING>
-                        <SETTING><NAME>FileExtension</NAME><VALUE>.y</VALUE></SETTING>
-                        <SETTING><NAME>Compiler</NAME><VALUE>Bison Preprocessor</VALUE></SETTING>
-                        <SETTING><NAME>Precompile</NAME><VALUE>true</VALUE></SETTING>
-                        <SETTING><NAME>Launchable</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>ResourceFile</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>IgnoredByMake</NAME><VALUE>false</VALUE></SETTING>
-                    </SETTING>
-                    <SETTING>
-                        <SETTING><NAME>FileType</NAME><VALUE>XCOF</VALUE></SETTING>
-                        <SETTING><NAME>FileExtension</NAME><VALUE></VALUE></SETTING>
-                        <SETTING><NAME>Compiler</NAME><VALUE>XCOFF Import PPC</VALUE></SETTING>
-                        <SETTING><NAME>Precompile</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>Launchable</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>ResourceFile</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>IgnoredByMake</NAME><VALUE>false</VALUE></SETTING>
-                    </SETTING>
-                    <SETTING>
-                        <SETTING><NAME>FileType</NAME><VALUE>docu</VALUE></SETTING>
-                        <SETTING><NAME>FileExtension</NAME><VALUE></VALUE></SETTING>
-                        <SETTING><NAME>Compiler</NAME><VALUE></VALUE></SETTING>
-                        <SETTING><NAME>Precompile</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>Launchable</NAME><VALUE>true</VALUE></SETTING>
-                        <SETTING><NAME>ResourceFile</NAME><VALUE>true</VALUE></SETTING>
-                        <SETTING><NAME>IgnoredByMake</NAME><VALUE>false</VALUE></SETTING>
-                    </SETTING>
-                    <SETTING>
-                        <SETTING><NAME>FileType</NAME><VALUE>rsrc</VALUE></SETTING>
-                        <SETTING><NAME>FileExtension</NAME><VALUE></VALUE></SETTING>
-                        <SETTING><NAME>Compiler</NAME><VALUE></VALUE></SETTING>
-                        <SETTING><NAME>Precompile</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>Launchable</NAME><VALUE>true</VALUE></SETTING>
-                        <SETTING><NAME>ResourceFile</NAME><VALUE>true</VALUE></SETTING>
-                        <SETTING><NAME>IgnoredByMake</NAME><VALUE>false</VALUE></SETTING>
-                    </SETTING>
-                    <SETTING>
-                        <SETTING><NAME>FileType</NAME><VALUE>shlb</VALUE></SETTING>
-                        <SETTING><NAME>FileExtension</NAME><VALUE></VALUE></SETTING>
-                        <SETTING><NAME>Compiler</NAME><VALUE>PEF Import PPC</VALUE></SETTING>
-                        <SETTING><NAME>Precompile</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>Launchable</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>ResourceFile</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>IgnoredByMake</NAME><VALUE>false</VALUE></SETTING>
-                    </SETTING>
-                    <SETTING>
-                        <SETTING><NAME>FileType</NAME><VALUE>stub</VALUE></SETTING>
-                        <SETTING><NAME>FileExtension</NAME><VALUE></VALUE></SETTING>
-                        <SETTING><NAME>Compiler</NAME><VALUE>PEF Import PPC</VALUE></SETTING>
-                        <SETTING><NAME>Precompile</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>Launchable</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>ResourceFile</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>IgnoredByMake</NAME><VALUE>false</VALUE></SETTING>
-                    </SETTING>
-                    <SETTING>
-                        <SETTING><NAME>FileExtension</NAME><VALUE>.doc</VALUE></SETTING>
-                        <SETTING><NAME>Compiler</NAME><VALUE></VALUE></SETTING>
-                        <SETTING><NAME>Precompile</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>Launchable</NAME><VALUE>true</VALUE></SETTING>
-                        <SETTING><NAME>ResourceFile</NAME><VALUE>false</VALUE></SETTING>
-                        <SETTING><NAME>IgnoredByMake</NAME><VALUE>true</VALUE></SETTING>
-                    </SETTING>
-                </SETTING>
-
-                <!-- Settings for "Build Extras" panel -->
-                <SETTING><NAME>CacheModDates</NAME><VALUE>true</VALUE></SETTING>
-                <SETTING><NAME>ActivateBrowser</NAME><VALUE>true</VALUE></SETTING>
-                <SETTING><NAME>DumpBrowserInfo</NAME><VALUE>false</VALUE></SETTING>
-                <SETTING><NAME>CacheSubprojects</NAME><VALUE>true</VALUE></SETTING>
-                <SETTING><NAME>UseThirdPartyDebugger</NAME><VALUE>false</VALUE></SETTING>
-                <SETTING><NAME>DebuggerCommandLine</NAME><VALUE></VALUE></SETTING>
-                <PANELDATA><NAME>Debugger Runtime</NAME><VALUE>
-                    0002000000000000000000000000000000000000000000000000000000000000
-                    0000000000000000000000000000000000000000000000000000000000000000
-                    0000000000000000000000000000000000000000000000000000000000000000
-                    0000000000000000000000000000000000000000000000000000000000000000
-                    0000000000000000000000000000000000000000000000000000000000000000
-                    0000000000000000000000000000000000000000000000000000000000000000
-                    0000000000000000000000000000000000000000000000000000000000000000
-                    0000000000000000000000000000000000000000000000000000000000000000
-                    0000000000000000000000000000000000000000000000000000000000000000
-                    0000000000000000000000000000000000000000000000000000000000000000
-                    0000000000000000000000000000000000000000000000000000000000000000
-                    0000000000000000000000000000000000000000000000000000000000000000
-                    0000000000000000000000000000000000000000000000000000000000000000
-                    0000000000000000000000000000000000000000000000000000000000000000
-                    0000000000000000000000000000000000000000000000000000000000000000
-                    0000000000000000000000000000000000000000000000000000000000000000
-                    0000000000000000000000000000000000000000000000000000000000000000
-                    0000000000000000000000000000000000000000000000000000000000000000
-                    0000000000000000000000000000000000000000000000000000000000000000
-                    0000000000000000000000000000000000000000000000000000000000000000
-                    0000000000000000000000000000000000000000000000000000000000000000
-                    0000000000000000000000000000000000000000000000000000000000000000
-                    0000000000000000000000000000000000000000000000000000000000000000
-                    0000000000000000000000000000000000000000000000000000000000000000
-                    0000000000000000000000000000000000000000000000000000000000000000
-                    0000000000000000000000000000000000000000000000000000000000000000
-                    0000000000000000000000000000000000000000000000000000000000000000
-                    0000000000000000000000000000000000000000000000000000000000000000
-                    0000000000000000000000000000000000000000000000000000000000000000
-                    0000000000000000000000000000000000000000000000000000000000000000
-                    0000000000000000000000000000000000000000000000000000000000000000
-                    0000000000000000000000000000000000000000000000000000000000000000
-                    0000000000000000000000000000000006315C40000000000000010006316550
-                    000200000000000000000000063153E000000000000000000000000000000000
-                    0000000000000000000000000000000000000000000000000000000000000000
-                    0000000000000000000000000000000000000000000000000000000000000000
-                    0000000000000000000000000000000000000000000000000000000000000000
-                    0000000000000000000000000000000000000000000000000000000000000000
-                    0000000000000000000000000000000000000000000000000000000000000000
-                    0000000000000000000000000000000000000000000000000000000000000000
-                    00000000000000000000000000000000
-                </VALUE></PANELDATA>
-
-                <!-- Settings for "Debugger Target" panel -->
-                <SETTING><NAME>LogSystemMessages</NAME><VALUE>false</VALUE></SETTING>
-                <SETTING><NAME>AutoTargetDLLs</NAME><VALUE>false</VALUE></SETTING>
-                <SETTING><NAME>StopAtWatchpoints</NAME><VALUE>true</VALUE></SETTING>
-                <SETTING><NAME>PauseWhileRunning</NAME><VALUE>false</VALUE></SETTING>
-                <SETTING><NAME>PauseInterval</NAME><VALUE>5</VALUE></SETTING>
-                <SETTING><NAME>PauseUIFlags</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>AltExePath</NAME>
-                    <SETTING><NAME>Path</NAME><VALUE></VALUE></SETTING>
-                    <SETTING><NAME>PathFormat</NAME><VALUE>Generic</VALUE></SETTING>
-                    <SETTING><NAME>PathRoot</NAME><VALUE>Absolute</VALUE></SETTING>
-                </SETTING>
-                <SETTING><NAME>StopAtTempBPOnLaunch</NAME><VALUE>true</VALUE></SETTING>
-                <SETTING><NAME>CacheSymbolics</NAME><VALUE>true</VALUE></SETTING>
-                <SETTING><NAME>TempBPFunctionName</NAME><VALUE>main</VALUE></SETTING>
-                <SETTING><NAME>TempBPType</NAME><VALUE>false</VALUE></SETTING>
-
-                <!-- Settings for "68K CodeGen" panel -->
-                <SETTING><NAME>MWCodeGen_68K_codesize</NAME><VALUE>Smart</VALUE></SETTING>
-                <SETTING><NAME>MWCodeGen_68K_structalignment</NAME><VALUE>MC68K</VALUE></SETTING>
-                <SETTING><NAME>MWCodeGen_68K_fp_mode</NAME><VALUE>SANE</VALUE></SETTING>
-                <SETTING><NAME>MWCodeGen_68K_code68020</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWCodeGen_68K_profiler</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWCodeGen_68K_mpwc</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWCodeGen_68K_fourbyteints</NAME><VALUE>1</VALUE></SETTING>
-                <SETTING><NAME>MWCodeGen_68K_IEEEdoubles</NAME><VALUE>1</VALUE></SETTING>
-                <SETTING><NAME>MWCodeGen_68K_fardata</NAME><VALUE>1</VALUE></SETTING>
-                <SETTING><NAME>MWCodeGen_68K_farvtables</NAME><VALUE>1</VALUE></SETTING>
-                <SETTING><NAME>MWCodeGen_68K_farstrings</NAME><VALUE>1</VALUE></SETTING>
-                <SETTING><NAME>MWCodeGen_68K_pcrelstrings</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWCodeGen_68K_macsbug</NAME><VALUE>New</VALUE></SETTING>
-                <SETTING><NAME>MWCodeGen_68K_a6frames</NAME><VALUE>1</VALUE></SETTING>
-
-                <!-- Settings for "68K Disassembler" panel -->
-                <SETTING><NAME>MWDisassembler_68K_showcode</NAME><VALUE>1</VALUE></SETTING>
-                <SETTING><NAME>MWDisassembler_68K_mix</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWDisassembler_68K_nohex</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWDisassembler_68K_showdata</NAME><VALUE>1</VALUE></SETTING>
-                <SETTING><NAME>MWDisassembler_68K_showexceptions</NAME><VALUE>1</VALUE></SETTING>
-                <SETTING><NAME>MWDisassembler_68K_showsym</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWDisassembler_68K_shownames</NAME><VALUE>1</VALUE></SETTING>
-
-                <!-- Settings for "68K Global Optimizer" panel -->
-                <SETTING><NAME>GlobalOptimizer_68K_optimizationlevel</NAME><VALUE>Level0</VALUE></SETTING>
-                <SETTING><NAME>GlobalOptimizer_68K_optfor</NAME><VALUE>Speed</VALUE></SETTING>
-
-                <!-- Settings for "68K Linker" panel -->
-                <SETTING><NAME>MWLinker_68K_linksym</NAME><VALUE>1</VALUE></SETTING>
-                <SETTING><NAME>MWLinker_68K_symfullpath</NAME><VALUE>1</VALUE></SETTING>
-                <SETTING><NAME>MWLinker_68K_linksingle</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWLinker_68K_fastlink</NAME><VALUE>1</VALUE></SETTING>
-                <SETTING><NAME>MWLinker_68K_generateMap</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWLinker_68K_nolinkwarnings</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWLinker_68K_glueintosegone</NAME><VALUE>1</VALUE></SETTING>
-                <SETTING><NAME>MWLinker_68K_dontdeadstripinitcode</NAME><VALUE>0</VALUE></SETTING>
-
-                <!-- Settings for "68K Project" panel -->
-                <SETTING><NAME>MWProject_68K_type</NAME><VALUE>Application</VALUE></SETTING>
-                <SETTING><NAME>MWProject_68K_outfile</NAME><VALUE>MacOS Toolbox DEBUG 68K</VALUE></SETTING>
-                <SETTING><NAME>MWProject_68K_symfilename</NAME><VALUE></VALUE></SETTING>
-                <SETTING><NAME>MWProject_68K_filecreator</NAME><VALUE>1061109567</VALUE></SETTING>
-                <SETTING><NAME>MWProject_68K_filetype</NAME><VALUE>1095782476</VALUE></SETTING>
-                <SETTING><NAME>MWProject_68K_size</NAME><VALUE>384</VALUE></SETTING>
-                <SETTING><NAME>MWProject_68K_flags</NAME><VALUE>22720</VALUE></SETTING>
-                <SETTING><NAME>MWProject_68K_rsrcheader</NAME><VALUE>Standard</VALUE></SETTING>
-                <SETTING><NAME>MWProject_68K_rsrcname</NAME><VALUE></VALUE></SETTING>
-                <SETTING><NAME>MWProject_68K_rsrctype</NAME><VALUE>1061109567</VALUE></SETTING>
-                <SETTING><NAME>MWProject_68K_rsrcid</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWProject_68K_rsrcmulti</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWProject_68K_rsrcstore</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWProject_68K_rsrcmerge</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWProject_68K_rsrcflags</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWProject_68K_a4</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWProject_68K_minsize</NAME><VALUE>384</VALUE></SETTING>
-                <SETTING><NAME>MWProject_68K_rsrcsegtype</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWProject_68K_cfm68kcodegen</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWProject_68K_stacksize</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWProject_68K_thedebugger</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWProject_68K_rsrc_custom</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWProject_68K_is_rseg_app</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWProject_68K_is_pilot_lib</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWProject_68K_pilot_main_entry</NAME><VALUE></VALUE></SETTING>
-
-                <!-- Settings for "C/C++ Compiler" panel -->
-                <SETTING><NAME>MWFrontEnd_C_cplusplus</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWFrontEnd_C_checkprotos</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWFrontEnd_C_arm</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWFrontEnd_C_trigraphs</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWFrontEnd_C_onlystdkeywords</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWFrontEnd_C_enumsalwaysint</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWFrontEnd_C_mpwpointerstyle</NAME><VALUE>1</VALUE></SETTING>
-                <SETTING><NAME>MWFrontEnd_C_prefixname</NAME><VALUE>defs-cw5.h</VALUE></SETTING>
-                <SETTING><NAME>MWFrontEnd_C_ansistrict</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWFrontEnd_C_mpwcnewline</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWFrontEnd_C_wchar_type</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWFrontEnd_C_enableexceptions</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWFrontEnd_C_dontreusestrings</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWFrontEnd_C_poolstrings</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWFrontEnd_C_dontinline</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWFrontEnd_C_useRTTI</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWFrontEnd_C_multibyteaware</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWFrontEnd_C_unsignedchars</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWFrontEnd_C_autoinline</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWFrontEnd_C_booltruefalse</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWFrontEnd_C_direct_to_som</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWFrontEnd_C_som_env_check</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWFrontEnd_C_alwaysinline</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWFrontEnd_C_inlinelevel</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWFrontEnd_C_ecplusplus</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWFrontEnd_C_objective_c</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWFrontEnd_C_defer_codegen</NAME><VALUE>0</VALUE></SETTING>
-
-                <!-- Settings for "C/C++ Warnings" panel -->
-                <SETTING><NAME>MWWarning_C_warn_illpragma</NAME><VALUE>1</VALUE></SETTING>
-                <SETTING><NAME>MWWarning_C_warn_emptydecl</NAME><VALUE>1</VALUE></SETTING>
-                <SETTING><NAME>MWWarning_C_warn_possunwant</NAME><VALUE>1</VALUE></SETTING>
-                <SETTING><NAME>MWWarning_C_warn_unusedvar</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWWarning_C_warn_unusedarg</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWWarning_C_warn_extracomma</NAME><VALUE>1</VALUE></SETTING>
-                <SETTING><NAME>MWWarning_C_pedantic</NAME><VALUE>1</VALUE></SETTING>
-                <SETTING><NAME>MWWarning_C_warningerrors</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWWarning_C_warn_hidevirtual</NAME><VALUE>1</VALUE></SETTING>
-                <SETTING><NAME>MWWarning_C_warn_implicitconv</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWWarning_C_warn_notinlined</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWWarning_C_warn_structclass</NAME><VALUE>0</VALUE></SETTING>
-
-                <!-- Settings for "CFM68K" panel -->
-                <SETTING><NAME>MWCFM68K_exports</NAME><VALUE>None</VALUE></SETTING>
-                <SETTING><NAME>MWCFM68K_olddefversion</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWCFM68K_oldimpversion</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWCFM68K_currentversion</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWCFM68K_farthreshold</NAME><VALUE>256</VALUE></SETTING>
-                <SETTING><NAME>PCFM68K_sharedata</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWCFM68K_fragmentname</NAME><VALUE></VALUE></SETTING>
-                <SETTING><NAME>MWCFM68K_initname</NAME><VALUE></VALUE></SETTING>
-                <SETTING><NAME>MWCFM68K_mainname</NAME><VALUE>__start</VALUE></SETTING>
-                <SETTING><NAME>MWCFM68K_termname</NAME><VALUE></VALUE></SETTING>
-                <SETTING><NAME>MWCFM68K_libfolder</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWCFM68K_alignment</NAME><VALUE>Align_2</VALUE></SETTING>
-
-                <!-- Settings for "MacOS Merge Panel" panel -->
-                <SETTING><NAME>MWMerge_MacOS_projectType</NAME><VALUE>Application</VALUE></SETTING>
-                <SETTING><NAME>MWMerge_MacOS_outputName</NAME><VALUE>Merge Out</VALUE></SETTING>
-                <SETTING><NAME>MWMerge_MacOS_outputCreator</NAME><VALUE>1061109567</VALUE></SETTING>
-                <SETTING><NAME>MWMerge_MacOS_outputType</NAME><VALUE>1095782476</VALUE></SETTING>
-                <SETTING><NAME>MWMerge_MacOS_suppressWarning</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWMerge_MacOS_copyFragments</NAME><VALUE>1</VALUE></SETTING>
-                <SETTING><NAME>MWMerge_MacOS_copyResources</NAME><VALUE>1</VALUE></SETTING>
-                <SETTING><NAME>MWMerge_MacOS_skipResources</NAME>
-                    <SETTING><VALUE></VALUE></SETTING>
-                    <SETTING><VALUE>\ 6ªZ\83</VALUE></SETTING>
-                    <SETTING><VALUE>\ 6~\97¯</VALUE></SETTING>
-                    <SETTING><VALUE>\ 6
-|0</VALUE></SETTING>
-                </SETTING>
-
-                <!-- Settings for "PPC CodeGen" panel -->
-                <SETTING><NAME>MWCodeGen_PPC_structalignment</NAME><VALUE>PPC</VALUE></SETTING>
-                <SETTING><NAME>MWCodeGen_PPC_tracebacktables</NAME><VALUE>Inline</VALUE></SETTING>
-                <SETTING><NAME>MWCodeGen_PPC_processor</NAME><VALUE>Generic</VALUE></SETTING>
-                <SETTING><NAME>MWCodeGen_PPC_readonlystrings</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWCodeGen_PPC_tocdata</NAME><VALUE>1</VALUE></SETTING>
-                <SETTING><NAME>MWCodeGen_PPC_profiler</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWCodeGen_PPC_fpcontract</NAME><VALUE>1</VALUE></SETTING>
-                <SETTING><NAME>MWCodeGen_PPC_schedule</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWCodeGen_PPC_peephole</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWCodeGen_PPC_processorspecific</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWCodeGen_PPC_altivec</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWCodeGen_PPC_vectortocdata</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWCodeGen_PPC_vrsave</NAME><VALUE>0</VALUE></SETTING>
-
-                <!-- Settings for "PPC Disassembler" panel -->
-                <SETTING><NAME>MWDisassembler_PPC_showcode</NAME><VALUE>1</VALUE></SETTING>
-                <SETTING><NAME>MWDisassembler_PPC_extended</NAME><VALUE>1</VALUE></SETTING>
-                <SETTING><NAME>MWDisassembler_PPC_mix</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWDisassembler_PPC_nohex</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWDisassembler_PPC_showdata</NAME><VALUE>1</VALUE></SETTING>
-                <SETTING><NAME>MWDisassembler_PPC_showexceptions</NAME><VALUE>1</VALUE></SETTING>
-                <SETTING><NAME>MWDisassembler_PPC_showsym</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWDisassembler_PPC_shownames</NAME><VALUE>1</VALUE></SETTING>
-
-                <!-- Settings for "PPC Global Optimizer" panel -->
-                <SETTING><NAME>GlobalOptimizer_PPC_optimizationlevel</NAME><VALUE>Level0</VALUE></SETTING>
-                <SETTING><NAME>GlobalOptimizer_PPC_optfor</NAME><VALUE>Speed</VALUE></SETTING>
-
-                <!-- Settings for "PPC Linker" panel -->
-                <SETTING><NAME>MWLinker_PPC_linksym</NAME><VALUE>1</VALUE></SETTING>
-                <SETTING><NAME>MWLinker_PPC_symfullpath</NAME><VALUE>1</VALUE></SETTING>
-                <SETTING><NAME>MWLinker_PPC_linkmap</NAME><VALUE>1</VALUE></SETTING>
-                <SETTING><NAME>MWLinker_PPC_nolinkwarnings</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWLinker_PPC_dontdeadstripinitcode</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWLinker_PPC_permitmultdefs</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWLinker_PPC_linkmode</NAME><VALUE>Fast</VALUE></SETTING>
-                <SETTING><NAME>MWLinker_PPC_initname</NAME><VALUE></VALUE></SETTING>
-                <SETTING><NAME>MWLinker_PPC_mainname</NAME><VALUE>__start</VALUE></SETTING>
-                <SETTING><NAME>MWLinker_PPC_termname</NAME><VALUE></VALUE></SETTING>
-
-                <!-- Settings for "PPC PEF" panel -->
-                <SETTING><NAME>MWPEF_exports</NAME><VALUE>None</VALUE></SETTING>
-                <SETTING><NAME>MWPEF_libfolder</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWPEF_sortcode</NAME><VALUE>None</VALUE></SETTING>
-                <SETTING><NAME>MWPEF_expandbss</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWPEF_sharedata</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWPEF_olddefversion</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWPEF_oldimpversion</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWPEF_currentversion</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWPEF_fragmentname</NAME><VALUE></VALUE></SETTING>
-                <SETTING><NAME>MWPEF_collapsereloads</NAME><VALUE>0</VALUE></SETTING>
-
-                <!-- Settings for "PPC Project" panel -->
-                <SETTING><NAME>MWProject_PPC_type</NAME><VALUE>Application</VALUE></SETTING>
-                <SETTING><NAME>MWProject_PPC_outfile</NAME><VALUE>Emacs CW</VALUE></SETTING>
-                <SETTING><NAME>MWProject_PPC_filecreator</NAME><VALUE>1162690936</VALUE></SETTING>
-                <SETTING><NAME>MWProject_PPC_filetype</NAME><VALUE>1095782476</VALUE></SETTING>
-                <SETTING><NAME>MWProject_PPC_size</NAME><VALUE>16384</VALUE></SETTING>
-                <SETTING><NAME>MWProject_PPC_minsize</NAME><VALUE>16384</VALUE></SETTING>
-                <SETTING><NAME>MWProject_PPC_stacksize</NAME><VALUE>512</VALUE></SETTING>
-                <SETTING><NAME>MWProject_PPC_flags</NAME><VALUE>22752</VALUE></SETTING>
-                <SETTING><NAME>MWProject_PPC_symfilename</NAME><VALUE></VALUE></SETTING>
-                <SETTING><NAME>MWProject_PPC_rsrcname</NAME><VALUE></VALUE></SETTING>
-                <SETTING><NAME>MWProject_PPC_rsrcheader</NAME><VALUE>Native</VALUE></SETTING>
-                <SETTING><NAME>MWProject_PPC_rsrctype</NAME><VALUE>1061109567</VALUE></SETTING>
-                <SETTING><NAME>MWProject_PPC_rsrcid</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWProject_PPC_rsrcflags</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWProject_PPC_rsrcstore</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWProject_PPC_rsrcmerge</NAME><VALUE>0</VALUE></SETTING>
-
-                <!-- Settings for "PPCAsm Panel" panel -->
-                <SETTING><NAME>MWAssembler_PPC_auxheader</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWAssembler_PPC_symmode</NAME><VALUE>Mac</VALUE></SETTING>
-                <SETTING><NAME>MWAssembler_PPC_dialect</NAME><VALUE>PPC</VALUE></SETTING>
-                <SETTING><NAME>MWAssembler_PPC_prefixfile</NAME><VALUE></VALUE></SETTING>
-                <SETTING><NAME>MWAssembler_PPC_typecheck</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWAssembler_PPC_warnings</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWAssembler_PPC_casesensitive</NAME><VALUE>0</VALUE></SETTING>
-
-                <!-- Settings for "Rez Compiler" panel -->
-                <SETTING><NAME>MWRez_Language_maxwidth</NAME><VALUE>80</VALUE></SETTING>
-                <SETTING><NAME>MWRez_Language_script</NAME><VALUE>Roman</VALUE></SETTING>
-                <SETTING><NAME>MWRez_Language_alignment</NAME><VALUE>Align1</VALUE></SETTING>
-                <SETTING><NAME>MWRez_Language_filtermode</NAME><VALUE>FilterSkip</VALUE></SETTING>
-                <SETTING><NAME>MWRez_Language_suppresswarnings</NAME><VALUE>0</VALUE></SETTING>
-                <SETTING><NAME>MWRez_Language_escapecontrolchars</NAME><VALUE>1</VALUE></SETTING>
-                <SETTING><NAME>MWRez_Language_prefixname</NAME><VALUE></VALUE></SETTING>
-                <SETTING><NAME>MWRez_Language_filteredtypes</NAME><VALUE>'CODE' 'DATA' 'PICT'</VALUE></SETTING>
-            </SETTINGLIST>
-            <FILELIST>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>InterfaceLib</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Library</FILEKIND>
-                    <FILEFLAGS></FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>MathLib</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Library</FILEKIND>
-                    <FILEFLAGS></FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>MSL RuntimePPC.Lib</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Library</FILEKIND>
-                    <FILEFLAGS></FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>emacs.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>process.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>floatfns.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>editfns.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>macros.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>xdisp.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>window.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>minibuf.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>keymap.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>buffer.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>cmds.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>casefiddle.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>textprop.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>undo.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>syntax.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>search.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>marker.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>insdel.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>indent.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>coding.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>fileio.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>alloc.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>fns.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>eval.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>doc.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>dired.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>charset.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>ccl.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>category.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>callproc.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>casetab.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>callint.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>bytecode.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>abbrev.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>print.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>data.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>intervals.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>regex.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>mktime.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>filemode.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>getloadavg.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>scroll.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>region-cache.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>doprnt.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>cm.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>termcap.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>tparam.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>sysdep.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>lread.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>frame.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>term.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>keyboard.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>fontset.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>dispnew.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>Emacs.r</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>AppleScriptLib</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Library</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>strftime.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>TextEncodingConverter</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Library</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>xfaces.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>macfns.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>macterm.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>composite.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>atimer.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>mac.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>alloca.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>MSL C.PPC.Lib</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Library</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>MSL SIOUX.PPC.Lib</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Library</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>macmenu.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>AppearanceLib</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Library</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-                <FILE>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>md5.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                    <FILEKIND>Text</FILEKIND>
-                    <FILEFLAGS>Debug</FILEFLAGS>
-                </FILE>
-            </FILELIST>
-            <LINKORDER>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>abbrev.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>alloc.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>alloca.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>atimer.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>buffer.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>bytecode.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>callint.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>callproc.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>casefiddle.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>casetab.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>category.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>ccl.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>charset.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>cm.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>cmds.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>coding.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>composite.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>data.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>dired.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>dispnew.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>doc.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>doprnt.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>editfns.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>emacs.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>eval.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>fileio.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>filemode.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>floatfns.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>fns.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>fontset.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>frame.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>getloadavg.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>indent.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>insdel.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>intervals.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>keyboard.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>keymap.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>lread.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>macros.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>marker.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>md5.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>minibuf.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>mktime.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>print.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>process.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>regex.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>region-cache.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>scroll.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>search.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>strftime.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>syntax.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>term.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>termcap.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>textprop.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>tparam.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>undo.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>window.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>xdisp.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>sysdep.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>xfaces.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>mac.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>macfns.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>macmenu.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>macterm.c</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>MSL RuntimePPC.Lib</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>InterfaceLib</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>MathLib</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>AppleScriptLib</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>TextEncodingConverter</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>MSL C.PPC.Lib</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>MSL SIOUX.PPC.Lib</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>AppearanceLib</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-                <FILEREF>
-                    <PATHTYPE>Name</PATHTYPE>
-                    <PATH>Emacs.r</PATH>
-                    <PATHFORMAT>MacOS</PATHFORMAT>
-                </FILEREF>
-            </LINKORDER>
-        </TARGET>
-    </TARGETLIST>
-
-    <TARGETORDER>
-        <ORDEREDTARGET><NAME>Emacs</NAME></ORDEREDTARGET>
-    </TARGETORDER>
-
-    <GROUPLIST>
-        <GROUP><NAME>Emacs Source</NAME>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>abbrev.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>alloc.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>alloca.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>atimer.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>buffer.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>bytecode.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>callint.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>callproc.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>casefiddle.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>casetab.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>category.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>ccl.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>charset.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>cm.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>cmds.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>coding.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>composite.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>data.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>dired.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>dispnew.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>doc.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>doprnt.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>editfns.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>emacs.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>eval.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>fileio.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>filemode.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>floatfns.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>fns.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>fontset.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>frame.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>getloadavg.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>indent.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>insdel.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>intervals.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>keyboard.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>keymap.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>lread.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>macros.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>marker.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>md5.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>minibuf.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>mktime.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>print.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>process.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>regex.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>region-cache.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>scroll.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>search.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>strftime.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>syntax.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>sysdep.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>term.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>termcap.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>textprop.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>tparam.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>undo.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>window.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>xdisp.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>xfaces.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-        </GROUP>
-        <GROUP><NAME>Mac Source</NAME>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>mac.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>macfns.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>macmenu.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>macterm.c</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-        </GROUP>
-        <GROUP><NAME>Resources</NAME>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>Emacs.r</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-        </GROUP>
-        <GROUP><NAME>Mac Libraries</NAME>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>MSL RuntimePPC.Lib</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>InterfaceLib</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>MathLib</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>AppleScriptLib</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>TextEncodingConverter</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>AppearanceLib</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-        </GROUP>
-        <GROUP><NAME>ANSI Libraries</NAME>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>MSL C.PPC.Lib</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-            <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
-                <PATHTYPE>Name</PATHTYPE>
-                <PATH>MSL SIOUX.PPC.Lib</PATH>
-                <PATHFORMAT>MacOS</PATHFORMAT>
-            </FILEREF>
-        </GROUP>
-    </GROUPLIST>
-
-</PROJECT>
index 454b947..c522497 100644 (file)
@@ -19,7 +19,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 02111-1307, USA.
 
 
-Contributed by Andrew Choi (akochoi@i-cable.com).
+Contributed by Andrew Choi (akochoi@mac.com).
 
 Exported from the emacs-cw6.mcp project in Metrowerks CodeWarrior Pro
 6 for distribution.  This copyright notice was then added by hand.
@@ -80,7 +80,7 @@ emacs-cw6.mcp project.
 <PROJECT>
     <TARGETLIST>
         <TARGET>
-            <NAME>Emacs</NAME>
+            <NAME>Emacs CW</NAME>
             <SETTINGLIST>
 
                 <!-- Settings for "Source Trees" panel -->
@@ -153,7 +153,7 @@ emacs-cw6.mcp project.
                 <SETTING><NAME>Linker</NAME><VALUE>MacOS PPC Linker</VALUE></SETTING>
                 <SETTING><NAME>PreLinker</NAME><VALUE></VALUE></SETTING>
                 <SETTING><NAME>PostLinker</NAME><VALUE></VALUE></SETTING>
-                <SETTING><NAME>Targetname</NAME><VALUE>Emacs</VALUE></SETTING>
+                <SETTING><NAME>Targetname</NAME><VALUE>Emacs CW</VALUE></SETTING>
                 <SETTING><NAME>OutputDirectory</NAME>
                     <SETTING><NAME>Path</NAME><VALUE>:</VALUE></SETTING>
                     <SETTING><NAME>PathFormat</NAME><VALUE>MacOS</VALUE></SETTING>
@@ -637,7 +637,7 @@ emacs-cw6.mcp project.
                 <!-- Settings for "FTP Panel" panel -->
                 <SETTING><NAME>MWFTP_Post_hostName</NAME><VALUE></VALUE></SETTING>
                 <SETTING><NAME>MWFTP_Post_username</NAME><VALUE></VALUE></SETTING>
-                <SETTING><NAME>MWFTP_Post_password</NAME><VALUE>3654kr6a654npes6544xbe*&#154;\aA&#145;&#224;"</VALUE></SETTING>
+                <SETTING><NAME>MWFTP_Post_password</NAME><VALUE>35kmm835kpjgj5k5td7&#224;</VALUE></SETTING>
                 <SETTING><NAME>MWFTP_Post_remoteDir</NAME><VALUE></VALUE></SETTING>
                 <SETTING><NAME>MWFTP_Post_ftp_PathVersion</NAME><VALUE>0</VALUE></SETTING>
                 <SETTING><NAME>MWFTP_Post_ftp_PathType</NAME><VALUE>0</VALUE></SETTING>
@@ -1882,367 +1882,367 @@ emacs-cw6.mcp project.
     </TARGETLIST>
 
     <TARGETORDER>
-        <ORDEREDTARGET><NAME>Emacs</NAME></ORDEREDTARGET>
+        <ORDEREDTARGET><NAME>Emacs CW</NAME></ORDEREDTARGET>
     </TARGETORDER>
 
     <GROUPLIST>
         <GROUP><NAME>Emacs Source</NAME>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>abbrev.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>alloc.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>alloca.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>atimer.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>buffer.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>bytecode.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>callint.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>callproc.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>casefiddle.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>casetab.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>category.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>ccl.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>charset.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>cm.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>cmds.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>coding.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>composite.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>data.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>dired.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>dispnew.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>doc.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>doprnt.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>editfns.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>emacs.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>eval.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>fileio.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>filemode.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>floatfns.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>fns.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>fontset.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>frame.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>getloadavg.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>indent.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>insdel.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>intervals.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>keyboard.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>keymap.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>lread.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>macros.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>marker.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>md5.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>minibuf.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>mktime.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>print.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>process.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>regex.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>region-cache.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>scroll.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>search.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>strftime.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>syntax.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>sysdep.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>term.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>termcap.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>textprop.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>tparam.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>undo.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>window.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>xdisp.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>xfaces.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
@@ -2250,25 +2250,25 @@ emacs-cw6.mcp project.
         </GROUP>
         <GROUP><NAME>Mac Source</NAME>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>mac.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>macfns.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>macmenu.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>macterm.c</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
@@ -2276,7 +2276,7 @@ emacs-cw6.mcp project.
         </GROUP>
         <GROUP><NAME>Resources</NAME>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>Emacs.r</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
@@ -2284,31 +2284,31 @@ emacs-cw6.mcp project.
         </GROUP>
         <GROUP><NAME>Mac Libraries</NAME>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>InterfaceLib</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>MathLib</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>AppleScriptLib</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>TextEncodingConverter</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>AppearanceLib</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
@@ -2316,19 +2316,19 @@ emacs-cw6.mcp project.
         </GROUP>
         <GROUP><NAME>ANSI Libraries</NAME>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>MSL C.PPC.Lib</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>MSL SIOUX.PPC.Lib</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
             </FILEREF>
             <FILEREF>
-                <TARGETNAME>Emacs</TARGETNAME>
+                <TARGETNAME>Emacs CW</TARGETNAME>
                 <PATHTYPE>Name</PATHTYPE>
                 <PATH>MSL RuntimePPC.Lib</PATH>
                 <PATHFORMAT>MacOS</PATHFORMAT>
index 6d29a0e..f0b1e76 100644 (file)
@@ -17,7 +17,7 @@ along with GNU Emacs; see the file COPYING.  If not, write to the Free
 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 02111-1307, USA.  */
 
-/* Contributed by Andrew Choi (akochoi@users.sourceforge.net).  */
+/* Contributed by Andrew Choi (akochoi@mac.com).  */
 
 #ifndef _ALLOCA_H_
 #define _ALLOCA_H_
index aeb4a8a..a536ee9 100644 (file)
@@ -20,6 +20,8 @@ along with GNU Emacs; see the file COPYING.  If not, write to the
 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
+/* Contributed by Andrew Choi (akochoi@mac.com).  */
+
 
 /* No code in Emacs #includes config.h twice, but some of the code
    intended to work with other packages as well (like gmalloc.c) 
@@ -567,4 +569,4 @@ extern char *getenv ();
 
 /* #define GLYPH_DEBUG 1 */
 
-#define NO_RETURN /* nothing */
\ No newline at end of file
+#define NO_RETURN /* nothing */
diff --git a/mac/inc/defs-cw5.h b/mac/inc/defs-cw5.h
deleted file mode 100644 (file)
index ffc00d0..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Copyright (C) 2001 Free Software Foundation, Inc.
-
-This file is part of GNU Emacs.
-
-GNU Emacs is free software; you can redistribute it and/or modify it
-under the terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option) any
-later version.
-
-GNU Emacs is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Emacs; see the file COPYING.  If not, write to the Free
-Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-02111-1307, USA.  */
-
-/* Contributed by Andrew Choi (akochoi@users.sourceforge.net).  */
-
-#define emacs 1
-#define HAVE_CONFIG_H
index 6b386ba..e8d8abb 100644 (file)
@@ -17,9 +17,10 @@ along with GNU Emacs; see the file COPYING.  If not, write to the Free
 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 02111-1307, USA.  */
 
-/* Contributed by Andrew Choi (akochoi@users.sourceforge.net).  */
+/* Contributed by Andrew Choi (akochoi@mac.com).  */
 
 #define emacs 1
 #define HAVE_CONFIG_H
 
-#define CODEWARRIOR_VERSION_6
+#define MAC_OS8 1
+#define MAC_OS 1
index 8513acb..59b0c44 100644 (file)
@@ -18,7 +18,7 @@ along with GNU Emacs; see the file COPYING.  If not, write to
 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
-/* Contributed by Andrew Choi (akochoi@users.sourceforge.net).  */
+/* Contributed by Andrew Choi (akochoi@mac.com).  */
 
 #ifndef _DIRENT_H
 #define _DIRENT_H
index 7dad458..0ec9da7 100644 (file)
@@ -20,7 +20,7 @@ along with GNU Emacs; see the file COPYING.  If not, write to
 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
-/* Contributed by Andrew Choi (akochoi@users.sourceforge.net).  */
+/* Contributed by Andrew Choi (akochoi@mac.com).  */
 
 /* The default search path for Lisp function "load".
    This sets load-path.  */
index 6378c61..69f33a3 100644 (file)
@@ -18,7 +18,7 @@ along with GNU Emacs; see the file COPYING.  If not, write to
 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
-/* Contributed by Andrew Choi (akochoi@users.sourceforge.net).  */
+/* Contributed by Andrew Choi (akochoi@mac.com).  */
 
 /* The following line tells the configuration script what sort of 
    operating system this machine is likely to run.
index 8e6a5de..dedc809 100644 (file)
@@ -18,7 +18,7 @@ along with GNU Emacs; see the file COPYING.  If not, write to
 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
-/* Contributed by Andrew Choi (akochoi@users.sourceforge.net).  */
+/* Contributed by Andrew Choi (akochoi@mac.com).  */
 
 #ifndef _PWD_H
 #define _PWD_H
index 3780664..35143dd 100644 (file)
@@ -18,7 +18,7 @@ along with GNU Emacs; see the file COPYING.  If not, write to
 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
-/* Contributed by Andrew Choi (akochoi@users.sourceforge.net).  */
+/* Contributed by Andrew Choi (akochoi@mac.com).  */
 
 /*
  *     Define symbols to identify the version of Unix this is.
index c37d700..b33f8aa 100644 (file)
@@ -18,7 +18,7 @@ along with GNU Emacs; see the file COPYING.  If not, write to
 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
-/* Contributed by Andrew Choi (akochoi@users.sourceforge.net).  */
+/* Contributed by Andrew Choi (akochoi@mac.com).  */
 
 #ifndef _SYS_FILE_H
 #define _SYS_FILE_H
index 116e7bf..ae1a76b 100644 (file)
@@ -18,7 +18,7 @@ along with GNU Emacs; see the file COPYING.  If not, write to
 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
-/* Contributed by Andrew Choi (akochoi@users.sourceforge.net).  */
+/* Contributed by Andrew Choi (akochoi@mac.com).  */
 
 #ifndef _SYS_IOCTL_H
 #define _SYS_IOCTL_H
index 7a39b14..247f397 100644 (file)
@@ -18,7 +18,7 @@ along with GNU Emacs; see the file COPYING.  If not, write to
 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
-/* Contributed by Andrew Choi (akochoi@users.sourceforge.net).  */
+/* Contributed by Andrew Choi (akochoi@mac.com).  */
 
 #ifndef _SYS_PARAM_H
 #define _SYS_PARAM_H
index fe3dc5d..0f9ee79 100644 (file)
@@ -18,7 +18,7 @@ along with GNU Emacs; see the file COPYING.  If not, write to
 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
-/* Contributed by Andrew Choi (akochoi@users.sourceforge.net).  */
+/* Contributed by Andrew Choi (akochoi@mac.com).  */
 
 #ifndef _SYS_STAT_H
 #define _SYS_STAT_H
@@ -26,7 +26,7 @@ Boston, MA 02111-1307, USA.  */
 #ifdef __MWERKS__
 #include <stat.mac.h>
 
-#ifdef CODEWARRIOR_VERSION_6
+#if __MSL__ >= 0x6000
 #define fstat _fstat
 #endif
 
index 5c55c09..b9936e9 100644 (file)
@@ -18,7 +18,7 @@ along with GNU Emacs; see the file COPYING.  If not, write to
 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
-/* Contributed by Andrew Choi (akochoi@users.sourceforge.net).  */
+/* Contributed by Andrew Choi (akochoi@mac.com).  */
 
 #ifndef _SYS_TIME_H
 #define _SYS_TIME_H
index 71eb976..9f358b2 100644 (file)
@@ -18,7 +18,7 @@ along with GNU Emacs; see the file COPYING.  If not, write to
 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
-/* Contributed by Andrew Choi (akochoi@users.sourceforge.net).  */
+/* Contributed by Andrew Choi (akochoi@mac.com).  */
 
 #ifndef _SYS_TYPES_H
 #define _SYS_TYPES_H
index 3f194e5..7d42363 100644 (file)
@@ -18,7 +18,7 @@ along with GNU Emacs; see the file COPYING.  If not, write to
 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
-/* Contributed by Andrew Choi (akochoi@users.sourceforge.net).  */
+/* Contributed by Andrew Choi (akochoi@mac.com).  */
 
 #ifndef _SYS_TERMIO_H
 #define _SYS_TERMIO_H
index 8cb65ec..1a7f925 100644 (file)
@@ -18,7 +18,7 @@ along with GNU Emacs; see the file COPYING.  If not, write to
 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
-/* Contributed by Andrew Choi (akochoi@users.sourceforge.net).  */
+/* Contributed by Andrew Choi (akochoi@mac.com).  */
 
 #ifndef _UTIME_H_
 #define _UTIME_H_
index fec32be..0469fcf 100644 (file)
@@ -18,7 +18,7 @@ along with GNU Emacs; see the file COPYING.  If not, write to
 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
-/* Contributed by Andrew Choi (akochoi@users.sourceforge.net).  */
+/* Contributed by Andrew Choi (akochoi@mac.com).  */
 
 #ifndef        _UTSNAME_H
 #define        _UTSNAME_H
diff --git a/mac/make-bin-dist b/mac/make-bin-dist
new file mode 100755 (executable)
index 0000000..793f155
--- /dev/null
@@ -0,0 +1,117 @@
+#!/bin/sh
+
+#### make-bin-dist: create a binary Emacs distribution tar file for
+#### Mac OS X.  This basically runs a `configure' and `make install'
+#### into a temporary directory and archives that directory.  It also
+#### places the Emacs application bundle and a installer script in the
+#### tar file.  The installer script is run to set up the XML file for
+#### setting the environment variables used by Emacs when it is
+#### started from the Finder.
+
+# Copyright (C) 2002 Free Software Foundation, Inc.
+#
+# This file is part of GNU Emacs.
+#
+# GNU Emacs is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# GNU Emacs is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Emacs; see the file COPYING.  If not, write to the
+# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+progname="$0"
+
+### Exit if a command fails.
+#set -e
+
+### Print out each line we read, for debugging's sake.
+set -v
+
+LANGUAGE=C
+LC_ALL=C
+LC_MESSAGES=
+LANG=
+export LANGUAGE LC_ALL LC_MESSAGES LANG
+
+## Don't restrict access to any files.
+umask 0
+
+### Make sure we're running in the right place.
+if [ ! -f Emacs.app/Contents/PkgInfo ]; then
+  echo "${progname}: Can't find \`Emacs.app/Contents/PkgInfo'" >&2
+  echo "${progname} must be run in the \`mac' directory of the Emacs" >&2
+  echo "distribution tree.  cd to that directory and try again." >&2
+  exit 1
+fi
+
+### Check whether file ../lisp/version.el exists.
+if [ ! -f ../lisp/version.el ]; then
+  echo "${progname}: Can't find \`../lisp/version.el'" >&2
+  exit 1
+fi
+
+### Find out which version of Emacs this is.
+shortversion=`grep 'defconst[   ]*emacs-version' ../lisp/version.el \
+        | sed -e 's/^.*"\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/'`
+version=`grep 'defconst[        ]*emacs-version' ../lisp/version.el \
+        | sed -e 's/^[^"]*"\([^"]*\)".*$/\1/'`
+if [ ! "${version}" ]; then
+  echo "${progname}: can't find current Emacs version in \`./lisp/version.el'" >&2
+  exit 1
+fi
+
+echo Version numbers are $version and $shortversion
+
+### Make sure we don't already have a directory  emacs-${version}.
+
+emacsname="emacs-${version}${new_extension}"
+
+if [ -d ${emacsname} ]
+then
+  echo Directory "${emacsname}" already exists >&2
+  exit 1
+fi
+
+### Make sure the subdirectory is available.
+tempparent="make-bin-dist.tmp.$$"
+if [ -d ${tempparent} ]; then
+  echo "${progname}: staging directory \`${tempparent}' already exists.
+Perhaps a previous invocation of \`${progname}' failed to clean up after
+itself.  Check that directories whose names are of the form
+\`make-dist.tmp.NNNNN' don't contain any important information, remove
+them, and try again." >&2
+  exit 1
+fi
+
+tempparentfull="`pwd`/${tempparent}"
+
+echo Installing into directory ${tempparentfull} >&2
+
+(cd ..; ./configure --prefix=${tempparentfull}; make install)
+
+### This trap ensures that the staging directory will be cleaned up even
+### when the script is interrupted in mid-career.
+trap "echo 'Interrupted...cleaning up the staging directory'; rm -rf ${tempparent}; exit 1" 1 2 15
+
+cp -r Emacs.app ${tempparent}
+
+cp osx-install ${tempparent}
+
+echo "Creating tar file"
+
+mv ${tempparent} ${emacsname}
+
+tar cvf - ${emacsname} | gzip > ${emacsname}-mac-bin.tar.gz
+
+echo "Cleaning up the staging directory"
+rm -rf ${emacsname}
+
+### make-bin-dist ends here
index 66ad1c7..4ad27ef 100644 (file)
@@ -47,13 +47,13 @@ OptOption = # -opt speed                    # alternatively set to -opt off or -opt size
 PPCCOptions = {SymOption} {OptOption} -noMapCR -enum int Â¶
        -typecheck relaxed -w off Â¶
        -includes unix -i {Includes},{Src} Â¶
-       -d emacs=1 -d HAVE_CONFIG_H
+       -d emacs=1 -d HAVE_CONFIG_H -d MAC_OS -d MAC_OS8
 
 LinkOptions = {SymOption} -d
 
 CONFIG_H_GROUP = "{Includes}config.h" "{Includes}s-mac.h" "{Includes}utsname.h" "{Includes}m-mac.h"
-DISPEXTERN_H_GROUP = "{Src}dispextern.h" "{Includes}macgui.h"
-INTERVALS_H_GROUP = "{Src}intervals.h" "{Src}dispextern.h" "{Includes}macgui.h"
+DISPEXTERN_H_GROUP = "{Src}dispextern.h" "{Src}macgui.h"
+INTERVALS_H_GROUP = "{Src}intervals.h" "{Src}dispextern.h" "{Src}macgui.h"
 WINDOW_H_GROUP = "{Src}window.h" {DISPEXTERN_H_GROUP}
 BLOCKINPUT_H_GROUP = "{Src}blockinput.h" "{Src}atimer.h" "{Src}systime.h" Â¶
   "{Includes}sys:time.h" "{Includes}sys:time.h"
@@ -125,10 +125,10 @@ EmacsObjects = 
 # The list of object files generated from new source files of the Macintosh port.
 
 MacObjects = Â¶
-       "{Source}mac.c.x" Â¶
-       "{Source}macfns.c.x" Â¶
-       "{Source}macmenu.c.x" Â¶
-       "{Source}macterm.c.x"
+       "{Src}mac.c.x" Â¶
+       "{Src}macfns.c.x" Â¶
+       "{Src}macmenu.c.x" Â¶
+       "{Src}macterm.c.x"
 
 # The next two are the dependency rules for building Emacs.
 
@@ -369,8 +369,8 @@ Emacs 
        "{Src}process.h" Â¶
        "{Src}keyboard.h" Â¶
        "{Src}syssignal.h" Â¶
-       "{Includes}macterm.h" Â¶
-               "{Includes}macgui.h" Â¶
+       "{Src}macterm.h" Â¶
+               "{Src}macgui.h" Â¶
                "{Src}frame.h" Â¶
        "{Src}systime.h"
        
@@ -482,8 +482,8 @@ Emacs 
        "{Src}lisp.h" Â¶
        "{Src}charset.h" Â¶
        "{Src}fontset.h" Â¶
-       "{Includes}macterm.h" Â¶
-               "{Includes}macgui.h" Â¶
+       "{Src}macterm.h" Â¶
+               "{Src}macgui.h" Â¶
                "{Src}frame.h" Â¶
        "{Src}frame.h" Â¶
        "{Src}fontset.h" Â¶
@@ -556,8 +556,8 @@ Emacs 
        "{Src}systty.h" Â¶
                "{Includes}termio.h" Â¶
        "{Includes}sys:types.h" Â¶
-       "{Includes}macterm.h" Â¶
-               "{Includes}macgui.h" Â¶
+       "{Src}macterm.h" Â¶
+               "{Src}macgui.h" Â¶
                "{Src}frame.h" Â¶
        "{Src}systime.h"
 
@@ -734,8 +734,8 @@ Emacs 
        {DISPEXTERN_H_GROUP} Â¶
        {WINDOW_H_GROUP} Â¶
        "{Src}cm.h" Â¶
-       "{Includes}macterm.h" Â¶
-               "{Includes}macgui.h" Â¶
+       "{Src}macterm.h" Â¶
+               "{Src}macgui.h" Â¶
                "{Src}frame.h"
        
 {Src}termcap.c.x Ã„ Â¶
@@ -774,8 +774,8 @@ Emacs 
        {DISPEXTERN_H_GROUP} Â¶
        {BLOCKINPUT_H_GROUP} Â¶
        {INTERVALS_H_GROUP} Â¶
-       "{Includes}macterm.h" Â¶
-               "{Includes}macgui.h" Â¶
+       "{Src}macterm.h" Â¶
+               "{Src}macgui.h" Â¶
                "{Src}frame.h"  
        
 {Src}xdisp.c.x Ã„ Â¶
@@ -799,8 +799,8 @@ Emacs 
        "{Src}process.h" Â¶
        "{Src}region-cache.h" Â¶
        "{Src}fontset.h" Â¶
-       "{Includes}macterm.h" Â¶
-               "{Includes}macgui.h" Â¶
+       "{Src}macterm.h" Â¶
+               "{Src}macgui.h" Â¶
                "{Src}frame.h"  
        
 {Src}xfaces.c.x Ã„ Â¶
@@ -811,8 +811,8 @@ Emacs 
        "{Src}charset.h" Â¶
        "{Src}frame.h" Â¶
        "{Src}fontset.h" Â¶
-       "{Includes}macterm.h" Â¶
-               "{Includes}macgui.h" Â¶
+       "{Src}macterm.h" Â¶
+               "{Src}macgui.h" Â¶
                "{Src}frame.h" Â¶
        "{Src}buffer.h" Â¶
        {DISPEXTERN_H_GROUP} Â¶
@@ -833,7 +833,7 @@ Emacs 
        "{Includes}sys:types.h" Â¶
        {DISPEXTERN_H_GROUP}
 
-{Source}mac.c Ã„ Â¶
+{Src}mac.c Ã„ Â¶
        {CONFIG_H_GROUP} Â¶
        "{Includes}utime.h" Â¶
        "{Includes}dirent.h" Â¶
@@ -849,12 +849,12 @@ Emacs 
                "{Includes}sys:time.h" Â¶
        "{Includes}utsname.h"
 
-{Source}macfns.c Ã„ Â¶
+{Src}macfns.c Ã„ Â¶
        {CONFIG_H_GROUP} Â¶
        "{Src}lisp.h" Â¶
        "{Src}charset.h" Â¶
-       "{Includes}macterm.h" Â¶
-               "{Includes}macgui.h" Â¶
+       "{Src}macterm.h" Â¶
+               "{Src}macgui.h" Â¶
                "{Src}frame.h" Â¶
        "{Src}frame.h" Â¶
        {WINDOW_H_GROUP} Â¶
@@ -871,13 +871,13 @@ Emacs 
        "{Src}systime.h" Â¶
        "{Src}bitmaps:gray.xbm"
 
-{Source}macterm.c Ã„ Â¶
+{Src}macterm.c Ã„ Â¶
        {CONFIG_H_GROUP} Â¶
        "{Src}lisp.h" Â¶
        {BLOCKINPUT_H_GROUP} Â¶
        "{Src}syssignal.h" Â¶
-       "{Includes}macterm.h" Â¶
-               "{Includes}macgui.h" Â¶
+       "{Src}macterm.h" Â¶
+               "{Src}macgui.h" Â¶
                "{Src}frame.h" Â¶
        "{Includes}alloca.h" Â¶
        "{Includes}sys:types.h" Â¶
@@ -992,9 +992,9 @@ EmacsSource = 
        "{Src}xmenu.c"
 
 MacSource = Â¶
-       "{Source}mac.c" Â¶
-       "{Source}macfns.c" Â¶
-       "{Source}macterm.c"
+       "{Src}mac.c" Â¶
+       "{Src}macfns.c" Â¶
+       "{Src}macterm.c"
 
 
 LispSource = Â¶
@@ -1040,22 +1040,10 @@ LispSource = 
        {Lisp}language:chinese.elc Â¶
        {Lisp}language:cyrillic.elc Â¶
        {Lisp}language:indian.elc Â¶
-       {Lisp}language:devanagari.elc Â¶
-       {Lisp}language:english.elc Â¶
        {Lisp}language:ethiopic.elc Â¶
        {Lisp}language:european.elc Â¶
-       {Lisp}language:czech.elc Â¶
-       {Lisp}language:slovak.elc Â¶
-       {Lisp}language:romanian.elc Â¶
-       {Lisp}language:greek.elc Â¶
-       {Lisp}language:hebrew.elc Â¶
-       {Lisp}language:japanese.elc Â¶
-       {Lisp}language:korean.elc Â¶
-       {Lisp}language:lao.elc Â¶
-       {Lisp}language:thai.elc Â¶
        {Lisp}language:tibetan.elc Â¶
        {Lisp}language:vietnamese.elc Â¶
-       {Lisp}language:misc-lang.elc Â¶
        {Lisp}paths.el Â¶
        {Lisp}register.elc Â¶
        {Lisp}replace.elc Â¶
@@ -1073,13 +1061,27 @@ LispSource = 
        {Lisp}window.elc Â¶
        {Lisp}version.el
 
+LispSourceDontCompile = Â¶
+       {Lisp}language:devanagari.el Â¶
+       {Lisp}language:english.el Â¶
+       {Lisp}language:czech.el Â¶
+       {Lisp}language:slovak.el Â¶
+       {Lisp}language:romanian.el Â¶
+       {Lisp}language:greek.el Â¶
+       {Lisp}language:hebrew.el Â¶
+       {Lisp}language:japanese.el Â¶
+       {Lisp}language:korean.el Â¶
+       {Lisp}language:lao.el Â¶
+       {Lisp}language:thai.el Â¶
+       {Lisp}language:misc-lang.el
 
 Doc Ã„ {DocTarget}DOC
 
-{DocTarget}DOC Ã„ {Makefile} {EmacsSource} {MacSource} {LispSource} {Make-DocFileDir}Make-DocFile
+{DocTarget}DOC Ã„ {Makefile} {EmacsSource} {MacSource} {LispSource} {LispSourceDontCompile} {Make-DocFileDir}Make-DocFile
        {Make-DocFileDir}make-docfile {EmacsSource} > {DocTarget}DOC
        {Make-DocFileDir}make-docfile {MacSource} >> {DocTarget}DOC
        {Make-DocFileDir}make-docfile {LispSource} >> {DocTarget}DOC
+       {Make-DocFileDir}make-docfile {LispSourceDontCompile} >> {DocTarget}DOC
 
 
 #-----------------------------------------------#
diff --git a/mac/osx-install b/mac/osx-install
new file mode 100755 (executable)
index 0000000..85a3304
--- /dev/null
@@ -0,0 +1,97 @@
+#!/bin/sh
+
+#### osx-install: create the file ~/.MacOSX/environment.plist with
+#### appropriate paths for Emacs to access lisp and bin directories.
+#### On Mac OS X, this file contains values for environment variables
+#### seen by Aqua application launched in the Finder.  This script
+#### must be run at the top level of a Mac OS X binary distribution.
+
+# Copyright (C) 2002 Free Software Foundation, Inc.
+#
+# This file is part of GNU Emacs.
+#
+# GNU Emacs is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# GNU Emacs is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Emacs; see the file COPYING.  If not, write to the
+# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+progname="$0"
+
+### Exit if a command fails.
+#set -e
+
+### Print out each line we read, for debugging's sake.
+set -v
+
+LANGUAGE=C
+LC_ALL=C
+LC_MESSAGES=
+LANG=
+export LANGUAGE LC_ALL LC_MESSAGES LANG
+
+## Don't restrict access to any files.
+umask 0
+
+### Make sure we're running in the right place.
+if [ ! -d Emacs.app -o ! -d libexec -o ! -d share ]; then
+  echo "${progname} must be run in the top directory of the Emacs" >&2
+  echo "binary distribution tree for Mac OS.  cd to that directory" >&2
+  echo "and try again." >&2
+  exit 1
+fi
+
+versionfile=`ls share/emacs/21.*/lisp/version.el`
+
+### Find out which version of Emacs this is.
+shortversion=`grep 'defconst[   ]*emacs-version' ${versionfile} \
+        | sed -e 's/^.*"\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/'`
+version=`grep 'defconst[        ]*emacs-version' ${versionfile} \
+        | sed -e 's/^[^"]*"\([^"]*\)".*$/\1/'`
+if [ ! "${version}" ]; then
+  echo "${progname}: can't find current Emacs version in \`./lisp/version.el'" >&2
+  exit 1
+fi
+
+echo Version numbers are $version and $shortversion
+
+homedir=`ls -d ~`
+initfile="${homedir}/.MacOSX/environment.plist"
+
+if [ -f ${initfile} ]; then
+  mv ${initfile} ${initfile}.old
+fi
+
+if [ -d ${homedir}/.MacOSX ]; then
+  mkdir ${homedir}/.MacOSX
+fi
+
+execpath=`ls -d libexec/emacs/21.*/powerpc-apple-*/`
+
+echo '<?xml version="1.0" encoding="UTF-8"?>' > ${initfile}
+echo '<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">' >> ${initfile}
+echo '<plist version="0.9">' >> ${initfile}
+echo '<dict>' >> ${initfile}
+echo '  <key>EMACSLOADPATH</key>' >> ${initfile}
+echo "  <string>`pwd`/share/emacs/${version}/lisp/</string>" >> ${initfile}
+echo '  <key>EMACSPATH</key>' >> ${initfile}
+echo "  <string>`pwd`/${execpath}:`pwd`/bin/</string>" >> ${initfile}
+echo '  <key>EMACSDATA</key>' >> ${initfile}
+echo "  <string>`pwd`/share/emacs/${version}/etc/</string>" >> ${initfile}
+echo '  <key>EMACSDOC</key>' >> ${initfile}
+echo "  <string>`pwd`/share/emacs/${version}/etc/</string>" >> ${initfile}
+echo '  <key>INFOPATH</key>' >> ${initfile}
+echo "  <string>`pwd`/info/</string>" >> ${initfile}
+echo '</dict>' >> ${initfile}
+echo '</plist>' >> ${initfile}
+
+### osx-install ends here
index 475bce6..6163085 100644 (file)
@@ -18,11 +18,13 @@ along with GNU Emacs; see the file COPYING.  If not, write to
 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
-/* Contributed by Andrew Choi (akochoi@users.sourceforge.net).  */
+/* Contributed by Andrew Choi (akochoi@mac.com).  */
 
+#ifndef TARGET_API_MAC_CARBON
 #include "Types.r"
 /* added for finder icon balloon help --ben */
 #include "Balloons.r"
+#endif
 
 /* Define to use gnu icon */
 /* #define GNU_ICON 1 */
@@ -55,10 +57,12 @@ resource 'hfdr' (-5696) { /*help for emacs icon*/
        }
 };
 
+#ifndef TARGET_API_MAC_CARBON
 /* added for finder icon balloon help --ben */
 resource 'STR ' (128) { /*help message for emacs icon*/
        "GNU Emacs\0xd1the extensible, customizable, self-documenting real-time display editor."
 };
+#endif
 
 resource 'MENU' (128, preload) {
        128,
index c4ff17f..ad49ab3 100644 (file)
@@ -20,7 +20,7 @@ along with GNU Emacs; see the file COPYING.  If not, write to
 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
-/* Contributed by Andrew Choi (akochoi@users.sourceforge.net).  */
+/* Contributed by Andrew Choi (akochoi@mac.com).  */
 
 #include "Types.r"
 #include "CodeFragmentTypes.r"
index 5bf9354..987df20 100644 (file)
@@ -18,7 +18,7 @@ along with GNU Emacs; see the file COPYING.  If not, write to
 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
-/* Contributed by Andrew Choi (akochoi@users.sourceforge.net).  */
+/* Contributed by Andrew Choi (akochoi@mac.com).  */
 
 #include <string.h>
 #include <Files.h>
index 32c678e..91002d9 100755 (executable)
--- a/make-dist
+++ b/make-dist
@@ -325,7 +325,9 @@ for subdir in lisp site-lisp lispref lispintro \
              src src/m src/s src/bitmaps lib-src oldXMenu lwlib \
              nt nt/inc nt/inc/sys nt/inc/arpa nt/inc/netinet nt/icons \
              etc etc/e lock info man msdos vms mac mac/inc mac/inc/sys \
-             mac/src
+             mac/src mac/Emacs.app mac/Emacs.app/Contents \
+             mac/Emacs.app/Contents/MacOS mac/Emacs.app/Contents/Resources \
+             mac/Emacs.app/Contents/Resources/English.lproj
 do
   echo "  ${tempdir}/${subdir}"
   mkdir ${tempdir}/${subdir}
@@ -528,6 +530,14 @@ echo "Making links to \`mac/src'"
 (cd mac/src
  ln [a-z]*.c *.r ../../${tempdir}/mac/src)
 
+echo "Making links to \`mac/Emacs.app/Contents'"
+(cd mac/Emacs.app/Contents
+ ln Info.plist PkgInfo ../../../${tempdir}/mac/Emacs.app/Contents)
+
+echo "Making links to \`mac/Emacs.app/Contents/Resources/English.lproj'"
+(cd mac/Emacs.app/Contents/Resources/English.lproj
+ ln InfoPlist.strings ../../../../../${tempdir}/mac/Emacs.app/Contents/Resources/English.lproj)
 echo "Making links to \`msdos'"
 (cd msdos
  ln  ChangeLog emacs.ico emacs.pif ../${tempdir}/msdos
index 9913104..6a7b291 100644 (file)
@@ -1,27 +1,31 @@
 @c This is part of the Emacs manual.
-@c Copyright (C) 2000,2001 Free Software Foundation, Inc.
+@c Copyright (C) 2000,2001,2002 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Mac OS, MS-DOS, Antinews, Top
 @appendix Emacs and the Mac OS
 @cindex Mac OS
 @cindex Macintosh
 
-  Emacs built on the Mac OS supports many of its major features:
+  Emacs built on Mac OS X supports most of its major features:
 multiple frames, colors, scroll bars, menu bars, use of the mouse,
-fontsets, international characters, input methods, coding systems, and
-synchronous subprocesses (@code{call-process}).  Much of this works in
-the same way as on other platforms and is therefore documented in the
-rest of this manual.  This section describes the peculiarities of using
-Emacs under the Mac OS.
-
-  The following features of Emacs are not yet supported on the Mac:
-unexec (@code{dump-emacs}), asynchronous subprocesses
+fontsets, international characters, input methods, coding systems,
+asynchronous and synchronous subprocesses, unexec (@code{dump-emacs}),
+and networking (@code{open-network-stream}).  Support for various
+image file formats has not been implemented yet.
+
+  The following features of Emacs are not yet supported on the Mac OS
+8 or 9: unexec (@code{dump-emacs}), asynchronous subprocesses
 (@code{start-process}), and networking (@code{open-network-stream}).
 As a result, packages such as Gnus, GUD, and Comint do not work.
+However, synchronous subprocesses (@code{call-process}) are supported.
+Since external programs to handle commands such as @code{print-buffer}
+and @code{diff} are not available on Mac OS 8 or 9, they are not
+supported.
 
-  Since external programs to handle commands such as
-@code{print-buffer} and @code{diff} are not available on the Mac OS,
-they are not supported in the Mac OS version.
+  Most of the features that are supported work in the same way as on
+other platforms and are therefore documented in the rest of this
+manual.  This section describes the peculiarities of using Emacs under
+the Mac OS.
 
 @menu
 * Input: Mac Input.                Keyboard input on the Mac.
@@ -138,9 +142,15 @@ Traditional Chinese, use @samp{chinese-big5-mac} and for Japanese,
 @section Environment Variables and Command Line Arguments.
 @cindex environment variables (Mac OS)
 
-  Environment variables and command line arguments for Emacs can be set
-by modifying the @samp{STR#} resources 128 and 129, respectively.  A common
-environment variable that one may want to set is @samp{HOME}.
+  On Mac OS X, when Emacs is run in a terminal, it inherits the values
+of environment variables from the shell from which it is invoked.
+However, when it is run from the Finder as a GUI application, it
+inherits no environment variable values.
+
+  On Mac OS 8 or 9, environment variables and command line arguments
+for Emacs can be set by modifying the @samp{STR#} resources 128 and
+129, respectively.  A common environment variable that one may want to
+set is @samp{HOME}.
 
   The way to set an environment variable is by adding a string of the
 form
@@ -173,17 +183,18 @@ So when Emacs requests a file name, doing file name completion on
 @file{/} will display all volumes on the system.  You can use @file{..}
 to go up a directory level.
 
-  To access files and folders on the desktop, look in the folder
-@file{Desktop Folder} in your boot volume (this folder is usually
-invisible in the Mac @code{Finder}).
-
-  Emacs creates the Mac folder @file{:Preferences:Emacs:} in the
-@file{System Folder} and uses it as the temporary directory.  Emacs
-maps the directory name @file{/tmp/} to that.  Therefore it
-is best to avoid naming a volume @file{tmp}.  If everything works
-correctly, the program should leave no files in it when it exits.  You
-should be able to set the environment variable @code{TMPDIR} to use
-another directory but this folder will still be created.
+  On Mac OS 8 or 9, to access files and folders on the desktop, look
+in the folder @file{Desktop Folder} in your boot volume (this folder
+is usually invisible in the Mac @code{Finder}).
+
+  On Mac OS 8 or 9, Emacs creates the Mac folder
+@file{:Preferences:Emacs:} in the @file{System Folder} and uses it as
+the temporary directory.  Emacs maps the directory name @file{/tmp/}
+to that.  Therefore it is best to avoid naming a volume @file{tmp}.
+If everything works correctly, the program should leave no files in it
+when it exits.  You should be able to set the environment variable
+@code{TMPDIR} to use another directory but this folder will still be
+created.
 
 
 @node Mac Font Specs
index 990f10d..a2db98d 100644 (file)
@@ -1,3 +1,36 @@
+2002-04-26  Andrew Choi  <akochoi@shaw.ca>
+
+       * Makefile.in (C_SWITCH_SYSTEM_TEMACS): Add.
+       [HAVE_CARBON]: Include Mac object files.
+
+       * alloc.c, callproc.c, dispextern.h, dispnew.c, emacs.c,
+       fontset.c, frame.c, frame.h, keyboard.c, sysdep.c, term.c,
+       termcap.c, window.c, xdisp.c, xfaces.c: Use macros MAC_OS8,
+       MAC_OSX, and MAC_OS instead of macintosh.
+
+       * editfns.c [MAC_OS8]: Include stdio.h.
+
+       * emacs.c [MAC_OS8]: Call mac_initialize instead of x_term_init.
+
+       * fontset.c [MAC_OS]: Set Vdefault_fontset to ETL Fixed instead of
+       Apple Monaco.
+
+       * process.c: Declare QCfamily and QCfilter as extern.
+       (wait_reading_process_input) [MAC_OSX]: Clear bit for stdin before
+       calling select.
+
+       * termcap.c [MAC_OSX]: Don't define tgetnum, PC, tputs, and
+       tgetent.
+       
+       * tparam.c [MAC_OSX]: Don't define BC and UP.
+       
+       * config.in [HAVE_CARBON]: Add.
+
+       * mac.c, macgui.h, macfns.c, macmenu.c, macterm.c, macterm.h: Move
+       here from mac/src and mac/inc.
+
+       * s/darwin.h, m/powermac.h, unexmacosx.c: New files.
+       
 2002-04-26  Gerd Moellmann  <gerd@gnu.org>
 
        * xterm.c (x_draw_phys_cursor_glyph): Undo last change.  Compute
index 1d8f1ad..82d1e78 100644 (file)
@@ -159,6 +159,12 @@ CC = C_COMPILER
 #define LD_SWITCH_SYSTEM_TEMACS
 #endif
 
+/* Some s/SYSTEM.h files define this to request special switches
+   for compiling temacs.  */
+#ifndef C_SWITCH_SYSTEM_TEMACS
+#define C_SWITCH_SYSTEM_TEMACS
+#endif
+
 /* Some m/MACHINE.h files define this to request special switches in ld.  */
 #ifndef LD_SWITCH_MACHINE
 #define LD_SWITCH_MACHINE
@@ -266,7 +272,7 @@ TOOLKIT_DEFINES =
 
 /* 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) $(MYCPPFLAG) -I. -I${srcdir} C_SWITCH_MACHINE C_SWITCH_SYSTEM C_SWITCH_SITE C_SWITCH_X_SITE C_SWITCH_X_MACHINE C_SWITCH_X_SYSTEM ${CFLAGS}
+ALL_CFLAGS=-Demacs -DHAVE_CONFIG_H $(TOOLKIT_DEFINES) $(MYCPPFLAG) -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}
 .c.o:
        $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) $<
 
@@ -531,10 +537,17 @@ MSDOS_OBJ = dosfns.o msdos.o w16select.o
 #endif
 #endif
 
+#ifdef HAVE_CARBON
+XMENU_OBJ =
+MAC_OBJ = mac.o macterm.o macfns.o macmenu.o fontset.o
+emacsapp = ../mac/Emacs.app/
+#else
+XMENU_OBJ = xmenu.o
+#endif
 
 /* lastfile must follow all files
    whose initialized data areas should be dumped as pure by dump-emacs.  */
-obj=    dispnew.o frame.o scroll.o xdisp.o xmenu.o window.o \
+obj=    dispnew.o frame.o scroll.o xdisp.o $(XMENU_OBJ) window.o \
        charset.o coding.o category.o ccl.o\
        cm.o term.o xfaces.o $(XOBJ) \
        emacs.o keyboard.o macros.o keymap.o sysdep.o \
@@ -547,13 +560,14 @@ obj=    dispnew.o frame.o scroll.o xdisp.o xmenu.o window.o \
        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)
+       $(MSDOS_OBJ) $(MAC_OBJ)
 
 /* Object files used on some machine or other.
    These go in the DOC file on all machines
    in case they are needed there.  */
 SOME_MACHINE_OBJECTS = sunfns.o dosfns.o msdos.o \
-  xterm.o xfns.o xmenu.o xselect.o xrdb.o xsmfns.o
+  xterm.o xfns.o xmenu.o xselect.o xrdb.o \
+  mac.o macterm.o macfns.o macmenu.o
 
 
 #ifdef TERMINFO
@@ -1168,6 +1182,38 @@ composite.o: composite.c buffer.h  charset.h $(INTERVAL_SRC) $(config_h)
 
 sunfns.o: sunfns.c buffer.h window.h dispextern.h $(config_h)
 
+#ifdef HAVE_CARBON
+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: macgui.h
+mac.o: mac.c process.h sysselect.h systime.h $(config_h)
+macfns.o: macfns.c charset.h macterm.h macgui.h frame.h window.h buffer.h \
+  dispextern.h macgui.h fontset.h $(INTERVAL_SRC) keyboard.h blockinput.h \
+  atimer.h systime.h epaths.h termhooks.h coding.h ccl.h systime.h $(config_h)
+macmenu.o: macmenu.c termhooks.h frame.h window.h dispextern.h macgui.h \
+  keyboard.h blockinput.h atimer.h systime.h buffer.h macterm.h $(config_h)
+macterm.o: blockinput.h atimer.h systime.h syssignal.h macterm.h macgui.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)
+
+macosx-app: ${emacsapp}Contents/MacOS/Emacs \
+  ${emacsapp}Contents/Resources/Emacs.rsrc
+
+${emacsapp}Contents/MacOS/Emacs: emacs
+       if [ -d ${emacsapp}Contents/MacOS/ ]; then true; else \
+         mkdir ${emacsapp}Contents/MacOS/; \
+       fi
+       cd ${emacsapp}Contents/MacOS/; cp ../../../../src/emacs Emacs
+
+${emacsapp}Contents/Resources/Emacs.rsrc: ../mac/src/Emacs.r
+       /Developer/Tools/Rez -useDF -o \
+       ${emacsapp}Contents/Resources/Emacs.rsrc \
+       /System/Library/Frameworks/Carbon.framework/Headers/Carbon.r \
+       ../mac/src/Emacs.r
+#endif
+
 ${libsrc}emacstool: ${libsrc}emacstool.c
        cd ${libsrc}; ${MAKE} ${MFLAGS} emacstool
 bootstrapclean:
index 067dd7b..9116508 100644 (file)
@@ -1341,7 +1341,7 @@ allocate_string ()
 
 #ifdef GC_CHECK_STRING_BYTES
   if (!noninteractive
-#ifdef macintosh
+#ifdef MAC_OS8
       && current_sblock
 #endif
      )
index 92e6e47..77d8b40 100644 (file)
@@ -154,14 +154,14 @@ Lisp_Object
 call_process_cleanup (fdpid)
      Lisp_Object fdpid;
 {
-#if defined (MSDOS) || defined (macintosh)
+#if defined (MSDOS) || defined (MAC_OS8)
   /* for MSDOS fdpid is really (fd . tempfile)  */
   register Lisp_Object file;
   file = Fcdr (fdpid);
   emacs_close (XFASTINT (Fcar (fdpid)));
   if (strcmp (XSTRING (file)-> data, NULL_DEVICE) != 0)
     unlink (XSTRING (file)->data);
-#else /* not MSDOS and not macintosh */
+#else /* not MSDOS and not MAC_OS8 */
   register int pid = XFASTINT (Fcdr (fdpid));
 
   if (call_process_exited)
@@ -232,7 +232,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS)  */)
   char *outf, *tempfile;
   int outfilefd;
 #endif
-#ifdef macintosh
+#ifdef MAC_OS8
   char *tempfile;
   int outfilefd;
 #endif
@@ -440,7 +440,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS)  */)
   fd[1] = outfilefd;
 #endif /* MSDOS */
 
-#ifdef macintosh
+#ifdef MAC_OS8
   /* Since we don't have pipes on the Mac, create a temporary file to
      hold the output of the subprocess.  */
   tempfile = (char *) alloca (STRING_BYTES (XSTRING (Vtemp_file_name_pattern)) + 1);
@@ -458,14 +458,14 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS)  */)
     }
   fd[0] = filefd;
   fd[1] = outfilefd;
-#endif /* macintosh */
+#endif /* MAC_OS8 */
 
   if (INTEGERP (buffer))
     fd[1] = emacs_open (NULL_DEVICE, O_WRONLY, 0), fd[0] = -1;
   else
     {
 #ifndef MSDOS
-#ifndef macintosh
+#ifndef MAC_OS8
       errno = 0;
       if (pipe (fd) == -1)
        {
@@ -531,7 +531,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS)  */)
 
     current_dir = ENCODE_FILE (current_dir);
 
-#ifdef macintosh
+#ifdef MAC_OS8
     {
       /* Call run_mac_command in sysdep.c here directly instead of doing
          a child_setup as for MSDOS and other platforms.  Note that this
@@ -576,7 +576,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS)  */)
          report_file_error ("Cannot re-open temporary file", Qnil);
        }
     }
-#else /* not macintosh */
+#else /* not MAC_OS8 */
 #ifdef MSDOS /* MW, July 1993 */
     /* Note that on MSDOS `child_setup' actually returns the child process
        exit status, not its PID, so we assign it to `synch_process_retcode'
@@ -635,7 +635,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS)  */)
     if (fd_error >= 0)
       emacs_close (fd_error);
 #endif /* not MSDOS */
-#endif /* not macintosh */
+#endif /* not MAC_OS8 */
 
     environ = save_environ;
 
@@ -669,14 +669,14 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS)  */)
   /* Enable sending signal if user quits below.  */
   call_process_exited = 0;
 
-#if defined(MSDOS) || defined(macintosh)
+#if defined(MSDOS) || defined(MAC_OS8)
   /* MSDOS needs different cleanup information.  */
   record_unwind_protect (call_process_cleanup,
                         Fcons (make_number (fd[0]), build_string (tempfile)));
 #else
   record_unwind_protect (call_process_cleanup,
                         Fcons (make_number (fd[0]), make_number (pid)));
-#endif /* not MSDOS and not macintosh */
+#endif /* not MSDOS and not MAC_OS8 */
 
 
   if (BUFFERP (buffer))
index fe68725..e54ecc6 100644 (file)
@@ -717,6 +717,18 @@ Boston, MA 02111-1307, USA.  */
 /* Define as `fork' if `vfork' does not work. */
 #undef vfork
 
+/* Define if we should use the Carbon API on Mac OS X.  */
+#undef HAVE_CARBON
+
+#ifdef HAVE_CARBON
+#define HAVE_WINDOW_SYSTEM
+#define HAVE_MOUSE
+#define HAVE_MENUS
+#endif
+
+/* Define if we have the session management (SM) library.  */
+#undef HAVE_X_SM
+
 /* Define to empty if the keyword `volatile' does not work. Warning: valid
    code using `volatile' can become incorrect without. Disable with care. */
 #undef volatile
index 135eaec..b4442d4 100644 (file)
@@ -39,7 +39,7 @@ Boston, MA 02111-1307, USA.  */
 #include "w32gui.h"
 #endif
 
-#ifdef macintosh
+#ifdef MAC_OS
 #include "macgui.h"
 #endif
 
index f19f111..35c1b87 100644 (file)
@@ -60,9 +60,9 @@ Boston, MA 02111-1307, USA.  */
 #include "w32term.h"
 #endif /* HAVE_NTGUI */
 
-#ifdef macintosh
+#ifdef MAC_OS
 #include "macterm.h"
-#endif /* macintosh */
+#endif /* MAC_OS */
 
 /* Include systime.h after xterm.h to avoid double inclusion of time.h.  */
 
@@ -6469,7 +6469,7 @@ init_display ()
     }
 #endif /* HAVE_NTGUI */
 
-#ifdef macintosh
+#ifdef MAC_OS
   if (!inhibit_window_system) 
     {
       Vwindow_system = intern ("mac");
@@ -6477,7 +6477,7 @@ init_display ()
       adjust_frame_glyphs_initially ();
       return;
     }
-#endif /* macintosh */
+#endif /* MAC_OS */
 
   /* If no window system has been specified, try to use the terminal.  */
   if (! isatty (0))
index bfc982b..86129c6 100644 (file)
@@ -33,6 +33,12 @@ Boston, MA 02111-1307, USA.  */
 #include <unistd.h>
 #endif
 
+/* Without this, sprintf on Mac OS Classic will produce wrong
+   result.  */
+#ifdef MAC_OS8
+#include <stdio.h>
+#endif
+
 #include <ctype.h>
 
 #include "lisp.h"
index fdd5355..d0bd502 100644 (file)
@@ -793,6 +793,11 @@ main (argc, argv, envp)
     run_time_remap (argv[0]);
 #endif
 
+#ifdef MAC_OSX
+  if (!initialized)
+    unexec_init_emacs_zone ();
+#endif
+
   sort_args (argc, argv);
   argc = 0;
   while (argv[argc]) argc++;
@@ -848,6 +853,13 @@ main (argc, argv, envp)
   }
 #endif /* NeXT */
 
+#ifdef MAC_OSX
+  /* Skip process serial number passed in the form -psn_x_y as
+     command-line argument.  */
+  if (argc > skip_args + 1 && strncmp (argv[skip_args+1], "-psn_", 5) == 0)
+    skip_args++;
+#endif /* MAC_OSX */
+
 #ifdef VMS
   /* If -map specified, map the data file in.  */
   {
@@ -1175,12 +1187,12 @@ main (argc, argv, envp)
         CANNOT_DUMP is defined.  */
       syms_of_keyboard ();
 
-#ifdef macintosh
+#ifdef MAC_OS8
       /* init_window_once calls make_terminal_frame which on Mac OS
          creates a full-fledge output_mac type frame.  This does not
          work correctly before syms_of_textprop, syms_of_macfns,
          syms_of_ccl, syms_of_fontset, syms_of_xterm, syms_of_search,
-         syms_of_frame, x_term_init, and init_keyboard have already
+         syms_of_frame, mac_initialize, and init_keyboard have already
          been called.  */
       syms_of_textprop ();
       syms_of_macfns ();
@@ -1192,7 +1204,7 @@ main (argc, argv, envp)
       syms_of_search ();
       syms_of_frame ();
 
-      x_term_init ();
+      mac_initialize ();
       init_keyboard ();
 #endif
 
@@ -1388,8 +1400,8 @@ main (argc, argv, envp)
       /* The basic levels of Lisp must come first.  */
       /* And data must come first of all
         for the sake of symbols like error-message.  */
-#ifndef macintosh
-      /* Called before init_window_once for Mac OS.  */
+#ifndef MAC_OS8
+      /* Called before init_window_once for Mac OS Classic.  */
       syms_of_data ();
 #endif
       syms_of_alloc ();
@@ -1407,8 +1419,8 @@ main (argc, argv, envp)
       syms_of_casetab ();
       syms_of_callproc ();
       syms_of_category ();
-#ifndef macintosh
-      /* Called before init_window_once for Mac OS.  */
+#ifndef MAC_OS8
+      /* Called before init_window_once for Mac OS Classic.  */
       syms_of_ccl ();
 #endif
       syms_of_charset ();
@@ -1432,8 +1444,8 @@ main (argc, argv, envp)
       syms_of_marker ();
       syms_of_minibuf ();
       syms_of_process ();
-#ifndef macintosh
-      /* Called before init_window_once for Mac OS.  */
+#ifndef MAC_OS8
+      /* Called before init_window_once for Mac OS Classic.  */
       syms_of_search ();
       syms_of_frame ();
 #endif
@@ -1443,8 +1455,8 @@ main (argc, argv, envp)
 #ifdef HAVE_SOUND
       syms_of_sound ();
 #endif
-#ifndef macintosh
-      /* Called before init_window_once for Mac OS.  */
+#ifndef MAC_OS8
+      /* Called before init_window_once for Mac OS Classic.  */
       syms_of_textprop ();
 #endif
       syms_of_composite ();
@@ -1469,7 +1481,8 @@ main (argc, argv, envp)
 #endif /* HAVE_X_WINDOWS */
 
 #ifndef HAVE_NTGUI
-#ifndef macintosh
+#ifndef MAC_OS
+      /* Called before init_window_once for Mac OS Classic.  */
       syms_of_xmenu ();
 #endif
 #endif
@@ -1482,6 +1495,13 @@ main (argc, argv, envp)
       syms_of_fontset ();
 #endif /* HAVE_NTGUI */
 
+#ifdef HAVE_CARBON
+      syms_of_macterm ();
+      syms_of_macfns ();
+      syms_of_macmenu ();
+      syms_of_fontset ();
+#endif /* HAVE_CARBON */
+
 #ifdef SYMS_SYSTEM
       SYMS_SYSTEM;
 #endif
@@ -1506,8 +1526,8 @@ main (argc, argv, envp)
 #endif /* VMS */
       init_display (); /* Determine terminal type.  init_sys_modes uses results.  */
     }
-#ifndef macintosh
-  /* Called before init_window_once for Mac OS.  */
+#ifndef MAC_OS8
+  /* Called before init_window_once for Mac OS Classic.  */
   init_keyboard ();    /* This too must precede init_sys_modes.  */
 #endif
 #ifdef VMS
index 30bec52..6679b1f 100644 (file)
@@ -1410,10 +1410,10 @@ syms_of_fontset ()
   FONTSET_ID (Vdefault_fontset) = make_number (0);
   FONTSET_NAME (Vdefault_fontset)
     = build_string ("-*-*-*-*-*-*-*-*-*-*-*-*-fontset-default");
-#if defined (macintosh)
+#if defined (MAC_OS)
   FONTSET_ASCII (Vdefault_fontset)
     = Fcons (make_number (0),
-            build_string ("-apple-monaco-medium-r-*--*-120-*-*-*-*-mac-roman"));
+            build_string ("-ETL-fixed-medium-r-*--*-160-*-*-*-*-iso8859-1"));
 #elif defined (WINDOWSNT)
   FONTSET_ASCII (Vdefault_fontset)
     = Fcons (make_number (0),
index 5525e2a..795183b 100644 (file)
@@ -30,7 +30,7 @@ Boston, MA 02111-1307, USA.  */
 #ifdef WINDOWSNT
 #include "w32term.h"
 #endif
-#ifdef macintosh
+#ifdef MAC_OS
 #include "macterm.h"
 #endif
 #include "buffer.h"
@@ -486,11 +486,11 @@ make_terminal_frame ()
   f->output_method = output_termcap;
   f->output_data.x = &tty_display;
 #else
-#ifdef macintosh
+#ifdef MAC_OS8
   make_mac_terminal_frame (f);
 #else
   f->output_data.x = &tty_display;
-#endif /* macintosh */
+#endif /* MAC_OS8 */
 #endif /* WINDOWSNT */
 #endif /* MSDOS */
 
@@ -521,7 +521,7 @@ Note that changing the size of one terminal frame automatically affects all.  */
     abort ();
 #else /* not MSDOS */
 
-#ifdef macintosh
+#ifdef MAC_OS
   if (sf->output_method != output_mac)
     error ("Not running on a Macintosh screen; cannot make a new Macintosh frame");
 #else
@@ -1112,7 +1112,7 @@ frame.  The hook is called with one argument FRAME.  */)
     return Qnil;
 
   if (NILP (force) && !other_visible_frames (f)
-#ifdef macintosh
+#ifdef MAC_OS8
       /* Terminal frame deleted before any other visible frames are
         created.  */
       && strcmp (XSTRING (f->name)->data, "F1") != 0
index bcfb208..9f6f647 100644 (file)
@@ -57,7 +57,7 @@ enum vertical_scroll_bar_type
   vertical_scroll_bar_right
 };
 
-#if !defined(MSDOS) && !defined(WINDOWSNT) && !defined(macintosh)
+#if !defined(MSDOS) && !defined(WINDOWSNT) && !defined(MAC_OS)
 
 #if !defined(HAVE_X_WINDOWS)
 
@@ -82,7 +82,7 @@ struct x_output
 /* A structure describing a termcap frame display.  */
 extern struct x_output tty_display;
 
-#endif /* ! MSDOS && ! WINDOWSNT && ! macintosh */
+#endif /* ! MSDOS && ! WINDOWSNT && ! MAC_OS */
 
 struct frame
 {
@@ -260,7 +260,7 @@ struct frame
   /* Number of lines of menu bar.  */
   int menu_bar_lines;
 
-#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (macintosh)
+#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (MAC_OS)
   /* Nonzero means using a menu bar that comes from the X toolkit.  */
   int external_menu_bar;
 #endif
@@ -404,7 +404,7 @@ typedef struct frame *FRAME_PTR;
 #ifdef HAVE_NTGUI
 #define FRAME_WINDOW_P(f) FRAME_W32_P (f)
 #endif
-#ifdef macintosh
+#ifdef MAC_OS
 #define FRAME_WINDOW_P(f) FRAME_MAC_P (f)
 #endif
 #ifndef FRAME_WINDOW_P
@@ -444,7 +444,7 @@ typedef struct frame *FRAME_PTR;
 
 /* 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 (macintosh)
+#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (MAC_OS)
 #define FRAME_EXTERNAL_MENU_BAR(f) (f)->external_menu_bar
 #else
 #define FRAME_EXTERNAL_MENU_BAR(f) 0
index cd3aa37..d1c3681 100644 (file)
@@ -71,7 +71,7 @@ Boston, MA 02111-1307, USA.  */
 #include "w32term.h"
 #endif /* HAVE_NTGUI */
 
-#ifdef macintosh
+#ifdef MAC_OS
 #include "macterm.h"
 #endif
 
@@ -94,8 +94,8 @@ extern int input_fd;
 
 #ifdef HAVE_WINDOW_SYSTEM
 /* Make all keyboard buffers much bigger when using X windows.  */
-#ifdef macintosh
-/* But not too big (local data > 32K error) if on macintosh.  */
+#ifdef MAC_OS8
+/* But not too big (local data > 32K error) if on Mac OS Classic.  */
 #define KBD_BUFFER_SIZE 512
 #else
 #define KBD_BUFFER_SIZE 4096
@@ -3687,7 +3687,7 @@ kbd_buffer_get_event (kbp, used_mouse_menu)
          abort ();
 #endif
        }
-#if defined (HAVE_X11) || defined (HAVE_NTGUI) || defined (macintosh)
+#if defined (HAVE_X11) || defined (HAVE_NTGUI) || defined (MAC_OS)
       else if (event->kind == delete_window_event)
        {
          /* Make an event (delete-frame (FRAME)).  */
@@ -3718,7 +3718,7 @@ kbd_buffer_get_event (kbp, used_mouse_menu)
          XSETBUFFER (obj, current_buffer);
          kbd_fetch_ptr = event + 1;
        }
-#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (macintosh)
+#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (MAC_OS)
       else if (event->kind == menu_bar_activate_event)
        {
          kbd_fetch_ptr = event + 1;
@@ -5373,7 +5373,7 @@ make_lispy_event (event)
       }
 #endif /* HAVE_MOUSE */
 
-#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (macintosh)
+#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (MAC_OS)
     case MENU_BAR_EVENT:
       if (EQ (event->arg, event->frame_or_window))
        /* This is the prefix key.  We translate this to
diff --git a/src/m/powermac.h b/src/m/powermac.h
new file mode 100644 (file)
index 0000000..0f54d18
--- /dev/null
@@ -0,0 +1,121 @@
+/* Machine description file for Apple Power Macintosh
+   Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Emacs.
+
+GNU Emacs is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Emacs is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Emacs; see the file COPYING.  If not, write to
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
+
+
+/* The following line tells the configuration script what sort of 
+   operating system this machine is likely to run.
+   USUAL-OPSYS="darwin"  */
+
+/* Define WORDS_BIG_ENDIAN iff lowest-numbered byte in a word
+   is the most significant byte.  */
+
+#define WORDS_BIG_ENDIAN
+
+/* Define NO_ARG_ARRAY if you cannot take the address of the first of a
+ * group of arguments and treat it as an array of the arguments.  */
+
+#define NO_ARG_ARRAY
+
+/* Define WORD_MACHINE if addresses and such have
+ * to be corrected before they can be used as byte counts.  */
+
+/* #define WORD_MACHINE */
+
+/* Now define a symbol for the cpu type, if your compiler
+   does not define it automatically:
+   Ones defined so far include vax, m68000, ns16000, pyramid,
+   orion, tahoe, APOLLO and many others */
+
+/* Use type int rather than a union, to represent Lisp_Object */
+/* This is desirable for most machines.  */
+
+#define NO_UNION_TYPE
+
+/* Define EXPLICIT_SIGN_EXTEND if XINT must explicitly sign-extend
+   the 24-bit bit field into an int.  In other words, if bit fields
+   are always unsigned.
+
+   If you use NO_UNION_TYPE, this flag does not matter.  */
+
+/* #define EXPLICIT_SIGN_EXTEND */
+
+/* Data type of load average, as read out of kmem.  */
+
+#define LOAD_AVE_TYPE long
+
+/* Convert that into an integer that is 100 for a load average of 1.0  */
+
+#define LOAD_AVE_CVT(x) (int) (((double) (x)) * 100.0 / FSCALE)
+
+/* Define CANNOT_DUMP on machines where unexec does not work.
+   Then the function dump-emacs will not be defined
+   and temacs will do (load "loadup") automatically unless told otherwise.  */
+
+/* #define CANNOT_DUMP */
+
+/* Define VIRT_ADDR_VARIES if the virtual addresses of
+   pure and impure space as loaded can vary, and even their
+   relative order cannot be relied on.
+
+   Otherwise Emacs assumes that text space precedes data space,
+   numerically.  */
+
+/* #define VIRT_ADDR_VARIES * */
+
+/* Define C_ALLOCA if this machine does not support a true alloca
+   and the one written in C should be used instead.
+   Define HAVE_ALLOCA to say that the system provides a properly
+   working alloca function and it should be used.
+   Define neither one if an assembler-language alloca
+   in the file alloca.s should be used.  */
+
+/* #define C_ALLOCA */
+/* #define HAVE_ALLOCA */
+
+/* Define NO_REMAP if memory segmentation makes it not work well
+   to change the boundary between the text section and data section
+   when Emacs is dumped.  If you define this, the preloaded Lisp
+   code will not be sharable; but that's better than failing completely.  */
+
+#define NO_REMAP
+
+/* Some really obscure 4.2-based systems (like Sequent DYNIX)
+ * do not support asynchronous I/O (using SIGIO) on sockets,
+ * even though it works fine on tty's.  If you have one of
+ * these systems, define the following, and then use it in
+ * config.h (or elsewhere) to decide when (not) to use SIGIO.
+ *
+ * You'd think this would go in an operating-system description file,
+ * but since it only occurs on some, but not all, BSD systems, the
+ * reasonable place to select for it is in the machine description
+ * file.
+ */
+
+/* #define NO_SOCK_SIGIO */
+
+
+/* After adding support for a new system, modify the large case
+   statement in the `configure' script to recognize reasonable
+   configuration names, and add a description of the system to
+   `etc/MACHINES'.
+
+   If you've just fixed a problem in an existing configuration file,
+   you should also check `etc/MACHINES' to make sure its descriptions
+   of known problems in that configuration should be updated.  */
similarity index 91%
rename from mac/src/mac.c
rename to src/mac.c
index 473273f..4e6ee4b 100644 (file)
+++ b/src/mac.c
@@ -1,5 +1,5 @@
 /* Unix emulation routines for GNU Emacs on the Mac OS.
-   Copyright (C) 2000 Free Software Foundation, Inc.
+   Copyright (C) 2000, 2001 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -18,7 +18,7 @@ along with GNU Emacs; see the file COPYING.  If not, write to
 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
-/* Contributed by Andrew Choi (akochoi@users.sourceforge.net).  */
+/* Contributed by Andrew Choi (akochoi@mac.com).  */
 
 #include <config.h>
 
@@ -34,6 +34,20 @@ Boston, MA 02111-1307, USA.  */
 #include <unistd.h>
 #endif
 
+#ifdef MAC_OSX
+#undef mktime
+#undef DEBUG
+#undef free
+#undef malloc
+#undef realloc
+#include <Carbon/Carbon.h>
+#undef free
+#define free unexec_free
+#undef malloc
+#define malloc unexec_malloc
+#undef realloc
+#define realloc unexec_realloc
+#else /* not MAC_OSX */
 #include <Files.h>
 #include <MacTypes.h>
 #include <TextUtils.h>
@@ -44,6 +58,8 @@ Boston, MA 02111-1307, USA.  */
 #include <Timer.h>
 #include <OSA.h>
 #include <AppleScript.h>
+#include <Scrap.h>
+#endif /* not MAC_OSX */
 
 #include "lisp.h"
 #include "process.h"
@@ -81,13 +97,13 @@ string_cat_and_replace (char *s1, const char *s2, int n, char a, char b)
 }
 
 
-/* Convert a Mac pathname to Unix form.  A Mac full pathname is one
+/* Convert a Mac pathname to Posix form.  A Mac full pathname is one
    that does not begin with a ':' and contains at least one ':'. A Mac
-   full pathname causes an '/' to be prepended to the Unix pathname.
+   full pathname causes an '/' to be prepended to the Posix pathname.
    The algorithm for the rest of the pathname is as follows:
      For each segment between two ':',
        if it is non-null, copy as is and then add a '/' at the end,
-       otherwise, insert a "../" into the Unix pathname.
+       otherwise, insert a "../" into the Posix pathname.
    Returns 1 if successful; 0 if fails.  */
    
 int
@@ -146,7 +162,7 @@ mac_to_posix_pathname (const char *mfn, char *ufn, int ufnbuflen)
 extern char *get_temp_dir_name ();
 
 
-/* Convert a Unix pathname to Mac form.  Approximately reverse of the
+/* Convert a Posix pathname to Mac form.  Approximately reverse of the
    above in algorithm.  */
    
 int
@@ -235,6 +251,7 @@ posix_to_mac_pathname (const char *ufn, char *mfn, int mfnbuflen)
   return 1;
 }
 
+#ifndef MAC_OSX
 
 /* The following functions with "sys_" prefix are stubs to Unix
    functions that have already been implemented by CW or MPW.  The
@@ -250,21 +267,21 @@ posix_to_mac_pathname (const char *ufn, char *mfn, int mfnbuflen)
 #define MAC_UNIX_EPOCH_DIFF  ((365L * 66 + 17) * 24 * 60 * 60)
 
 #ifdef __MWERKS__
-#ifndef CODEWARRIOR_VERSION_6
+#if __MSL__ < 0x6000
 /* CW Pro 5 epoch is Jan 1, 1900 (aaarghhhhh!); remember, 1900 is not
    a leap year!  This is for adjusting time_t values returned by MSL
    functions.  */
 #define CW_OR_MPW_UNIX_EPOCH_DIFF ((365L * 70 + 17) * 24 * 60 * 60)
-#else
-/* CW changes Pro 6 to following Unix!  */
+#else /* __MSL__ >= 0x6000 */
+/* CW changes Pro 6 to follow Unix!  */
 #define CW_OR_MPW_UNIX_EPOCH_DIFF ((365L * 66 + 17) * 24 * 60 * 60)
-#endif
+#endif /* __MSL__ >= 0x6000 */
 #elif __MRC__
 /* MPW library functions follow Unix (confused?).  */
 #define CW_OR_MPW_UNIX_EPOCH_DIFF ((365L * 66 + 17) * 24 * 60 * 60)
-#else
+#else /* not __MRC__ */
 You lose!!!
-#endif
+#endif /* not __MRC__ */
 
 
 /* Define our own stat function for both MrC and CW.  The reason for
@@ -408,8 +425,6 @@ fstat (int fildes, struct stat *buf)
 #endif  /* __MRC__ */
 
 
-/* Adapted from Think Reference code example.  */
-
 int
 mkdir (const char *dirname, int mode)
 {
@@ -611,9 +626,9 @@ sys_open (const char *path, int oflag)
       if (oflag & O_CREAT)
         fsetfileinfo (mac_pathname, 'EMAx', 'TEXT');
       return res;
-#else
+#else /* not __MRC__ */
       return open (mac_pathname, oflag);
-#endif
+#endif /* not __MRC__ */
     }
 }
 
@@ -637,9 +652,9 @@ sys_creat (const char *path, mode_t mode)
       int result = creat (mac_pathname);
       fsetfileinfo (mac_pathname, 'EMAx', 'TEXT');
       return result;
-#else
+#else /* not __MRC__ */
       return creat (mac_pathname, mode);
-#endif
+#endif /* not __MRC__ */
     }
 }
 
@@ -675,7 +690,7 @@ sys_read (int fildes, char *buf, int count)
   if (fildes == 0)  /* this should not be used for console input */
     return -1;
   else
-#ifdef CODEWARRIOR_VERSION_6
+#if __MSL__ >= 0x6000
     return _read (fildes, buf, count);
 #else
     return read (fildes, buf, count);
@@ -690,7 +705,7 @@ sys_write (int fildes, const char *buf, int count)
   if (fildes == DEV_NULL_FD)
     return count;
   else
-#ifdef CODEWARRIOR_VERSION_6
+#if __MSL__ >= 0x6000
     return _write (fildes, buf, count);
 #else
     return write (fildes, buf, count);
@@ -764,7 +779,7 @@ sys_fopen (const char *name, const char *mode)
 #ifdef __MRC__
       if (mode[0] == 'w' || mode[0] == 'a')
         fsetfileinfo (mac_pathname, 'EMAx', 'TEXT');
-#endif
+#endif /* not __MRC__ */
       return fopen (mac_pathname, mode);
     }
 }
@@ -778,9 +793,9 @@ long target_ticks = 0;
 __sigfun alarm_signal_func = (__sigfun) 0;
 #elif __MWERKS__
 __signal_func_ptr alarm_signal_func = (__signal_func_ptr) 0;
-#else
+#else /* not __MRC__ and not __MWERKS__ */
 You lose!!!
-#endif
+#endif /* not __MRC__ and not __MWERKS__ */
 
 
 /* These functions simulate SIG_ALRM.  The stub for function signal
@@ -804,13 +819,16 @@ check_alarm ()
 
 
 int
-select(n,  rfds, wfds, efds, timeout)
+select (n,  rfds, wfds, efds, timeout)
   int n;
   SELECT_TYPE *rfds;
   SELECT_TYPE *wfds;
   SELECT_TYPE *efds;
   struct timeval *timeout;
 {
+#ifdef TARGET_API_MAC_CARBON
+  return 1;
+#else /* not TARGET_API_MAC_CARBON */
   EMACS_TIME end_time, now;
   EventRecord e;
 
@@ -844,7 +862,8 @@ select(n,  rfds, wfds, efds, timeout)
           }
       }
       
-      WaitNextEvent (0, &e, 1UL, NULL);        /* Accept no event; wait 1 tic. by T.I.*/
+      WaitNextEvent (0, &e, 1UL, NULL);        /* Accept no event; wait 1
+                                          tic. by T.I. */
       
       EMACS_GET_TIME (now);
       EMACS_SUB_TIME (now, end_time, now);
@@ -852,6 +871,7 @@ select(n,  rfds, wfds, efds, timeout)
   while (!EMACS_TIME_NEG_P (now));
 
   return 0;
+#endif /* not TARGET_API_MAC_CARBON */
 }
 
 
@@ -866,8 +886,9 @@ pause ()
   if (!target_ticks)  /* no alarm pending */
     return -1;
 
-  if ( (tick = TickCount ()) < target_ticks )
-    WaitNextEvent (0, &e, target_ticks - tick, NULL);  /* Accept no event; just wait. by T.I.*/
+  if ((tick = TickCount ()) < target_ticks)
+    WaitNextEvent (0, &e, target_ticks - tick, NULL); /* Accept no event;
+                                                        just wait. by T.I. */
   
   target_ticks = 0;
   if (alarm_signal_func)
@@ -897,9 +918,9 @@ sys_signal (int signal_num, __sigfun signal_func)
 extern __signal_func_ptr signal (int signal, __signal_func_ptr signal_func);
 __signal_func_ptr
 sys_signal (int signal_num, __signal_func_ptr signal_func)
-#else
+#else /* not __MRC__ and not __MWERKS__ */
      You lose!!!
-#endif
+#endif /* not __MRC__ and not __MWERKS__ */
 {
   if (signal_num != SIGALRM)
     return signal (signal_num, signal_func);
@@ -1003,7 +1024,7 @@ extern struct tm *localtime (const time_t *);
 struct tm *
 sys_localtime (const time_t *timer)
 {
-#ifdef CODEWARRIOR_VERSION_6
+#if __MSL__ >= 0x6000
   time_t unix_time = *timer;
 #else
   time_t unix_time = *timer + CW_OR_MPW_UNIX_EPOCH_DIFF;
@@ -1018,7 +1039,7 @@ extern char *ctime (const time_t *);
 char *
 sys_ctime (const time_t *timer)
 {
-#ifdef CODEWARRIOR_VERSION_6
+#if __MSL__ >= 0x6000
   time_t unix_time = *timer;
 #else
   time_t unix_time = *timer + CW_OR_MPW_UNIX_EPOCH_DIFF;
@@ -1033,7 +1054,7 @@ extern time_t time (time_t *);
 time_t
 sys_time (time_t *timer)
 {
-#ifdef CODEWARRIOR_VERSION_6
+#if __MSL__ >= 0x6000
   time_t mac_time = time (NULL);
 #else
   time_t mac_time = time (NULL) - CW_OR_MPW_UNIX_EPOCH_DIFF;
@@ -1333,6 +1354,7 @@ link (const char *name1, const char *name2)
   return -1;
 }
 
+#endif  /* ! MAC_OSX */
 
 /* Determine the path name of the file specified by VREFNUM, DIRID,
    and NAME and place that in the buffer PATH of length
@@ -1381,6 +1403,7 @@ path_from_vol_dir_name (char *path, int man_path_len, short vol_ref_num,
   return 1;  /* success */
 }
 
+#ifndef MAC_OSX
 
 int
 readlink (const char *path, char *buf, int bufsiz)
@@ -1593,7 +1616,7 @@ geteuid ()
 
 
 #ifdef __MWERKS__
-#ifndef CODEWARRIOR_VERSION_6
+#if __MSL__ < 0x6000
 #undef getpid
 int
 getpid ()
@@ -1603,6 +1626,8 @@ getpid ()
 #endif
 #endif /* __MWERKS__ */
 
+#endif /* ! MAC_OSX */
+
 
 /* Return the path to the directory in which Emacs can create
    temporary files.  The MacOS "temporary items" directory cannot be
@@ -1613,7 +1638,7 @@ getpid ()
    directory "Emacs" in the Preferences Folder.  This directory is
    created if it does not exist.  */
 
-static char *
+char *
 get_temp_dir_name ()
 {
   static char *temp_dir_name = NULL;
@@ -1658,6 +1683,7 @@ get_temp_dir_name ()
   return temp_dir_name;
 }
 
+#ifndef MAC_OSX
 
 /* Allocate and construct an array of pointers to strings from a list
    of strings stored in a 'STR#' resource.  The returned pointer array
@@ -1725,7 +1751,8 @@ get_path_to_system_folder ()
   if (!path_from_vol_dir_name (full_path, 255, vol_ref_num, dir_id, "\p"))
     return NULL;
 
-  if (!mac_to_posix_pathname (full_path, system_folder_unix_name, MAXPATHLEN+1))
+  if (!mac_to_posix_pathname (full_path, system_folder_unix_name,
+                             MAXPATHLEN+1))
     return NULL;
     
   return system_folder_unix_name;
@@ -1831,9 +1858,9 @@ char *sys_siglist[] =
   "Segment violation",
   "Terminal"
 };
-#else
+#else /* not __MRC__ and not __MWERKS__ */
 You lose!!!
-#endif
+#endif /* not __MRC__ and not __MWERKS__ */
 
 
 #include <utsname.h>
@@ -1928,6 +1955,9 @@ run_mac_command (argv, workdir, infn, outfn, errfn)
      const char *workdir;
      const char *infn, *outfn, *errfn;
 {
+#ifdef TARGET_API_MAC_CARBON
+  return -1;
+#else /* not TARGET_API_MAC_CARBON */
   char macappname[MAXPATHLEN+1], macworkdir[MAXPATHLEN+1];
   char macinfn[MAXPATHLEN+1], macoutfn[MAXPATHLEN+1], macerrfn[MAXPATHLEN+1];
   int paramlen, argc, newargc, j, retries;
@@ -2008,9 +2038,9 @@ run_mac_command (argv, workdir, infn, outfn, errfn)
          char *t = (char *) alloca (strlen (newargv[0]) + 7 + 1);
          strcpy (t, "~emacs/");
          strcat (t, newargv[0]);
-#endif
+#endif /* 0 */
          Lisp_Object path;
-         openp (Vexec_path, build_string (newargv[0]), Vexec_suffixes, &path,
+         openp (Vexec_path, build_string (newargv[0]), EXEC_SUFFIXES, &path,
                 1);
 
          if (NILP (path))
@@ -2158,6 +2188,7 @@ run_mac_command (argv, workdir, infn, outfn, errfn)
   free (param);
 
   return ref_con;
+#endif /* not TARGET_API_MAC_CARBON */
 }
 
 
@@ -2360,6 +2391,8 @@ getwd (char *path)
     return path;
 }
 
+#endif  /* ! MAC_OSX */
+
 
 void
 initialize_applescript ()
@@ -2423,6 +2456,15 @@ do_applescript (char *script, char **result)
       if (!OSAScriptError (as_scripting_component, kOSAErrorMessage, typeChar,
                           &error_desc))
         {
+#if TARGET_API_MAC_CARBON
+          length = AEGetDescDataSize (&error_desc);
+          *result = (char *) xmalloc (length + 1);
+          if (*result)
+            {
+              AEGetDescData (&error_desc, *result, length);
+              *(*result + length) = '\0';
+            }
+#else /* not TARGET_API_MAC_CARBON */
           HLock (error_desc.dataHandle);
           length = GetHandleSize(error_desc.dataHandle);
           *result = (char *) xmalloc (length + 1);
@@ -2432,11 +2474,21 @@ do_applescript (char *script, char **result)
               *(*result + length) = '\0';
             }
           HUnlock (error_desc.dataHandle);
+#endif /* not TARGET_API_MAC_CARBON */
           AEDisposeDesc (&error_desc);
         }
     }
   else if (osaerror == noErr)  /* success: retrieve resulting script value */
     {
+#if TARGET_API_MAC_CARBON
+      length = AEGetDescDataSize (&result_desc);
+      *result = (char *) xmalloc (length + 1);
+      if (*result)
+        {
+          AEGetDescData (&result_desc, *result, length);
+          *(*result + length) = '\0';
+        }
+#else /* not TARGET_API_MAC_CARBON */
       HLock (result_desc.dataHandle);
       length = GetHandleSize(result_desc.dataHandle);
       *result = (char *) xmalloc (length + 1);
@@ -2446,6 +2498,7 @@ do_applescript (char *script, char **result)
           *(*result + length) = '\0';
         }
       HUnlock (result_desc.dataHandle);
+#endif /* not TARGET_API_MAC_CARBON */
     }
 
   AEDisposeDesc (&script_desc);
@@ -2456,11 +2509,11 @@ do_applescript (char *script, char **result)
 
 
 DEFUN ("do-applescript", Fdo_applescript, Sdo_applescript, 1, 1, 0,
-    "Compile and execute AppleScript SCRIPT and retrieve and return the\n\
-result.  If compilation and execution are successful, the resulting script\n\
-value is returned as a string.  Otherwise the function aborts and\n\
-displays the error message returned by the AppleScript scripting\n\
-component.")
+       doc: /* Compile and execute AppleScript SCRIPT and retrieve and return the result.
+If compilation and execution are successful, the resulting script
+value is returned as a string.  Otherwise the function aborts and
+displays the error message returned by the AppleScript scripting
+component.  */)
   (script)
     Lisp_Object script;
 {
@@ -2468,7 +2521,7 @@ component.")
   Lisp_Object lisp_result;
   long status;
 
-  CHECK_STRING (script, 0);
+  CHECK_STRING (script);
   
   status = do_applescript (XSTRING (script)->data, &result);
   if (status)
@@ -2497,15 +2550,15 @@ component.")
 }
 
 
-DEFUN ("mac-file-name-to-posix", Fmac_file_name_to_posix, Smac_file_name_to_posix, 1,
-       1, 0,
-    "Convert Macintosh filename to Posix form.")
-  (mac_filename)
-    Lisp_Object mac_filename;
+DEFUN ("mac-file-name-to-posix", Fmac_file_name_to_posix,
+       Smac_file_name_to_posix, 1, 1, 0,
+       doc: /* Convert Macintosh filename to Posix form.  */)
+     (mac_filename)
+     Lisp_Object mac_filename;
 {
   char posix_filename[MAXPATHLEN+1];
 
-  CHECK_STRING (mac_filename, 0);
+  CHECK_STRING (mac_filename);
   
   if (mac_to_posix_pathname (XSTRING (mac_filename)->data, posix_filename,
                           MAXPATHLEN))
@@ -2515,15 +2568,15 @@ DEFUN ("mac-file-name-to-posix", Fmac_file_name_to_posix, Smac_file_name_to_posi
 }
 
 
-DEFUN ("posix-file-name-to-mac", Fposix_file_name_to_mac, Sposix_file_name_to_mac, 1,
-       1, 0,
-    "Convert Unix filename to Mac form.")
-  (posix_filename)
-    Lisp_Object posix_filename;
+DEFUN ("posix-file-name-to-mac", Fposix_file_name_to_mac,
+       Sposix_file_name_to_mac, 1, 1, 0,
+       doc: /* Convert Posix filename to Mac form.  */)
+     (posix_filename)
+     Lisp_Object posix_filename;
 {
   char mac_filename[MAXPATHLEN+1];
 
-  CHECK_STRING (posix_filename, 0);
+  CHECK_STRING (posix_filename);
   
   if (posix_to_mac_pathname (XSTRING (posix_filename)->data, mac_filename,
                           MAXPATHLEN))
@@ -2536,9 +2589,39 @@ DEFUN ("posix-file-name-to-mac", Fposix_file_name_to_mac, Sposix_file_name_to_ma
 /* set interprogram-paste-function to mac-paste-function in mac-win.el
    to enable Emacs to obtain the contents of the Mac clipboard. */
 DEFUN ("mac-paste-function", Fmac_paste_function, Smac_paste_function, 0, 0, 0,
-    "Return the contents of the Mac clipboard as a string.")
-  ()
+       doc: /* Return the contents of the Mac clipboard as a string.  */)
+     ()
 {
+#if TARGET_API_MAC_CARBON
+  ScrapRef scrap;
+  ScrapFlavorFlags sff;
+  Size s;
+  int i;
+  char *data;
+
+  if (GetCurrentScrap (&scrap) != noErr)
+    return Qnil;
+
+  if (GetScrapFlavorFlags (scrap, kScrapFlavorTypeText, &sff) != noErr)
+    return Qnil;
+
+  if (GetScrapFlavorSize (scrap, kScrapFlavorTypeText, &s) != noErr)
+    return Qnil;
+
+  if ((data = (char*) alloca (s)) == NULL)
+    return Qnil;
+
+  if (GetScrapFlavorData (scrap, kScrapFlavorTypeText, &s, data) != noErr
+      || s == 0)
+    return Qnil;
+  
+  /* Emacs expects clipboard contents have Unix-style eol's */
+  for (i = 0; i < s; i++)
+    if (data[i] == '\r')
+      data[i] = '\n';
+
+  return make_string (data, s);
+#else /* not TARGET_API_MAC_CARBON */
   Lisp_Object value;
   Handle my_handle;
   long scrap_offset, rc, i;
@@ -2563,13 +2646,14 @@ DEFUN ("mac-paste-function", Fmac_paste_function, Smac_paste_function, 0, 0, 0,
   DisposeHandle (my_handle);
 
   return value;
+#endif /* not TARGET_API_MAC_CARBON */
 }
 
 
 /* set interprogram-cut-function to mac-cut-function in mac-win.el
    to enable Emacs to write the top of the kill-ring to the Mac clipboard. */
 DEFUN ("mac-cut-function", Fmac_cut_function, Smac_cut_function, 1, 2, 0,
-    "Put the value of the string parameter to the Mac clipboard.")
+       doc: /* Put the value of the string parameter to the Mac clipboard.  */)
   (value, push)
     Lisp_Object value, push;
 {
@@ -2578,36 +2662,50 @@ DEFUN ("mac-cut-function", Fmac_cut_function, Smac_cut_function, 1, 2, 0,
 
   /* fixme: ignore the push flag for now */
 
-  CHECK_STRING (value, 0);
+  CHECK_STRING (value);
   
   len = XSTRING (value)->size;
-  buf = (char *) alloca (len);
-  bcopy(XSTRING (value)->data, buf, len);
+  buf = (char *) alloca (len+1);
+  bcopy (XSTRING (value)->data, buf, len);
+  buf[len] = '\0';
   
   /* convert to Mac-style eol's before sending to clipboard */
   for (i = 0; i < len; i++)
     if (buf[i] == '\n')
       buf[i] = '\r';
 
+#if TARGET_API_MAC_CARBON
+  {
+    ScrapRef scrap;
+    ClearCurrentScrap ();
+    if (GetCurrentScrap (&scrap) != noErr)
+      error ("cannot get current scrap");
+
+    if (PutScrapFlavor (scrap, kScrapFlavorTypeText, kScrapFlavorMaskNone, len,
+                       buf) != noErr)
+      error ("cannot put to scrap");
+  }
+#else /* not TARGET_API_MAC_CARBON */
   ZeroScrap ();
   PutScrap (len, 'TEXT', buf);
+#endif /* not TARGET_API_MAC_CARBON */
   
   return Qnil;
 }
 
 
 DEFUN ("x-selection-exists-p", Fx_selection_exists_p, Sx_selection_exists_p,
-  0, 1, 0,
-  "Whether there is an owner for the given X Selection.\n\
-The arg should be the name of the selection in question, typically one of\n\
-the symbols `PRIMARY', `SECONDARY', or `CLIPBOARD'.\n\
-\(Those are literal upper-case symbol names, since that's what X expects.)\n\
-For convenience, the symbol nil is the same as `PRIMARY',\n\
-and t is the same as `SECONDARY'.")
+       0, 1, 0,
+       doc: /* Whether there is an owner for the given X Selection.
+The arg should be the name of the selection in question, typically one of
+the symbols `PRIMARY', `SECONDARY', or `CLIPBOARD'.
+(Those are literal upper-case symbol names, since that's what X expects.)
+For convenience, the symbol nil is the same as `PRIMARY',
+and t is the same as `SECONDARY'.  */)
   (selection)
      Lisp_Object selection;
 {
-  CHECK_SYMBOL (selection, 0);
+  CHECK_SYMBOL (selection);
 
   /* Return nil for PRIMARY and SECONDARY selections; for CLIPBOARD, check
      if the clipboard currently has valid text format contents. */
@@ -2615,7 +2713,15 @@ and t is the same as `SECONDARY'.")
   if (EQ (selection, QCLIPBOARD))
     {
       Lisp_Object val = Qnil;
-      Lisp_Object value;
+
+#if TARGET_API_MAC_CARBON
+      ScrapRef scrap;
+      ScrapFlavorFlags sff;
+
+      if (GetCurrentScrap (&scrap) == noErr)
+        if (GetScrapFlavorFlags (scrap, kScrapFlavorTypeText, &sff) == noErr)
+          val = Qt;
+#else /* not TARGET_API_MAC_CARBON */
       Handle my_handle;
       long rc, scrap_offset;
 
@@ -2626,6 +2732,7 @@ and t is the same as `SECONDARY'.")
         val = Qt;
 
       DisposeHandle (my_handle);
+#endif /* not TARGET_API_MAC_CARBON */
 
       return val;
     }
@@ -2641,7 +2748,9 @@ syms_of_mac ()
   
   defsubr (&Smac_paste_function);
   defsubr (&Smac_cut_function);
+#if 0
   defsubr (&Sx_selection_exists_p);
+#endif /* 0 */
 
   defsubr (&Sdo_applescript);
   defsubr (&Smac_file_name_to_posix);
similarity index 94%
rename from mac/src/macfns.c
rename to src/macfns.c
index fc0cf27..a4235d7 100644 (file)
@@ -1,5 +1,5 @@
 /* Graphical user interface functions for Mac OS.
-   Copyright (C) 2000 Free Software Foundation, Inc.
+   Copyright (C) 2000, 2001 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -18,7 +18,7 @@ along with GNU Emacs; see the file COPYING.  If not, write to
 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
-/* Contributed by Andrew Choi (akochoi@users.sourceforge.net).  */
+/* Contributed by Andrew Choi (akochoi@mac.com).  */
 
 #include <config.h>
 
@@ -57,24 +57,41 @@ static unsigned char gray_bits[] = {
 
 #include <stdlib.h>
 #include <string.h>
+#ifndef MAC_OSX
 #include <alloca.h>
-#if 0
-#include <unistd.h>
 #endif
 
+#ifdef MAC_OSX
+#undef mktime
+#undef DEBUG
+#undef Z
+#undef free
+#undef malloc
+#undef realloc
+/* Macros max and min defined in lisp.h conflict with those in
+   precompiled header Carbon.h.  */
+#undef max
+#undef min
+#include <Carbon/Carbon.h>
+#undef Z
+#define Z (current_buffer->text->z)
+#undef free
+#define free unexec_free
+#undef malloc
+#define malloc unexec_malloc
+#undef realloc
+#define realloc unexec_realloc
+#undef min
+#define min(a, b) ((a) < (b) ? (a) : (b))
+#undef max
+#define max(a, b) ((a) > (b) ? (a) : (b))
+#else /* not MAC_OSX */ 
 #include <Windows.h>
 #include <Gestalt.h>
 #include <TextUtils.h>
-
-#ifndef min
-#define min(a,b) ((a) < (b) ? (a) : (b))
-#endif
-#ifndef max
-#define max(a,b) ((a) > (b) ? (a) : (b))
-#endif
+#endif /* not MAC_OSX */
 
 /*extern void free_frame_menubar ();
-extern void x_compute_fringe_widths (struct frame *, int);
 extern double atof ();
 extern int w32_console_toggle_lock_key (int vk_code, Lisp_Object new_state);
 extern int quit_char;*/
@@ -232,18 +249,20 @@ extern Lisp_Object Vwindow_system_version;
 
 Lisp_Object Qface_set_after_frame_default;
 
+extern int mac_initialized;
+
 /* Functions in macterm.c.  */
 extern void x_set_offset (struct frame *, int, int, int);
 extern void x_wm_set_icon_position (struct frame *, int, int);
 extern void x_display_cursor (struct window *, int, int, int, int, int);
 extern void x_set_window_size (struct frame *, int, int, int);
 extern void x_make_frame_visible (struct frame *);
-extern struct mac_display_info *x_term_init (Lisp_Object, char *, char *);
+extern struct mac_display_info *mac_term_init (Lisp_Object, char *, char *);
 extern struct font_info *x_get_font_info (FRAME_PTR, int);
 extern struct font_info *x_load_font (struct frame *, char *, int);
 extern void x_find_ccl_program (struct font_info *);
 extern struct font_info *x_query_font (struct frame *, char *);
-
+extern void mac_initialize ();
 
 /* compare two strings ignoring case */
 
@@ -297,7 +316,7 @@ check_x_frame (frame)
 
   if (NILP (frame))
     frame = selected_frame;
-  CHECK_LIVE_FRAME (frame, 0);
+  CHECK_LIVE_FRAME (frame);
   f = XFRAME (frame);
   if (! FRAME_MAC_P (f))
     error ("non-mac frame used");
@@ -312,6 +331,12 @@ static struct mac_display_info *
 check_x_display_info (frame)
      Lisp_Object frame;
 {
+  if (!mac_initialized)
+    {
+      mac_initialize ();
+      mac_initialized = 1;
+    }
+
   if (NILP (frame))
     {
       struct frame *sf = XFRAME (selected_frame);
@@ -327,7 +352,7 @@ check_x_display_info (frame)
     {
       FRAME_PTR f;
 
-      CHECK_LIVE_FRAME (frame, 0);
+      CHECK_LIVE_FRAME (frame);
       f = XFRAME (frame);
       if (! FRAME_MAC_P (f))
        error ("non-mac frame used");
@@ -356,7 +381,7 @@ x_window_to_frame (dpyinfo, wdesc)
       f = XFRAME (frame);
       if (!FRAME_W32_P (f) || FRAME_MAC_DISPLAY_INFO (f) != dpyinfo)
        continue;
-      /*if (f->output_data.w32->busy_window == wdesc)
+      /*if (f->output_data.w32->hourglass_window == wdesc)
         return f;*/
 
       /* MAC_TODO: Check tooltips when supported.  */
@@ -514,7 +539,7 @@ x_create_bitmap_from_file (f, file)
     }
 
   /* Search bitmap-file-path for the file, if appropriate.  */
-  fd = openp (Vx_bitmap_file_path, file, Qnil, &found, 0);
+  fd = openp (Vx_bitmap_file_path, file, "", &found, 0);
   if (fd < 0)
     return -1;
   /* LoadLibraryEx won't handle special files handled by Emacs handler.  */
@@ -605,7 +630,6 @@ void x_set_cursor_type P_ ((struct frame *, Lisp_Object, Lisp_Object));
 void x_set_icon_type P_ ((struct frame *, Lisp_Object, Lisp_Object));
 void x_set_icon_name P_ ((struct frame *, Lisp_Object, Lisp_Object));
 void x_set_font P_ ((struct frame *, Lisp_Object, Lisp_Object));
-static void x_set_fringe_width P_ ((struct frame *, Lisp_Object, Lisp_Object));
 void x_set_border_width P_ ((struct frame *, Lisp_Object, Lisp_Object));
 void x_set_internal_border_width P_ ((struct frame *, Lisp_Object,
                                      Lisp_Object));
@@ -661,9 +685,7 @@ static struct x_frame_parm_table x_frame_parms[] =
   "scroll-bar-background", x_set_scroll_bar_background,
 #endif
   "screen-gamma", x_set_screen_gamma,
-  "line-spacing", x_set_line_spacing,
-  "left-fringe", x_set_fringe_width,
-  "right-fringe", x_set_fringe_width
+  "line-spacing", x_set_line_spacing
 };
 
 /* Attach the `x-frame-parameter' properties to
@@ -755,16 +777,13 @@ x_set_frame_parameters (f, alist)
   /* Process foreground_color and background_color before anything else.
      They are independent of other properties, but other properties (e.g.,
      cursor_color) are dependent upon them.  */
-  /* Process default font as well, since fringe widths depends on it.  */
   for (p = 0; p < i; p++) 
     {
       Lisp_Object prop, val;
 
       prop = parms[p];
       val = values[p];
-      if (EQ (prop, Qforeground_color)
-         || EQ (prop, Qbackground_color)
-         || EQ (prop, Qfont))
+      if (EQ (prop, Qforeground_color) || EQ (prop, Qbackground_color))
        {
          register Lisp_Object param_index, old_value;
 
@@ -798,9 +817,7 @@ x_set_frame_parameters (f, alist)
        icon_top = val;
       else if (EQ (prop, Qicon_left))
        icon_left = val;
-      else if (EQ (prop, Qforeground_color)
-              || EQ (prop, Qbackground_color)
-              || EQ (prop, Qfont))
+      else if (EQ (prop, Qforeground_color) || EQ (prop, Qbackground_color))
        /* Processed above.  */
        continue;
       else
@@ -959,9 +976,18 @@ x_real_positions (f, xptr, yptr)
   Point pt;
   GrafPtr oldport;
 
+#ifdef TARGET_API_MAC_CARBON
+  {
+    Rect r;
+    
+    GetWindowPortBounds (f->output_data.mac->mWP, &r);
+    SetPt (&pt, r.left, r.top);
+  }
+#else /* not TARGET_API_MAC_CARBON */
   SetPt (&pt,
         f->output_data.mac->mWP->portRect.left,
         f->output_data.mac->mWP->portRect.top);
+#endif /* not TARGET_API_MAC_CARBON */
   GetPort (&oldport);
   LocalToGlobal (&pt);
   SetPort (oldport);
@@ -1002,14 +1028,6 @@ x_report_frame_params (f, alistptr)
                   make_number (f->output_data.mac->border_width));
   store_in_alist (alistptr, Qinternal_border_width,
                   make_number (f->output_data.mac->internal_border_width));
-  store_in_alist (alistptr, Qleft_fringe,
-                  make_number (f->output_data.mac->left_fringe_width));
-  store_in_alist (alistptr, Qright_fringe,
-                  make_number (f->output_data.mac->right_fringe_width));
-  store_in_alist (alistptr, Qscroll_bar_width,
-           make_number (FRAME_HAS_VERTICAL_SCROLL_BARS (f)
-                        ? FRAME_SCROLL_BAR_PIXEL_WIDTH(f)
-                        : 0));
   sprintf (buf, "%ld", (long) FRAME_MAC_WINDOW (f));
   store_in_alist (alistptr, Qwindow_id,
                   build_string (buf));
@@ -2044,7 +2062,7 @@ x_decode_color (f, arg, def)
 {
   XColor cdef;
 
-  CHECK_STRING (arg, 0);
+  CHECK_STRING (arg);
 
   if (strcmp (XSTRING (arg)->data, "black") == 0)
     return BLACK_PIX_DEFAULT (f);
@@ -2173,7 +2191,7 @@ x_set_mouse_color (f, arg, oldval)
 
   if (!EQ (Qnil, Vx_pointer_shape))
     {
-      CHECK_NUMBER (Vx_pointer_shape, 0);
+      CHECK_NUMBER (Vx_pointer_shape);
       cursor = XCreateFontCursor (FRAME_W32_DISPLAY (f), XINT (Vx_pointer_shape));
     }
   else
@@ -2182,7 +2200,7 @@ x_set_mouse_color (f, arg, oldval)
 
   if (!EQ (Qnil, Vx_nontext_pointer_shape))
     {
-      CHECK_NUMBER (Vx_nontext_pointer_shape, 0);
+      CHECK_NUMBER (Vx_nontext_pointer_shape);
       nontext_cursor = XCreateFontCursor (FRAME_W32_DISPLAY (f),
                                          XINT (Vx_nontext_pointer_shape));
     }
@@ -2192,7 +2210,7 @@ x_set_mouse_color (f, arg, oldval)
 
   if (!EQ (Qnil, Vx_hourglass_pointer_shape))
     {
-      CHECK_NUMBER (Vx_hourglass_pointer_shape, 0);
+      CHECK_NUMBER (Vx_hourglass_pointer_shape);
       hourglass_cursor = XCreateFontCursor (FRAME_W32_DISPLAY (f),
                                            XINT (Vx_hourglass_pointer_shape));
     }
@@ -2203,7 +2221,7 @@ x_set_mouse_color (f, arg, oldval)
   x_check_errors (FRAME_W32_DISPLAY (f), "bad nontext pointer cursor: %s");
   if (!EQ (Qnil, Vx_mode_pointer_shape))
     {
-      CHECK_NUMBER (Vx_mode_pointer_shape, 0);
+      CHECK_NUMBER (Vx_mode_pointer_shape);
       mode_cursor = XCreateFontCursor (FRAME_W32_DISPLAY (f),
                                       XINT (Vx_mode_pointer_shape));
     }
@@ -2213,7 +2231,7 @@ x_set_mouse_color (f, arg, oldval)
 
   if (!EQ (Qnil, Vx_sensitive_text_pointer_shape))
     {
-      CHECK_NUMBER (Vx_sensitive_text_pointer_shape, 0);
+      CHECK_NUMBER (Vx_sensitive_text_pointer_shape);
       cross_cursor
        = XCreateFontCursor (FRAME_W32_DISPLAY (f),
                             XINT (Vx_sensitive_text_pointer_shape));
@@ -2223,14 +2241,14 @@ x_set_mouse_color (f, arg, oldval)
 
   if (!NILP (Vx_window_horizontal_drag_shape))
     {
-      CHECK_NUMBER (Vx_window_horizontal_drag_shape, 0);
+      CHECK_NUMBER (Vx_window_horizontal_drag_shape);
       horizontal_drag_cursor
-       = XCreateFontCursor (FRAME_X_DISPLAY (f),
+       = XCreateFontCursor (FRAME_W32_DISPLAY (f),
                             XINT (Vx_window_horizontal_drag_shape));
     }
   else
     horizontal_drag_cursor
-      = XCreateFontCursor (FRAME_X_DISPLAY (f), XC_sb_h_double_arrow);
+      = XCreateFontCursor (FRAME_W32_DISPLAY (f), XC_sb_h_double_arrow);
 
   /* Check and report errors with the above calls.  */
   x_check_errors (FRAME_W32_DISPLAY (f), "can't set cursor shape: %s");
@@ -2362,7 +2380,7 @@ x_set_border_color (f, arg, oldval)
 {
   int pix;
 
-  CHECK_STRING (arg, 0);
+  CHECK_STRING (arg);
   pix = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
   x_set_border_pixel (f, pix);
   update_face_from_frame_parameter (f, Qborder_color, arg);
@@ -2447,7 +2465,7 @@ x_set_icon_type (f, arg, oldval)
 
   UNBLOCK_INPUT;
 }
-#endif
+#endif /* MAC_TODO */
 
 /* Return non-nil if frame F wants a bitmap icon.  */
 
@@ -2481,7 +2499,7 @@ x_set_icon_name (f, arg, oldval)
 
   f->icon_name = arg;
 
-#if 0
+#if 0 /* MAC_TODO */
   if (f->output_data.w32->icon_bitmap != 0)
     return;
 
@@ -2512,7 +2530,7 @@ x_set_icon_name (f, arg, oldval)
 
   XFlush (FRAME_W32_DISPLAY (f));
   UNBLOCK_INPUT;
-#endif
+#endif /* MAC_TODO */
 }
 
 extern Lisp_Object x_new_font ();
@@ -2526,8 +2544,9 @@ x_set_font (f, arg, oldval)
   Lisp_Object result;
   Lisp_Object fontset_name;
   Lisp_Object frame;
+  int old_fontset = FRAME_FONTSET(f);
 
-  CHECK_STRING (arg, 1);
+  CHECK_STRING (arg);
 
   fontset_name = Fquery_fontset (arg, Qnil);
 
@@ -2543,8 +2562,16 @@ x_set_font (f, arg, oldval)
     error ("The characters of the given font have varying widths");
   else if (STRINGP (result))
     {
-      if (!NILP (Fequal (result, oldval)))
-       return;
+      if (STRINGP (fontset_name))
+       {
+         /* Fontset names are built from ASCII font names, so the
+            names may be equal despite there was a change.  */
+         if (old_fontset == FRAME_FONTSET (f))
+           return;
+       }
+      else if (!NILP (Fequal (result, oldval)))
+        return;
+
       store_frame_param (f, Qfont, result);
       recompute_basic_faces (f);
     }
@@ -2565,25 +2592,17 @@ x_set_font (f, arg, oldval)
     }
 }
 
-static void
-x_set_fringe_width (f, new_value, old_value)
-     struct frame *f;
-     Lisp_Object new_value, old_value;
-{
-  x_compute_fringe_widths (f, 1);
-}
-
 void
 x_set_border_width (f, arg, oldval)
      struct frame *f;
      Lisp_Object arg, oldval;
 {
-  CHECK_NUMBER (arg, 0);
+  CHECK_NUMBER (arg);
 
   if (XINT (arg) == f->output_data.mac->border_width)
     return;
 
-#if 0
+#if 0 /* MAC_TODO */
   if (FRAME_MAC_WINDOW (f) != 0)
     error ("Cannot change the border width of a window");
 #endif
@@ -2598,7 +2617,7 @@ x_set_internal_border_width (f, arg, oldval)
 {
   int old = f->output_data.mac->internal_border_width;
 
-  CHECK_NUMBER (arg, 0);
+  CHECK_NUMBER (arg);
   f->output_data.mac->internal_border_width = XINT (arg);
   if (f->output_data.mac->internal_border_width < 0)
     f->output_data.mac->internal_border_width = 0;
@@ -2612,6 +2631,8 @@ x_set_internal_border_width (f, arg, oldval)
       SET_FRAME_GARBAGED (f);
       do_pending_window_change (0);
     }
+  else
+    SET_FRAME_GARBAGED (f);
 }
 
 void
@@ -2698,6 +2719,7 @@ x_set_menu_bar_lines (f, value, oldval)
   adjust_glyphs (f);
 }
 
+
 /* Set the number of lines used for the tool bar of frame F to VALUE.
    VALUE not an integer, or < 0 means set the lines to zero.  OLDVAL
    is the old number of tool bar lines.  This function changes the
@@ -2767,6 +2789,9 @@ x_set_tool_bar_lines (f, value, oldval)
       XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
                    0, y, width, height, 0);
       UNBLOCK_INPUT;
+
+      if (WINDOWP (f->tool_bar_window))
+       clear_glyph_matrix (XWINDOW (f->tool_bar_window)->current_matrix);
     }
 }
 
@@ -2813,7 +2838,7 @@ x_set_name (f, name, explicit)
       name = build_string (FRAME_MAC_DISPLAY_INFO (f)->mac_id_name);
     }
   else
-    CHECK_STRING (name, 0);
+    CHECK_STRING (name);
 
   /* Don't change the name if it's already NAME.  */
   if (! NILP (Fstring_equal (name, f->name)))
@@ -2987,6 +3012,11 @@ x_set_scroll_bar_width (f, arg, oldval)
 
   if (NILP (arg))
     {
+#ifdef MAC_OSX
+      FRAME_SCROLL_BAR_PIXEL_WIDTH (f) = 16;  /* Aqua scroll bars.  */
+      FRAME_SCROLL_BAR_COLS (f) = (FRAME_SCROLL_BAR_PIXEL_WIDTH (f) +
+                                   wid - 1) / wid;
+#else /* not MAC_OSX */
       /* Make the actual width at least 14 pixels and a multiple of a
         character width.  */
       FRAME_SCROLL_BAR_COLS (f) = (14 + wid - 1) / wid;
@@ -2994,7 +3024,7 @@ x_set_scroll_bar_width (f, arg, oldval)
       /* Use all of that space (aside from required margins) for the
         scroll bar.  */
       FRAME_SCROLL_BAR_PIXEL_WIDTH (f) = 0;
-
+#endif /* not MAC_OSX */
       if (FRAME_MAC_WINDOW (f))
        x_set_window_size (f, 0, FRAME_WIDTH (f), FRAME_HEIGHT (f));
       do_pending_window_change (0);
@@ -3090,15 +3120,15 @@ validate_x_resource_name ()
 extern char *x_get_string_resource ();
 
 DEFUN ("x-get-resource", Fx_get_resource, Sx_get_resource, 2, 4, 0,
-  "Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.\n\
-This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the\n\
-class, where INSTANCE is the name under which Emacs was invoked, or\n\
-the name specified by the `-name' or `-rn' command-line arguments.\n\
-\n\
-The optional arguments COMPONENT and SUBCLASS add to the key and the\n\
-class, respectively.  You must specify both of them or neither.\n\
-If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE'\n\
-and the class is `Emacs.CLASS.SUBCLASS'.")
+       doc: /* Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.
+This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the
+class, where INSTANCE is the name under which Emacs was invoked, or
+the name specified by the `-name' or `-rn' command-line arguments.
+
+The optional arguments COMPONENT and SUBCLASS add to the key and the
+class, respectively.  You must specify both of them or neither.
+If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE'
+and the class is `Emacs.CLASS.SUBCLASS'.  */)
   (attribute, class, component, subclass)
      Lisp_Object attribute, class, component, subclass;
 {
@@ -3106,13 +3136,13 @@ and the class is `Emacs.CLASS.SUBCLASS'.")
   char *name_key;
   char *class_key;
 
-  CHECK_STRING (attribute, 0);
-  CHECK_STRING (class, 0);
+  CHECK_STRING (attribute);
+  CHECK_STRING (class);
 
   if (!NILP (component))
-    CHECK_STRING (component, 1);
+    CHECK_STRING (component);
   if (!NILP (subclass))
-    CHECK_STRING (subclass, 2);
+    CHECK_STRING (subclass);
   if (NILP (component) != NILP (subclass))
     error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");
 
@@ -3185,7 +3215,7 @@ x_get_resource_string (attribute, class)
 
   return x_get_string_resource (sf, name_key, class_key);
 }
-#endif
+#endif /* MAC_TODO */
 
 /* Types we might convert a resource string into.  */
 enum resource_types
@@ -3273,7 +3303,7 @@ mac_get_arg (alist, param, attribute, class, type)
            }
        }
       else
-#endif
+#endif /* MAC_TODO */
        return Qunbound;
     }
   return Fcdr (tem);
@@ -3304,13 +3334,150 @@ x_default_parameter (f, alist, prop, deflt, xprop, xclass, type)
   return tem;
 }
 \f
+/* XParseGeometry copied from w32xfns.c */
+
+/*
+ *   XParseGeometry parses strings of the form
+ *   "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where
+ *   width, height, xoffset, and yoffset are unsigned integers.
+ *   Example:  "=80x24+300-49"
+ *   The equal sign is optional.
+ *   It returns a bitmask that indicates which of the four values
+ *   were actually found in the string.  For each value found,
+ *   the corresponding argument is updated;  for each value
+ *   not found, the corresponding argument is left unchanged. 
+ */
+
+static int
+read_integer (string, NextString)
+     register char *string;
+     char **NextString;
+{
+  register int Result = 0;
+  int Sign = 1;
+  
+  if (*string == '+')
+    string++;
+  else if (*string == '-')
+    {
+      string++;
+      Sign = -1;
+    }
+  for (; (*string >= '0') && (*string <= '9'); string++)
+    {
+      Result = (Result * 10) + (*string - '0');
+    }
+  *NextString = string;
+  if (Sign >= 0)
+    return (Result);
+  else
+    return (-Result);
+}
+
+int 
+XParseGeometry (string, x, y, width, height)
+     char *string;
+     int *x, *y;
+     unsigned int *width, *height;    /* RETURN */
+{
+  int mask = NoValue;
+  register char *strind;
+  unsigned int tempWidth, tempHeight;
+  int tempX, tempY;
+  char *nextCharacter;
+  
+  if ((string == NULL) || (*string == '\0')) return (mask);
+  if (*string == '=')
+    string++;  /* ignore possible '=' at beg of geometry spec */
+  
+  strind = (char *)string;
+  if (*strind != '+' && *strind != '-' && *strind != 'x') 
+    {
+      tempWidth = read_integer (strind, &nextCharacter);
+      if (strind == nextCharacter) 
+       return (0);
+      strind = nextCharacter;
+      mask |= WidthValue;
+    }
+  
+  if (*strind == 'x' || *strind == 'X') 
+    {  
+      strind++;
+      tempHeight = read_integer (strind, &nextCharacter);
+      if (strind == nextCharacter)
+       return (0);
+      strind = nextCharacter;
+      mask |= HeightValue;
+    }
+  
+  if ((*strind == '+') || (*strind == '-')) 
+    {
+      if (*strind == '-') 
+       {
+         strind++;
+         tempX = -read_integer (strind, &nextCharacter);
+         if (strind == nextCharacter)
+           return (0);
+         strind = nextCharacter;
+         mask |= XNegative;
+
+       }
+      else
+       {       
+         strind++;
+         tempX = read_integer (strind, &nextCharacter);
+         if (strind == nextCharacter)
+           return (0);
+         strind = nextCharacter;
+       }
+      mask |= XValue;
+      if ((*strind == '+') || (*strind == '-')) 
+       {
+         if (*strind == '-') 
+           {
+             strind++;
+             tempY = -read_integer (strind, &nextCharacter);
+             if (strind == nextCharacter)
+               return (0);
+             strind = nextCharacter;
+             mask |= YNegative;
+
+           }
+         else
+           {
+             strind++;
+             tempY = read_integer (strind, &nextCharacter);
+             if (strind == nextCharacter)
+               return (0);
+             strind = nextCharacter;
+           }
+         mask |= YValue;
+       }
+    }
+  
+  /* If strind isn't at the end of the string the it's an invalid
+     geometry specification. */
+  
+  if (*strind != '\0') return (0);
+  
+  if (mask & XValue)
+    *x = tempX;
+  if (mask & YValue)
+    *y = tempY;
+  if (mask & WidthValue)
+    *width = tempWidth;
+  if (mask & HeightValue)
+    *height = tempHeight;
+  return (mask);
+}
+
 DEFUN ("x-parse-geometry", Fx_parse_geometry, Sx_parse_geometry, 1, 1, 0,
-       "Parse an X-style geometry string STRING.\n\
-Returns an alist of the form ((top . TOP), (left . LEFT) ... ).\n\
-The properties returned may include `top', `left', `height', and `width'.\n\
-The value of `left' or `top' may be an integer,\n\
-or a list (+ N) meaning N pixels relative to top/left corner,\n\
-or a list (- N) meaning -N pixels relative to bottom/right corner.")
+       doc: /* Parse an X-style geometry string STRING.
+Returns an alist of the form ((top . TOP), (left . LEFT) ... ).
+The properties returned may include `top', `left', `height', and `width'.
+The value of `left' or `top' may be an integer,
+or a list (+ N) meaning N pixels relative to top/left corner,
+or a list (- N) meaning -N pixels relative to bottom/right corner.  */)
      (string)
      Lisp_Object string;
 {
@@ -3318,7 +3485,7 @@ or a list (- N) meaning -N pixels relative to bottom/right corner.")
   unsigned int width, height;
   Lisp_Object result;
 
-  CHECK_STRING (string, 0);
+  CHECK_STRING (string);
 
   geometry = XParseGeometry ((char *) XSTRING (string)->data,
                             &x, &y, &width, &height);
@@ -3391,12 +3558,12 @@ x_figure_window_size (f, parms)
     {
       if (!EQ (tem0, Qunbound))
        {
-         CHECK_NUMBER (tem0, 0);
+         CHECK_NUMBER (tem0);
          f->height = XINT (tem0);
        }
       if (!EQ (tem1, Qunbound))
        {
-         CHECK_NUMBER (tem1, 0);
+         CHECK_NUMBER (tem1);
          SET_FRAME_WIDTH (f, XINT (tem1));
        }
       if (!NILP (tem2) && !EQ (tem2, Qunbound))
@@ -3411,7 +3578,9 @@ x_figure_window_size (f, parms)
        : FRAME_SCROLL_BAR_PIXEL_WIDTH (f) > 0
        ? FRAME_SCROLL_BAR_PIXEL_WIDTH (f)
        : (FRAME_SCROLL_BAR_COLS (f) * FONT_WIDTH (f->output_data.mac->font)));
+
   x_compute_fringe_widths (f, 0);
+
   f->output_data.mac->pixel_width = CHAR_TO_PIXEL_WIDTH (f, f->width);
   f->output_data.mac->pixel_height = CHAR_TO_PIXEL_HEIGHT (f, f->height);
 
@@ -3442,7 +3611,7 @@ x_figure_window_size (f, parms)
        f->output_data.mac->top_pos = 0;
       else
        {
-         CHECK_NUMBER (tem0, 0);
+         CHECK_NUMBER (tem0);
          f->output_data.mac->top_pos = XINT (tem0);
          if (f->output_data.mac->top_pos < 0)
            window_prompting |= YNegative;
@@ -3470,7 +3639,7 @@ x_figure_window_size (f, parms)
        f->output_data.mac->left_pos = 0;
       else
        {
-         CHECK_NUMBER (tem1, 0);
+         CHECK_NUMBER (tem1);
          f->output_data.mac->left_pos = XINT (tem1);
          if (f->output_data.mac->left_pos < 0)
            window_prompting |= XNegative;
@@ -3486,7 +3655,7 @@ x_figure_window_size (f, parms)
 }
 
 \f
-#if 0
+#if 0 /* MAC_TODO */
 /* Create and set up the Mac window for frame F.  */
 
 static void
@@ -3543,7 +3712,7 @@ mac_window (f, window_prompting, minibuffer_only)
   if (FRAME_MAC_WINDOW (f) == 0)
     error ("Unable to create window");
 }
-#endif
+#endif /* MAC_TODO */
 
 /* Handle the icon stuff for this window.  Perhaps later we might
    want an x_set_icon_position which can be called interactively as
@@ -3562,8 +3731,8 @@ x_icon (f, parms)
   icon_y = mac_get_arg (parms, Qicon_top, 0, 0, RES_TYPE_NUMBER);
   if (!EQ (icon_x, Qunbound) && !EQ (icon_y, Qunbound))
     {
-      CHECK_NUMBER (icon_x, 0);
-      CHECK_NUMBER (icon_y, 0);
+      CHECK_NUMBER (icon_x);
+      CHECK_NUMBER (icon_y);
     }
   else if (!EQ (icon_x, Qunbound) || !EQ (icon_y, Qunbound))
     error ("Both left and top icon corners of icon must be specified");
@@ -3589,7 +3758,7 @@ x_icon (f, parms)
 }
 
 
-static void
+void
 x_make_gc (f)
      struct frame *f;
 {
@@ -3602,23 +3771,23 @@ x_make_gc (f)
 
   /* Normal video */
   gc_values.font = f->output_data.mac->font;
-  gc_values.foreground = f->output_data.mac->foreground_pixel;
-  gc_values.background = f->output_data.mac->background_pixel;
+  gc_values.foreground = FRAME_FOREGROUND_PIXEL (f);
+  gc_values.background = FRAME_BACKGROUND_PIXEL (f);
   f->output_data.mac->normal_gc = XCreateGC (FRAME_MAC_DISPLAY (f),
                                             FRAME_MAC_WINDOW (f),
                                             GCFont | GCForeground | GCBackground,
                                             &gc_values);
 
   /* Reverse video style.  */
-  gc_values.foreground = f->output_data.mac->background_pixel;
-  gc_values.background = f->output_data.mac->foreground_pixel;
+  gc_values.foreground = FRAME_BACKGROUND_PIXEL (f);
+  gc_values.background = FRAME_FOREGROUND_PIXEL (f);
   f->output_data.mac->reverse_gc = XCreateGC (FRAME_MAC_DISPLAY (f),
                                              FRAME_MAC_WINDOW (f),
                                              GCFont | GCForeground | GCBackground,
                                              &gc_values);
 
   /* Cursor has cursor-color background, background-color foreground.  */
-  gc_values.foreground = f->output_data.mac->background_pixel;
+  gc_values.foreground = FRAME_BACKGROUND_PIXEL (f);
   gc_values.background = f->output_data.mac->cursor_pixel;
   f->output_data.mac->cursor_gc = XCreateGC (FRAME_MAC_DISPLAY (f),
                                             FRAME_MAC_WINDOW (f),
@@ -3635,15 +3804,15 @@ x_make_gc (f)
 
 DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
        1, 1, 0,
-  "Make a new window, which is called a \"frame\" in Emacs terms.\n\
-Returns an Emacs frame object.\n\
-ALIST is an alist of frame parameters.\n\
-If the parameters specify that the frame should not have a minibuffer,\n\
-and do not specify a specific minibuffer window to use,\n\
-then `default-minibuffer-frame' must be a frame whose minibuffer can\n\
-be shared by the new frame.\n\
-\n\
-This function is an internal primitive--use `make-frame' instead.")
+       doc: /* Make a new window, which is called a \"frame\" in Emacs terms.
+Returns an Emacs frame object.
+ALIST is an alist of frame parameters.
+If the parameters specify that the frame should not have a minibuffer,
+and do not specify a specific minibuffer window to use,
+then `default-minibuffer-frame' must be a frame whose minibuffer can
+be shared by the new frame.
+
+This function is an internal primitive--use `make-frame' instead.  */)
   (parms)
      Lisp_Object parms;
 {
@@ -3660,7 +3829,7 @@ This function is an internal primitive--use `make-frame' instead.")
   Lisp_Object parent;
   struct kboard *kb;
   char x_frame_name[10];
-  static int x_frame_count = 2;  /* starts from 2 because terminal frame is F1 */
+  static int x_frame_count = 2;  /* begins at 2 because terminal frame is F1 */
 
   check_mac ();
 
@@ -3692,14 +3861,15 @@ This function is an internal primitive--use `make-frame' instead.")
   if (EQ (parent, Qunbound))
     parent = Qnil;
   if (! NILP (parent))
-    CHECK_NUMBER (parent, 0);
+    CHECK_NUMBER (parent);
 
   /* make_frame_without_minibuffer can run Lisp code and garbage collect.  */
   /* No need to protect DISPLAY because that's not used after passing
      it to make_frame_without_minibuffer.  */
   frame = Qnil;
   GCPRO4 (parms, parent, name, frame);
-  tem = mac_get_arg (parms, Qminibuffer, 0, 0, RES_TYPE_SYMBOL);
+  tem = mac_get_arg (parms, Qminibuffer, "minibuffer", "Minibuffer",
+                     RES_TYPE_SYMBOL);
   if (EQ (tem, Qnone) || NILP (tem))
     f = make_frame_without_minibuffer (Qnil, kb, display);
   else if (EQ (tem, Qonly))
@@ -3732,7 +3902,7 @@ This function is an internal primitive--use `make-frame' instead.")
   f->output_method = output_mac;
   f->output_data.mac = (struct mac_output *) xmalloc (sizeof (struct mac_output));
   bzero (f->output_data.mac, sizeof (struct mac_output));
-  f->output_data.mac->fontset = -1;
+  FRAME_FONTSET (f) = -1;
   f->output_data.mac->scroll_bar_foreground_pixel = -1;
   f->output_data.mac->scroll_bar_background_pixel = -1;
 
@@ -3821,18 +3991,16 @@ This function is an internal primitive--use `make-frame' instead.")
       Lisp_Object value;
 
       value = mac_get_arg (parms, Qinternal_border_width,
-                        "internalBorder", "BorderWidth", RES_TYPE_NUMBER);
+                        "internalBorder", "InternalBorder", RES_TYPE_NUMBER);
       if (! EQ (value, Qunbound))
        parms = Fcons (Fcons (Qinternal_border_width, value),
                       parms);
     }
-
   /* Default internalBorderWidth to 0 on Windows to match other programs.  */
   x_default_parameter (f, parms, Qinternal_border_width, make_number (0),
-                      "internalBorderWidth", "BorderWidth", RES_TYPE_NUMBER);
-
-  x_default_parameter (f, parms, Qvertical_scroll_bars, Qt,
-                      "verticalScrollBars", "ScrollBars", RES_TYPE_BOOLEAN);
+                      "internalBorderWidth", "InternalBorder", RES_TYPE_NUMBER);
+  x_default_parameter (f, parms, Qvertical_scroll_bars, Qright,
+                      "verticalScrollBars", "ScrollBars", RES_TYPE_SYMBOL);
 
   /* Also do the stuff which must be set before the window exists.  */
   x_default_parameter (f, parms, Qforeground_color, build_string ("black"),
@@ -3854,6 +4022,7 @@ This function is an internal primitive--use `make-frame' instead.")
   x_default_parameter (f, parms, Qright_fringe, Qnil,
                       "rightFringe", "RightFringe", RES_TYPE_NUMBER);
 
+
   /* Init faces before x_default_parameter is called for scroll-bar
      parameters because that function calls x_set_scroll_bar_width,
      which calls change_frame_size, which calls Fset_window_buffer,
@@ -3866,10 +4035,8 @@ This function is an internal primitive--use `make-frame' instead.")
                       "menuBar", "MenuBar", RES_TYPE_NUMBER);
   x_default_parameter (f, parms, Qtool_bar_lines, make_number (0),
                        "toolBar", "ToolBar", RES_TYPE_NUMBER);
-#if 0
   x_default_parameter (f, parms, Qbuffer_predicate, Qnil,
                       "bufferPredicate", "BufferPredicate", RES_TYPE_SYMBOL);
-#endif
   x_default_parameter (f, parms, Qtitle, Qnil,
                       "title", "Title", RES_TYPE_STRING);
 
@@ -3932,9 +4099,9 @@ This function is an internal primitive--use `make-frame' instead.")
   /* Dimensions, especially f->height, must be done via change_frame_size.
      Change will not be effected unless different from the current
      f->height.  */
-
   width = f->width;
   height = f->height;
+
   f->height = 0;
   SET_FRAME_WIDTH (f, 0);
   change_frame_size (f, height, width, 1, 0, 0);
@@ -3973,8 +4140,12 @@ This function is an internal primitive--use `make-frame' instead.")
        /* Must have been Qnil.  */
        ;
     }
-
   UNGCPRO;
+  
+  /* Make sure windows on this frame appear in calls to next-window
+     and similar functions.  */
+  Vwindow_list = Qnil;
+  
   return unbind_to (count, frame);
 }
 
@@ -3995,14 +4166,14 @@ x_get_focus_frame (frame)
 }
 \f
 DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0,
-  "Internal function called by `color-defined-p', which see.")
+       doc: /* Internal function called by `color-defined-p', which see.  */)
   (color, frame)
      Lisp_Object color, frame;
 {
   XColor foo;
   FRAME_PTR f = check_x_frame (frame);
 
-  CHECK_STRING (color, 1);
+  CHECK_STRING (color);
 
   if (mac_defined_color (f, XSTRING (color)->data, &foo, 0))
     return Qt;
@@ -4011,14 +4182,14 @@ DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0,
 }
 
 DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0,
-  "Internal function called by `color-values', which see.")
+       doc: /* Internal function called by `color-values', which see.  */)
   (color, frame)
      Lisp_Object color, frame;
 {
   XColor foo;
   FRAME_PTR f = check_x_frame (frame);
 
-  CHECK_STRING (color, 1);
+  CHECK_STRING (color);
 
   if (mac_defined_color (f, XSTRING (color)->data, &foo, 0))
     {
@@ -4037,7 +4208,7 @@ DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0,
 }
 
 DEFUN ("xw-display-color-p", Fxw_display_color_p, Sxw_display_color_p, 0, 1, 0,
-  "Internal function called by `display-color-p', which see.")
+       doc: /* Internal function called by `display-color-p', which see.  */)
   (display)
      Lisp_Object display;
 {
@@ -4050,12 +4221,12 @@ DEFUN ("xw-display-color-p", Fxw_display_color_p, Sxw_display_color_p, 0, 1, 0,
 }
 
 DEFUN ("x-display-grayscale-p", Fx_display_grayscale_p, Sx_display_grayscale_p,
-  0, 1, 0,
-  "Return t if the X display supports shades of gray.\n\
-Note that color displays do support shades of gray.\n\
-The optional argument DISPLAY specifies which display to ask about.\n\
-DISPLAY should be either a frame or a display name (a string).\n\
-If omitted or nil, that stands for the selected frame's display.")
+       0, 1, 0,
+       doc: /* Return t if the X display supports shades of gray.
+Note that color displays do support shades of gray.
+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.  */)
   (display)
      Lisp_Object display;
 {
@@ -4068,11 +4239,11 @@ If omitted or nil, that stands for the selected frame's display.")
 }
 
 DEFUN ("x-display-pixel-width", Fx_display_pixel_width, Sx_display_pixel_width,
-  0, 1, 0,
-  "Returns the width in pixels of the X display DISPLAY.\n\
-The optional argument DISPLAY specifies which display to ask about.\n\
-DISPLAY should be either a frame or a display name (a string).\n\
-If omitted or nil, that stands for the selected frame's display.")
+       0, 1, 0,
+       doc: /* Returns the width in pixels of the X display DISPLAY.
+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.  */)
   (display)
      Lisp_Object display;
 {
@@ -4082,11 +4253,11 @@ If omitted or nil, that stands for the selected frame's display.")
 }
 
 DEFUN ("x-display-pixel-height", Fx_display_pixel_height,
-  Sx_display_pixel_height, 0, 1, 0,
-  "Returns the height in pixels of the X display DISPLAY.\n\
-The optional argument DISPLAY specifies which display to ask about.\n\
-DISPLAY should be either a frame or a display name (a string).\n\
-If omitted or nil, that stands for the selected frame's display.")
+       Sx_display_pixel_height, 0, 1, 0,
+       doc: /* Returns the height in pixels of the X display DISPLAY.
+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.  */)
   (display)
      Lisp_Object display;
 {
@@ -4096,11 +4267,11 @@ If omitted or nil, that stands for the selected frame's display.")
 }
 
 DEFUN ("x-display-planes", Fx_display_planes, Sx_display_planes,
-  0, 1, 0,
-  "Returns the number of bitplanes of the display DISPLAY.\n\
-The optional argument DISPLAY specifies which display to ask about.\n\
-DISPLAY should be either a frame or a display name (a string).\n\
-If omitted or nil, that stands for the selected frame's display.")
+       0, 1, 0,
+       doc: /* Returns the number of bitplanes of the display DISPLAY.
+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.  */)
   (display)
      Lisp_Object display;
 {
@@ -4110,11 +4281,11 @@ If omitted or nil, that stands for the selected frame's display.")
 }
 
 DEFUN ("x-display-color-cells", Fx_display_color_cells, Sx_display_color_cells,
-  0, 1, 0,
-  "Returns the number of color cells of the display DISPLAY.\n\
-The optional argument DISPLAY specifies which display to ask about.\n\
-DISPLAY should be either a frame or a display name (a string).\n\
-If omitted or nil, that stands for the selected frame's display.")
+       0, 1, 0,
+       doc: /* Returns the number of color cells of the display DISPLAY.
+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.  */)
   (display)
      Lisp_Object display;
 {
@@ -4126,11 +4297,11 @@ If omitted or nil, that stands for the selected frame's display.")
 
 DEFUN ("x-server-max-request-size", Fx_server_max_request_size,
        Sx_server_max_request_size,
-  0, 1, 0,
-  "Returns the maximum request size of the server of display DISPLAY.\n\
-The optional argument DISPLAY specifies which display to ask about.\n\
-DISPLAY should be either a frame or a display name (a string).\n\
-If omitted or nil, that stands for the selected frame's display.")
+       0, 1, 0,
+       doc: /* Returns the maximum request size of the server of display DISPLAY.
+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.   */)
   (display)
      Lisp_Object display;
 {
@@ -4140,10 +4311,10 @@ If omitted or nil, that stands for the selected frame's display.")
 }
 
 DEFUN ("x-server-vendor", Fx_server_vendor, Sx_server_vendor, 0, 1, 0,
-  "Returns the vendor ID string of the W32 system (Microsoft).\n\
-The optional argument DISPLAY specifies which display to ask about.\n\
-DISPLAY should be either a frame or a display name (a string).\n\
-If omitted or nil, that stands for the selected frame's display.")
+       doc: /* Returns the vendor ID string of the Mac OS system (Apple).
+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.  */)
   (display)
      Lisp_Object display;
 {
@@ -4151,13 +4322,14 @@ If omitted or nil, that stands for the selected frame's display.")
 }
 
 DEFUN ("x-server-version", Fx_server_version, Sx_server_version, 0, 1, 0,
-  "Returns the version numbers of the server of display DISPLAY.\n\
-The value is a list of three integers: the major and minor\n\
-version numbers, and the vendor-specific release\n\
-number.  See also the function `x-server-vendor'.\n\n\
-The optional argument DISPLAY specifies which display to ask about.\n\
-DISPLAY should be either a frame or a display name (a string).\n\
-If omitted or nil, that stands for the selected frame's display.")
+       doc: /* Returns the version numbers of the server of display DISPLAY.
+The value is a list of three integers: the major and minor
+version numbers, and the vendor-specific release
+number.  See also the function `x-server-vendor'.
+
+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.  */)
   (display)
      Lisp_Object display;
 {
@@ -4175,10 +4347,10 @@ If omitted or nil, that stands for the selected frame's display.")
 }
 
 DEFUN ("x-display-screens", Fx_display_screens, Sx_display_screens, 0, 1, 0,
-  "Returns the number of screens on the server of display DISPLAY.\n\
-The optional argument DISPLAY specifies which display to ask about.\n\
-DISPLAY should be either a frame or a display name (a string).\n\
-If omitted or nil, that stands for the selected frame's display.")
+       doc: /* Return the number of screens on the server of display DISPLAY.
+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.  */)
   (display)
      Lisp_Object display;
 {
@@ -4186,10 +4358,10 @@ If omitted or nil, that stands for the selected frame's display.")
 }
 
 DEFUN ("x-display-mm-height", Fx_display_mm_height, Sx_display_mm_height, 0, 1, 0,
-  "Returns the height in millimeters of the X display DISPLAY.\n\
-The optional argument DISPLAY specifies which display to ask about.\n\
-DISPLAY should be either a frame or a display name (a string).\n\
-If omitted or nil, that stands for the selected frame's display.")
+       doc: /* Return the height in millimeters of the X display DISPLAY.
+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.  */)
   (display)
      Lisp_Object display;
 {
@@ -4204,10 +4376,10 @@ If omitted or nil, that stands for the selected frame's display.")
 }
 
 DEFUN ("x-display-mm-width", Fx_display_mm_width, Sx_display_mm_width, 0, 1, 0,
-  "Returns the width in millimeters of the X display DISPLAY.\n\
-The optional argument DISPLAY specifies which display to ask about.\n\
-DISPLAY should be either a frame or a display name (a string).\n\
-If omitted or nil, that stands for the selected frame's display.")
+       doc: /* Return the width in millimeters of the X display DISPLAY.
+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.  */)
   (display)
      Lisp_Object display;
 {
@@ -4222,12 +4394,12 @@ If omitted or nil, that stands for the selected frame's display.")
 }
 
 DEFUN ("x-display-backing-store", Fx_display_backing_store,
-  Sx_display_backing_store, 0, 1, 0,
-  "Returns an indication of whether display DISPLAY does backing store.\n\
-The value may be `always', `when-mapped', or `not-useful'.\n\
-The optional argument DISPLAY specifies which display to ask about.\n\
-DISPLAY should be either a frame or a display name (a string).\n\
-If omitted or nil, that stands for the selected frame's display.")
+       Sx_display_backing_store, 0, 1, 0,
+       doc: /* Returns an indication of whether display DISPLAY does backing store.
+The value may be `always', `when-mapped', or `not-useful'.
+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.  */)
   (display)
      Lisp_Object display;
 {
@@ -4235,13 +4407,14 @@ If omitted or nil, that stands for the selected frame's display.")
 }
 
 DEFUN ("x-display-visual-class", Fx_display_visual_class,
-  Sx_display_visual_class, 0, 1, 0,
-  "Returns the visual class of the display DISPLAY.\n\
-The value is one of the symbols `static-gray', `gray-scale',\n\
-`static-color', `pseudo-color', `true-color', or `direct-color'.\n\n\
-The optional argument DISPLAY specifies which display to ask about.\n\
-DISPLAY should be either a frame or a display name (a string).\n\
-If omitted or nil, that stands for the selected frame's display.")
+       Sx_display_visual_class, 0, 1, 0,
+       doc: /* Returns the visual class of the display DISPLAY.
+The value is one of the symbols `static-gray', `gray-scale',
+`static-color', `pseudo-color', `true-color', or `direct-color'.
+
+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.  */)
        (display)
      Lisp_Object display;
 {
@@ -4259,17 +4432,17 @@ If omitted or nil, that stands for the selected frame's display.")
     default:
       error ("Display has an unknown visual class");
     }
-#endif
+#endif /* 0 */
 
   error ("Display has an unknown visual class");
 }
 
 DEFUN ("x-display-save-under", Fx_display_save_under,
-  Sx_display_save_under, 0, 1, 0,
-  "Returns t if the display DISPLAY supports the save-under feature.\n\
-The optional argument DISPLAY specifies which display to ask about.\n\
-DISPLAY should be either a frame or a display name (a string).\n\
-If omitted or nil, that stands for the selected frame's display.")
+       Sx_display_save_under, 0, 1, 0,
+       doc: /* Returns t if the display DISPLAY supports the save-under feature.
+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.  */)
   (display)
      Lisp_Object display;
 {
@@ -4321,7 +4494,7 @@ x_display_info_for_name (name)
   Lisp_Object names;
   struct mac_display_info *dpyinfo;
 
-  CHECK_STRING (name, 0);
+  CHECK_STRING (name);
 
   for (dpyinfo = &one_mac_display_info, names = x_display_name_list;
        dpyinfo;
@@ -4338,7 +4511,7 @@ x_display_info_for_name (name)
 
   validate_x_resource_name ();
 
-  dpyinfo = x_term_init (name, (unsigned char *) 0,
+  dpyinfo = mac_term_init (name, (unsigned char *) 0,
                           (char *) XSTRING (Vx_resource_name)->data);
 
   if (dpyinfo == 0)
@@ -4352,20 +4525,21 @@ x_display_info_for_name (name)
 
 #if 0 /* MAC_TODO: implement network support */
 DEFUN ("x-open-connection", Fx_open_connection, Sx_open_connection,
-       1, 3, 0, "Open a connection to a server.\n\
-DISPLAY is the name of the display to connect to.\n\
-Optional second arg XRM-STRING is a string of resources in xrdb format.\n\
-If the optional third arg MUST-SUCCEED is non-nil,\n\
-terminate Emacs if we can't open the connection.")
+       1, 3, 0,
+       doc: /* Open a connection to a server.
+DISPLAY is the name of the display to connect to.
+Optional second arg XRM-STRING is a string of resources in xrdb format.
+If the optional third arg MUST-SUCCEED is non-nil,
+terminate Emacs if we can't open the connection.  */)
   (display, xrm_string, must_succeed)
      Lisp_Object display, xrm_string, must_succeed;
 {
   unsigned char *xrm_option;
   struct mac_display_info *dpyinfo;
 
-  CHECK_STRING (display, 0);
+  CHECK_STRING (display);
   if (! NILP (xrm_string))
-    CHECK_STRING (xrm_string, 1);
+    CHECK_STRING (xrm_string);
 
   if (! EQ (Vwindow_system, intern ("mac")))
     error ("Not using Mac OS");
@@ -4399,9 +4573,9 @@ terminate Emacs if we can't open the connection.")
 
 DEFUN ("x-close-connection", Fx_close_connection,
        Sx_close_connection, 1, 1, 0,
-   "Close the connection to DISPLAY's server.\n\
-For DISPLAY, specify either a frame or a display name (a string).\n\
-If DISPLAY is nil, that stands for the selected frame's display.")
+       doc: /* Close the connection to DISPLAY's server.
+For DISPLAY, specify either a frame or a display name (a string).
+If DISPLAY is nil, that stands for the selected frame's display.  */)
   (display)
   Lisp_Object display;
 {
@@ -4428,10 +4602,10 @@ If DISPLAY is nil, that stands for the selected frame's display.")
 
   return Qnil;
 }
-#endif
+#endif /* 0 */
 
 DEFUN ("x-display-list", Fx_display_list, Sx_display_list, 0, 0, 0,
-  "Return the list of display names that Emacs has connections to.")
+       doc: /* Return the list of display names that Emacs has connections to.  */)
   ()
 {
   Lisp_Object tail, result;
@@ -4444,12 +4618,12 @@ DEFUN ("x-display-list", Fx_display_list, Sx_display_list, 0, 0, 0,
 }
 
 DEFUN ("x-synchronize", Fx_synchronize, Sx_synchronize, 1, 2, 0,
-   "If ON is non-nil, report errors as soon as the erring request is made.\n\
-If ON is nil, allow buffering of requests.\n\
-This is a noop on W32 systems.\n\
-The optional second argument DISPLAY specifies which display to act on.\n\
-DISPLAY should be either a frame or a display name (a string).\n\
-If DISPLAY is omitted or nil, that stands for the selected frame's display.")
+       doc: /* If ON is non-nil, report errors as soon as the erring request is made.
+If ON is nil, allow buffering of requests.
+This is a noop on Mac OS systems.
+The optional second argument DISPLAY specifies which display to act on.
+DISPLAY should be either a frame or a display name (a string).
+If DISPLAY is omitted or nil, that stands for the selected frame's display.  */)
   (on, display)
     Lisp_Object display, on;
 {
@@ -4482,8 +4656,8 @@ Lisp_Object Qxbm;
 /* Keywords.  */
 
 extern Lisp_Object QCwidth, QCheight, QCforeground, QCbackground, QCfile;
-extern Lisp_Object QCdata;
-Lisp_Object QCtype, QCascent, QCmargin, QCrelief;
+extern Lisp_Object QCdata, QCtype;
+Lisp_Object QCascent, QCmargin, QCrelief;
 Lisp_Object QCconversion, QCcolor_symbols, QCheuristic_mask;
 Lisp_Object QCindex;
 
@@ -4953,7 +5127,7 @@ x_clear_image (f, img)
       img->colors = NULL;
       img->ncolors = 0;
     }
-#endif
+#endif /* MAC_TODO */
 }
 
 
@@ -4989,7 +5163,7 @@ x_alloc_image_color (f, img, color_name, dflt)
   else
     result = dflt;
   return result;
-#endif
+#endif /* MAC_TODO */
   return 0;
 }
 
@@ -5039,8 +5213,8 @@ free_image_cache (f)
       for (i = 0; i < c->used; ++i)
        free_image (f, c->images[i]);
       xfree (c->images);
-      xfree (c);
       xfree (c->buckets);
+      xfree (c);
       FRAME_X_IMAGE_CACHE (f) = NULL;
     }
 }
@@ -5096,9 +5270,9 @@ clear_image_cache (f, force_p)
 
 DEFUN ("clear-image-cache", Fclear_image_cache, Sclear_image_cache,
        0, 1, 0,
-  "Clear the image cache of FRAME.\n\
-FRAME nil or omitted means use the selected frame.\n\
-FRAME t means clear the image caches of all frames.")
+       doc: /* Clear the image cache of FRAME.
+FRAME nil or omitted means use the selected frame.
+FRAME t means clear the image caches of all frames.  */)
   (frame)
      Lisp_Object frame;
 {
@@ -5154,6 +5328,7 @@ lookup_image (f, spec)
       img = make_image (spec, hash);
       cache_image (f, img);
       img->load_failed_p = img->type->load (f, img) == 0;
+      xassert (!interrupt_input_blocked);
 
       /* If we can't load the image, and we don't have a width and
         height, use some arbitrary width and height so that we can
@@ -5331,7 +5506,7 @@ x_create_x_image_and_pixmap (f, width, height, depth, ximg, pixmap)
       image_error ("Unable to create X pixmap", Qnil, Qnil);
       return 0;
     }
-#endif
+#endif /* MAC_TODO */
   return 1;
 }
 
@@ -5369,7 +5544,7 @@ x_put_x_image (f, ximg, pixmap, width, height)
   XFreeGC (NULL, gc);
 }
 
-#endif
+#endif /* MAC_TODO */
 
 \f
 /***********************************************************************
@@ -5888,7 +6063,7 @@ xbm_load_image_from_file (f, img, specified_file)
        success_p = 1;
       
       UNBLOCK_INPUT;
-#endif
+#endif /* MAC_TODO */
     }
   else
     image_error ("Error loading XBM image `%s'", img->spec, Qnil);
@@ -6489,7 +6664,7 @@ x_laplace_write_row (f, pixels, width, ximg, y)
   for (x = 0; x < width; ++x)
     XPutPixel (ximg, x, y, pixels[x]);
 }
-#endif
+#endif /* MAC_TODO */
 
 /* Transform image IMG which is used on frame F with a Laplace
    edge-detection algorithm.  The result is an image that can be used
@@ -8807,9 +8982,9 @@ x_kill_gs_process (pixmap, f)
 
 DEFUN ("x-change-window-property", Fx_change_window_property,
        Sx_change_window_property, 2, 3, 0,
-  "Change window property PROP to VALUE on the X window of FRAME.\n\
-PROP and VALUE must be strings.  FRAME nil or omitted means use the\n\
-selected frame.  Value is VALUE.")
+       doc: /* Change window property PROP to VALUE on the X window of FRAME.
+PROP and VALUE must be strings.  FRAME nil or omitted means use the
+selected frame.  Value is VALUE.  */)
   (prop, value, frame)
      Lisp_Object frame, prop, value;
 {
@@ -8817,8 +8992,8 @@ selected frame.  Value is VALUE.")
   struct frame *f = check_x_frame (frame);
   Atom prop_atom;
 
-  CHECK_STRING (prop, 1);
-  CHECK_STRING (value, 2);
+  CHECK_STRING (prop);
+  CHECK_STRING (value);
 
   BLOCK_INPUT;
   prop_atom = XInternAtom (FRAME_W32_DISPLAY (f), XSTRING (prop)->data, False);
@@ -8838,8 +9013,8 @@ selected frame.  Value is VALUE.")
 
 DEFUN ("x-delete-window-property", Fx_delete_window_property,
        Sx_delete_window_property, 1, 2, 0,
-  "Remove window property PROP from X window of FRAME.\n\
-FRAME nil or omitted means use the selected frame.  Value is PROP.")
+       doc: /* Remove window property PROP from X window of FRAME.
+FRAME nil or omitted means use the selected frame.  Value is PROP.  */)
   (prop, frame)
      Lisp_Object prop, frame;
 {
@@ -8848,7 +9023,7 @@ FRAME nil or omitted means use the selected frame.  Value is PROP.")
   struct frame *f = check_x_frame (frame);
   Atom prop_atom;
 
-  CHECK_STRING (prop, 1);
+  CHECK_STRING (prop);
   BLOCK_INPUT;
   prop_atom = XInternAtom (FRAME_W32_DISPLAY (f), XSTRING (prop)->data, False);
   XDeleteProperty (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f), prop_atom);
@@ -8864,10 +9039,10 @@ FRAME nil or omitted means use the selected frame.  Value is PROP.")
 
 DEFUN ("x-window-property", Fx_window_property, Sx_window_property,
        1, 2, 0,
-  "Value is the value of window property PROP on FRAME.\n\
-If FRAME is nil or omitted, use the selected frame.  Value is nil\n\
-if FRAME hasn't a property with name PROP or if PROP has no string\n\
-value.")
+       doc: /* Value is the value of window property PROP on FRAME.
+If FRAME is nil or omitted, use the selected frame.  Value is nil
+if FRAME hasn't a property with name PROP or if PROP has no string
+value.  */)
   (prop, frame)
      Lisp_Object prop, frame;
 {
@@ -8882,7 +9057,7 @@ value.")
   int actual_format;
   unsigned long actual_size, bytes_remaining;
 
-  CHECK_STRING (prop, 1);
+  CHECK_STRING (prop);
   BLOCK_INPUT;
   prop_atom = XInternAtom (FRAME_W32_DISPLAY (f), XSTRING (prop)->data, False);
   rc = XGetWindowProperty (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f),
@@ -8919,7 +9094,7 @@ value.")
 
 \f
 /***********************************************************************
-                               Busy cursor
+                               Hourglass cursor
  ***********************************************************************/
 
 /* If non-null, an asynchronous timer that, when it expires, displays
@@ -8951,7 +9126,7 @@ static void hide_hourglass P_ ((void));
 void
 start_hourglass ()
 {
-#if 0 /* TODO: cursor shape changes.  */
+#if 0 /* MAC_TODO: cursor shape changes.  */
   EMACS_TIME delay;
   int secs, usecs = 0;
   
@@ -8973,8 +9148,8 @@ start_hourglass ()
   
   EMACS_SET_SECS_USECS (delay, secs, usecs);
   hourglass_atimer = start_atimer (ATIMER_RELATIVE, delay,
-                                  show_hourglass, NULL);
-#endif
+                                    show_hourglass, NULL);
+#endif /* MAC_TODO */
 }
 
 
@@ -9050,7 +9225,7 @@ show_hourglass (timer)
       hourglass_shown_p = 1;
       UNBLOCK_INPUT;
     }
-#endif
+#endif /* MAC_TODO */
 }
 
 
@@ -9059,7 +9234,7 @@ show_hourglass (timer)
 static void
 hide_hourglass ()
 {
-#if 0 /* TODO: cursor shape changes.  */
+#if 0 /* MAC_TODO: cursor shape changes.  */
   if (hourglass_shown_p)
     {
       Lisp_Object rest, frame;
@@ -9085,7 +9260,7 @@ hide_hourglass ()
       hourglass_shown_p = 0;
       UNBLOCK_INPUT;
     }
-#endif
+#endif /* MAC_TODO */
 }
 
 
@@ -9094,7 +9269,7 @@ hide_hourglass ()
                                Tool tips
  ***********************************************************************/
 
-static Lisp_Object x_create_tip_frame P_ ((struct w32_display_info *,
+static Lisp_Object x_create_tip_frame P_ ((struct mac_display_info *,
                                           Lisp_Object));
      
 /* The frame of a currently visible tooltip, or null.  */
@@ -9107,12 +9282,17 @@ Lisp_Object tip_frame;
 Lisp_Object tip_timer;
 Window tip_window;
 
+/* If non-nil, a vector of 3 elements containing the last args
+   with which x-show-tip was called.  See there.  */
+
+Lisp_Object last_show_tip_args;
+
 /* Create a frame for a tooltip on the display described by DPYINFO.
    PARMS is a list of frame parameters.  Value is the frame.  */
 
 static Lisp_Object
 x_create_tip_frame (dpyinfo, parms)
-     struct w32_display_info *dpyinfo;
+     struct mac_display_info *dpyinfo;
      Lisp_Object parms;
 {
 #if 0 /* MAC_TODO : Mac version */
@@ -9345,26 +9525,26 @@ x_create_tip_frame (dpyinfo, parms)
   return Qnil;
 }
 
-#ifdef TODO /* Tooltip support not complete.  */
+
 DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, 0,
-  "Show STRING in a \"tooltip\" window on frame FRAME.\n\
-A tooltip window is a small window displaying a string.\n\
-\n\
-FRAME nil or omitted means use the selected frame.\n\
-\n\
-PARMS is an optional list of frame parameters which can be\n\
-used to change the tooltip's appearance.\n\
-\n\
-Automatically hide the tooltip after TIMEOUT seconds.\n\
-TIMEOUT nil means use the default timeout of 5 seconds.\n\
-\n\
-If the list of frame parameters PARAMS contains a `left' parameters,\n\
-the tooltip is displayed at that x-position.  Otherwise it is\n\
-displayed at the mouse position, with offset DX added (default is 5 if\n\
-DX isn't specified).  Likewise for the y-position; if a `top' frame\n\
-parameter is specified, it determines the y-position of the tooltip\n\
-window, otherwise it is displayed at the mouse position, with offset\n\
-DY added (default is 10).")
+       doc : /* Show STRING in a "tooltip" window on frame FRAME.
+A tooltip window is a small window displaying a string.
+
+FRAME nil or omitted means use the selected frame.
+
+PARMS is an optional list of frame parameters which can be used to
+change the tooltip's appearance.
+
+Automatically hide the tooltip after TIMEOUT seconds.  TIMEOUT nil
+means use the default timeout of 5 seconds.
+
+If the list of frame parameters PARAMS contains a `left' parameters,
+the tooltip is displayed at that x-position.  Otherwise it is
+displayed at the mouse position, with offset DX added (default is 5 if
+DX isn't specified).  Likewise for the y-position; if a `top' frame
+parameter is specified, it determines the y-position of the tooltip
+window, otherwise it is displayed at the mouse position, with offset
+DY added (default is 10).  */)
   (string, frame, parms, timeout, dx, dy)
      Lisp_Object string, frame, parms, timeout, dx, dy;
 {
@@ -9385,22 +9565,22 @@ DY added (default is 10).")
 
   GCPRO4 (string, parms, frame, timeout);
 
-  CHECK_STRING (string, 0);
+  CHECK_STRING (string);
   f = check_x_frame (frame);
   if (NILP (timeout))
     timeout = make_number (5);
   else
-    CHECK_NATNUM (timeout, 2);
+    CHECK_NATNUM (timeout);
 
   if (NILP (dx))
     dx = make_number (5);
   else
-    CHECK_NUMBER (dx, 5);
+    CHECK_NUMBER (dx);
   
   if (NILP (dy))
     dy = make_number (-10);
   else
-    CHECK_NUMBER (dy, 6);
+    CHECK_NUMBER (dy);
 
   if (NILP (last_show_tip_args))
     last_show_tip_args = Fmake_vector (make_number (3), Qnil);
@@ -9425,11 +9605,13 @@ DY added (default is 10).")
              call1 (Qcancel_timer, timer);
            }
 
+#if 0 /* MAC_TODO : Mac specifics */
          BLOCK_INPUT;
          compute_tip_xy (f, parms, dx, dy, &root_x, &root_y);
          XMoveWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
                       root_x, root_y - PIXEL_HEIGHT (f));
          UNBLOCK_INPUT;
+#endif /* MAC_TODO */
          goto start_timer;
        }
     }
@@ -9517,15 +9699,17 @@ DY added (default is 10).")
 
   /* Move the tooltip window where the mouse pointer is.  Resize and
      show it.  */
+#if 0 /* TODO : Mac specifics */
   compute_tip_xy (f, parms, dx, dy, &root_x, &root_y);
 
-#if 0 /* TODO : Mac specifics */
   BLOCK_INPUT;
-  XMoveResizeWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
-                    root_x, root_y - height, width, height);
-  XMapRaised (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f));
+  XQueryPointer (FRAME_W32_DISPLAY (f), FRAME_W32_DISPLAY_INFO (f)->root_window,
+                &root, &child, &root_x, &root_y, &win_x, &win_y, &pmask);
+  XMoveResizeWindow (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f),
+                    root_x + 5, root_y - height - 5, width, height);
+  XMapRaised (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f));
   UNBLOCK_INPUT;
-#endif /* TODO */
+#endif /* MAC_TODO */
 
   /* Draw into the window.  */
   w->must_be_updated_p = 1;
@@ -9546,8 +9730,8 @@ DY added (default is 10).")
 
 
 DEFUN ("x-hide-tip", Fx_hide_tip, Sx_hide_tip, 0, 0, 0,
-  "Hide the current tooltip window, if there is any.\n\
-Value is t is tooltip was open, nil otherwise.")
+       doc: /* Hide the current tooltip window, if there is any.
+Value is t is tooltip was open, nil otherwise.  */)
   ()
 {
   int count;
@@ -9579,7 +9763,6 @@ Value is t is tooltip was open, nil otherwise.")
   UNGCPRO;
   return unbind_to (count, deleted);
 }
-#endif
 
 
 \f
@@ -9591,11 +9774,11 @@ Value is t is tooltip was open, nil otherwise.")
 extern Lisp_Object Qfile_name_history;
 
 DEFUN ("x-file-dialog", Fx_file_dialog, Sx_file_dialog, 2, 4, 0,
-  "Read file name, prompting with PROMPT in directory DIR.\n\
-Use a file selection dialog.\n\
-Select DEFAULT-FILENAME in the dialog's file selection box, if\n\
-specified.  Don't let the user enter a file name in the file\n\
-selection dialog's entry field, if MUSTMATCH is non-nil.")
+       doc: /* Read file name, prompting with PROMPT in directory DIR.
+Use a file selection dialog.
+Select DEFAULT-FILENAME in the dialog's file selection box, if
+specified.  Don't let the user enter a file name in the file
+selection dialog's entry field, if MUSTMATCH is non-nil.  */)
   (prompt, dir, default_filename, mustmatch)
      Lisp_Object prompt, dir, default_filename, mustmatch;
 {
@@ -9608,8 +9791,8 @@ selection dialog's entry field, if MUSTMATCH is non-nil.")
   int use_dialog_p = 1;
 
   GCPRO5 (prompt, dir, default_filename, mustmatch, file);
-  CHECK_STRING (prompt, 0);
-  CHECK_STRING (dir, 1);
+  CHECK_STRING (prompt);
+  CHECK_STRING (dir);
 
   /* Create the dialog with PROMPT as title, using DIR as initial
      directory and using "*" as pattern.  */
@@ -9692,7 +9875,7 @@ selection dialog's entry field, if MUSTMATCH is non-nil.")
 
   return unbind_to (count, file);
 }
-#endif
+#endif /* MAC_TODO */
 
 
 \f
@@ -9703,7 +9886,7 @@ selection dialog's entry field, if MUSTMATCH is non-nil.")
 #if GLYPH_DEBUG
 
 DEFUN ("imagep", Fimagep, Simagep, 1, 1, 0,
-  "Value is non-nil if SPEC is a valid image specification.")
+       doc: /* Value is non-nil if SPEC is a valid image specification.  */)
   (spec)
      Lisp_Object spec;
 {
@@ -9801,8 +9984,6 @@ syms_of_macfns ()
   staticpro (&Qline_spacing);
   Qcenter = intern ("center");
   staticpro (&Qcenter);
-  Qcancel_timer = intern ("cancel-timer");
-  staticpro (&Qcancel_timer);
   /* This is the end of symbol initialization.  */
 
   Qhyper = intern ("hyper");
@@ -9839,22 +10020,22 @@ syms_of_macfns ()
   init_x_parm_symbols ();
 
   DEFVAR_LISP ("x-bitmap-file-path", &Vx_bitmap_file_path,
-    "List of directories to search for bitmap files for w32.");
+              doc: /* List of directories to search for bitmap files for w32.  */);
   Vx_bitmap_file_path = decode_env_path ((char *) 0, "PATH");
 
   DEFVAR_LISP ("x-pointer-shape", &Vx_pointer_shape,
-    "The shape of the pointer when over text.\n\
-Changing the value does not affect existing frames\n\
-unless you set the mouse color.");
+              doc: /* The shape of the pointer when over text.
+Changing the value does not affect existing frames
+unless you set the mouse color.  */);
   Vx_pointer_shape = Qnil;
 
   DEFVAR_LISP ("x-resource-name", &Vx_resource_name,
-    "The name Emacs uses to look up resources; for internal use only.\n\
-`x-get-resource' uses this as the first component of the instance name\n\
-when requesting resource values.\n\
-Emacs initially sets `x-resource-name' to the name under which Emacs\n\
-was invoked, or to the value specified with the `-name' or `-rn'\n\
-switches, if present.");
+              doc: /* The name Emacs uses to look up resources; for internal use only.
+`x-get-resource' uses this as the first component of the instance name
+when requesting resource values.
+Emacs initially sets `x-resource-name' to the name under which Emacs
+was invoked, or to the value specified with the `-name' or `-rn'
+switches, if present.  */);
   Vx_resource_name = Qnil;
 
   Vx_nontext_pointer_shape = Qnil;
@@ -9862,54 +10043,54 @@ switches, if present.");
   Vx_mode_pointer_shape = Qnil;
 
   DEFVAR_LISP ("x-hourglass-pointer-shape", &Vx_hourglass_pointer_shape,
-    "The shape of the pointer when Emacs is busy.\n\
-This variable takes effect when you create a new frame\n\
-or when you set the mouse color.");
+              doc: /* The shape of the pointer when Emacs is hourglass.
+This variable takes effect when you create a new frame
+or when you set the mouse color.  */);
   Vx_hourglass_pointer_shape = Qnil;
 
   DEFVAR_BOOL ("display-hourglass", &display_hourglass_p,
-    "Non-zero means Emacs displays an hourglass pointer on window systems.");
+              doc: /* Non-zero means Emacs displays an hourglass pointer on window systems.  */);
   display_hourglass_p = 1;
   
   DEFVAR_LISP ("hourglass-delay", &Vhourglass_delay,
-     "*Seconds to wait before displaying an hourglass pointer.\n\
-Value must be an integer or float.");
+              doc: /* *Seconds to wait before displaying an hourglass pointer.
+Value must be an integer or float.  */);
   Vhourglass_delay = make_number (DEFAULT_HOURGLASS_DELAY);
 
   DEFVAR_LISP ("x-sensitive-text-pointer-shape",
-             &Vx_sensitive_text_pointer_shape,
-             "The shape of the pointer when over mouse-sensitive text.\n\
-This variable takes effect when you create a new frame\n\
-or when you set the mouse color.");
+              &Vx_sensitive_text_pointer_shape,
+              doc: /* The shape of the pointer when over mouse-sensitive text.
+This variable takes effect when you create a new frame
+or when you set the mouse color.  */);
   Vx_sensitive_text_pointer_shape = Qnil;
 
   DEFVAR_LISP ("x-cursor-fore-pixel", &Vx_cursor_fore_pixel,
-              "A string indicating the foreground color of the cursor box.");
+              doc: /* A string indicating the foreground color of the cursor box.  */);
   Vx_cursor_fore_pixel = Qnil;
 
   DEFVAR_LISP ("x-no-window-manager", &Vx_no_window_manager,
-              "Non-nil if no window manager is in use.\n\
-Emacs doesn't try to figure this out; this is always nil\n\
-unless you set it to something else.");
+              doc: /* Non-nil if no window manager is in use.
+Emacs doesn't try to figure this out; this is always nil
+unless you set it to something else.  */);
   /* We don't have any way to find this out, so set it to nil
      and maybe the user would like to set it to t.  */
   Vx_no_window_manager = Qnil;
 
   DEFVAR_LISP ("x-pixel-size-width-font-regexp",
               &Vx_pixel_size_width_font_regexp,
-     "Regexp matching a font name whose width is the same as `PIXEL_SIZE'.\n\
-\n\
-Since Emacs gets width of a font matching with this regexp from\n\
-PIXEL_SIZE field of the name, font finding mechanism gets faster for\n\
-such a font.  This is especially effective for such large fonts as\n\
-Chinese, Japanese, and Korean.");
+              doc: /* Regexp matching a font name whose width is the same as `PIXEL_SIZE'.
+
+Since Emacs gets width of a font matching with this regexp from
+PIXEL_SIZE field of the name, font finding mechanism gets faster for
+such a font.  This is especially effective for such large fonts as
+Chinese, Japanese, and Korean.  */);
   Vx_pixel_size_width_font_regexp = Qnil;
 
   DEFVAR_LISP ("image-cache-eviction-delay", &Vimage_cache_eviction_delay,
-     "Time after which cached images are removed from the cache.\n\
-When an image has not been displayed this many seconds, remove it\n\
-from the image cache.  Value must be an integer or nil with nil\n\
-meaning don't clear the cache.");
+              doc: /* Time after which cached images are removed from the cache.
+When an image has not been displayed this many seconds, remove it
+from the image cache.  Value must be an integer or nil with nil
+meaning don't clear the cache.  */);
   Vimage_cache_eviction_delay = make_number (30 * 60);
 
 #if 0 /* MAC_TODO: implement get X resource */
@@ -10024,18 +10205,15 @@ meaning don't clear the cache.");
   defsubr (&Simagep);
   defsubr (&Slookup_image);
 #endif
-#endif /* TODO */
+#endif /* MAC_TODO */
 
   hourglass_atimer = NULL;
   hourglass_shown_p = 0;
-#ifdef TODO /* Tooltip support not complete.  */
+
   defsubr (&Sx_show_tip);
   defsubr (&Sx_hide_tip);
-#endif
-  tip_timer = Qnil;
   staticpro (&tip_timer);
-  tip_frame = Qnil;
-  staticpro (&tip_frame);
+  tip_timer = Qnil;
 
 #if 0 /* MAC_TODO */
   defsubr (&Sx_file_dialog);
@@ -10049,8 +10227,8 @@ init_xfns ()
   image_types = NULL;
   Vimage_types = Qnil;
 
-#if 0 /* TODO : Image support for W32 */
   define_image_type (&xbm_type);
+#if 0 /* NTEMACS_TODO : Image support for W32 */
   define_image_type (&gs_type);
   define_image_type (&pbm_type);
   
@@ -10075,38 +10253,3 @@ init_xfns ()
 #endif
 #endif /* NTEMACS_TODO */
 }
-
-#undef abort
-
-#if 0
-void 
-w32_abort()
-{
-  int button;
-  button = MessageBox (NULL,
-                      "A fatal error has occurred!\n\n"
-                      "Select Abort to exit, Retry to debug, Ignore to continue",
-                      "Emacs Abort Dialog",
-                      MB_ICONEXCLAMATION | MB_TASKMODAL
-                      | MB_SETFOREGROUND | MB_ABORTRETRYIGNORE);
-  switch (button)
-    {
-    case IDRETRY:
-      DebugBreak ();
-      break;
-    case IDIGNORE:
-      break;
-    case IDABORT:
-    default:
-      abort ();
-      break;
-    }
-}
-
-/* For convenience when debugging.  */
-int
-w32_last_error()
-{
-  return GetLastError ();
-}
-#endif
similarity index 92%
rename from mac/inc/macgui.h
rename to src/macgui.h
index 1072bce..a6ad18f 100644 (file)
@@ -1,5 +1,5 @@
 /* Definitions and headers for communication on the Mac OS.
-   Copyright (C) 2000 Free Software Foundation, Inc.
+   Copyright (C) 2000, 2001 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -18,22 +18,24 @@ along with GNU Emacs; see the file COPYING.  If not, write to
 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
-/* Contributed by Andrew Choi (akochoi@users.sourceforge.net).  */
+/* Contributed by Andrew Choi (akochoi@mac.com).  */
 
 #ifndef EMACS_MACGUI_H
 #define EMACS_MACGUI_H
 
-#include <MacTypes.h>
-#include <Quickdraw.h>
-
 typedef int Pixmap;
 typedef int Bitmap;
 
 typedef int Display;  /* fix later */
 
 typedef unsigned long Time;
-typedef RGBColor Color;
+
+#if MAC_OSX
+typedef struct OpaqueWindowPtr* Window;
+#else
+#include <QuickDraw.h>
 typedef WindowPtr Window;
+#endif
 
 #define FACE_DEFAULT (~0)
 
@@ -51,9 +53,9 @@ typedef struct _XCharStruct
 struct MacFontStruct {
   char *fontname;
 
-  SInt16 mac_fontnum;  /* font number of font used in this window */
+  short mac_fontnum;  /* font number of font used in this window */
   int mac_fontsize;  /* size of font */
-  Style mac_fontface;  /* plain, bold, italics, etc. */
+  short mac_fontface;  /* plain, bold, italics, etc. */
   short mac_scriptcode;  /* Mac OS script code for font used */
 
 #if 0
@@ -67,14 +69,14 @@ struct MacFontStruct {
   int mDescent;
   int mLeading;
   char mTwoByte;  /* true for two-byte font */
-#endif
+#endif /* 0 */
 
 /* from Xlib.h */
 #if 0
   XExtData *ext_data;      /* hook for extension to hang data */
   Font fid;                /* Font id for this font */
   unsigned direction;      /* hint about the direction font is painted */
-#endif
+#endif /* 0 */
   unsigned min_char_or_byte2;/* first character */
   unsigned max_char_or_byte2;/* last character */
   unsigned min_byte1;      /* first row that exists */
@@ -84,7 +86,7 @@ struct MacFontStruct {
   unsigned default_char;   /* char to print for undefined character */
   int n_properties;        /* how many properties there are */
   XFontProp *properties;   /* pointer to array of additional properties */
-#endif
+#endif /* 0 */
   XCharStruct min_bounds;  /* minimum bounds over all existing char */
   XCharStruct max_bounds;  /* maximum bounds over all existing char */
   XCharStruct *per_char;   /* first_char to last_char information */
similarity index 78%
rename from mac/src/macmenu.c
rename to src/macmenu.c
index b7ed55a..f9498cd 100644 (file)
@@ -1,5 +1,5 @@
 /* Menu support for GNU Emacs on the for Mac OS.
-   Copyright (C) 2000 Free Software Foundation, Inc.
+   Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -18,7 +18,7 @@ along with GNU Emacs; see the file COPYING.  If not, write to
 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
-/* Contributed by Andrew Choi (akochoi@users.sourceforge.net).  */
+/* Contributed by Andrew Choi (akochoi@mac.com).  */
 
 #include <config.h>
 #include <signal.h>
@@ -26,15 +26,40 @@ Boston, MA 02111-1307, USA.  */
 #include <stdio.h>
 #include "lisp.h"
 #include "termhooks.h"
+#include "keyboard.h"
+#include "keymap.h"
 #include "frame.h"
 #include "window.h"
-#include "keyboard.h"
 #include "blockinput.h"
 #include "buffer.h"
 #include "charset.h"
 #include "coding.h"
-#include "keymap.h"
 
+#ifdef MAC_OSX
+#undef mktime
+#undef DEBUG
+#undef Z
+#undef free
+#undef malloc
+#undef realloc
+/* Macros max and min defined in lisp.h conflict with those in
+   precompiled header Carbon.h.  */
+#undef max
+#undef min
+#include <Carbon/Carbon.h>
+#undef Z
+#define Z (current_buffer->text->z)
+#undef free
+#define free unexec_free
+#undef malloc
+#define malloc unexec_malloc
+#undef realloc
+#define realloc unexec_realloc
+#undef min
+#define min(a, b) ((a) < (b) ? (a) : (b))
+#undef max
+#define max(a, b) ((a) > (b) ? (a) : (b))
+#else /* not MAC_OSX */
 #include <MacTypes.h>
 #include <Menus.h>
 #include <QuickDraw.h>
@@ -43,9 +68,10 @@ Boston, MA 02111-1307, USA.  */
 #include <Controls.h>
 #include <Windows.h>
 #include <Events.h>
-#if defined (__MRC__) || defined (CODEWARRIOR_VERSION_6)
+#if defined (__MRC__) || (__MSL__ >= 0x6000)
 #include <ControlDefinitions.h>
 #endif
+#endif /* not MAC_OSX */
 
 /* This may include sys/types.h, and that somehow loses
    if this is not done before the other system files.  */
@@ -68,15 +94,13 @@ Boston, MA 02111-1307, USA.  */
 #define HAVE_DIALOGS 1
 
 #undef HAVE_MULTILINGUAL_MENU
+#undef HAVE_DIALOGS /* TODO: Implement native dialogs.  */
 
 /******************************************************************/
 /* Definitions copied from lwlib.h */
 
 typedef void * XtPointer;
 
-#define True 1
-#define False 0
-
 enum button_type
 {
   BUTTON_TYPE_NONE,
@@ -84,6 +108,8 @@ enum button_type
   BUTTON_TYPE_RADIO
 };
 
+/* This structure is based on the one in ../lwlib/lwlib.h, modified
+   for Mac OS.  */
 typedef struct _widget_value
 {
   /* name of widget */
@@ -92,8 +118,10 @@ typedef struct _widget_value
   char*                value;
   /* keyboard equivalent. no implications for XtTranslations */ 
   char*                key;
-  /* Help string or null if none.  */
-  char         *help;
+  /* Help string or nil if none.
+     GC finds this string through the frame's menu_bar_vector
+     or through menu_items.  */
+  Lisp_Object  help;
   /* true if enabled */
   Boolean      enabled;
   /* true if selected */
@@ -138,9 +166,6 @@ typedef struct _widget_value
 
 /******************************************************************/
 
-#define min(x,y) (((x) < (y)) ? (x) : (y))
-#define max(x,y) (((x) > (y)) ? (x) : (y))
-
 #ifndef TRUE
 #define TRUE 1
 #define FALSE 0
@@ -167,7 +192,9 @@ void set_frame_menubar ();
 static void push_menu_item P_ ((Lisp_Object, Lisp_Object, Lisp_Object,
                                Lisp_Object, Lisp_Object, Lisp_Object,
                                Lisp_Object, Lisp_Object));
+#ifdef HAVE_DIALOGS
 static Lisp_Object mac_dialog_show ();
+#endif
 static Lisp_Object mac_menu_show ();
 
 static void keymap_panes ();
@@ -339,7 +366,7 @@ push_left_right_boundary ()
   XVECTOR (menu_items)->contents[menu_items_used++] = Qquote;
 }
 
-/* Start a new menu pane in menu_items..
+/* Start a new menu pane in menu_items.
    NAME is the pane name.  PREFIX_VEC is a prefix key for this pane.  */
 
 static void
@@ -400,7 +427,8 @@ keymap_panes (keymaps, nmaps, notreal)
      But don't make a pane that is empty--ignore that map instead.
      P is the number of panes we have made so far.  */
   for (mapno = 0; mapno < nmaps; mapno++)
-    single_keymap_panes (keymaps[mapno], Qnil, Qnil, notreal, 10);
+    single_keymap_panes (keymaps[mapno],
+                         Fkeymap_prompt (keymaps[mapno]), Qnil, notreal, 10);
 
   finish_menu_items ();
 }
@@ -553,10 +581,10 @@ list_of_panes (menu)
       Lisp_Object elt, pane_name, pane_data;
       elt = Fcar (tail);
       pane_name = Fcar (elt);
-      CHECK_STRING (pane_name, 0);
+      CHECK_STRING (pane_name);
       push_menu_pane (pane_name, Qnil);
       pane_data = Fcdr (elt);
-      CHECK_CONS (pane_data, 0);
+      CHECK_CONS (pane_data);
       list_of_items (pane_data);
     }
 
@@ -580,56 +608,55 @@ list_of_items (pane)
        push_left_right_boundary ();
       else
        {
-         CHECK_CONS (item, 0);
+         CHECK_CONS (item);
          item1 = Fcar (item);
-         CHECK_STRING (item1, 1);
+         CHECK_STRING (item1);
          push_menu_item (item1, Qt, Fcdr (item), Qt, Qnil, Qnil, Qnil, Qnil);
        }
     }
 }
 \f
 DEFUN ("x-popup-menu", Fx_popup_menu, Sx_popup_menu, 2, 2, 0,
-  "Pop up a deck-of-cards menu and return user's selection.\n\
-POSITION is a position specification.  This is either a mouse button event\n\
-or a list ((XOFFSET YOFFSET) WINDOW)\n\
-where XOFFSET and YOFFSET are positions in pixels from the top left\n\
-corner of WINDOW's frame.  (WINDOW may be a frame object instead of a window.)\n\
-This controls the position of the center of the first line\n\
-in the first pane of the menu, not the top left of the menu as a whole.\n\
-If POSITION is t, it means to use the current mouse position.\n\
-\n\
-MENU is a specifier for a menu.  For the simplest case, MENU is a keymap.\n\
-The menu items come from key bindings that have a menu string as well as\n\
-a definition; actually, the \"definition\" in such a key binding looks like\n\
-\(STRING . REAL-DEFINITION).  To give the menu a title, put a string into\n\
-the keymap as a top-level element.\n\n\
-If REAL-DEFINITION is nil, that puts a nonselectable string in the menu.\n\
-Otherwise, REAL-DEFINITION should be a valid key binding definition.\n\
-\n\
-You can also use a list of keymaps as MENU.\n\
-  Then each keymap makes a separate pane.\n\
-When MENU is a keymap or a list of keymaps, the return value\n\
-is a list of events.\n\n\
-\n\
-Alternatively, you can specify a menu of multiple panes\n\
-  with a list of the form (TITLE PANE1 PANE2...),\n\
-where each pane is a list of form (TITLE ITEM1 ITEM2...).\n\
-Each ITEM is normally a cons cell (STRING . VALUE);\n\
-but a string can appear as an item--that makes a nonselectable line\n\
-in the menu.\n\
-With this form of menu, the return value is VALUE from the chosen item.\n\
-\n\
-If POSITION is nil, don't display the menu at all, just precalculate the\n\
-cached information about equivalent key sequences.")
+       doc: /* Pop up a deck-of-cards menu and return user's selection.
+POSITION is a position specification.  This is either a mouse button
+event or a list ((XOFFSET YOFFSET) WINDOW) where XOFFSET and YOFFSET
+are positions in pixels from the top left corner of WINDOW's frame
+\(WINDOW may be a frame object instead of a window).  This controls the
+position of the center of the first line in the first pane of the
+menu, not the top left of the menu as a whole.  If POSITION is t, it
+means to use the current mouse position.
+
+MENU is a specifier for a menu.  For the simplest case, MENU is a keymap.
+The menu items come from key bindings that have a menu string as well as
+a definition; actually, the \"definition\" in such a key binding looks like
+\(STRING . REAL-DEFINITION).  To give the menu a title, put a string into
+the keymap as a top-level element.
+
+If REAL-DEFINITION is nil, that puts a nonselectable string in the menu.
+Otherwise, REAL-DEFINITION should be a valid key binding definition.
+
+You can also use a list of keymaps as MENU.  Then each keymap makes a
+separate pane.  When MENU is a keymap or a list of keymaps, the return
+value is a list of events.
+
+Alternatively, you can specify a menu of multiple panes with a list of
+the form (TITLE PANE1 PANE2...), where each pane is a list of
+form (TITLE ITEM1 ITEM2...).
+Each ITEM is normally a cons cell (STRING . VALUE); but a string can
+appear as an item--that makes a nonselectable line in the menu.
+With this form of menu, the return value is VALUE from the chosen item.
+
+If POSITION is nil, don't display the menu at all, just precalculate the
+cached information about equivalent key sequences.  */)
   (position, menu)
      Lisp_Object position, menu;
 {
   Lisp_Object keymap, tem;
-  int xpos, ypos;
+  int xpos = 0, ypos = 0;
   Lisp_Object title;
   char *error_name;
   Lisp_Object selection;
-  FRAME_PTR f;
+  FRAME_PTR f = NULL;
   Lisp_Object x, y, window;
   int keymaps = 0;
   int for_click = 0;
@@ -642,7 +669,8 @@ cached information about equivalent key sequences.")
 
       /* Decode the first argument: find the window and the coordinates.  */
       if (EQ (position, Qt)
-         || (CONSP (position) && EQ (XCAR (position), Qmenu_bar)))
+         || (CONSP (position) && (EQ (XCAR (position), Qmenu_bar)
+                                   || EQ (XCAR (position), Qtool_bar))))
        {
          /* Use the mouse's current position.  */
          FRAME_PTR new_f = SELECTED_FRAME ();
@@ -682,8 +710,8 @@ cached information about equivalent key sequences.")
            }
        }
 
-      CHECK_NUMBER (x, 0);
-      CHECK_NUMBER (y, 0);
+      CHECK_NUMBER (x);
+      CHECK_NUMBER (y);
 
       /* Decode where to put the menu.  */
 
@@ -695,7 +723,7 @@ cached information about equivalent key sequences.")
        }
       else if (WINDOWP (window))
        {
-         CHECK_LIVE_WINDOW (window, 0);
+         CHECK_LIVE_WINDOW (window);
          f = XFRAME (WINDOW_FRAME (XWINDOW (window)));
 
          xpos = (FONT_WIDTH (FRAME_FONT (f))
@@ -706,7 +734,7 @@ cached information about equivalent key sequences.")
       else
        /* ??? Not really clean; should be CHECK_WINDOW_OR_FRAME,
           but I don't want to make one now.  */
-       CHECK_WINDOW (window, 0);
+       CHECK_WINDOW (window);
 
       xpos += XINT (x);
       ypos += XINT (y);
@@ -721,15 +749,11 @@ cached information about equivalent key sequences.")
 
   /* Decode the menu items from what was specified.  */
 
-  keymap = Fkeymapp (menu);
-  tem = Qnil;
-  if (CONSP (menu))
-    tem = Fkeymapp (Fcar (menu));
-  if (!NILP (keymap))
+  keymap = get_keymap (menu, 0, 0);
+  if (CONSP (keymap))
     {
       /* We were given a keymap.  Extract menu info from the keymap.  */
       Lisp_Object prompt;
-      keymap = get_keymap (menu);
 
       /* Extract the detailed info to make one pane.  */
       keymap_panes (&menu, 1, NILP (position));
@@ -746,7 +770,7 @@ cached information about equivalent key sequences.")
 
       keymaps = 1;
     }
-  else if (!NILP (tem))
+  else if (CONSP (menu) && KEYMAPP (XCAR (menu)))
     {
       /* We were given a list of keymaps.  */
       int nmaps = XFASTINT (Flength (menu));
@@ -762,7 +786,7 @@ cached information about equivalent key sequences.")
        {
          Lisp_Object prompt;
 
-         maps[i++] = keymap = get_keymap (Fcar (tem));
+         maps[i++] = keymap = get_keymap (Fcar (tem), 1, 0);
 
          prompt = Fkeymap_prompt (keymap);
          if (NILP (title) && !NILP (prompt))
@@ -782,7 +806,7 @@ cached information about equivalent key sequences.")
     {
       /* We were given an old-fashioned menu.  */
       title = Fcar (menu);
-      CHECK_STRING (title, 1);
+      CHECK_STRING (title);
 
       list_of_panes (Fcdr (menu));
 
@@ -816,37 +840,39 @@ cached information about equivalent key sequences.")
 #ifdef HAVE_MENUS
 
 DEFUN ("x-popup-dialog", Fx_popup_dialog, Sx_popup_dialog, 2, 2, 0,
-  "Pop up a dialog box and return user's selection.\n\
-POSITION specifies which frame to use.\n\
-This is normally a mouse button event or a window or frame.\n\
-If POSITION is t, it means to use the frame the mouse is on.\n\
-The dialog box appears in the middle of the specified frame.\n\
-\n\
-CONTENTS specifies the alternatives to display in the dialog box.\n\
-It is a list of the form (TITLE ITEM1 ITEM2...).\n\
-Each ITEM is a cons cell (STRING . VALUE).\n\
-The return value is VALUE from the chosen item.\n\n\
-An ITEM may also be just a string--that makes a nonselectable item.\n\
-An ITEM may also be nil--that means to put all preceding items\n\
-on the left of the dialog box and all following items on the right.\n\
-\(By default, approximately half appear on each side.)")
+       doc: /* Pop up a dialog box and return user's selection.
+POSITION specifies which frame to use.
+This is normally a mouse button event or a window or frame.
+If POSITION is t, it means to use the frame the mouse is on.
+The dialog box appears in the middle of the specified frame.
+
+CONTENTS specifies the alternatives to display in the dialog box.
+It is a list of the form (TITLE ITEM1 ITEM2...).
+Each ITEM is a cons cell (STRING . VALUE).
+The return value is VALUE from the chosen item.
+
+An ITEM may also be just a string--that makes a nonselectable item.
+An ITEM may also be nil--that means to put all preceding items
+on the left of the dialog box and all following items on the right.
+\(By default, approximately half appear on each side.)  */)
   (position, contents)
      Lisp_Object position, contents;
 {
-  FRAME_PTR f;
+  FRAME_PTR f = NULL;
   Lisp_Object window;
 
   check_mac ();
 
   /* Decode the first argument: find the window or frame to use.  */
   if (EQ (position, Qt)
-      || (CONSP (position) && EQ (XCAR (position), Qmenu_bar)))
+      || (CONSP (position) && (EQ (XCAR (position), Qmenu_bar)
+                               || EQ (XCAR (position), Qtool_bar))))
     {
 #if 0 /* Using the frame the mouse is on may not be right.  */
       /* Use the mouse's current position.  */
       FRAME_PTR new_f = SELECTED_FRAME ();
       Lisp_Object bar_window;
-      int part;
+      enum scroll_bar_part part;
       unsigned long time;
       Lisp_Object x, y;
 
@@ -882,13 +908,13 @@ on the left of the dialog box and all following items on the right.\n\
     f = XFRAME (window);
   else if (WINDOWP (window))
     {
-      CHECK_LIVE_WINDOW (window, 0);
+      CHECK_LIVE_WINDOW (window);
       f = XFRAME (WINDOW_FRAME (XWINDOW (window)));
     }
   else
     /* ??? Not really clean; should be CHECK_WINDOW_OR_FRAME,
        but I don't want to make one now.  */
-    CHECK_WINDOW (window, 0);
+    CHECK_WINDOW (window);
 
 #ifndef HAVE_DIALOGS
   /* Display a menu with these alternatives
@@ -911,7 +937,7 @@ on the left of the dialog box and all following items on the right.\n\
 
     /* Decode the dialog items from what was specified.  */
     title = Fcar (contents);
-    CHECK_STRING (title, 1);
+    CHECK_STRING (title);
 
     list_of_panes (Fcons (contents, Qnil));
 
@@ -972,6 +998,7 @@ menubar_selection_callback (FRAME_PTR f, int client_data)
 
   if (!f)
     return;
+  entry = Qnil;
   subprefix_stack = (Lisp_Object *) alloca (f->menu_bar_items_used * sizeof (Lisp_Object));
   vector = f->menu_bar_vector;
   prefix = Qnil;
@@ -997,7 +1024,9 @@ menubar_selection_callback (FRAME_PTR f, int client_data)
       else
        {
          entry = XVECTOR (vector)->contents[i + MENU_ITEMS_ITEM_VALUE];
-         if (client_data == i)
+         /* The EMACS_INT cast avoids a warning.  There's no problem
+            as long as pointers have enough bits to hold small integers.  */
+         if ((int) (EMACS_INT) client_data == i)
            {
              int j;
              struct input_event buf;
@@ -1031,19 +1060,15 @@ menubar_selection_callback (FRAME_PTR f, int client_data)
              buf.arg = entry;
              kbd_buffer_store_event (&buf);
 
-#if 0
-             /* Queue this to recompute possibly updated menubar.  */
-             buf.kind = menu_bar_activate_event;
-             buf.frame_or_window = frame;
-             buf.arg = Qnil;
-             kbd_buffer_store_event (&buf);
-#endif
-
+             f->output_data.mac->menu_command_in_progress = 0;
+             f->output_data.mac->menubar_active = 0;
              return;
            }
          i += MENU_ITEMS_ITEM_LENGTH;
        }
     }
+  f->output_data.mac->menu_command_in_progress = 0;
+  f->output_data.mac->menubar_active = 0;
 }
 
 /* Allocate a widget_value, blocking input.  */
@@ -1124,8 +1149,7 @@ single_submenu (item_key, item_name, maps)
   for (i = 0; i < len; i++)
     {
       if (SYMBOLP (mapvec[i])
-         || (CONSP (mapvec[i])
-             && NILP (Fkeymapp (mapvec[i]))))
+         || (CONSP (mapvec[i]) && !KEYMAPP (mapvec[i])))
        {
          /* Here we have a command at top level in the menu bar
             as opposed to a submenu.  */
@@ -1148,6 +1172,7 @@ single_submenu (item_key, item_name, maps)
   wv->value = 0;
   wv->enabled = 1;
   wv->button_type = BUTTON_TYPE_NONE;
+  wv->help = Qnil;
   first_wv = wv;
   save_wv = 0;
   prev_wv = 0;
@@ -1184,11 +1209,16 @@ single_submenu (item_key, item_name, maps)
          /* Create a new pane.  */
          Lisp_Object pane_name, prefix;
          char *pane_string;
+
          pane_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_NAME];
          prefix = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_PREFIX];
+
 #ifndef HAVE_MULTILINGUAL_MENU
          if (STRINGP (pane_name) && STRING_MULTIBYTE (pane_name))
-           pane_name = string_make_unibyte (pane_name);
+           {
+             pane_name = ENCODE_SYSTEM (pane_name);
+             AREF (menu_items, i + MENU_ITEMS_PANE_NAME) = pane_name;
+           }
 #endif
          pane_string = (NILP (pane_name)
                         ? "" : (char *) XSTRING (pane_name)->data);
@@ -1215,6 +1245,7 @@ single_submenu (item_key, item_name, maps)
              wv->value = 0;
              wv->enabled = 1;
              wv->button_type = BUTTON_TYPE_NONE;
+             wv->help = Qnil;
            }
          save_wv = wv;
          prev_wv = 0;
@@ -1226,21 +1257,27 @@ single_submenu (item_key, item_name, maps)
          Lisp_Object item_name, enable, descrip, def, type, selected;
           Lisp_Object help;
 
-         item_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_NAME];
-         enable = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_ENABLE];
-         descrip
-           = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_EQUIV_KEY];
-         def = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_DEFINITION];
-         type = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_TYPE];
-         selected = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_SELECTED];
-         help = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_HELP];
+         item_name = AREF (menu_items, i + MENU_ITEMS_ITEM_NAME);
+         enable = AREF (menu_items, i + MENU_ITEMS_ITEM_ENABLE);
+         descrip = AREF (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY);
+         def = AREF (menu_items, i + MENU_ITEMS_ITEM_DEFINITION);
+         type = AREF (menu_items, i + MENU_ITEMS_ITEM_TYPE);
+         selected = AREF (menu_items, i + MENU_ITEMS_ITEM_SELECTED);
+         help = AREF (menu_items, i + MENU_ITEMS_ITEM_HELP);
 
 #ifndef HAVE_MULTILINGUAL_MENU
-          if (STRING_MULTIBYTE (item_name))
-            item_name = string_make_unibyte (item_name);
-          if (STRINGP (descrip) && STRING_MULTIBYTE (descrip))
-            descrip = string_make_unibyte (descrip);
-#endif
+         if (STRING_MULTIBYTE (item_name))
+           {
+             item_name = ENCODE_SYSTEM (item_name);
+             AREF (menu_items, i + MENU_ITEMS_ITEM_NAME) = item_name;
+           }
+
+         if (STRINGP (descrip) && STRING_MULTIBYTE (descrip))
+           {
+             descrip = ENCODE_SYSTEM (descrip);
+             AREF (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY) = descrip;
+           }
+#endif /* not HAVE_MULTILINGUAL_MENU */
 
          wv = xmalloc_widget_value ();
          if (prev_wv) 
@@ -1267,10 +1304,10 @@ single_submenu (item_key, item_name, maps)
            abort ();
 
          wv->selected = !NILP (selected);
-         if (STRINGP (help))
-           wv->help = (char *) XSTRING (help)->data;
-          else
-            wv->help = NULL;
+         if (!STRINGP (help))
+           help = Qnil;
+
+         wv->help = help;
 
          prev_wv = wv;
 
@@ -1305,149 +1342,203 @@ set_frame_menubar (f, first_time, deep_p)
   widget_value *wv, *first_wv, *prev_wv = 0;
   int i;
 
+  /* We must not change the menubar when actually in use.  */
+  if (f->output_data.mac->menubar_active)
+    return;
+
   XSETFRAME (Vmenu_updating_frame, f);
 
+  if (! menubar_widget)
+    deep_p = 1;
+  else if (pending_menu_activation && !deep_p)
+    deep_p = 1;
+
   wv = xmalloc_widget_value ();
   wv->name = "menubar";
   wv->value = 0;
   wv->enabled = 1;
   wv->button_type = BUTTON_TYPE_NONE;
+  wv->help = Qnil;
   first_wv = wv;
 
-  {
-    /* Make a widget-value tree representing the entire menu trees.  */
-
-    struct buffer *prev = current_buffer;
-    Lisp_Object buffer;
-    int specpdl_count = specpdl_ptr - specpdl;
-    int previous_menu_items_used = f->menu_bar_items_used;
-    Lisp_Object *previous_items
-      = (Lisp_Object *) alloca (previous_menu_items_used
-                                * sizeof (Lisp_Object));
-
-    /* If we are making a new widget, its contents are empty,
-       do always reinitialize them.  */
-    if (! menubar_widget)
-      previous_menu_items_used = 0;
-
-    buffer = XWINDOW (FRAME_SELECTED_WINDOW (f))->buffer;
-    specbind (Qinhibit_quit, Qt);
-    /* Don't let the debugger step into this code
-       because it is not reentrant.  */
-    specbind (Qdebug_on_next_call, Qnil);
-
-    record_unwind_protect (Fset_match_data, Fmatch_data (Qnil, Qnil));
-    if (NILP (Voverriding_local_map_menu_flag))
-      {
-       specbind (Qoverriding_terminal_local_map, Qnil);
-       specbind (Qoverriding_local_map, Qnil);
-      }
+  if (deep_p)
+    {
+      /* Make a widget-value tree representing the entire menu trees.  */
+
+      struct buffer *prev = current_buffer;
+      Lisp_Object buffer;
+      int specpdl_count = specpdl_ptr - specpdl;
+      int previous_menu_items_used = f->menu_bar_items_used;
+      Lisp_Object *previous_items
+       = (Lisp_Object *) alloca (previous_menu_items_used
+                                 * sizeof (Lisp_Object));
+
+      /* If we are making a new widget, its contents are empty,
+        do always reinitialize them.  */
+      if (! menubar_widget)
+       previous_menu_items_used = 0;
+
+      buffer = XWINDOW (FRAME_SELECTED_WINDOW (f))->buffer;
+      specbind (Qinhibit_quit, Qt);
+      /* Don't let the debugger step into this code
+        because it is not reentrant.  */
+      specbind (Qdebug_on_next_call, Qnil);
+
+      record_unwind_protect (Fset_match_data, Fmatch_data (Qnil, Qnil));
+      if (NILP (Voverriding_local_map_menu_flag))
+       {
+         specbind (Qoverriding_terminal_local_map, Qnil);
+         specbind (Qoverriding_local_map, Qnil);
+       }
 
-    set_buffer_internal_1 (XBUFFER (buffer));
+      set_buffer_internal_1 (XBUFFER (buffer));
 
-    /* Run the Lucid hook.  */
-    safe_run_hooks (Qactivate_menubar_hook);
-    /* If it has changed current-menubar from previous value,
-       really recompute the menubar from the value.  */
-    if (! NILP (Vlucid_menu_bar_dirty_flag))
-      call0 (Qrecompute_lucid_menubar);
-    safe_run_hooks (Qmenu_bar_update_hook);
-    FRAME_MENU_BAR_ITEMS (f) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f));
+      /* Run the Lucid hook.  */
+      safe_run_hooks (Qactivate_menubar_hook);
+      /* If it has changed current-menubar from previous value,
+        really recompute the menubar from the value.  */
+      if (! NILP (Vlucid_menu_bar_dirty_flag))
+       call0 (Qrecompute_lucid_menubar);
+      safe_run_hooks (Qmenu_bar_update_hook);
+      FRAME_MENU_BAR_ITEMS (f) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f));
 
-    items = FRAME_MENU_BAR_ITEMS (f);
+      items = FRAME_MENU_BAR_ITEMS (f);
 
-    inhibit_garbage_collection ();
+      inhibit_garbage_collection ();
 
-    /* Save the frame's previous menu bar contents data.  */
-    bcopy (XVECTOR (f->menu_bar_vector)->contents, previous_items,
-          previous_menu_items_used * sizeof (Lisp_Object));
+      /* Save the frame's previous menu bar contents data.  */
+      if (previous_menu_items_used)
+       bcopy (XVECTOR (f->menu_bar_vector)->contents, previous_items,
+              previous_menu_items_used * sizeof (Lisp_Object));
 
-    /* Fill in the current menu bar contents.  */
-    menu_items = f->menu_bar_vector;
-    menu_items_allocated = XVECTOR (menu_items)->size;
-    init_menu_items ();
-    for (i = 0; i < XVECTOR (items)->size; i += 4)
-      {
-       Lisp_Object key, string, maps;
+      /* Fill in the current menu bar contents.  */
+      menu_items = f->menu_bar_vector;
+      menu_items_allocated = VECTORP (menu_items) ? ASIZE (menu_items) : 0;
+      init_menu_items ();
+      for (i = 0; i < XVECTOR (items)->size; i += 4)
+       {
+         Lisp_Object key, string, maps;
+
+         key = XVECTOR (items)->contents[i];
+         string = XVECTOR (items)->contents[i + 1];
+         maps = XVECTOR (items)->contents[i + 2];
+         if (NILP (string))
+           break;
+
+         wv = single_submenu (key, string, maps);
+         if (prev_wv) 
+           prev_wv->next = wv;
+         else
+           first_wv->contents = wv;
+         /* Don't set wv->name here; GC during the loop might relocate it.  */
+         wv->enabled = 1;
+         wv->button_type = BUTTON_TYPE_NONE;
+         prev_wv = wv;
+       }
+
+      finish_menu_items ();
 
-       key = XVECTOR (items)->contents[i];
-       string = XVECTOR (items)->contents[i + 1];
-       maps = XVECTOR (items)->contents[i + 2];
-       if (NILP (string))
+      set_buffer_internal_1 (prev);
+      unbind_to (specpdl_count, Qnil);
+
+      /* If there has been no change in the Lisp-level contents
+        of the menu bar, skip redisplaying it.  Just exit.  */
+
+      for (i = 0; i < previous_menu_items_used; i++)
+       if (menu_items_used == i
+           || (!Fequal (previous_items[i], XVECTOR (menu_items)->contents[i])))
          break;
+      if (i == menu_items_used && i == previous_menu_items_used && i != 0)
+       {
+         free_menubar_widget_value_tree (first_wv);
+         menu_items = Qnil;
 
-       wv = single_submenu (key, string, maps);
-       if (prev_wv) 
-         prev_wv->next = wv;
-       else
-         first_wv->contents = wv;
-       /* Don't set wv->name here; GC during the loop might relocate it.  */
-       wv->enabled = 1;
-       wv->button_type = BUTTON_TYPE_NONE;
-       prev_wv = wv;
-      }
+         return;
+       }
 
-    finish_menu_items ();
+      /* Now GC cannot happen during the lifetime of the widget_value,
+        so it's safe to store data from a Lisp_String, as long as
+        local copies are made when the actual menu is created.
+        Windows takes care of this for normal string items, but
+        not for owner-drawn items or additional item-info.  */
+      wv = first_wv->contents;
+      for (i = 0; i < XVECTOR (items)->size; i += 4)
+       {
+         Lisp_Object string;
+         string = XVECTOR (items)->contents[i + 1];
+         if (NILP (string))
+           break;
+         wv->name = (char *) XSTRING (string)->data;
+         wv = wv->next;
+       }
 
-    set_buffer_internal_1 (prev);
-    unbind_to (specpdl_count, Qnil);
+      f->menu_bar_vector = menu_items;
+      f->menu_bar_items_used = menu_items_used;
+      menu_items = Qnil;
+    }
+  else
+    {
+      /* Make a widget-value tree containing
+        just the top level menu bar strings.  */
 
-    /* If there has been no change in the Lisp-level contents
-       of the menu bar, skip redisplaying it.  Just exit.  */
+      items = FRAME_MENU_BAR_ITEMS (f);
+      for (i = 0; i < XVECTOR (items)->size; i += 4)
+       {
+         Lisp_Object string;
 
-    for (i = 0; i < previous_menu_items_used; i++)
-    if (menu_items_used == i
-       || (!EQ (previous_items[i], XVECTOR (menu_items)->contents[i])))
-      break;
-    if (i == menu_items_used && i == previous_menu_items_used && i != 0)
-      {
-       free_menubar_widget_value_tree (first_wv);
-       menu_items = Qnil;
+         string = XVECTOR (items)->contents[i + 1];
+         if (NILP (string))
+           break;
 
-       return;
-      }
+         wv = xmalloc_widget_value ();
+         wv->name = (char *) XSTRING (string)->data;
+         wv->value = 0;
+         wv->enabled = 1;
+         wv->button_type = BUTTON_TYPE_NONE;
+         wv->help = Qnil;
+         /* This prevents lwlib from assuming this
+            menu item is really supposed to be empty.  */
+         /* The EMACS_INT cast avoids a warning.
+            This value just has to be different from small integers.  */
+         wv->call_data = (void *) (EMACS_INT) (-1);
 
-    /* Now GC cannot happen during the lifetime of the widget_value,
-       so it's safe to store data from a Lisp_String.  */
-    wv = first_wv->contents;
-    for (i = 0; i < XVECTOR (items)->size; i += 4)
-      {
-       Lisp_Object string;
-       string = XVECTOR (items)->contents[i + 1];
-       if (NILP (string))
-         break;
-       wv->name = (char *) XSTRING (string)->data;
-       wv = wv->next;
-      }
+         if (prev_wv) 
+           prev_wv->next = wv;
+         else
+           first_wv->contents = wv;
+         prev_wv = wv;
+       }
 
-    f->menu_bar_vector = menu_items;
-    f->menu_bar_items_used = menu_items_used;
-    menu_items = Qnil;
-  }
+      /* Forget what we thought we knew about what is in the
+        detailed contents of the menu bar menus.
+        Changing the top level always destroys the contents.  */
+      f->menu_bar_items_used = 0;
+    }
 
   /* Create or update the menu bar widget.  */
 
   BLOCK_INPUT;
 
-  f->output_data.mac->menubar_widget = NULL;  /* always NULL on Mac */
+  /* Non-null value to indicate menubar has already been "created".  */
+  f->output_data.mac->menubar_widget = 1;
 
   {
     int i = MIN_MENU_ID;
     MenuHandle menu = GetMenuHandle (i);
     while (menu != NULL)
       {
-        DeleteMenu (i);
-        DisposeMenu (menu);
-        menu = GetMenuHandle (++i);
+       DeleteMenu (i);
+       DisposeMenu (menu);
+       menu = GetMenuHandle (++i);
       }
-
+    
     i = MIN_SUBMENU_ID;
     menu = GetMenuHandle (i);
     while (menu != NULL)
       {
-        DeleteMenu (i);
-        DisposeMenu (menu);
-        menu = GetMenuHandle (++i);
+       DeleteMenu (i);
+       DisposeMenu (menu);
+       menu = GetMenuHandle (++i);
       }
   }
 
@@ -1460,10 +1551,10 @@ set_frame_menubar (f, first_time, deep_p)
   UNBLOCK_INPUT;
 }
 
-/* Called from Fx_create_frame to create the initial menubar of a
-   frame before it is mapped, so that the window is mapped with the
-   menubar already there instead of us tacking it on later and
-   thrashing the window after it is visible.  */
+/* Called from Fx_create_frame to create the initial menubar of a frame
+   before it is mapped, so that the window is mapped with the menubar already
+   there instead of us tacking it on later and thrashing the window after it
+   is visible.  */
 
 void
 initialize_frame_menubar (f)
@@ -1482,8 +1573,7 @@ void
 free_frame_menubar (f)
      FRAME_PTR f;
 {
-  /* Nothing to do since set_frame_menubar disposes of menus before
-     installing new ones.  */
+  f->output_data.mac->menubar_widget = NULL;
 }
 
 \f
@@ -1523,7 +1613,6 @@ mac_menu_show (f, x, y, for_click, keymaps, title, error)
     = (Lisp_Object *) alloca (menu_items_used * sizeof (Lisp_Object));
   int submenu_depth = 0;
   int first_pane;
-  int next_release_must_exit = 0;
 
   *error = NULL;
 
@@ -1540,6 +1629,7 @@ mac_menu_show (f, x, y, for_click, keymaps, title, error)
   wv->value = 0;
   wv->enabled = 1;
   wv->button_type = BUTTON_TYPE_NONE;
+  wv->help = Qnil;
   first_wv = wv;
   first_pane = 1;
  
@@ -1574,11 +1664,14 @@ mac_menu_show (f, x, y, for_click, keymaps, title, error)
          /* Create a new pane.  */
          Lisp_Object pane_name, prefix;
          char *pane_string;
-         pane_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_NAME];
-         prefix = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_PREFIX];
+         pane_name = AREF (menu_items, i + MENU_ITEMS_PANE_NAME);
+         prefix = AREF (menu_items, i + MENU_ITEMS_PANE_PREFIX);
 #ifndef HAVE_MULTILINGUAL_MENU
          if (STRINGP (pane_name) && STRING_MULTIBYTE (pane_name))
-           pane_name = string_make_unibyte (pane_name);
+           {
+             pane_name = ENCODE_SYSTEM (pane_name);
+             AREF (menu_items, i + MENU_ITEMS_PANE_NAME) = pane_name;
+           }
 #endif
          pane_string = (NILP (pane_name)
                         ? "" : (char *) XSTRING (pane_name)->data);
@@ -1603,6 +1696,7 @@ mac_menu_show (f, x, y, for_click, keymaps, title, error)
              wv->value = 0;
              wv->enabled = 1;
              wv->button_type = BUTTON_TYPE_NONE;
+             wv->help = Qnil;
              save_wv = wv;
              prev_wv = 0;
            }
@@ -1619,21 +1713,26 @@ mac_menu_show (f, x, y, for_click, keymaps, title, error)
          /* Create a new item within current pane.  */
          Lisp_Object item_name, enable, descrip, def, type, selected, help;
 
-         item_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_NAME];
-         enable = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_ENABLE];
-         descrip
-           = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_EQUIV_KEY];
-         def = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_DEFINITION];
-         type = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_TYPE];
-         selected = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_SELECTED];
-          help = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_HELP];
+         item_name = AREF (menu_items, i + MENU_ITEMS_ITEM_NAME);
+         enable = AREF (menu_items, i + MENU_ITEMS_ITEM_ENABLE);
+         descrip = AREF (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY);
+         def = AREF (menu_items, i + MENU_ITEMS_ITEM_DEFINITION);
+         type = AREF (menu_items, i + MENU_ITEMS_ITEM_TYPE);
+         selected = AREF (menu_items, i + MENU_ITEMS_ITEM_SELECTED);
+          help = AREF (menu_items, i + MENU_ITEMS_ITEM_HELP);
 
 #ifndef HAVE_MULTILINGUAL_MENU
-          if (STRING_MULTIBYTE (item_name))
-            item_name = string_make_unibyte (item_name);
+          if (STRINGP (item_name) && STRING_MULTIBYTE (item_name))
+           {
+             item_name = ENCODE_SYSTEM (item_name);
+             AREF (menu_items, i + MENU_ITEMS_ITEM_NAME) = item_name;
+           }
           if (STRINGP (descrip) && STRING_MULTIBYTE (descrip))
-            descrip = string_make_unibyte (descrip);
-#endif
+            {
+             descrip = ENCODE_SYSTEM (descrip);
+             AREF (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY) = descrip;
+           }
+#endif /* not HAVE_MULTILINGUAL_MENU */
 
          wv = xmalloc_widget_value ();
          if (prev_wv) 
@@ -1645,7 +1744,7 @@ mac_menu_show (f, x, y, for_click, keymaps, title, error)
            wv->key = (char *) XSTRING (descrip)->data;
          wv->value = 0;
          /* Use the contents index as call_data, since we are
-             restricted to 16-bits..  */
+             restricted to 16-bits.  */
          wv->call_data = !NILP (def) ? (void *) (EMACS_INT) i : 0;
          wv->enabled = !NILP (enable);
 
@@ -1659,11 +1758,10 @@ mac_menu_show (f, x, y, for_click, keymaps, title, error)
            abort ();
 
          wv->selected = !NILP (selected);
+          if (!STRINGP (help))
+           help = Qnil;
 
-          if (STRINGP (help))
-            wv->help = (char *) XSTRING (help)->data;
-          else
-            wv->help = NULL;
+         wv->help = help;
 
          prev_wv = wv;
 
@@ -1681,14 +1779,17 @@ mac_menu_show (f, x, y, for_click, keymaps, title, error)
         so that it looks better.  Having two separators looks odd.  */
       wv_sep->name = "--";
       wv_sep->next = first_wv->contents;
+      wv_sep->help = Qnil;
 
 #ifndef HAVE_MULTILINGUAL_MENU
       if (STRING_MULTIBYTE (title))
-       title = string_make_unibyte (title);
+       title = ENCODE_SYSTEM (title);
 #endif
       wv_title->name = (char *) XSTRING (title)->data;
-      wv_title->enabled = True;
+      wv_title->enabled = TRUE;
+      wv_title->title = TRUE;
       wv_title->button_type = BUTTON_TYPE_NONE;
+      wv_title->help = Qnil;
       wv_title->next = wv_sep;
       first_wv->contents = wv_title;
     }
@@ -1700,16 +1801,23 @@ mac_menu_show (f, x, y, for_click, keymaps, title, error)
   /* Adjust coordinates to be root-window-relative.  */
   pos.h = x;
   pos.v = y;
+
+#if TARGET_API_MAC_CARBON
+  SetPort (GetWindowPort (FRAME_MAC_WINDOW (f)));
+#else
   SetPort (FRAME_MAC_WINDOW (f));
+#endif
+
   LocalToGlobal (&pos);
 
+  /* No selection has been chosen yet.  */
+  menu_item_selection = 0;
+
   InsertMenu (menu, -1);
 
   /* Display the menu.  */
   menu_item_selection = LoWord (PopUpMenuSelect (menu, pos.v, pos.h, 0));
 
-  GetMenuItemRefCon (menu, menu_item_selection, &menu_item_selection);
-
   DeleteMenu (POPUP_SUBMENU_ID);
   
 #if 0
@@ -1724,13 +1832,13 @@ mac_menu_show (f, x, y, for_click, keymaps, title, error)
 
   DisposeMenu (menu);
 
-  /* Find the selected item, and its pane, to return the proper
-     value.  */
+  /* Find the selected item, and its pane, to return
+     the proper value.  */
   if (menu_item_selection != 0)
     {
       Lisp_Object prefix, entry;
 
-      prefix = Qnil;
+      prefix = entry = Qnil;
       i = 0;
       while (i < menu_items_used)
        {
@@ -1751,8 +1859,8 @@ mac_menu_show (f, x, y, for_click, keymaps, title, error)
                = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_PREFIX];
              i += MENU_ITEMS_PANE_LENGTH;
            }
-         /* Ignore a nil in the item list.  It's meaningful only for
-            dialog boxes.  */
+         /* Ignore a nil in the item list.
+            It's meaningful only for dialog boxes.  */
          else if (EQ (XVECTOR (menu_items)->contents[i], Qquote))
            i += 1;
          else
@@ -1783,6 +1891,7 @@ mac_menu_show (f, x, y, for_click, keymaps, title, error)
 }
 \f
 
+#ifdef HAVE_DIALOGS
 /* Construct native Mac OS menubar based on widget_value tree.  */
 
 static int
@@ -1809,7 +1918,7 @@ mac_dialog (widget_value *wv)
   nb_buttons = dialog_name[1] - '0';
   left_count = nb_buttons - (dialog_name[4] - '0');
   button_labels = (char **) alloca (sizeof (char *) * nb_buttons);
-  ref_cons = (int *) alloca (sizeof (UInt32) * nb_buttons);
+  ref_cons = (UInt32 *) alloca (sizeof (UInt32) * nb_buttons);
   
   wv = wv->contents;
   prompt = (char *) alloca (strlen (wv->value) + 1);
@@ -1828,7 +1937,12 @@ mac_dialog (widget_value *wv)
     }
 
   window_ptr = GetNewCWindow (DIALOG_WINDOW_RESOURCE, NULL, (WindowPtr) -1);
+
+#if TARGET_API_MAC_CARBON
+  SetPort (GetWindowPort (window_ptr));
+#else
   SetPort (window_ptr);
+#endif
   
   TextFont (0);
   /* Left and right margins in the dialog are 13 pixels each.*/
@@ -1846,7 +1960,12 @@ mac_dialog (widget_value *wv)
   SizeWindow (window_ptr, dialog_width, 78, 0);
   ShowWindow (window_ptr);
 
+#if TARGET_API_MAC_CARBON
+  SetPort (GetWindowPort (window_ptr));
+#else
   SetPort (window_ptr);
+#endif
+  
   TextFont (0);
 
   MoveTo (13, 29);
@@ -1903,12 +2022,11 @@ mac_dialog_show (f, keymaps, title, error)
   char dialog_name[6];
   int menu_item_selection;
 
-  widget_value *wv, *save_wv = 0, *first_wv = 0, *prev_wv = 0;
+  widget_value *wv, *first_wv = 0, *prev_wv = 0;
 
   /* Number of elements seen so far, before boundary.  */
   int left_count = 0;
-  /* 1 means we've seen the boundary between left-hand elts and
-     right-hand.  */
+  /* 1 means we've seen the boundary between left-hand elts and right-hand.  */
   int boundary_seen = 0;
 
   *error = NULL;
@@ -1919,8 +2037,8 @@ mac_dialog_show (f, keymaps, title, error)
       return Qnil;
     }
 
-  /* Create a tree of widget_value objects representing the text label
-     and buttons.  */
+  /* Create a tree of widget_value objects
+     representing the text label and buttons.  */
   {
     Lisp_Object pane_name, prefix;
     char *pane_string;
@@ -1934,6 +2052,7 @@ mac_dialog_show (f, keymaps, title, error)
       prev_wv->name++;
     prev_wv->enabled = 1;
     prev_wv->name = "message";
+    prev_wv->help = Qnil;
     first_wv = prev_wv;
  
     /* Loop over all panes and items, filling in the tree.  */
@@ -1958,8 +2077,8 @@ mac_dialog_show (f, keymaps, title, error)
          }
        if (EQ (item_name, Qquote))
          {
-           /* This is the boundary between left-side elts and
-              right-side elts.  Stop incrementing right_count.  */
+           /* This is the boundary between left-side elts
+              and right-side elts.  Stop incrementing right_count.  */
            boundary_seen = 1;
            i++;
            continue;
@@ -1980,6 +2099,7 @@ mac_dialog_show (f, keymaps, title, error)
        wv->call_data = (void *) i;
          /* menu item is identified by its index in menu_items table */
        wv->enabled = !NILP (enable);
+       wv->help = Qnil;
        prev_wv = wv;
 
        if (! boundary_seen)
@@ -1989,16 +2109,18 @@ mac_dialog_show (f, keymaps, title, error)
        i += MENU_ITEMS_ITEM_LENGTH;
       }
 
-    /* If the boundary was not specified, by default put half on the
-       left and half on the right.  */
+    /* If the boundary was not specified,
+       by default put half on the left and half on the right.  */
     if (! boundary_seen)
       left_count = nb_buttons - nb_buttons / 2;
 
     wv = xmalloc_widget_value ();
     wv->name = dialog_name;
+    wv->help = Qnil;
 
-    /* Dialog boxes use a really stupid name encoding which specifies
-       how many buttons to use and how many buttons are on the right.
+    /* Dialog boxes use a really stupid name encoding
+       which specifies how many buttons to use
+       and how many buttons are on the right.
        The Q means something also.  */
     dialog_name[0] = 'Q';
     dialog_name[1] = '0' + nb_buttons;
@@ -2018,8 +2140,7 @@ mac_dialog_show (f, keymaps, title, error)
   menu_item_selection = 0;
 #endif
 
-  /* Free the widget_value objects we used to specify the
-     contents.  */
+  /* Free the widget_value objects we used to specify the contents.  */
   free_menubar_widget_value_tree (first_wv);
 
   /* Find the selected item, and its pane, to return the proper
@@ -2061,6 +2182,7 @@ mac_dialog_show (f, keymaps, title, error)
 
   return Qnil;
 }
+#endif  /* HAVE_DIALOGS  */
 \f
 
 /* Is this item a separator? */
@@ -2068,9 +2190,14 @@ static int
 name_is_separator (name)
      char *name;
 {
-  /* Check if name string consists of only dashes ('-') */
+  char *start = name;
+
+  /* Check if name string consists of only dashes ('-').  */
   while (*name == '-') name++;
-  return (*name == '\0');
+  /* Separators can also be of the form "--:TripleSuperMegaEtched"
+     or "--deep-shadow".  We don't implement them yet, se we just treat
+     them like normal separators.  */
+  return (*name == '\0' || start + 2 == name);
 }
 
 static void
@@ -2086,7 +2213,11 @@ add_menu_item (MenuHandle menu, widget_value *wv, int submenu, int indent,
     {
       AppendMenu (menu, "\pX");
       
+#if TARGET_API_MAC_CARBON
+      pos = CountMenuItems (menu);
+#else
       pos = CountMItems (menu);
+#endif
 
       strcpy (item_name, "");
       for (i = 0; i < indent; i++)
@@ -2101,9 +2232,17 @@ add_menu_item (MenuHandle menu, widget_value *wv, int submenu, int indent,
       SetMenuItemText (menu, pos, item_name);
 
       if (wv->enabled && !force_disable)
-       EnableItem (menu, pos);
+#if TARGET_API_MAC_CARBON
+        EnableMenuItem (menu, pos);
+#else
+        EnableItem (menu, pos);
+#endif
       else
-       DisableItem (menu, pos);
+#if TARGET_API_MAC_CARBON
+        DisableMenuItem (menu, pos);
+#else
+        DisableItem (menu, pos);
+#endif
 
       /* Draw radio buttons and tickboxes. */
       {
@@ -2184,6 +2323,7 @@ fill_menubar (widget_value *wv)
 }
 
 #endif /* HAVE_MENUS */
+
 \f
 void
 syms_of_macmenu ()
@@ -2195,8 +2335,8 @@ syms_of_macmenu ()
   staticpro (&Qdebug_on_next_call);
 
   DEFVAR_LISP ("menu-updating-frame", &Vmenu_updating_frame,
-    "Frame for which we are updating a menu.\n\
-The enable predicate for a menu command should check this variable.");
+              doc: /* Frame for which we are updating a menu.
+The enable predicate for a menu command should check this variable.  */);
   Vmenu_updating_frame = Qnil;
 
   defsubr (&Sx_popup_menu);
similarity index 82%
rename from mac/src/macterm.c
rename to src/macterm.c
index 3def022..4e3dc93 100644 (file)
@@ -1,5 +1,5 @@
 /* Implementation of GUI terminal on the Mac OS.
-   Copyright (C) 2000 Free Software Foundation, Inc.
+   Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -18,31 +18,44 @@ along with GNU Emacs; see the file COPYING.  If not, write to
 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
-/* Contributed by Andrew Choi (akochoi@users.sourceforge.net).  */
+/* Contributed by Andrew Choi (akochoi@mac.com).  */
 
 #include <config.h>
-
-/* On 4.3 these lose if they come after xterm.h.  */
-/* Putting these at the beginning seems to be standard for other .c files.  */
 #include <signal.h>
-
 #include <stdio.h>
-
+#include <stdlib.h>
 #include "lisp.h"
+#include "charset.h"
 #include "blockinput.h"
 
-/* Need syssignal.h for various externs and definitions that may be required
-   by some configurations for calls to signal later in this source file.  */
-#include "syssignal.h"
-
-/* This may include sys/types.h, and that somehow loses
-   if this is not done before the other system files.  */
 #include "macterm.h"
 
-#include <stdlib.h>
-#include <string.h>
+#ifndef MAC_OSX
 #include <alloca.h>
+#endif
 
+#ifdef MAC_OSX
+#undef mktime
+#undef DEBUG
+#undef free
+#undef malloc
+#undef realloc
+/* Macros max and min defined in lisp.h conflict with those in
+   precompiled header Carbon.h.  */
+#undef max
+#undef min
+#include <Carbon/Carbon.h>
+#undef free
+#define free unexec_free
+#undef malloc
+#define malloc unexec_malloc
+#undef realloc
+#define realloc unexec_realloc
+#undef min
+#define min(a, b) ((a) < (b) ? (a) : (b))
+#undef max
+#define max(a, b) ((a) > (b) ? (a) : (b))
+#else /* not MAC_OSX */
 #include <Quickdraw.h>
 #include <ToolUtils.h>
 #include <Sound.h>
@@ -53,29 +66,27 @@ Boston, MA 02111-1307, USA.  */
 #include <TextUtils.h>
 #include <LowMem.h>
 #include <Controls.h>
-#if defined (__MRC__) || defined (CODEWARRIOR_VERSION_6)
+#if defined (__MRC__) || (__MSL__ >= 0x6000)
 #include <ControlDefinitions.h>
 #endif
+#include <Gestalt.h>
 
 #if __profile__
 #include <profiler.h>
 #endif
-
-#include <sys/types.h>
+#endif /* not MAC_OSX */
 
 #include "systty.h"
 #include "systime.h"
+#include "atimer.h"
+#include "keymap.h"
 
-#ifndef INCLUDED_FCNTL
-#include <fcntl.h>
-#endif
 #include <ctype.h>
 #include <errno.h>
 #include <setjmp.h>
 #include <sys/stat.h>
 
-#include "charset.h"
-#include "ccl.h"
+#include "keyboard.h"
 #include "frame.h"
 #include "dispextern.h"
 #include "fontset.h"
@@ -86,29 +97,10 @@ Boston, MA 02111-1307, USA.  */
 #include "disptab.h"
 #include "buffer.h"
 #include "window.h"
-#include "keyboard.h"
 #include "intervals.h"
-#include "process.h"
-#include "atimer.h"
-#include "keymap.h"
+#include "composite.h"
 #include "coding.h"
 
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#ifndef USE_X_TOOLKIT
-#define x_any_window_to_frame x_window_to_frame
-#define x_top_window_to_frame x_window_to_frame
-#endif
-
-#ifndef min
-#define min(a,b) ((a) < (b) ? (a) : (b))
-#endif
-#ifndef max
-#define max(a,b) ((a) > (b) ? (a) : (b))
-#endif
-
 #define BETWEEN(X, LOWER, UPPER)  ((X) >= (LOWER) && (X) < (UPPER))
 
 \f
@@ -188,9 +180,9 @@ static unsigned char ov_bits[] = {
 extern Lisp_Object Qhelp_echo;
 
 \f
-/* Non-zero means Emacs uses toolkit scroll bars.  */
+/* Non-nil means Emacs uses toolkit scroll bars.  */
 
-int x_toolkit_scroll_bars_p;
+Lisp_Object Vx_toolkit_scroll_bars;
 
 /* If a string, XTread_socket generates an event to display that string.
    (The display is done in read_char.)  */
@@ -209,12 +201,20 @@ static Lisp_Object previous_help_echo;
 
 static int any_help_event_p;
 
+/* Non-zero means autoselect window with the mouse cursor.  */
+
+int x_autoselect_window_p;
+
 /* Non-zero means draw block and hollow cursor as wide as the glyph
    under it.  For example, if a block cursor is over a tab, it will be
    drawn as wide as that tab on the display.  */
 
 int x_stretch_cursor_p;
 
+/* Non-zero means make use of UNDERLINE_POSITION font properties.  */
+
+int x_use_underline_position_properties;
+
 /* This is a chain of structures for all the X displays currently in
    use.  */
 
@@ -237,6 +237,8 @@ struct mac_display_info one_mac_display_info;
 
 extern struct frame *updating_frame;
 
+extern int waiting_for_input;
+
 /* This is a frame waiting to be auto-raised, within XTread_socket.  */
 
 struct frame *pending_autoraise_frame;
@@ -371,21 +373,21 @@ struct frame * x_window_to_frame (struct mac_display_info *, WindowPtr);
 struct mac_display_info *mac_display_info_for_display (Display *);
 static void x_update_window_end P_ ((struct window *, int, int));
 static void frame_to_window_pixel_xy P_ ((struct window *, int *, int *));
-void x_delete_display P_ ((struct x_display_info *));
-static unsigned int x_mac_to_emacs_modifiers P_ ((struct x_display_info *,
-                                                 unsigned short));
 static int fast_find_position P_ ((struct window *, int, int *, int *,
-                                  int *, int *));
+                                  int *, int *, Lisp_Object));
+static int fast_find_string_pos P_ ((struct window *, int, Lisp_Object,
+                                    int *, int *, int *, int *, int));
 static void set_output_cursor P_ ((struct cursor_pos *));
 static struct glyph *x_y_to_hpos_vpos P_ ((struct window *, int, int,
-                                          int *, int *, int *));
+                                          int *, int *, int *, int));
 static void note_mode_line_highlight P_ ((struct window *, int, int));
 static void note_mouse_highlight P_ ((struct frame *, int, int));
 static void note_tool_bar_highlight P_ ((struct frame *f, int, int));
-static void x_handle_tool_bar_click P_ ((struct frame *, XButtonEvent *));
+static void x_handle_tool_bar_click P_ ((struct frame *, EventRecord *));
 static void show_mouse_face P_ ((struct x_display_info *,
                                 enum draw_glyphs_face));
-void clear_mouse_face P_ ((struct mac_display_info *));
+static int cursor_in_mouse_face_p P_ ((struct window *));
+static int clear_mouse_face P_ ((struct mac_display_info *));
 static int x_io_error_quitter P_ ((Display *));
 int x_catch_errors P_ ((Display *));
 void x_uncatch_errors P_ ((Display *, int));
@@ -397,7 +399,7 @@ void x_raise_frame P_ ((struct frame *));
 void x_set_window_size P_ ((struct frame *, int, int, int));
 void x_wm_set_window_state P_ ((struct frame *, int));
 void x_wm_set_icon_pixmap P_ ((struct frame *, int));
-void x_initialize P_ ((void));
+void mac_initialize P_ ((void));
 static void x_font_min_bounds P_ ((XFontStruct *, int *, int *));
 static int x_compute_min_glyph_bounds P_ ((struct frame *));
 enum text_cursor_kinds x_specified_cursor_type P_ ((Lisp_Object, int *));
@@ -424,12 +426,12 @@ static void x_draw_hollow_cursor P_ ((struct window *, struct glyph_row *));
 static void x_draw_bar_cursor P_ ((struct window *, struct glyph_row *, int));
 static int x_intersect_rectangles P_ ((Rect *, Rect *, Rect *));
 static void expose_frame P_ ((struct frame *, int, int, int, int));
-static void expose_window_tree P_ ((struct window *, Rect *));
-static void expose_window P_ ((struct window *, Rect *));
+static int expose_window_tree P_ ((struct window *, Rect *));
+static int expose_window P_ ((struct window *, Rect *));
 static void expose_area P_ ((struct window *, struct glyph_row *,
-                            XRectangle *, enum glyph_row_area));
-static void expose_line P_ ((struct window *, struct glyph_row *,
-                            XRectangle *));
+                            Rect *, enum glyph_row_area));
+static int expose_line P_ ((struct window *, struct glyph_row *,
+                           Rect *));
 void x_display_cursor (struct window *, int, int, int, int, int);
 void x_update_cursor P_ ((struct frame *, int));
 static void x_update_cursor_in_window_tree P_ ((struct window *, int));
@@ -442,7 +444,9 @@ static void x_clip_to_row P_ ((struct window *, struct glyph_row *,
                               GC, int));
 static int x_phys_cursor_in_rect_p P_ ((struct window *, Rect *));
 static void x_draw_row_fringe_bitmaps P_ ((struct window *, struct glyph_row *));
-static void note_overwritten_text_cursor P_ ((struct window *, int, int));
+static void notice_overwritten_cursor P_ ((struct window *,
+                                          enum glyph_row_area,
+                                          int, int, int, int));
 static void x_flush P_ ((struct frame *f));
 static void x_update_begin P_ ((struct frame *));
 static void x_update_window_begin P_ ((struct window *));
@@ -537,7 +541,12 @@ XDrawLine (display, w, gc, x1, y1, x2, y2)
      GC gc;
      int x1, y1, x2, y2;
 {
+#if TARGET_API_MAC_CARBON
+  SetPort (GetWindowPort (w));
+#else
   SetPort (w);
+#endif
+
   mac_set_colors (gc);
 
   MoveTo (x1, y1);
@@ -558,10 +567,15 @@ XClearArea (display, w, x, y, width, height, exposures)
   Rect r;
   XGCValues xgc;
 
-  xgc.foreground = mwp->foreground_pixel;
-  xgc.background = mwp->background_pixel;
+  xgc.foreground = mwp->x_compatible.foreground_pixel;
+  xgc.background = mwp->x_compatible.background_pixel;
 
+#if TARGET_API_MAC_CARBON
+  SetPort (GetWindowPort (w));
+#else
   SetPort (w);
+#endif
+
   mac_set_colors (&xgc);
   SetRect (&r, x, y, x + width, y + height);
 
@@ -578,13 +592,27 @@ XClearWindow (display, w)
   struct mac_output *mwp = (mac_output *) GetWRefCon (w);
   XGCValues xgc;
 
-  xgc.foreground = mwp->foreground_pixel;
-  xgc.background = mwp->background_pixel;
+  xgc.foreground = mwp->x_compatible.foreground_pixel;
+  xgc.background = mwp->x_compatible.background_pixel;
 
+#if TARGET_API_MAC_CARBON
+  SetPort (GetWindowPort (w));
+#else
   SetPort (w);
+#endif
+
   mac_set_colors (&xgc);
 
-  EraseRect (&(w->portRect));  
+#if TARGET_API_MAC_CARBON
+  {
+    Rect r;
+    
+    GetWindowPortBounds (w, &r);
+    EraseRect (&r);
+  }
+#else /* not TARGET_API_MAC_CARBON */
+  EraseRect (&(w->portRect));
+#endif /* not TARGET_API_MAC_CARBON */
 }
 
 
@@ -600,11 +628,27 @@ mac_draw_bitmap (display, w, gc, x, y, bitmap)
 {
   Rect r;
 
+#if TARGET_API_MAC_CARBON
+  SetPort (GetWindowPort (w));
+#else
   SetPort (w);
+#endif
+
   mac_set_colors (gc);
   SetRect (&r, x, y, x + bitmap->bounds.right, y + bitmap->bounds.bottom);
 
+#if TARGET_API_MAC_CARBON
+  {
+    PixMapHandle pmh;
+
+    LockPortBits (GetWindowPort (w));
+    pmh = GetPortPixMap (GetWindowPort (w));
+    CopyBits (bitmap, (BitMap *) *pmh, &(bitmap->bounds), &r, srcCopy, 0);
+    UnlockPortBits (GetWindowPort (w));
+  }
+#else /* not TARGET_API_MAC_CARBON */
   CopyBits (bitmap, &(w->portBits), &(bitmap->bounds), &r, srcCopy, 0);        
+#endif /* not TARGET_API_MAC_CARBON */
 }
 
 
@@ -616,7 +660,11 @@ mac_set_clip_rectangle (display, w, r)
      WindowPtr w;
      Rect *r;
 {
+#if TARGET_API_MAC_CARBON
+  SetPort (GetWindowPort (w));
+#else
   SetPort (w);
+#endif
 
   ClipRect (r);
 }
@@ -631,7 +679,11 @@ mac_reset_clipping (display, w)
 {
   Rect r;
   
+#if TARGET_API_MAC_CARBON
+  SetPort (GetWindowPort (w));
+#else
   SetPort (w);
+#endif
 
   SetRect (&r, -32767, -32767, 32767, 32767);
   ClipRect (&r);
@@ -682,7 +734,12 @@ XFillRectangle (display, w, gc, x, y, width, height)
 {
   Rect r;
 
+#if TARGET_API_MAC_CARBON
+  SetPort (GetWindowPort (w));
+#else
   SetPort (w);
+#endif
+
   mac_set_colors (gc);
   SetRect (&r, x, y, x + width, y + height);
 
@@ -702,7 +759,12 @@ mac_draw_rectangle (display, w, gc, x, y, width, height)
 {
   Rect r;
 
+#if TARGET_API_MAC_CARBON
+  SetPort (GetWindowPort (w));
+#else
   SetPort (w);
+#endif
+
   mac_set_colors (gc);
   SetRect (&r, x, y, x + width + 1, y + height + 1);
 
@@ -723,12 +785,17 @@ mac_draw_rectangle_to_pixmap (display, p, gc, x, y, width, height)
 #if 0 /* MAC_TODO: draw a rectangle in a PixMap */
   Rect r;
 
+#if TARGET_API_MAC_CARBON
+  SetPort (GetWindowPort (w));
+#else
   SetPort (w);
+#endif
+
   mac_set_colors (gc);
   SetRect (&r, x, y, x + width, y + height);
 
   FrameRect (&r); /* using foreground color of gc */
-#endif
+#endif /* 0 */
 }
 
 
@@ -742,7 +809,12 @@ mac_draw_string_common (display, w, gc, x, y, buf, nchars, mode,
      char *buf;
      int nchars, mode, bytes_per_char;
 {
+#if TARGET_API_MAC_CARBON
+  SetPort (GetWindowPort (w));
+#else
   SetPort (w);
+#endif
+
   mac_set_colors (gc);
 
   TextFont (gc->font->mac_fontnum);
@@ -832,13 +904,29 @@ mac_copy_area (display, src, dest, gc, src_x, src_y, width, height, dest_x,
 {
   Rect src_r, dest_r;
 
+#if TARGET_API_MAC_CARBON
+  SetPort (GetWindowPort (dest));
+#else
   SetPort (dest);
+#endif
+
   mac_set_colors (gc);
 
   SetRect (&src_r, src_x, src_y, src_x + width, src_y + height);
   SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height);
 
-  CopyBits ((BitMap *) src, &(dest->portBits), &src_r, &dest_r, srcCopy, 0);
+#if TARGET_API_MAC_CARBON
+  {
+    PixMapHandle pmh;
+
+    LockPortBits (GetWindowPort (dest));
+    pmh = GetPortPixMap (GetWindowPort (dest));
+    CopyBits ((BitMap *) &src, (BitMap *) *pmh, &src_r, &dest_r, srcCopy, 0);
+    UnlockPortBits (GetWindowPort (dest));
+  }
+#else /* not TARGET_API_MAC_CARBON */
+  CopyBits ((BitMap *) &src, &(dest->portBits), &src_r, &dest_r, srcCopy, 0);
+#endif /* not TARGET_API_MAC_CARBON */
 }
 
 
@@ -871,6 +959,21 @@ mac_scroll_area (display, w, gc, src_x, src_y, width, height, dest_x, dest_y)
      unsigned int width, height;
      int dest_x, dest_y;
 {
+#if TARGET_API_MAC_CARBON
+  Rect gw_r, src_r, dest_r;
+  PixMapHandle pmh;
+
+  SetRect (&src_r, src_x, src_y, src_x + width, src_y + height);
+  SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height);
+
+  SetPort (GetWindowPort (w));
+  mac_set_colors (gc);
+
+  LockPortBits (GetWindowPort (w));
+  pmh = GetPortPixMap (GetWindowPort (w));
+  CopyBits ((BitMap *) *pmh, (BitMap *) *pmh, &src_r, &dest_r, srcCopy, 0);
+  UnlockPortBits (GetWindowPort (w));
+#else /* not TARGET_API_MAC_CARBON */
   Rect src_r, dest_r;
 
   SetPort (w);
@@ -899,6 +1002,7 @@ mac_scroll_area (display, w, gc, src_x, src_y, width, height, dest_x, dest_y)
   
   mac_set_colors (gc);
 #endif
+#endif /* not TARGET_API_MAC_CARBON */
 }
 
 
@@ -926,7 +1030,7 @@ mac_copy_area_to_pixmap (display, src, dest, gc, src_x, src_y, width, height,
   SetRect (&src_r, src_x, src_y, src_right, src_bottom);
   SetRect (&dest_r, dest_x, dest_y, dest_x + w, dest_y + h);
 
-  CopyBits ((BitMap *) src, (BitMap *) dest, &src_r, &dest_r, srcCopy, 0);
+  CopyBits ((BitMap *) &src, (BitMap *) &dest, &src_r, &dest_r, srcCopy, 0);
 }
 
 
@@ -1022,13 +1126,26 @@ x_sync (f)
 }
 
 
+/* Remove calls to XFlush by defining XFlush to an empty replacement.
+   Calls to XFlush should be unnecessary because the X output buffer
+   is flushed automatically as needed by calls to XPending,
+   XNextEvent, or XWindowEvent according to the XFlush man page.
+   XTread_socket calls XPending.  Removing XFlush improves
+   performance.  */
+
+#if TARGET_API_MAC_CARBON
+#define XFlush(DISPLAY) QDFlushPortBuffer (GetQDGlobalsThePort (), NULL)
+#else
+#define XFlush(DISPLAY)        (void) 0 
+#endif
+
 /* Flush display of frame F, or of all frames if F is null.  */
 
 void
 x_flush (f)
      struct frame *f;
 {
-#if 0 /* Nothing to do for Mac OS (needed in OS X perhaps?).  */
+#if TARGET_API_MAC_CARBON
   BLOCK_INPUT;
   if (f == NULL)
     {
@@ -1039,19 +1156,10 @@ x_flush (f)
   else if (FRAME_X_P (f))
     XFlush (FRAME_MAC_DISPLAY (f));
   UNBLOCK_INPUT;
-#endif
+#endif /* TARGET_API_MAC_CARBON */
 }
 
 
-/* Remove calls to XFlush by defining XFlush to an empty replacement.
-   Calls to XFlush should be unnecessary because the X output buffer
-   is flushed automatically as needed by calls to XPending,
-   XNextEvent, or XWindowEvent according to the XFlush man page.
-   XTread_socket calls XPending.  Removing XFlush improves
-   performance.  */
-
-#define XFlush(DISPLAY)        (void) 0 
-
 \f
 /* Return the struct mac_display_info corresponding to DPY.  There's
    only one.  */
@@ -1072,10 +1180,9 @@ mac_display_info_for_display (dpy)
 /* Start an update of frame F.  This function is installed as a hook
    for update_begin, i.e. it is called when update_begin is called.
    This function is called prior to calls to x_update_window_begin for
-   each window being updated.  Currently, there is nothing to do here
-   because all interesting stuff is done on a window basis.  */
+   each window being updated.  */
 
-void
+static void
 x_update_begin (f)
      struct frame *f;
 {
@@ -1087,7 +1194,7 @@ x_update_begin (f)
    to the window being updated and set output_cursor to the cursor
    position of W.  */
 
-void
+static void
 x_update_window_begin (w)
      struct window *w;
 {
@@ -1126,7 +1233,7 @@ x_update_window_begin (w)
        {
          int i;
 
-         for (i = 0; i < w->desired_matrix->nrows; ++i)
+          for (i = 0; i < w->desired_matrix->nrows; ++i)
            if (MATRIX_ROW_ENABLED_P (w->desired_matrix, i))
              break;
 
@@ -1166,7 +1273,7 @@ x_draw_vertical_border (w)
                 f->output_data.mac->normal_gc, x1, y0, x1, y1);
     }
 }
-   
+
    
 /* End update of window W (which is equal to updated_window).
 
@@ -1178,30 +1285,21 @@ x_draw_vertical_border (w)
    make sure that the mouse-highlight is properly redrawn.
 
    W may be a menu bar pseudo-window in case we don't have X toolkit
-   support.  Such windows don't have a cursor, so don't display it
-   here.  */
+   support. Such windows don't have a cursor, so don't display it
+   here. */
 
-void
+static void
 x_update_window_end (w, cursor_on_p, mouse_face_overwritten_p)
      struct window *w;
      int cursor_on_p, mouse_face_overwritten_p;
 {
+  struct mac_display_info *dpyinfo
+    = FRAME_MAC_DISPLAY_INFO (XFRAME (w->frame));
+
   if (!w->pseudo_window_p)
     {
-      struct mac_display_info *dpyinfo
-       = FRAME_MAC_DISPLAY_INFO (XFRAME (w->frame));
-      
       BLOCK_INPUT;
 
-      /* If a row with mouse-face was overwritten, arrange for
-        XTframe_up_to_date to redisplay the mouse highlight.  */
-      if (mouse_face_overwritten_p)
-       {
-         dpyinfo->mouse_face_beg_row = dpyinfo->mouse_face_beg_col = -1;
-         dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1;
-         dpyinfo->mouse_face_window = Qnil;
-       }
-      
       if (cursor_on_p)
        x_display_and_set_cursor (w, 1, output_cursor.hpos,
                                  output_cursor.vpos,
@@ -1210,7 +1308,24 @@ x_update_window_end (w, cursor_on_p, mouse_face_overwritten_p)
       x_draw_vertical_border (w);
       UNBLOCK_INPUT;
     }
-  
+
+  /* If a row with mouse-face was overwritten, arrange for
+     XTframe_up_to_date to redisplay the mouse highlight.  */
+  if (mouse_face_overwritten_p)
+    {
+      dpyinfo->mouse_face_beg_row = dpyinfo->mouse_face_beg_col = -1;
+      dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1;
+      dpyinfo->mouse_face_window = Qnil;
+    }
+
+#if 0
+  /* Unhide the caret.  This won't actually show the cursor, unless it
+     was visible before the corresponding call to HideCaret in
+     x_update_window_begin.  */
+  if (w32_use_visible_system_caret)
+    SendMessage (w32_system_caret_hwnd, WM_EMACS_SHOW_CARET, 0, 0);
+#endif
+
   updated_window = NULL;
 }
 
@@ -1218,14 +1333,19 @@ x_update_window_end (w, cursor_on_p, mouse_face_overwritten_p)
 /* End update of frame F.  This function is installed as a hook in
    update_end.  */
 
-void
+static void
 x_update_end (f)
      struct frame *f;
 {
   /* Reset the background color of Mac OS Window to that of the frame after
      update so that it is used by Mac Toolbox to clear the update region before
      an update event is generated.  */
+#if TARGET_API_MAC_CARBON
+  SetPort (GetWindowPort (FRAME_MAC_WINDOW (f)));
+#else
   SetPort (FRAME_MAC_WINDOW (f));
+#endif
+
   mac_set_backcolor (FRAME_BACKGROUND_PIXEL (f));
   
   /* Mouse highlight may be displayed again.  */
@@ -1241,7 +1361,7 @@ x_update_end (f)
    complete update has been performed.  The global variable
    updated_window is not available here.  */
 
-void
+static void
 XTframe_up_to_date (f)
      struct frame *f;
 {
@@ -1267,37 +1387,54 @@ XTframe_up_to_date (f)
 /* Draw truncation mark bitmaps, continuation mark bitmaps, overlay
    arrow bitmaps, or clear the fringes if no bitmaps are required
    before DESIRED_ROW is made current.  The window being updated is
-   found in updated_window.  This function It is called from
+   found in updated_window.  This function is called from
    update_window_line only if it is known that there are differences
    between bitmaps to be drawn between current row and DESIRED_ROW.  */
 
-void
+static void
 x_after_update_window_line (desired_row)
      struct glyph_row *desired_row;
 {
   struct window *w = updated_window;
-  
+  struct frame *f;
+  int width, height;
+
   xassert (w);
   
   if (!desired_row->mode_line_p && !w->pseudo_window_p)
     {
       BLOCK_INPUT;
       x_draw_row_fringe_bitmaps (w, desired_row);
+      UNBLOCK_INPUT;
+    }
 
-      /* When a window has disappeared, make sure that no rest of
-        full-width rows stays visible in the internal border.  */
-      if (windows_or_buffers_changed)
-       {
-         struct frame *f = XFRAME (w->frame);
-         int width = FRAME_INTERNAL_BORDER_WIDTH (f);
-         int height = desired_row->visible_height;
-         int x = (window_box_right (w, -1)
-                  + FRAME_X_RIGHT_FRINGE_WIDTH (f));
-         int y = WINDOW_TO_FRAME_PIXEL_Y (w, max (0, desired_row->y));
+  /* When a window has disappeared, make sure that no rest of
+     full-width rows stays visible in the internal border.  Could
+     check here if updated_window is the leftmost/rightmost window,
+     but I guess it's not worth doing since vertically split windows
+     are almost never used, internal border is rarely set, and the
+     overhead is very small.  */
+  if (windows_or_buffers_changed
+      && desired_row->full_width_p
+      && (f = XFRAME (w->frame),
+         width = FRAME_INTERNAL_BORDER_WIDTH (f),
+         width != 0)
+      && (height = desired_row->visible_height,
+         height > 0))
+    {
+      int y = WINDOW_TO_FRAME_PIXEL_Y (w, max (0, desired_row->y));
+      /* Internal border is drawn below the tool bar.  */
+      if (WINDOWP (f->tool_bar_window)
+         && w == XWINDOW (f->tool_bar_window))
+       y -= width;
 
-         XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
-                     x, y, width, height, 0);
-       }
+      BLOCK_INPUT;
+
+      XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
+                 0, y, width, height, 0);
+      XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
+                 f->output_data.mac->pixel_width - width, y,
+                 width, height, 0);
       
       UNBLOCK_INPUT;
     }
@@ -1324,10 +1461,11 @@ x_draw_fringe_bitmap (w, row, which, left_p)
   unsigned char *bits;
   BitMap bitmap;
   XGCValues gcv;
+  GC gc = f->output_data.mac->normal_gc;
   struct face *face;
 
   /* Must clip because of partially visible lines.  */
-  x_clip_to_row (w, row, 1);
+  x_clip_to_row (w, row, gc, 1);
 
   /* Convert row to frame coordinates.  */
   y = WINDOW_TO_FRAME_PIXEL_Y (w, row->y);
@@ -1386,8 +1524,7 @@ x_draw_fringe_bitmap (w, row, which, left_p)
   /* Set dy to the offset in the row to start drawing the bitmap.  */
   dy = (row->height - h) / 2;
 
-  /* Draw the bitmap.  I believe these small pixmaps can be cached
-     by the server.  */
+  /* Draw the bitmap.  */
   face = FACE_FROM_ID (f, FRINGE_FACE_ID);
   PREPARE_FACE_FOR_DISPLAY (f, face);
 
@@ -1460,7 +1597,10 @@ x_draw_fringe_bitmap (w, row, which, left_p)
     }
 
   if (which == NO_FRINGE_BITMAP)
-    return;
+    {
+      mac_reset_clipping (display, window);
+      return;
+    }
 
   mac_create_bitmap_from_bitmap_data (&bitmap, bits, wd, h);
   gcv.foreground = face->foreground;
@@ -1525,47 +1665,20 @@ x_draw_row_fringe_bitmaps (w, row)
 }
 
 \f
-/***********************************************************************
-                         Line Highlighting
- ***********************************************************************/
-
-/* External interface to control of standout mode.  Not used for X
-   frames.  Aborts when called.  */
-
-void
-XTreassert_line_highlight (new, vpos)
-     int new, vpos;
-{
-  abort ();
-}
-
-
-/* Call this when about to modify line at position VPOS and change
-   whether it is highlighted.  Not used for X frames.  Aborts when
-   called.  */
-
-void
-x_change_line_highlight (new_highlight, vpos, y, first_unused_hpos)
-     int new_highlight, vpos, y, first_unused_hpos;
-{
-  abort ();
-}
-
-
 /* This is called when starting Emacs and when restarting after
-   suspend.  When starting Emacs, no window is mapped.  And nothing
+   suspend.  When starting Emacs, no window is mapped.  And nothing
    must be done to Emacs's own window if it is suspended (though that
    rarely happens).  */
 
-void
+static void
 XTset_terminal_modes ()
 {
 }
 
 /* This is called when exiting or suspending Emacs.  Exiting will make
-   the X-windows go away, and suspending requires no action.  */
+   the windows go away, and suspending requires no action.  */
 
-void
+static void
 XTreset_terminal_modes ()
 {
 }
@@ -1600,7 +1713,7 @@ set_output_cursor (cursor)
    cursor position for that window.  If updated_window is null, use
    selected_window and display the cursor at the given position.  */
 
-void
+static void
 XTcursor_to (vpos, hpos, y, x)
      int vpos, hpos, y, x;
 {
@@ -2047,13 +2160,16 @@ x_produce_image_glyph (it)
   
   if (face->box != FACE_NO_BOX)
     {
-      it->ascent += face->box_line_width;
-      it->descent += face->box_line_width;
+      if (face->box_line_width > 0)
+       {
+         it->ascent += face->box_line_width;
+         it->descent += face->box_line_width;
+       }
       
       if (it->start_of_box_run_p)
-       it->pixel_width += face->box_line_width;
+       it->pixel_width += abs (face->box_line_width);
       if (it->end_of_box_run_p)
-       it->pixel_width += face->box_line_width;
+       it->pixel_width += abs (face->box_line_width);
     }
 
   take_vertical_position_into_account (it);
@@ -2145,9 +2261,9 @@ x_append_stretch_glyph (it, object, width, height, ascent)
    4. `:height HEIGHT' specifies that the height of the stretch produced
    should be HEIGHT, measured in canonical character units.
 
-   5. `:relative-height FACTOR' specifies that the height of the stretch
-   should be FACTOR times the height of the characters having the glyph
-   property.
+   5. `:relative-height FACTOR' specifies that the height of the
+   stretch should be FACTOR times the height of the characters having
+   the glyph property.
 
    Either none or exactly one of 4 or 5 must be present.
 
@@ -2236,7 +2352,7 @@ x_produce_stretch_glyph (it)
       NUMVAL (prop) > 0 && NUMVAL (prop) <= 100)
     ascent = NUMVAL (prop) / 100.0;
   else
-    ascent = (double) font->ascent / FONT_HEIGHT (font);
+    ascent = (double) FONT_BASE (font) / FONT_HEIGHT (font);
 
   if (width <= 0)
     width = 1;
@@ -2258,13 +2374,16 @@ x_produce_stretch_glyph (it)
 
   if (face->box != FACE_NO_BOX)
     {
-      it->ascent += face->box_line_width;
-      it->descent += face->box_line_width;
+      if (face->box_line_width > 0)
+       {
+         it->ascent += face->box_line_width;
+         it->descent += face->box_line_width;
+       }
       
       if (it->start_of_box_run_p)
-       it->pixel_width += face->box_line_width;
+       it->pixel_width += abs (face->box_line_width);
       if (it->end_of_box_run_p)
-       it->pixel_width += face->box_line_width;
+       it->pixel_width += abs (face->box_line_width);
     }
   
   take_vertical_position_into_account (it);
@@ -2298,16 +2417,17 @@ x_produce_stretch_glyph (it)
        F_HEIGHT = FRAME_LINE_HEIGHT (F)
 */
 
-#define VCENTER_BASELINE_OFFSET(FONT, F)               \
- ((FONT)->descent                                              \
-  + (FRAME_LINE_HEIGHT ((F)) - FONT_HEIGHT ((FONT))) / 2       \
-  - ((F)->output_data.mac->font->descent - (F)->output_data.mac->baseline_offset))
+#define VCENTER_BASELINE_OFFSET(FONT, F)                       \
+  (FONT_DESCENT (FONT)                                         \
+   + (FRAME_LINE_HEIGHT ((F)) - FONT_HEIGHT ((FONT))           \
+      + (FRAME_LINE_HEIGHT ((F)) > FONT_HEIGHT ((FONT)))) / 2  \
+   - (FONT_DESCENT (FRAME_FONT (F)) - FRAME_BASELINE_OFFSET (F)))
 
 /* Produce glyphs/get display metrics for the display element IT is
    loaded with.  See the description of struct display_iterator in
    dispextern.h for an overview of struct display_iterator.  */
 
-void
+static void
 x_produce_glyphs (it)
      struct it *it;
 {
@@ -2321,35 +2441,47 @@ x_produce_glyphs (it)
       XCharStruct *pcm;
       int font_not_found_p;
       struct font_info *font_info;
-      int boff;                        /* baseline offset */
+      int boff;                 /* baseline offset */
+      /* We may change it->multibyte_p upon unibyte<->multibyte
+        conversion.  So, save the current value now and restore it
+        later.
+
+        Note: It seems that we don't have to record multibyte_p in
+        struct glyph because the character code itself tells if or
+        not the character is multibyte.  Thus, in the future, we must
+        consider eliminating the field `multibyte_p' in the struct
+        glyph.
+      */
+      int saved_multibyte_p = it->multibyte_p;
 
       /* Maybe translate single-byte characters to multibyte, or the
-        other way.  */
+         other way.  */
       it->char_to_display = it->c;
       if (!ASCII_BYTE_P (it->c))
-       {
-         if (unibyte_display_via_language_environment
-             && SINGLE_BYTE_CHAR_P (it->c)
-             && (it->c >= 0240
-                 || !NILP (Vnonascii_translation_table)))
-           {
-             it->char_to_display = unibyte_char_to_multibyte (it->c);
+        {
+          if (unibyte_display_via_language_environment
+              && SINGLE_BYTE_CHAR_P (it->c)
+              && (it->c >= 0240
+                  || !NILP (Vnonascii_translation_table)))
+            {
+              it->char_to_display = unibyte_char_to_multibyte (it->c);
+              it->multibyte_p = 1;
              it->face_id = FACE_FOR_CHAR (it->f, face, it->char_to_display);
              face = FACE_FROM_ID (it->f, it->face_id);
            }
          else if (!SINGLE_BYTE_CHAR_P (it->c)
                   && !it->multibyte_p)
            {
-             it->char_to_display = multibyte_char_to_unibyte (it->c, Qnil);
+              it->multibyte_p = 1;
              it->face_id = FACE_FOR_CHAR (it->f, face, it->char_to_display);
              face = FACE_FROM_ID (it->f, it->face_id);
            }
-       }
+        }
       
       /* Get font to use.  Encode IT->char_to_display.  */
       x_get_char_face_and_encoding (it->f, it->char_to_display,
-                                   it->face_id, &char2b,
-                                   it->multibyte_p);
+                                    it->face_id, &char2b,
+                                    it->multibyte_p);
       font = face->font;
 
       /* When no suitable font found, use the default font.  */
@@ -2376,24 +2508,24 @@ x_produce_glyphs (it)
 
          it->nglyphs = 1;
 
-         pcm = x_per_char_metric (font, &char2b);
-         it->ascent = font->ascent + boff;
-         it->descent = font->descent - boff;
-
-         if (pcm)
-           {
-             it->phys_ascent = pcm->ascent + boff;
-             it->phys_descent = pcm->descent - boff;
-             it->pixel_width = pcm->width;
-           }
-         else
-           {
-             it->glyph_not_available_p = 1;
-             it->phys_ascent = font->ascent + boff;
-             it->phys_descent = font->descent - boff;
-             it->pixel_width = FONT_WIDTH (font);
-           }
+          pcm = x_per_char_metric (font, &char2b);
+         it->ascent = FONT_BASE (font) + boff;
+         it->descent = FONT_DESCENT (font) - boff;
 
+          if (pcm)
+            {
+              it->phys_ascent = pcm->ascent + boff;
+              it->phys_descent = pcm->descent - boff;
+              it->pixel_width = pcm->width;
+            }
+          else
+            {
+              it->glyph_not_available_p = 1;
+              it->phys_ascent = FONT_BASE (font) + boff;
+              it->phys_descent = FONT_DESCENT (font) - boff;
+              it->pixel_width = FONT_WIDTH (font);
+            }
+          
          /* If this is a space inside a region of text with
             `space-width' property, change its width.  */
          stretched_p = it->char_to_display == ' ' && !NILP (it->space_width);
@@ -2407,8 +2539,13 @@ x_produce_glyphs (it)
            {
              int thick = face->box_line_width;
              
-             it->ascent += thick;
-             it->descent += thick;
+             if (thick > 0)
+               {
+                 it->ascent += thick;
+                 it->descent += thick;
+               }
+             else
+               thick = -thick;
              
              if (it->start_of_box_run_p)
                it->pixel_width += thick;
@@ -2430,7 +2567,8 @@ x_produce_glyphs (it)
                {
                  /* Translate a space with a `space-width' property
                     into a stretch glyph.  */
-                 double ascent = (double) font->ascent / FONT_HEIGHT (font);
+                 double ascent = (double) FONT_BASE (font)
+                                / FONT_HEIGHT (font);
                  x_append_stretch_glyph (it, it->object, it->pixel_width, 
                                          it->ascent + it->descent, ascent);
                }
@@ -2449,14 +2587,14 @@ x_produce_glyphs (it)
          /* A newline has no width but we need the height of the line.  */
          it->pixel_width = 0;
          it->nglyphs = 0;
-         it->ascent = it->phys_ascent = font->ascent + boff;
-         it->descent = it->phys_descent = font->descent - boff;
+         it->ascent = it->phys_ascent = FONT_BASE (font) + boff;
+         it->descent = it->phys_descent = FONT_DESCENT (font) - boff;
       
-         if (face->box != FACE_NO_BOX)
+         if (face->box != FACE_NO_BOX
+             && face->box_line_width > 0)
            {
-             int thick = face->box_line_width;
-             it->ascent += thick;
-             it->descent += thick;
+             it->ascent += face->box_line_width;
+             it->descent += face->box_line_width;
            }
        }
       else if (it->char_to_display == '\t')
@@ -2465,10 +2603,16 @@ x_produce_glyphs (it)
          int x = it->current_x + it->continuation_lines_width;
          int next_tab_x = ((1 + x + tab_width - 1) / tab_width) * tab_width;
       
+         /* If the distance from the current position to the next tab
+            stop is less than a canonical character width, use the
+            tab stop after that.  */
+         if (next_tab_x - x < CANON_X_UNIT (it->f))
+           next_tab_x += tab_width;
+
          it->pixel_width = next_tab_x - x;
          it->nglyphs = 1;
-         it->ascent = it->phys_ascent = font->ascent + boff;
-         it->descent = it->phys_descent = font->descent - boff;
+         it->ascent = it->phys_ascent = FONT_BASE (font) + boff;
+         it->descent = it->phys_descent = FONT_DESCENT (font) - boff;
          
          if (it->glyph_row)
            {
@@ -2496,27 +2640,33 @@ x_produce_glyphs (it)
              it->glyph_not_available_p = 1;
              it->pixel_width = (FONT_WIDTH (FRAME_FONT (it->f))
                                 * CHARSET_WIDTH (charset));
-             it->phys_ascent = font->ascent + boff;
-             it->phys_descent = font->descent - boff;
+             it->phys_ascent = FONT_BASE (font) + boff;
+             it->phys_descent = FONT_DESCENT (font) - boff;
            }
          else
            {
              it->pixel_width = pcm->width;
-             it->phys_ascent = pcm->ascent + boff;
-             it->phys_descent = pcm->descent - boff;
-             if (it->glyph_row
-                 && (pcm->lbearing < 0
-                     || pcm->rbearing > pcm->width))
-               it->glyph_row->contains_overlapping_glyphs_p = 1;
-           }
-         it->nglyphs = 1;
-         it->ascent = font->ascent + boff;
-         it->descent = font->descent - boff;
+              it->phys_ascent = pcm->ascent + boff;
+              it->phys_descent = pcm->descent - boff;
+              if (it->glyph_row
+                  && (pcm->lbearing < 0
+                      || pcm->rbearing > pcm->width))
+                it->glyph_row->contains_overlapping_glyphs_p = 1;
+            }
+          it->nglyphs = 1;
+          it->ascent = FONT_BASE (font) + boff;
+          it->descent = FONT_DESCENT (font) - boff;
          if (face->box != FACE_NO_BOX)
            {
              int thick = face->box_line_width;
-             it->ascent += thick;
-             it->descent += thick;
+
+             if (thick > 0)
+               {
+                 it->ascent += thick;
+                 it->descent += thick;
+               }
+             else
+               thick = - thick;
          
              if (it->start_of_box_run_p)
                it->pixel_width += thick;
@@ -2534,6 +2684,7 @@ x_produce_glyphs (it)
          if (it->glyph_row)
            x_append_glyph (it);
        }
+      it->multibyte_p = saved_multibyte_p;
     }
   else if (it->what == IT_COMPOSITION)
     {
@@ -2558,7 +2709,7 @@ x_produce_glyphs (it)
        {
          it->char_to_display = unibyte_char_to_multibyte (it->c);
        }
-      
+
       /* Get face and font to use.  Encode IT->char_to_display.  */
       it->face_id = FACE_FOR_CHAR (it->f, face, it->char_to_display);
       face = FACE_FROM_ID (it->f, it->face_id);
@@ -2601,8 +2752,8 @@ x_produce_glyphs (it)
             this composition (adjusted by baseline offset).  Ascent
             and descent of overall glyphs should not be less than
             them respectively.  */
-         int font_ascent = font->ascent + boff;
-         int font_descent = font->descent - boff;
+         int font_ascent = FONT_BASE (font) + boff;
+         int font_descent = FONT_DESCENT (font) - boff;
          /* Bounding box of the overall glyphs.  */
          int leftmost, rightmost, lowest, highest;
          int i, width, ascent, descent;
@@ -2620,8 +2771,8 @@ x_produce_glyphs (it)
          else
            {
              width = FONT_WIDTH (font);
-             ascent = font->ascent;
-             descent = font->descent;
+             ascent = FONT_BASE (font);
+             descent = FONT_DESCENT (font);
            }
          
          rightmost = width;
@@ -2648,7 +2799,7 @@ x_produce_glyphs (it)
              int left, right, btm, top;
              int ch = COMPOSITION_GLYPH (cmp, i);
              int face_id = FACE_FOR_CHAR (it->f, face, ch);
-             
+
              face = FACE_FROM_ID (it->f, face_id);
              x_get_char_face_and_encoding (it->f, ch, face->id, &char2b,
                                            it->multibyte_p);
@@ -2678,8 +2829,8 @@ x_produce_glyphs (it)
              else
                {
                  width = FONT_WIDTH (font);
-                 ascent = font->ascent;
-                 descent = font->descent;
+                 ascent = 1;
+                 descent = 0;
                }
 
              if (cmp->method != COMPOSITION_WITH_RULE_ALTCHARS)
@@ -2781,8 +2932,14 @@ x_produce_glyphs (it)
       if (face->box != FACE_NO_BOX)
        {
          int thick = face->box_line_width;
-         it->ascent += thick;
-         it->descent += thick;
+
+         if (thick > 0)
+           {
+             it->ascent += thick;
+             it->descent += thick;
+           }
+         else
+           thick = - thick;
          
          if (it->start_of_box_run_p)
            it->pixel_width += thick;
@@ -2810,9 +2967,9 @@ x_produce_glyphs (it)
   xassert (it->ascent >= 0 && it->descent >= 0);
   if (it->area == TEXT_AREA)
     it->current_x += it->pixel_width;
-  
+
   it->descent += it->extra_line_spacing;
-  
+
   it->max_ascent = max (it->max_ascent, it->ascent);
   it->max_descent = max (it->max_descent, it->descent);
   it->max_phys_ascent = max (it->max_phys_ascent, it->phys_ascent);
@@ -2828,7 +2985,7 @@ x_estimate_mode_line_height (f, face_id)
      struct frame *f;
      enum face_id face_id;
 {
-  int height = 1;
+  int height = FONT_HEIGHT (FRAME_FONT (f));
 
   /* This function is called so early when Emacs starts that the face
      cache and mode line face are not yet initialized.  */
@@ -2836,7 +2993,12 @@ x_estimate_mode_line_height (f, face_id)
       {
        struct face *face = FACE_FROM_ID (f, face_id);
        if (face)
-         height = FONT_HEIGHT (face->font) + 2 * face->box_line_width;
+          {
+            if (face->font)
+              height = FONT_HEIGHT (face->font);
+           if (face->box_line_width > 0)
+             height += 2 * face->box_line_width;
+          }
       }
   
   return height;
@@ -3012,7 +3174,7 @@ static void x_init_glyph_string P_ ((struct glyph_string *,
                                        enum draw_glyphs_face));
 static int x_draw_glyphs P_ ((struct window *, int , struct glyph_row *,
                              enum glyph_row_area, int, int,
-                             enum draw_glyphs_face, int *, int *, int));
+                             enum draw_glyphs_face, int));
 static void x_set_glyph_string_clipping P_ ((struct glyph_string *));
 static void x_set_glyph_string_gc P_ ((struct glyph_string *));
 static void x_draw_glyph_string_background P_ ((struct glyph_string *,
@@ -3028,8 +3190,8 @@ static void x_set_mouse_face_gc P_ ((struct glyph_string *));
 static void x_get_glyph_overhangs P_ ((struct glyph *, struct frame *,
                                       int *, int *));
 static void x_compute_overhangs_and_x P_ ((struct glyph_string *, int, int));
-static int x_alloc_lighter_color P_ ((struct frame *, Display *, Colormap,
-                                     unsigned long *, double, int));
+/*static int x_alloc_lighter_color P_ ((struct frame *, Display *, Colormap,
+  unsigned long *, double, int));*/
 static void x_setup_relief_color P_ ((struct frame *, struct relief *,
                                      double, int, unsigned long));
 static void x_setup_relief_colors P_ ((struct glyph_string *));
@@ -3041,9 +3203,9 @@ static void x_fill_image_glyph_string P_ ((struct glyph_string *));
 static void x_clear_glyph_string_rect P_ ((struct glyph_string *, int,
                                           int, int, int));
 static void x_draw_relief_rect P_ ((struct frame *, int, int, int, int,
-                                   int, int, int, int, XRectangle *));
+                                   int, int, int, int, Rect *));
 static void x_draw_box_rect P_ ((struct glyph_string *, int, int, int, int,
-                                int, int, int, XRectangle *));
+                                int, int, int, Rect *));
 static void x_fix_overlapping_area P_ ((struct window *, struct glyph_row *,
                                        enum glyph_row_area));
 static int x_fill_stretch_glyph_string P_ ((struct glyph_string *,
@@ -3054,7 +3216,7 @@ static int x_fill_stretch_glyph_string P_ ((struct glyph_string *,
 static void x_check_font P_ ((struct frame *, XFontStruct *));
 #endif
 
-
+     
 /* Append the list of glyph strings with head H and tail T to the list
    with head *HEAD and tail *TAIL.  Set *HEAD and *TAIL to the result.  */
 
@@ -3171,9 +3333,12 @@ x_set_mouse_face_gc (s)
   int face_id;
   struct face *face;
 
-  /* What face has to be used for the mouse face?  */
+  /* What face has to be used last for the mouse face?  */
   face_id = FRAME_X_DISPLAY_INFO (s->f)->mouse_face_face_id;
   face = FACE_FROM_ID (s->f, face_id);
+  if (face == NULL)
+    face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
+  
   if (s->first_glyph->type == CHAR_GLYPH)
     face_id = FACE_FOR_CHAR (s->f, face, s->first_glyph->u.ch);
   else
@@ -3311,20 +3476,6 @@ x_get_glyph_string_clip_rect (s, r)
       r_height = s->row->visible_height;
     }
 
-  /* Don't use S->y for clipping because it doesn't take partially
-     visible lines into account.  For example, it can be negative for
-     partially visible lines at the top of a window.  */
-  if (!s->row->full_width_p
-      && MATRIX_ROW_PARTIALLY_VISIBLE_AT_TOP_P (s->w, s->row))
-    r->top = WINDOW_DISPLAY_HEADER_LINE_HEIGHT (s->w);
-  else
-    r->top = max (0, s->row->y);
-
-  /* If drawing a tool-bar window, draw it over the internal border
-     at the top of the window.  */
-  if (s->w == XWINDOW (s->f->tool_bar_window))
-    r->top -= s->f->output_data.mac->internal_border_width;
-
   /* If S draws overlapping rows, it's sufficient to use the top and
      bottom of the window for clipping because this glyph string
      intentionally draws over other lines.  */
@@ -3333,7 +3484,23 @@ x_get_glyph_string_clip_rect (s, r)
       r->top = WINDOW_DISPLAY_HEADER_LINE_HEIGHT (s->w);
       r_height = window_text_bottom_y (s->w) - r->top;
     }
-      
+  else
+    {
+      /* Don't use S->y for clipping because it doesn't take partially
+        visible lines into account.  For example, it can be negative for
+        partially visible lines at the top of a window.  */
+      if (!s->row->full_width_p
+         && MATRIX_ROW_PARTIALLY_VISIBLE_AT_TOP_P (s->w, s->row))
+       r->top = WINDOW_DISPLAY_HEADER_LINE_HEIGHT (s->w);
+      else
+       r->top = max (0, s->row->y);
+
+      /* If drawing a tool-bar window, draw it over the internal border
+        at the top of the window.  */
+      if (s->w == XWINDOW (s->f->tool_bar_window))
+       r->top -= s->f->output_data.mac->internal_border_width;
+    }
+
   r->top = WINDOW_TO_FRAME_PIXEL_Y (s->w, r->top);
 
   r->bottom = r->top + r_height;
@@ -3581,28 +3748,30 @@ x_draw_glyph_string_background (s, force_p)
      shouldn't be drawn in the first place.  */
   if (!s->background_filled_p)
     {
+      int box_line_width = max (s->face->box_line_width, 0);
+
 #if 0 /* MAC_TODO: stipple */
       if (s->stippled_p)
        {
          /* Fill background with a stipple pattern.  */
          XSetFillStyle (s->display, s->gc, FillOpaqueStippled);
          XFillRectangle (s->display, s->window, s->gc, s->x,
-                         s->y + s->face->box_line_width,
+                         s->y + box_line_width,
                          s->background_width,
-                         s->height - 2 * s->face->box_line_width);
+                         s->height - 2 * box_line_width);
          XSetFillStyle (s->display, s->gc, FillSolid);
          s->background_filled_p = 1;
        }
       else
 #endif
-      if (FONT_HEIGHT (s->font) < s->height - 2 * s->face->box_line_width
+        if (FONT_HEIGHT (s->font) < s->height - 2 * box_line_width
               || s->font_not_found_p
               || s->extends_to_end_of_line_p
               || force_p)
        {
-         x_clear_glyph_string_rect (s, s->x, s->y + s->face->box_line_width,
+         x_clear_glyph_string_rect (s, s->x, s->y + box_line_width,
                                     s->background_width,
-                                    s->height - 2 * s->face->box_line_width);
+                                    s->height - 2 * box_line_width);
          s->background_filled_p = 1;
        }
     }
@@ -3621,7 +3790,7 @@ x_draw_glyph_string_foreground (s)
      of S to the right of that box line.  */
   if (s->face->box != FACE_NO_BOX
       && s->first_glyph->left_box_line_p)
-    x = s->x + s->face->box_line_width;
+    x = s->x + abs (s->face->box_line_width);
   else
     x = s->x;
 
@@ -3691,7 +3860,7 @@ x_draw_composite_glyph_string_foreground (s)
      of S to the right of that box line.  */
   if (s->face->box != FACE_NO_BOX
       && s->first_glyph->left_box_line_p)
-    x = s->x + s->face->box_line_width;
+    x = s->x + abs (s->face->box_line_width);
   else
     x = s->x;
 
@@ -3776,7 +3945,7 @@ x_alloc_nearest_color_for_widget (widget, cmap, color)
 
 #endif /* USE_X_TOOLKIT */
 
-#if 0
+#if 0 /* MAC_TODO */
 
 /* Allocate the color COLOR->pixel on SCREEN of DISPLAY, colormap
    CMAP.  If an exact match can't be allocated, try the nearest color
@@ -3885,7 +4054,7 @@ x_copy_dpy_color (dpy, cmap, pixel)
   return color.pixel;
 }
 
-#endif
+#endif /* MAC_TODO */
 
 /* Allocate a color which is lighter or darker than *COLOR by FACTOR
    or DELTA.  Try a color with RGB values multiplied by FACTOR first.
@@ -4044,7 +4213,8 @@ x_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width,
     gc = f->output_data.mac->black_relief.gc;
   else
     gc = f->output_data.mac->white_relief.gc;
-  mac_set_clip_rectangle (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), clip_rect);
+  mac_set_clip_rectangle (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
+                         clip_rect);
   
   /* Bottom.  */
   for (i = 0; i < width; ++i)
@@ -4128,10 +4298,10 @@ x_draw_glyph_string_box (s)
                ? s->first_glyph
                : s->first_glyph + s->nchars - 1);
 
-  width = s->face->box_line_width;
+  width = abs (s->face->box_line_width);
   raised_p = s->face->box == FACE_RAISED_BOX;
   left_x = s->x;
-  right_x = ((s->row->full_width_p
+  right_x = ((s->row->full_width_p && s->extends_to_end_of_line_p
              ? last_x - 1
              : min (last_x, s->x + s->background_width) - 1));
   top_y = s->y;
@@ -4173,7 +4343,7 @@ x_draw_image_foreground (s)
      right of that line.  */
   if (s->face->box != FACE_NO_BOX
       && s->first_glyph->left_box_line_p)
-    x = s->x + s->face->box_line_width;
+    x = s->x + abs (s->face->box_line_width);
   else
     x = s->x;
 
@@ -4213,7 +4383,7 @@ x_draw_image_foreground (s)
                       r.x - x, r.y - y, r.width, r.height, r.x, r.y);
        }
       else
-#endif
+#endif /* MAC_TODO */
        {
          mac_copy_area (s->display, s->img->pixmap, s->window, s->gc,
                       0, 0, s->img->width, s->img->height, x, y);
@@ -4236,6 +4406,7 @@ x_draw_image_foreground (s)
 }
 
 
+
 /* Draw a relief around the image glyph string S.  */
 
 static void
@@ -4246,12 +4417,12 @@ x_draw_image_relief (s)
   Rect r;
   int x;
   int y = s->ybase - image_ascent (s->img, s->face);
-  
   /* If first glyph of S has a left box line, start drawing it to the
      right of that line.  */
   if (s->face->box != FACE_NO_BOX
       && s->first_glyph->left_box_line_p)
-    x = s->x + s->face->box_line_width;
+    x = s->x + abs (s->face->box_line_width);
   else
     x = s->x;
   
@@ -4263,7 +4434,7 @@ x_draw_image_relief (s)
   if (s->hl == DRAW_IMAGE_SUNKEN
       || s->hl == DRAW_IMAGE_RAISED)
     {
-      thick = tool_bar_button_relief > 0 ? tool_bar_button_relief : 3;
+      thick = tool_bar_button_relief >= 0 ? tool_bar_button_relief : DEFAULT_TOOL_BAR_BUTTON_RELIEF;
       raised_p = s->hl == DRAW_IMAGE_RAISED;
     }
   else
@@ -4297,7 +4468,7 @@ x_draw_image_foreground_1 (s, pixmap)
      right of that line.  */
   if (s->face->box != FACE_NO_BOX
       && s->first_glyph->left_box_line_p)
-    x = s->face->box_line_width;
+    x = abs (s->face->box_line_width);
   else
     x = 0;
 
@@ -4331,7 +4502,7 @@ x_draw_image_foreground_1 (s, pixmap)
          XSetClipMask (s->display, s->gc, None);
        }
       else
-#endif
+#endif /* MAC_TODO */
        {
          mac_copy_area_to_pixmap (s->display, s->img->pixmap, pixmap, s->gc,
                               0, 0, s->img->width, s->img->height, x, y);
@@ -4371,7 +4542,7 @@ x_draw_glyph_string_bg_rect (s, x, y, w, h)
       XSetFillStyle (s->display, s->gc, FillSolid);
     }
   else
-#endif
+#endif /* MAC_TODO */
     x_clear_glyph_string_rect (s, x, y, w, h);
 }
 
@@ -4395,38 +4566,38 @@ x_draw_image_glyph_string (s)
      struct glyph_string *s;
 {
   int x, y;
-  int box_line_width = s->face->box_line_width;
+  int box_line_hwidth = abs (s->face->box_line_width);
+  int box_line_vwidth = max (s->face->box_line_width, 0);
   int height;
   Pixmap pixmap = 0;
 
-  height = s->height - 2 * box_line_width;
+  height = s->height - 2 * box_line_vwidth;
 
   /* Fill background with face under the image.  Do it only if row is
      taller than image or if image has a clip mask to reduce
      flickering.  */
   s->stippled_p = s->face->stipple != 0;
   if (height > s->img->height
-      || s->img->vmargin
       || s->img->hmargin
-#if 0 /* MAC_TODO: image mask */
+      || s->img->vmargin
+#if 0 /* TODO: image mask */
       || s->img->mask
 #endif
       || s->img->pixmap == 0
       || s->width != s->background_width)
     {
-      if (box_line_width && s->first_glyph->left_box_line_p)
-       x = s->x + box_line_width;
+      if (box_line_hwidth && s->first_glyph->left_box_line_p)
+       x = s->x + box_line_hwidth;
       else
        x = s->x;
       
-      y = s->y + box_line_width;
-      
-#if 0 /* MAC_TODO: image mask */
+      y = s->y + box_line_vwidth;
+#if 0 /* TODO: image mask */
       if (s->img->mask)
        {
-         /* Create a pixmap as large as the glyph string Fill it with
-            the background color.  Copy the image to it, using its
-            mask.  Copy the temporary pixmap to the display.  */
+         /* Create a pixmap as large as the glyph string.  Fill it
+            with the background color.  Copy the image to it, using
+            its mask.  Copy the temporary pixmap to the display.  */
          Screen *screen = FRAME_X_SCREEN (s->f);
          int depth = DefaultDepthOfScreen (screen);
 
@@ -4461,10 +4632,6 @@ x_draw_image_glyph_string (s)
        }
       else
 #endif
-       /* Implementation idea: Is it possible to construct a mask?
-          We could look at the color at the margins of the image, and
-          say that this color is probably the background color of the
-          image.  */
        x_draw_glyph_string_bg_rect (s, x, y, s->background_width, height);
       
       s->background_filled_p = 1;
@@ -4477,6 +4644,7 @@ x_draw_image_glyph_string (s)
       x_set_glyph_string_clipping (s);
       mac_copy_area (s->display, pixmap, s->window, s->gc,
                   0, 0, s->background_width, s->height, s->x, s->y);
+      mac_reset_clipping (s->display, s->window);
       XFreePixmap (s->display, pixmap);
     }
   else
@@ -4517,6 +4685,15 @@ x_draw_stretch_glyph_string (s)
          int w = s->background_width - width, h = s->height;
          Rect r;
 
+         if (s->row->mouse_face_p
+             && cursor_in_mouse_face_p (s->w))
+           {
+             x_set_mouse_face_gc (s);
+             gc = s->gc;
+           }
+         else
+           gc = s->face->gc;
+  
          x_get_glyph_string_clip_rect (s, &r);
          mac_set_clip_rectangle (s->display, s->window, &r);
 
@@ -4529,7 +4706,7 @@ x_draw_stretch_glyph_string (s)
              XSetFillStyle (s->display, gc, FillSolid);
            }
          else
-#endif
+#endif /* MAC_TODO */
            {
              XGCValues xgcv;
              XGetGCValues (s->display, gc, GCForeground | GCBackground, &xgcv);
@@ -4537,9 +4714,11 @@ x_draw_stretch_glyph_string (s)
              XFillRectangle (s->display, s->window, gc, x, y, w, h);
              XSetForeground (s->display, gc, xgcv.foreground);
            }
+
+         mac_reset_clipping (s->display, s->window);
        }
     }
-  else
+  else if (!s->background_filled_p)
     x_draw_glyph_string_bg_rect (s, s->x, s->y, s->background_width,
                                 s->height);
   
@@ -4553,6 +4732,8 @@ static void
 x_draw_glyph_string (s)
      struct glyph_string *s;
 {
+  int relief_drawn_p = 0;
+
   /* If S draws into the background of its successor, draw the
      background of the successor first so that S can draw into it.
      This makes S->next use XDrawString instead of XDrawImageString.  */
@@ -4562,11 +4743,28 @@ x_draw_glyph_string (s)
       x_set_glyph_string_gc (s->next);
       x_set_glyph_string_clipping (s->next);
       x_draw_glyph_string_background (s->next, 1);
+
     }
 
   /* Set up S->gc, set clipping and draw S.  */
   x_set_glyph_string_gc (s);
-  x_set_glyph_string_clipping (s);
+
+  /* Draw relief (if any) in advance for char/composition so that the
+     glyph string can be drawn over it.  */
+  if (!s->for_overlaps_p
+      && s->face->box != FACE_NO_BOX
+      && (s->first_glyph->type == CHAR_GLYPH
+         || s->first_glyph->type == COMPOSITE_GLYPH))
+
+    {
+      x_set_glyph_string_clipping (s);
+      x_draw_glyph_string_background (s, 1);
+      x_draw_glyph_string_box (s);
+      x_set_glyph_string_clipping (s);
+      relief_drawn_p = 1;
+    }
+  else
+    x_set_glyph_string_clipping (s);
 
   switch (s->first_glyph->type)
     {
@@ -4582,7 +4780,7 @@ x_draw_glyph_string (s)
       if (s->for_overlaps_p)
        s->background_filled_p = 1;
       else
-       x_draw_glyph_string_background (s, 0);
+        x_draw_glyph_string_background (s, 0);
       x_draw_glyph_string_foreground (s);
       break;
 
@@ -4660,10 +4858,10 @@ x_draw_glyph_string (s)
        }
   
       /* Draw relief.  */
-      if (s->face->box != FACE_NO_BOX)
-       x_draw_glyph_string_box (s);
+      if (!relief_drawn_p && s->face->box != FACE_NO_BOX)
+        x_draw_glyph_string_box (s);
     }
-  
+
   /* Reset clipping.  */
   mac_reset_clipping (s->display, s->window);
 }
@@ -4693,7 +4891,7 @@ x_fill_composite_glyph_string (s, faces, overlaps_p)
   xassert (s);
 
   s->for_overlaps_p = overlaps_p;
-  
+
   s->face = faces[s->gidx];
   s->font = s->face->font;
   s->font_info = FONT_INFO_FROM_ID (s->f, s->face->font_info_id);
@@ -4750,16 +4948,16 @@ x_fill_glyph_string (s, face_id, start, end, overlaps_p)
   struct glyph *glyph, *last;
   int voffset;
   int glyph_not_available_p;
-  
+
   xassert (s->f == XFRAME (s->w->frame));
   xassert (s->nchars == 0);
   xassert (start >= 0 && end > start);
 
-  s->for_overlaps_p = overlaps_p,
+  s->for_overlaps_p = overlaps_p;
   glyph = s->row->glyphs[s->area] + start;
   last = s->row->glyphs[s->area] + end;
   voffset = glyph->voffset;
-  
+
   glyph_not_available_p = glyph->glyph_not_available_p;
 
   while (glyph < last
@@ -4767,13 +4965,13 @@ x_fill_glyph_string (s, face_id, start, end, overlaps_p)
         && glyph->voffset == voffset
         /* Same face id implies same font, nowadays.  */
         && glyph->face_id == face_id
-        && glyph->glyph_not_available_p == glyph_not_available_p)
+         && glyph->glyph_not_available_p == glyph_not_available_p)
     {
       int two_byte_p;
 
       s->face = x_get_glyph_face_and_encoding (s->f, glyph,
                                               s->char2b + s->nchars,
-                                              &two_byte_p);
+                                               &two_byte_p);
       s->two_byte_p = two_byte_p;
       ++s->nchars;
       xassert (s->nchars <= end - start);
@@ -4796,7 +4994,7 @@ x_fill_glyph_string (s, face_id, start, end, overlaps_p)
 
   /* Adjust base line for subscript/superscript text.  */
   s->ybase += voffset;
-
+  
   xassert (s->face && s->face->gc);
   return glyph - s->row->glyphs[s->area];
 }
@@ -4860,7 +5058,7 @@ x_fill_stretch_glyph_string (s, row, area, start, end)
   /* Adjust base line for subscript/superscript text.  */
   s->ybase += voffset;
 
-  xassert (s->face && s->face->gc);
+  xassert (s->face);
   return glyph - s->row->glyphs[s->area];
 }
 
@@ -4919,10 +5117,15 @@ x_set_glyph_string_background_width (s, start, last_x)
   struct face *default_face = FACE_FROM_ID (s->f, DEFAULT_FACE_ID);
   
   if (start == s->row->used[s->area]
-      && s->hl == DRAW_NORMAL_TEXT
-      && ((s->area == TEXT_AREA && s->row->fill_line_p)
-         || s->face->background != default_face->background
-         || s->face->stipple != default_face->stipple))
+      && s->area == TEXT_AREA
+      && ((s->hl == DRAW_NORMAL_TEXT
+          && (s->row->fill_line_p
+              || s->face->background != default_face->background
+              || s->face->stipple != default_face->stipple
+              || s->row->mouse_face_p))
+         || s->hl == DRAW_MOUSE_FACE
+         || ((s->hl == DRAW_IMAGE_RAISED || s->hl == DRAW_IMAGE_SUNKEN)
+             && s->row->fill_line_p)))
     s->extends_to_end_of_line_p = 1;
   
   /* If S extends its face to the end of the line, set its
@@ -5126,27 +5329,19 @@ x_set_glyph_string_background_width (s, start, last_x)
    DRAW_IMAGE_SUNKEN   draw an image with a sunken relief around it
    DRAW_IMAGE_RAISED   draw an image with a raised relief around it
 
-   If REAL_START is non-null, return in *REAL_START the real starting
-   position for display.  This can be different from START in case
-   overlapping glyphs must be displayed.  If REAL_END is non-null,
-   return in *REAL_END the real end position for display.  This can be
-   different from END in case overlapping glyphs must be displayed.
-
    If OVERLAPS_P is non-zero, draw only the foreground of characters
    and clip to the physical height of ROW.
 
    Value is the x-position reached, relative to AREA of W.  */
      
 static int
-x_draw_glyphs (w, x, row, area, start, end, hl, real_start, real_end,
-              overlaps_p)
+x_draw_glyphs (w, x, row, area, start, end, hl, overlaps_p)
      struct window *w;
      int x;
      struct glyph_row *row;
      enum glyph_row_area area;
      int start, end;
      enum draw_glyphs_face hl;
-     int *real_start, *real_end;
      int overlaps_p;
 {
   struct glyph_string *head, *tail;
@@ -5156,12 +5351,9 @@ x_draw_glyphs (w, x, row, area, start, end, hl, real_start, real_end,
   int i, j;
 
   /* Let's rather be paranoid than getting a SEGV.  */
-  start = max (0, start);
   end = min (end, row->used[area]);
-  if (real_start)
-    *real_start = start;
-  if (real_end)
-    *real_end = end;
+  start = max (0, start);
+  start = min (end, start);
 
   /* Translate X to frame coordinates.  Set last_x to the right
      end of the drawing area.  */
@@ -5169,7 +5361,7 @@ x_draw_glyphs (w, x, row, area, start, end, hl, real_start, real_end,
     {
       /* X is relative to the left edge of W, without scroll bars
         or fringes.  */
-      struct frame *f = XFRAME (w->frame);
+      struct frame *f = XFRAME (WINDOW_FRAME (w));
       int window_left_x = WINDOW_LEFT_MARGIN (w) * CANON_X_UNIT (f);
 
       x += window_left_x;
@@ -5201,7 +5393,7 @@ x_draw_glyphs (w, x, row, area, start, end, hl, real_start, real_end,
      the reason we use a separate variable `i'.  */
   i = start;
   BUILD_GLYPH_STRINGS (w, row, area, i, end, head, tail, hl, x, last_x,
-                      overlaps_p);
+                       overlaps_p);
   if (tail)
     x_reached = tail->x + tail->background_width;
   else
@@ -5210,7 +5402,7 @@ x_draw_glyphs (w, x, row, area, start, end, hl, real_start, real_end,
   /* If there are any glyphs with lbearing < 0 or rbearing > width in
      the row, redraw some glyphs in front or following the glyph
      strings built above.  */
-  if (!overlaps_p && row->contains_overlapping_glyphs_p)
+  if (head && !overlaps_p && row->contains_overlapping_glyphs_p)
     {
       int dummy_x = 0;
       struct glyph_string *h, *t;
@@ -5230,10 +5422,8 @@ x_draw_glyphs (w, x, row, area, start, end, hl, real_start, real_end,
          j = i;
          BUILD_GLYPH_STRINGS (w, row, area, j, start, h, t,
                               DRAW_NORMAL_TEXT, dummy_x, last_x,
-                              overlaps_p);
+                               overlaps_p);
          start = i;
-         if (real_start)
-           *real_start = start;
          x_compute_overhangs_and_x (t, head->x, 1);
          x_prepend_glyph_string_lists (&head, &tail, h, t);
        }
@@ -5250,11 +5440,9 @@ x_draw_glyphs (w, x, row, area, start, end, hl, real_start, real_end,
        {
          BUILD_GLYPH_STRINGS (w, row, area, i, start, h, t,
                               DRAW_NORMAL_TEXT, dummy_x, last_x,
-                              overlaps_p);
+                               overlaps_p);
          for (s = h; s; s = s->next)
            s->background_filled_p = 1;
-         if (real_start)
-           *real_start = i;
          x_compute_overhangs_and_x (t, head->x, 1);
          x_prepend_glyph_string_lists (&head, &tail, h, t);
        }
@@ -5268,11 +5456,9 @@ x_draw_glyphs (w, x, row, area, start, end, hl, real_start, real_end,
        {
          BUILD_GLYPH_STRINGS (w, row, area, end, i, h, t,
                               DRAW_NORMAL_TEXT, x, last_x,
-                              overlaps_p);
+                               overlaps_p);
          x_compute_overhangs_and_x (h, tail->x + tail->width, 0);
          x_append_glyph_string_lists (&head, &tail, h, t);
-         if (real_end)
-           *real_end = i;
        }
 
       /* Append glyph strings for glyphs following the last glyph
@@ -5285,13 +5471,11 @@ x_draw_glyphs (w, x, row, area, start, end, hl, real_start, real_end,
        {
          BUILD_GLYPH_STRINGS (w, row, area, end, i, h, t,
                               DRAW_NORMAL_TEXT, x, last_x,
-                              overlaps_p);
+                               overlaps_p);
          for (s = h; s; s = s->next)
            s->background_filled_p = 1;
          x_compute_overhangs_and_x (h, tail->x + tail->width, 0);
          x_append_glyph_string_lists (&head, &tail, h, t);
-         if (real_end)
-           *real_end = i;
        }
     }
 
@@ -5299,6 +5483,30 @@ x_draw_glyphs (w, x, row, area, start, end, hl, real_start, real_end,
   for (s = head; s; s = s->next)
     x_draw_glyph_string (s);
 
+  if (area == TEXT_AREA
+      && !row->full_width_p
+      /* When drawing overlapping rows, only the glyph strings'
+        foreground is drawn, which doesn't erase a cursor
+        completely. */
+      && !overlaps_p)
+    {
+      int x0 = head ? head->x : x;
+      int x1 = tail ? tail->x + tail->background_width : x;
+      
+      x0 = FRAME_TO_WINDOW_PIXEL_X (w, x0);
+      x1 = FRAME_TO_WINDOW_PIXEL_X (w, x1);
+      
+      if (!row->full_width_p && XFASTINT (w->left_margin_width) != 0)
+       {
+         int left_area_width = window_box_width (w, LEFT_MARGIN_AREA);
+         x0 -= left_area_width;
+         x1 -= left_area_width;
+       }
+
+      notice_overwritten_cursor (w, area, x0, x1,
+                                row->y, MATRIX_ROW_BOTTOM_Y (row));
+    }
+
   /* Value is the x-position up to which drawn, relative to AREA of W.
      This doesn't include parts drawn because of overhangs.  */
   x_reached = FRAME_TO_WINDOW_PIXEL_X (w, x_reached);
@@ -5309,13 +5517,14 @@ x_draw_glyphs (w, x, row, area, start, end, hl, real_start, real_end,
       if (area > TEXT_AREA)
        x_reached -= window_box_width (w, TEXT_AREA);
     }
+
   return x_reached;
 }
 
 
 /* Fix the display of area AREA of overlapping row ROW in window W.  */
 
-void
+static void
 x_fix_overlapping_area (w, row, area)
      struct window *w;
      struct glyph_row *row;
@@ -5348,9 +5557,7 @@ x_fix_overlapping_area (w, row, area)
                 && row->glyphs[area][i].overlaps_vertically_p);
 
          x_draw_glyphs (w, start_x, row, area, start, i,
-                        (row->inverse_p
-                         ? DRAW_INVERSE_VIDEO : DRAW_NORMAL_TEXT),
-                        NULL, NULL, 1);
+                        DRAW_NORMAL_TEXT, 1);
        }
       else
        {
@@ -5369,12 +5576,12 @@ x_fix_overlapping_area (w, row, area)
    the glyph row being updated, and updated_area is the area of that
    row being updated.  */
 
-void
+static void
 x_write_glyphs (start, len)
      struct glyph *start;
      int len;
 {
-  int x, hpos, real_start, real_end;
+  int x, hpos;
 
   xassert (updated_window && updated_row);
   BLOCK_INPUT;
@@ -5385,13 +5592,7 @@ x_write_glyphs (start, len)
   x = x_draw_glyphs (updated_window, output_cursor.x,
                     updated_row, updated_area,
                     hpos, hpos + len,
-                    (updated_row->inverse_p
-                     ? DRAW_INVERSE_VIDEO : DRAW_NORMAL_TEXT),
-                    &real_start, &real_end, 0);
-
-  /* If we drew over the cursor, note that it is not visible any more.  */
-  note_overwritten_text_cursor (updated_window, real_start,
-                               real_end - real_start);
+                    DRAW_NORMAL_TEXT, 0);
 
   UNBLOCK_INPUT;
   
@@ -5403,7 +5604,7 @@ x_write_glyphs (start, len)
 
 /* Insert LEN glyphs from START at the nominal cursor position.   */
 
-void
+static void
 x_insert_glyphs (start, len)
      struct glyph *start;
      register int len;
@@ -5413,7 +5614,7 @@ x_insert_glyphs (start, len)
   int line_height, shift_by_width, shifted_region_width;
   struct glyph_row *row;
   struct glyph *glyph;
-  int frame_x, frame_y, hpos, real_start, real_end;
+  int frame_x, frame_y, hpos;
 
   xassert (updated_window && updated_row);
   BLOCK_INPUT;
@@ -5435,7 +5636,7 @@ x_insert_glyphs (start, len)
                          - shift_by_width);
 
   /* Shift right.  */
-  frame_x = WINDOW_TO_FRAME_PIXEL_X (w, output_cursor.x);
+  frame_x = window_box_left (w, updated_area) + output_cursor.x;
   frame_y = WINDOW_TO_FRAME_PIXEL_Y (w, output_cursor.y);
 
   mac_scroll_area (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
@@ -5447,9 +5648,8 @@ x_insert_glyphs (start, len)
   /* Write the glyphs.  */
   hpos = start - row->glyphs[updated_area];
   x_draw_glyphs (w, output_cursor.x, row, updated_area, hpos, hpos + len,
-                DRAW_NORMAL_TEXT, &real_start, &real_end, 0);
-  note_overwritten_text_cursor (w, real_start, real_end - real_start);
-  
+                DRAW_NORMAL_TEXT, 0);
+
   /* Advance the output cursor.  */
   output_cursor.hpos += len;
   output_cursor.x += shift_by_width;
@@ -5460,7 +5660,7 @@ x_insert_glyphs (start, len)
 /* Delete N glyphs at the nominal cursor position.  Not implemented
    for X frames.  */
 
-void
+static void
 x_delete_glyphs (n)
      register int n;
 {
@@ -5475,7 +5675,7 @@ x_delete_glyphs (n)
    TO_X is a pixel position relative to updated_area of
    updated_window.  TO_X == -1 means clear to the end of this area.  */
 
-void
+static void
 x_clear_end_of_line (to_x)
      int to_x;
 {
@@ -5511,10 +5711,13 @@ x_clear_end_of_line (to_x)
   
   /* Notice if the cursor will be cleared by this operation.  */
   if (!updated_row->full_width_p)
-    note_overwritten_text_cursor (w, output_cursor.hpos, -1);
+    notice_overwritten_cursor (w, updated_area,
+                              output_cursor.x, -1,
+                              updated_row->y,
+                              MATRIX_ROW_BOTTOM_Y (updated_row));
 
   from_x = output_cursor.x;
-     
+
   /* Translate to frame coordinates.  */
   if (updated_row->full_width_p)
     {
@@ -5546,7 +5749,7 @@ x_clear_end_of_line (to_x)
 /* Clear entire frame.  If updating_frame is non-null, clear that
    frame.  Otherwise clear the selected frame.  */
 
-void
+static void
 x_clear_frame ()
 {
   struct frame *f;
@@ -5705,7 +5908,7 @@ XTset_terminal_window (n)
 /* Perform an insert-lines or delete-lines operation, inserting N
    lines or deleting -N lines at vertical position VPOS.  */
 
-void
+static void
 x_ins_del_lines (vpos, n)
      int vpos, n;
 {
@@ -5715,7 +5918,7 @@ x_ins_del_lines (vpos, n)
 
 /* Scroll part of the display as described by RUN.  */
 
-void
+static void
 x_scroll_run (w, run)
      struct window *w;
      struct run *run;
@@ -5785,6 +5988,7 @@ expose_frame (f, x, y, w, h)
      int x, y, w, h;
 {
   Rect r;
+  int mouse_face_overwritten_p = 0;
 
   TRACE ((stderr, "expose_frame "));
 
@@ -5828,90 +6032,65 @@ expose_frame (f, x, y, w, h)
     }
 
   TRACE ((stderr, "(%d, %d, %d, %d)\n", r.left, r.top, r.right, r.bottom));
-  expose_window_tree (XWINDOW (f->root_window), &r);
+  mouse_face_overwritten_p = expose_window_tree (XWINDOW (f->root_window), &r);
 
   if (WINDOWP (f->tool_bar_window))
+    mouse_face_overwritten_p
+      |= expose_window (XWINDOW (f->tool_bar_window), &r);
+
+  /* Some window managers support a focus-follows-mouse style with
+     delayed raising of frames.  Imagine a partially obscured frame,
+     and moving the mouse into partially obscured mouse-face on that
+     frame.  The visible part of the mouse-face will be highlighted,
+     then the WM raises the obscured frame.  With at least one WM, KDE
+     2.1, Emacs is not getting any event for the raising of the frame
+     (even tried with SubstructureRedirectMask), only Expose events.
+     These expose events will draw text normally, i.e. not
+     highlighted.  Which means we must redo the highlight here.
+     Subsume it under ``we love X''.  --gerd 2001-08-15  */
+  /* Included in Windows version because Windows most likely does not
+     do the right thing if any third party tool offers
+     focus-follows-mouse with delayed raise.  --jason 2001-10-12  */
+  if (mouse_face_overwritten_p && !FRAME_GARBAGED_P (f))
     {
-      struct window *w = XWINDOW (f->tool_bar_window);
-      Rect window_rect;
-      Rect intersection_rect;
-      int window_x, window_y, window_width, window_height;
-      
-
-      window_box (w, -1, &window_x, &window_y, &window_width, &window_height);
-      window_rect.left = window_x;
-      window_rect.top = window_y;
-      window_rect.right = window_x + window_width;
-      window_rect.bottom = window_y + window_height;
-
-      if (x_intersect_rectangles (&r, &window_rect, &intersection_rect))
-       expose_window (w, &intersection_rect);
-    }
-
-#ifndef USE_X_TOOLKIT
-  if (WINDOWP (f->menu_bar_window))
-    {
-      struct window *w = XWINDOW (f->menu_bar_window);
-      Rect window_rect;
-      Rect intersection_rect;
-      int window_x, window_y, window_width, window_height;
-      
-
-      window_box (w, -1, &window_x, &window_y, &window_width, &window_height);
-      window_rect.left = window_x;
-      window_rect.top = window_y;
-      window_rect.right = window_x + window_width;
-      window_rect.bottom = window_y + window_height;
-
-      if (x_intersect_rectangles (&r, &window_rect, &intersection_rect))
-       expose_window (w, &intersection_rect);
+      struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (f);
+      if (f == dpyinfo->mouse_face_mouse_frame)
+       {
+         int x = dpyinfo->mouse_face_mouse_x;
+         int y = dpyinfo->mouse_face_mouse_y;
+         clear_mouse_face (dpyinfo);
+         note_mouse_highlight (f, x, y);
+       }
     }
-#endif /* not USE_X_TOOLKIT */
 }
 
 
 /* Redraw (parts) of all windows in the window tree rooted at W that
    intersect R.  R contains frame pixel coordinates.  */
 
-static void
+static int
 expose_window_tree (w, r)
      struct window *w;
      Rect *r;
 {
-  while (w)
+  struct frame *f = XFRAME (w->frame);
+  int mouse_face_overwritten_p = 0;
+
+  while (w && !FRAME_GARBAGED_P (f))
     {
       if (!NILP (w->hchild))
-       expose_window_tree (XWINDOW (w->hchild), r);
+       mouse_face_overwritten_p
+         |= expose_window_tree (XWINDOW (w->hchild), r);
       else if (!NILP (w->vchild))
-       expose_window_tree (XWINDOW (w->vchild), r);
+       mouse_face_overwritten_p
+         |= expose_window_tree (XWINDOW (w->vchild), r);
       else
-       {
-         Rect window_rect;
-         Rect intersection_rect;
-         struct frame *f = XFRAME (w->frame);
-         int window_x, window_y, window_width, window_height;
-
-         /* Frame-relative pixel rectangle of W.  */
-         window_box (w, -1, &window_x, &window_y, &window_width,
-                     &window_height);
-         window_rect.left
-           = (window_x
-              - FRAME_X_LEFT_FRINGE_WIDTH (f)
-              - FRAME_LEFT_SCROLL_BAR_WIDTH (f) * CANON_Y_UNIT (f));
-         window_rect.top = window_y;
-         window_rect.right = window_rect.left
-           + (window_width
-              + FRAME_X_FRINGE_WIDTH (f)
-              + FRAME_SCROLL_BAR_WIDTH (f) * CANON_X_UNIT (f));
-         window_rect.bottom = window_rect.top
-           + window_height + CURRENT_MODE_LINE_HEIGHT (w);
-
-         if (x_intersect_rectangles (r, &window_rect, &intersection_rect))
-           expose_window (w, &intersection_rect);
-       }
+       mouse_face_overwritten_p |= expose_window (w, r);
 
-      w = NILP (w->next) ? 0 : XWINDOW (w->next);
+      w = NILP (w->next) ? NULL : XWINDOW (w->next);
     }
+
+  return mouse_face_overwritten_p;
 }
 
 
@@ -5925,31 +6104,30 @@ expose_area (w, row, r, area)
      Rect *r;
      enum glyph_row_area area;
 {
-  int x;
   struct glyph *first = row->glyphs[area];
   struct glyph *end = row->glyphs[area] + row->used[area];
   struct glyph *last;
-  int first_x;
-
-  /* Set x to the window-relative start position for drawing glyphs of
-     AREA.  The first glyph of the text area can be partially visible.
-     The first glyphs of other areas cannot.  */
-  if (area == LEFT_MARGIN_AREA)
-    x = 0;
-  else if (area == TEXT_AREA)
-    x = row->x + window_box_width (w, LEFT_MARGIN_AREA);
-  else
-    x = (window_box_width (w, LEFT_MARGIN_AREA)
-        + window_box_width (w, TEXT_AREA));
+  int first_x, start_x, x;
 
   if (area == TEXT_AREA && row->fill_line_p)
     /* If row extends face to end of line write the whole line.  */
-    x_draw_glyphs (w, x, row, area,
+    x_draw_glyphs (w, 0, row, area,
                   0, row->used[area],
-                  row->inverse_p ? DRAW_INVERSE_VIDEO : DRAW_NORMAL_TEXT,
-                  NULL, NULL, 0);
+                  DRAW_NORMAL_TEXT, 0);
   else
     {
+      /* Set START_X to the window-relative start position for drawing glyphs of
+        AREA.  The first glyph of the text area can be partially visible.
+        The first glyphs of other areas cannot.  */
+      if (area == LEFT_MARGIN_AREA)
+       start_x = 0;
+      else if (area == TEXT_AREA)
+       start_x = row->x + window_box_width (w, LEFT_MARGIN_AREA);
+      else
+       start_x = (window_box_width (w, LEFT_MARGIN_AREA)
+                  + window_box_width (w, TEXT_AREA));
+      x = start_x;
+
       /* Find the first glyph that must be redrawn.  */
       while (first < end
              && x + first->pixel_width < r->left)
@@ -5967,22 +6145,22 @@ expose_area (w, row, r, area)
           x += last->pixel_width;
           ++last;
         }
-      
+
       /* Repaint.  */
       if (last > first)
-       x_draw_glyphs (w, first_x, row, area,
-                      first - row->glyphs[area],
-                      last - row->glyphs[area],
-                      row->inverse_p ? DRAW_INVERSE_VIDEO : DRAW_NORMAL_TEXT,
-                      NULL, NULL, 0);
+        x_draw_glyphs (w, first_x - start_x, row, area,
+                       first - row->glyphs[area],
+                       last - row->glyphs[area],
+                       DRAW_NORMAL_TEXT, 0);
     }
 }
-      
+
 
 /* Redraw the parts of the glyph row ROW on window W intersecting
-   rectangle R.  R is in window-relative coordinates.  */
+   rectangle R.  R is in window-relative coordinates.  Value is
+   non-zero if mouse face was overwritten.  */
 
-static void
+static int
 expose_line (w, row, r)
      struct window *w;
      struct glyph_row *row;
@@ -5992,8 +6170,7 @@ expose_line (w, row, r)
   
   if (row->mode_line_p || w->pseudo_window_p)
     x_draw_glyphs (w, 0, row, TEXT_AREA, 0, row->used[TEXT_AREA],
-                  row->inverse_p ? DRAW_INVERSE_VIDEO : DRAW_NORMAL_TEXT,
-                  NULL, NULL, 0);
+                  DRAW_NORMAL_TEXT, 0);
   else
     {
       if (row->used[LEFT_MARGIN_AREA])
@@ -6004,6 +6181,8 @@ expose_line (w, row, r)
        expose_area (w, row, r, RIGHT_MARGIN_AREA);
       x_draw_row_fringe_bitmaps (w, row);
     }
+
+  return row->mouse_face_p;
 }
 
 
@@ -6031,97 +6210,120 @@ x_phys_cursor_in_rect_p (w, r)
 }
 
 
-/* Redraw a rectangle of window W.  R is a rectangle in window
-   relative coordinates.  Call this function with input blocked.  */
+/* Redraw the part of window W intersection rectagle FR.  Pixel
+   coordinates in FR are frame relative.  Call this function with
+   input blocked.  Value is non-zero if the exposure overwrites
+   mouse-face.  */
 
-static void
-expose_window (w, r)
+static int
+expose_window (w, fr)
      struct window *w;
-     Rect *r;
+     Rect *fr;
 {
-  struct glyph_row *row;
-  int y;
-  int yb = window_text_bottom_y (w);
-  int cursor_cleared_p;
+  struct frame *f = XFRAME (w->frame);
+  Rect wr, r;
+  int mouse_face_overwritten_p = 0;
 
   /* If window is not yet fully initialized, do nothing.  This can
      happen when toolkit scroll bars are used and a window is split.
      Reconfiguring the scroll bar will generate an expose for a newly
      created window.  */
   if (w->current_matrix == NULL)
-    return;
-
-  TRACE ((stderr, "expose_window (%d, %d, %d, %d)\n",
-         r->left, r->top, r->right, r->bottom));
-
-  /* Convert to window coordinates.  */
-  r->left = FRAME_TO_WINDOW_PIXEL_X (w, r->left);
-  r->top = FRAME_TO_WINDOW_PIXEL_Y (w, r->top);
-  r->right = FRAME_TO_WINDOW_PIXEL_X (w, r->right);
-  r->bottom = FRAME_TO_WINDOW_PIXEL_Y (w, r->bottom);
+    return 0;
 
-  /* Turn off the cursor.  */
-  if (!w->pseudo_window_p
-      && x_phys_cursor_in_rect_p (w, r))
+  /* When we're currently updating the window, display and current
+     matrix usually don't agree.  Arrange for a thorough display
+     later.  */
+  if (w == updated_window)
     {
-      x_clear_cursor (w);
-      cursor_cleared_p = 1;
+      SET_FRAME_GARBAGED (f);
+      return 0;
     }
-  else
-    cursor_cleared_p = 0;
 
-  /* Find the first row intersecting the rectangle R.  */
-  row = w->current_matrix->rows;
-  y = 0;
-  while (row->enabled_p
-        && y < yb
-        && y + row->height < r->top)
-    {
-      y += row->height;
-      ++row;
-    }
-       
-  /* Display the text in the rectangle, one text line at a time.  */
-  while (row->enabled_p
-        && y < yb
-        && y < r->bottom)
+  /* Frame-relative pixel rectangle of W.  */
+  wr.left = XFASTINT (w->left) * CANON_X_UNIT (f);
+  wr.top = XFASTINT (w->top) * CANON_Y_UNIT (f);
+  wr.right = wr.left + XFASTINT (w->width) * CANON_X_UNIT (f);
+  wr.bottom = wr.top + XFASTINT (w->height) * CANON_Y_UNIT (f);
+
+  if (x_intersect_rectangles (fr, &wr, &r))
     {
-      expose_line (w, row, r);
-      y += row->height;
-      ++row;
-    }
+      int yb = window_text_bottom_y (w);
+      struct glyph_row *row;
+      int cursor_cleared_p;
 
-  /* Display the mode line if there is one.  */
-  if (WINDOW_WANTS_MODELINE_P (w)
-      && (row = MATRIX_MODE_LINE_ROW (w->current_matrix),
-         row->enabled_p)
-      && row->y < r->bottom)
-    expose_line (w, row, r);
+      TRACE ((stderr, "expose_window (%d, %d, %d, %d)\n",
+             r.left, r.top, r.right, r.bottom));
 
-  if (!w->pseudo_window_p)
-    {
-      /* Draw border between windows.  */
-      x_draw_vertical_border (w);
-      
-      /* Turn the cursor on again.  */
-      if (cursor_cleared_p)
-       x_update_window_cursor (w, 1);
+      /* Convert to window coordinates.  */
+      r.left = FRAME_TO_WINDOW_PIXEL_X (w, r.left);
+      r.right = FRAME_TO_WINDOW_PIXEL_X (w, r.right);
+      r.top = FRAME_TO_WINDOW_PIXEL_Y (w, r.top);
+      r.bottom = FRAME_TO_WINDOW_PIXEL_Y (w, r.bottom);
+
+      /* Turn off the cursor.  */
+      if (!w->pseudo_window_p
+         && x_phys_cursor_in_rect_p (w, &r))
+       {
+         x_clear_cursor (w);
+         cursor_cleared_p = 1;
+       }
+      else
+       cursor_cleared_p = 0;
+
+      /* Find the first row intersecting the rectangle R.  */
+      for (row = w->current_matrix->rows;
+          row->enabled_p;
+          ++row)
+       {
+         int y0 = row->y;
+         int y1 = MATRIX_ROW_BOTTOM_Y (row);
+
+         if ((y0 >= r.top && y0 < r.bottom)
+             || (y1 > r.top && y1 < r.bottom)
+             || (r.top >= y0 && r.top < y1)
+             || (r.bottom > y0 && r.bottom < y1))
+           {
+             if (expose_line (w, row, &r))
+               mouse_face_overwritten_p = 1;
+           }
+
+         if (y1 >= yb)
+           break;
+       }
+
+      /* Display the mode line if there is one.  */
+      if (WINDOW_WANTS_MODELINE_P (w)
+         && (row = MATRIX_MODE_LINE_ROW (w->current_matrix),
+             row->enabled_p)
+         && row->y < r.bottom)
+       {
+         if (expose_line (w, row, &r))
+           mouse_face_overwritten_p = 1;
+       }
+
+      if (!w->pseudo_window_p)
+       {
+         /* Draw border between windows.  */
+         x_draw_vertical_border (w);
+
+         /* Turn the cursor on again.  */
+         if (cursor_cleared_p)
+           x_update_window_cursor (w, 1);
+       }
     }
-  
+
   /* Display scroll bar for this window.  */
   if (!NILP (w->vertical_scroll_bar))
     {
       ControlHandle ch
-      = SCROLL_BAR_CONTROL_HANDLE (XSCROLL_BAR (w->vertical_scroll_bar));
+       = SCROLL_BAR_CONTROL_HANDLE (XSCROLL_BAR (w->vertical_scroll_bar));
 
       Draw1Control (ch);
     }
-}
-
 
-/* Determine the intersection of two rectangles R1 and R2.  Return
-   the intersection in *RESULT.  Value is non-zero if RESULT is not
-   empty.  */
+  return mouse_face_overwritten_p;
+}
 
 static int
 x_intersect_rectangles (r1, r2, result)
@@ -6228,7 +6430,7 @@ x_new_focus_frame (dpyinfo, frame)
 
 /* Handle an event saying the mouse has moved out of an Emacs frame.  */
 
-static void
+void
 x_mouse_leave (dpyinfo)
      struct x_display_info *dpyinfo;
 {
@@ -6243,7 +6445,7 @@ x_mouse_leave (dpyinfo)
    frame is being highlighted or un-highlighted; we only use it to find
    the appropriate X display info.  */
 
-void
+static void
 XTframe_rehighlight (frame)
      struct frame *frame;
 {
@@ -6284,7 +6486,7 @@ x_frame_rehighlight (dpyinfo)
 \f
 /* Keyboard processing - modifier keys, vendor-specific keysyms, etc.  */
 
-#if 0
+#if 0 /* MAC_TODO */
 /* Initialize mode_switch_bit and modifier_meaning.  */
 static void
 x_find_modifier_meanings (dpyinfo)
@@ -6387,7 +6589,7 @@ x_find_modifier_meanings (dpyinfo)
   XFreeModifiermap (mods);
 }
 
-#endif
+#endif /* MAC_TODO */
 
 /* Convert between the modifier bits X uses and the modifier bits
    Emacs uses.  */
@@ -6403,7 +6605,7 @@ x_mac_to_emacs_modifiers (dpyinfo, state)
          | ((state & optionKey) ? alt_modifier : 0));
 }
 
-#if 0
+#if 0 /* MAC_TODO */
 static unsigned short
 x_emacs_to_x_modifiers (dpyinfo, state)
      struct x_display_info *dpyinfo;
@@ -6416,7 +6618,7 @@ x_emacs_to_x_modifiers (dpyinfo, state)
          | ((state & ctrl_modifier)    ? ControlMask      : 0)
          | ((state & meta_modifier)    ? dpyinfo->meta_mod_mask  : 0));
 }
-#endif
+#endif /* MAC_TODO */
 
 /* Convert a keysym to its name.  */
 
@@ -6454,10 +6656,18 @@ pixel_to_glyph_coords (f, pix_x, pix_y, x, y, bounds, noclip)
      Rect *bounds;
      int noclip;
 {
-  /* Arrange for the division in PIXEL_TO_CHAR_COL etc.  to round down
+  /* Support tty mode: if Vwindow_system is nil, behave correctly. */
+  if (NILP (Vwindow_system))
+    {
+      *x = pix_x;
+      *y = pix_y;
+      return;
+    }
+
+  /* Arrange for the division in PIXEL_TO_CHAR_COL etc. to round down
      even for negative values.  */
   if (pix_x < 0)
-    pix_x -= FONT_WIDTH ((f)->output_data.mac->font) - 1;
+    pix_x -= FONT_WIDTH (FRAME_FONT (f)) - 1;
   if (pix_y < 0)
     pix_y -= (f)->output_data.mac->line_height - 1;
 
@@ -6468,8 +6678,8 @@ pixel_to_glyph_coords (f, pix_x, pix_y, x, y, bounds, noclip)
     {
       bounds->left = CHAR_TO_PIXEL_COL (f, pix_x);
       bounds->top = CHAR_TO_PIXEL_ROW (f, pix_y);
-      bounds->right  = bounds->left + FONT_WIDTH  (f->output_data.mac->font);
-      bounds->bottom = bounds->top + f->output_data.mac->line_height;
+      bounds->right  = bounds->left + FONT_WIDTH  (FRAME_FONT (f)) - 1;
+      bounds->bottom = bounds->top + f->output_data.mac->line_height - 1;
     }
 
   if (!noclip)
@@ -6495,7 +6705,7 @@ pixel_to_glyph_coords (f, pix_x, pix_y, x, y, bounds, noclip)
    can't tell the positions because W's display is not up to date,
    return 0.  */
 
-static int
+int
 glyph_to_pixel_coords (w, hpos, vpos, frame_x, frame_y)
      struct window *w;
      int hpos, vpos;
@@ -6553,7 +6763,13 @@ construct_mouse_click (result, event, f)
   result->modifiers = event->what == mouseDown ? down_modifier : up_modifier;
 
   mouseLoc = event->where;
+
+#if TARGET_API_MAC_CARBON
+  SetPort (GetWindowPort (FRAME_MAC_WINDOW (f)));
+#else
   SetPort (FRAME_MAC_WINDOW (f));
+#endif
+
   GlobalToLocal (&mouseLoc);
   XSETINT (result->x, mouseLoc.h);
   XSETINT (result->y, mouseLoc.v);
@@ -6581,11 +6797,19 @@ note_mouse_movement (frame, pos)
      FRAME_PTR frame;
      Point *pos;
 {
+#if TARGET_API_MAC_CARBON
+  Rect r;
+#endif
+
   last_mouse_movement_time = TickCount () * (1000 / 60);  /* to milliseconds */
   last_mouse_motion_position = *pos;
   XSETFRAME (last_mouse_motion_frame, frame);
 
+#if TARGET_API_MAC_CARBON
+  if (!PtInRect (*pos, GetWindowPortBounds (FRAME_MAC_WINDOW (frame), &r)))
+#else
   if (!PtInRect (*pos, &FRAME_MAC_WINDOW (frame)->portRect))
+#endif
     {
       frame->mouse_moved = 1;
       last_mouse_scroll_bar = Qnil;
@@ -6622,10 +6846,11 @@ int disable_mouse_highlight;
    date.  */
 
 static struct glyph *
-x_y_to_hpos_vpos (w, x, y, hpos, vpos, area)
+x_y_to_hpos_vpos (w, x, y, hpos, vpos, area, buffer_only_p)
      struct window *w;
      int x, y;
      int *hpos, *vpos, *area;
+     int buffer_only_p;
 {
   struct glyph *glyph, *end;
   struct glyph_row *row = NULL;
@@ -6683,7 +6908,7 @@ x_y_to_hpos_vpos (w, x, y, hpos, vpos, area)
        {
          if (w->pseudo_window_p)
            break;
-         else if (BUFFERP (glyph->object))
+         else if (!buffer_only_p || BUFFERP (glyph->object))
            break;
        }
       
@@ -6723,7 +6948,7 @@ frame_to_window_pixel_xy (w, x, y)
 }
 
 
-/* Take proper action when mouse has moved to the mode or top line of
+/* Take proper action when mouse has moved to the mode or header line of
    window W, x-position X.  MODE_LINE_P non-zero means mouse is on the
    mode line.  X is relative to the start of the text display area of
    W, so the width of fringes and scroll bars must be subtracted
@@ -6736,14 +6961,14 @@ note_mode_line_highlight (w, x, mode_line_p)
 {
   struct frame *f = XFRAME (w->frame);
   struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (f);
-  Cursor cursor = dpyinfo->vertical_scroll_bar_cursor;
+  struct Cursor *cursor = dpyinfo->vertical_scroll_bar_cursor;
   struct glyph_row *row;
 
   if (mode_line_p)
     row = MATRIX_MODE_LINE_ROW (w->current_matrix);
   else
     row = MATRIX_HEADER_LINE_ROW (w->current_matrix);
-  
+
   if (row->enabled_p)
     {
       struct glyph *glyph, *end;
@@ -6755,6 +6980,7 @@ note_mode_line_highlight (w, x, mode_line_p)
       end = glyph + row->used[TEXT_AREA];
       x0 = - (FRAME_LEFT_SCROLL_BAR_WIDTH (f) * CANON_X_UNIT (f)
              + FRAME_X_LEFT_FRINGE_WIDTH (f));
+      
       while (glyph < end
             && x >= x0 + glyph->pixel_width)
        {
@@ -6774,12 +7000,12 @@ note_mode_line_highlight (w, x, mode_line_p)
          help = Fget_text_property (make_number (glyph->charpos),
                                     Qhelp_echo, glyph->object);
          if (!NILP (help))
-           {
-             help_echo = help;
-             XSETWINDOW (help_echo_window, w);
-             help_echo_object = glyph->object;
-             help_echo_pos = glyph->charpos;
-           }
+            {
+              help_echo = help;
+              XSETWINDOW (help_echo_window, w);
+              help_echo_object = glyph->object;
+              help_echo_pos = glyph->charpos;
+            }
 
          /* Change the mouse pointer according to what is under X/Y.  */
          map = Fget_text_property (make_number (glyph->charpos),
@@ -6816,14 +7042,15 @@ note_mouse_highlight (f, x, y)
   int portion;
   Lisp_Object window;
   struct window *w;
+  struct buffer *b;
 
-  /* When a menu is active, don't highlight because this looks odd.  */
-#ifdef USE_X_TOOLKIT
+#if 0
+  /* When a menu is active, don't highlight because this looks odd. */
   if (popup_activated ())
     return;
 #endif
 
-  if (disable_mouse_highlight
+  if (NILP (Vmouse_highlight)
       || !f->glyphs_initialized_p)
     return;
 
@@ -6851,6 +7078,9 @@ note_mouse_highlight (f, x, y)
   if (!WINDOWP (window))
     return;
 
+  /* Reset help_echo. It will get recomputed below.  */
+  help_echo = Qnil;
+
   /* Convert to window-relative pixel coordinates.  */
   w = XWINDOW (window);
   frame_to_window_pixel_xy (w, &x, &y);
@@ -6863,32 +7093,38 @@ note_mouse_highlight (f, x, y)
       return;
     }
 
+  /* Mouse is on the mode or header line?  */
   if (portion == 1 || portion == 3)
     {
-      /* Mouse is on the mode or top line.  */
       note_mode_line_highlight (w, x, portion == 1);
       return;
     }
-#if 0 /* MAC_TODO: mouse cursor */
+#if 0 /* TODO: mouse cursor */
+  if (portion == 2)
+    cursor = f->output_data.x->horizontal_drag_cursor;
   else
-    XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
-                  f->output_data.x->text_cursor);
+    cursor = f->output_data.x->text_cursor;
 #endif
-
   /* Are we in a window whose display is up to date?
      And verify the buffer's text has not changed.  */
+  b = XBUFFER (w->buffer);
   if (/* Within text portion of the window.  */
       portion == 0
       && EQ (w->window_end_valid, w->buffer)
-      && XFASTINT (w->last_modified) == BUF_MODIFF (XBUFFER (w->buffer))
-      && (XFASTINT (w->last_overlay_modified)
-         == BUF_OVERLAY_MODIFF (XBUFFER (w->buffer))))
+      && XFASTINT (w->last_modified) == BUF_MODIFF (b)
+      && XFASTINT (w->last_overlay_modified) == BUF_OVERLAY_MODIFF (b))
     {
       int hpos, vpos, pos, i, area;
       struct glyph *glyph;
+      Lisp_Object object;
+      Lisp_Object mouse_face = Qnil, overlay = Qnil, position;
+      Lisp_Object *overlay_vec = NULL;
+      int len, noverlays;
+      struct buffer *obuf;
+      int obegv, ozv, same_region;
 
       /* Find the glyph under X/Y.  */
-      glyph = x_y_to_hpos_vpos (w, x, y, &hpos, &vpos, &area);
+      glyph = x_y_to_hpos_vpos (w, x, y, &hpos, &vpos, &area, 0);
 
       /* Clear mouse face if X/Y not over text.  */
       if (glyph == NULL
@@ -6896,204 +7132,340 @@ note_mouse_highlight (f, x, y)
          || !MATRIX_ROW (w->current_matrix, vpos)->displays_text_p)
        {
          clear_mouse_face (dpyinfo);
-         return;
+         /* TODO: mouse cursor */
+         goto set_cursor;
        }
 
       pos = glyph->charpos;
-      xassert (w->pseudo_window_p || BUFFERP (glyph->object));
+      object = glyph->object;
+      if (!STRINGP (object) && !BUFFERP (object))
+       goto set_cursor;
+
+      /* If we get an out-of-range value, return now; avoid an error.  */
+      if (BUFFERP (object) && pos > BUF_Z (b))
+       goto set_cursor;
+
+      /* Make the window's buffer temporarily current for
+        overlays_at and compute_char_face.  */
+      obuf = current_buffer;
+      current_buffer = b;
+      obegv = BEGV;
+      ozv = ZV;
+      BEGV = BEG;
+      ZV = Z;
+
+      /* Is this char mouse-active or does it have help-echo?  */
+      position = make_number (pos);
+
+      if (BUFFERP (object))
+       {
+         /* Put all the overlays we want in a vector in overlay_vec.
+            Store the length in len.  If there are more than 10, make
+            enough space for all, and try again.  */
+         len = 10;
+         overlay_vec = (Lisp_Object *) alloca (len * sizeof (Lisp_Object));
+         noverlays =  overlays_at (pos, 0, &overlay_vec, &len, NULL, NULL, 0);
+         if (noverlays > len)
+           {
+             len = noverlays;
+             overlay_vec = (Lisp_Object *) alloca (len * sizeof (Lisp_Object));
+             noverlays = overlays_at (pos, 0, &overlay_vec, &len, NULL, NULL,0);
+           }
 
-      /* Check for mouse-face and help-echo.  */
-      {
-       Lisp_Object mouse_face, overlay, position;
-       Lisp_Object *overlay_vec;
-       int len, noverlays;
-       struct buffer *obuf;
-       int obegv, ozv;
-
-       /* If we get an out-of-range value, return now; avoid an error.  */
-       if (pos > BUF_Z (XBUFFER (w->buffer)))
-         return;
+         /* Sort overlays into increasing priority order.  */
+         noverlays = sort_overlays (overlay_vec, noverlays, w);
+       }
+      else
+       noverlays = 0;
+
+      same_region = (EQ (window, dpyinfo->mouse_face_window)
+                    && vpos >= dpyinfo->mouse_face_beg_row
+                    && vpos <= dpyinfo->mouse_face_end_row
+                    && (vpos > dpyinfo->mouse_face_beg_row
+                        || hpos >= dpyinfo->mouse_face_beg_col)
+                    && (vpos < dpyinfo->mouse_face_end_row
+                        || hpos < dpyinfo->mouse_face_end_col
+                        || dpyinfo->mouse_face_past_end));
+
+      /* TODO: if (same_region)
+        mouse cursor */
+
+      /* Check mouse-face highlighting.  */
+      if (! same_region
+         /* If there exists an overlay with mouse-face overlapping
+            the one we are currently highlighting, we have to
+            check if we enter the overlapping overlay, and then
+            highlight that.  */
+         || (OVERLAYP (dpyinfo->mouse_face_overlay)
+             && mouse_face_overlay_overlaps (dpyinfo->mouse_face_overlay)))
+       {
+         /* Find the highest priority overlay that has a mouse-face
+            property.  */
+         overlay = Qnil;
+         for (i = noverlays - 1; i >= 0 && NILP (overlay); --i)
+           {
+             mouse_face = Foverlay_get (overlay_vec[i], Qmouse_face);
+             if (!NILP (mouse_face))
+               overlay = overlay_vec[i];
+           }
 
-       /* Make the window's buffer temporarily current for
-          overlays_at and compute_char_face.  */
-       obuf = current_buffer;
-       current_buffer = XBUFFER (w->buffer);
-       obegv = BEGV;
-       ozv = ZV;
-       BEGV = BEG;
-       ZV = Z;
-
-       /* Is this char mouse-active or does it have help-echo?  */
-       XSETINT (position, pos);
-
-       /* Put all the overlays we want in a vector in overlay_vec.
-          Store the length in len.  If there are more than 10, make
-          enough space for all, and try again.  */
-       len = 10;
-       overlay_vec = (Lisp_Object *) alloca (len * sizeof (Lisp_Object));
-       noverlays = overlays_at (pos, 0, &overlay_vec, &len, NULL, NULL);
-       if (noverlays > len)
-         {
-           len = noverlays;
-           overlay_vec = (Lisp_Object *) alloca (len * sizeof (Lisp_Object));
-           noverlays = overlays_at (pos, 0, &overlay_vec, &len, NULL, NULL);
-         }
+         /* If we're actually highlighting the same overlay as
+            before, there's no need to do that again.  */
+         if (!NILP (overlay)
+             && EQ (overlay, dpyinfo->mouse_face_overlay))
+           goto check_help_echo;
 
-       /* Sort overlays into increasing priority order.  */
-       noverlays = sort_overlays (overlay_vec, noverlays, w);
-
-       /* Check mouse-face highlighting.  */
-       if (! (EQ (window, dpyinfo->mouse_face_window)
-              && vpos >= dpyinfo->mouse_face_beg_row
-              && vpos <= dpyinfo->mouse_face_end_row
-              && (vpos > dpyinfo->mouse_face_beg_row
-                  || hpos >= dpyinfo->mouse_face_beg_col)
-              && (vpos < dpyinfo->mouse_face_end_row
-                  || hpos < dpyinfo->mouse_face_end_col
-                  || dpyinfo->mouse_face_past_end)))
-         {
-           /* Clear the display of the old active region, if any.  */
-           clear_mouse_face (dpyinfo);
+         dpyinfo->mouse_face_overlay = overlay;
 
-           /* Find the highest priority overlay that has a mouse-face prop.  */
-           overlay = Qnil;
-           for (i = noverlays - 1; i >= 0; --i)
-             {
-               mouse_face = Foverlay_get (overlay_vec[i], Qmouse_face);
-               if (!NILP (mouse_face))
-                 {
-                   overlay = overlay_vec[i];
-                   break;
-                 }
-             }
+         /* Clear the display of the old active region, if any.  */
+         clear_mouse_face (dpyinfo);
+         /* TODO: mouse cursor changes.  */
 
-           /* If no overlay applies, get a text property.  */
-           if (NILP (overlay))
-             mouse_face = Fget_text_property (position, Qmouse_face, w->buffer);
+         /* If no overlay applies, get a text property.  */
+         if (NILP (overlay))
+           mouse_face = Fget_text_property (position, Qmouse_face, object);
 
-           /* Handle the overlay case.  */
-           if (! NILP (overlay))
-             {
-               /* Find the range of text around this char that
-                  should be active.  */
-               Lisp_Object before, after;
-               int ignore;
-
-               before = Foverlay_start (overlay);
-               after = Foverlay_end (overlay);
-               /* Record this as the current active region.  */
-               fast_find_position (w, XFASTINT (before),
-                                   &dpyinfo->mouse_face_beg_col,
-                                   &dpyinfo->mouse_face_beg_row,
-                                   &dpyinfo->mouse_face_beg_x,
-                                   &dpyinfo->mouse_face_beg_y);
-               dpyinfo->mouse_face_past_end
-                 = !fast_find_position (w, XFASTINT (after),
-                                        &dpyinfo->mouse_face_end_col,
-                                        &dpyinfo->mouse_face_end_row,
-                                        &dpyinfo->mouse_face_end_x,
-                                        &dpyinfo->mouse_face_end_y);
-               dpyinfo->mouse_face_window = window;
+         /* Handle the overlay case.  */
+         if (!NILP (overlay))
+           {
+             /* Find the range of text around this char that
+                should be active.  */
+             Lisp_Object before, after;
+             int ignore;
+
+             before = Foverlay_start (overlay);
+             after = Foverlay_end (overlay);
+             /* Record this as the current active region.  */
+             fast_find_position (w, XFASTINT (before),
+                                 &dpyinfo->mouse_face_beg_col,
+                                 &dpyinfo->mouse_face_beg_row,
+                                 &dpyinfo->mouse_face_beg_x,
+                                 &dpyinfo->mouse_face_beg_y, Qnil);
+
+             dpyinfo->mouse_face_past_end
+               = !fast_find_position (w, XFASTINT (after),
+                                      &dpyinfo->mouse_face_end_col,
+                                      &dpyinfo->mouse_face_end_row,
+                                      &dpyinfo->mouse_face_end_x,
+                                      &dpyinfo->mouse_face_end_y, Qnil);
+             dpyinfo->mouse_face_window = window;
+
+             dpyinfo->mouse_face_face_id
+               = face_at_buffer_position (w, pos, 0, 0,
+                                          &ignore, pos + 1, 1);
+
+             /* Display it as active.  */
+             show_mouse_face (dpyinfo, DRAW_MOUSE_FACE);
+             /* TODO: mouse cursor changes.  */
+           }
+         /* Handle the text property case.  */
+         else if (! NILP (mouse_face) && BUFFERP (object))
+           {
+             /* Find the range of text around this char that
+                should be active.  */
+             Lisp_Object before, after, beginning, end;
+             int ignore;
+
+             beginning = Fmarker_position (w->start);
+             end = make_number (BUF_Z (XBUFFER (object))
+                                - XFASTINT (w->window_end_pos));
+             before
+               = Fprevious_single_property_change (make_number (pos + 1),
+                                                   Qmouse_face,
+                                                   object, beginning);
+             after
+               = Fnext_single_property_change (position, Qmouse_face,
+                                               object, end);
+
+             /* Record this as the current active region.  */
+             fast_find_position (w, XFASTINT (before),
+                                 &dpyinfo->mouse_face_beg_col,
+                                 &dpyinfo->mouse_face_beg_row,
+                                 &dpyinfo->mouse_face_beg_x,
+                                 &dpyinfo->mouse_face_beg_y, Qnil);
+             dpyinfo->mouse_face_past_end
+               = !fast_find_position (w, XFASTINT (after),
+                                      &dpyinfo->mouse_face_end_col,
+                                      &dpyinfo->mouse_face_end_row,
+                                      &dpyinfo->mouse_face_end_x,
+                                      &dpyinfo->mouse_face_end_y, Qnil);
+             dpyinfo->mouse_face_window = window;
+
+             if (BUFFERP (object))
                dpyinfo->mouse_face_face_id
                  = face_at_buffer_position (w, pos, 0, 0,
                                             &ignore, pos + 1, 1);
 
-               /* Display it as active.  */
-               show_mouse_face (dpyinfo, DRAW_MOUSE_FACE);
-             }
-           /* Handle the text property case.  */
-           else if (! NILP (mouse_face))
-             {
-               /* Find the range of text around this char that
-                  should be active.  */
-               Lisp_Object before, after, beginning, end;
-               int ignore;
-
-               beginning = Fmarker_position (w->start);
-               XSETINT (end, (BUF_Z (XBUFFER (w->buffer))
-                              - XFASTINT (w->window_end_pos)));
-               before
-                 = Fprevious_single_property_change (make_number (pos + 1),
-                                                     Qmouse_face,
-                                                     w->buffer, beginning);
-               after
-                 = Fnext_single_property_change (position, Qmouse_face,
-                                                 w->buffer, end);
-               /* Record this as the current active region.  */
-               fast_find_position (w, XFASTINT (before),
+             /* Display it as active.  */
+             show_mouse_face (dpyinfo, DRAW_MOUSE_FACE);
+             /* TODO: mouse cursor changes.  */
+           }
+         else if (!NILP (mouse_face) && STRINGP (object))
+           {
+             Lisp_Object b, e;
+             int ignore;
+
+             b = Fprevious_single_property_change (make_number (pos + 1),
+                                                   Qmouse_face,
+                                                   object, Qnil);
+             e = Fnext_single_property_change (position, Qmouse_face,
+                                               object, Qnil);
+             if (NILP (b))
+               b = make_number (0);
+             if (NILP (e))
+               e = make_number (XSTRING (object)->size - 1);
+             fast_find_string_pos (w, XINT (b), object,
                                    &dpyinfo->mouse_face_beg_col,
                                    &dpyinfo->mouse_face_beg_row,
                                    &dpyinfo->mouse_face_beg_x,
-                                   &dpyinfo->mouse_face_beg_y);
-               dpyinfo->mouse_face_past_end
-                 = !fast_find_position (w, XFASTINT (after),
-                                        &dpyinfo->mouse_face_end_col,
-                                        &dpyinfo->mouse_face_end_row,
-                                        &dpyinfo->mouse_face_end_x,
-                                        &dpyinfo->mouse_face_end_y);
-               dpyinfo->mouse_face_window = window;
-               dpyinfo->mouse_face_face_id
-                 = face_at_buffer_position (w, pos, 0, 0,
-                                            &ignore, pos + 1, 1);
-
-               /* Display it as active.  */
-               show_mouse_face (dpyinfo, DRAW_MOUSE_FACE);
-             }
-         }
-
-       /* Look for a `help-echo' property.  */
-       {
-         Lisp_Object help, overlay;
-
-         /* Check overlays first.  */
-         help = Qnil;
-         for (i = noverlays - 1; i >= 0 && NILP (help); --i)
-           {
-             overlay = overlay_vec[i];
-             help = Foverlay_get (overlay, Qhelp_echo);
+                                   &dpyinfo->mouse_face_beg_y, 0);
+             fast_find_string_pos (w, XINT (e), object,
+                                   &dpyinfo->mouse_face_end_col,
+                                   &dpyinfo->mouse_face_end_row,
+                                   &dpyinfo->mouse_face_end_x,
+                                   &dpyinfo->mouse_face_end_y, 1);
+             dpyinfo->mouse_face_past_end = 0;
+             dpyinfo->mouse_face_window = window;
+             dpyinfo->mouse_face_face_id
+               = face_at_string_position (w, object, pos, 0, 0, 0, &ignore,
+                                          glyph->face_id, 1);
+             show_mouse_face (dpyinfo, DRAW_MOUSE_FACE);
+             /* TODO: mouse cursor changes.  */
            }
-
-         if (!NILP (help))
-           {
-             help_echo = help;
-             help_echo_window = window;
-             help_echo_object = overlay;
-             help_echo_pos = pos;
-           }
-         else
+         else if (STRINGP (object) && NILP (mouse_face))
            {
-             /* Try text properties.  */
-             if ((STRINGP (glyph->object)
-                  && glyph->charpos >= 0
-                  && glyph->charpos < XSTRING (glyph->object)->size)
-                 || (BUFFERP (glyph->object)
-                     && glyph->charpos >= BEGV
-                     && glyph->charpos < ZV))
-               help = Fget_text_property (make_number (glyph->charpos),
-                                          Qhelp_echo, glyph->object);
-           
-             if (!NILP (help))
+             /* A string which doesn't have mouse-face, but
+                the text ``under'' it might have.  */
+             struct glyph_row *r = MATRIX_ROW (w->current_matrix, vpos);
+             int start = MATRIX_ROW_START_CHARPOS (r);
+             
+             pos = string_buffer_position (w, object, start);
+             if (pos > 0)
+               mouse_face = get_char_property_and_overlay (make_number (pos),
+                                                           Qmouse_face,
+                                                           w->buffer,
+                                                           &overlay);
+             if (!NILP (mouse_face) && !NILP (overlay))
                {
-                 help_echo = help;
-                 help_echo_window = window;
-                 help_echo_object = glyph->object;
-                 help_echo_pos = glyph->charpos;
+                 Lisp_Object before = Foverlay_start (overlay);
+                 Lisp_Object after = Foverlay_end (overlay);
+                 int ignore;
+
+                 /* Note that we might not be able to find position
+                    BEFORE in the glyph matrix if the overlay is
+                    entirely covered by a `display' property.  In
+                    this case, we overshoot.  So let's stop in
+                    the glyph matrix before glyphs for OBJECT.  */
+                 fast_find_position (w, XFASTINT (before),
+                                     &dpyinfo->mouse_face_beg_col,
+                                     &dpyinfo->mouse_face_beg_row,
+                                     &dpyinfo->mouse_face_beg_x,
+                                     &dpyinfo->mouse_face_beg_y,
+                                     object);
+                      
+                 dpyinfo->mouse_face_past_end
+                   = !fast_find_position (w, XFASTINT (after),
+                                          &dpyinfo->mouse_face_end_col,
+                                          &dpyinfo->mouse_face_end_row,
+                                          &dpyinfo->mouse_face_end_x,
+                                          &dpyinfo->mouse_face_end_y,
+                                          Qnil);
+                 dpyinfo->mouse_face_window = window;
+                 dpyinfo->mouse_face_face_id
+                   = face_at_buffer_position (w, pos, 0, 0,
+                                              &ignore, pos + 1, 1);
+
+                 /* Display it as active.  */
+                 show_mouse_face (dpyinfo, DRAW_MOUSE_FACE);
+                 /* TODO: mouse cursor changes.  */
                }
            }
        }
-         
-       BEGV = obegv;
-       ZV = ozv;
-       current_buffer = obuf;
-      }
-    }
-}
 
-static void
-redo_mouse_highlight ()
-{
-  if (!NILP (last_mouse_motion_frame)
-      && FRAME_LIVE_P (XFRAME (last_mouse_motion_frame)))
+    check_help_echo:
+
+      /* Look for a `help-echo' property.  */
+      {
+       Lisp_Object help, overlay;
+
+       /* Check overlays first.  */
+       help = overlay = Qnil;
+       for (i = noverlays - 1; i >= 0 && NILP (help); --i)
+         {
+           overlay = overlay_vec[i];
+           help = Foverlay_get (overlay, Qhelp_echo); 
+         }
+
+       if (!NILP (help))
+         {
+           help_echo = help;
+           help_echo_window = window;
+           help_echo_object = overlay;
+           help_echo_pos = pos;
+         }
+       else
+         {
+           Lisp_Object object = glyph->object;
+           int charpos = glyph->charpos;
+
+           /* Try text properties.  */
+           if (STRINGP (object)
+               && charpos >= 0
+               && charpos < XSTRING (object)->size)
+             {
+               help = Fget_text_property (make_number (charpos),
+                                          Qhelp_echo, object);
+               if (NILP (help))
+                 {
+                   /* If the string itself doesn't specify a help-echo,
+                      see if the buffer text ``under'' it does.  */
+                   struct glyph_row *r
+                     = MATRIX_ROW (w->current_matrix, vpos);
+                   int start = MATRIX_ROW_START_CHARPOS (r);
+                   int pos = string_buffer_position (w, object, start);
+                   if (pos > 0)
+                     {
+                       help = Fget_char_property (make_number (pos),
+                                                  Qhelp_echo, w->buffer);
+                       if (!NILP (help))
+                         {
+                           charpos = pos;
+                           object = w->buffer;
+                         }
+                     }
+                 }
+             }
+           else if (BUFFERP (object)
+                    && charpos >= BEGV
+                    && charpos < ZV)
+             help = Fget_text_property (make_number (charpos), Qhelp_echo,
+                                        object);
+           
+           if (!NILP (help))
+             {
+               help_echo = help;
+               help_echo_window = window;
+               help_echo_object = object;
+               help_echo_pos = charpos;
+             }
+         }
+      }
+
+      BEGV = obegv;
+      ZV = ozv;
+      current_buffer = obuf;
+    }
+
+ set_cursor:
+  /* TODO: mouse cursor changes. */
+  ;
+}
+
+static void
+redo_mouse_highlight ()
+{
+  if (!NILP (last_mouse_motion_frame)
+      && FRAME_LIVE_P (XFRAME (last_mouse_motion_frame)))
     note_mouse_highlight (XFRAME (last_mouse_motion_frame),
                          last_mouse_motion_position.h,
                          last_mouse_motion_position.v);
@@ -7136,7 +7508,7 @@ x_tool_bar_item (f, x, y, glyph, hpos, vpos, prop_idx)
   int area;
 
   /* Find the glyph under X/Y.  */
-  *glyph = x_y_to_hpos_vpos (w, x, y, hpos, vpos, &area);
+  *glyph = x_y_to_hpos_vpos (w, x, y, hpos, vpos, &area, 0);
   if (*glyph == NULL)
     return -1;
 
@@ -7317,28 +7689,101 @@ note_tool_bar_highlight (f, x, y)
 
 
 \f
-/* Find the glyph matrix position of buffer position POS in window W.
-   *HPOS, *VPOS, *X, and *Y are set to the positions found.  W's
-   current glyphs must be up to date.  If POS is above window start
-   return (0, 0, 0, 0).  If POS is after end of W, return end of
-   last line in W.  */
+/* Find the glyph matrix position of buffer position CHARPOS in window
+   *W.  HPOS, *VPOS, *X, and *Y are set to the positions found.  W's
+   current glyphs must be up to date.  If CHARPOS is above window
+   start return (0, 0, 0, 0).  If CHARPOS is after end of W, return end
+   of last line in W.  In the row containing CHARPOS, stop before glyphs
+   having STOP as object.  */
+
+#if 0 /* This is a version of fast_find_position that's more correct
+        in the presence of hscrolling, for example.  I didn't install
+        it right away because the problem fixed is minor, it failed
+        in 20.x as well, and I think it's too risky to install 
+        so near the release of 21.1.  2001-09-25 gerd.  */
+
+static int
+fast_find_position (w, charpos, hpos, vpos, x, y, stop)
+     struct window *w;
+     int charpos;
+     int *hpos, *vpos, *x, *y;
+     Lisp_Object stop;
+{
+  struct glyph_row *row, *first;
+  struct glyph *glyph, *end;
+  int i, past_end = 0;
+
+  first = MATRIX_FIRST_TEXT_ROW (w->current_matrix);
+  row = row_containing_pos (w, charpos, first, NULL, 0);
+  if (row == NULL)
+    {
+      if (charpos < MATRIX_ROW_START_CHARPOS (first))
+       {
+         *x = *y = *hpos = *vpos = 0;
+         return 0;
+       }
+      else
+       {
+         row = MATRIX_ROW (w->current_matrix, XFASTINT (w->window_end_vpos));
+         past_end = 1;
+       }
+    }
+
+  *x = row->x;
+  *y = row->y;
+  *vpos = MATRIX_ROW_VPOS (row, w->current_matrix);
+  
+  glyph = row->glyphs[TEXT_AREA];
+  end = glyph + row->used[TEXT_AREA];
+  
+  /* Skip over glyphs not having an object at the start of the row.
+     These are special glyphs like truncation marks on terminal
+     frames.  */
+  if (row->displays_text_p)
+    while (glyph < end
+          && INTEGERP (glyph->object)
+          && !EQ (stop, glyph->object)
+          && glyph->charpos < 0)
+      {
+       *x += glyph->pixel_width;
+       ++glyph;
+      }
+
+  while (glyph < end
+        && !INTEGERP (glyph->object)
+        && !EQ (stop, glyph->object)
+        && (!BUFFERP (glyph->object)
+            || glyph->charpos < charpos))
+    {
+      *x += glyph->pixel_width;
+      ++glyph;
+    }
+
+  *hpos = glyph - row->glyphs[TEXT_AREA];
+  return past_end;
+}
+
+#else /* not 0 */
 
 static int
-fast_find_position (w, pos, hpos, vpos, x, y)
+fast_find_position (w, pos, hpos, vpos, x, y, stop)
      struct window *w;
      int pos;
      int *hpos, *vpos, *x, *y;
+     Lisp_Object stop;
 {
   int i;
   int lastcol;
   int maybe_next_line_p = 0;
   int line_start_position;
   int yb = window_text_bottom_y (w);
-  struct glyph_row *row = MATRIX_ROW (w->current_matrix, 0);
-  struct glyph_row *best_row = row;
-  int row_vpos = 0, best_row_vpos = 0;
+  struct glyph_row *row, *best_row;
+  int row_vpos, best_row_vpos;
   int current_x;
 
+  row = best_row = MATRIX_FIRST_TEXT_ROW (w->current_matrix);
+  row_vpos = best_row_vpos = MATRIX_ROW_VPOS (row, w->current_matrix);
+
   while (row->y < yb)
     {
       if (row->used[TEXT_AREA])
@@ -7351,46 +7796,50 @@ fast_find_position (w, pos, hpos, vpos, x, y)
       /* If the position sought is the end of the buffer,
         don't include the blank lines at the bottom of the window.  */
       else if (line_start_position == pos
-              && pos == BUF_ZV (XBUFFER (w->buffer)))
+               && pos == BUF_ZV (XBUFFER (w->buffer)))
        {
          maybe_next_line_p = 1;
          break;
        }
       else if (line_start_position > 0)
-       {
-         best_row = row;
-         best_row_vpos = row_vpos;
-       }
+        {
+          best_row = row;
+          best_row_vpos = row_vpos;
+        }
 
       if (row->y + row->height >= yb)
-       break;
-      
+        break;
+
       ++row;
       ++row_vpos;
     }
-  
+
   /* Find the right column within BEST_ROW.  */
   lastcol = 0;
   current_x = best_row->x;
   for (i = 0; i < best_row->used[TEXT_AREA]; i++)
     {
       struct glyph *glyph = best_row->glyphs[TEXT_AREA] + i;
-      int charpos;
+      int charpos = glyph->charpos;
 
-      charpos = glyph->charpos;
-      if (charpos == pos)
+      if (BUFFERP (glyph->object))
        {
-         *hpos = i;
-         *vpos = best_row_vpos;
-         *x = current_x;
-         *y = best_row->y;
-         return 1;
+         if (charpos == pos)
+           {
+             *hpos = i;
+             *vpos = best_row_vpos;
+             *x = current_x;
+             *y = best_row->y;
+             return 1;
+           }
+         else if (charpos > pos)
+           break;
        }
-      else if (charpos > pos)
+      else if (EQ (glyph->object, stop))
        break;
-      else if (charpos > 0)
-       lastcol = i;
 
+      if (charpos > 0)
+       lastcol = i;
       current_x += glyph->pixel_width;
     }
 
@@ -7412,6 +7861,90 @@ fast_find_position (w, pos, hpos, vpos, x, y)
   return 0;
 }
 
+#endif /* not 0 */
+
+
+/* Find the position of the glyph for position POS in OBJECT in
+   window W's current matrix, and return in *X/*Y the pixel
+   coordinates, and return in *HPOS/*VPOS the column/row of the glyph.
+
+   RIGHT_P non-zero means return the position of the right edge of the
+   glyph, RIGHT_P zero means return the left edge position.
+
+   If no glyph for POS exists in the matrix, return the position of
+   the glyph with the next smaller position that is in the matrix, if
+   RIGHT_P is zero.  If RIGHT_P is non-zero, and no glyph for POS
+   exists in the matrix, return the position of the glyph with the
+   next larger position in OBJECT.
+
+   Value is non-zero if a glyph was found.  */
+
+static int
+fast_find_string_pos (w, pos, object, hpos, vpos, x, y, right_p)
+     struct window *w;
+     int pos;
+     Lisp_Object object;
+     int *hpos, *vpos, *x, *y;
+     int right_p;
+{
+  int yb = window_text_bottom_y (w);
+  struct glyph_row *r;
+  struct glyph *best_glyph = NULL;
+  struct glyph_row *best_row = NULL;
+  int best_x = 0;
+
+  for (r = MATRIX_FIRST_TEXT_ROW (w->current_matrix);
+       r->enabled_p && r->y < yb;
+       ++r)
+    {
+      struct glyph *g = r->glyphs[TEXT_AREA];
+      struct glyph *e = g + r->used[TEXT_AREA];
+      int gx;
+
+      for (gx = r->x; g < e; gx += g->pixel_width, ++g)
+       if (EQ (g->object, object))
+         {
+           if (g->charpos == pos)
+             {
+               best_glyph = g;
+               best_x = gx;
+               best_row = r;
+               goto found;
+             }
+           else if (best_glyph == NULL
+                    || ((abs (g->charpos - pos)
+                        < abs (best_glyph->charpos - pos))
+                        && (right_p
+                            ? g->charpos < pos
+                            : g->charpos > pos)))
+             {
+               best_glyph = g;
+               best_x = gx;
+               best_row = r;
+             }
+         }
+    }
+
+ found:
+
+  if (best_glyph)
+    {
+      *x = best_x;
+      *hpos = best_glyph - best_row->glyphs[TEXT_AREA];
+
+      if (right_p)
+       {
+         *x += best_glyph->pixel_width;
+         ++*hpos;
+       }
+      
+      *y = best_row->y;
+      *vpos = best_row - w->current_matrix->rows;
+    }
+
+  return best_glyph != NULL;
+}
+
 
 /* Display the active region described by mouse_face_*
    in its mouse-face if HL > 0, in its normal face if HL = 0.  */
@@ -7423,81 +7956,61 @@ show_mouse_face (dpyinfo, draw)
 {
   struct window *w = XWINDOW (dpyinfo->mouse_face_window);
   struct frame *f = XFRAME (WINDOW_FRAME (w));
-  int i;
-  int cursor_off_p = 0;
-  struct cursor_pos saved_cursor;
-
-  saved_cursor = output_cursor;
   
-  /* If window is in the process of being destroyed, don't bother
-     to do anything.  */
-  if (w->current_matrix == NULL)
-    goto set_x_cursor;
-
-  /* Recognize when we are called to operate on rows that don't exist
-     anymore.  This can happen when a window is split.  */
-  if (dpyinfo->mouse_face_end_row >= w->current_matrix->nrows)
-    goto set_x_cursor;
-
-  set_output_cursor (&w->phys_cursor);
-
-  /* Note that mouse_face_beg_row etc. are window relative.  */
-  for (i = dpyinfo->mouse_face_beg_row;
-       i <= dpyinfo->mouse_face_end_row;
-       i++)
+  if (/* If window is in the process of being destroyed, don't bother
+        to do anything.  */
+      w->current_matrix != NULL
+      /* Don't update mouse highlight if hidden */
+      && (draw != DRAW_MOUSE_FACE || !dpyinfo->mouse_face_hidden)
+      /* Recognize when we are called to operate on rows that don't exist
+        anymore.  This can happen when a window is split.  */
+      && dpyinfo->mouse_face_end_row < w->current_matrix->nrows)
     {
-      int start_hpos, end_hpos, start_x;
-      struct glyph_row *row = MATRIX_ROW (w->current_matrix, i);
-
-      /* Don't do anything if row doesn't have valid contents.  */
-      if (!row->enabled_p)
-       continue;
+      int phys_cursor_on_p = w->phys_cursor_on_p;
+      struct glyph_row *row, *first, *last;
 
-      /* For all but the first row, the highlight starts at column 0.  */
-      if (i == dpyinfo->mouse_face_beg_row)
-       {
-         start_hpos = dpyinfo->mouse_face_beg_col;
-         start_x = dpyinfo->mouse_face_beg_x;
-       }
-      else
+      first = MATRIX_ROW (w->current_matrix, dpyinfo->mouse_face_beg_row);
+      last = MATRIX_ROW (w->current_matrix, dpyinfo->mouse_face_end_row);
+      
+      for (row = first; row <= last && row->enabled_p; ++row)
        {
-         start_hpos = 0;
-         start_x = 0;
-       }
+         int start_hpos, end_hpos, start_x;
 
-      if (i == dpyinfo->mouse_face_end_row)
-       end_hpos = dpyinfo->mouse_face_end_col;
-      else
-       end_hpos = row->used[TEXT_AREA];
+         /* For all but the first row, the highlight starts at column 0.  */
+         if (row == first)
+           {
+             start_hpos = dpyinfo->mouse_face_beg_col;
+             start_x = dpyinfo->mouse_face_beg_x;
+           }
+         else
+           {
+             start_hpos = 0;
+             start_x = 0;
+           }
 
-      /* If the cursor's in the text we are about to rewrite, turn the
-        cursor off.  */
-      if (!w->pseudo_window_p
-         && i == output_cursor.vpos
-         && output_cursor.hpos >= start_hpos - 1
-         && output_cursor.hpos <= end_hpos)
-       {
-         x_update_window_cursor (w, 0);
-         cursor_off_p = 1;
-       }
+         if (row == last)
+           end_hpos = dpyinfo->mouse_face_end_col;
+         else
+           end_hpos = row->used[TEXT_AREA];
 
-      if (end_hpos > start_hpos)
-       {
-         row->mouse_face_p = draw == DRAW_MOUSE_FACE;
-         x_draw_glyphs (w, start_x, row, TEXT_AREA, 
-                        start_hpos, end_hpos, draw, NULL, NULL, 0);
-       }
-    }
+         if (end_hpos > start_hpos)
+           {
+             x_draw_glyphs (w, start_x, row, TEXT_AREA, 
+                            start_hpos, end_hpos, draw, 0);
 
-  /* If we turned the cursor off, turn it back on.  */
-  if (cursor_off_p)
-    x_display_cursor (w, 1,
-                     output_cursor.hpos, output_cursor.vpos,
-                     output_cursor.x, output_cursor.y);
+             row->mouse_face_p
+               = draw == DRAW_MOUSE_FACE || draw == DRAW_IMAGE_RAISED;
+           }
+       }
 
-  output_cursor = saved_cursor;
+      /* When we've written over the cursor, arrange for it to
+        be displayed again.  */
+      if (phys_cursor_on_p && !w->phys_cursor_on_p)
+       x_display_cursor (w, 1,
+                         w->phys_cursor.hpos, w->phys_cursor.vpos,
+                         w->phys_cursor.x, w->phys_cursor.y);
+    }
 
- set_x_cursor:
 #if 0 /* MAC_TODO: mouse cursor */
   /* Change the mouse cursor.  */
   if (draw == DRAW_NORMAL_TEXT)
@@ -7510,25 +8023,28 @@ show_mouse_face (dpyinfo, draw)
     XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
                   f->output_data.x->nontext_cursor);
 #endif
-  ;
 }
 
 /* Clear out the mouse-highlighted active region.
    Redraw it un-highlighted first.  */
 
-void
+static int
 clear_mouse_face (dpyinfo)
      struct mac_display_info *dpyinfo;
 {
-  if (!NILP (tip_frame))
-    return;
-  
+  int cleared = 0;
+
   if (! NILP (dpyinfo->mouse_face_window))
-    show_mouse_face (dpyinfo, DRAW_NORMAL_TEXT);
+    {
+      show_mouse_face (dpyinfo, DRAW_NORMAL_TEXT);
+      cleared = 1;
+    }
 
   dpyinfo->mouse_face_beg_row = dpyinfo->mouse_face_beg_col = -1;
   dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1;
   dpyinfo->mouse_face_window = Qnil;
+  dpyinfo->mouse_face_overlay = Qnil;
+  return cleared;
 }
 
 
@@ -7536,23 +8052,25 @@ clear_mouse_face (dpyinfo)
    redisplay interface, and is called from try_window_id and similar
    functions to ensure the mouse-highlight is off.  */
 
-void
+static void
 x_clear_mouse_face (w)
      struct window *w;
 {
   struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (XFRAME (w->frame));
   Lisp_Object window;
 
+  BLOCK_INPUT;
   XSETWINDOW (window, w);
   if (EQ (window, dpyinfo->mouse_face_window))
     clear_mouse_face (dpyinfo);
+  UNBLOCK_INPUT;
 }
 
 
 /* Just discard the mouse face information for frame F, if any.
    This is used when the size of F is changed.  */
 
-static void
+void
 cancel_mouse_face (f)
      FRAME_PTR f;
 {
@@ -7570,6 +8088,107 @@ cancel_mouse_face (f)
 \f
 static struct scroll_bar *x_window_to_scroll_bar ();
 static void x_scroll_bar_report_motion ();
+static void x_check_fullscreen P_ ((struct frame *));
+static void x_check_fullscreen_move P_ ((struct frame *));
+static int glyph_rect P_ ((struct frame *f, int, int, Rect *));
+
+
+/* Try to determine frame pixel position and size of the glyph under
+   frame pixel coordinates X/Y on frame F .  Return the position and
+   size in *RECT.  Value is non-zero if we could compute these
+   values.  */
+
+static int
+glyph_rect (f, x, y, rect)
+     struct frame *f;
+     int x, y;
+     Rect *rect;
+{
+  Lisp_Object window;
+  int part;
+
+  window = window_from_coordinates (f, x, y, &part, 0);
+  if (!NILP (window))
+    {
+      struct window *w = XWINDOW (window);
+      struct glyph_row *r = MATRIX_FIRST_TEXT_ROW (w->current_matrix);
+      struct glyph_row *end = r + w->current_matrix->nrows - 1;
+
+      frame_to_window_pixel_xy (w, &x, &y);
+
+      for (; r < end && r->enabled_p; ++r)
+       if (r->y <= y && r->y + r->height > y)
+         {
+           /* Found the row at y.  */
+           struct glyph *g = r->glyphs[TEXT_AREA];
+           struct glyph *end = g + r->used[TEXT_AREA];
+           int gx;
+
+           rect->top = WINDOW_TO_FRAME_PIXEL_Y (w, r->y);
+           rect->bottom = rect->top + r->height;
+
+           if (x < r->x)
+             {
+               /* x is to the left of the first glyph in the row.  */
+               rect->left = XINT (w->left);
+               rect->right = WINDOW_TO_FRAME_PIXEL_X (w, r->x);
+               return 1;
+             }
+
+           for (gx = r->x; g < end; gx += g->pixel_width, ++g)
+             if (gx <= x && gx + g->pixel_width > x)
+               {
+                 /* x is on a glyph.  */
+                 rect->left = WINDOW_TO_FRAME_PIXEL_X (w, gx);
+                 rect->right = rect->left + g->pixel_width;
+                 return 1;
+               }
+
+           /* x is to the right of the last glyph in the row.  */
+           rect->left = WINDOW_TO_FRAME_PIXEL_X (w, gx);
+           rect->right = XINT (w->left) + XINT (w->width);
+           return 1;
+         }
+    }
+
+  /* The y is not on any row.  */
+  return 0;
+}
+
+/* Record the position of the mouse in last_mouse_glyph.  */
+static void
+remember_mouse_glyph (f1, gx, gy)
+     struct frame * f1;
+     int gx, gy;
+{
+  if (!glyph_rect (f1, gx, gy, &last_mouse_glyph))
+    {
+      int width = FRAME_SMALLEST_CHAR_WIDTH (f1);
+      int height = FRAME_SMALLEST_FONT_HEIGHT (f1);
+
+      /* Arrange for the division in PIXEL_TO_CHAR_COL etc. to
+        round down even for negative values.  */
+      if (gx < 0)
+       gx -= width - 1;
+      if (gy < 0)
+       gy -= height - 1;
+#if 0
+      /* This was the original code from XTmouse_position, but it seems
+        to give the position of the glyph diagonally next to the one
+        the mouse is over.  */
+      gx = (gx + width - 1) / width * width;
+      gy = (gy + height - 1) / height * height;
+#else
+      gx = gx / width * width;
+      gy = gy / height * height;
+#endif
+
+      last_mouse_glyph.left = gx;
+      last_mouse_glyph.top = gy;
+      last_mouse_glyph.right  = gx + width;
+      last_mouse_glyph.bottom = gy + height;
+    }
+}
 
 /* Return the current position of the mouse.
    *fp should be a frame which indicates which display to ask about.
@@ -7591,7 +8210,7 @@ static void x_scroll_bar_report_motion ();
    This clears the mouse_moved flag, so we can wait for the next mouse
    movement.  */
 
-void
+static void
 XTmouse_position (fp, insist, bar_window, part, x, y, time)
      FRAME_PTR *fp;
      int insist;
@@ -7618,7 +8237,12 @@ XTmouse_position (fp, insist, bar_window, part, x, y, time)
 
       last_mouse_scroll_bar = Qnil;
 
+#if TARGET_API_MAC_CARBON
+      SetPort (GetWindowPort (wp));
+#else
       SetPort (wp);
+#endif
+
       GetMouse (&mouse_pos);
 
       pixel_to_glyph_coords (f, mouse_pos.h, mouse_pos.v, &ignore1, &ignore2,
@@ -7642,7 +8266,7 @@ XTmouse_position (fp, insist, bar_window, part, x, y, time)
                                                                         
 /* Create a scroll bar and return the scroll bar vector for it.  W is
    the Emacs window on which to create the scroll bar. TOP, LEFT,
-   WIDTH and HEIGHT are.the pixel coordinates and dimensions of the
+   WIDTH and HEIGHT are the pixel coordinates and dimensions of the
    scroll bar. */
 
 static struct scroll_bar *
@@ -7663,8 +8287,13 @@ x_scroll_bar_create (w, top, left, width, height, disp_top, disp_height)
   r.right = left + width;
   r.bottom = disp_top + disp_height;
   
+#ifdef TARGET_API_MAC_CARBON
+  ch = NewControl (FRAME_MAC_WINDOW (f), &r, "\p", 1, 0, 0, 0,
+                  kControlScrollBarProc, 0L);
+#else
   ch = NewControl (FRAME_MAC_WINDOW (f), &r, "\p", 1, 0, 0, 0, scrollBarProc,
                   0L);
+#endif
   SET_SCROLL_BAR_CONTROL_HANDLE (bar, ch);
   SetControlReference (ch, (long) bar);
 
@@ -7711,6 +8340,8 @@ x_scroll_bar_set_handle (bar, start, end, rebuild)
   int dragging = ! NILP (bar->dragging);
   ControlHandle ch = SCROLL_BAR_CONTROL_HANDLE (bar);
   FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)));
+  int top_range = VERTICAL_SCROLL_BAR_TOP_RANGE (f, XINT (bar->height));
+  int length = end - start;
 
   /* If the display is already accurate, do nothing.  */
   if (! rebuild
@@ -7720,53 +8351,41 @@ x_scroll_bar_set_handle (bar, start, end, rebuild)
 
   BLOCK_INPUT;
 
-  {
-    int inside_width = VERTICAL_SCROLL_BAR_INSIDE_WIDTH (f, XINT (bar->width));
-    int inside_height = VERTICAL_SCROLL_BAR_INSIDE_HEIGHT (f, XINT (bar->height));
-    int top_range = VERTICAL_SCROLL_BAR_TOP_RANGE (f, XINT (bar->height));
-
-    /* Make sure the values are reasonable, and try to preserve
-       the distance between start and end.  */
-    {
-      int length = end - start;
-
-      if (start < 0)
-       start = 0;
-      else if (start > top_range)
-       start = top_range;
-      end = start + length;
-
-      if (end < start)
-       end = start;
-      else if (end > top_range && ! dragging)
-       end = top_range;
-    }
-
-    /* Store the adjusted setting in the scroll bar.  */
-    XSETINT (bar->start, start);
-    XSETINT (bar->end, end);
-
-    /* Clip the end position, just for display.  */
-    if (end > top_range)
-      end = top_range;
-
-    /* Draw bottom positions VERTICAL_SCROLL_BAR_MIN_HANDLE pixels
-       below top positions, to make sure the handle is always at least
-       that many pixels tall.  */
-    end += VERTICAL_SCROLL_BAR_MIN_HANDLE;
-
-    SetControlMinimum (ch, 0);
-    /* Don't inadvertently activate deactivated scroll bars */
-    if (GetControlMaximum (ch) != -1)
-       SetControlMaximum (ch,
-                         VERTICAL_SCROLL_BAR_TOP_RANGE (f,
-                                                        XINT (bar->height))
-                         - 1);
-    SetControlValue (ch, start);
-#if 0  /* MAC_TODO: detect Appearance Manager 1.1 before use.  */
-    SetControlViewSize (ch, end);
+  /* Make sure the values are reasonable, and try to preserve the
+     distance between start and end.  */
+  if (start < 0)
+    start = 0;
+  else if (start > top_range)
+    start = top_range;
+  end = start + length;
+  
+  if (end < start)
+    end = start;
+  else if (end > top_range && ! dragging)
+    end = top_range;
+
+  /* Store the adjusted setting in the scroll bar.  */
+  XSETINT (bar->start, start);
+  XSETINT (bar->end, end);
+
+  /* Clip the end position, just for display.  */
+  if (end > top_range)
+    end = top_range;
+
+  /* Draw bottom positions VERTICAL_SCROLL_BAR_MIN_HANDLE pixels below
+     top positions, to make sure the handle is always at least that
+     many pixels tall.  */
+  end += VERTICAL_SCROLL_BAR_MIN_HANDLE;
+
+  SetControlMinimum (ch, 0);
+  /* Don't inadvertently activate deactivated scroll bars */
+  if (GetControlMaximum (ch) != -1)
+    SetControlMaximum (ch, top_range + VERTICAL_SCROLL_BAR_MIN_HANDLE
+                      - (end - start));
+  SetControlValue (ch, start);
+#if TARGET_API_MAC_CARBON
+  SetControlViewSize (ch, end - start);
 #endif
-  }
 
   UNBLOCK_INPUT;
 }
@@ -7780,7 +8399,7 @@ x_scroll_bar_remove (bar)
      struct scroll_bar *bar;
 {
   FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)));
-  
+
   BLOCK_INPUT;
 
   /* Destroy the Mac scroll bar control  */
@@ -7792,12 +8411,10 @@ x_scroll_bar_remove (bar)
   UNBLOCK_INPUT;
 }
 
-
 /* Set the handle of the vertical scroll bar for WINDOW to indicate
    that we are displaying PORTION characters out of a total of WHOLE
    characters, starting at POSITION.  If WINDOW has no scroll bar,
    create one.  */
-
 static void
 XTset_vertical_scroll_bar (w, portion, whole, position)
      struct window *w;
@@ -7811,7 +8428,11 @@ XTset_vertical_scroll_bar (w, portion, whole, position)
   /* Get window dimensions.  */
   window_box (w, -1, &window_x, &window_y, &window_width, &window_height);
   top = window_y;
+#ifdef MAC_OSX
+  width = 16;
+#else
   width = FRAME_SCROLL_BAR_COLS (f) * CANON_X_UNIT (f);
+#endif
   height = window_height;
 
   /* Compute the left edge of the scroll bar area.  */
@@ -7881,9 +8502,19 @@ XTset_vertical_scroll_bar (w, portion, whole, position)
         Draw1Control (ch);
       else
         {
+         /* Clear areas not covered by the scroll bar because it's not as
+            wide as the area reserved for it .  This makes sure a
+            previous mode line display is cleared after C-x 2 C-x 1, for
+            example.  */
+         int area_width = FRAME_SCROLL_BAR_COLS (f) * CANON_X_UNIT (f);
+         XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
+                     left, top, area_width, height, 0);
+
+#if 0
           if (sb_left + sb_width >= PIXEL_WIDTH (f))
             XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
                        sb_left - 1, top, 1, height, 0);
+#endif
 
           HideControl (ch);
           MoveControl (ch, sb_left + VERTICAL_SCROLL_BAR_WIDTH_TRIM, disp_top);
@@ -7949,8 +8580,10 @@ XTcondemn_scroll_bars (frame)
     }
 }
 
+
 /* Un-mark WINDOW's scroll bar for deletion in this judgment cycle.
    Note that WINDOW isn't necessarily condemned at all.  */
+
 static void
 XTredeem_scroll_bar (window)
      struct window *window;
@@ -8037,11 +8670,14 @@ activate_scroll_bars (frame)
   while (! NILP (bar))
     {
       ch = SCROLL_BAR_CONTROL_HANDLE (XSCROLL_BAR (bar));
+#ifdef TARGET_API_MAC_CARBON
+      ActivateControl (ch);
+#else
       SetControlMaximum (ch,
                         VERTICAL_SCROLL_BAR_TOP_RANGE (frame,
                                                        XINT (XSCROLL_BAR (bar)
                                                              ->height)) - 1);
-      
+#endif
       bar = XSCROLL_BAR (bar)->next;
     }
 }
@@ -8058,8 +8694,11 @@ deactivate_scroll_bars (frame)
   while (! NILP (bar))
     {
       ch = SCROLL_BAR_CONTROL_HANDLE (XSCROLL_BAR (bar));
+#ifdef TARGET_API_MAC_CARBON
+      DeactivateControl (ch);
+#else
       SetControlMaximum (ch, XINT (-1));
-      
+#endif      
       bar = XSCROLL_BAR (bar)->next;
     }
 }
@@ -8100,7 +8739,11 @@ x_scroll_bar_handle_click (bar, part_code, er, bufp)
     case kControlPageDownPart:
       bufp->part = scroll_bar_below_handle;
       break;
+#ifdef TARGET_API_MAC_CARBON
+    default:
+#else
     case kControlIndicatorPart:
+#endif
       if (er->what == mouseDown)
         bar->dragging = make_number (0);
       XSETVECTOR (last_mouse_scroll_bar, bar);
@@ -8161,7 +8804,12 @@ x_scroll_bar_report_motion (fp, bar_window, part, x, y, time)
   struct frame *f = ((mac_output *) GetWRefCon (wp))->mFP;
   int win_y, top_range;
 
+#if TARGET_API_MAC_CARBON
+  SetPort (GetWindowPort (wp));
+#else
   SetPort (wp);
+#endif
+
   GetMouse (&mouse_pos);
 
   win_y = mouse_pos.v - XINT (bar->top);
@@ -8204,21 +8852,24 @@ x_scroll_bar_report_motion (fp, bar_window, part, x, y, time)
                             Text Cursor
  ***********************************************************************/
 
-/* Note if the text cursor of window W has been overwritten by a
-   drawing operation that outputs N glyphs starting at HPOS in the
-   line given by output_cursor.vpos.  N < 0 means all the rest of the
-   line after HPOS has been written.  */
+/* Notice if the text cursor of window W has been overwritten by a
+   drawing operation that outputs glyphs starting at START_X and
+   ending at END_X in the line given by output_cursor.vpos.
+   Coordinates are area-relative.  END_X < 0 means all the rest
+   of the line after START_X has been written.  */
 
 static void
-note_overwritten_text_cursor (w, hpos, n)
+notice_overwritten_cursor (w, area, x0, x1, y0, y1)
      struct window *w;
-     int hpos, n;
-{
-  if (updated_area == TEXT_AREA
-      && output_cursor.vpos == w->phys_cursor.vpos
-      && hpos <= w->phys_cursor.hpos
-      && (n < 0
-         || hpos + n > w->phys_cursor.hpos))
+     enum glyph_row_area area;
+     int x0, x1, y0, y1;
+{
+  if (area == TEXT_AREA
+      && w->phys_cursor_on_p
+      && y0 <= w->phys_cursor.y
+      && y1 >= w->phys_cursor.y + w->phys_cursor_height
+      && x0 <= w->phys_cursor.x
+      && (x1 < 0 || x1 > w->phys_cursor.x))
     w->phys_cursor_on_p = 0;
 }
 
@@ -8405,9 +9056,11 @@ x_draw_phys_cursor_glyph (w, row, hl)
      glyphs and mini-buffer.  */
   if (w->phys_cursor.hpos < row->used[TEXT_AREA])
     {
+      int on_p = w->phys_cursor_on_p;
       x_draw_glyphs (w, w->phys_cursor.x, row, TEXT_AREA,
-                    w->phys_cursor.hpos, w->phys_cursor.hpos + 1,
-                    hl, 0, 0, 0);
+                     w->phys_cursor.hpos, w->phys_cursor.hpos + 1,
+                     hl, 0);
+      w->phys_cursor_on_p = on_p;
 
       /* When we erase the cursor, and ROW is overlapped by other
         rows, make sure that these overlapping parts of other rows
@@ -8459,7 +9112,7 @@ x_erase_phys_cursor (w)
     goto mark_cursor_off;
   
   /* If row is completely invisible, don't attempt to delete a cursor which
-     isn't there.  This can happen if cursor is at top of a window, and
+     isn't there.  This may happen if cursor is at top of window, and
      we switch to a buffer with a header line in that window.  */
   if (cursor_row->visible_height <= 0)
     goto mark_cursor_off;
@@ -8512,8 +9165,6 @@ x_erase_phys_cursor (w)
   /* Erase the cursor by redrawing the character underneath it.  */
   if (mouse_face_here_p)
     hl = DRAW_MOUSE_FACE;
-  else if (cursor_row->inverse_p)
-    hl = DRAW_INVERSE_VIDEO;
   else
     hl = DRAW_NORMAL_TEXT;
   x_draw_phys_cursor_glyph (w, cursor_row, hl);
@@ -8524,6 +9175,36 @@ x_erase_phys_cursor (w)
 }
 
 
+/* Non-zero if physical cursor of window W is within mouse face.  */
+
+static int
+cursor_in_mouse_face_p (w)
+     struct window *w;
+{
+  struct mac_display_info *dpyinfo
+    = FRAME_MAC_DISPLAY_INFO (XFRAME (w->frame));
+  int in_mouse_face = 0;
+  
+  if (WINDOWP (dpyinfo->mouse_face_window)
+      && XWINDOW (dpyinfo->mouse_face_window) == w)
+    {
+      int hpos = w->phys_cursor.hpos;
+      int vpos = w->phys_cursor.vpos;
+
+      if (vpos >= dpyinfo->mouse_face_beg_row
+         && vpos <= dpyinfo->mouse_face_end_row
+         && (vpos > dpyinfo->mouse_face_beg_row
+             || hpos >= dpyinfo->mouse_face_beg_col)
+         && (vpos < dpyinfo->mouse_face_end_row
+             || hpos < dpyinfo->mouse_face_end_col
+             || dpyinfo->mouse_face_past_end))
+       in_mouse_face = 1;
+    }
+
+  return in_mouse_face;
+}
+
+
 /* Display or clear cursor of window W.  If ON is zero, clear the
    cursor.  If it is non-zero, display the cursor.  If ON is nonzero,
    where to put the cursor is specified by HPOS, VPOS, X and Y.  */
@@ -8539,6 +9220,8 @@ x_display_and_set_cursor (w, on, hpos, vpos, x, y)
   struct glyph_matrix *current_glyphs;
   struct glyph_row *glyph_row;
   struct glyph *glyph;
+  int cursor_non_selected;
+  int active_cursor = 1;
 
   /* This is pointless on invisible frames, and dangerous on garbaged
      windows and frames; in the latter case, the frame or window may
@@ -8574,6 +9257,9 @@ x_display_and_set_cursor (w, on, hpos, vpos, x, y)
      the cursor type given by the frame parameter.  If explicitly
      marked off, draw no cursor.  In all other cases, we want a hollow
      box cursor.  */
+  cursor_non_selected 
+    = !NILP (Fbuffer_local_value (Qcursor_in_non_selected_windows,
+                                 w->buffer));
   new_cursor_width = -1;
   if (cursor_in_echo_area
       && FRAME_HAS_MINIBUF_P (f)
@@ -8582,31 +9268,46 @@ x_display_and_set_cursor (w, on, hpos, vpos, x, y)
       if (w == XWINDOW (echo_area_window))
        new_cursor_type = FRAME_DESIRED_CURSOR (f);
       else
-       new_cursor_type = HOLLOW_BOX_CURSOR;
-    }
-  else
-    {
-      if (w != XWINDOW (selected_window)
-         || f != FRAME_X_DISPLAY_INFO (f)->x_highlight_frame)
        {
-         extern int cursor_in_non_selected_windows;
-         
-         if (MINI_WINDOW_P (w) || !cursor_in_non_selected_windows)
-           new_cursor_type = NO_CURSOR;
-         else
+         if (cursor_non_selected)
            new_cursor_type = HOLLOW_BOX_CURSOR;
+         else
+           new_cursor_type = NO_CURSOR;
+         active_cursor = 0;
        }
-      else if (w->cursor_off_p)
-       new_cursor_type = NO_CURSOR;
+    }
+  else
+    {
+      if (f != FRAME_MAC_DISPLAY_INFO (f)->x_highlight_frame
+          || w != XWINDOW (f->selected_window))
+        {
+         active_cursor = 0;
+
+          if (MINI_WINDOW_P (w) 
+              || !cursor_non_selected
+              || NILP (XBUFFER (w->buffer)->cursor_type))
+            new_cursor_type = NO_CURSOR;
+          else
+            new_cursor_type = HOLLOW_BOX_CURSOR;
+        }
       else
-       {
+        {
          struct buffer *b = XBUFFER (w->buffer);
 
          if (EQ (b->cursor_type, Qt))
-           new_cursor_type = FRAME_DESIRED_CURSOR (f);
+            new_cursor_type = FRAME_DESIRED_CURSOR (f);
          else
            new_cursor_type = x_specified_cursor_type (b->cursor_type, 
                                                       &new_cursor_width);
+         if (w->cursor_off_p)
+           {
+             if (new_cursor_type == FILLED_BOX_CURSOR)
+               new_cursor_type = HOLLOW_BOX_CURSOR;
+             else if (new_cursor_type == BAR_CURSOR && new_cursor_width > 1)
+               new_cursor_width = 1;
+             else
+               new_cursor_type = NO_CURSOR;
+           }
        }
     }
 
@@ -8617,7 +9318,9 @@ x_display_and_set_cursor (w, on, hpos, vpos, x, y)
       && (!on
          || w->phys_cursor.x != x
          || w->phys_cursor.y != y
-         || new_cursor_type != w->phys_cursor_type))
+         || new_cursor_type != w->phys_cursor_type
+         || (new_cursor_type == BAR_CURSOR
+             && new_cursor_width != w->phys_cursor_width)))
     x_erase_phys_cursor (w);
 
   /* If the cursor is now invisible and we want it to be visible,
@@ -8634,6 +9337,7 @@ x_display_and_set_cursor (w, on, hpos, vpos, x, y)
       w->phys_cursor.hpos = hpos;
       w->phys_cursor.vpos = vpos;
       w->phys_cursor_type = new_cursor_type;
+      w->phys_cursor_width = new_cursor_width;
       w->phys_cursor_on_p = 1;
 
       switch (new_cursor_type)
@@ -8656,18 +9360,7 @@ x_display_and_set_cursor (w, on, hpos, vpos, x, y)
        default:
          abort ();
        }
-      
-#ifdef HAVE_X_I18N
-      if (w == XWINDOW (f->selected_window))
-       if (FRAME_XIC (f) && (FRAME_XIC_STYLE (f) & XIMPreeditPosition))
-         xic_set_preeditarea (w, x, y);
-#endif
     }
-
-#ifndef XFlush
-  if (updating_frame != f)
-    XFlush (FRAME_X_DISPLAY (f));
-#endif
 }
 
 
@@ -8694,6 +9387,7 @@ x_display_cursor (w, on, hpos, vpos, x, y)
 void
 x_update_cursor (f, on_p)
      struct frame *f;
+     int on_p;
 {
   x_update_cursor_in_window_tree (XWINDOW (f->root_window), on_p);
 }
@@ -8734,368 +9428,91 @@ x_update_window_cursor (w, on)
   if (w->current_matrix)
     {
       BLOCK_INPUT;
-      x_display_and_set_cursor (w, on, w->phys_cursor.hpos, w->phys_cursor.vpos,
-                               w->phys_cursor.x, w->phys_cursor.y);
+      x_display_and_set_cursor (w, on, w->phys_cursor.hpos,
+                                w->phys_cursor.vpos, w->phys_cursor.x,
+                                w->phys_cursor.y);
       UNBLOCK_INPUT;
     }
 }
 
-\f
-#if 0 /* MAC_TODO: no icon and X error handling (?) */
-/* Icons.  */
 
-/* Refresh bitmap kitchen sink icon for frame F
-   when we get an expose event for it.  */
 
-void
-refreshicon (f)
-     struct frame *f;
-{
-  /* Normally, the window manager handles this function.  */
-}
-
-/* Make the x-window of frame F use the gnu icon bitmap.  */
+\f
+/* Icons.  */
 
+#if 0 /* MAC_TODO: no icon support yet.  */
 int
-x_bitmap_icon (f, file)
+x_bitmap_icon (f, icon)
      struct frame *f;
-     Lisp_Object file;
+     Lisp_Object icon;
 {
-  int bitmap_id;
+  HANDLE hicon;
 
-  if (FRAME_X_WINDOW (f) == 0)
+  if (FRAME_W32_WINDOW (f) == 0)
     return 1;
 
-  /* Free up our existing icon bitmap if any.  */
-  if (f->output_data.x->icon_bitmap > 0)
-    x_destroy_bitmap (f, f->output_data.x->icon_bitmap);
-  f->output_data.x->icon_bitmap = 0;
-
-  if (STRINGP (file))
-    bitmap_id = x_create_bitmap_from_file (f, file);
-  else
-    {
-      /* Create the GNU bitmap if necessary.  */
-      if (FRAME_X_DISPLAY_INFO (f)->icon_bitmap_id < 0)
-       FRAME_X_DISPLAY_INFO (f)->icon_bitmap_id
-         = x_create_bitmap_from_data (f, gnu_bits,
-                                      gnu_width, gnu_height);
-
-      /* The first time we create the GNU bitmap,
-        this increments the ref-count one extra time.
-        As a result, the GNU bitmap is never freed.
-        That way, we don't have to worry about allocating it again.  */
-      x_reference_bitmap (f, FRAME_X_DISPLAY_INFO (f)->icon_bitmap_id);
+  if (NILP (icon))
+    hicon = LoadIcon (hinst, EMACS_CLASS);
+  else if (STRINGP (icon))
+    hicon = LoadImage (NULL, (LPCTSTR) XSTRING (icon)->data, IMAGE_ICON, 0, 0,
+                      LR_DEFAULTSIZE | LR_LOADFROMFILE);
+  else if (SYMBOLP (icon))
+    {
+      LPCTSTR name;
+
+      if (EQ (icon, intern ("application")))
+       name = (LPCTSTR) IDI_APPLICATION;
+      else if (EQ (icon, intern ("hand")))
+       name = (LPCTSTR) IDI_HAND;
+      else if (EQ (icon, intern ("question")))
+       name = (LPCTSTR) IDI_QUESTION;
+      else if (EQ (icon, intern ("exclamation")))
+       name = (LPCTSTR) IDI_EXCLAMATION;
+      else if (EQ (icon, intern ("asterisk")))
+       name = (LPCTSTR) IDI_ASTERISK;
+      else if (EQ (icon, intern ("winlogo")))
+       name = (LPCTSTR) IDI_WINLOGO;
+      else
+       return 1;
 
-      bitmap_id = FRAME_X_DISPLAY_INFO (f)->icon_bitmap_id;
+      hicon = LoadIcon (NULL, name);
     }
-
-  x_wm_set_icon_pixmap (f, bitmap_id);
-  f->output_data.x->icon_bitmap = bitmap_id;
-
-  return 0;
-}
-
-
-/* Make the x-window of frame F use a rectangle with text.
-   Use ICON_NAME as the text.  */
-
-int
-x_text_icon (f, icon_name)
-     struct frame *f;
-     char *icon_name;
-{
-  if (FRAME_X_WINDOW (f) == 0)
+  else
     return 1;
 
-#ifdef HAVE_X11R4
-  {
-    XTextProperty text;
-    text.value = (unsigned char *) icon_name;
-    text.encoding = XA_STRING;
-    text.format = 8;
-    text.nitems = strlen (icon_name);
-#ifdef USE_X_TOOLKIT
-    XSetWMIconName (FRAME_X_DISPLAY (f), XtWindow (f->output_data.x->widget),
-                   &text);
-#else /* not USE_X_TOOLKIT */
-    XSetWMIconName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), &text);
-#endif /* not USE_X_TOOLKIT */
-  }
-#else /* not HAVE_X11R4 */
-  XSetIconName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), icon_name);
-#endif /* not HAVE_X11R4 */
+  if (hicon == NULL)
+    return 1;
 
-  if (f->output_data.x->icon_bitmap > 0)
-    x_destroy_bitmap (f, f->output_data.x->icon_bitmap);
-  f->output_data.x->icon_bitmap = 0;
-  x_wm_set_icon_pixmap (f, 0);
+  PostMessage (FRAME_W32_WINDOW (f), WM_SETICON, (WPARAM) ICON_BIG,
+               (LPARAM) hicon);
 
   return 0;
 }
+#endif /* MAC_TODO */
 \f
-#define X_ERROR_MESSAGE_SIZE 200
-
-/* If non-nil, this should be a string.
-   It means catch X errors  and store the error message in this string.  */
-
-static Lisp_Object x_error_message_string;
+/************************************************************************
+                         Handling X errors
+ ************************************************************************/
 
-/* An X error handler which stores the error message in
-   x_error_message_string.  This is called from x_error_handler if
-   x_catch_errors is in effect.  */
+/* Display Error Handling functions not used on W32. Listing them here
+   helps diff stay in step when comparing w32term.c with xterm.c.
 
-static void
 x_error_catcher (display, error)
-     Display *display;
-     XErrorEvent *error;
-{
-  XGetErrorText (display, error->error_code,
-                XSTRING (x_error_message_string)->data,
-                X_ERROR_MESSAGE_SIZE);
-}
-
-/* Begin trapping X errors for display DPY.  Actually we trap X errors
-   for all displays, but DPY should be the display you are actually
-   operating on.
-
-   After calling this function, X protocol errors no longer cause
-   Emacs to exit; instead, they are recorded in the string
-   stored in x_error_message_string.
-
-   Calling x_check_errors signals an Emacs error if an X error has
-   occurred since the last call to x_catch_errors or x_check_errors.
-
-   Calling x_uncatch_errors resumes the normal error handling.  */
-
-void x_check_errors ();
-static Lisp_Object x_catch_errors_unwind ();
-
-int
 x_catch_errors (dpy)
-     Display *dpy;
-{
-  int count = specpdl_ptr - specpdl;
-
-  /* Make sure any errors from previous requests have been dealt with.  */
-  XSync (dpy, False);
-
-  record_unwind_protect (x_catch_errors_unwind, x_error_message_string);
-
-  x_error_message_string = make_uninit_string (X_ERROR_MESSAGE_SIZE);
-  XSTRING (x_error_message_string)->data[0] = 0;
-
-  return count;
-}
-
-/* Unbind the binding that we made to check for X errors.  */
-
-static Lisp_Object
 x_catch_errors_unwind (old_val)
-     Lisp_Object old_val;
-{
-  x_error_message_string = old_val;
-  return Qnil;
-}
-
-/* If any X protocol errors have arrived since the last call to
-   x_catch_errors or x_check_errors, signal an Emacs error using
-   sprintf (a buffer, FORMAT, the x error message text) as the text.  */
-
-void
 x_check_errors (dpy, format)
-     Display *dpy;
-     char *format;
-{
-  /* Make sure to catch any errors incurred so far.  */
-  XSync (dpy, False);
-
-  if (XSTRING (x_error_message_string)->data[0])
-    error (format, XSTRING (x_error_message_string)->data);
-}
-
-/* Nonzero if we had any X protocol errors
-   since we did x_catch_errors on DPY.  */
-
-int
 x_had_errors_p (dpy)
-     Display *dpy;
-{
-  /* Make sure to catch any errors incurred so far.  */
-  XSync (dpy, False);
-
-  return XSTRING (x_error_message_string)->data[0] != 0;
-}
-
-/* Forget about any errors we have had, since we did x_catch_errors on DPY.  */
-
-void
 x_clear_errors (dpy)
-     Display *dpy;
-{
-  XSTRING (x_error_message_string)->data[0] = 0;
-}
-
-/* Stop catching X protocol errors and let them make Emacs die.
-   DPY should be the display that was passed to x_catch_errors.
-   COUNT should be the value that was returned by
-   the corresponding call to x_catch_errors.  */
-
-void
 x_uncatch_errors (dpy, count)
-     Display *dpy;
-     int count;
-{
-  unbind_to (count, Qnil);
-}
-
-#if 0
-static unsigned int x_wire_count;
 x_trace_wire ()
-{
-  fprintf (stderr, "Lib call: %d\n", ++x_wire_count);
-}
-#endif /* ! 0 */
-
-\f
-/* Handle SIGPIPE, which can happen when the connection to a server
-   simply goes away.  SIGPIPE is handled by x_connection_signal.
-   Don't need to do anything, because the write which caused the 
-   SIGPIPE will fail, causing Xlib to invoke the X IO error handler,
-   which will do the appropriate cleanup for us.  */
-   
-static SIGTYPE
-x_connection_signal (signalnum)        /* If we don't have an argument, */
-     int signalnum;            /* some compilers complain in signal calls.  */
-{
-#ifdef USG
-  /* USG systems forget handlers when they are used;
-     must reestablish each time */
-  signal (signalnum, x_connection_signal);
-#endif /* USG */
-}
-\f
-/* Handling X errors.  */
-
-/* Handle the loss of connection to display DISPLAY.  */
-
-static SIGTYPE
-x_connection_closed (display, error_message)
-     Display *display;
-     char *error_message;
-{
-  struct x_display_info *dpyinfo = x_display_info_for_display (display);
-  Lisp_Object frame, tail;
-
-  /* Indicate that this display is dead.  */
-
-#if 0 /* Closing the display caused a bus error on OpenWindows.  */
-#ifdef USE_X_TOOLKIT
-  XtCloseDisplay (display);
-#endif
-#endif
-
-  if (dpyinfo)
-    dpyinfo->display = 0;
-
-  /* First delete frames whose mini-buffers are on frames
-     that are on the dead display.  */
-  FOR_EACH_FRAME (tail, frame)
-    {
-      Lisp_Object minibuf_frame;
-      minibuf_frame
-       = WINDOW_FRAME (XWINDOW (FRAME_MINIBUF_WINDOW (XFRAME (frame))));
-      if (FRAME_X_P (XFRAME (frame))
-         && FRAME_X_P (XFRAME (minibuf_frame))
-         && ! EQ (frame, minibuf_frame)
-         && FRAME_X_DISPLAY_INFO (XFRAME (minibuf_frame)) == dpyinfo)
-       Fdelete_frame (frame, Qt);
-    }
-
-  /* Now delete all remaining frames on the dead display.
-     We are now sure none of these is used as the mini-buffer
-     for another frame that we need to delete.  */
-  FOR_EACH_FRAME (tail, frame)
-    if (FRAME_X_P (XFRAME (frame))
-       && FRAME_X_DISPLAY_INFO (XFRAME (frame)) == dpyinfo)
-      {
-       /* Set this to t so that Fdelete_frame won't get confused
-          trying to find a replacement.  */
-       FRAME_KBOARD (XFRAME (frame))->Vdefault_minibuffer_frame = Qt;
-       Fdelete_frame (frame, Qt);
-      }
-
-  if (dpyinfo)
-    x_delete_display (dpyinfo);
-
-  if (x_display_list == 0)
-    {
-      fprintf (stderr, "%s\n", error_message);
-      shut_down_emacs (0, 0, Qnil);
-      exit (70);
-    }
-
-  /* Ordinary stack unwind doesn't deal with these.  */
-#ifdef SIGIO
-  sigunblock (sigmask (SIGIO));
-#endif
-  sigunblock (sigmask (SIGALRM));
-  TOTALLY_UNBLOCK_INPUT;
-
-  clear_waiting_for_input ();
-  error ("%s", error_message);
-}
-
-/* This is the usual handler for X protocol errors.
-   It kills all frames on the display that we got the error for.
-   If that was the only one, it prints an error message and kills Emacs.  */
-
-static void
+x_connection_signal (signalnum)
+x_connection_closed (dpy, error_message)
 x_error_quitter (display, error)
-     Display *display;
-     XErrorEvent *error;
-{
-  char buf[256], buf1[356];
-
-  /* Note that there is no real way portable across R3/R4 to get the
-     original error handler.  */
-
-  XGetErrorText (display, error->error_code, buf, sizeof (buf));
-  sprintf (buf1, "X protocol error: %s on protocol request %d",
-          buf, error->request_code);
-  x_connection_closed (display, buf1);
-}
-
-/* This is the first-level handler for X protocol errors.
-   It calls x_error_quitter or x_error_catcher.  */
-
-static int
 x_error_handler (display, error)
-     Display *display;
-     XErrorEvent *error;
-{
-  if (! NILP (x_error_message_string))
-    x_error_catcher (display, error);
-  else
-    x_error_quitter (display, error);
-  return 0;
-}
-
-/* This is the handler for X IO errors, always.
-   It kills all frames on the display that we lost touch with.
-   If that was the only one, it prints an error message and kills Emacs.  */
-
-static int
 x_io_error_quitter (display)
-     Display *display;
-{
-  char buf[256];
 
-  sprintf (buf, "Connection lost to X server `%s'", DisplayString (display));
-  x_connection_closed (display, buf);
-  return 0;
-}
-#endif
+ */
+
 \f
 /* Changing the font of the frame.  */
 
@@ -9115,47 +9532,41 @@ x_new_font (f, fontname)
   if (!fontp)
     return Qnil;
 
-  f->output_data.mac->font = (XFontStruct *) (fontp->font);
-  f->output_data.mac->baseline_offset = fontp->baseline_offset;
-  f->output_data.mac->fontset = -1;
-  
+  FRAME_FONT (f) = (XFontStruct *) (fontp->font);
+  FRAME_BASELINE_OFFSET (f) = fontp->baseline_offset;
+  FRAME_FONTSET (f) = -1;
+
   /* Compute the scroll bar width in character columns.  */
   if (f->scroll_bar_pixel_width > 0)
     {
-      int wid = FONT_WIDTH (f->output_data.mac->font);
+      int wid = FONT_WIDTH (FRAME_FONT (f));
       f->scroll_bar_cols = (f->scroll_bar_pixel_width + wid-1) / wid;
     }
   else
     {
-      int wid = FONT_WIDTH (f->output_data.mac->font);
+      int wid = FONT_WIDTH (FRAME_FONT (f));
       f->scroll_bar_cols = (14 + wid - 1) / wid;
     }
 
   /* Now make the frame display the given font.  */
   if (FRAME_MAC_WINDOW (f) != 0)
     {
-      XSetFont (FRAME_MAC_DISPLAY (f), f->output_data.mac->normal_gc,
-               f->output_data.mac->font);
-      XSetFont (FRAME_MAC_DISPLAY (f), f->output_data.mac->reverse_gc,
-               f->output_data.mac->font);
-      XSetFont (FRAME_MAC_DISPLAY (f), f->output_data.mac->cursor_gc,
-               f->output_data.mac->font);
-
       frame_update_line_height (f);
-      x_set_window_size (f, 0, f->width, f->height);
+      if (NILP (tip_frame) || XFRAME (tip_frame) != f)
+        x_set_window_size (f, 0, f->width, f->height);
     }
   else
-    /* If we are setting a new frame's font for the first time, there
-       are no faces yet, so this font's height is the line height.  */
-    f->output_data.mac->line_height = FONT_HEIGHT (f->output_data.mac->font);
+    /* If we are setting a new frame's font for the first time,
+       there are no faces yet, so this font's height is the line height.  */
+    f->output_data.mac->line_height = FONT_HEIGHT (FRAME_FONT (f));
 
   return build_string (fontp->full_name);
 }
-
+\f
 /* Give frame F the fontset named FONTSETNAME as its default font, and
-   return the full name of that fontset.  FONTSETNAME may be a
-   wildcard pattern; in that case, we choose some fontset that fits
-   the pattern.  The return value shows which fontset we chose.  */
+   return the full name of that fontset.  FONTSETNAME may be a wildcard
+   pattern; in that case, we choose some fontset that fits the pattern.
+   The return value shows which fontset we chose.  */
 
 Lisp_Object
 x_new_fontset (f, fontsetname)
@@ -9168,7 +9579,7 @@ x_new_fontset (f, fontsetname)
   if (fontset < 0)
     return Qnil;
 
-  if (f->output_data.mac->fontset == fontset)
+  if (FRAME_FONTSET (f) == fontset)
     /* This fontset is already set in frame F.  There's nothing more
        to do.  */
     return fontset_name (fontset);
@@ -9179,16 +9590,9 @@ x_new_fontset (f, fontsetname)
     /* Can't load ASCII font.  */
     return Qnil;
 
-  /* Since x_new_font doesn't update any fontset information, do it
-     now.  */
-  f->output_data.mac->fontset = fontset;
+  /* Since x_new_font doesn't update any fontset information, do it now.  */
+  FRAME_FONTSET(f) = fontset;
 
-#ifdef HAVE_X_I18N
-  if (FRAME_XIC (f)
-      && (FRAME_XIC_STYLE (f) & (XIMPreeditPosition | XIMStatusArea)))
-    xic_set_xfontset (f, XSTRING (fontset_ascii (fontset))->data);
-#endif
-  
   return build_string (fontsetname);
 }
 
@@ -9277,215 +9681,25 @@ x_compute_fringe_widths (f, redraw)
       redraw_frame (f);
 }
 \f
-#if 0 /* MAC_TODO: inline input methods for Mac */
 /***********************************************************************
-                          X Input Methods
+       TODO: W32 Input Methods
  ***********************************************************************/
+/* Listing missing functions from xterm.c helps diff stay in step.
 
-#ifdef HAVE_X_I18N
-
-#ifdef HAVE_X11R6
-
-/* XIM destroy callback function, which is called whenever the
-   connection to input method XIM dies.  CLIENT_DATA contains a
-   pointer to the x_display_info structure corresponding to XIM.  */
-
-static void
 xim_destroy_callback (xim, client_data, call_data)
-     XIM xim;
-     XPointer client_data;
-     XPointer call_data;
-{
-  struct x_display_info *dpyinfo = (struct x_display_info *) client_data;
-  Lisp_Object frame, tail;
-  
-  BLOCK_INPUT;
-  
-  /* No need to call XDestroyIC.. */
-  FOR_EACH_FRAME (tail, frame)
-    {
-      struct frame *f = XFRAME (frame);
-      if (FRAME_X_DISPLAY_INFO (f) == dpyinfo)
-       {
-         FRAME_XIC (f) = NULL;
-         if (FRAME_XIC_FONTSET (f))
-           {
-             XFreeFontSet (FRAME_X_DISPLAY (f), FRAME_XIC_FONTSET (f));
-             FRAME_XIC_FONTSET (f) = NULL;
-           }
-       }
-    }
-  
-  /* No need to call XCloseIM.  */
-  dpyinfo->xim = NULL;
-  XFree (dpyinfo->xim_styles);
-  UNBLOCK_INPUT;
-}
-
-#endif /* HAVE_X11R6 */
-
-/* Open the connection to the XIM server on display DPYINFO.
-   RESOURCE_NAME is the resource name Emacs uses.  */
-
-static void
 xim_open_dpy (dpyinfo, resource_name)
-     struct x_display_info *dpyinfo;
-     char *resource_name;
-{
-#ifdef USE_XIM
-  XIM xim;
-
-  xim = XOpenIM (dpyinfo->display, dpyinfo->xrdb, resource_name, EMACS_CLASS);
-  dpyinfo->xim = xim;
-
-  if (xim)
-    {
-#ifdef HAVE_X11R6
-      XIMCallback destroy;
-#endif
-      
-      /* Get supported styles and XIM values.  */
-      XGetIMValues (xim, XNQueryInputStyle, &dpyinfo->xim_styles, NULL);
-      
-#ifdef HAVE_X11R6
-      destroy.callback = xim_destroy_callback;
-      destroy.client_data = (XPointer)dpyinfo;
-      /* This isn't prototyped in OSF 5.0.  */
-      XSetIMValues (xim, XNDestroyCallback, &destroy, NULL);
-#endif
-    }
-  
-#else /* not USE_XIM */
-  dpyinfo->xim = NULL;
-#endif /* not USE_XIM */
-}
-
-
-#ifdef HAVE_X11R6_XIM
-
 struct xim_inst_t
-{
-  struct x_display_info *dpyinfo;
-  char *resource_name;
-};
-
-/* XIM instantiate callback function, which is called whenever an XIM
-   server is available.  DISPLAY is teh display of the XIM.
-   CLIENT_DATA contains a pointer to an xim_inst_t structure created
-   when the callback was registered.  */
-
-static void
 xim_instantiate_callback (display, client_data, call_data)
-     Display *display;
-     XPointer client_data;
-     XPointer call_data;
-{
-  struct xim_inst_t *xim_inst = (struct xim_inst_t *) client_data;
-  struct x_display_info *dpyinfo = xim_inst->dpyinfo;
-
-  /* We don't support multiple XIM connections. */
-  if (dpyinfo->xim)
-    return;
-  
-  xim_open_dpy (dpyinfo, xim_inst->resource_name);
-
-  /* Create XIC for the existing frames on the same display, as long
-     as they have no XIC.  */
-  if (dpyinfo->xim && dpyinfo->reference_count > 0)
-    {
-      Lisp_Object tail, frame;
-
-      BLOCK_INPUT;
-      FOR_EACH_FRAME (tail, frame)
-       {
-         struct frame *f = XFRAME (frame);
-         
-         if (FRAME_X_DISPLAY_INFO (f) == xim_inst->dpyinfo)
-           if (FRAME_XIC (f) == NULL)
-             {
-               create_frame_xic (f);
-               if (FRAME_XIC_STYLE (f) & XIMStatusArea)
-                 xic_set_statusarea (f);
-               if (FRAME_XIC_STYLE (f) & XIMPreeditPosition)
-                 {
-                   struct window *w = XWINDOW (f->selected_window);
-                   xic_set_preeditarea (w, w->cursor.x, w->cursor.y);
-                 }
-             }
-       }
-      
-      UNBLOCK_INPUT;
-    }
-}
-
-#endif /* HAVE_X11R6_XIM */
-
-
-/* Open a connection to the XIM server on display DPYINFO.
-   RESOURCE_NAME is the resource name for Emacs.  On X11R5, open the
-   connection only at the first time.  On X11R6, open the connection
-   in the XIM instantiate callback function.  */
-
-static void
 xim_initialize (dpyinfo, resource_name)
-     struct x_display_info *dpyinfo;
-     char *resource_name;
-{
-#ifdef USE_XIM
-#ifdef HAVE_X11R6_XIM
-  struct xim_inst_t *xim_inst;
-  int len;
-  
-  dpyinfo->xim = NULL;
-  xim_inst = (struct xim_inst_t *) xmalloc (sizeof (struct xim_inst_t));
-  xim_inst->dpyinfo = dpyinfo;
-  len = strlen (resource_name);
-  xim_inst->resource_name = (char *) xmalloc (len + 1);
-  bcopy (resource_name, xim_inst->resource_name, len + 1);
-  XRegisterIMInstantiateCallback (dpyinfo->display, dpyinfo->xrdb,
-                                 resource_name, EMACS_CLASS,
-                                 xim_instantiate_callback,
-                                 /* Fixme: This is XPointer in
-                                    XFree86 but (XPointer *) on
-                                    Tru64, at least.  */
-                                 (XPointer) xim_inst);
-#else /* not HAVE_X11R6_XIM */
-  dpyinfo->xim = NULL;
-  xim_open_dpy (dpyinfo, resource_name);
-#endif /* not HAVE_X11R6_XIM */
-  
-#else /* not USE_XIM */
-  dpyinfo->xim = NULL;
-#endif /* not USE_XIM */
-}
-
-
-/* Close the connection to the XIM server on display DPYINFO. */
-
-static void
 xim_close_dpy (dpyinfo)
-     struct x_display_info *dpyinfo;
-{
-#ifdef USE_XIM
-#ifdef HAVE_X11R6_XIM
-  XUnregisterIMInstantiateCallback (dpyinfo->display, dpyinfo->xrdb,
-                                   NULL, EMACS_CLASS,
-                                   xim_instantiate_callback, NULL);
-#endif /* not HAVE_X11R6_XIM */
-  XCloseIM (dpyinfo->xim);
-  dpyinfo->xim = NULL;
-  XFree (dpyinfo->xim_styles);
-#endif /* USE_XIM */
-}
 
-#endif /* not HAVE_X11R6_XIM */
+ */
 
-#endif
 \f
 /* Calculate the absolute position in frame F
    from its current recorded position values and gravity.  */
 
-static void
+void
 x_calc_absolute_position (f)
      struct frame *f;
 {
@@ -9500,8 +9714,23 @@ x_calc_absolute_position (f)
     {
       GrafPtr savePort;
       GetPort (&savePort);
+
+#if TARGET_API_MAC_CARBON
+      SetPort (GetWindowPort (FRAME_MAC_WINDOW (f)));
+#else
       SetPort (FRAME_MAC_WINDOW (f));
+#endif
+
+#if TARGET_API_MAC_CARBON
+      {
+        Rect r;
+    
+        GetWindowPortBounds (FRAME_MAC_WINDOW (f), &r);
+        SetPt(&pt, r.left,  r.top);
+      }
+#else /* not TARGET_API_MAC_CARBON */
       SetPt(&pt, FRAME_MAC_WINDOW (f)->portRect.left,  FRAME_MAC_WINDOW (f)->portRect.top);
+#endif /* not TARGET_API_MAC_CARBON */
       LocalToGlobal (&pt);
       SetPort (savePort);
     }
@@ -9537,6 +9766,8 @@ x_set_offset (f, xoff, yoff, change_gravity)
      register int xoff, yoff;
      int change_gravity;
 {
+  int modified_top, modified_left;
+
   if (change_gravity > 0)
     {
       f->output_data.mac->top_pos = yoff;
@@ -9553,7 +9784,11 @@ x_set_offset (f, xoff, yoff, change_gravity)
   BLOCK_INPUT;
   x_wm_set_size_hint (f, (long) 0, 0);
 
-  MoveWindow (f->output_data.mac->mWP, xoff + 6, yoff + 42, false);
+  modified_left = f->output_data.mac->left_pos;
+  modified_top = f->output_data.mac->top_pos;
+
+  MoveWindow (f->output_data.mac->mWP, modified_left + 6,
+             modified_top + 42, false);
 
   UNBLOCK_INPUT;
 }
@@ -9570,13 +9805,13 @@ x_set_window_size (f, change_gravity, cols, rows)
      int cols, rows;
 {
   int pixelwidth, pixelheight;
-
+  
+  BLOCK_INPUT;
+  
   check_frame_size (f, &rows, &cols);
   f->output_data.mac->vertical_scroll_bar_extra
     = (!FRAME_HAS_VERTICAL_SCROLL_BARS (f)
        ? 0
-       : FRAME_SCROLL_BAR_PIXEL_WIDTH (f) > 0
-       ? FRAME_SCROLL_BAR_PIXEL_WIDTH (f)
        : (FRAME_SCROLL_BAR_COLS (f) * FONT_WIDTH (f->output_data.mac->font)));
 
   x_compute_fringe_widths (f, 0);
@@ -9593,7 +9828,7 @@ x_set_window_size (f, change_gravity, cols, rows)
      but the window manager will get around to dealing with the size
      change request eventually, and we'll hear how it went when the
      ConfigureNotify event gets here.
-
+     
      We could just not bother storing any of this information here,
      and let the ConfigureNotify event set everything up, but that
      might be kind of confusing to the Lisp code, since size changes
@@ -9622,6 +9857,8 @@ x_set_window_size (f, change_gravity, cols, rows)
      Actually checking whether it is outside is a pain in the neck,
      so don't try--just let the highlighting be done afresh with new size.  */
   cancel_mouse_face (f);
+
+  UNBLOCK_INPUT;
 }
 \f
 /* Mouse warping.  */
@@ -9647,8 +9884,6 @@ x_set_mouse_position (f, x, y)
   x_set_mouse_pixel_position (f, pix_x, pix_y);
 }
 
-/* Move the mouse to position pixel PIX_X, PIX_Y relative to frame F.  */
-
 void
 x_set_mouse_pixel_position (f, pix_x, pix_y)
      struct frame *f;
@@ -9662,10 +9897,11 @@ x_set_mouse_pixel_position (f, pix_x, pix_y)
   UNBLOCK_INPUT;
 #endif
 }
+
 \f
 /* focus shifting, raising and lowering.  */
 
-static void
+void
 x_focus_on_frame (f)
      struct frame *f;
 {
@@ -9681,20 +9917,13 @@ x_focus_on_frame (f)
 #endif /* ! 0 */
 }
 
-static void
+void
 x_unfocus_frame (f)
      struct frame *f;
 {
-#if 0
-  /* Look at the remarks in x_focus_on_frame.  */
-  if (FRAME_X_DISPLAY_INFO (f)->x_focus_frame == f)
-    XSetInputFocus (FRAME_X_DISPLAY (f), PointerRoot,
-                   RevertToPointerRoot, CurrentTime);
-#endif /* ! 0 */
 }
 
 /* Raise frame F.  */
-
 void
 x_raise_frame (f)
      struct frame *f;
@@ -9704,7 +9933,6 @@ x_raise_frame (f)
 }
 
 /* Lower frame F.  */
-
 void
 x_lower_frame (f)
      struct frame *f;
@@ -9713,7 +9941,7 @@ x_lower_frame (f)
     SendBehind (FRAME_MAC_WINDOW (f), nil);
 }
 
-void
+static void
 XTframe_raise_lower (f, raise_flag)
      FRAME_PTR f;
      int raise_flag;
@@ -9760,6 +9988,7 @@ x_make_frame_visible (f)
 
   XFlush (FRAME_MAC_DISPLAY (f));
 
+#if 0 /* MAC_TODO */
   /* Synchronize to ensure Emacs knows the frame is visible
      before we do anything else.  We do this loop with input not blocked
      so that incoming events are handled.  */
@@ -9803,6 +10032,7 @@ x_make_frame_visible (f)
        FRAME_SAMPLE_VISIBILITY (f);
       }
   }
+#endif /* MAC_TODO */
 }
 
 /* Change from mapped state to withdrawn state.  */
@@ -9941,8 +10171,9 @@ x_iconify_frame (f)
   XFlush (FRAME_X_DISPLAY (f));
   UNBLOCK_INPUT;
 #endif /* not USE_X_TOOLKIT */
-#endif
+#endif /* MAC_TODO */
 }
+
 \f
 /* Destroy the X window of frame F.  */
 
@@ -9991,7 +10222,6 @@ x_destroy_window (f)
    that the window now has.
    If USER_POSITION is nonzero, we set the USPosition
    flag (this is useful when FLAGS is 0).  */
-
 void
 x_wm_set_size_hint (f, flags, user_position)
      struct frame *f;
@@ -10134,10 +10364,10 @@ x_wm_set_size_hint (f, flags, user_position)
 #else
   XSetNormalHints (FRAME_X_DISPLAY (f), window, &size_hints);
 #endif
-#endif /* MACTODO */
+#endif /* MAC_TODO */
 }
 
-#if 0 /* MACTODO: hide application instead of iconify? */
+#if 0 /* MAC_TODO: hide application instead of iconify? */
 /* Used for IconicState or NormalState */
 
 void
@@ -10208,7 +10438,7 @@ x_wm_set_icon_pixmap (f, pixmap_id)
 #endif /* not USE_X_TOOLKIT */
 }
 
-#endif
+#endif /* MAC_TODO */
 
 void
 x_wm_set_icon_position (f, icon_x, icon_y)
@@ -10227,7 +10457,7 @@ x_wm_set_icon_position (f, icon_x, icon_y)
   f->output_data.x->wm_hints.icon_y = icon_y;
 
   XSetWMHints (FRAME_X_DISPLAY (f), window, &f->output_data.x->wm_hints);
-#endif
+#endif /* MAC_TODO */
 }
 
 \f
@@ -10421,92 +10651,165 @@ x_font_name_to_mac_font_name (char *xf, char *mf)
 static void
 init_font_name_table ()
 {
-  GrafPtr port;
-  SInt16 fontnum, old_fontnum;
-  int num_mac_fonts = CountResources('FOND');
-  int i, j;
-  Handle font_handle, font_handle_2;
-  short id, scriptcode;
-  ResType type;
-  Str32 name;
-  struct FontAssoc *fat;
-  struct AsscEntry *assc_entry;
+#if TARGET_API_MAC_CARBON
+  SInt32 sv;
+  
+  if (Gestalt (gestaltSystemVersion, &sv) == noErr && sv >= 0x1000)
+    {
+      FMFontFamilyIterator ffi;
+      FMFontFamilyInstanceIterator ffii;
+      FMFontFamily ff;
 
-  GetPort (&port);  /* save the current font number used */
-  old_fontnum = port->txFont;
+      /* Create a dummy instance iterator here to avoid creating and
+        destroying it in the loop.  */
+      if (FMCreateFontFamilyInstanceIterator (0, &ffii) != noErr)
+       return;
+      /* Create an iterator to enumerate the font families.  */
+      if (FMCreateFontFamilyIterator (NULL, NULL, kFMDefaultOptions, &ffi)
+         != noErr)
+       {
+         FMDisposeFontFamilyInstanceIterator (&ffii);
+         return;
+       }
 
-  for (i = 1; i <= num_mac_fonts; i++)  /* loop to get all available fonts */
+      while (FMGetNextFontFamily (&ffi, &ff) == noErr)
+       {
+         Str255 name;
+         FMFont font;
+         FMFontStyle style;
+         FMFontSize size;
+         SInt16 sc;
+      
+         if (FMGetFontFamilyName (ff, name) != noErr)
+           break;
+         p2cstr (name);
+      
+         sc = FontToScript (ff);
+         
+         /* Point the instance iterator at the current font family.  */
+         if (FMResetFontFamilyInstanceIterator(ff, &ffii) != noErr)
+           break;
+      
+         while (FMGetNextFontFamilyInstance (&ffii, &font, &style, &size)
+                == noErr)
+           {
+             if (font_name_table_size == 0)
+               {
+                 font_name_table_size = 16;
+                 font_name_table = (char **)
+                   xmalloc (font_name_table_size * sizeof (char *));
+               }
+             else if (font_name_count + 1 >= font_name_table_size)
+               {
+                 font_name_table_size += 16;
+                 font_name_table = (char **)
+                   xrealloc (font_name_table,
+                             font_name_table_size * sizeof (char *));
+               }
+             font_name_table[font_name_count++]
+               = mac_to_x_fontname (name, size, style, sc);
+           }
+       }
+  
+      /* Dispose of the iterators.  */
+      FMDisposeFontFamilyIterator (&ffi);
+      FMDisposeFontFamilyInstanceIterator (&ffii);
+    }
+  else
     {
-      font_handle = GetIndResource ('FOND', i);
-      if (!font_handle)
-        continue;
-        
-      GetResInfo (font_handle, &id, &type, name);
-      GetFNum (name, &fontnum);
-      p2cstr (name);
-      if (fontnum == 0)
-        continue;
+#endif  /* TARGET_API_MAC_CARBON */
+      GrafPtr port;
+      SInt16 fontnum, old_fontnum;
+      int num_mac_fonts = CountResources('FOND');
+      int i, j;
+      Handle font_handle, font_handle_2;
+      short id, scriptcode;
+      ResType type;
+      Str32 name;
+      struct FontAssoc *fat;
+      struct AsscEntry *assc_entry;
       
-      TextFont (fontnum);
-      scriptcode = FontToScript (fontnum);
-      do
-        {
-          HLock (font_handle);
-                    
-          if (GetResourceSizeOnDisk (font_handle) >= sizeof (struct FamRec))
-            {
-              fat = (struct FontAssoc *) (*font_handle
-                                         + sizeof (struct FamRec));
-              assc_entry = (struct AsscEntry *) (*font_handle
-                                                + sizeof (struct FamRec)
-                                                + sizeof (struct FontAssoc));
-              
-              for (j = 0; j <= fat->numAssoc; j++, assc_entry++)
-                {
-                  if (font_name_table_size == 0)
-                    {
-                      font_name_table_size = 16;
-                      font_name_table = (char **)
-                       xmalloc (font_name_table_size * sizeof (char *));
-                    }
-                  else if (font_name_count >= font_name_table_size ||
-                          /* fonts in Japanese scripts require two
-                             entries.  */
-                          scriptcode == smJapanese &&
-                          font_name_count + 1 >= font_name_table_size)
-                    {
-                      font_name_table_size += 16;
-                      font_name_table = (char **)
-                       xrealloc (font_name_table,
-                                 font_name_table_size * sizeof (char *));
-                    }
-                  font_name_table[font_name_count++]
-                   = mac_to_x_fontname (name,
-                                        assc_entry->fontSize,
-                                        assc_entry->fontStyle,
-                                        scriptcode);
-                 /* Both jisx0208.1983-sjis and jisx0201.1976-0 parts
-                    are contained in Apple Japanese (SJIS) font.  */
-                 if (smJapanese == scriptcode)
+      GetPort (&port);  /* save the current font number used */
+#if TARGET_API_MAC_CARBON
+      old_fontnum = GetPortTextFont (port);
+#else
+      old_fontnum = port->txFont;
+#endif
+
+      for (i = 1; i <= num_mac_fonts; i++)  /* get all available fonts */
+       {
+         font_handle = GetIndResource ('FOND', i);
+         if (!font_handle)
+           continue;
+         
+         GetResInfo (font_handle, &id, &type, name);
+         GetFNum (name, &fontnum);
+         p2cstr (name);
+         if (fontnum == 0)
+           continue;
+         
+         TextFont (fontnum);
+         scriptcode = FontToScript (fontnum);
+         do
+           {
+             HLock (font_handle);
+             
+             if (GetResourceSizeOnDisk (font_handle)
+                 >= sizeof (struct FamRec))
+               {
+                 fat = (struct FontAssoc *) (*font_handle
+                                             + sizeof (struct FamRec));
+                 assc_entry
+                   = (struct AsscEntry *) (*font_handle
+                                           + sizeof (struct FamRec)
+                                           + sizeof (struct FontAssoc));
+                 
+                 for (j = 0; j <= fat->numAssoc; j++, assc_entry++)
                    {
+                     if (font_name_table_size == 0)
+                       {
+                         font_name_table_size = 16;
+                         font_name_table = (char **)
+                           xmalloc (font_name_table_size * sizeof (char *));
+                       }
+                     else if (font_name_count >= font_name_table_size)
+                       {
+                         font_name_table_size += 16;
+                         font_name_table = (char **)
+                           xrealloc (font_name_table,
+                                     font_name_table_size * sizeof (char *));
+                       }
                      font_name_table[font_name_count++]
-                       = mac_to_x_fontname (name,
+                       = mac_to_x_fontname (name,
                                             assc_entry->fontSize,
                                             assc_entry->fontStyle,
-                                            -smJapanese);
+                                            scriptcode);
+                     /* Both jisx0208.1983-sjis and
+                        jisx0201.1976-sjis parts are contained in
+                        Apple Japanese (SJIS) font.  */
+                     if (smJapanese == scriptcode)
+                       {
+                         font_name_table[font_name_count++]
+                           = mac_to_x_fontname (name,
+                                                assc_entry->fontSize,
+                                                assc_entry->fontStyle,
+                                                smRoman);
+                       }
                    }
-                }
-            }
-
-          HUnlock (font_handle);
-          font_handle_2 = GetNextFOND (font_handle);
-          ReleaseResource (font_handle);
-          font_handle = font_handle_2;
-        }
-      while (ResError () == noErr && font_handle);
+               }
+             
+             HUnlock (font_handle);
+             font_handle_2 = GetNextFOND (font_handle);
+             ReleaseResource (font_handle);
+             font_handle = font_handle_2;
+           }
+         while (ResError () == noErr && font_handle);
+       }
+  
+      TextFont (old_fontnum);
+#if TARGET_API_MAC_CARBON
     }
-
-  TextFont (old_fontnum);
+#endif  /* TARGET_API_MAC_CARBON */
 }
 
 
@@ -10559,8 +10862,8 @@ x_list_fonts (struct frame *f,
 
 #if GLYPH_DEBUG
 
-/* Check that FONT is valid on frame F.  It is if it can be found in
-   F's font table.  */
+/* Check that FONT is valid on frame F.  It is if it can be found in F's
+   font table.  */
 
 static void
 x_check_font (f, font)
@@ -10582,7 +10885,6 @@ x_check_font (f, font)
 
 #endif /* GLYPH_DEBUG != 0 */
 
-
 /* Set *W to the minimum width, *H to the minimum font height of FONT.
    Note: There are (broken) X fonts out there with invalid XFontStruct
    min_bounds contents.  For example, handa@etl.go.jp reports that
@@ -10594,14 +10896,12 @@ x_font_min_bounds (font, w, h)
      MacFontStruct *font;
      int *w, *h;
 {
+  /*
+   * TODO: Windows does not appear to offer min bound, only
+   * average and maximum width, and maximum height.
+   */
   *h = FONT_HEIGHT (font);
-  *w = font->min_bounds.width;
-
-  /* Try to handle the case where FONT->min_bounds has invalid
-     contents.  Since the only font known to have invalid min_bounds
-     is fixed-width, use max_bounds if min_bounds seems to be invalid.  */
-  if (*w <= 0)
-    *w = font->max_bounds.width;
+  *w = FONT_WIDTH (font);
 }
 
 
@@ -10611,7 +10911,7 @@ x_font_min_bounds (font, w, h)
    the values computed.  Value is non-zero if smallest_font_height or
    smallest_char_width become smaller than they were before.  */
 
-static int
+int
 x_compute_min_glyph_bounds (f)
      struct frame *f;
 {
@@ -10682,12 +10982,11 @@ is_fully_specified_xlfd (char *p)
 const int kDefaultFontSize = 9;
 
 
-/* MacLoadQueryFont creates and returns an internal representation for
-   a font in a MacFontStruct struct (similar in function to
-   XLoadQueryFont in X).  There is really no concept corresponding to
-   "loading" a font on the Mac.  But we check its existence and find
-   the font number and all other information for it and store them in
-   the returned MacFontStruct.  */
+/* XLoadQueryFont creates and returns an internal representation for a
+   font in a MacFontStruct struct.  There is really no concept
+   corresponding to "loading" a font on the Mac.  But we check its
+   existence and find the font number and all other information for it
+   and store them in the returned MacFontStruct.  */
 
 static MacFontStruct *
 XLoadQueryFont (Display *dpy, char *fontname)
@@ -10719,9 +11018,15 @@ XLoadQueryFont (Display *dpy, char *fontname)
     }
 
   GetPort (&port);  /* save the current font number used */
+#if TARGET_API_MAC_CARBON
+  old_fontnum = GetPortTextFont (port);
+  old_fontsize = GetPortTextSize (port);
+  old_fontface = GetPortTextFace (port);
+#else
   old_fontnum = port->txFont;
   old_fontsize = port->txSize;
   old_fontface = port->txFace;
+#endif
 
   if (sscanf (name, "-%*[^-]-%*[^-]-%*[^-]-%*c-%*[^-]--%d-%*[^-]-%*[^-]-%*[^-]-%*c-%*[^-]-%*s", &size) != 1)
     size = kDefaultFontSize;
@@ -10752,7 +11057,7 @@ XLoadQueryFont (Display *dpy, char *fontname)
 
   /* Apple Japanese (SJIS) font is listed as both
      "*-jisx0208.1983-sjis" (Japanese script) and "*-jisx0201.1976-0"
-     (Roman script) in init_font_name_table().  The latter should be
+     (Roman script) in init_font_name_table ().  The latter should be
      treated as a one-byte font.  */
   {
     char cs[32];
@@ -10760,7 +11065,7 @@ XLoadQueryFont (Display *dpy, char *fontname)
     if (sscanf (name, 
                "-%*[^-]-%*[^-]-%*[^-]-%*c-%*[^-]--%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*c-%*[^-]-%31s",
                cs) == 1
-       && 0 == strcmp (cs, "jisx0201.1976-0"))  
+       && 0 == strcmp (cs, "mac-roman"))  
       font->mac_scriptcode = smRoman;
   }
   
@@ -11109,61 +11414,28 @@ same_x_server (name1, name2)
   /* Treat this host's domainless name like an empty host name.  */
   if (! strncmp (name1, system_name, length_until_period)
       && name1[length_until_period] == ':')
-    name1 += length_until_period;
-  if (! strncmp (name2, system_name, length_until_period)
-      && name2[length_until_period] == ':')
-    name2 += length_until_period;
-
-  for (; *name1 != '\0' && *name1 == *name2; name1++, name2++)
-    {
-      if (*name1 == ':')
-       seen_colon++;
-      if (seen_colon && *name1 == '.')
-       return 1;
-    }
-  return (seen_colon
-         && (*name1 == '.' || *name1 == '\0')
-         && (*name2 == '.' || *name2 == '\0'));
-}
-#endif
-
-struct mac_display_info *
-x_term_init (display_name, xrm_option, resource_name)
-     Lisp_Object display_name;
-     char *xrm_option;
-     char *resource_name;
-{
-  if (!x_initialized)
-    {
-      x_initialize ();
-      x_initialized = 1;
-    }
-
-  return &one_mac_display_info;
-}
-\f
-/* Set up use of X before we make the first connection.  */
-
-static struct redisplay_interface x_redisplay_interface =
-{
-  x_produce_glyphs,
-  x_write_glyphs,
-  x_insert_glyphs,
-  x_clear_end_of_line,
-  x_scroll_run,
-  x_after_update_window_line,
-  x_update_window_begin,
-  x_update_window_end,
-  XTcursor_to,
-  x_flush,
-  x_clear_mouse_face,
-  x_get_glyph_overhangs,
-  x_fix_overlapping_area
-};
+    name1 += length_until_period;
+  if (! strncmp (name2, system_name, length_until_period)
+      && name2[length_until_period] == ':')
+    name2 += length_until_period;
+
+  for (; *name1 != '\0' && *name1 == *name2; name1++, name2++)
+    {
+      if (*name1 == ':')
+       seen_colon++;
+      if (seen_colon && *name1 == '.')
+       return 1;
+    }
+  return (seen_colon
+         && (*name1 == '.' || *name1 == '\0')
+         && (*name2 == '.' || *name2 == '\0'));
+}
+#endif
 
 
 /* The Mac Event loop code */
 
+#ifndef MAC_OSX
 #include <Events.h>
 #include <Quickdraw.h>
 #include <Balloons.h>
@@ -11177,7 +11449,6 @@ static struct redisplay_interface x_redisplay_interface =
 #include <TextUtils.h>
 #include <Dialogs.h>
 #include <Script.h>
-#include <Scrap.h>
 #include <Types.h>
 #include <TextEncodingConverter.h>
 #include <Resources.h>
@@ -11185,6 +11456,7 @@ static struct redisplay_interface x_redisplay_interface =
 #if __MWERKS__
 #include <unix.h>
 #endif
+#endif /* ! MAC_OSX */
 
 #define M_APPLE 128
 #define I_ABOUT 1
@@ -11240,8 +11512,10 @@ Point saved_menu_event_location;
 
 /* Apple Events */
 static void init_required_apple_events(void);
-static pascal OSErr do_ae_open_application(const AppleEvent *, AppleEvent *, long);
-static pascal OSErr do_ae_print_documents(const AppleEvent *, AppleEvent *, long);
+static pascal OSErr
+do_ae_open_application(const AppleEvent *, AppleEvent *, long);
+static pascal OSErr
+do_ae_print_documents(const AppleEvent *, AppleEvent *, long);
 static pascal OSErr do_ae_open_documents(AppleEvent *, AppleEvent *, long);
 static pascal OSErr do_ae_quit_application(AppleEvent *, AppleEvent *, long);
 
@@ -11276,6 +11550,7 @@ do_get_menus (void)
 static void
 do_init_managers (void)
 {
+#if !TARGET_API_MAC_CARBON
   InitGraf (&qd.thePort);
   InitFonts ();
   FlushEvents (everyEvent, 0);
@@ -11283,8 +11558,10 @@ do_init_managers (void)
   InitMenus ();
   TEInit ();
   InitDialogs (NULL);
-  InitCursor ();       
+#endif /* !TARGET_API_MAC_CARBON */
+  InitCursor ();
        
+#if !TARGET_API_MAC_CARBON
   /* set up some extra stack space for use by emacs */
   SetApplLimit ((Ptr) ((long) GetApplLimit () - EXTRA_STACK_ALLOC));
 
@@ -11292,9 +11569,9 @@ do_init_managers (void)
      complicated scripts */
   MaxApplZone ();
   MoreMasters ();
+#endif /* !TARGET_API_MAC_CARBON */
 }
 
-
 static void
 do_check_ram_size (void)
 {
@@ -11310,7 +11587,6 @@ do_check_ram_size (void)
     }
 }
 
-
 static void
 do_window_update (WindowPtr win)
 {
@@ -11345,44 +11621,78 @@ do_window_update (WindowPtr win)
     }
 }
 
+static int
+is_emacs_window (WindowPtr win)
+{
+  Lisp_Object tail, frame;
+
+  if (!win)
+    return 0;
+
+  FOR_EACH_FRAME (tail, frame)
+    if (FRAME_MAC_P (XFRAME (frame)))
+      if (FRAME_MAC_WINDOW (XFRAME (frame)) == win)
+       return 1;
+
+  return 0;
+}
+
 static void
 do_window_activate (WindowPtr win)
 {
-  mac_output *mwp = (mac_output *) GetWRefCon (win);
-  struct frame *f = mwp->mFP;
+  mac_output *mwp;
+  struct frame *f;
 
-  if (f)
+  if (is_emacs_window (win))
     {
-      x_new_focus_frame (FRAME_MAC_DISPLAY_INFO (f), f);
-      activate_scroll_bars (f);
+      mwp = (mac_output *) GetWRefCon (win);
+      f = mwp->mFP;
+      
+      if (f)
+       {
+         x_new_focus_frame (FRAME_MAC_DISPLAY_INFO (f), f);
+         activate_scroll_bars (f);
+       }
     }
 }
 
 static void
 do_window_deactivate (WindowPtr win)
 {
-  mac_output *mwp = (mac_output *) GetWRefCon (win);
-  struct frame *f = mwp->mFP;
+  mac_output *mwp;
+  struct frame *f;
 
-  if (f == FRAME_MAC_DISPLAY_INFO (f)->x_focus_frame)
+  if (is_emacs_window (win))
     {
-      x_new_focus_frame (FRAME_MAC_DISPLAY_INFO (f), 0);
-      deactivate_scroll_bars (f);
+      mwp = (mac_output *) GetWRefCon (win);
+      f = mwp->mFP;
+      
+      if (f == FRAME_MAC_DISPLAY_INFO (f)->x_focus_frame)
+       {
+         x_new_focus_frame (FRAME_MAC_DISPLAY_INFO (f), 0);
+         deactivate_scroll_bars (f);
+       }
     }
 }
 
 static void
 do_app_resume ()
 {
-  mac_output *mwp = (mac_output *) GetWRefCon (FrontWindow ());
-  struct frame *f = mwp->mFP;
-
-  SetCursor (&qd.arrow);
+  WindowPtr wp;
+  mac_output *mwp;
+  struct frame *f;
 
-  if (f)
+  wp = FrontWindow();
+  if (is_emacs_window (wp))
     {
-      x_new_focus_frame (FRAME_MAC_DISPLAY_INFO (f), f);
-      activate_scroll_bars (f);
+      mwp = (mac_output *) GetWRefCon (wp);
+      f = mwp->mFP;
+
+      if (f)
+       {
+         x_new_focus_frame (FRAME_MAC_DISPLAY_INFO (f), f);
+         activate_scroll_bars (f);
+       }
     }
 
   app_is_suspended = false;
@@ -11392,13 +11702,21 @@ do_app_resume ()
 static void
 do_app_suspend ()
 {
-  mac_output *mwp = (mac_output *) GetWRefCon (FrontWindow ());
-  struct frame *f = mwp->mFP;
+  WindowPtr wp;
+  mac_output *mwp;
+  struct frame *f;
 
-  if (f == FRAME_MAC_DISPLAY_INFO (f)->x_focus_frame)
+  wp = FrontWindow();
+  if (is_emacs_window (wp))
     {
-      x_new_focus_frame (FRAME_MAC_DISPLAY_INFO (f), 0);
-      deactivate_scroll_bars (f);
+      mwp = (mac_output *) GetWRefCon (wp);
+      f = mwp->mFP;
+
+      if (f == FRAME_MAC_DISPLAY_INFO (f)->x_focus_frame)
+       {
+         x_new_focus_frame (FRAME_MAC_DISPLAY_INFO (f), 0);
+         deactivate_scroll_bars (f);
+       }
     }
 
   app_is_suspended = true;
@@ -11412,7 +11730,12 @@ do_mouse_moved (Point mouse_pos)
   WindowPtr wp = FrontWindow ();
   struct frame *f = ((mac_output *) GetWRefCon (wp))->mFP;            
 
-  SetPort (wp);
+#if TARGET_API_MAC_CARBON
+      SetPort (GetWindowPort (wp));
+#else
+      SetPort (wp);
+#endif
+
   GlobalToLocal (&mouse_pos);
 
   note_mouse_movement (f, &mouse_pos);
@@ -11431,7 +11754,7 @@ do_os_event (EventRecord *erp)
        do_app_suspend ();
       break;
                                
-    case mouseMovedMessage:    /* never reached */
+    case mouseMovedMessage:
       do_mouse_moved (erp->where);
       break;
     }
@@ -11462,6 +11785,7 @@ do_events (EventRecord *erp)
 static void
 do_apple_menu (SInt16 menu_item)
 {
+#if !TARGET_API_MAC_CARBON
   Str255 item_name;
   SInt16 da_driver_refnum;
        
@@ -11472,6 +11796,7 @@ do_apple_menu (SInt16 menu_item)
       GetMenuItemText (GetMenuHandle (M_APPLE), menu_item, item_name);
       da_driver_refnum = OpenDeskAcc (item_name);
     }
+#endif /* !TARGET_API_MAC_CARBON */
 }
 
 void
@@ -11553,16 +11878,50 @@ do_zoom_window (WindowPtr w, int zoom_in_or_out)
   struct frame *f = mwp->mFP;
    
   GetPort (&save_port);
+
+#if TARGET_API_MAC_CARBON
+  SetPort (GetWindowPort (w));
+#else
   SetPort (w);
-  EraseRect (&(w->portRect));  /* erase to avoid flicker */
+#endif
+
+  /* Clear window to avoid flicker.  */
+#if TARGET_API_MAC_CARBON
+  {
+    Rect r;
+    BitMap bm;
+    
+    GetWindowPortBounds (w, &r);
+    EraseRect (&r);
+
+    if (zoom_in_or_out == inZoomOut)
+      {
+        /* calculate height of window's title bar (hard card it for now).  */
+        w_title_height = 20 + GetMBarHeight ();
+
+        /* get maximum height of window into zoom_rect.bottom -
+          zoom_rect.top */
+        GetQDGlobalsScreenBits (&bm);
+        zoom_rect = bm.bounds;
+        zoom_rect.top += w_title_height;
+        InsetRect (&zoom_rect, 8, 4);  /* not too tight */
+    
+        zoom_rect.right = zoom_rect.left
+         + CHAR_TO_PIXEL_WIDTH (f, DEFAULT_NUM_COLS);
+
+        SetWindowStandardState (w, &zoom_rect);
+      }
+  }
+#else /* not TARGET_API_MAC_CARBON */
+  EraseRect (&(w->portRect));
   if (zoom_in_or_out == inZoomOut)
     {
-      SetPt(&top_left, w->portRect.left, w->portRect.top);
+      SetPt (&top_left, w->portRect.left, w->portRect.top);
       LocalToGlobal (&top_left);
 
       /* calculate height of window's title bar */
       w_title_height = top_left.v - 1
-       - (**((WindowPeek) w)->strucRgn).rgnBBox.top + GetMBarHeight();
+       - (**((WindowPeek) w)->strucRgn).rgnBBox.top + GetMBarHeight ();
 
       /* get maximum height of window into zoom_rect.bottom - zoom_rect.top */
       zoom_rect = qd.screenBits.bounds;
@@ -11572,13 +11931,19 @@ do_zoom_window (WindowPtr w, int zoom_in_or_out)
       zoom_rect.right = zoom_rect.left
        + CHAR_TO_PIXEL_WIDTH (f, DEFAULT_NUM_COLS);
 
-      (**((WStateDataHandle) ((WindowPeek) w)->dataHandle)).stdState = zoom_rect;
+      (**((WStateDataHandle) ((WindowPeek) w)->dataHandle)).stdState
+       = zoom_rect;
     }
+#endif /* not TARGET_API_MAC_CARBON */
 
-  ZoomWindow (w, zoom_in_or_out, w == FrontWindow());
+  ZoomWindow (w, zoom_in_or_out, w == FrontWindow ());
 
   /* retrieve window size and update application values */
+#if TARGET_API_MAC_CARBON
+  GetWindowPortBounds (w, &port_rect);
+#else
   port_rect = w->portRect;
+#endif
   rows = PIXEL_TO_CHAR_HEIGHT (f, port_rect.bottom - port_rect.top);
   columns = PIXEL_TO_CHAR_WIDTH (f, port_rect.right - port_rect.left);
   x_set_window_size (mwp->mFP, 0, columns, rows);
@@ -11602,27 +11967,59 @@ init_required_apple_events ()
   if (!(result & (1 << gestaltAppleEventsPresent)))
     abort ();
   
+#if TARGET_API_MAC_CARBON
   err = AEInstallEventHandler(kCoreEventClass, kAEOpenApplication,
-                              NewAEEventHandlerProc ((AEEventHandlerProcPtr) do_ae_open_application),
+                             NewAEEventHandlerUPP
+                             ((AEEventHandlerProcPtr) do_ae_open_application),
                               0L, false);
+#else
+  err = AEInstallEventHandler(kCoreEventClass, kAEOpenApplication,
+                             NewAEEventHandlerProc
+                             ((AEEventHandlerProcPtr) do_ae_open_application),
+                              0L, false);
+#endif
   if (err != noErr)
     abort ();
-    
+
+#if TARGET_API_MAC_CARBON
+  err = AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments,
+                              NewAEEventHandlerUPP
+                             ((AEEventHandlerProcPtr) do_ae_open_documents),
+                              0L, false);
+#else
   err = AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments,
-                              NewAEEventHandlerProc ((AEEventHandlerProcPtr) do_ae_open_documents),
+                              NewAEEventHandlerProc
+                             ((AEEventHandlerProcPtr) do_ae_open_documents),
                               0L, false);
+#endif
   if (err != noErr)
     abort ();
 
+#if TARGET_API_MAC_CARBON
+  err = AEInstallEventHandler(kCoreEventClass, kAEPrintDocuments,
+                              NewAEEventHandlerUPP
+                             ((AEEventHandlerProcPtr) do_ae_print_documents),
+                              0L, false);
+#else
   err = AEInstallEventHandler(kCoreEventClass, kAEPrintDocuments,
-                              NewAEEventHandlerProc ((AEEventHandlerProcPtr) do_ae_print_documents),
+                              NewAEEventHandlerProc
+                             ((AEEventHandlerProcPtr) do_ae_print_documents),
                               0L, false);
+#endif
   if (err != noErr)
     abort ();
 
+#if TARGET_API_MAC_CARBON
+  err = AEInstallEventHandler(kCoreEventClass, kAEQuitApplication,
+                              NewAEEventHandlerUPP
+                             ((AEEventHandlerProcPtr) do_ae_quit_application),
+                              0L, false);
+#else
   err = AEInstallEventHandler(kCoreEventClass, kAEQuitApplication,
-                              NewAEEventHandlerProc ((AEEventHandlerProcPtr) do_ae_quit_application),
+                              NewAEEventHandlerProc
+                             ((AEEventHandlerProcPtr) do_ae_quit_application),
                               0L, false);
+#endif
   if (err != noErr)
     abort ();
 }
@@ -11761,6 +12158,7 @@ profiler_exit_proc ()
    hints and prompts in the minibuffer after the user stops typing for
    a wait, etc.  */
 
+#if !TARGET_API_MAC_CARBON
 #undef main
 int 
 main (void)
@@ -11813,7 +12211,7 @@ main (void)
   /* Never reached - real exit in Fkill_emacs */
   return 0;
 }
-
+#endif
 
 /* Table for translating Mac keycode to X keysym values.  Contributed
    by Sudhir Shenoy.  */
@@ -11824,25 +12222,25 @@ static unsigned char keycode_to_xkeysym_table[] = {
   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 /* 0x40 */
-  0,                   '\xae' /* kp. */,       0,                      '\xaa' /* kp* */, 
-  0,                   '\xab' /* kp+ */,       0,                      '\x7f' /* kp_clr */,
-  0,                   0,                      0,                      '\xaf' /* kp/ */,
-  '\x8d' /* kp_ent */, 0,                      '\xad' /* kp- */,       0,
+  0, '\xae' /* kp. */, 0, '\xaa' /* kp* */, 
+  0, '\xab' /* kp+ */, 0, '\x7f' /* kp_clr */,
+  0, 0, 0, '\xaf' /* kp/ */,
+  '\x8d' /* kp_ent */, 0, '\xad' /* kp- */, 0,
 /* 0x50 */
-  0,                   '\xbd' /* kp= */,       '\xb0' /* kp0 */,       '\xb1' /* kp1 */,
-  '\xb2' /* kp2 */,    '\xb3' /* kp3 */,       '\xb4' /* kp4 */,       '\xb5' /* kp5 */,
-  '\xb6' /* kp6 */,    '\xb7' /* kp7 */,       0,                      '\xb8' /* kp8 */,
-  '\xb9' /* kp9 */,    0,                      0,                      0,
+  0, '\xbd' /* kp= */, '\xb0' /* kp0 */, '\xb1' /* kp1 */,
+  '\xb2' /* kp2 */, '\xb3' /* kp3 */, '\xb4' /* kp4 */, '\xb5' /* kp5 */,
+  '\xb6' /* kp6 */, '\xb7' /* kp7 */, 0, '\xb8' /* kp8 */,
+  '\xb9' /* kp9 */, 0, 0, 0,
 /* 0x60 */
-  '\xc2' /* F5 */,     '\xc3' /* F6 */,        '\xc4' /* F7 */,        '\xc0' /* F3 */,
-  '\xc5' /* F8 */,     '\xc6' /* F9 */,        0,                      '\xc8' /* F11 */, 
-  0,                   '\xca' /* F13 */,       0,                      '\xcb' /* F14 */, 
-  0,                   '\xc7' /* F10 */,       0,                      '\xc9' /* F12 */,       
+  '\xc2' /* F5 */, '\xc3' /* F6 */, '\xc4' /* F7 */, '\xc0' /* F3 */,
+  '\xc5' /* F8 */, '\xc6' /* F9 */, 0, '\xc8' /* F11 */, 
+  0, '\xca' /* F13 */, 0, '\xcb' /* F14 */, 
+  0, '\xc7' /* F10 */, 0, '\xc9' /* F12 */,   
 /* 0x70 */
-  0,                   '\xcc' /* F15 */,       '\x9e' /* ins */,       '\x95' /* home */,
-  '\x9a' /* pgup */,   '\x9f' /* del */,       '\xc1' /* F4 */,        '\x9c' /* end */,
-  '\xbf' /* F2 */,     '\x9b' /* pgdown */,    '\xbe' /* F1 */,        '\x51' /* left */,
-  '\x53' /* right */,  '\x54' /* down */,      '\x52' /* up */,        0
+  0, '\xcc' /* F15 */, '\x9e' /* ins */, '\x95' /* home */,
+  '\x9a' /* pgup */, '\x9f' /* del */, '\xc1' /* F4 */, '\x9c' /* end */,
+  '\xbf' /* F2 */, '\x9b' /* pgdown */, '\xbe' /* F1 */, '\x51' /* left */,
+  '\x53' /* right */, '\x54' /* down */, '\x52' /* up */, 0
 };
 
 static int
@@ -11862,11 +12260,13 @@ XTread_socket (int sd, struct input_event *bufp, int numchars, int expected)
   int the_modifiers;
   EventMask event_mask;
 
+#if 0
   if (interrupt_input_blocked)
     {
       interrupt_input_pending = 1;
       return -1;
     }
+#endif
 
   interrupt_input_pending = 0;
   BLOCK_INPUT;
@@ -11917,7 +12317,12 @@ XTread_socket (int sd, struct input_event *bufp, int numchars, int expected)
              Point mouse_loc = er.where;
              
              /* Convert to local coordinates of new window.  */
-             SetPort (window_ptr);
+#if TARGET_API_MAC_CARBON
+              SetPort (GetWindowPort (window_ptr));
+#else
+              SetPort (window_ptr);
+#endif
+
              GlobalToLocal (&mouse_loc);
                  
              bufp->code = 0;  /* only one mouse button */
@@ -11961,24 +12366,37 @@ XTread_socket (int sd, struct input_event *bufp, int numchars, int expected)
                SelectWindow (window_ptr);
              else
                {
-                 int control_part_code;
+                 SInt16 control_part_code;
                  ControlHandle ch;
                  struct mac_output *mwp = (mac_output *)
                    GetWRefCon (window_ptr);
                  Point mouse_loc = er.where;
                  
                  /* convert to local coordinates of new window */
-                 SetPort (window_ptr);
+#if TARGET_API_MAC_CARBON
+                  SetPort (GetWindowPort (window_ptr));
+#else
+                  SetPort (window_ptr);
+#endif
+
                  GlobalToLocal (&mouse_loc);
+#if TARGET_API_MAC_CARBON
+                 ch = FindControlUnderMouse (mouse_loc, window_ptr,
+                                             &control_part_code);
+#else
                  control_part_code = FindControl (mouse_loc, window_ptr, &ch);
-                 
+#endif           
                  bufp->code = 0;  /* only one mouse button */
                  XSETINT (bufp->x, mouse_loc.h);
                  XSETINT (bufp->y, mouse_loc.v);
                  bufp->timestamp = er.when * (1000 / 60);
                    /* ticks to milliseconds */
-                 
+
+#if TARGET_API_MAC_CARBON                
+                 if (ch != 0)
+#else
                  if (control_part_code != 0)
+#endif
                    {
                      struct scroll_bar *bar = (struct scroll_bar *)
                        GetControlReference (ch);
@@ -11987,7 +12405,8 @@ XTread_socket (int sd, struct input_event *bufp, int numchars, int expected)
                      if (er.what == mouseDown
                          && control_part_code == kControlIndicatorPart)
                        {
-                         mouse_tracking_in_progress = mouse_tracking_scroll_bar;
+                         mouse_tracking_in_progress
+                           = mouse_tracking_scroll_bar;
                          tracked_scroll_bar = bar;
                        }
                      else
@@ -12001,9 +12420,10 @@ XTread_socket (int sd, struct input_event *bufp, int numchars, int expected)
                      bufp->kind = mouse_click;
                      XSETFRAME (bufp->frame_or_window, mwp->mFP);
                      if (er.what == mouseDown)
-                       mouse_tracking_in_progress = mouse_tracking_mouse_movement;
+                       mouse_tracking_in_progress
+                         = mouse_tracking_mouse_movement;
                      else
-                       mouse_tracking_in_progress = mouse_tracking_none;             
+                       mouse_tracking_in_progress = mouse_tracking_none;
                    }
                                
                  switch (er.what)
@@ -12023,7 +12443,16 @@ XTread_socket (int sd, struct input_event *bufp, int numchars, int expected)
              break;
 
            case inDrag:
+#if TARGET_API_MAC_CARBON
+             {
+               BitMap bm;
+               
+               GetQDGlobalsScreenBits (&bm);
+               DragWindow (window_ptr, er.where, &bm.bounds);
+             }
+#else /* not TARGET_API_MAC_CARBON */
              DragWindow (window_ptr, er.where, &qd.screenBits.bounds);
+#endif /* not TARGET_API_MAC_CARBON */
              break;
 
            case inGoAway:
@@ -12121,9 +12550,11 @@ XTread_socket (int sd, struct input_event *bufp, int numchars, int expected)
                 the_err = TECCreateConverter (&converter,
                                              kTextEncodingMacRoman,
                                              mac_keyboard_text_encoding);
-                current_mac_keyboard_text_encoding = mac_keyboard_text_encoding;
+                current_mac_keyboard_text_encoding
+                 = mac_keyboard_text_encoding;
               }
-            else if (mac_keyboard_text_encoding != current_mac_keyboard_text_encoding)
+            else if (mac_keyboard_text_encoding
+                    != current_mac_keyboard_text_encoding)
               {
                 /* Free the converter for the current encoding before
                    creating a new one.  */
@@ -12131,7 +12562,8 @@ XTread_socket (int sd, struct input_event *bufp, int numchars, int expected)
                 the_err = TECCreateConverter (&converter,
                                              kTextEncodingMacRoman,
                                              mac_keyboard_text_encoding);
-                current_mac_keyboard_text_encoding = mac_keyboard_text_encoding;
+                current_mac_keyboard_text_encoding
+                 = mac_keyboard_text_encoding;
               } 
               
             if (the_err == noErr)
@@ -12211,7 +12643,16 @@ XTread_socket (int sd, struct input_event *bufp, int numchars, int expected)
                Otherwise parts of the screen can be left in an
                inconsistent state.  */
             if (wp)
+#if TARGET_API_MAC_CARBON
+             {
+               Rect r;
+               
+               GetWindowPortBounds (wp, &r);
+               InvalWindowRect (wp, &r);
+             }
+#else /* not TARGET_API_MAC_CARBON */
               InvalRect (&(wp->portRect));
+#endif /* not TARGET_API_MAC_CARBON */
             
             count++;
            bufp++;
@@ -12231,7 +12672,9 @@ XTread_socket (int sd, struct input_event *bufp, int numchars, int expected)
       pending_autoraise_frame = 0;
     }
 
+#if !TARGET_API_MAC_CARBON
   check_alarm ();  /* simulate the handling of a SIGALRM */
+#endif
 
   {
     static Point old_mouse_pos = { -1, -1 };
@@ -12244,27 +12687,38 @@ XTread_socket (int sd, struct input_event *bufp, int numchars, int expected)
     else
       {
         Point mouse_pos;
-        WindowPtr wp = FrontWindow ();
-        struct frame *f = ((mac_output *) GetWRefCon (wp))->mFP;
+        WindowPtr wp;
+        struct frame *f;
         Lisp_Object bar;
         struct scroll_bar *sb;         
 
-        SetPort (wp);
-        GetMouse (&mouse_pos);
+        wp = FrontWindow ();
+       if (is_emacs_window (wp))
+         {
+           f = ((mac_output *) GetWRefCon (wp))->mFP;
 
-        if (!EqualPt (mouse_pos, old_mouse_pos))
-          {
-            if (mouse_tracking_in_progress == mouse_tracking_scroll_bar
-               && tracked_scroll_bar)
-              x_scroll_bar_note_movement (tracked_scroll_bar,
-                                         mouse_pos.v
-                                         - XINT (tracked_scroll_bar->top),
-                                         TickCount() * (1000 / 60));
-            else
-              note_mouse_movement (f, &mouse_pos);
-             
-            old_mouse_pos = mouse_pos;            
-          }
+#if TARGET_API_MAC_CARBON
+           SetPort (GetWindowPort (wp));
+#else
+           SetPort (wp);
+#endif
+
+           GetMouse (&mouse_pos);
+
+           if (!EqualPt (mouse_pos, old_mouse_pos))
+             {
+               if (mouse_tracking_in_progress == mouse_tracking_scroll_bar
+                   && tracked_scroll_bar)
+                 x_scroll_bar_note_movement (tracked_scroll_bar,
+                                             mouse_pos.v
+                                             - XINT (tracked_scroll_bar->top),
+                                             TickCount() * (1000 / 60));
+               else
+                 note_mouse_movement (f, &mouse_pos);
+               
+               old_mouse_pos = mouse_pos;            
+             }
+         }
       }
   }
   
@@ -12300,7 +12754,11 @@ void
 NewMacWindow (FRAME_PTR fp)
 {
   mac_output *mwp;
+#if TARGET_API_MAC_CARBON
+  static int making_terminal_window = 0;
+#else
   static int making_terminal_window = 1;
+#endif
 
   mwp = fp->output_data.mac;
 
@@ -12320,7 +12778,11 @@ NewMacWindow (FRAME_PTR fp)
     /* so that update events can find this mac_output struct */
   mwp->mFP = fp;  /* point back to emacs frame */
 
+#if TARGET_API_MAC_CARBON
+  SetPort (GetWindowPort (mwp->mWP));
+#else
   SetPort (mwp->mWP);
+#endif
 
   mwp->fontset = -1;
        
@@ -12336,8 +12798,8 @@ void make_mac_frame (struct frame *f)
   FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_right;
   
   NewMacWindow(f);
-  f->output_data.mac->background_pixel = 0xffffff;
-  f->output_data.mac->foreground_pixel = 0;
+  FRAME_BACKGROUND_PIXEL (f) = 0xffffff;
+  FRAME_FOREGROUND_PIXEL (f) = 0;
 
   f->output_data.mac->cursor_pixel = 0;
   f->output_data.mac->border_pixel = 0x00ff00;
@@ -12385,7 +12847,12 @@ void make_mac_terminal_frame (struct frame *f)
   f->height = 4;
 
   make_mac_frame (f);
+
+  x_make_gc (f);
   
+  /* Need to be initialized for unshow_buffer in window.c.  */
+  selected_window = f->selected_window;
+
   Fmodify_frame_parameters (frame,
                             Fcons (Fcons (Qfont,
                                           build_string ("-*-monaco-medium-r-*--*-90-*-*-*-*-mac-roman")), Qnil));
@@ -12397,6 +12864,81 @@ void make_mac_terminal_frame (struct frame *f)
                                           build_string ("white")), Qnil));
 }
 
+\f
+/***********************************************************************
+                           Initialization
+ ***********************************************************************/
+
+#ifdef USE_X_TOOLKIT
+static XrmOptionDescRec emacs_options[] = {
+  {"-geometry",        ".geometry", XrmoptionSepArg, NULL},
+  {"-iconic",  ".iconic", XrmoptionNoArg, (XtPointer) "yes"},
+
+  {"-internal-border-width", "*EmacsScreen.internalBorderWidth",
+     XrmoptionSepArg, NULL},
+  {"-ib",      "*EmacsScreen.internalBorderWidth", XrmoptionSepArg, NULL},
+
+  {"-T",       "*EmacsShell.title", XrmoptionSepArg, (XtPointer) NULL},
+  {"-wn",      "*EmacsShell.title", XrmoptionSepArg, (XtPointer) NULL},
+  {"-title",   "*EmacsShell.title", XrmoptionSepArg, (XtPointer) NULL},
+  {"-iconname",        "*EmacsShell.iconName", XrmoptionSepArg, (XtPointer) NULL},
+  {"-in",      "*EmacsShell.iconName", XrmoptionSepArg, (XtPointer) NULL},
+  {"-mc",      "*pointerColor", XrmoptionSepArg, (XtPointer) NULL},
+  {"-cr",      "*cursorColor", XrmoptionSepArg, (XtPointer) NULL}
+};
+#endif /* USE_X_TOOLKIT */
+
+#ifdef MULTI_KBOARD
+/* Test whether two display-name strings agree up to the dot that separates
+   the screen number from the server number.  */
+static int
+same_x_server (name1, name2)
+     char *name1, *name2;
+{
+  int seen_colon = 0;
+  unsigned char *system_name = XSTRING (Vsystem_name)->data;
+  int system_name_length = strlen (system_name);
+  int length_until_period = 0;
+
+  while (system_name[length_until_period] != 0
+        && system_name[length_until_period] != '.')
+    length_until_period++;
+
+  /* Treat `unix' like an empty host name.  */
+  if (! strncmp (name1, "unix:", 5))
+    name1 += 4;
+  if (! strncmp (name2, "unix:", 5))
+    name2 += 4;
+  /* Treat this host's name like an empty host name.  */
+  if (! strncmp (name1, system_name, system_name_length)
+      && name1[system_name_length] == ':')
+    name1 += system_name_length;
+  if (! strncmp (name2, system_name, system_name_length)
+      && name2[system_name_length] == ':')
+    name2 += system_name_length;
+  /* Treat this host's domainless name like an empty host name.  */
+  if (! strncmp (name1, system_name, length_until_period)
+      && name1[length_until_period] == ':')
+    name1 += length_until_period;
+  if (! strncmp (name2, system_name, length_until_period)
+      && name2[length_until_period] == ':')
+    name2 += length_until_period;
+
+  for (; *name1 != '\0' && *name1 == *name2; name1++, name2++)
+    {
+      if (*name1 == ':')
+       seen_colon++;
+      if (seen_colon && *name1 == '.')
+       return 1;
+    }
+  return (seen_colon
+         && (*name1 == '.' || *name1 == '\0')
+         && (*name2 == '.' || *name2 == '\0'));
+}
+#endif
+
+int mac_initialized = 0;
+
 void
 mac_initialize_display_info ()
 {
@@ -12410,6 +12952,18 @@ mac_initialize_display_info ()
                                x_display_name_list);
   dpyinfo->name_list_element = XCAR (x_display_name_list);
   
+#if 0
+  dpyinfo->mac_id_name
+    = (char *) xmalloc (XSTRING (Vinvocation_name)->size
+                       + XSTRING (Vsystem_name)->size
+                       + 2);
+  sprintf (dpyinfo->mac_id_name, "%s@%s",
+          XSTRING (Vinvocation_name)->data, XSTRING (Vsystem_name)->data);
+#else
+  dpyinfo->mac_id_name = (char *) xmalloc (strlen ("Mac Display") + 1);
+  strcpy (dpyinfo->mac_id_name, "Mac Display");
+#endif
+
   main_device_handle = LMGetMainDevice();
 
   dpyinfo->reference_count = 0;
@@ -12426,17 +12980,61 @@ mac_initialize_display_info ()
   dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1;
   dpyinfo->mouse_face_face_id = DEFAULT_FACE_ID;
   dpyinfo->mouse_face_window = Qnil;
+}
+
+struct mac_display_info *
+mac_term_init (display_name, xrm_option, resource_name)
+     Lisp_Object display_name;
+     char *xrm_option;
+     char *resource_name;
+{
+  struct mac_display_info *dpyinfo;
+  GDHandle main_device_handle;
+
+  if (!mac_initialized)
+    {
+      mac_initialize ();
+      mac_initialized = 1;
+    }
+
+  mac_initialize_display_info (display_name);
+
+  dpyinfo = &one_mac_display_info;
+
+  main_device_handle = LMGetMainDevice();
+
+  dpyinfo->height = (**main_device_handle).gdRect.bottom;
+  dpyinfo->width = (**main_device_handle).gdRect.right;
 
+  return dpyinfo;
 }
+\f
+/* Set up use of X before we make the first connection.  */
+
+static struct redisplay_interface x_redisplay_interface =
+{
+  x_produce_glyphs,
+  x_write_glyphs,
+  x_insert_glyphs,
+  x_clear_end_of_line,
+  x_scroll_run,
+  x_after_update_window_line,
+  x_update_window_begin,
+  x_update_window_end,
+  XTcursor_to,
+  x_flush,
+  x_clear_mouse_face,
+  x_get_glyph_overhangs,
+  x_fix_overlapping_area
+};
 
 void
-x_initialize ()
+mac_initialize ()
 {
   rif = &x_redisplay_interface;
 
   clear_frame_hook = x_clear_frame;
   ins_del_lines_hook = x_ins_del_lines;
-  change_line_highlight_hook = x_change_line_highlight;
   delete_glyphs_hook = x_delete_glyphs;
   ring_bell_hook = XTring_bell;
   reset_terminal_modes_hook = XTreset_terminal_modes;
@@ -12446,7 +13044,6 @@ x_initialize ()
   set_terminal_window_hook = XTset_terminal_window;
   read_socket_hook = XTread_socket;
   frame_up_to_date_hook = XTframe_up_to_date;
-  reassert_line_highlight_hook = XTreassert_line_highlight;
   mouse_position_hook = XTmouse_position;
   frame_rehighlight_hook = XTframe_rehighlight;
   frame_raise_lower_hook = XTframe_raise_lower;
@@ -12458,11 +13055,11 @@ x_initialize ()
 
   estimate_mode_line_height_hook = x_estimate_mode_line_height;
 
-  scroll_region_ok = 1;                /* we'll scroll partial frames */
-  char_ins_del_ok = 0;         /* just as fast to write the line */
-  line_ins_del_ok = 1;         /* we'll just blt 'em */
-  fast_clear_end_of_line = 1;  /* X does this well */
-  memory_below_frame = 0;      /* we don't remember what scrolls
+  scroll_region_ok = 1;         /* we'll scroll partial frames */
+  char_ins_del_ok = 1;
+  line_ins_del_ok = 1;          /* we'll just blt 'em */
+  fast_clear_end_of_line = 1;   /* X does this well */
+  memory_below_frame = 0;       /* we don't remember what scrolls
                                   off the bottom */
   baud_rate = 19200;
 
@@ -12546,40 +13143,50 @@ syms_of_macterm ()
   staticpro (&previous_help_echo);
   help_echo_pos = -1;
 
+  DEFVAR_BOOL ("x-autoselect-window", &x_autoselect_window_p,
+    doc: /* *Non-nil means autoselect window with mouse pointer.  */);
+  x_autoselect_window_p = 0;
+
   DEFVAR_BOOL ("x-stretch-cursor", &x_stretch_cursor_p,
-    "*Non-nil means draw block cursor as wide as the glyph under it.\n\
-For example, if a block cursor is over a tab, it will be drawn as\n\
-wide as that tab on the display.");
+    doc: /* *Non-nil means draw block cursor as wide as the glyph under it.
+For example, if a block cursor is over a tab, it will be drawn as
+wide as that tab on the display.  */);
   x_stretch_cursor_p = 0;
 
-  DEFVAR_BOOL ("x-toolkit-scroll-bars-p", &x_toolkit_scroll_bars_p,
-    "If not nil, Emacs uses toolkit scroll bars.");
-#if USE_TOOLKIT_SCROLL_BARS
-  x_toolkit_scroll_bars_p = 1;
-#else
-  x_toolkit_scroll_bars_p = 0;
+#if 0 /* TODO: Setting underline position from font properties.  */
+  DEFVAR_BOOL ("x-use-underline-position-properties",
+              &x_use_underline_position_properties,
+    doc: /* *Non-nil means make use of UNDERLINE_POSITION font properties.
+nil means ignore them.  If you encounter fonts with bogus
+UNDERLINE_POSITION font properties, for example 7x13 on XFree prior
+to 4.1, set this to nil.  */);
+  x_use_underline_position_properties = 1;
 #endif
 
+  DEFVAR_LISP ("x-toolkit-scroll-bars", &Vx_toolkit_scroll_bars,
+              doc: /* If not nil, Emacs uses toolkit scroll bars.  */);
+  Vx_toolkit_scroll_bars = Qt;
+
   staticpro (&last_mouse_motion_frame);
   last_mouse_motion_frame = Qnil;
   
   DEFVAR_LISP ("mac-command-key-is-meta", &Vmac_command_key_is_meta,
-    "Non-nil means that the command key is used as the Emacs meta key.\n\
-Otherwise the option key is used.");
+    doc: /* Non-nil means that the command key is used as the Emacs meta key.
+Otherwise the option key is used.  */);
   Vmac_command_key_is_meta = Qt;
 
   DEFVAR_INT ("mac-keyboard-text-encoding", &mac_keyboard_text_encoding,
-    "One of the Text Encoding Base constant values defined in the\n\
-Basic Text Constants section of Inside Macintosh - Text Encoding\n\
-Conversion Manager.  Its value determines the encoding characters\n\
-typed at the Mac keyboard (presumed to be in the MacRoman encoding)\n\
-will convert into.  E.g., if it is set to kTextEncodingMacRoman (0),\n\
-its default value, no conversion takes place.  If it is set to\n\
-kTextEncodingISOLatin1 (0x201) or kTextEncodingISOLatin2 (0x202),\n\
-characters typed on Mac keyboard are first converted into the\n\
-ISO Latin-1 or ISO Latin-2 encoding, respectively before being\n\
-passed to Emacs.  Together with Emacs's set-keyboard-coding-system\n\
-command, this enables the Mac keyboard to be used to enter non-ASCII\n\
-characters directly.");
+    doc: /* One of the Text Encoding Base constant values defined in the
+Basic Text Constants section of Inside Macintosh - Text Encoding
+Conversion Manager.  Its value determines the encoding characters
+typed at the Mac keyboard (presumed to be in the MacRoman encoding)
+will convert into.  E.g., if it is set to kTextEncodingMacRoman (0),
+its default value, no conversion takes place.  If it is set to
+kTextEncodingISOLatin1 (0x201) or kTextEncodingISOLatin2 (0x202),
+characters typed on Mac keyboard are first converted into the
+ISO Latin-1 or ISO Latin-2 encoding, respectively before being
+passed to Emacs.  Together with Emacs's set-keyboard-coding-system
+command, this enables the Mac keyboard to be used to enter non-ASCII
+characters directly.  */);
   mac_keyboard_text_encoding = kTextEncodingMacRoman;
 }
similarity index 91%
rename from mac/inc/macterm.h
rename to src/macterm.h
index 340be4e..578a6ec 100644 (file)
@@ -1,5 +1,5 @@
 /* Display module for Mac OS.
-   Copyright (C) 2000 Free Software Foundation, Inc.
+   Copyright (C) 2000, 2001 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -18,7 +18,7 @@ along with GNU Emacs; see the file COPYING.  If not, write to
 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
-/* Contributed by Andrew Choi (akochoi@users.sourceforge.net).  */
+/* Contributed by Andrew Choi (akochoi@mac.com).  */
 
 #include "macgui.h"
 #include "frame.h"
@@ -103,7 +103,7 @@ struct mac_display_info
   Window root_window;
 
   /* The cursor to use for vertical scroll bars.  */
-  Cursor vertical_scroll_bar_cursor;
+  struct Cursor *vertical_scroll_bar_cursor;
 
 #if 0
   /* color palette information.  */
@@ -151,10 +151,9 @@ struct mac_display_info
   int mouse_face_end_row, mouse_face_end_col;
   int mouse_face_end_x, mouse_face_end_y;
   int mouse_face_past_end;
-
   Lisp_Object mouse_face_window;
-
   int mouse_face_face_id;
+  Lisp_Object mouse_face_overlay;
 
   /* 1 if a mouse motion event came and we didn't handle it right away because
      gc was in progress.  */
@@ -169,6 +168,9 @@ struct mac_display_info
   /* Nonzero means defer mouse-motion highlighting.  */
   int mouse_face_defer;
 
+  /* Nonzero means that the mouse highlight should not be shown.  */
+  int mouse_face_hidden;
+
   int mouse_face_image_state;
 
   char *mac_id_name;
@@ -208,12 +210,12 @@ struct mac_display_info
 
 #define x_display_info mac_display_info
 
-/* This is a chain of structures for all the displays currently in use.  */
-extern struct mac_display_info one_mac_display_info;
-
 /* This is a chain of structures for all the X displays currently in use.  */
 extern struct x_display_info *x_display_list;
 
+/* This is a chain of structures for all the displays currently in use.  */
+extern struct mac_display_info one_mac_display_info;
+
 /* This is a list of cons cells, each of the form (NAME . FONT-LIST-CACHE),
    one for each element of x_display_list and in the same order.
    NAME is the name of the frame.
@@ -228,10 +230,24 @@ extern struct x_display_info *x_display_info_for_name P_ ((Lisp_Object));
 
 extern struct mac_display_info *mac_term_init ();
 
-/* The collection of data describing a window on the Mac.  Functions
-   defined in macterm.c */
+/* When Emacs uses a tty window, tty_display in frame.c points to an
+   x_output struct .  */
+struct x_output
+{
+  unsigned long background_pixel;
+  unsigned long foreground_pixel;
+};
+
+/* The collection of data describing a window on the Mac.  */
 struct mac_output {
-  WindowPtr mWP;               /* pointer to QuickDraw window */
+  /* Placeholder for things accessed through output_data.x.  Must
+     appear first.  */
+  struct x_output x_compatible;
+
+  /* Menubar "widget" handle.  */
+  int menubar_widget;
+
+  Window mWP;                  /* pointer to QuickDraw window */
   FRAME_PTR mFP;               /* points back to the frame struct */
 
 #if 0
@@ -239,11 +255,15 @@ struct mac_output {
   int mNumRows;                        /* number of characters per row */
   int mLineHeight;             /* height of one line of text in pixels */
   int mCharWidth;              /* width of one character in pixels */
-  int mHomeX;                  /* X pixel coordinate of lower left corner of character at (0, 0) */
-  int mHomeY;                  /* Y pixel coordinate of lower left corner of character at (0, 0) */
+  int mHomeX;                  /* X pixel coordinate of lower left
+                                  corner of character at (0, 0) */
+  int mHomeY;                  /* Y pixel coordinate of lower left
+                                  corner of character at (0, 0) */
   int mHighlight;              /* current highlight state (0 = off). */
-  int mTermWinSize;            /* num of lines from top of window affected by ins_del_lines; set by set_terminal_window. */
-#endif
+  int mTermWinSize;            /* num of lines from top of window
+                                  affected by ins_del_lines; set by
+                                  set_terminal_window. */
+#endif /* 0 */
 
 #if 0
   /* stuffs used by xfaces.c */
@@ -254,9 +274,6 @@ struct mac_output {
   int size_computed_faces;
 #endif
 
-  unsigned long background_pixel;
-  unsigned long foreground_pixel;
-
   /* Position of the Mac window (x and y offsets in global coordinates).  */
   int left_pos;
   int top_pos;
@@ -318,11 +335,11 @@ struct mac_output {
   unsigned long scroll_bar_background_pixel;
 
   /* Descriptor for the cursor in use for this window.  */
-  Cursor text_cursor;
-  Cursor nontext_cursor;
-  Cursor modeline_cursor;
-  Cursor cross_cursor;
-  Cursor hourglass_cursor;
+  struct Cursor *text_cursor;
+  struct Cursor *nontext_cursor;
+  struct Cursor *modeline_cursor;
+  struct Cursor *cross_cursor;
+  struct Cursor *hourglass_cursor;
 #if 0
   /* Window whose cursor is hourglass_cursor.  This window is temporarily
      mapped to display a hourglass-cursor.  */
@@ -380,15 +397,13 @@ struct mac_output {
   /* Nonzero means menubar is currently active.  */
   char menubar_active;
 
-  /* Always contains NULL on the Mac OS because the menu bar is shared.  */
-  int menubar_widget;
-  
-#if 0
+  /* Nonzero means a menu command is being processed.  */
+  char menu_command_in_progress;
+
   /* Nonzero means menubar is about to become active, but should be
      brought up to date first.  */
   volatile char pending_menu_activation;
 
-#endif
   /* Relief GCs, colors etc.  */
   struct relief
   {
@@ -408,13 +423,15 @@ typedef struct mac_output mac_output;
 /* Return the Mac window used for displaying data in frame F.  */
 #define FRAME_MAC_WINDOW(f) ((f)->output_data.mac->mWP)
 
-#define FRAME_FOREGROUND_PIXEL(f) ((f)->output_data.mac->foreground_pixel)
-#define FRAME_BACKGROUND_PIXEL(f) ((f)->output_data.mac->background_pixel)
+#define FRAME_FOREGROUND_PIXEL(f) ((f)->output_data.x->foreground_pixel)
+#define FRAME_BACKGROUND_PIXEL(f) ((f)->output_data.x->background_pixel)
 
 #define FRAME_FONT(f) ((f)->output_data.mac->font)
 #define FRAME_FONTSET(f) ((f)->output_data.mac->fontset)
 
-#define FRAME_INTERNAL_BORDER_WIDTH(f) ((f)->output_data.mac->internal_border_width)
+#undef FRAME_INTERNAL_BORDER_WIDTH
+#define FRAME_INTERNAL_BORDER_WIDTH(f) \
+     ((f)->output_data.mac->internal_border_width)
 #define FRAME_LINE_HEIGHT(f) ((f)->output_data.mac->line_height)
 /* Width of the default font of frame F.  Must be defined by each
    terminal specific header.  */
@@ -469,6 +486,7 @@ typedef struct mac_output mac_output;
 #define FRAME_X_LEFT_FRINGE_WIDTH(F) ((F)->output_data.mac->left_fringe_width)
 #define FRAME_X_RIGHT_FRINGE_WIDTH(F) ((F)->output_data.mac->right_fringe_width)
 
+
 \f
 /* Mac-specific scroll bar stuff.  */
 
@@ -539,13 +557,16 @@ struct scroll_bar {
    XSETINT ((high), ((int32) >> 16) & 0xffff))
 
 
-/* Extract the Mac control handle of the scroll bar from a struct scroll_bar.  */
+/* Extract the Mac control handle of the scroll bar from a struct
+   scroll_bar.  */
 #define SCROLL_BAR_CONTROL_HANDLE(ptr) \
-  ((ControlHandle) SCROLL_BAR_PACK ((ptr)->control_handle_low, (ptr)->control_handle_high))
+  ((ControlHandle) SCROLL_BAR_PACK ((ptr)->control_handle_low, \
+                                    (ptr)->control_handle_high))
 
 /* Store a Mac control handle in a struct scroll_bar.  */
 #define SET_SCROLL_BAR_CONTROL_HANDLE(ptr, id) \
-  (SCROLL_BAR_UNPACK ((ptr)->control_handle_low, (ptr)->control_handle_high, (int) id))
+  (SCROLL_BAR_UNPACK ((ptr)->control_handle_low, \
+                      (ptr)->control_handle_high, (int) id))
 
 /* Return the inside width of a vertical scroll bar, given the outside
    width.  */
@@ -563,12 +584,14 @@ struct scroll_bar {
    scaling buffer positions to scroll bar positions, we use this, not
    VERTICAL_SCROLL_BAR_INSIDE_HEIGHT.  */
 #define VERTICAL_SCROLL_BAR_TOP_RANGE(f,height) \
-  (VERTICAL_SCROLL_BAR_INSIDE_HEIGHT (f, height) - VERTICAL_SCROLL_BAR_MIN_HANDLE - UP_AND_DOWN_ARROWS)
+  (VERTICAL_SCROLL_BAR_INSIDE_HEIGHT (f, height) \
+   - VERTICAL_SCROLL_BAR_MIN_HANDLE - UP_AND_DOWN_ARROWS)
 
 /* Return the inside height of vertical scroll bar, given the outside
    height.  See VERTICAL_SCROLL_BAR_TOP_RANGE too.  */
 #define VERTICAL_SCROLL_BAR_INSIDE_HEIGHT(f,height) \
-  ((height) - VERTICAL_SCROLL_BAR_TOP_BORDER - VERTICAL_SCROLL_BAR_BOTTOM_BORDER)
+  ((height) - VERTICAL_SCROLL_BAR_TOP_BORDER \
+   - VERTICAL_SCROLL_BAR_BOTTOM_BORDER)
 
 
 /* Border widths for scroll bars.
@@ -645,8 +668,3 @@ struct scroll_bar {
 
 struct frame * check_x_frame (Lisp_Object);
 
-/* Dummy entry for defining tty_display in frame.c.  */
-struct x_output
-{
-  char _dummy;
-};
index 06e931a..a62b13c 100644 (file)
@@ -137,6 +137,11 @@ extern Lisp_Object QCfamily, QCfilter;
 
 /* Qexit is declared and initialized in eval.c.  */
 
+/* QCfamily is defined in xfaces.c.  */
+extern Lisp_Object QCfamily;
+/* QCfilter is defined in keyboard.c.  */
+extern Lisp_Object QCfilter;
+
 /* a process object is a network connection when its childp field is neither
    Qt nor Qnil but is instead a cons cell (HOSTNAME PORTNUM).  */
 
@@ -3750,6 +3755,14 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
          SELECT_TYPE Atemp, Ctemp;
 
          Atemp = input_wait_mask;
+#ifdef MAC_OSX
+          /* On Mac OS X, the SELECT system call always says input is
+             present (for reading) at stdin, even when none is.  This
+             causes the the call to SELECT below to return 1 and
+             status_notify not to be called.  As a result output of
+             subprocesses are incorrectly discarded.  */
+          FD_CLR (0, &Atemp);
+#endif
          Ctemp = connect_wait_mask;
          EMACS_SET_SECS_USECS (timeout, 0, 0);
          if ((select (max (max_process_desc, max_keyboard_desc) + 1,
diff --git a/src/s/darwin.h b/src/s/darwin.h
new file mode 100644 (file)
index 0000000..214b55b
--- /dev/null
@@ -0,0 +1,291 @@
+/* System description header file for Darwin (Mac OS X).
+   Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Emacs.
+
+GNU Emacs is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Emacs is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Emacs; see the file COPYING.  If not, write to
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
+
+
+/*
+ *     Define symbols to identify the version of Unix this is.
+ *     Define all the symbols that apply correctly.
+ */
+
+/* #define UNIPLUS */
+/* #define USG5 */
+/* #define USG */
+/* #define HPUX */
+/* #define UMAX */
+/* #define BSD4_1 */
+#define BSD4_2
+/* BSD4_3 and BSD4_4 are already defined in sys/param.h */
+/* #define BSD4_3 */
+/* #define BSD4_4 */
+#define BSD_SYSTEM
+/* #define VMS */
+
+/* MAC_OS is used to conditionally compile code common to both MAC_OS8
+   and MAC_OSX.  */
+#ifdef MAC_OSX
+#define MAC_OS
+#endif
+
+/* SYSTEM_TYPE should indicate the kind of system you are using.
+ It sets the Lisp variable system-type.  */
+
+#define SYSTEM_TYPE "darwin"
+
+/* NOMULTIPLEJOBS should be defined if your system's shell
+ does not have "job control" (the ability to stop a program,
+ run some other program, then continue the first one).  */
+
+/* #define NOMULTIPLEJOBS */
+
+/* Emacs can read input using SIGIO and buffering characters itself,
+   or using CBREAK mode and making C-g cause SIGINT.
+   The choice is controlled by the variable interrupt_input.
+
+   Define INTERRUPT_INPUT to make interrupt_input = 1 the default (use SIGIO)
+
+   Emacs uses the presence or absence of the SIGIO and BROKEN_SIGIO macros
+   to indicate whether or not signal-driven I/O is possible.  It uses
+   INTERRUPT_INPUT to decide whether to use it by default.
+
+   SIGIO can be used only on systems that implement it (4.2 and 4.3).
+   CBREAK mode has two disadvantages
+     1) At least in 4.2, it is impossible to handle the Meta key properly.
+        I hear that in system V this problem does not exist.
+     2) Control-G causes output to be discarded.
+        I do not know whether this can be fixed in system V.
+
+   Another method of doing input is planned but not implemented.
+   It would have Emacs fork off a separate process
+   to read the input and send it to the true Emacs process
+   through a pipe. */
+
+#define INTERRUPT_INPUT
+
+/* Letter to use in finding device name of first pty,
+  if system supports pty's.  'a' means it is /dev/ptya0  */
+
+#define FIRST_PTY_LETTER 'p'
+
+/*
+ *     Define HAVE_TERMIOS if the system provides POSIX-style
+ *     functions and macros for terminal control.
+ *
+ *     Define HAVE_TERMIO if the system provides sysV-style ioctls
+ *     for terminal control.
+ *
+ *     Do not define both.  HAVE_TERMIOS is preferred, if it is
+ *     supported on your system.
+ */
+
+#define HAVE_TERMIOS
+/* #define HAVE_TERMIO */
+
+#define NO_TERMIO
+
+/*
+ *     Define HAVE_PTYS if the system supports pty devices.
+ */
+
+#define HAVE_PTYS
+
+/*
+ *     Define NONSYSTEM_DIR_LIBRARY to make Emacs emulate
+ *      The 4.2 opendir, etc., library functions.
+ */
+
+/* #define NONSYSTEM_DIR_LIBRARY */
+
+/* Define this symbol if your system has the functions bcopy, etc. */
+
+#define BSTRING
+
+/* subprocesses should be defined if you want to
+   have code for asynchronous subprocesses
+   (as used in M-x compile and M-x shell).
+   This is generally OS dependent, and not supported
+   under most USG systems. */
+
+#define subprocesses
+
+/* If your system uses COFF (Common Object File Format) then define the
+   preprocessor symbol "COFF". */
+
+/* #define COFF */
+
+/* define MAIL_USE_FLOCK if the mailer uses flock
+   to interlock access to /usr/spool/mail/$USER.
+   The alternative is that a lock file named
+   /usr/spool/mail/$USER.lock.  */
+
+#define MAIL_USE_FLOCK
+
+/* Define CLASH_DETECTION if you want lock files to be written
+   so that Emacs can tell instantly when you try to modify
+   a file that someone else has modified in his Emacs.  */
+
+#define CLASH_DETECTION
+
+/* Define this if your operating system declares signal handlers to
+   have a type other than the usual.  `The usual' is `void' for ANSI C
+   systems (i.e. when the __STDC__ macro is defined), and `int' for
+   pre-ANSI systems.  If you're using GCC on an older system, __STDC__
+   will be defined, but the system's include files will still say that
+   signal returns int or whatever; in situations like that, define
+   this to be what the system's include files want.  */
+/* #define SIGTYPE int */
+
+/* If the character used to separate elements of the executable path
+   is not ':', #define this to be the appropriate character constant.  */
+/* #define SEPCHAR ':' */
+
+/* Define this if the system can use mmap for buffer text allocation.  */
+/* #define USE_MMAP_FOR_BUFFERS 1 */
+
+/* ============================================================ */
+
+/* Here, add any special hacks needed
+   to make Emacs work on this system.  For example,
+   you might define certain system call names that don't
+   exist on your system, or that do different things on
+   your system and must be used only through an encapsulation
+   (Which you should place, by convention, in sysdep.c).  */
+
+/* Some compilers tend to put everything declared static
+   into the initialized data area, which becomes pure after dumping Emacs.
+   On these systems, you must #define static as nothing to foil this.
+   Note that emacs carefully avoids static vars inside functions.  */
+
+/* #define static */
+
+/* If the system's imake configuration file defines `NeedWidePrototypes'
+   as `NO', we must define NARROWPROTO manually.  Such a define is
+   generated in the Makefile generated by `xmkmf'.  If we don't 
+   define NARROWPROTO, we will see the wrong function prototypes
+   for X functions taking float or double parameters.  */
+
+/*  #define NARROWPROTO 1 */
+
+/* ============================================================ */
+
+/* After adding support for a new system, modify the large case
+   statement in the `configure' script to recognize reasonable
+   configuration names, and add a description of the system to
+   `etc/MACHINES'.
+
+   If you've just fixed a problem in an existing configuration file,
+   you should also check `etc/MACHINES' to make sure its descriptions
+   of known problems in that configuration should be updated.  */
+
+
+/* Avoid the use of the name init_process (process.c) because it is
+   also the name of a Mach system call.  */
+#define init_process emacs_init_process
+
+/* Fix compilation problem for regex.c.  */
+#define __restrict
+
+/* Fix compilation problem for md5.c.  */
+#define __attribute__(x)
+
+/* Used in dispnew.c.  Copied from freebsd.h. */
+#define PENDING_OUTPUT_COUNT(FILE) ((FILE)->_p - (FILE)->_bf._base)
+
+/* Darwin provides POSIX-style getpgrp.  */
+#define GETPGRP_NO_ARG
+
+/* System uses OXTABS instead of the expected TAB3.  (Copied from
+   bsd386.h.)  */
+#define TAB3 OXTABS
+
+/* Darwin ld insists on the use of malloc routines in the System
+   framework.  */
+#define SYSTEM_MALLOC
+
+/* Define HAVE_SOCKETS if system supports 4.2-compatible sockets.  */
+#define HAVE_SOCKETS
+
+/* Extra initialization calls in main for Mac OS X system type.  */
+#define SYMS_SYSTEM syms_of_mac()
+
+/* Definitions for how to dump.  Copied from nextstep.h.  */
+
+#define UNEXEC unexmacosx.o
+
+#define START_FILES pre-crt0.o
+
+/* start_of_text isn't actually used, so make it compile without error.  */
+#define TEXT_START (0)
+
+/* This seems to be right for end_of_text, but it may not be used anyway.  */
+#define TEXT_END get_etext()
+
+/* This seems to be right for end_of_data, but it may not be used anyway.  */
+#define DATA_END get_edata()
+
+/* Definitions for how to compile & link.  */
+
+/* Indicate that we are compiling for Mac OS X and where to find Mac
+   specific headers.  */
+#define C_SWITCH_SYSTEM -fpascal-strings -fno-common -DMAC_OSX -I../mac/src
+
+/* Link in the Carbon lib.  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 -framework Carbon -lstdc++ -Xlinker -headerpad -Xlinker 690
+
+#define C_SWITCH_SYSTEM_TEMACS -Dtemacs
+
+/* Link this program just by running cc.  */
+#define ORDINARY_LINK
+
+/* We don't have a g library, so override the -lg LIBS_DEBUG switch.  */
+#define LIBS_DEBUG
+
+/* Adding -lm confuses the dynamic linker, so omit it.  */
+#define LIB_MATH
+
+/* Tell src/Makefile.in to create files in the Mac OS X application
+   bundle mac/Emacs.app.  */
+#define OTHER_FILES macosx-app
+
+
+/* Define the following so emacs symbols will not conflict with those
+   in the System framework.  Otherwise -prebind will not work.  */
+
+/* Do not define abort in emacs.c.  */
+#define NO_ABORT
+
+/* Do not define matherr in floatfns.c.  */
+#define NO_MATHERR
+
+
+/* This prevents a compilation error in xfaces.c: struct kboard * is
+   used in a function protocol the first time this type appears in the
+   file, since MULTI_KBOARD is undefined for the Mac OS X build.  */
+#ifndef NOT_C_CODE
+struct kboard;
+#endif
+
+#ifdef temacs
+#define malloc unexec_malloc
+#define realloc unexec_realloc
+#define free unexec_free
+#endif
index 75d929e..c7e4aba 100644 (file)
@@ -48,7 +48,7 @@ extern void srandom P_ ((unsigned int));
 #include "blockinput.h"
 #undef NULL
 
-#ifdef macintosh
+#ifdef MAC_OS8
 /* It is essential to include stdlib.h so that this file picks up
    the correct definitions of rand, srand, and RAND_MAX.
    Otherwise random numbers will not work correctly.  */
@@ -58,7 +58,7 @@ extern void srandom P_ ((unsigned int));
 /* Nonzero means delete a process right away if it exits (process.c).  */
 static int delete_exited_processes;
 #endif
-#endif  /* macintosh */
+#endif  /* MAC_OS8 */
 
 #ifdef WINDOWSNT
 #define read sys_read
@@ -759,7 +759,7 @@ sys_suspend ()
 
 /* Fork a subshell.  */
 
-#ifndef macintosh
+#ifndef MAC_OS8
 void
 sys_subshell ()
 {
@@ -895,7 +895,7 @@ sys_subshell ()
   synch_process_alive = 0;
 #endif /* !VMS */
 }
-#endif /* !macintosh */
+#endif /* !MAC_OS8 */
 
 static void
 save_signal_handlers (saved_handlers)
@@ -1305,7 +1305,7 @@ init_sys_modes ()
 {
   struct emacs_tty tty;
 
-#ifdef macintosh
+#ifdef MAC_OS8
 /* cus-start.el complains if delete-exited-processes is not defined */
 #ifndef subprocesses
   DEFVAR_BOOL ("delete-exited-processes", &delete_exited_processes,
@@ -1313,7 +1313,7 @@ init_sys_modes ()
 nil means don't delete them until `list-processes' is run.  */);
   delete_exited_processes = 0;
 #endif
-#endif /* not macintosh */
+#endif /* MAC_OS8 */
 
 #ifdef VMS
 #if 0
index 66f1c54..c2bac22 100644 (file)
@@ -56,7 +56,7 @@ extern int tgetnum P_ ((char *id));
 #ifdef HAVE_X_WINDOWS
 #include "xterm.h"
 #endif
-#ifdef macintosh
+#ifdef MAC_OS
 #include "macterm.h"
 #endif
 
index b87fee4..8918f06 100644 (file)
@@ -144,6 +144,9 @@ find_capability (bp, cap)
   return NULL;
 }
 
+/* These are already defined in the System framework in Mac OS X and
+   cause prebinding to fail.  */
+#ifndef MAC_OSX
 int
 tgetnum (cap)
      char *cap;
@@ -177,6 +180,7 @@ tgetstr (cap, area)
     return NULL;
   return tgetst1 (ptr, area);
 }
+#endif /* MAC_OSX */
 
 #ifdef IS_EBCDIC_HOST
 /* Table, indexed by a character in range 0200 to 0300 with 0200 subtracted,
@@ -294,7 +298,12 @@ short ospeed;
 /* If OSPEED is 0, we use this as the actual baud rate.  */
 int tputs_baud_rate;
 #endif
+
+/* Already defined in the System framework in Mac OS X and causes
+   prebinding to fail.  */
+#ifndef MAC_OSX
 char PC;
+#endif  /* MAC_OSX */
 
 #ifndef emacs
 /* Actual baud rate if positive;
@@ -313,6 +322,9 @@ static int speeds[] =
 
 #endif /* not emacs */
 
+/* Already defined in the System framework in Mac OS X and causes
+   prebinding to fail.  */
+#ifndef MAC_OSX
 void
 tputs (str, nlines, outfun)
      register char *str;
@@ -375,6 +387,7 @@ tputs (str, nlines, outfun)
   while (padcount-- > 0)
     (*outfun) (PC);
 }
+#endif /* MAC_OSX */
 \f
 /* Finding the termcap entry in the termcap data base.  */
 
@@ -445,6 +458,9 @@ valid_filename_p (fn)
    0 if the data base is accessible but the type NAME is not defined
    in it, and some other value otherwise.  */
 
+/* Already defined in the System framework in Mac OS X and causes
+   prebinding to fail.  */
+#ifndef MAC_OSX
 int
 tgetent (bp, name)
      char *bp, *name;
@@ -603,6 +619,7 @@ tgetent (bp, name)
   term_entry = bp;
   return 1;
 }
+#endif /* MAC_OSX */
 
 /* Given file open on FD and buffer BUFP,
    scan the file from the beginning until a line is found
index 5a9809a..844e5f6 100644 (file)
@@ -107,6 +107,9 @@ tparam (string, outstring, len, arg0, arg1, arg2, arg3)
   return tparam1 (string, outstring, len, NULL, NULL, arg);
 }
 
+/* These are already defined in the System framework in Mac OS X and
+   cause prebinding to fail.  */
+#ifndef MAC_OSX
 char *BC;
 char *UP;
 
@@ -124,6 +127,7 @@ tgoto (cm, hpos, vpos)
   args[1] = hpos;
   return tparam1 (cm, tgoto_buf, 50, UP, BC, args);
 }
+#endif
 
 static char *
 tparam1 (string, outstring, len, up, left, argp)
diff --git a/src/unexmacosx.c b/src/unexmacosx.c
new file mode 100644 (file)
index 0000000..da4b82b
--- /dev/null
@@ -0,0 +1,914 @@
+/* Dump Emacs in Mach-O format for use on Mac OS X.
+   Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Emacs.
+
+GNU Emacs is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Emacs is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Emacs; see the file COPYING.  If not, write to
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
+
+/* Contributed by Andrew Choi (akochoi@mac.com).  */
+
+/* Documentation note.
+
+   Consult the following documents/files for a description of the
+   Mach-O format: the file loader.h, man pages for Mach-O and ld, old
+   NEXTSTEP documents of the Mach-O format.  The tool otool dumps the
+   mach header (-h option) and the load commands (-l option) in a
+   Mach-O file.  The tool nm on Mac OS X displays the symbol table in
+   a Mach-O file.  For examples of unexec for the Mach-O format, see
+   the file unexnext.c in the GNU Emacs distribution, the file
+   unexdyld.c in the Darwin port of GNU Emacs 20.7, and unexdyld.c in
+   the Darwin port of XEmacs 21.1.  Also the Darwin Libc source
+   contains the source code for malloc_freezedry and malloc_jumpstart.
+   Read that to see what they do.  This file was written completely
+   from scratch, making use of information from the above sources.  */
+
+/* The Mac OS X implementation of unexec makes use of Darwin's `zone'
+   memory allocator.  All calls to malloc, realloc, and free in Emacs
+   are redirected to unexec_malloc, unexec_realloc, and unexec_free in
+   this file.  When temacs is run, all memory requests are handled in
+   the zone EmacsZone.  The Darwin memory allocator library calls
+   maintain the data structures to manage this zone.  Dumping writes
+   its contents to data segments of the executable file.  When emacs
+   is run, the loader recreates the contents of the zone in memory.
+   However since the initialization routine of the zone memory
+   allocator is run again, this `zone' can no longer be used as a
+   heap.  That is why emacs uses the ordinary malloc system call to
+   allocate memory.  Also, when a block of memory needs to be
+   reallocated and the new size is larger than the old one, a new
+   block must be obtained by malloc and the old contents copied to
+   it.  */
+
+/* Peculiarity of the Mach-O files generated by ld in Mac OS X
+   (possible causes of future bugs if changed).
+
+   The file offset of the start of the __TEXT segment is zero.  Since
+   the Mach header and load commands are located at the beginning of a
+   Mach-O file, copying the contents of the __TEXT segment from the
+   input file overwrites them in the output file.  Despite this,
+   unexec works fine as written below because the segment load command
+   for __TEXT appears, and is therefore processed, before all other
+   load commands except the segment load command for __PAGEZERO, which
+   remains unchanged.
+
+   Although the file offset of the start of the __TEXT segment is
+   zero, none of the sections it contains actually start there.  In
+   fact, the earliest one starts a few hundred bytes beyond the end of
+   the last load command.  The linker option -headerpad controls the
+   minimum size of this padding.  Its setting can be changed in
+   s/darwin.h.  A value of 0x300, e.g., leaves room for about 15
+   additional load commands for the newly created __DATA segments (at
+   56 bytes each).  Unexec fails if there is not enough room for these
+   new segments.
+
+   The __TEXT segment contains the sections __text, __cstring,
+   __picsymbol_stub, and __const and the __DATA segment contains the
+   sections __data, __la_symbol_ptr, __nl_symbol_ptr, __dyld, __bss,
+   and __common.  The other segments do not contain any sections.
+   These sections are copied from the input file to the output file,
+   except for __data, __bss, and __common, which are dumped from
+   memory.  The types of the sections __bss and __common are changed
+   from S_ZEROFILL to S_REGULAR.  Note that the number of sections and
+   their relative order in the input and output files remain
+   unchanged.  Otherwise all n_sect fields in the nlist records in the
+   symbol table (specified by the LC_SYMTAB load command) will have to
+   be changed accordingly.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <stdarg.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <mach/mach.h>
+#include <mach-o/loader.h>
+#include <objc/malloc.h>
+
+#define VERBOSE 1
+
+/* Size of buffer used to copy data from the input file to the output
+   file in function unexec_copy.  */
+#define UNEXEC_COPY_BUFSZ 1024
+
+/* Regions with memory addresses above this value are assumed to be
+   mapped to dynamically loaded libraries and will not be dumped.  */
+#define VM_DATA_TOP (20 * 1024 * 1024)
+
+/* Used by malloc_freezedry and malloc_jumpstart.  */
+int malloc_cookie;
+
+/* Type of an element on the list of regions to be dumped.  */
+struct region_t {
+  vm_address_t address;
+  vm_size_t size;
+  vm_prot_t protection;
+  vm_prot_t max_protection;
+
+  struct region_t *next;
+};
+
+/* Head and tail of the list of regions to be dumped.  */
+struct region_t *region_list_head = 0;
+struct region_t *region_list_tail = 0;
+
+/* Pointer to array of load commands.  */
+struct load_command **lca;
+
+/* Number of load commands.  */
+int nlc;
+
+/* The highest VM address of segments loaded by the input file.
+   Regions with addresses beyond this are assumed to be allocated
+   dynamically and thus require dumping.  */
+vm_address_t infile_lc_highest_addr = 0;
+
+/* The lowest file offset used by the all sections in the __TEXT
+   segments.  This leaves room at the beginning of the file to store
+   the Mach-O header.  Check this value against header size to ensure
+   the added load commands for the new __DATA segments did not
+   overwrite any of the sections in the __TEXT segment.  */
+unsigned long text_seg_lowest_offset = 0x10000000;
+
+/* Mach header.  */
+struct mach_header mh;
+
+/* Offset at which the next load command should be written.  */
+unsigned long curr_header_offset = sizeof (struct mach_header);
+
+/* Current adjustment that needs to be made to offset values because
+   of additional data segments.  */
+unsigned long delta = 0;
+
+int infd, outfd;
+
+int in_dumped_exec = 0;
+
+malloc_zone_t *emacs_zone;
+
+/* Read n bytes from infd into memory starting at address dest.
+   Return true if successful, false otherwise.  */
+static int
+unexec_read (void *dest, size_t n)
+{
+  return n == read (infd, dest, n);
+}
+
+/* Write n bytes from memory starting at address src to outfd starting
+   at offset dest.  Return true if successful, false otherwise.  */
+static int
+unexec_write (off_t dest, const void *src, size_t count)
+{
+  if (lseek (outfd, dest, SEEK_SET) != dest)
+    return 0;
+
+  return write (outfd, src, count) == count;
+}
+
+/* Copy n bytes from starting offset src in infd to starting offset
+   dest in outfd.  Return true if successful, false otherwise.  */
+static int
+unexec_copy (off_t dest, off_t src, ssize_t count)
+{
+  ssize_t bytes_read;
+
+  char buf[UNEXEC_COPY_BUFSZ];
+
+  if (lseek (infd, src, SEEK_SET) != src)
+    return 0;
+
+  if (lseek (outfd, dest, SEEK_SET) != dest)
+    return 0;
+
+  while (count > 0)
+    {
+      bytes_read = read (infd, buf, UNEXEC_COPY_BUFSZ);
+      if (bytes_read <= 0)
+       return 0;
+      if (write (outfd, buf, bytes_read) != bytes_read)
+       return 0;
+      count -= bytes_read;
+    }
+
+  return 1;
+}
+
+/* Debugging and informational messages routines.  */
+
+static void
+unexec_error (char *format, ...)
+{
+  va_list ap;
+
+  va_start (ap, format);
+  fprintf (stderr, "unexec: ");
+  vfprintf (stderr, format, ap);
+  fprintf (stderr, "\n");
+  va_end (ap);
+  exit (1);
+}
+
+static void
+print_prot (vm_prot_t prot)
+{
+  if (prot == VM_PROT_NONE)
+    printf ("none");
+  else
+    {
+      putchar (prot & VM_PROT_READ ? 'r' : ' ');
+      putchar (prot & VM_PROT_WRITE ? 'w' : ' ');
+      putchar (prot & VM_PROT_EXECUTE ? 'x' : ' ');
+      putchar (' ');
+    }
+}
+
+static void
+print_region (vm_address_t address, vm_size_t size, vm_prot_t prot,
+             vm_prot_t max_prot)
+{
+  printf ("%#10x %#8x ", address, size);
+  print_prot (prot);
+  putchar (' ');
+  print_prot (max_prot);
+  putchar ('\n');
+}
+
+static void
+print_region_list ()
+{
+  struct region_t *r;
+
+  printf ("   address     size prot maxp\n");
+
+  for (r = region_list_head; r; r = r->next)
+    print_region (r->address, r->size, r->protection, r->max_protection);
+}
+
+void
+print_regions ()
+{
+  task_t target_task = mach_task_self ();
+  vm_address_t address = (vm_address_t) 0;
+  vm_size_t size;
+  struct vm_region_basic_info info;
+  mach_msg_type_number_t info_count = VM_REGION_BASIC_INFO_COUNT;
+  mach_port_t object_name;
+
+  printf ("   address     size prot maxp\n");
+
+  while (vm_region (target_task, &address, &size, VM_REGION_BASIC_INFO,
+                   (vm_region_info_t) &info, &info_count, &object_name)
+        == KERN_SUCCESS && info_count == VM_REGION_BASIC_INFO_COUNT)
+    {
+      print_region (address, size, info.protection, info.max_protection);
+
+      if (object_name != MACH_PORT_NULL)
+       mach_port_deallocate (target_task, object_name);
+      
+      address += size;
+    }
+}
+
+/* Build the list of regions that need to be dumped.  Regions with
+   addresses above VM_DATA_TOP are omitted.  Adjacent regions with
+   identical protection are merged.  Note that non-writable regions
+   cannot be omitted because they some regions created at run time are
+   read-only.  */
+static void
+build_region_list ()
+{
+  task_t target_task = mach_task_self ();
+  vm_address_t address = (vm_address_t) 0;
+  vm_size_t size;
+  struct vm_region_basic_info info;
+  mach_msg_type_number_t info_count = VM_REGION_BASIC_INFO_COUNT;
+  mach_port_t object_name;
+  struct region_t *r;
+
+#if VERBOSE
+  printf ("--- List of All Regions ---\n");
+  printf ("   address     size prot maxp\n");
+#endif
+
+  while (vm_region (target_task, &address, &size, VM_REGION_BASIC_INFO,
+                   (vm_region_info_t) &info, &info_count, &object_name)
+        == KERN_SUCCESS && info_count == VM_REGION_BASIC_INFO_COUNT)
+    {
+      /* Done when we reach addresses of shared libraries, which are
+        loaded in high memory.  */
+      if (address >= VM_DATA_TOP)
+       break;
+
+#if VERBOSE
+      print_region (address, size, info.protection, info.max_protection);
+#endif
+
+      /* If a region immediately follows the previous one (the one
+        most recently added to the list) and has identical
+        protection, merge it with the latter.  Otherwise create a
+        new list element for it.  */
+      if (region_list_tail
+         && info.protection == region_list_tail->protection
+         && info.max_protection == region_list_tail->max_protection
+         && region_list_tail->address + region_list_tail->size == address)
+       {
+         region_list_tail->size += size;
+       }
+      else
+       {
+         r = (struct region_t *) malloc (sizeof (struct region_t));
+         
+         if (!r)
+           unexec_error ("cannot allocate region structure");
+         
+         r->address = address;
+         r->size = size;
+         r->protection = info.protection;
+         r->max_protection = info.max_protection;
+         
+         r->next = 0;
+         if (region_list_head == 0)
+           {
+             region_list_head = r;
+             region_list_tail = r;
+           }
+         else
+           {
+             region_list_tail->next = r;
+             region_list_tail = r;
+           }
+         
+         /* Deallocate (unused) object name returned by
+            vm_region.  */
+         if (object_name != MACH_PORT_NULL)
+           mach_port_deallocate (target_task, object_name);
+       }
+      
+      address += size;
+    }
+
+  printf ("--- List of Regions to be Dumped ---\n");
+  print_region_list ();
+}
+
+
+#define MAX_UNEXEC_REGIONS 30
+
+int num_unexec_regions;
+vm_range_t unexec_regions[MAX_UNEXEC_REGIONS];
+
+static void
+unexec_regions_recorder (task_t task, void *rr, unsigned type,
+                        vm_range_t *ranges, unsigned num)
+{
+  while (num && num_unexec_regions < MAX_UNEXEC_REGIONS)
+    {
+      unexec_regions[num_unexec_regions++] = *ranges;
+      printf ("%#8x (sz: %#8x)\n", ranges->address, ranges->size);
+      ranges++; num--;
+    }
+  if (num_unexec_regions == MAX_UNEXEC_REGIONS)
+    fprintf (stderr, "malloc_freezedry_recorder: too many regions\n");
+}
+
+static kern_return_t
+unexec_reader (task_t task, vm_address_t address, vm_size_t size, void **ptr)
+{
+  *ptr = (void *) address;
+  return KERN_SUCCESS;
+}
+
+void
+find_emacs_zone_regions ()
+{
+  num_unexec_regions = 0;
+
+  emacs_zone->introspect->enumerator (mach_task_self(), 0,
+                                     MALLOC_PTR_REGION_RANGE_TYPE
+                                     | MALLOC_ADMIN_REGION_RANGE_TYPE,
+                                     (vm_address_t) emacs_zone,
+                                     unexec_reader,
+                                     unexec_regions_recorder);
+}
+
+
+/* More informational messages routines.  */
+
+static void
+print_load_command_name (int lc)
+{
+  switch (lc)
+    {
+    case LC_SEGMENT:
+      printf ("LC_SEGMENT       ");
+      break;
+    case LC_LOAD_DYLINKER:
+      printf ("LC_LOAD_DYLINKER ");
+      break;
+    case LC_LOAD_DYLIB:
+      printf ("LC_LOAD_DYLIB    ");
+      break;
+    case LC_SYMTAB:
+      printf ("LC_SYMTAB        ");
+      break;
+    case LC_DYSYMTAB:
+      printf ("LC_DYSYMTAB      ");
+      break;
+    case LC_UNIXTHREAD:
+      printf ("LC_UNIXTHREAD    ");
+      break;
+    case LC_PREBOUND_DYLIB:
+      printf ("LC_PREBOUND_DYLIB");
+      break;
+    case LC_TWOLEVEL_HINTS:
+      printf ("LC_TWOLEVEL_HINTS");
+      break;
+    default:
+      printf ("unknown          ");
+    }
+}
+
+static void
+print_load_command (struct load_command *lc)
+{
+  print_load_command_name (lc->cmd);
+  printf ("%8d", lc->cmdsize);
+
+  if (lc->cmd == LC_SEGMENT)
+    {
+      struct segment_command *scp;
+      struct section *sectp;
+      int j;
+
+      scp = (struct segment_command *) lc;
+      printf (" %-16.16s %#10x %#8x\n",
+             scp->segname, scp->vmaddr, scp->vmsize);
+
+      sectp = (struct section *) (scp + 1);
+      for (j = 0; j < scp->nsects; j++)
+       {
+         printf ("                           %-16.16s %#10x %#8x\n",
+                 sectp->sectname, sectp->addr, sectp->size);
+         sectp++;
+       }
+    }
+  else
+    printf ("\n");
+}
+
+/* Read header and load commands from input file.  Store the latter in
+   the global array lca.  Store the total number of load commands in
+   global variable nlc.  */
+static void
+read_load_commands ()
+{
+  int n, i, j;
+
+  if (!unexec_read (&mh, sizeof (struct mach_header)))
+    unexec_error ("cannot read mach-o header");
+
+  if (mh.magic != MH_MAGIC)
+    unexec_error ("input file not in Mach-O format");
+
+  if (mh.filetype != MH_EXECUTE)
+    unexec_error ("input Mach-O file is not an executable object file");
+
+#if VERBOSE
+  printf ("--- Header Information ---\n");
+  printf ("Magic = 0x%08x\n", mh.magic);
+  printf ("CPUType = %d\n", mh.cputype);
+  printf ("CPUSubType = %d\n", mh.cpusubtype);
+  printf ("FileType = 0x%x\n", mh.filetype);
+  printf ("NCmds = %d\n", mh.ncmds);
+  printf ("SizeOfCmds = %d\n", mh.sizeofcmds);
+  printf ("Flags = 0x%08x\n", mh.flags);
+#endif
+
+  nlc = mh.ncmds;
+  lca = (struct load_command **) malloc (nlc * sizeof (struct load_command *));
+  
+  for (i = 0; i < nlc; i++)
+    {
+      struct load_command lc;
+      /* Load commands are variable-size: so read the command type and
+        size first and then read the rest.  */
+      if (!unexec_read (&lc, sizeof (struct load_command)))
+        unexec_error ("cannot read load command");
+      lca[i] = (struct load_command *) malloc (lc.cmdsize);
+      memcpy (lca[i], &lc, sizeof (struct load_command));
+      if (!unexec_read (lca[i] + 1, lc.cmdsize - sizeof (struct load_command)))
+        unexec_error ("cannot read content of load command");
+      if (lc.cmd == LC_SEGMENT)
+       {
+         struct segment_command *scp = (struct segment_command *) lca[i];
+         
+         if (scp->vmaddr + scp->vmsize > infile_lc_highest_addr)
+           infile_lc_highest_addr = scp->vmaddr + scp->vmsize;
+
+         if (strncmp (scp->segname, SEG_TEXT, 16) == 0)
+           {
+             struct section *sectp = (struct section *) (scp + 1);
+             int j;
+
+             for (j = 0; j < scp->nsects; j++)
+               if (sectp->offset < text_seg_lowest_offset)
+                 text_seg_lowest_offset = sectp->offset;
+           }
+       }
+    }
+
+  printf ("Highest address of load commands in input file: %#8x\n",
+         infile_lc_highest_addr);
+
+  printf ("Lowest offset of all sections in __TEXT segment: %#8x\n",
+         text_seg_lowest_offset);
+
+  printf ("--- List of Load Commands in Input File ---\n");
+  printf ("# cmd              cmdsize name                address     size\n");
+
+  for (i = 0; i < nlc; i++)
+    {
+      printf ("%1d ", i);
+      print_load_command (lca[i]);
+    }
+}
+
+/* Copy a LC_SEGMENT load command other than the __DATA segment from
+   the input file to the output file, adjusting the file offset of the
+   segment and the file offsets of sections contained in it.  */
+static void
+copy_segment (struct load_command *lc)
+{
+  struct segment_command *scp = (struct segment_command *) lc;
+  unsigned long old_fileoff = scp->fileoff;
+  struct section *sectp;
+  int j;
+
+  scp->fileoff += delta;
+
+  sectp = (struct section *) (scp + 1);
+  for (j = 0; j < scp->nsects; j++)
+    {
+      sectp->offset += delta;
+      sectp++;
+    }
+
+  printf ("Writing segment %-16.16s at %#8x - %#8x (sz: %#8x)\n",
+         scp->segname, scp->fileoff, scp->fileoff + scp->filesize,
+         scp->filesize);
+
+  if (!unexec_copy (scp->fileoff, old_fileoff, scp->filesize))
+    unexec_error ("cannot copy segment from input to output file");
+  if (!unexec_write (curr_header_offset, lc, lc->cmdsize))
+    unexec_error ("cannot write load command to header");
+
+  curr_header_offset += lc->cmdsize;
+}
+
+/* Copy a LC_SEGMENT load command for the __DATA segment in the input
+   file to the output file.  We assume that only one such segment load
+   command exists in the input file and it contains the sections
+   __data, __bss, __common, __la_symbol_ptr, __nl_symbol_ptr, and
+   __dyld.  The first three of these should be dumped from memory and
+   the rest should be copied from the input file.  Note that the
+   sections __bss and __common contain no data in the input file
+   because their flag fields have the value S_ZEROFILL.  Dumping these
+   from memory makes it necessary to adjust file offset fields in
+   subsequently dumped load commands.  Then, create new __DATA segment
+   load commands for regions on the region list other than the one
+   corresponding to the __DATA segment in the input file.  */
+static void
+copy_data_segment (struct load_command *lc)
+{
+  struct segment_command *scp = (struct segment_command *) lc;
+  struct section *sectp;
+  int j;
+  unsigned long header_offset, file_offset, old_file_offset;
+  struct region_t *r;
+
+  printf ("Writing segment %-16.16s at %#8x - %#8x (sz: %#8x)\n",
+         scp->segname, scp->fileoff, scp->fileoff + scp->filesize,
+         scp->filesize);
+
+  if (delta != 0)
+    unexec_error ("cannot handle multiple DATA segments in input file");
+
+  /* Offsets in the output file for writing the next section structure
+     and segment data block, respectively.  */
+  header_offset = curr_header_offset + sizeof (struct segment_command);
+
+  sectp = (struct section *) (scp + 1);
+  for (j = 0; j < scp->nsects; j++)
+    {
+      old_file_offset = sectp->offset;
+      sectp->offset = sectp->addr - scp->vmaddr + scp->fileoff;
+      /* The __data section is dumped from memory.  The __bss and
+        __common sections are also dumped from memory but their flag
+        fields require changing (from S_ZEROFILL to S_REGULAR).  The
+        other three kinds of sections are just copied from the input
+        file.  */
+      if (strncmp (sectp->sectname, SECT_DATA, 16) == 0)
+       {
+         if (!unexec_write (sectp->offset, (void *) sectp->addr, sectp->size))
+           unexec_error ("cannot write section %s", SECT_DATA);
+         if (!unexec_write (header_offset, sectp, sizeof (struct section)))
+           unexec_error ("cannot write section %s's header", SECT_DATA);
+       }
+      else if (strncmp (sectp->sectname, SECT_BSS, 16) == 0
+              || strncmp (sectp->sectname, SECT_COMMON, 16) == 0)
+       {
+         sectp->flags = S_REGULAR;
+         if (!unexec_write (sectp->offset, (void *) sectp->addr, sectp->size))
+           unexec_error ("cannot write section %s", SECT_DATA);
+         if (!unexec_write (header_offset, sectp, sizeof (struct section)))
+           unexec_error ("cannot write section %s's header", SECT_DATA);
+       }
+      else if (strncmp (sectp->sectname, "__la_symbol_ptr", 16) == 0
+              || strncmp (sectp->sectname, "__nl_symbol_ptr", 16) == 0
+              || strncmp (sectp->sectname, "__dyld", 16) == 0
+              || strncmp (sectp->sectname, "__const", 16) == 0)
+       {
+         if (!unexec_copy (sectp->offset, old_file_offset, sectp->size))
+           unexec_error ("cannot copy section %s", sectp->sectname);
+         if (!unexec_write (header_offset, sectp, sizeof (struct section)))
+           unexec_error ("cannot write section %s's header", sectp->sectname);
+       }
+      else
+       unexec_error ("unrecognized section name in __DATA segment");
+      
+      printf ("        section %-16.16s at %#8x - %#8x (sz: %#8x)\n",
+             sectp->sectname, sectp->offset, sectp->offset + sectp->size,
+             sectp->size);
+
+      header_offset += sizeof (struct section);
+      sectp++;
+    }
+
+  /* The new filesize of the segment is set to its vmsize because data
+     blocks for segments must start at region boundaries.  Note that
+     this may leave unused locations at the end of the segment data
+     block because the total of the sizes of all sections in the
+     segment is generally smaller than vmsize.  */
+  delta = scp->vmsize - scp->filesize;
+  scp->filesize = scp->vmsize;
+  if (!unexec_write (curr_header_offset, scp, sizeof (struct segment_command)))
+    unexec_error ("cannot write header of __DATA segment");
+  curr_header_offset += lc->cmdsize;
+
+  /* Create new __DATA segment load commands for regions on the region
+     list that do not corresponding to any segment load commands in
+     the input file.
+     */
+  file_offset = scp->fileoff + scp->filesize;
+  for (j = 0; j < num_unexec_regions; j++)
+    {
+      struct segment_command sc;
+      
+      sc.cmd = LC_SEGMENT;
+      sc.cmdsize = sizeof (struct segment_command);
+      strncpy (sc.segname, SEG_DATA, 16);
+      sc.vmaddr = unexec_regions[j].address;
+      sc.vmsize = unexec_regions[j].size;
+      sc.fileoff = file_offset;
+      sc.filesize = unexec_regions[j].size;
+      sc.maxprot = VM_PROT_READ | VM_PROT_WRITE;
+      sc.initprot = VM_PROT_READ | VM_PROT_WRITE;
+      sc.nsects = 0;
+      sc.flags = 0;
+      
+      printf ("Writing segment %-16.16s at %#8x - %#8x (sz: %#8x)\n",
+             sc.segname, sc.fileoff, sc.fileoff + sc.filesize,
+             sc.filesize);
+
+      if (!unexec_write (sc.fileoff, (void *) sc.vmaddr, sc.vmsize))
+       unexec_error ("cannot write new __DATA segment");
+      delta += sc.filesize;
+      file_offset += sc.filesize;
+      
+      if (!unexec_write (curr_header_offset, &sc, sc.cmdsize))
+       unexec_error ("cannot write new __DATA segment's header");
+      curr_header_offset += sc.cmdsize;
+      mh.ncmds++;
+    }
+}
+
+/* Copy a LC_SYMTAB load command from the input file to the output
+   file, adjusting the file offset fields.  */
+static void
+copy_symtab (struct load_command *lc)
+{
+  struct symtab_command *stp = (struct symtab_command *) lc;
+
+  stp->symoff += delta;
+  stp->stroff += delta;
+
+  printf ("Writing LC_SYMTAB command\n");
+
+  if (!unexec_write (curr_header_offset, lc, lc->cmdsize))
+    unexec_error ("cannot write symtab command to header");
+
+  curr_header_offset += lc->cmdsize;
+}
+
+/* Copy a LC_DYSYMTAB load command from the input file to the output
+   file, adjusting the file offset fields.  */
+static void
+copy_dysymtab (struct load_command *lc)
+{
+  struct dysymtab_command *dstp = (struct dysymtab_command *) lc;
+
+  /* If Mach-O executable is not prebound, relocation entries need
+     fixing up.  This is not supported currently.  */
+  if (!(mh.flags & MH_PREBOUND) && (dstp->nextrel != 0 || dstp->nlocrel != 0))
+    unexec_error ("cannot handle LC_DYSYMTAB with relocation entries");
+
+  if (dstp->nextrel > 0) {
+    dstp->extreloff += delta;
+  }
+
+  if (dstp->nlocrel > 0) {
+    dstp->locreloff += delta;
+  }
+
+  if (dstp->nindirectsyms > 0)
+    dstp->indirectsymoff += delta;
+
+  printf ("Writing LC_DYSYMTAB command\n");
+
+  if (!unexec_write (curr_header_offset, lc, lc->cmdsize))
+    unexec_error ("cannot write symtab command to header");
+
+  curr_header_offset += lc->cmdsize;
+}
+
+/* Copy other kinds of load commands from the input file to the output
+   file, ones that do not require adjustments of file offsets.  */
+static void
+copy_other (struct load_command *lc)
+{
+  printf ("Writing ");
+  print_load_command_name (lc->cmd);
+  printf (" command\n");
+
+  if (!unexec_write (curr_header_offset, lc, lc->cmdsize))
+    unexec_error ("cannot write symtab command to header");
+
+  curr_header_offset += lc->cmdsize;
+}
+
+/* Loop through all load commands and dump them.  Then write the Mach
+   header.  */
+static void
+dump_it ()
+{
+  int i;
+
+  printf ("--- Load Commands written to Output File ---\n");
+
+  for (i = 0; i < nlc; i++)
+    switch (lca[i]->cmd)
+      {
+      case LC_SEGMENT:
+       {
+         struct segment_command *scp = (struct segment_command *) lca[i];
+         if (strncmp (scp->segname, SEG_DATA, 16) == 0)
+           {
+             copy_data_segment (lca[i]);
+           }
+         else
+           {
+             copy_segment (lca[i]);
+           }
+       }
+       break;
+      case LC_SYMTAB:
+       copy_symtab (lca[i]);
+       break;
+      case LC_DYSYMTAB:
+       copy_dysymtab (lca[i]);
+       break;
+      default:
+       copy_other (lca[i]);
+       break;
+      }
+
+  if (curr_header_offset > text_seg_lowest_offset)
+    unexec_error ("not enough room for load commands for new __DATA segments");
+
+  printf ("%d unused bytes follow Mach-O header\n",
+         text_seg_lowest_offset - curr_header_offset);
+
+  mh.sizeofcmds = curr_header_offset - sizeof (struct mach_header);
+  if (!unexec_write (0, &mh, sizeof (struct mach_header)))
+    unexec_error ("cannot write final header contents");
+}
+
+/* Take a snapshot of Emacs and make a Mach-O format executable file
+   from it.  The file names of the output and input files are outfile
+   and infile, respectively.  The three other parameters are
+   ignored.  */
+void
+unexec (char *outfile, char *infile, void *start_data, void *start_bss,
+        void *entry_address)
+{
+  infd = open (infile, O_RDONLY, 0);
+  if (infd < 0)
+    {
+      unexec_error ("cannot open input file `%s'", infile);
+    }
+        
+  outfd = open (outfile, O_WRONLY | O_TRUNC | O_CREAT, 0755);
+  if (outfd < 0)
+    {
+      close (infd);
+      unexec_error ("cannot open output file `%s'", outfile);
+    }
+
+  build_region_list ();
+  read_load_commands ();
+
+  find_emacs_zone_regions ();
+
+  in_dumped_exec = 1;
+
+  dump_it ();
+
+  close (outfd);
+}
+
+
+void
+unexec_init_emacs_zone ()
+{
+  emacs_zone = malloc_create_zone (0, 0);
+  malloc_set_zone_name (emacs_zone, "EmacsZone");
+}
+
+int
+ptr_in_unexec_regions (void *ptr)
+{
+  int i;
+
+  for (i = 0; i < num_unexec_regions; i++)
+    if ((vm_address_t) ptr - unexec_regions[i].address
+       < unexec_regions[i].size)
+      return 1;
+
+  return 0;
+}
+
+void *
+unexec_malloc (size_t size)
+{
+  if (in_dumped_exec)
+    return malloc (size);
+  else
+    return malloc_zone_malloc (emacs_zone, size);
+}
+
+void *
+unexec_realloc (void *old_ptr, size_t new_size)
+{
+  if (in_dumped_exec)
+    if (ptr_in_unexec_regions (old_ptr))
+      {
+       char *p = malloc (new_size);
+       /* 2002-04-15 T. Ikegami <ikegami@adam.uprr.pr>.  The original
+          code to get size failed to reallocate read_buffer
+          (lread.c).  */
+       int old_size = emacs_zone->size (emacs_zone, old_ptr);
+       int size = new_size > old_size ? old_size : new_size;
+
+       if (size)
+         memcpy (p, old_ptr, size);
+       return p;
+      }
+    else
+      return realloc (old_ptr, new_size);
+  else
+    return malloc_zone_realloc (emacs_zone, old_ptr, new_size);
+}
+
+void
+unexec_free (void *ptr)
+{
+  if (in_dumped_exec)
+    {
+      if (!ptr_in_unexec_regions (ptr))
+       free (ptr);
+    }
+  else
+    malloc_zone_free (emacs_zone, ptr);
+}
index 4dc8329..24a95dc 100644 (file)
@@ -44,7 +44,7 @@ Boston, MA 02111-1307, USA.  */
 #ifdef MSDOS
 #include "msdos.h"
 #endif
-#ifdef macintosh
+#ifdef MAC_OS
 #include "macterm.h"
 #endif
 
index 4764bfb..5eaf833 100644 (file)
@@ -194,13 +194,13 @@ Boston, MA 02111-1307, USA.  */
 #ifdef WINDOWSNT
 #include "w32term.h"
 #endif
-#ifdef macintosh
+#ifdef MAC_OS
 #include "macterm.h"
 #endif
 
 #define INFINITY 10000000
 
-#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (macintosh)
+#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (MAC_OS)
 extern void set_frame_menubar P_ ((struct frame *f, int, int));
 extern int pending_menu_activation;
 #endif
@@ -7077,7 +7077,7 @@ echo_area_display (update_frame_p)
     return 0;
 
 /* The terminal frame is used as the first Emacs frame on the Mac OS.  */
-#ifndef macintosh
+#ifndef MAC_OS8
 #ifdef HAVE_WINDOW_SYSTEM
   /* When Emacs starts, selected_frame may be a visible terminal
      frame, even if we run under a window system.  If we let this
@@ -7450,7 +7450,7 @@ update_menu_bar (f, save_match_data)
 
   if (FRAME_WINDOW_P (f)
       ?
-#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (macintosh)
+#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (MAC_OS)
       FRAME_EXTERNAL_MENU_BAR (f) 
 #else
       FRAME_MENU_BAR_LINES (f) > 0
@@ -7501,9 +7501,9 @@ update_menu_bar (f, save_match_data)
          FRAME_MENU_BAR_ITEMS (f) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f));
          
          /* Redisplay the menu bar in case we changed it.  */
-#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (macintosh)
+#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (MAC_OS)
          if (FRAME_WINDOW_P (f)
-#if defined (macintosh)
+#if defined (MAC_OS)
               /* All frames on Mac OS share the same menubar.  So only the
                  selected frame should be allowed to set it.  */
               && f == SELECTED_FRAME ()
@@ -10647,7 +10647,7 @@ redisplay_window (window, just_this_one_p)
 
       if (FRAME_WINDOW_P (f))
        {
-#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (macintosh)
+#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (MAC_OS)
          redisplay_menu_p = FRAME_EXTERNAL_MENU_BAR (f);
 #else
          redisplay_menu_p = FRAME_MENU_BAR_LINES (f) > 0;
@@ -13379,7 +13379,7 @@ display_menu_bar (w)
   if (FRAME_X_P (f))
     return;
 #endif
-#ifdef macintosh
+#ifdef MAC_OS
   if (FRAME_MAC_P (f))
     return;
 #endif
index 256bb3a..9e37f09 100644 (file)
@@ -234,32 +234,11 @@ Boston, MA 02111-1307, USA.  */
 #define FONT_WIDTH FONT_MAX_WIDTH
 #endif /* WINDOWSNT */
 
-#ifdef macintosh
+#ifdef MAC_OS
 #include "macterm.h"
 #define x_display_info mac_display_info
 #define check_x check_mac
-
-extern XGCValues *XCreateGC (void *, WindowPtr, unsigned long, XGCValues *);
-
-static INLINE GC
-x_create_gc (f, mask, xgcv)
-     struct frame *f;
-     unsigned long mask;
-     XGCValues *xgcv;
-{
-  GC gc;
-  gc = XCreateGC (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), mask, xgcv);
-  return gc;
-}
-
-static INLINE void
-x_free_gc (f, gc)
-     struct frame *f;
-     GC gc;
-{
-  XFreeGC (FRAME_MAC_DISPLAY (f), gc);
-}
-#endif
+#endif /* MAC_OS */
 
 #include "buffer.h"
 #include "dispextern.h"
@@ -814,6 +793,32 @@ x_free_gc (f, gc)
 
 #endif  /* WINDOWSNT */
 
+#ifdef MAC_OS
+/* Mac OS emulation of GCs */
+
+extern XGCValues *XCreateGC (void *, Window, unsigned long, XGCValues *);
+
+static INLINE GC
+x_create_gc (f, mask, xgcv)
+     struct frame *f;
+     unsigned long mask;
+     XGCValues *xgcv;
+{
+  GC gc;
+  gc = XCreateGC (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), mask, xgcv);
+  return gc;
+}
+
+static INLINE void
+x_free_gc (f, gc)
+     struct frame *f;
+     GC gc;
+{
+  XFreeGC (FRAME_MAC_DISPLAY (f), gc);
+}
+
+#endif  /* MAC_OS */
+
 /* Like stricmp.  Used to compare parts of font names which are in
    ISO8859-1.  */
 
@@ -1382,7 +1387,7 @@ defined_color (f, color_name, color_def, alloc)
   else if (FRAME_W32_P (f))
     return w32_defined_color (f, color_name, color_def, alloc);
 #endif
-#ifdef macintosh
+#ifdef MAC_OS
   else if (FRAME_MAC_P (f))
     return mac_defined_color (f, color_name, color_def, alloc);
 #endif
@@ -1889,7 +1894,7 @@ static struct frame *font_frame;
    font height, then for weight, then for slant.'  This variable can be
    set via set-face-font-sort-order.  */
 
-#ifdef macintosh
+#ifdef MAC_OS
 static int font_sort_order[4] = {
   XLFD_SWIDTH, XLFD_POINT_SIZE, XLFD_WEIGHT, XLFD_SLANT
 };
@@ -4341,7 +4346,7 @@ DEFUN ("internal-face-x-get-resource", Finternal_face_x_get_resource,
 {
   Lisp_Object value = Qnil;
 #ifndef WINDOWSNT
-#ifndef macintosh
+#ifndef MAC_OS
   CHECK_STRING (resource);
   CHECK_STRING (class);
   CHECK_LIVE_FRAME (frame);
@@ -4349,7 +4354,7 @@ DEFUN ("internal-face-x-get-resource", Finternal_face_x_get_resource,
   value = display_x_get_resource (FRAME_X_DISPLAY_INFO (XFRAME (frame)),
                                  resource, class, Qnil, Qnil);
   UNBLOCK_INPUT;
-#endif /* not macintosh */
+#endif /* not MAC_OS */
 #endif /* not WINDOWSNT */
   return value;
 }
@@ -4997,7 +5002,7 @@ prepare_face_for_display (f, face)
 #ifdef WINDOWSNT
          xgcv.font = face->font;
 #endif
-#ifdef macintosh
+#ifdef MAC_OS
          xgcv.font = face->font;
 #endif
          mask |= GCFont;
@@ -6428,7 +6433,7 @@ realize_x_face (cache, attrs, c, base_face)
       face->fontset = make_fontset_for_ascii_face (f, fontset);
       face->font = NULL;       /* to force realize_face to load font */
 
-#ifdef macintosh
+#ifdef MAC_OS
       /* Load the font if it is specified in ATTRS.  This fixes
          changing frame font on the Mac.  */
       if (STRINGP (attrs[LFACE_FONT_INDEX]))