changeset 223:2c611d1463a6 r20-4b10

Import from CVS: tag r20-4b10
author cvs
date Mon, 13 Aug 2007 10:10:54 +0200
parents aae4c8b01452
children 4663b37daab6
files CHANGES-beta ChangeLog PROBLEMS configure configure.in etc/BETA etc/NEWS lib-src/ChangeLog lib-src/update-elc.sh lisp/ChangeLog lisp/auto-autoloads.el lisp/cl-macs.el lisp/cus-dep.el lisp/cus-edit.el lisp/cus-start.el lisp/custom.el lisp/dumped-lisp.el lisp/etags.el lisp/files.el lisp/format.el lisp/help.el lisp/keydefs.el lisp/loadup.el lisp/make-docfile.el lisp/mouse.el lisp/mule/mule-debug.el lisp/simple.el lisp/undo-stack.el lisp/update-elc.el lisp/window.el lisp/x-toolbar.el man/ChangeLog man/Makefile nt/ChangeLog nt/puresize-adjust.h nt/xemacs.mak src/ChangeLog src/Makefile.in.in src/bytecode.c src/callint.c src/config.h.in src/console-msw.h src/device-msw.c src/device-tty.c src/device.h src/elhash.c src/elhash.h src/emacs.c src/emacsfns.h src/eval.c src/event-msw.c src/event-msw.h src/events.c src/extents.c src/faces.c src/fileio.c src/fns.c src/frame-msw.c src/frame-tty.c src/frame-x.c src/general.c src/glyphs-x.c src/glyphs.c src/input-method-motif.c src/input-method-xfs.c src/input-method-xlib.c src/intl.c src/msw-proc.c src/nt.c src/ntproc.c src/print.c src/process.c src/pure.c src/redisplay-msw.c src/redisplay.c src/s/windowsnt.h src/signal.c src/symsinit.h src/syssignal.h src/systime.h src/undo.c src/window.c version.sh
diffstat 83 files changed, 3477 insertions(+), 2362 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGES-beta	Mon Aug 13 10:10:03 2007 +0200
+++ b/CHANGES-beta	Mon Aug 13 10:10:54 2007 +0200
@@ -1,4 +1,9 @@
 							-*- indented-text -*-
+to 20.4 beta10 "Barbari"
+-- MS Windows NT updates courtesy of Kirill M. Katsnelson
+-- etags.el update courtesy of Hrvoje Niksic
+-- Miscellaneous bug fixes
+
 to 20.4 beta9 "Australian Goat"
 -- MS Windows patches for clipboard courtesy of Jonathon Harris
 -- ImageMagick support displays images now courtesy of Jareth Hein
--- a/ChangeLog	Mon Aug 13 10:10:03 2007 +0200
+++ b/ChangeLog	Mon Aug 13 10:10:54 2007 +0200
@@ -1,3 +1,22 @@
+1997-12-13  SL Baur  <steve@altair.xemacs.org>
+
+	* XEmacs 20-.4-beta10 is released.
+
+1997-12-12  SL Baur  <steve@altair.xemacs.org>
+
+	* configure.in (CPP): Don't add special CFLAGS for ix86/Linux.
+
+1997-12-10  Karl M. Hegbloom  <karlheg@bittersweet.inetarena.com>
+
+	* configure.in (autodetect ImageMagick): also look for
+ 	"X11/magick/magick.h", and if present, define
+ 	MAGICK_HEADERS_ARE_UNDER_X11
+
+1997-12-11  SL Baur  <steve@altair.xemacs.org>
+
+	* configure.in (imagick_libs): Add autodetection for freetype
+	-lttf library.
+
 1997-12-09  SL Baur <steve@altair.xemacs.org>
 
 	* XEmacs 20.4-beta9 is released.
--- a/PROBLEMS	Mon Aug 13 10:10:03 2007 +0200
+++ b/PROBLEMS	Mon Aug 13 10:10:54 2007 +0200
@@ -13,8 +13,8 @@
  - Mule issues
 
 Use `C-c C-f' to move to the next equal level of outline, and
-`C-c C-f' to move to previous equal level.  `C-h m' will give more
-advice about the Outline mode.
+`C-c C-b' to move to previous equal level.  `C-h m' will give more
+info about the Outline mode.
 
 Also, Try finding the things you need using one of the search commands
 XEmacs provides (e.g. `C-s').
@@ -29,7 +29,7 @@
 ===============================
 
 ** Don't use -O2 with gcc 2.7.2 under Linux without also using
-   `-fno-strength-reduce'.
+`-fno-strength-reduce'.
 
 gcc will generate incorrect code otherwise.  This bug is present in at
 least 2.6.x and 2.7.[0-2].  This bug has been fixed in GCC 2.7.2.1 and
@@ -1281,7 +1281,7 @@
 cripple emacs.
 
 ** Some packages that worked before now cause the error
-   Wrong type argument: arrayp, #<face ... >
+Wrong type argument: arrayp, #<face ... >
 
 Code which uses the `face' accessor functions must be recompiled with
 xemacs 19.9 or later.  The functions whose callers must be recompiled
@@ -1306,21 +1306,33 @@
 * MULE issues
 =============
 
+** A reminder: XEmacs/Mule work does not currently receive *any*
+funding, and all work is done by volunteers.  If you think you can
+help, please contact the XEmacs maintainers.
+
+** XEmacs/Mule doesn't work on a tty.
+
+This is a major problem, which we plan to address in a future release
+of XEmacs.  Basically, XEmacs should have primitives to be told
+whether the terminal can handle international output, and which
+locale.  Also, it should be able to do approximations of characters to
+the nearest supported by the locale.
+
 ** Internationalized (Asian) Isearch doesn't work.
 
 Currently, Isearch doesn't directly support any of the input methods
 that are not XIM based (like egg, canna and quail) (and there are
-potential problems with XIM version too...). This is something
-we are working on, but for the moment, if you're using egg there is a
-workaround. Hitting <RET> right after C-s to invoke Isearch will put
-Isearch in string mode, where a complete string can be typed into the
-minibuffer and then processed by Isearch afterwards. Since egg is now
-supported in the minibuffer using string mode you can now use egg to
-input your Japanese, Korean or Chinese string, then hit return to send 
-that to Isearch and then use standard Isearch commands from there.
+potential problems with XIM version too...).  If you're using egg
+there is a workaround.  Hitting <RET> right after C-s to invoke
+Isearch will put Isearch in string mode, where a complete string can
+be typed into the minibuffer and then processed by Isearch afterwards.
+Since egg is now supported in the minibuffer using string mode you can
+now use egg to input your Japanese, Korean or Chinese string, then hit
+return to send that to Isearch and then use standard Isearch commands
+from there.
 
-** Using egg or canna and mousing around while in 'fence' mode screws
-up my buffer.
+** Using egg and mousing around while in 'fence' mode screws up my
+buffer.
 
 Don't do this. The fence modes of egg and canna are currently very
 modal, and messing with where they expect point to be and what they
@@ -1330,3 +1342,35 @@
 protect against this where we can, but there still are many ways to
 shoot yourself in the foot. So just finish what you are typing into
 the fence before reaching for the mouse.
+
+** Not all languages in Quail are supported like Devanagari and Indian
+languages, Lao and Tibetan.
+
+Quail requires more work and testing.  Although it has been ported to
+XEmacs, it works really well for Japanese and for the European
+languages.
+
+** Right-to-left mode is not yet implemented, so languages like
+Arabic, Hebrew and Thai don't work.
+
+Getting this right requires more work.  It may be implemented in a
+future XEmacs version, but don't hold your breath.  If you know
+someone who is ready to implement this, please let us know.
+
+** We need more developers and native language testers.  It's extremely
+difficult (and not particularly productive) to address languages that
+nobody is using and testing.
+
+** The kWnn and cWnn support for Chinese and Korean needs developers
+and testers.  It probably doesn't work.
+
+** There are no `native XEmacs' TUTORIALs for any Asian languages,
+including Japanese.  FSF Emacs and XEmacs tutorials are quite similar, 
+so it should be sufficient to skim through the differences and apply
+them to the Japanese version.
+
+** We only have localized menus translated for Japanese, and the
+Japanese menus are developing bitrot (the Mule menu appears in
+English).
+
+** XIM is untested for any language other than Japanese.
--- a/configure	Mon Aug 13 10:10:03 2007 +0200
+++ b/configure	Mon Aug 13 10:10:54 2007 +0200
@@ -2081,9 +2081,7 @@
 if test -z "$CFLAGS"; then
       if   test "$GCC" = "yes"; then
     CFLAGS="-g -O2 -Wall -Wno-switch"
-    test "$opsys $machine" = "linux intel386" && \
-      CFLAGS="$CFLAGS -fno-strength-reduce -malign-loops=2 -malign-jumps=2 -malign-functions=2"
-  elif test "$__sunpro_c" = "yes"; then
+                elif test "$__sunpro_c" = "yes"; then
     case "$opsys" in
       sol2    ) CFLAGS="-v -xO4" ;;
       sunos4* ) CFLAGS="-xO2";;
@@ -2140,7 +2138,7 @@
  fi
 
 echo $ac_n "checking for dynodump""... $ac_c" 1>&6
-echo "configure:2144: checking for dynodump" >&5
+echo "configure:2142: checking for dynodump" >&5
 if test "$unexec" != "unexsol2.o"; then
   echo "$ac_t""no" 1>&6
 else
@@ -2238,19 +2236,19 @@
 
 if test "$add_runtime_path" = "yes"; then
       echo $ac_n "checking "for runtime libraries flag"""... $ac_c" 1>&6
-echo "configure:2242: checking "for runtime libraries flag"" >&5
+echo "configure:2240: checking "for runtime libraries flag"" >&5
   dash_r=""
   for try_dash_r in "-R" "-R " "-rpath "; do
     xe_check_libs="${try_dash_r}/no/such/file-or-directory"
     cat > conftest.$ac_ext <<EOF
-#line 2247 "configure"
-#include "confdefs.h"
-
-int main() {
-
-; return 0; }
-EOF
-if { (eval echo configure:2254: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+#line 2245 "configure"
+#include "confdefs.h"
+
+int main() {
+
+; return 0; }
+EOF
+if { (eval echo configure:2252: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   dash_r="$try_dash_r"
 else
@@ -2348,7 +2346,7 @@
 # Extract the first word of "ranlib", so it can be a program name with args.
 set dummy ranlib; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2352: checking for $ac_word" >&5
+echo "configure:2350: checking for $ac_word" >&5
 
 if test -n "$RANLIB"; then
   ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
@@ -2401,7 +2399,7 @@
 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
 # ./install, which can be erroneously created by make from ./install.sh.
 echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
-echo "configure:2405: checking for a BSD compatible install" >&5
+echo "configure:2403: checking for a BSD compatible install" >&5
 if test -z "$INSTALL"; then
 
   IFS="${IFS= 	}"; ac_save_IFS="$IFS"; IFS="${IFS}:"
@@ -2452,7 +2450,7 @@
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2456: checking for $ac_word" >&5
+echo "configure:2454: checking for $ac_word" >&5
 
 if test -n "$YACC"; then
   ac_cv_prog_YACC="$YACC" # Let the user override the test.
@@ -2483,15 +2481,15 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:2487: checking for $ac_hdr" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 2490 "configure"
+echo "configure:2485: checking for $ac_hdr" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 2488 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2495: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2493: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -2524,15 +2522,15 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:2528: checking for $ac_hdr" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 2531 "configure"
+echo "configure:2526: checking for $ac_hdr" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 2529 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2536: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2534: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -2565,15 +2563,15 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:2569: checking for $ac_hdr" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 2572 "configure"
+echo "configure:2567: checking for $ac_hdr" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 2570 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2577: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2575: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -2603,10 +2601,10 @@
 done
 
 echo $ac_n "checking for sys/wait.h that is POSIX.1 compatible""... $ac_c" 1>&6
-echo "configure:2607: checking for sys/wait.h that is POSIX.1 compatible" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 2610 "configure"
+echo "configure:2605: checking for sys/wait.h that is POSIX.1 compatible" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 2608 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/wait.h>
@@ -2622,7 +2620,7 @@
 s = WIFEXITED (s) ? WEXITSTATUS (s) : 1;
 ; return 0; }
 EOF
-if { (eval echo configure:2626: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2624: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_header_sys_wait_h=yes
 else
@@ -2646,10 +2644,10 @@
 fi
 
 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:2650: checking for ANSI C header files" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 2653 "configure"
+echo "configure:2648: checking for ANSI C header files" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 2651 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 #include <stdarg.h>
@@ -2657,7 +2655,7 @@
 #include <float.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2661: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2659: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -2674,7 +2672,7 @@
 if test $ac_cv_header_stdc = yes; then
   # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 2678 "configure"
+#line 2676 "configure"
 #include "confdefs.h"
 #include <string.h>
 EOF
@@ -2692,7 +2690,7 @@
 if test $ac_cv_header_stdc = yes; then
   # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 2696 "configure"
+#line 2694 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 EOF
@@ -2710,7 +2708,7 @@
 if test $ac_cv_header_stdc = yes; then
   # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
 cat > conftest.$ac_ext <<EOF
-#line 2714 "configure"
+#line 2712 "configure"
 #include "confdefs.h"
 #include <ctype.h>
 #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -2721,7 +2719,7 @@
 exit (0); }
 
 EOF
-if { (eval echo configure:2725: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
+if { (eval echo configure:2723: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
 then
   :
 else
@@ -2746,10 +2744,10 @@
 fi
 
 echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
-echo "configure:2750: checking whether time.h and sys/time.h may both be included" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 2753 "configure"
+echo "configure:2748: checking whether time.h and sys/time.h may both be included" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 2751 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/time.h>
@@ -2758,7 +2756,7 @@
 struct tm *tp;
 ; return 0; }
 EOF
-if { (eval echo configure:2762: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2760: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_header_time=yes
 else
@@ -2782,10 +2780,10 @@
 fi
 
 echo $ac_n "checking for sys_siglist declaration in signal.h or unistd.h""... $ac_c" 1>&6
-echo "configure:2786: checking for sys_siglist declaration in signal.h or unistd.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 2789 "configure"
+echo "configure:2784: checking for sys_siglist declaration in signal.h or unistd.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 2787 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <signal.h>
@@ -2797,7 +2795,7 @@
 char *msg = *(sys_siglist + 1);
 ; return 0; }
 EOF
-if { (eval echo configure:2801: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2799: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_decl_sys_siglist=yes
 else
@@ -2822,9 +2820,9 @@
 
 
 echo $ac_n "checking for struct utimbuf""... $ac_c" 1>&6
-echo "configure:2826: checking for struct utimbuf" >&5
-cat > conftest.$ac_ext <<EOF
-#line 2828 "configure"
+echo "configure:2824: checking for struct utimbuf" >&5
+cat > conftest.$ac_ext <<EOF
+#line 2826 "configure"
 #include "confdefs.h"
 #ifdef TIME_WITH_SYS_TIME
 #include <sys/time.h>
@@ -2843,7 +2841,7 @@
 static struct utimbuf x; x.actime = x.modtime;
 ; return 0; }
 EOF
-if { (eval echo configure:2847: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2845: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6
    { test "$extra_verbose" = "yes" && cat << \EOF
@@ -2863,10 +2861,10 @@
 rm -f conftest*
 
 echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
-echo "configure:2867: checking return type of signal handlers" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 2870 "configure"
+echo "configure:2865: checking return type of signal handlers" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 2868 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <signal.h>
@@ -2883,7 +2881,7 @@
 int i;
 ; return 0; }
 EOF
-if { (eval echo configure:2887: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2885: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_type_signal=void
 else
@@ -2905,10 +2903,10 @@
 
 
 echo $ac_n "checking for size_t""... $ac_c" 1>&6
-echo "configure:2909: checking for size_t" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 2912 "configure"
+echo "configure:2907: checking for size_t" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 2910 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -2939,10 +2937,10 @@
 fi
 
 echo $ac_n "checking for pid_t""... $ac_c" 1>&6
-echo "configure:2943: checking for pid_t" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 2946 "configure"
+echo "configure:2941: checking for pid_t" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 2944 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -2973,10 +2971,10 @@
 fi
 
 echo $ac_n "checking for uid_t in sys/types.h""... $ac_c" 1>&6
-echo "configure:2977: checking for uid_t in sys/types.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 2980 "configure"
+echo "configure:2975: checking for uid_t in sys/types.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 2978 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 EOF
@@ -3012,10 +3010,10 @@
 fi
 
 echo $ac_n "checking for mode_t""... $ac_c" 1>&6
-echo "configure:3016: checking for mode_t" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3019 "configure"
+echo "configure:3014: checking for mode_t" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3017 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -3046,10 +3044,10 @@
 fi
 
 echo $ac_n "checking for off_t""... $ac_c" 1>&6
-echo "configure:3050: checking for off_t" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3053 "configure"
+echo "configure:3048: checking for off_t" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3051 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -3081,9 +3079,9 @@
 
 
 echo $ac_n "checking for struct timeval""... $ac_c" 1>&6
-echo "configure:3085: checking for struct timeval" >&5
-cat > conftest.$ac_ext <<EOF
-#line 3087 "configure"
+echo "configure:3083: checking for struct timeval" >&5
+cat > conftest.$ac_ext <<EOF
+#line 3085 "configure"
 #include "confdefs.h"
 #ifdef TIME_WITH_SYS_TIME
 #include <sys/time.h>
@@ -3099,7 +3097,7 @@
 static struct timeval x; x.tv_sec = x.tv_usec;
 ; return 0; }
 EOF
-if { (eval echo configure:3103: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3101: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6
   HAVE_TIMEVAL=yes
@@ -3121,10 +3119,10 @@
 rm -f conftest*
 
 echo $ac_n "checking whether struct tm is in sys/time.h or time.h""... $ac_c" 1>&6
-echo "configure:3125: checking whether struct tm is in sys/time.h or time.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3128 "configure"
+echo "configure:3123: checking whether struct tm is in sys/time.h or time.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3126 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <time.h>
@@ -3132,7 +3130,7 @@
 struct tm *tp; tp->tm_sec;
 ; return 0; }
 EOF
-if { (eval echo configure:3136: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3134: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_struct_tm=time.h
 else
@@ -3156,10 +3154,10 @@
 fi
 
 echo $ac_n "checking for tm_zone in struct tm""... $ac_c" 1>&6
-echo "configure:3160: checking for tm_zone in struct tm" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3163 "configure"
+echo "configure:3158: checking for tm_zone in struct tm" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3161 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <$ac_cv_struct_tm>
@@ -3167,7 +3165,7 @@
 struct tm tm; tm.tm_zone;
 ; return 0; }
 EOF
-if { (eval echo configure:3171: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3169: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_struct_tm_zone=yes
 else
@@ -3190,10 +3188,10 @@
 
 else
   echo $ac_n "checking for tzname""... $ac_c" 1>&6
-echo "configure:3194: checking for tzname" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3197 "configure"
+echo "configure:3192: checking for tzname" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3195 "configure"
 #include "confdefs.h"
 #include <time.h>
 #ifndef tzname /* For SGI.  */
@@ -3203,7 +3201,7 @@
 atoi(*tzname);
 ; return 0; }
 EOF
-if { (eval echo configure:3207: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3205: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   ac_cv_var_tzname=yes
 else
@@ -3229,10 +3227,10 @@
 
 
 echo $ac_n "checking for working const""... $ac_c" 1>&6
-echo "configure:3233: checking for working const" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3236 "configure"
+echo "configure:3231: checking for working const" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3234 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -3281,7 +3279,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:3285: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3283: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_const=yes
 else
@@ -3306,7 +3304,7 @@
 
 
 echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
-echo "configure:3310: checking whether ${MAKE-make} sets \${MAKE}" >&5
+echo "configure:3308: checking whether ${MAKE-make} sets \${MAKE}" >&5
 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
 
 cat > conftestmake <<\EOF
@@ -3331,12 +3329,12 @@
 
 
 echo $ac_n "checking whether byte ordering is bigendian""... $ac_c" 1>&6
-echo "configure:3335: checking whether byte ordering is bigendian" >&5
+echo "configure:3333: checking whether byte ordering is bigendian" >&5
 
 ac_cv_c_bigendian=unknown
 # See if sys/param.h defines the BYTE_ORDER macro.
 cat > conftest.$ac_ext <<EOF
-#line 3340 "configure"
+#line 3338 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/param.h>
@@ -3347,11 +3345,11 @@
 #endif
 ; return 0; }
 EOF
-if { (eval echo configure:3351: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3349: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   # It does; now see whether it defined to BIG_ENDIAN or not.
 cat > conftest.$ac_ext <<EOF
-#line 3355 "configure"
+#line 3353 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/param.h>
@@ -3362,7 +3360,7 @@
 #endif
 ; return 0; }
 EOF
-if { (eval echo configure:3366: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3364: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_bigendian=yes
 else
@@ -3379,7 +3377,7 @@
 rm -f conftest*
 if test $ac_cv_c_bigendian = unknown; then
 cat > conftest.$ac_ext <<EOF
-#line 3383 "configure"
+#line 3381 "configure"
 #include "confdefs.h"
 main () {
   /* Are we little or big endian?  From Harbison&Steele.  */
@@ -3392,7 +3390,7 @@
   exit (u.c[sizeof (long) - 1] == 1);
 }
 EOF
-if { (eval echo configure:3396: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
+if { (eval echo configure:3394: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
 then
   ac_cv_c_bigendian=no
 else
@@ -3418,10 +3416,10 @@
 
 
 echo $ac_n "checking size of short""... $ac_c" 1>&6
-echo "configure:3422: checking size of short" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3425 "configure"
+echo "configure:3420: checking size of short" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3423 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 main()
@@ -3432,7 +3430,7 @@
   exit(0);
 }
 EOF
-if { (eval echo configure:3436: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
+if { (eval echo configure:3434: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
 then
   ac_cv_sizeof_short=`cat conftestval`
 else
@@ -3459,10 +3457,10 @@
   exit 1
 fi
 echo $ac_n "checking size of int""... $ac_c" 1>&6
-echo "configure:3463: checking size of int" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3466 "configure"
+echo "configure:3461: checking size of int" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3464 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 main()
@@ -3473,7 +3471,7 @@
   exit(0);
 }
 EOF
-if { (eval echo configure:3477: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
+if { (eval echo configure:3475: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
 then
   ac_cv_sizeof_int=`cat conftestval`
 else
@@ -3494,10 +3492,10 @@
 
 
 echo $ac_n "checking size of long""... $ac_c" 1>&6
-echo "configure:3498: checking size of long" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3501 "configure"
+echo "configure:3496: checking size of long" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3499 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 main()
@@ -3508,7 +3506,7 @@
   exit(0);
 }
 EOF
-if { (eval echo configure:3512: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
+if { (eval echo configure:3510: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
 then
   ac_cv_sizeof_long=`cat conftestval`
 else
@@ -3529,10 +3527,10 @@
 
 
 echo $ac_n "checking size of long long""... $ac_c" 1>&6
-echo "configure:3533: checking size of long long" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3536 "configure"
+echo "configure:3531: checking size of long long" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3534 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 main()
@@ -3543,7 +3541,7 @@
   exit(0);
 }
 EOF
-if { (eval echo configure:3547: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
+if { (eval echo configure:3545: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
 then
   ac_cv_sizeof_long_long=`cat conftestval`
 else
@@ -3564,10 +3562,10 @@
 
 
 echo $ac_n "checking size of void *""... $ac_c" 1>&6
-echo "configure:3568: checking size of void *" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 3571 "configure"
+echo "configure:3566: checking size of void *" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 3569 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 main()
@@ -3578,7 +3576,7 @@
   exit(0);
 }
 EOF
-if { (eval echo configure:3582: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
+if { (eval echo configure:3580: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
 then
   ac_cv_sizeof_void_p=`cat conftestval`
 else
@@ -3600,7 +3598,7 @@
 
 
 echo $ac_n "checking for long file names""... $ac_c" 1>&6
-echo "configure:3604: checking for long file names" >&5
+echo "configure:3602: checking for long file names" >&5
 
 ac_cv_sys_long_file_names=yes
 # Test for long file names in all the places we know might matter:
@@ -3647,12 +3645,12 @@
 
 
 echo $ac_n "checking for sin in -lm""... $ac_c" 1>&6
-echo "configure:3651: checking for sin in -lm" >&5
+echo "configure:3649: checking for sin in -lm" >&5
 ac_lib_var=`echo m'_'sin | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lm "
 cat > conftest.$ac_ext <<EOF
-#line 3656 "configure"
+#line 3654 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3663,7 +3661,7 @@
 sin()
 ; return 0; }
 EOF
-if { (eval echo configure:3667: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3665: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3705,7 +3703,7 @@
 
 
 echo "checking type of mail spool file locking" 1>&6
-echo "configure:3709: checking type of mail spool file locking" >&5
+echo "configure:3707: checking type of mail spool file locking" >&5
 test -z "$mail_locking" -a "$mail_use_flock" = "yes" && mail_locking=flock
 test -z "$mail_locking" -a "$mail_use_lockf" = "yes" && mail_locking=lockf
 if   test "$mail_locking" = "lockf"; then { test "$extra_verbose" = "yes" && cat << \EOF
@@ -3729,12 +3727,12 @@
 
 
 echo $ac_n "checking for kstat_open in -lkstat""... $ac_c" 1>&6
-echo "configure:3733: checking for kstat_open in -lkstat" >&5
+echo "configure:3731: checking for kstat_open in -lkstat" >&5
 ac_lib_var=`echo kstat'_'kstat_open | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lkstat "
 cat > conftest.$ac_ext <<EOF
-#line 3738 "configure"
+#line 3736 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3745,7 +3743,7 @@
 kstat_open()
 ; return 0; }
 EOF
-if { (eval echo configure:3749: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3747: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3779,12 +3777,12 @@
 
 
 echo $ac_n "checking for kvm_read in -lkvm""... $ac_c" 1>&6
-echo "configure:3783: checking for kvm_read in -lkvm" >&5
+echo "configure:3781: checking for kvm_read in -lkvm" >&5
 ac_lib_var=`echo kvm'_'kvm_read | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lkvm "
 cat > conftest.$ac_ext <<EOF
-#line 3788 "configure"
+#line 3786 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3795,7 +3793,7 @@
 kvm_read()
 ; return 0; }
 EOF
-if { (eval echo configure:3799: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3797: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3829,12 +3827,12 @@
 
 
 echo $ac_n "checking for cma_open in -lpthreads""... $ac_c" 1>&6
-echo "configure:3833: checking for cma_open in -lpthreads" >&5
+echo "configure:3831: checking for cma_open in -lpthreads" >&5
 ac_lib_var=`echo pthreads'_'cma_open | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lpthreads "
 cat > conftest.$ac_ext <<EOF
-#line 3838 "configure"
+#line 3836 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3845,7 +3843,7 @@
 cma_open()
 ; return 0; }
 EOF
-if { (eval echo configure:3849: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3847: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3881,7 +3879,7 @@
 fi
 
 echo $ac_n "checking whether the -xildoff compiler flag is required""... $ac_c" 1>&6
-echo "configure:3885: checking whether the -xildoff compiler flag is required" >&5
+echo "configure:3883: checking whether the -xildoff compiler flag is required" >&5
 if   ${CC-cc} '-###' -xildon  no_such_file.c 2>&1 | grep '^[^ ]*/ild ' > /dev/null ; then
   if ${CC-cc} '-###' -xildoff no_such_file.c 2>&1 | grep '^[^ ]*/ild ' > /dev/null ;
     then echo "$ac_t""no" 1>&6;
@@ -3892,7 +3890,7 @@
 
 if test "$opsys" = "sol2" && test "$OS_RELEASE" -ge 56; then
   echo $ac_n "checking for \"-z ignore\" linker flag""... $ac_c" 1>&6
-echo "configure:3896: checking for \"-z ignore\" linker flag" >&5
+echo "configure:3894: checking for \"-z ignore\" linker flag" >&5
   case "`ld -h 2>&1`" in
     *-z\ ignore\|record* ) echo "$ac_t""yes" 1>&6
       ld_switch_site="-z ignore $ld_switch_site" &&  if test "$extra_verbose" = "yes"; then echo "    Prepending \"-z ignore\" to \$ld_switch_site"; fi ;;
@@ -3902,7 +3900,7 @@
 
 
 echo "checking "for specified window system"" 1>&6
-echo "configure:3906: checking "for specified window system"" >&5
+echo "configure:3904: checking "for specified window system"" >&5
 
 if test "$with_x11" != "no"; then
     test "$x_includes $x_libraries" != "NONE NONE" && \
@@ -3932,7 +3930,7 @@
 # Uses ac_ vars as temps to allow command line to override cache and checks.
 # --without-x overrides everything else, but does not touch the cache.
 echo $ac_n "checking for X""... $ac_c" 1>&6
-echo "configure:3936: checking for X" >&5
+echo "configure:3934: checking for X" >&5
 
 # Check whether --with-x or --without-x was given.
 if test "${with_x+set}" = set; then
@@ -3992,12 +3990,12 @@
 
   # First, try using that file with no special directory specified.
 cat > conftest.$ac_ext <<EOF
-#line 3996 "configure"
+#line 3994 "configure"
 #include "confdefs.h"
 #include <$x_direct_test_include>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4001: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3999: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -4066,14 +4064,14 @@
   ac_save_LIBS="$LIBS"
   LIBS="-l$x_direct_test_library $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4070 "configure"
+#line 4068 "configure"
 #include "confdefs.h"
 
 int main() {
 ${x_direct_test_function}()
 ; return 0; }
 EOF
-if { (eval echo configure:4077: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4075: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   LIBS="$ac_save_LIBS"
 # We can link X programs with no special library path.
@@ -4182,17 +4180,17 @@
     case "`(uname -sr) 2>/dev/null`" in
     "SunOS 5"*)
       echo $ac_n "checking whether -R must be followed by a space""... $ac_c" 1>&6
-echo "configure:4186: checking whether -R must be followed by a space" >&5
+echo "configure:4184: checking whether -R must be followed by a space" >&5
       ac_xsave_LIBS="$LIBS"; LIBS="$LIBS -R$x_libraries"
       cat > conftest.$ac_ext <<EOF
-#line 4189 "configure"
-#include "confdefs.h"
-
-int main() {
-
-; return 0; }
-EOF
-if { (eval echo configure:4196: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+#line 4187 "configure"
+#include "confdefs.h"
+
+int main() {
+
+; return 0; }
+EOF
+if { (eval echo configure:4194: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   ac_R_nospace=yes
 else
@@ -4208,14 +4206,14 @@
       else
 	LIBS="$ac_xsave_LIBS -R $x_libraries"
 	cat > conftest.$ac_ext <<EOF
-#line 4212 "configure"
-#include "confdefs.h"
-
-int main() {
-
-; return 0; }
-EOF
-if { (eval echo configure:4219: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+#line 4210 "configure"
+#include "confdefs.h"
+
+int main() {
+
+; return 0; }
+EOF
+if { (eval echo configure:4217: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   ac_R_space=yes
 else
@@ -4251,12 +4249,12 @@
 else
 
 echo $ac_n "checking for dnet_ntoa in -ldnet""... $ac_c" 1>&6
-echo "configure:4255: checking for dnet_ntoa in -ldnet" >&5
+echo "configure:4253: checking for dnet_ntoa in -ldnet" >&5
 ac_lib_var=`echo dnet'_'dnet_ntoa | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -ldnet "
 cat > conftest.$ac_ext <<EOF
-#line 4260 "configure"
+#line 4258 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -4267,7 +4265,7 @@
 dnet_ntoa()
 ; return 0; }
 EOF
-if { (eval echo configure:4271: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4269: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4291,12 +4289,12 @@
     if test $ac_cv_lib_dnet_dnet_ntoa = no; then
       
 echo $ac_n "checking for dnet_ntoa in -ldnet_stub""... $ac_c" 1>&6
-echo "configure:4295: checking for dnet_ntoa in -ldnet_stub" >&5
+echo "configure:4293: checking for dnet_ntoa in -ldnet_stub" >&5
 ac_lib_var=`echo dnet_stub'_'dnet_ntoa | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -ldnet_stub "
 cat > conftest.$ac_ext <<EOF
-#line 4300 "configure"
+#line 4298 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -4307,7 +4305,7 @@
 dnet_ntoa()
 ; return 0; }
 EOF
-if { (eval echo configure:4311: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4309: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4336,10 +4334,10 @@
     # The nsl library prevents programs from opening the X display
     # on Irix 5.2, according to dickey@clark.net.
     echo $ac_n "checking for gethostbyname""... $ac_c" 1>&6
-echo "configure:4340: checking for gethostbyname" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 4343 "configure"
+echo "configure:4338: checking for gethostbyname" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 4341 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char gethostbyname(); below.  */
@@ -4362,7 +4360,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:4366: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4364: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_gethostbyname=yes"
 else
@@ -4383,12 +4381,12 @@
     if test $ac_cv_func_gethostbyname = no; then
       
 echo $ac_n "checking for gethostbyname in -lnsl""... $ac_c" 1>&6
-echo "configure:4387: checking for gethostbyname in -lnsl" >&5
+echo "configure:4385: checking for gethostbyname in -lnsl" >&5
 ac_lib_var=`echo nsl'_'gethostbyname | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lnsl "
 cat > conftest.$ac_ext <<EOF
-#line 4392 "configure"
+#line 4390 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -4399,7 +4397,7 @@
 gethostbyname()
 ; return 0; }
 EOF
-if { (eval echo configure:4403: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4401: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4429,10 +4427,10 @@
     # -lsocket must be given before -lnsl if both are needed.
     # We assume that if connect needs -lnsl, so does gethostbyname.
     echo $ac_n "checking for connect""... $ac_c" 1>&6
-echo "configure:4433: checking for connect" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 4436 "configure"
+echo "configure:4431: checking for connect" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 4434 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char connect(); below.  */
@@ -4455,7 +4453,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:4459: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4457: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_connect=yes"
 else
@@ -4478,12 +4476,12 @@
 xe_msg_checking="for connect in -lsocket"
 test -n "$X_EXTRA_LIBS" && xe_msg_checking="$xe_msg_checking using extra libs $X_EXTRA_LIBS"
 echo $ac_n "checking "$xe_msg_checking"""... $ac_c" 1>&6
-echo "configure:4482: checking "$xe_msg_checking"" >&5
+echo "configure:4480: checking "$xe_msg_checking"" >&5
 ac_lib_var=`echo socket'_'connect | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lsocket $X_EXTRA_LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4487 "configure"
+#line 4485 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -4494,7 +4492,7 @@
 connect()
 ; return 0; }
 EOF
-if { (eval echo configure:4498: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4496: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4518,10 +4516,10 @@
 
     # gomez@mi.uni-erlangen.de says -lposix is necessary on A/UX.
     echo $ac_n "checking for remove""... $ac_c" 1>&6
-echo "configure:4522: checking for remove" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 4525 "configure"
+echo "configure:4520: checking for remove" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 4523 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char remove(); below.  */
@@ -4544,7 +4542,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:4548: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4546: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_remove=yes"
 else
@@ -4565,12 +4563,12 @@
     if test $ac_cv_func_remove = no; then
       
 echo $ac_n "checking for remove in -lposix""... $ac_c" 1>&6
-echo "configure:4569: checking for remove in -lposix" >&5
+echo "configure:4567: checking for remove in -lposix" >&5
 ac_lib_var=`echo posix'_'remove | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lposix "
 cat > conftest.$ac_ext <<EOF
-#line 4574 "configure"
+#line 4572 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -4581,7 +4579,7 @@
 remove()
 ; return 0; }
 EOF
-if { (eval echo configure:4585: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4583: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4605,10 +4603,10 @@
 
     # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay.
     echo $ac_n "checking for shmat""... $ac_c" 1>&6
-echo "configure:4609: checking for shmat" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 4612 "configure"
+echo "configure:4607: checking for shmat" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 4610 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char shmat(); below.  */
@@ -4631,7 +4629,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:4635: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4633: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_shmat=yes"
 else
@@ -4652,12 +4650,12 @@
     if test $ac_cv_func_shmat = no; then
       
 echo $ac_n "checking for shmat in -lipc""... $ac_c" 1>&6
-echo "configure:4656: checking for shmat in -lipc" >&5
+echo "configure:4654: checking for shmat in -lipc" >&5
 ac_lib_var=`echo ipc'_'shmat | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lipc "
 cat > conftest.$ac_ext <<EOF
-#line 4661 "configure"
+#line 4659 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -4668,7 +4666,7 @@
 shmat()
 ; return 0; }
 EOF
-if { (eval echo configure:4672: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4670: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4702,12 +4700,12 @@
   #  --interran@uluru.Stanford.EDU, kb@cs.umb.edu.
   
 echo $ac_n "checking for IceConnectionNumber in -lICE""... $ac_c" 1>&6
-echo "configure:4706: checking for IceConnectionNumber in -lICE" >&5
+echo "configure:4704: checking for IceConnectionNumber in -lICE" >&5
 ac_lib_var=`echo ICE'_'IceConnectionNumber | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lICE "
 cat > conftest.$ac_ext <<EOF
-#line 4711 "configure"
+#line 4709 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -4718,7 +4716,7 @@
 IceConnectionNumber()
 ; return 0; }
 EOF
-if { (eval echo configure:4722: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4720: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4851,7 +4849,7 @@
   fi
 
     echo "checking for X defines extracted by xmkmf" 1>&6
-echo "configure:4855: checking for X defines extracted by xmkmf" >&5
+echo "configure:4853: checking for X defines extracted by xmkmf" >&5
   rm -fr conftestdir
   if mkdir conftestdir; then
     cd conftestdir
@@ -4883,15 +4881,15 @@
 
     ac_safe=`echo "X11/Intrinsic.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for X11/Intrinsic.h""... $ac_c" 1>&6
-echo "configure:4887: checking for X11/Intrinsic.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 4890 "configure"
+echo "configure:4885: checking for X11/Intrinsic.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 4888 "configure"
 #include "confdefs.h"
 #include <X11/Intrinsic.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4895: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4893: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -4915,12 +4913,12 @@
 
       
 echo $ac_n "checking for XOpenDisplay in -lX11""... $ac_c" 1>&6
-echo "configure:4919: checking for XOpenDisplay in -lX11" >&5
+echo "configure:4917: checking for XOpenDisplay in -lX11" >&5
 ac_lib_var=`echo X11'_'XOpenDisplay | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lX11 "
 cat > conftest.$ac_ext <<EOF
-#line 4924 "configure"
+#line 4922 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -4931,7 +4929,7 @@
 XOpenDisplay()
 ; return 0; }
 EOF
-if { (eval echo configure:4935: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4933: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4956,12 +4954,12 @@
 xe_msg_checking="for XGetFontProperty in -lX11"
 test -n "-b i486-linuxaout" && xe_msg_checking="$xe_msg_checking using extra libs -b i486-linuxaout"
 echo $ac_n "checking "$xe_msg_checking"""... $ac_c" 1>&6
-echo "configure:4960: checking "$xe_msg_checking"" >&5
+echo "configure:4958: checking "$xe_msg_checking"" >&5
 ac_lib_var=`echo X11'_'XGetFontProperty | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lX11 -b i486-linuxaout"
 cat > conftest.$ac_ext <<EOF
-#line 4965 "configure"
+#line 4963 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -4972,7 +4970,7 @@
 XGetFontProperty()
 ; return 0; }
 EOF
-if { (eval echo configure:4976: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4974: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4999,12 +4997,12 @@
 
     
 echo $ac_n "checking for XShapeSelectInput in -lXext""... $ac_c" 1>&6
-echo "configure:5003: checking for XShapeSelectInput in -lXext" >&5
+echo "configure:5001: checking for XShapeSelectInput in -lXext" >&5
 ac_lib_var=`echo Xext'_'XShapeSelectInput | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lXext "
 cat > conftest.$ac_ext <<EOF
-#line 5008 "configure"
+#line 5006 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -5015,7 +5013,7 @@
 XShapeSelectInput()
 ; return 0; }
 EOF
-if { (eval echo configure:5019: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5017: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5038,12 +5036,12 @@
 
     
 echo $ac_n "checking for XtOpenDisplay in -lXt""... $ac_c" 1>&6
-echo "configure:5042: checking for XtOpenDisplay in -lXt" >&5
+echo "configure:5040: checking for XtOpenDisplay in -lXt" >&5
 ac_lib_var=`echo Xt'_'XtOpenDisplay | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lXt "
 cat > conftest.$ac_ext <<EOF
-#line 5047 "configure"
+#line 5045 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -5054,7 +5052,7 @@
 XtOpenDisplay()
 ; return 0; }
 EOF
-if { (eval echo configure:5058: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5056: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5077,14 +5075,14 @@
 
 
   echo $ac_n "checking the version of X11 being used""... $ac_c" 1>&6
-echo "configure:5081: checking the version of X11 being used" >&5
+echo "configure:5079: checking the version of X11 being used" >&5
   cat > conftest.$ac_ext <<EOF
-#line 5083 "configure"
+#line 5081 "configure"
 #include "confdefs.h"
 #include <X11/Intrinsic.h>
     main(int c, char* v[]) { return c>1 ? XlibSpecificationRelease : 0; }
 EOF
-if { (eval echo configure:5088: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
+if { (eval echo configure:5086: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
 then
   ./conftest foobar; x11_release=$?
 else
@@ -5108,15 +5106,15 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:5112: checking for $ac_hdr" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 5115 "configure"
+echo "configure:5110: checking for $ac_hdr" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 5113 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5120: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5118: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -5147,7 +5145,7 @@
 
 
     echo $ac_n "checking for XFree86""... $ac_c" 1>&6
-echo "configure:5151: checking for XFree86" >&5
+echo "configure:5149: checking for XFree86" >&5
   if test -d "/usr/X386/include" -o \
           -f "/etc/XF86Config"    -o \
 	  -f "/etc/X11/XF86Config" -o \
@@ -5167,12 +5165,12 @@
 
     test -z "$with_xmu" && { 
 echo $ac_n "checking for XmuReadBitmapDataFromFile in -lXmu""... $ac_c" 1>&6
-echo "configure:5171: checking for XmuReadBitmapDataFromFile in -lXmu" >&5
+echo "configure:5169: checking for XmuReadBitmapDataFromFile in -lXmu" >&5
 ac_lib_var=`echo Xmu'_'XmuReadBitmapDataFromFile | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lXmu "
 cat > conftest.$ac_ext <<EOF
-#line 5176 "configure"
+#line 5174 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -5183,7 +5181,7 @@
 XmuReadBitmapDataFromFile()
 ; return 0; }
 EOF
-if { (eval echo configure:5187: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5185: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5222,19 +5220,19 @@
 
       
 echo $ac_n "checking for main in -lXbsd""... $ac_c" 1>&6
-echo "configure:5226: checking for main in -lXbsd" >&5
+echo "configure:5224: checking for main in -lXbsd" >&5
 ac_lib_var=`echo Xbsd'_'main | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lXbsd "
 cat > conftest.$ac_ext <<EOF
-#line 5231 "configure"
+#line 5229 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:5238: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5236: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5288,7 +5286,7 @@
 esac
 
 echo "checking for session-management option" 1>&6
-echo "configure:5292: checking for session-management option" >&5;
+echo "configure:5290: checking for session-management option" >&5;
 if test "$with_session" = "yes"; then
   { test "$extra_verbose" = "yes" && cat << \EOF
     Defining HAVE_SESSION
@@ -5303,15 +5301,15 @@
 test -z "$with_xauth" && test "$window_system" = "none" && with_xauth=no
 test -z "$with_xauth" && { ac_safe=`echo "X11/Xauth.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for X11/Xauth.h""... $ac_c" 1>&6
-echo "configure:5307: checking for X11/Xauth.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 5310 "configure"
+echo "configure:5305: checking for X11/Xauth.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 5308 "configure"
 #include "confdefs.h"
 #include <X11/Xauth.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5315: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5313: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -5334,12 +5332,12 @@
  }
 test -z "$with_xauth" && { 
 echo $ac_n "checking for XauGetAuthByAddr in -lXau""... $ac_c" 1>&6
-echo "configure:5338: checking for XauGetAuthByAddr in -lXau" >&5
+echo "configure:5336: checking for XauGetAuthByAddr in -lXau" >&5
 ac_lib_var=`echo Xau'_'XauGetAuthByAddr | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lXau "
 cat > conftest.$ac_ext <<EOF
-#line 5343 "configure"
+#line 5341 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -5350,7 +5348,7 @@
 XauGetAuthByAddr()
 ; return 0; }
 EOF
-if { (eval echo configure:5354: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5352: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5410,15 +5408,15 @@
       for dir in "" "Tt/" "desktop/" ; do
     ac_safe=`echo "${dir}tt_c.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for ${dir}tt_c.h""... $ac_c" 1>&6
-echo "configure:5414: checking for ${dir}tt_c.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 5417 "configure"
+echo "configure:5412: checking for ${dir}tt_c.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 5415 "configure"
 #include "confdefs.h"
 #include <${dir}tt_c.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5422: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5420: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -5447,12 +5445,12 @@
 xe_msg_checking="for tt_message_create in -ltt"
 test -n "$extra_libs" && xe_msg_checking="$xe_msg_checking using extra libs $extra_libs"
 echo $ac_n "checking "$xe_msg_checking"""... $ac_c" 1>&6
-echo "configure:5451: checking "$xe_msg_checking"" >&5
+echo "configure:5449: checking "$xe_msg_checking"" >&5
 ac_lib_var=`echo tt'_'tt_message_create | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -ltt $extra_libs"
 cat > conftest.$ac_ext <<EOF
-#line 5456 "configure"
+#line 5454 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -5463,7 +5461,7 @@
 tt_message_create()
 ; return 0; }
 EOF
-if { (eval echo configure:5467: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5465: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5512,15 +5510,15 @@
 
 test -z "$with_cde" && { ac_safe=`echo "Dt/Dt.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for Dt/Dt.h""... $ac_c" 1>&6
-echo "configure:5516: checking for Dt/Dt.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 5519 "configure"
+echo "configure:5514: checking for Dt/Dt.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 5517 "configure"
 #include "confdefs.h"
 #include <Dt/Dt.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5524: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5522: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -5543,12 +5541,12 @@
  }
 test -z "$with_cde" && { 
 echo $ac_n "checking for DtDndDragStart in -lDtSvc""... $ac_c" 1>&6
-echo "configure:5547: checking for DtDndDragStart in -lDtSvc" >&5
+echo "configure:5545: checking for DtDndDragStart in -lDtSvc" >&5
 ac_lib_var=`echo DtSvc'_'DtDndDragStart | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lDtSvc "
 cat > conftest.$ac_ext <<EOF
-#line 5552 "configure"
+#line 5550 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -5559,7 +5557,7 @@
 DtDndDragStart()
 ; return 0; }
 EOF
-if { (eval echo configure:5563: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5561: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5599,12 +5597,12 @@
 if test "$with_x11" = "yes"; then
 
   echo "checking for X11 graphics libraries" 1>&6
-echo "configure:5603: checking for X11 graphics libraries" >&5
+echo "configure:5601: checking for X11 graphics libraries" >&5
     echo $ac_n "checking for Xpm - no older than 3.4f""... $ac_c" 1>&6
-echo "configure:5605: checking for Xpm - no older than 3.4f" >&5
+echo "configure:5603: checking for Xpm - no older than 3.4f" >&5
   xe_check_libs=-lXpm
   test -z "$with_xpm" && { cat > conftest.$ac_ext <<EOF
-#line 5608 "configure"
+#line 5606 "configure"
 #include "confdefs.h"
 #include <X11/xpm.h>
   int main(int c, char **v) {
@@ -5614,7 +5612,7 @@
 		  0 ;
   }
 EOF
-if { (eval echo configure:5618: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
+if { (eval echo configure:5616: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
 then
   ./conftest foobar; xpm_status=$?;
     if test "$xpm_status" = "0"; then with_xpm=yes; else with_xpm=no; fi;
@@ -5652,15 +5650,15 @@
 
     test -z "$with_xface" && { ac_safe=`echo "compface.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for compface.h""... $ac_c" 1>&6
-echo "configure:5656: checking for compface.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 5659 "configure"
+echo "configure:5654: checking for compface.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 5657 "configure"
 #include "confdefs.h"
 #include <compface.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5664: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5662: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -5683,12 +5681,12 @@
  }
   test -z "$with_xface" && { 
 echo $ac_n "checking for UnGenFace in -lcompface""... $ac_c" 1>&6
-echo "configure:5687: checking for UnGenFace in -lcompface" >&5
+echo "configure:5685: checking for UnGenFace in -lcompface" >&5
 ac_lib_var=`echo compface'_'UnGenFace | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lcompface "
 cat > conftest.$ac_ext <<EOF
-#line 5692 "configure"
+#line 5690 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -5699,7 +5697,7 @@
 UnGenFace()
 ; return 0; }
 EOF
-if { (eval echo configure:5703: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5701: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5735,15 +5733,15 @@
 
     test -z "$with_imagick" && { ac_safe=`echo "magick/magick.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for magick/magick.h""... $ac_c" 1>&6
-echo "configure:5739: checking for magick/magick.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 5742 "configure"
+echo "configure:5737: checking for magick/magick.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 5740 "configure"
 #include "confdefs.h"
 #include <magick/magick.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5747: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5745: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -5761,19 +5759,56 @@
   :
 else
   echo "$ac_t""no" 1>&6
+ac_safe=`echo "X11/magick/magick.h" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for X11/magick/magick.h""... $ac_c" 1>&6
+echo "configure:5765: checking for X11/magick/magick.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 5768 "configure"
+#include "confdefs.h"
+#include <X11/magick/magick.h>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:5773: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out`
+if test -z "$ac_err"; then
+  rm -rf conftest*
+  eval "ac_cv_header_$ac_safe=yes"
+else
+  echo "$ac_err" >&5
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  { test "$extra_verbose" = "yes" && cat << \EOF
+    Defining MAGICK_HEADERS_ARE_UNDER_X11
+EOF
+cat >> confdefs.h <<\EOF
+#define MAGICK_HEADERS_ARE_UNDER_X11 1
+EOF
+}
+
+else
+  echo "$ac_t""no" 1>&6
 with_imagick=no
 fi
+
+fi
  }
   test -z "$with_imagick" && {
         imagick_libs=""
     
 echo $ac_n "checking for XDPSPixelsPerPoint in -ldps""... $ac_c" 1>&6
-echo "configure:5772: checking for XDPSPixelsPerPoint in -ldps" >&5
+echo "configure:5807: checking for XDPSPixelsPerPoint in -ldps" >&5
 ac_lib_var=`echo dps'_'XDPSPixelsPerPoint | sed 'y%./+-%__p_%'`
 
 xe_check_libs="-ldpstk -ldps "
 cat > conftest.$ac_ext <<EOF
-#line 5777 "configure"
+#line 5812 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -5784,7 +5819,7 @@
 XDPSPixelsPerPoint()
 ; return 0; }
 EOF
-if { (eval echo configure:5788: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5823: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5806,12 +5841,12 @@
 
     
 echo $ac_n "checking for FPX_SetToolkitMemoryLimit in -lfpx""... $ac_c" 1>&6
-echo "configure:5810: checking for FPX_SetToolkitMemoryLimit in -lfpx" >&5
+echo "configure:5845: checking for FPX_SetToolkitMemoryLimit in -lfpx" >&5
 ac_lib_var=`echo fpx'_'FPX_SetToolkitMemoryLimit | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lfpx "
 cat > conftest.$ac_ext <<EOF
-#line 5815 "configure"
+#line 5850 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -5822,7 +5857,7 @@
 FPX_SetToolkitMemoryLimit()
 ; return 0; }
 EOF
-if { (eval echo configure:5826: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5861: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5844,12 +5879,12 @@
 
     
 echo $ac_n "checking for DF24getdims in -ldf""... $ac_c" 1>&6
-echo "configure:5848: checking for DF24getdims in -ldf" >&5
+echo "configure:5883: checking for DF24getdims in -ldf" >&5
 ac_lib_var=`echo df'_'DF24getdims | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -ldf "
 cat > conftest.$ac_ext <<EOF
-#line 5853 "configure"
+#line 5888 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -5860,7 +5895,7 @@
 DF24getdims()
 ; return 0; }
 EOF
-if { (eval echo configure:5864: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5899: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5882,12 +5917,12 @@
 
     
 echo $ac_n "checking for jbg_dec_init in -ljbig""... $ac_c" 1>&6
-echo "configure:5886: checking for jbg_dec_init in -ljbig" >&5
+echo "configure:5921: checking for jbg_dec_init in -ljbig" >&5
 ac_lib_var=`echo jbig'_'jbg_dec_init | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -ljbig "
 cat > conftest.$ac_ext <<EOF
-#line 5891 "configure"
+#line 5926 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -5898,7 +5933,7 @@
 jbg_dec_init()
 ; return 0; }
 EOF
-if { (eval echo configure:5902: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5937: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5920,12 +5955,12 @@
 
     
 echo $ac_n "checking for jpeg_read_header in -ljpeg""... $ac_c" 1>&6
-echo "configure:5924: checking for jpeg_read_header in -ljpeg" >&5
+echo "configure:5959: checking for jpeg_read_header in -ljpeg" >&5
 ac_lib_var=`echo jpeg'_'jpeg_read_header | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -ljpeg "
 cat > conftest.$ac_ext <<EOF
-#line 5929 "configure"
+#line 5964 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -5936,7 +5971,7 @@
 jpeg_read_header()
 ; return 0; }
 EOF
-if { (eval echo configure:5940: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5975: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5958,12 +5993,12 @@
 
     
 echo $ac_n "checking for OpenMPEG in -lmpeg""... $ac_c" 1>&6
-echo "configure:5962: checking for OpenMPEG in -lmpeg" >&5
+echo "configure:5997: checking for OpenMPEG in -lmpeg" >&5
 ac_lib_var=`echo mpeg'_'OpenMPEG | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lmpeg "
 cat > conftest.$ac_ext <<EOF
-#line 5967 "configure"
+#line 6002 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -5974,7 +6009,7 @@
 OpenMPEG()
 ; return 0; }
 EOF
-if { (eval echo configure:5978: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6013: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5995,13 +6030,51 @@
 
 
     
+echo $ac_n "checking for TT_Init_FreeType in -lttf""... $ac_c" 1>&6
+echo "configure:6035: checking for TT_Init_FreeType in -lttf" >&5
+ac_lib_var=`echo ttf'_'TT_Init_FreeType | sed 'y%./+-%__p_%'`
+
+xe_check_libs=" -lttf "
+cat > conftest.$ac_ext <<EOF
+#line 6040 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char TT_Init_FreeType();
+
+int main() {
+TT_Init_FreeType()
+; return 0; }
+EOF
+if { (eval echo configure:6051: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+xe_check_libs=""
+
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes" ; then
+  echo "$ac_t""yes" 1>&6
+  imagick_libs="$imagick_libs -lttf" &&  if test "$extra_verbose" = "yes"; then echo "    Appending \"-lttf\" to \$imagick_libs"; fi
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+
+    
 echo $ac_n "checking for png_create_read_struct in -lpng""... $ac_c" 1>&6
-echo "configure:6000: checking for png_create_read_struct in -lpng" >&5
+echo "configure:6073: checking for png_create_read_struct in -lpng" >&5
 ac_lib_var=`echo png'_'png_create_read_struct | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lpng "
 cat > conftest.$ac_ext <<EOF
-#line 6005 "configure"
+#line 6078 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -6012,7 +6085,7 @@
 png_create_read_struct()
 ; return 0; }
 EOF
-if { (eval echo configure:6016: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6089: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6032,12 +6105,12 @@
 xe_msg_checking="for png_create_read_struct in -lpng"
 test -n "-lz" && xe_msg_checking="$xe_msg_checking using extra libs -lz"
 echo $ac_n "checking "$xe_msg_checking"""... $ac_c" 1>&6
-echo "configure:6036: checking "$xe_msg_checking"" >&5
+echo "configure:6109: checking "$xe_msg_checking"" >&5
 ac_lib_var=`echo png'_'png_create_read_struct | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lpng -lz"
 cat > conftest.$ac_ext <<EOF
-#line 6041 "configure"
+#line 6114 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -6048,7 +6121,7 @@
 png_create_read_struct()
 ; return 0; }
 EOF
-if { (eval echo configure:6052: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6125: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6073,12 +6146,12 @@
 
     
 echo $ac_n "checking for TIFFOpen in -ltiff""... $ac_c" 1>&6
-echo "configure:6077: checking for TIFFOpen in -ltiff" >&5
+echo "configure:6150: checking for TIFFOpen in -ltiff" >&5
 ac_lib_var=`echo tiff'_'TIFFOpen | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -ltiff "
 cat > conftest.$ac_ext <<EOF
-#line 6082 "configure"
+#line 6155 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -6089,7 +6162,7 @@
 TIFFOpen()
 ; return 0; }
 EOF
-if { (eval echo configure:6093: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6166: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6109,12 +6182,12 @@
 xe_msg_checking="for TIFFOpen in -ltiff"
 test -n "-ljpeg -lz" && xe_msg_checking="$xe_msg_checking using extra libs -ljpeg -lz"
 echo $ac_n "checking "$xe_msg_checking"""... $ac_c" 1>&6
-echo "configure:6113: checking "$xe_msg_checking"" >&5
+echo "configure:6186: checking "$xe_msg_checking"" >&5
 ac_lib_var=`echo tiff'_'TIFFOpen | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -ltiff -ljpeg -lz"
 cat > conftest.$ac_ext <<EOF
-#line 6118 "configure"
+#line 6191 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -6125,7 +6198,7 @@
 TIFFOpen()
 ; return 0; }
 EOF
-if { (eval echo configure:6129: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6202: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6152,12 +6225,12 @@
   }
   test -z "$with_imagick" && { 
 echo $ac_n "checking for MogrifyImage in -lMagick""... $ac_c" 1>&6
-echo "configure:6156: checking for MogrifyImage in -lMagick" >&5
+echo "configure:6229: checking for MogrifyImage in -lMagick" >&5
 ac_lib_var=`echo Magick'_'MogrifyImage | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lMagick "
 cat > conftest.$ac_ext <<EOF
-#line 6161 "configure"
+#line 6234 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -6168,7 +6241,7 @@
 MogrifyImage()
 ; return 0; }
 EOF
-if { (eval echo configure:6172: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6245: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6204,12 +6277,12 @@
 
     
 echo $ac_n "checking for XawScrollbarSetThumb in -lXaw""... $ac_c" 1>&6
-echo "configure:6208: checking for XawScrollbarSetThumb in -lXaw" >&5
+echo "configure:6281: checking for XawScrollbarSetThumb in -lXaw" >&5
 ac_lib_var=`echo Xaw'_'XawScrollbarSetThumb | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lXaw "
 cat > conftest.$ac_ext <<EOF
-#line 6213 "configure"
+#line 6286 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -6220,7 +6293,7 @@
 XawScrollbarSetThumb()
 ; return 0; }
 EOF
-if { (eval echo configure:6224: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6297: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6244,15 +6317,15 @@
                     
     ac_safe=`echo "Xm/Xm.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for Xm/Xm.h""... $ac_c" 1>&6
-echo "configure:6248: checking for Xm/Xm.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 6251 "configure"
+echo "configure:6321: checking for Xm/Xm.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 6324 "configure"
 #include "confdefs.h"
 #include <Xm/Xm.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:6256: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:6329: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -6269,12 +6342,12 @@
   echo "$ac_t""yes" 1>&6
   
 echo $ac_n "checking for XmStringFree in -lXm""... $ac_c" 1>&6
-echo "configure:6273: checking for XmStringFree in -lXm" >&5
+echo "configure:6346: checking for XmStringFree in -lXm" >&5
 ac_lib_var=`echo Xm'_'XmStringFree | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lXm "
 cat > conftest.$ac_ext <<EOF
-#line 6278 "configure"
+#line 6351 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -6285,7 +6358,7 @@
 XmStringFree()
 ; return 0; }
 EOF
-if { (eval echo configure:6289: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6362: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6548,7 +6621,7 @@
 
 if test "$with_mule" = "yes" ; then
   echo "checking for Mule-related features" 1>&6
-echo "configure:6552: checking for Mule-related features" >&5
+echo "configure:6625: checking for Mule-related features" >&5
   { test "$extra_verbose" = "yes" && cat << \EOF
     Defining MULE
 EOF
@@ -6565,15 +6638,15 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:6569: checking for $ac_hdr" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 6572 "configure"
+echo "configure:6642: checking for $ac_hdr" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 6645 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:6577: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:6650: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -6604,12 +6677,12 @@
 
   
 echo $ac_n "checking for strerror in -lintl""... $ac_c" 1>&6
-echo "configure:6608: checking for strerror in -lintl" >&5
+echo "configure:6681: checking for strerror in -lintl" >&5
 ac_lib_var=`echo intl'_'strerror | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lintl "
 cat > conftest.$ac_ext <<EOF
-#line 6613 "configure"
+#line 6686 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -6620,7 +6693,7 @@
 strerror()
 ; return 0; }
 EOF
-if { (eval echo configure:6624: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6697: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6653,19 +6726,19 @@
 
 
   echo "checking for Mule input methods" 1>&6
-echo "configure:6657: checking for Mule input methods" >&5
+echo "configure:6730: checking for Mule input methods" >&5
       test -z "$with_xim" -a "$opsys" != "sol2" && with_xim=no
   case "$with_xim" in "" | "yes" )
     echo "checking for XIM" 1>&6
-echo "configure:6661: checking for XIM" >&5
+echo "configure:6734: checking for XIM" >&5
     
 echo $ac_n "checking for XmImMbLookupString in -lXm""... $ac_c" 1>&6
-echo "configure:6664: checking for XmImMbLookupString in -lXm" >&5
+echo "configure:6737: checking for XmImMbLookupString in -lXm" >&5
 ac_lib_var=`echo Xm'_'XmImMbLookupString | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lXm "
 cat > conftest.$ac_ext <<EOF
-#line 6669 "configure"
+#line 6742 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -6676,7 +6749,7 @@
 XmImMbLookupString()
 ; return 0; }
 EOF
-if { (eval echo configure:6680: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6753: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6741,15 +6814,15 @@
 
     if test "$with_xfs" = "yes" ; then
     echo "checking for XFontSet" 1>&6
-echo "configure:6745: checking for XFontSet" >&5
+echo "configure:6818: checking for XFontSet" >&5
     
 echo $ac_n "checking for XmbDrawString in -lX11""... $ac_c" 1>&6
-echo "configure:6748: checking for XmbDrawString in -lX11" >&5
+echo "configure:6821: checking for XmbDrawString in -lX11" >&5
 ac_lib_var=`echo X11'_'XmbDrawString | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lX11 "
 cat > conftest.$ac_ext <<EOF
-#line 6753 "configure"
+#line 6826 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -6760,7 +6833,7 @@
 XmbDrawString()
 ; return 0; }
 EOF
-if { (eval echo configure:6764: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6837: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6800,15 +6873,15 @@
     test "$with_wnn6" = "yes" && with_wnn=yes # wnn6 implies wnn support
   test -z "$with_wnn" && { ac_safe=`echo "wnn/jllib.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for wnn/jllib.h""... $ac_c" 1>&6
-echo "configure:6804: checking for wnn/jllib.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 6807 "configure"
+echo "configure:6877: checking for wnn/jllib.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 6880 "configure"
 #include "confdefs.h"
 #include <wnn/jllib.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:6812: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:6885: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -6833,10 +6906,10 @@
     for ac_func in crypt
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:6837: checking for $ac_func" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 6840 "configure"
+echo "configure:6910: checking for $ac_func" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 6913 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -6859,7 +6932,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:6863: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6936: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -6888,12 +6961,12 @@
 
     test "$ac_cv_func_crypt" != "yes" && { 
 echo $ac_n "checking for crypt in -lcrypt""... $ac_c" 1>&6
-echo "configure:6892: checking for crypt in -lcrypt" >&5
+echo "configure:6965: checking for crypt in -lcrypt" >&5
 ac_lib_var=`echo crypt'_'crypt | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lcrypt "
 cat > conftest.$ac_ext <<EOF
-#line 6897 "configure"
+#line 6970 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -6904,7 +6977,7 @@
 crypt()
 ; return 0; }
 EOF
-if { (eval echo configure:6908: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6981: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6938,12 +7011,12 @@
   fi
     test -z "$with_wnn" && { 
 echo $ac_n "checking for jl_dic_list_e in -lwnn""... $ac_c" 1>&6
-echo "configure:6942: checking for jl_dic_list_e in -lwnn" >&5
+echo "configure:7015: checking for jl_dic_list_e in -lwnn" >&5
 ac_lib_var=`echo wnn'_'jl_dic_list_e | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lwnn "
 cat > conftest.$ac_ext <<EOF
-#line 6947 "configure"
+#line 7020 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -6954,7 +7027,7 @@
 jl_dic_list_e()
 ; return 0; }
 EOF
-if { (eval echo configure:6958: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7031: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6991,12 +7064,12 @@
  fi
     
 echo $ac_n "checking for jl_fi_dic_list in -lwnn""... $ac_c" 1>&6
-echo "configure:6995: checking for jl_fi_dic_list in -lwnn" >&5
+echo "configure:7068: checking for jl_fi_dic_list in -lwnn" >&5
 ac_lib_var=`echo wnn'_'jl_fi_dic_list | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lwnn "
 cat > conftest.$ac_ext <<EOF
-#line 7000 "configure"
+#line 7073 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -7007,7 +7080,7 @@
 jl_fi_dic_list()
 ; return 0; }
 EOF
-if { (eval echo configure:7011: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7084: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -7039,15 +7112,15 @@
 
     test -z "$with_canna" && { ac_safe=`echo "canna/RK.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for canna/RK.h""... $ac_c" 1>&6
-echo "configure:7043: checking for canna/RK.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 7046 "configure"
+echo "configure:7116: checking for canna/RK.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 7119 "configure"
 #include "confdefs.h"
 #include <canna/RK.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:7051: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:7124: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -7070,12 +7143,12 @@
  }
   test -z "$with_canna" && { 
 echo $ac_n "checking for RkBgnBun in -lRKC""... $ac_c" 1>&6
-echo "configure:7074: checking for RkBgnBun in -lRKC" >&5
+echo "configure:7147: checking for RkBgnBun in -lRKC" >&5
 ac_lib_var=`echo RKC'_'RkBgnBun | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lRKC "
 cat > conftest.$ac_ext <<EOF
-#line 7079 "configure"
+#line 7152 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -7086,7 +7159,7 @@
 RkBgnBun()
 ; return 0; }
 EOF
-if { (eval echo configure:7090: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7163: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -7109,12 +7182,12 @@
  }
   test -z "$with_canna" && { 
 echo $ac_n "checking for jrKanjiControl in -lcanna""... $ac_c" 1>&6
-echo "configure:7113: checking for jrKanjiControl in -lcanna" >&5
+echo "configure:7186: checking for jrKanjiControl in -lcanna" >&5
 ac_lib_var=`echo canna'_'jrKanjiControl | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lcanna "
 cat > conftest.$ac_ext <<EOF
-#line 7118 "configure"
+#line 7191 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -7125,7 +7198,7 @@
 jrKanjiControl()
 ; return 0; }
 EOF
-if { (eval echo configure:7129: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7202: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -7174,12 +7247,12 @@
   libs_x="-lXm $libs_x" &&  if test "$extra_verbose" = "yes"; then echo "    Prepending \"-lXm\" to \$libs_x"; fi
     
 echo $ac_n "checking for layout_object_getvalue in -li18n""... $ac_c" 1>&6
-echo "configure:7178: checking for layout_object_getvalue in -li18n" >&5
+echo "configure:7251: checking for layout_object_getvalue in -li18n" >&5
 ac_lib_var=`echo i18n'_'layout_object_getvalue | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -li18n "
 cat > conftest.$ac_ext <<EOF
-#line 7183 "configure"
+#line 7256 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -7190,7 +7263,7 @@
 layout_object_getvalue()
 ; return 0; }
 EOF
-if { (eval echo configure:7194: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7267: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -7263,10 +7336,10 @@
 for ac_func in acosh asinh atanh cbrt closedir dup2 eaccess fmod fpathconf frexp ftime gethostname getpagesize gettimeofday getcwd getwd logb lrand48 matherr mkdir mktime perror poll random rename res_init rint rmdir select setitimer setpgid setlocale setsid sigblock sighold sigprocmask strcasecmp strerror tzset ulimit usleep utimes waitpid
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:7267: checking for $ac_func" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 7270 "configure"
+echo "configure:7340: checking for $ac_func" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 7343 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -7289,7 +7362,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:7293: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7366: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -7326,10 +7399,10 @@
     for ac_func in realpath
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:7330: checking for $ac_func" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 7333 "configure"
+echo "configure:7403: checking for $ac_func" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 7406 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -7352,7 +7425,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:7356: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7429: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -7385,16 +7458,16 @@
 esac
 
 echo $ac_n "checking whether netdb declares h_errno""... $ac_c" 1>&6
-echo "configure:7389: checking whether netdb declares h_errno" >&5
-cat > conftest.$ac_ext <<EOF
-#line 7391 "configure"
+echo "configure:7462: checking whether netdb declares h_errno" >&5
+cat > conftest.$ac_ext <<EOF
+#line 7464 "configure"
 #include "confdefs.h"
 #include <netdb.h>
 int main() {
 return h_errno;
 ; return 0; }
 EOF
-if { (eval echo configure:7398: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7471: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6
    { test "$extra_verbose" = "yes" && cat << \EOF
@@ -7414,16 +7487,16 @@
 rm -f conftest*
 
 echo $ac_n "checking for sigsetjmp""... $ac_c" 1>&6
-echo "configure:7418: checking for sigsetjmp" >&5
-cat > conftest.$ac_ext <<EOF
-#line 7420 "configure"
+echo "configure:7491: checking for sigsetjmp" >&5
+cat > conftest.$ac_ext <<EOF
+#line 7493 "configure"
 #include "confdefs.h"
 #include <setjmp.h>
 int main() {
 sigjmp_buf bar; sigsetjmp (bar, 0);
 ; return 0; }
 EOF
-if { (eval echo configure:7427: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:7500: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6
    { test "$extra_verbose" = "yes" && cat << \EOF
@@ -7443,11 +7516,11 @@
 rm -f conftest*
 
 echo $ac_n "checking whether localtime caches TZ""... $ac_c" 1>&6
-echo "configure:7447: checking whether localtime caches TZ" >&5
+echo "configure:7520: checking whether localtime caches TZ" >&5
 
 if test "$ac_cv_func_tzset" = "yes"; then
 cat > conftest.$ac_ext <<EOF
-#line 7451 "configure"
+#line 7524 "configure"
 #include "confdefs.h"
 #include <time.h>
 #if STDC_HEADERS
@@ -7482,7 +7555,7 @@
   exit (0);
 }
 EOF
-if { (eval echo configure:7486: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
+if { (eval echo configure:7559: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
 then
   emacs_cv_localtime_cache=no
 else
@@ -7511,9 +7584,9 @@
 
 if test "$HAVE_TIMEVAL" = "yes"; then
 echo $ac_n "checking whether gettimeofday cannot accept two arguments""... $ac_c" 1>&6
-echo "configure:7515: checking whether gettimeofday cannot accept two arguments" >&5
-cat > conftest.$ac_ext <<EOF
-#line 7517 "configure"
+echo "configure:7588: checking whether gettimeofday cannot accept two arguments" >&5
+cat > conftest.$ac_ext <<EOF
+#line 7590 "configure"
 #include "confdefs.h"
 
 #ifdef TIME_WITH_SYS_TIME
@@ -7535,7 +7608,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:7539: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7612: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   echo "$ac_t""no" 1>&6
 else
@@ -7557,19 +7630,19 @@
 
 
 echo $ac_n "checking for inline""... $ac_c" 1>&6
-echo "configure:7561: checking for inline" >&5
+echo "configure:7634: checking for inline" >&5
 
 ac_cv_c_inline=no
 for ac_kw in inline __inline__ __inline; do
   cat > conftest.$ac_ext <<EOF
-#line 7566 "configure"
+#line 7639 "configure"
 #include "confdefs.h"
 
 int main() {
 } $ac_kw foo() {
 ; return 0; }
 EOF
-if { (eval echo configure:7573: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:7646: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_inline=$ac_kw; break
 else
@@ -7619,17 +7692,17 @@
 # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
 # for constant arguments.  Useless!
 echo $ac_n "checking for working alloca.h""... $ac_c" 1>&6
-echo "configure:7623: checking for working alloca.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 7626 "configure"
+echo "configure:7696: checking for working alloca.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 7699 "configure"
 #include "confdefs.h"
 #include <alloca.h>
 int main() {
 char *p = alloca(2 * sizeof(int));
 ; return 0; }
 EOF
-if { (eval echo configure:7633: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7706: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   ac_cv_header_alloca_h=yes
 else
@@ -7653,10 +7726,10 @@
 fi
 
 echo $ac_n "checking for alloca""... $ac_c" 1>&6
-echo "configure:7657: checking for alloca" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 7660 "configure"
+echo "configure:7730: checking for alloca" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 7733 "configure"
 #include "confdefs.h"
 
 #ifdef __GNUC__
@@ -7679,7 +7752,7 @@
 char *p = (char *) alloca(1);
 ; return 0; }
 EOF
-if { (eval echo configure:7683: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7756: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   ac_cv_func_alloca_works=yes
 else
@@ -7718,10 +7791,10 @@
 
 
 echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6
-echo "configure:7722: checking whether alloca needs Cray hooks" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 7725 "configure"
+echo "configure:7795: checking whether alloca needs Cray hooks" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 7798 "configure"
 #include "confdefs.h"
 #if defined(CRAY) && ! defined(CRAY2)
 webecray
@@ -7745,10 +7818,10 @@
 if test $ac_cv_os_cray = yes; then
 for ac_func in _getb67 GETB67 getb67; do
   echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:7749: checking for $ac_func" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 7752 "configure"
+echo "configure:7822: checking for $ac_func" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 7825 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -7771,7 +7844,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:7775: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7848: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -7801,10 +7874,10 @@
 fi
 
 echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6
-echo "configure:7805: checking stack direction for C alloca" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 7808 "configure"
+echo "configure:7878: checking stack direction for C alloca" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 7881 "configure"
 #include "confdefs.h"
 find_stack_direction ()
 {
@@ -7823,7 +7896,7 @@
   exit (find_stack_direction() < 0);
 }
 EOF
-if { (eval echo configure:7827: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
+if { (eval echo configure:7900: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
 then
   ac_cv_c_stack_direction=1
 else
@@ -7851,15 +7924,15 @@
 
 ac_safe=`echo "vfork.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for vfork.h""... $ac_c" 1>&6
-echo "configure:7855: checking for vfork.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 7858 "configure"
+echo "configure:7928: checking for vfork.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 7931 "configure"
 #include "confdefs.h"
 #include <vfork.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:7863: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:7936: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -7887,10 +7960,10 @@
 fi
 
 echo $ac_n "checking for working vfork""... $ac_c" 1>&6
-echo "configure:7891: checking for working vfork" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 7894 "configure"
+echo "configure:7964: checking for working vfork" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 7967 "configure"
 #include "confdefs.h"
 /* Thanks to Paul Eggert for this test.  */
 #include <stdio.h>
@@ -7985,7 +8058,7 @@
   }
 }
 EOF
-if { (eval echo configure:7989: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
+if { (eval echo configure:8062: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
 then
   ac_cv_func_vfork_works=yes
 else
@@ -8010,10 +8083,10 @@
 
 
 echo $ac_n "checking for working strcoll""... $ac_c" 1>&6
-echo "configure:8014: checking for working strcoll" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8017 "configure"
+echo "configure:8087: checking for working strcoll" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8090 "configure"
 #include "confdefs.h"
 #include <string.h>
 main ()
@@ -8023,7 +8096,7 @@
 	strcoll ("123", "456") >= 0);
 }
 EOF
-if { (eval echo configure:8027: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
+if { (eval echo configure:8100: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
 then
   ac_cv_func_strcoll_works=yes
 else
@@ -8050,10 +8123,10 @@
 for ac_func in getpgrp
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:8054: checking for $ac_func" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8057 "configure"
+echo "configure:8127: checking for $ac_func" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8130 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -8076,7 +8149,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:8080: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:8153: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -8104,10 +8177,10 @@
 done
 
 echo $ac_n "checking whether getpgrp takes no argument""... $ac_c" 1>&6
-echo "configure:8108: checking whether getpgrp takes no argument" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8111 "configure"
+echo "configure:8181: checking whether getpgrp takes no argument" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8184 "configure"
 #include "confdefs.h"
 
 /*
@@ -8162,7 +8235,7 @@
 }
 
 EOF
-if { (eval echo configure:8166: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
+if { (eval echo configure:8239: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
 then
   ac_cv_func_getpgrp_void=yes
 else
@@ -8188,10 +8261,10 @@
 
 
 echo $ac_n "checking for working mmap""... $ac_c" 1>&6
-echo "configure:8192: checking for working mmap" >&5
+echo "configure:8265: checking for working mmap" >&5
 case "$opsys" in ultrix* ) have_mmap=no ;; *)
 cat > conftest.$ac_ext <<EOF
-#line 8195 "configure"
+#line 8268 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 #include <unistd.h>
@@ -8224,7 +8297,7 @@
   return 1;
 }
 EOF
-if { (eval echo configure:8228: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
+if { (eval echo configure:8301: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>&5
 then
   have_mmap=yes
 else
@@ -8258,15 +8331,15 @@
 
 ac_safe=`echo "termios.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for termios.h""... $ac_c" 1>&6
-echo "configure:8262: checking for termios.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8265 "configure"
+echo "configure:8335: checking for termios.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8338 "configure"
 #include "confdefs.h"
 #include <termios.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8270: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8343: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -8309,15 +8382,15 @@
   echo "$ac_t""no" 1>&6
 ac_safe=`echo "termio.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for termio.h""... $ac_c" 1>&6
-echo "configure:8313: checking for termio.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8316 "configure"
+echo "configure:8386: checking for termio.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8389 "configure"
 #include "confdefs.h"
 #include <termio.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8321: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8394: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -8349,10 +8422,10 @@
 
 
 echo $ac_n "checking for socket""... $ac_c" 1>&6
-echo "configure:8353: checking for socket" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8356 "configure"
+echo "configure:8426: checking for socket" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8429 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char socket(); below.  */
@@ -8375,7 +8448,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:8379: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:8452: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_socket=yes"
 else
@@ -8390,15 +8463,15 @@
   echo "$ac_t""yes" 1>&6
   ac_safe=`echo "netinet/in.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for netinet/in.h""... $ac_c" 1>&6
-echo "configure:8394: checking for netinet/in.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8397 "configure"
+echo "configure:8467: checking for netinet/in.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8470 "configure"
 #include "confdefs.h"
 #include <netinet/in.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8402: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8475: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -8415,15 +8488,15 @@
   echo "$ac_t""yes" 1>&6
   ac_safe=`echo "arpa/inet.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for arpa/inet.h""... $ac_c" 1>&6
-echo "configure:8419: checking for arpa/inet.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8422 "configure"
+echo "configure:8492: checking for arpa/inet.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8495 "configure"
 #include "confdefs.h"
 #include <arpa/inet.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8427: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8500: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -8448,9 +8521,9 @@
 }
 
       echo $ac_n "checking "for sun_len member in struct sockaddr_un"""... $ac_c" 1>&6
-echo "configure:8452: checking "for sun_len member in struct sockaddr_un"" >&5
+echo "configure:8525: checking "for sun_len member in struct sockaddr_un"" >&5
       cat > conftest.$ac_ext <<EOF
-#line 8454 "configure"
+#line 8527 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -8461,7 +8534,7 @@
 static struct sockaddr_un x; x.sun_len = 1;
 ; return 0; }
 EOF
-if { (eval echo configure:8465: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:8538: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6; { test "$extra_verbose" = "yes" && cat << \EOF
     Defining HAVE_SOCKADDR_SUN_LEN
@@ -8492,10 +8565,10 @@
 
 
 echo $ac_n "checking for msgget""... $ac_c" 1>&6
-echo "configure:8496: checking for msgget" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8499 "configure"
+echo "configure:8569: checking for msgget" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8572 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char msgget(); below.  */
@@ -8518,7 +8591,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:8522: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:8595: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_msgget=yes"
 else
@@ -8533,15 +8606,15 @@
   echo "$ac_t""yes" 1>&6
   ac_safe=`echo "sys/ipc.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for sys/ipc.h""... $ac_c" 1>&6
-echo "configure:8537: checking for sys/ipc.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8540 "configure"
+echo "configure:8610: checking for sys/ipc.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8613 "configure"
 #include "confdefs.h"
 #include <sys/ipc.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8545: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8618: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -8558,15 +8631,15 @@
   echo "$ac_t""yes" 1>&6
   ac_safe=`echo "sys/msg.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for sys/msg.h""... $ac_c" 1>&6
-echo "configure:8562: checking for sys/msg.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8565 "configure"
+echo "configure:8635: checking for sys/msg.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8638 "configure"
 #include "confdefs.h"
 #include <sys/msg.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8570: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8643: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -8604,15 +8677,15 @@
 
 ac_safe=`echo "dirent.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for dirent.h""... $ac_c" 1>&6
-echo "configure:8608: checking for dirent.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8611 "configure"
+echo "configure:8681: checking for dirent.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8684 "configure"
 #include "confdefs.h"
 #include <dirent.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8616: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8689: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -8639,15 +8712,15 @@
   echo "$ac_t""no" 1>&6
 ac_safe=`echo "sys/dir.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for sys/dir.h""... $ac_c" 1>&6
-echo "configure:8643: checking for sys/dir.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8646 "configure"
+echo "configure:8716: checking for sys/dir.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8719 "configure"
 #include "confdefs.h"
 #include <sys/dir.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8651: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8724: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -8680,15 +8753,15 @@
 
 ac_safe=`echo "nlist.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for nlist.h""... $ac_c" 1>&6
-echo "configure:8684: checking for nlist.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8687 "configure"
+echo "configure:8757: checking for nlist.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8760 "configure"
 #include "confdefs.h"
 #include <nlist.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8692: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8765: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -8718,7 +8791,7 @@
 
 
 echo "checking "for sound support"" 1>&6
-echo "configure:8722: checking "for sound support"" >&5
+echo "configure:8795: checking "for sound support"" >&5
 case "$with_sound" in
   native | both ) with_native_sound=yes;;
   nas    | no   ) with_native_sound=no;;
@@ -8729,15 +8802,15 @@
     if test -n "$native_sound_lib"; then
     ac_safe=`echo "multimedia/audio_device.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for multimedia/audio_device.h""... $ac_c" 1>&6
-echo "configure:8733: checking for multimedia/audio_device.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8736 "configure"
+echo "configure:8806: checking for multimedia/audio_device.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8809 "configure"
 #include "confdefs.h"
 #include <multimedia/audio_device.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8741: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8814: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -8785,12 +8858,12 @@
       if test -z "$native_sound_lib"; then
         
 echo $ac_n "checking for ALopenport in -laudio""... $ac_c" 1>&6
-echo "configure:8789: checking for ALopenport in -laudio" >&5
+echo "configure:8862: checking for ALopenport in -laudio" >&5
 ac_lib_var=`echo audio'_'ALopenport | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -laudio "
 cat > conftest.$ac_ext <<EOF
-#line 8794 "configure"
+#line 8867 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -8801,7 +8874,7 @@
 ALopenport()
 ; return 0; }
 EOF
-if { (eval echo configure:8805: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:8878: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -8832,12 +8905,12 @@
       if test -z "$native_sound_lib"; then
 	
 echo $ac_n "checking for AOpenAudio in -lAlib""... $ac_c" 1>&6
-echo "configure:8836: checking for AOpenAudio in -lAlib" >&5
+echo "configure:8909: checking for AOpenAudio in -lAlib" >&5
 ac_lib_var=`echo Alib'_'AOpenAudio | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lAlib "
 cat > conftest.$ac_ext <<EOF
-#line 8841 "configure"
+#line 8914 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -8848,7 +8921,7 @@
 AOpenAudio()
 ; return 0; }
 EOF
-if { (eval echo configure:8852: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:8925: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -8886,15 +8959,15 @@
     for dir in "machine" "sys" "linux"; do
       ac_safe=`echo "${dir}/soundcard.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for ${dir}/soundcard.h""... $ac_c" 1>&6
-echo "configure:8890: checking for ${dir}/soundcard.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 8893 "configure"
+echo "configure:8963: checking for ${dir}/soundcard.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 8966 "configure"
 #include "confdefs.h"
 #include <${dir}/soundcard.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8898: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8971: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -8964,7 +9037,7 @@
  fi
   libs_x="-laudio $libs_x" &&  if test "$extra_verbose" = "yes"; then echo "    Prepending \"-laudio\" to \$libs_x"; fi
       cat > conftest.$ac_ext <<EOF
-#line 8968 "configure"
+#line 9041 "configure"
 #include "confdefs.h"
 #include <audio/Xtutil.h>
 EOF
@@ -8991,7 +9064,7 @@
 
 if test "$with_tty" = "yes"  ; then
   echo "checking for TTY-related features" 1>&6
-echo "configure:8995: checking for TTY-related features" >&5
+echo "configure:9068: checking for TTY-related features" >&5
   { test "$extra_verbose" = "yes" && cat << \EOF
     Defining HAVE_TTY
 EOF
@@ -9007,12 +9080,12 @@
     if test -z "$with_ncurses"; then
     
 echo $ac_n "checking for tgetent in -lncurses""... $ac_c" 1>&6
-echo "configure:9011: checking for tgetent in -lncurses" >&5
+echo "configure:9084: checking for tgetent in -lncurses" >&5
 ac_lib_var=`echo ncurses'_'tgetent | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lncurses "
 cat > conftest.$ac_ext <<EOF
-#line 9016 "configure"
+#line 9089 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -9023,7 +9096,7 @@
 tgetent()
 ; return 0; }
 EOF
-if { (eval echo configure:9027: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:9100: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -9056,15 +9129,15 @@
 
     ac_safe=`echo "ncurses/curses.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for ncurses/curses.h""... $ac_c" 1>&6
-echo "configure:9060: checking for ncurses/curses.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9063 "configure"
+echo "configure:9133: checking for ncurses/curses.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9136 "configure"
 #include "confdefs.h"
 #include <ncurses/curses.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:9068: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:9141: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -9086,15 +9159,15 @@
 
     ac_safe=`echo "ncurses/term.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for ncurses/term.h""... $ac_c" 1>&6
-echo "configure:9090: checking for ncurses/term.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9093 "configure"
+echo "configure:9163: checking for ncurses/term.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9166 "configure"
 #include "confdefs.h"
 #include <ncurses/term.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:9098: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:9171: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -9124,15 +9197,15 @@
       c_switch_site="$c_switch_site -I/usr/include/ncurses"
       ac_safe=`echo "ncurses/curses.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for ncurses/curses.h""... $ac_c" 1>&6
-echo "configure:9128: checking for ncurses/curses.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9131 "configure"
+echo "configure:9201: checking for ncurses/curses.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9204 "configure"
 #include "confdefs.h"
 #include <ncurses/curses.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:9136: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:9209: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -9167,12 +9240,12 @@
 	for lib in curses termlib termcap; do
 	  
 echo $ac_n "checking for tgetent in -l$lib""... $ac_c" 1>&6
-echo "configure:9171: checking for tgetent in -l$lib" >&5
+echo "configure:9244: checking for tgetent in -l$lib" >&5
 ac_lib_var=`echo $lib'_'tgetent | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -l$lib "
 cat > conftest.$ac_ext <<EOF
-#line 9176 "configure"
+#line 9249 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -9183,7 +9256,7 @@
 tgetent()
 ; return 0; }
 EOF
-if { (eval echo configure:9187: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:9260: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -9214,12 +9287,12 @@
       else
 	
 echo $ac_n "checking for tgetent in -lcurses""... $ac_c" 1>&6
-echo "configure:9218: checking for tgetent in -lcurses" >&5
+echo "configure:9291: checking for tgetent in -lcurses" >&5
 ac_lib_var=`echo curses'_'tgetent | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lcurses "
 cat > conftest.$ac_ext <<EOF
-#line 9223 "configure"
+#line 9296 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -9230,7 +9303,7 @@
 tgetent()
 ; return 0; }
 EOF
-if { (eval echo configure:9234: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:9307: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -9248,12 +9321,12 @@
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for tgetent in -ltermcap""... $ac_c" 1>&6
-echo "configure:9252: checking for tgetent in -ltermcap" >&5
+echo "configure:9325: checking for tgetent in -ltermcap" >&5
 ac_lib_var=`echo termcap'_'tgetent | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -ltermcap "
 cat > conftest.$ac_ext <<EOF
-#line 9257 "configure"
+#line 9330 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -9264,7 +9337,7 @@
 tgetent()
 ; return 0; }
 EOF
-if { (eval echo configure:9268: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:9341: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -9312,15 +9385,15 @@
 
     test -z "$with_gpm" && { ac_safe=`echo "gpm.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for gpm.h""... $ac_c" 1>&6
-echo "configure:9316: checking for gpm.h" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9319 "configure"
+echo "configure:9389: checking for gpm.h" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9392 "configure"
 #include "confdefs.h"
 #include <gpm.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:9324: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:9397: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -9343,12 +9416,12 @@
  }
   test -z "$with_gpm" && { 
 echo $ac_n "checking for Gpm_Open in -lgpm""... $ac_c" 1>&6
-echo "configure:9347: checking for Gpm_Open in -lgpm" >&5
+echo "configure:9420: checking for Gpm_Open in -lgpm" >&5
 ac_lib_var=`echo gpm'_'Gpm_Open | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lgpm "
 cat > conftest.$ac_ext <<EOF
-#line 9352 "configure"
+#line 9425 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -9359,7 +9432,7 @@
 Gpm_Open()
 ; return 0; }
 EOF
-if { (eval echo configure:9363: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:9436: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -9408,17 +9481,17 @@
 
 
 echo "checking for database support" 1>&6
-echo "configure:9412: checking for database support" >&5
+echo "configure:9485: checking for database support" >&5
 
 if test "$with_database_gnudbm" != "no"; then
   
 echo $ac_n "checking for dbm_open in -lgdbm""... $ac_c" 1>&6
-echo "configure:9417: checking for dbm_open in -lgdbm" >&5
+echo "configure:9490: checking for dbm_open in -lgdbm" >&5
 ac_lib_var=`echo gdbm'_'dbm_open | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lgdbm "
 cat > conftest.$ac_ext <<EOF
-#line 9422 "configure"
+#line 9495 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -9429,7 +9502,7 @@
 dbm_open()
 ; return 0; }
 EOF
-if { (eval echo configure:9433: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:9506: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -9451,10 +9524,10 @@
 
   if test "$with_database_gnudbm" != "yes"; then
     echo $ac_n "checking for dbm_open""... $ac_c" 1>&6
-echo "configure:9455: checking for dbm_open" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9458 "configure"
+echo "configure:9528: checking for dbm_open" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9531 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char dbm_open(); below.  */
@@ -9477,7 +9550,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:9481: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:9554: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_dbm_open=yes"
 else
@@ -9513,10 +9586,10 @@
 
 if test "$with_database_dbm" != "no"; then
   echo $ac_n "checking for dbm_open""... $ac_c" 1>&6
-echo "configure:9517: checking for dbm_open" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9520 "configure"
+echo "configure:9590: checking for dbm_open" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9593 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char dbm_open(); below.  */
@@ -9539,7 +9612,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:9543: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:9616: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_dbm_open=yes"
 else
@@ -9560,12 +9633,12 @@
   if test "$need_libdbm" != "no"; then
     
 echo $ac_n "checking for dbm_open in -ldbm""... $ac_c" 1>&6
-echo "configure:9564: checking for dbm_open in -ldbm" >&5
+echo "configure:9637: checking for dbm_open in -ldbm" >&5
 ac_lib_var=`echo dbm'_'dbm_open | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -ldbm "
 cat > conftest.$ac_ext <<EOF
-#line 9569 "configure"
+#line 9642 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -9576,7 +9649,7 @@
 dbm_open()
 ; return 0; }
 EOF
-if { (eval echo configure:9580: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:9653: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -9613,10 +9686,10 @@
 
 if test "$with_database_berkdb" != "no"; then
   echo $ac_n "checking for dbopen""... $ac_c" 1>&6
-echo "configure:9617: checking for dbopen" >&5
-
-cat > conftest.$ac_ext <<EOF
-#line 9620 "configure"
+echo "configure:9690: checking for dbopen" >&5
+
+cat > conftest.$ac_ext <<EOF
+#line 9693 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char dbopen(); below.  */
@@ -9639,7 +9712,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:9643: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:9716: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_dbopen=yes"
 else
@@ -9660,12 +9733,12 @@
   if test "$need_libdb" != "no"; then
     
 echo $ac_n "checking for dbopen in -ldb""... $ac_c" 1>&6
-echo "configure:9664: checking for dbopen in -ldb" >&5
+echo "configure:9737: checking for dbopen in -ldb" >&5
 ac_lib_var=`echo db'_'dbopen | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -ldb "
 cat > conftest.$ac_ext <<EOF
-#line 9669 "configure"
+#line 9742 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -9676,7 +9749,7 @@
 dbopen()
 ; return 0; }
 EOF
-if { (eval echo configure:9680: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:9753: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -9700,7 +9773,7 @@
   if test "$with_database_berkdb" = "yes"; then
     for path in "db/db.h" "db.h"; do
 cat > conftest.$ac_ext <<EOF
-#line 9704 "configure"
+#line 9777 "configure"
 #include "confdefs.h"
 #ifdef HAVE_INTTYPES_H
 #define __BIT_TYPES_DEFINED__
@@ -9718,7 +9791,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:9722: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:9795: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   db_h_path="$path"; break
 else
@@ -9770,12 +9843,12 @@
 if test "$with_socks" = "yes"; then
   
 echo $ac_n "checking for SOCKSinit in -lsocks""... $ac_c" 1>&6
-echo "configure:9774: checking for SOCKSinit in -lsocks" >&5
+echo "configure:9847: checking for SOCKSinit in -lsocks" >&5
 ac_lib_var=`echo socks'_'SOCKSinit | sed 'y%./+-%__p_%'`
 
 xe_check_libs=" -lsocks "
 cat > conftest.$ac_ext <<EOF
-#line 9779 "configure"
+#line 9852 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -9786,7 +9859,7 @@
 SOCKSinit()
 ; return 0; }
 EOF
-if { (eval echo configure:9790: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:9863: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
--- a/configure.in	Mon Aug 13 10:10:03 2007 +0200
+++ b/configure.in	Mon Aug 13 10:10:54 2007 +0200
@@ -1642,8 +1642,9 @@
   dnl Should we take debugging options into consideration?
   if   test "$GCC" = "yes"; then
     CFLAGS="-g -O2 -Wall -Wno-switch"
-    test "$opsys $machine" = "linux intel386" && \
-      CFLAGS="$CFLAGS -fno-strength-reduce -malign-loops=2 -malign-jumps=2 -malign-functions=2"
+    dnl I'm not convinced this is a good idea any more. -sb
+    dnl test "$opsys $machine" = "linux intel386" && \
+      dnl CFLAGS="$CFLAGS -fno-strength-reduce -malign-loops=2 -malign-jumps=2 -malign-functions=2"
   elif test "$__sunpro_c" = "yes"; then
     case "$opsys" in
       sol2    ) CFLAGS="-v -xO4" ;;
@@ -2359,7 +2360,7 @@
   fi
 
   dnl autodetect ImageMagick
-  test -z "$with_imagick" && { AC_CHECK_HEADER(magick/magick.h,                    ,with_imagick=no) }
+  test -z "$with_imagick" && { AC_CHECK_HEADER(magick/magick.h, ,AC_CHECK_HEADER(X11/magick/magick.h,AC_DEFINE(MAGICK_HEADERS_ARE_UNDER_X11),with_imagick=no)) }
   test -z "$with_imagick" && {
     dnl check the appropriate libraries for ImageMagick
     imagick_libs=""
@@ -2369,6 +2370,7 @@
     AC_CHECK_LIB(jbig, jbg_dec_init, XE_APPEND(-ljbig, imagick_libs))
     AC_CHECK_LIB(jpeg, jpeg_read_header, XE_APPEND(-ljpeg, imagick_libs))
     AC_CHECK_LIB(mpeg, OpenMPEG, XE_APPEND(-lmpeg, imagick_libs))
+    AC_CHECK_LIB(ttf, TT_Init_FreeType, XE_APPEND(-lttf, imagick_libs))
     AC_CHECK_LIB(png, png_create_read_struct, XE_APPEND(-lpng, imagick_libs),
       AC_CHECK_LIB(png, png_create_read_struct, XE_APPEND(-lpng -lz, imagick_libs),,-lz))
     AC_CHECK_LIB(tiff, TIFFOpen, XE_APPEND(-ltiff, imagick_libs),
--- a/etc/BETA	Mon Aug 13 10:10:03 2007 +0200
+++ b/etc/BETA	Mon Aug 13 10:10:54 2007 +0200
@@ -190,8 +190,8 @@
 ** Creating patches for submission
 ==================================
 
-When making patches you should use the `-c' option, or preferably, if
-your diff supports it, `-u'.  Using ordinary (context-free) diffs are
+When making patches please use the `-u' option, or if your diff
+doesn't support it, `-c'.  Using ordinary (context-free) diffs are
 notoriously prone to error, since line numbers tend to change when
 others make changes to the same source file.
 
@@ -209,7 +209,8 @@
 $ diff -u lwlib/xlwmenu.c.orig lwlib/xlwmenu.c
 
 It is preferrable for patches to be accompanied by an update (raw
-entry preferred) to the appropriate ChangeLog file.
+entry preferred) to the appropriate ChangeLog file.  Patches to
+ChangeLog files have an extremely high rate of failure.
 
 Also note that if you cut & paste from an xterm to an XEmacs mail buffer
 you will probably lose due to tab expansion.  The best thing to do is
--- a/etc/NEWS	Mon Aug 13 10:10:03 2007 +0200
+++ b/etc/NEWS	Mon Aug 13 10:10:54 2007 +0200
@@ -3,100 +3,33 @@
 * Introduction
 ==============
 
-This file presents some general information about XEmacs.  It is primarily
-about the evolution of XEmacs and its release history.
-
-There are three sections.
-
-    Introduction................(this section) provides an introduction
-
-    Using Outline Mode..........briefly explains how to use outline mode
-
-    XEmacs Release Notes........details of the changes between releases
-
-New users should look at the next section on "Using Outline Mode".  You will
-be more efficient when you can navigate quickly through this file.  Users
-interested in some of the details of how XEmacs differs from GNU Emacs
-should read the section "What's Different?".
+This file presents some general information about XEmacs.  It is
+primarily about the evolution of XEmacs and its release history.
+
+Use `C-c C-f' to move to the next equal level of outline, and
+`C-c C-b' to move to previous equal level.  `C-h m' will give more
+info about the Outline mode.  Many commands are also available through 
+the menubar.
 
 Users who would like to know which capabilities have been introduced
-in each release should look at the appropriate subsection of the
-"XEmacs Release Notes."  Starting with version 20.0, XEmacs includes
-ChangeLogs, which can be consulted for a more detailed list of
-changes.
-
-    N.B.  The term "FSF GNU Emacs" refers to any release of Emacs Version 19
-    from the Free Software Foundation's GNU Project. (We do not say just
-    "GNU Emacs" because Richard M. Stallman ["RMS"] thinks that this term
-    is too generic; although we sometimes say e.g. "GNU Emacs 19.30" to refer
-    to a specific version of FSF GNU Emacs.  We do not say merely "Emacs", as
-    RMS prefers, because that is clearly an even more generic term.) The term
-    "XEmacs" refers to this program or to its predecessors "Era" and
-    "Lucid Emacs".  The predecessor of all these program is called "Emacs 18".
-    When no particular version is implied, "Emacs" will be used.
-
-
-* Using Outline Mode
-====================
-
-This file is in outline mode, a major mode for viewing (or editing)
-outlines.  It allows you to make parts of the text temporarily invisible so
-that you can see just the overall structure of the outline.
-
-There are two ways of using outline mode:  with keys or with menus.  Using
-outline mode with menus is the simplest and is just as effective as using
-keystrokes.  There are menus for outline mode on the menubar as well as in
-popup menus activated by pressing mouse button 3.
-
-Experiment with the menu commands.  Menu items under "Headings" allow
-you to navigate from heading to heading.  Menu items under "Show" make
-visible portions of the outline while menu items under "Hide" do the
-opposite.
-
-A special minor mode called "outl-mouse" has been automatically enabled.  In
-this minor mode, glyphs appear that, when clicked on, will alternately hide
-or show sections of the outline.
-
-You may at any time press `C-h m' to get a listing of the outline mode key
-bindings.  They are reproduced here:
-
-Commands:
-C-c C-n   outline-next-visible-heading      move by visible headings
-C-c C-p   outline-previous-visible-heading
-C-c C-f   outline-forward-same-level        similar but skip subheadings
-C-c C-b   outline-backward-same-level
-C-c C-u   outline-up-heading		    move from subheading to heading
-
-C-c C-t	make all text invisible (not headings).
-M-x show-all	make everything in buffer visible.
-
-The remaining commands are used when point is on a heading line.
-They apply to some of the body or subheadings of that heading.
-C-c C-d   hide-subtree	make body and subheadings invisible.
-C-c C-s   show-subtree	make body and subheadings visible.
-C-c tab   show-children	make direct subheadings visible.
-		 No effect on body, or subheadings 2 or more levels down.
-		 With arg N, affects subheadings N levels down.
-C-c C-c	   make immediately following body invisible.
-C-c C-e	   make it visible.
-C-c C-l	   make body under heading and under its subheadings invisible.
-		     The subheadings remain visible.
-C-c C-k  make all subheadings at all levels visible.
-
-
-			 XEmacs Release Notes
-			 ====================
-
-* Future Plans for XEmacs
-==========================
-
-** We are working on improving the Mule support in future releases:
-
-*** Other input methods, such as skk, will be supported.
-
-*** Wnn support will be made more solid.
-
-*** More user-level documentation on using Mule.
+in each release should look at the appropriate section of this file.
+Starting with version 20.0, XEmacs includes ChangeLogs, which can be
+consulted for a more detailed list of changes.
+
+Users interested in some of the details of how XEmacs differs from GNU
+Emacs should read the section "What's Different?" near the end of this
+file.
+
+    N.B.  The term "FSF GNU Emacs" refers to any release of Emacs
+    Version 19 from the Free Software Foundation's GNU Project. (We do
+    not say just "GNU Emacs" because Richard M. Stallman ["RMS"]
+    thinks that this term is too generic; although we sometimes say
+    e.g. "GNU Emacs 19.30" to refer to a specific version of FSF GNU
+    Emacs.  We do not say merely "Emacs", as RMS prefers, because that
+    is clearly an even more generic term.) The term "XEmacs" refers to
+    this program or to its predecessors "Era" and "Lucid Emacs".  The
+    predecessor of all these program is called "Emacs 18".  When no
+    particular version is implied, "Emacs" will be used.
 
 
 * Changes in XEmacs 20.4
@@ -106,6 +39,9 @@
 
 #### Document me, please.
 
+** Using the new `-private' option, you can make XEmacs use a private
+colormap.
+
 ** The `imenu' package has been ported to XEmacs.
 
 ** `echo-keystrokes' can now be a floating-point number, so that you
@@ -116,19 +52,83 @@
 ** The `M-.' command will now first search through exact tags matches,
 and then through inexact matches, as one would expect.
 
-** user-full-name  #### Document me.
+** The new variable `user-full-name' can be used to customize one's
+name when using the Emacs mail and news reading facilities.
+
+Normally, `user-full-name' is a function that returns the full name of 
+a user or UID, as specified by the system -- for instance,
+(user-full-name "root") returns something like "Super-User".  However, 
+when the function is called without arguments, it will return the
+value of the `user-full-name' variable.  The `user-full-name' variable 
+is initialized using the environment variable NAME and (failing that)
+the user's system name.
+
+If you specify an argument to the `user-full-name' function, it will
+not respect the `user-full-name' variable.
+
+** The new command `M-x customize-changed-options' lets you customize
+all the options whose default values have changed in recent Emacs
+versions.  You specify a previous Emacs version number as argument,
+and the command creates a customization buffer showing all the
+customizable options whose default values were changed since that
+version.
+
+If you don't specify a particular version number argument, then the
+customization buffer shows all the customizable options for which
+Emacs versions of changes are recorded.
+
+** defcustom now accepts the keyword `:version'.  Use this to specify
+in which version of Emacs a certain variable's default value changed.
+For example,
+
+   (defcustom foo-max 34 "*Maximum number of foo's allowed."
+     :type 'integer
+     :group 'foo
+     :version "20.4")
+
+This information is used to control the customize-changed-options
+command.
+
+** XEmacs/Mule (internationalization) changes.
+
+*** Egg/SJ3 input method is supported officially.  Quail and Egg/Skk
+have been available through the generalized Leim since 20.3.
+
+*** Localized Japanese menubars are available if XEmacs is built with
+XFONTSET and either the X11 libraries are built with X_LOCALE defined
+or the native C libraries support Japanese localization.  This has
+been available since 20.3, only it hasn't been announced before.
 
 
 * Lisp and internal changes in XEmacs 20.4
 ==========================================
 
+** The XEmacs hashtables now have a consistent read/print syntax.
+This means that a hashtable will be readably printed in a
+structure-like form:
+
+   #s(hashtable size 2 data (key1 value1 key2 value2))
+
+When XEmacs reads this form, it will create a new hashtable according
+to description.  This allows you to easily dump hashtables to files
+using `prin1', and read them back in using `read'.
+
+If `print-readably' is non-nil, a more relaxed syntax is used; for
+instance:
+
+   #<hashtable size 2/13 data (key1 value1 key2 value2) 0x874d>
+
+** The `make-event' function now supports the TYPE and PLIST
+arguments, which can be used to create many various events from Lisp.
+See the documentation for details.
+
 ** `function-interactive' is a new function that returns the
 interactive specification of a funcallable object.
 
 ** The new `lmessage' function allows printing of a formatted message
 with a particular label.
 
-  (lmessage 'progress "Processing... %d" counter)
+   (lmessage 'progress "Processing... %d" counter)
 
 This function is more convenient than `display-message' because it
 automatically applies `format' to its arguments.
@@ -2946,8 +2946,8 @@
 FSF 19 uses two distinct objects, "text properties" and "overlays",
 which divide up the functionality between them.  Extents are a
 superset of the functionality of the two FSF data types.  The full FSF
-19 interface to text properties is supported in XEmacs (with extents
-being the underlying representation).
+19 interface to text properties and overlays is supported in XEmacs
+(with extents being the underlying representation).
 
 Extents can be made to be copied into strings, and thus restored by kill
 and yank.  Thus, one can specify this behavior on either "extents" or
@@ -2956,7 +2956,7 @@
 
 Many more packages are provided standard with XEmacs than with FSF 19.
 
-Pixmaps of arbitrary size can be embedded in a buffer.
+Images of arbitrary size can be embedded in a buffer.
 
 Variable width fonts work.
 
--- a/lib-src/ChangeLog	Mon Aug 13 10:10:03 2007 +0200
+++ b/lib-src/ChangeLog	Mon Aug 13 10:10:54 2007 +0200
@@ -1,3 +1,8 @@
+1997-12-09  SL Baur  <steve@altair.xemacs.org>
+
+	* update-elc.sh (ignore_pattern): Correct paths of files that
+	should not be bytecompiled, and remove dead files.
+
 1997-12-02  SL Baur  <steve@altair.xemacs.org>
 
 	* update-elc.sh (mule_p): Update for addition of SKK.
--- a/lib-src/update-elc.sh	Mon Aug 13 10:10:03 2007 +0200
+++ b/lib-src/update-elc.sh	Mon Aug 13 10:10:54 2007 +0200
@@ -159,19 +159,15 @@
 \!/,!d
 \!/edebug/edebug-test.el$!d
 \!/paths.el$!d
-\!/prim/loadup.el$!d
-\!/prim/loadup-el.el$!d
-\!/prim/update-elc.el$!d
-\!/prim/list-autoloads.el$!d
-\!/prim/dumped-lisp.el$!d
-\!/prim/make-docfile.el$!d
+\!/loadup.el$!d
+\!/loadup-el.el$!d
+\!/update-elc.el$!d
+\!/dumped-lisp.el$!d
+\!/make-docfile.el$!d
 \!/site-start.el$!d
 \!/site-load.el$!d
 \!/site-init.el$!d
 \!/version.el$!d
-\!/mule/mule-load.el$!d
-\!/sunpro/sunpro-load.el$!d
-\!/tooltalk/tooltalk-load.el$!d
 \!/language/devanagari.el$!d
 \!/language/indian.el$!d
 \!/language/lao-util.el$!d
--- a/lisp/ChangeLog	Mon Aug 13 10:10:03 2007 +0200
+++ b/lisp/ChangeLog	Mon Aug 13 10:10:54 2007 +0200
@@ -1,3 +1,124 @@
+1997-12-13  SL Baur  <steve@altair.xemacs.org>
+
+	* help.el (describe-function-arglist): Restore.
+	(describe-function-1): Correct typo.
+	From Jamie Zawinski <jwz@netscape.com>
+
+1997-12-13  Hrvoje Niksic  <hniksic@srce.hr>
+
+	* cus-dep.el (Custom-make-dependencies): Cut a newline.
+
+	* cus-edit.el (customize-changed-options): Handle output more nicely.
+	(customize-changed-options): Mention `:version' instead of `:new'.
+	(customize-changed-options): Use `push'.
+
+1997-12-12  Colin Rafferty  <colin@xemacs.org>
+
+	* window.el (shrink-window-if-larger-than-buffer): Modified the
+	algorithm so that is calculates the amount it can shrink the
+	buffer by shrinking the buffer itself first.
+
+1997-12-10  Hrvoje Niksic  <hniksic@srce.hr>
+
+	* undo-stack.el (trunc-stack-bottom): Don't terminate error
+	message with a period.
+
+	* cus-start.el: Synch quoter with `custom-quote'.
+
+	* custom.el (custom-add-load): Update custom-group-hash-table.
+
+1997-12-12  Hrvoje Niksic  <hniksic@srce.hr>
+
+	* mouse.el (mouse-track-run-hook): Understand `make-local-hook'
+ 	convention.
+
+	* custom.el (custom-add-version): New function, from FSF.
+	(custom-handle-keyword): Use it.
+
+	* cus-edit.el (custom-variable-prompt): Require match.
+	(customize-changed-options): New function, from FSF.
+	(customize-version-lessp): Ditto.
+
+	* cus-edit.el (custom-quote): Defalias to `quote-maybe'.
+	(customize-set-variable): Use `quote-maybe'.
+	(customize-save-variable): Ditto.
+	(custom-variable-value-create): Ditto.
+	(custom-variable-set): Ditto.
+	(custom-variable-save): Ditto.
+
+	* cus-start.el: Use `quote-maybe'.
+
+1997-12-11  Hrvoje Niksic  <hniksic@srce.hr>
+
+	* simple.el (fsf:do-auto-fill): Comment out.
+
+	* simple.el (set-goal-column): Be careful about the format
+	argument to message.
+
+	* cl-macs.el: New setf methods for: buffer-dedicated-frame,
+ 	console-type-image-conversion-list, default-toolbar-position,
+ 	device-class, extent-begin-glyph, extent-begin-glyph-layout,
+ 	extent-end-glyph, extent-end-glyph-layout, extent-keymap,
+ 	extent-parent, extent-properties, frame-selected-window,
+ 	itimer-function, itimer-function-arguments, itimer-is-idle,
+ 	itimer-recorded-run-time, itimer-restart, itimer-uses-arguments,
+ 	itimer-value, keymap-parents, marker-insertion-type,
+ 	mouse-pixel-position, trunc-stack-length, trunc-stack-stack,
+ 	undoable-stack-max and weak-list-list.
+
+1997-12-12  SL Baur  <steve@altair.xemacs.org>
+
+	* keydefs.el (global-map): Import C-x M-: keybinding for
+	`repeat-complex-command' from Emacs 20.
+
+1997-12-11  Christoph Wedler  <wedler@fmi.uni-passau.de>
+
+	* mule/mule-debug.el (list-charsets): Make it work.  Better
+	formatting.
+
+1997-12-11  SL Baur  <steve@altair.xemacs.org>
+
+	* files.el (insert-file): Don't use format.el settings.
+
+	* format.el (format-decode): Update docstring.
+
+1997-12-09  SL Baur  <steve@altair.xemacs.org>
+
+	* make-docfile.el (package-path): Set load-path from package path
+	before collecting the files to dump.
+	* update-elc.el (package-path): Ditto.
+
+	* loadup.el: Comment changes, cleanup.
+
+1997-12-09  Hrvoje Niksic  <hniksic@srce.hr>
+
+	* etags.el (tags-loop-continue): Avoid giant `progn' in while test.
+	(next-file): Use `pop'.
+
+1997-12-08  Hrvoje Niksic  <hniksic@srce.hr>
+
+	* etags.el (find-tag-internal): Set the initial fuzz offset to 100
+ 	instead of 1000.
+	(find-tag-internal): Use `letf'.
+	(tags-delete): Removed -- was unused.
+	(set-buffer-tag-table): Use `expland-file-name'.
+	(get-tag-table-buffer): Use `ecase'.
+	(add-to-tag-completion-table): Mark the filename messages with
+ 	progress.
+	(add-to-tag-completion-table): Use `char-after' instead of
+ 	`following-char'.
+	(add-to-tag-completion-table): Use `match-string'.
+	(complete-symbol): Use `error' instead of message+ding.
+	(complete-symbol): Use `skip-syntax-forward'.
+	(tag-complete-symbol): Autoload.
+	(pop-mark-from-stack): Use `buffer-live-p'.
+	(pop-tag-mark): Autoload the `M-*' binding.
+	(list-tags): Made it work.
+
+1997-12-09  SL Baur  <steve@altair.xemacs.org>
+
+	* x-toolbar.el (toolbar-news): Fix typo.
+
 1997-12-06  Jonathan Harris <jhar@tardis.ed.ac.uk>
 
 	* dumped-lisp.el, emacs.c, symsinit.h, msw-init.el, 	  nt/xemacs.mak
--- a/lisp/auto-autoloads.el	Mon Aug 13 10:10:03 2007 +0200
+++ b/lisp/auto-autoloads.el	Mon Aug 13 10:10:54 2007 +0200
@@ -522,7 +522,7 @@
 
 ;;;***
 
-;;;### (autoloads (customize-menu-create custom-menu-create custom-save-all customize-save-customized customize-browse custom-buffer-create-other-window custom-buffer-create customize-apropos-groups customize-apropos-faces customize-apropos-options customize-apropos customize-saved customize-customized customize-face-other-window customize-face customize-option-other-window customize-variable customize-other-window customize customize-save-variable customize-set-variable customize-set-value) "cus-edit" "lisp/cus-edit.el")
+;;;### (autoloads (customize-menu-create custom-menu-create custom-save-all customize-save-customized customize-browse custom-buffer-create-other-window custom-buffer-create customize-apropos-groups customize-apropos-faces customize-apropos-options customize-apropos customize-saved customize-customized customize-face-other-window customize-face customize-option-other-window customize-changed-options customize-variable customize-other-window customize customize-save-variable customize-set-variable customize-set-value) "cus-edit" "lisp/cus-edit.el")
 
 (autoload 'customize-set-value "cus-edit" "\
 Set VARIABLE to VALUE.  VALUE is a Lisp object.
@@ -579,6 +579,10 @@
 (autoload 'customize-variable "cus-edit" "\
 Customize SYMBOL, which must be a user option variable." t nil)
 
+(autoload 'customize-changed-options "cus-edit" "\
+Customize all user option variables whose default values changed recently.
+This means, in other words, variables defined with a `:new' option." t nil)
+
 (defalias 'customize-variable-other-window 'customize-option-other-window)
 
 (autoload 'customize-option-other-window "cus-edit" "\
@@ -724,16 +728,10 @@
 
 ;;;***
 
-;;;### (autoloads (tags-apropos list-tags tags-query-replace tags-search tags-loop-continue next-file find-tag-other-window find-tag visit-tags-table) "etags" "lisp/etags.el")
-
-(defcustom tags-build-completion-table 'ask "*If this variable is nil, then tags completion is disabled.\nIf this variable is t, then things which prompt for tags will do so with \n completion across all known tags.\nIf this variable is the symbol `ask', then you will be asked whether each\n tags table should be added to the completion list as it is read in.\n (With the exception that for very small tags tables, you will not be asked,\n since they can be parsed quickly.)" :type '(radio (const :tag "Disabled" nil) (const :tag "Complete All" t) (const :tag "Ask" ask)) :group 'etags)
-
-(defcustom tags-always-exact nil "*If this variable is non-nil, then tags always looks for exact matches." :type 'boolean :group 'etags)
-
-(defcustom tag-table-alist nil "*A list which determines which tags files are active for a buffer.\nThis is not really an association list, in that all elements are\nchecked.  The CAR of each element of this list is a pattern against\nwhich the buffer's file name is compared; if it matches, then the CDR\nof the list should be the name of the tags table to use.  If more than\none element of this list matches the buffer's file name, then all of\nthe associated tags tables will be used.  Earlier ones will be\nsearched first.\n\nIf the CAR of elements of this list are strings, then they are treated\nas regular-expressions against which the file is compared (like the\nauto-mode-alist).  If they are not strings, then they are evaluated.\nIf they evaluate to non-nil, then the current buffer is considered to\nmatch.\n\nIf the CDR of the elements of this list are strings, then they are\nassumed to name a TAGS file.  If they name a directory, then the string\n\"TAGS\" is appended to them to get the file name.  If they are not \nstrings, then they are evaluated, and must return an appropriate string.\n\nFor example:\n  (setq tag-table-alist\n	'((\"/usr/src/public/perl/\" . \"/usr/src/public/perl/perl-3.0/\")\n	 (\"\\\\.el$\" . \"/usr/local/emacs/src/\")\n	 (\"/jbw/gnu/\" . \"/usr15/degree/stud/jbw/gnu/\")\n	 (\"\" . \"/usr/local/emacs/src/\")\n	 ))\n\nThis means that anything in the /usr/src/public/perl/ directory should use\nthe TAGS file /usr/src/public/perl/perl-3.0/TAGS; and file ending in .el should\nuse the TAGS file /usr/local/emacs/src/TAGS; and anything in or below the\ndirectory /jbw/gnu/ should use the TAGS file /usr15/degree/stud/jbw/gnu/TAGS.\nA file called something like \"/usr/jbw/foo.el\" would use both the TAGS files\n/usr/local/emacs/src/TAGS and /usr15/degree/stud/jbw/gnu/TAGS (in that order)\nbecause it matches both patterns.\n\nIf the buffer-local variable `buffer-tag-table' is set, then it names a tags\ntable that is searched before all others when find-tag is executed from this\nbuffer.\n\nIf there is a file called \"TAGS\" in the same directory as the file in \nquestion, then that tags file will always be used as well (after the\n`buffer-tag-table' but before the tables specified by this list.)\n\nIf the variable tags-file-name is set, then the tags file it names will apply\nto all buffers (for backwards compatibility.)  It is searched first.\n" :type '(repeat (cons (choice :value "" (regexp :tag "Buffer regexp") (function :tag "Expression")) (string :tag "Tag file or directory"))) :group 'etags)
+;;;### (autoloads (tags-apropos list-tags tags-query-replace tags-search tags-loop-continue next-file tag-complete-symbol find-tag-other-window find-tag visit-tags-table) "etags" "lisp/etags.el")
 
 (autoload 'visit-tags-table "etags" "\
-Tell tags commands to use tags table file FILE first.
+Tell tags commands to use tags table file FILE when all else fails.
 FILE should be the name of a file created with the `etags' program.
 A directory name is ok too; it means file TAGS in that directory." t nil)
 
@@ -782,6 +780,9 @@
   make-tags-files-invisible	whether tags tables should be very hidden
   tag-mark-stack-max		how many tags-based hops to remember" t nil)
 
+(autoload 'tag-complete-symbol "etags" "\
+The function used to do tags-completion (using 'tag-completion-predicate)." t nil)
+
 (autoload 'next-file "etags" "\
 Select next file among files in current tag table(s).
 
@@ -821,100 +822,35 @@
 See documentation of variable `tag-table-alist'." t nil)
 
 (autoload 'list-tags "etags" "\
-Display list of tags in file FILE.
-FILE should not contain a directory spec
-unless it has one in the tag table." t nil)
+Display list of tags in FILE." t nil)
 
 (autoload 'tags-apropos "etags" "\
 Display list of all tags in tag table REGEXP matches." t nil)
 
+(define-key esc-map "*" 'pop-tag-mark)
+
 ;;;***
 
 ;;;### (autoloads (font-lock-set-defaults-1 font-lock-fontify-buffer turn-off-font-lock turn-on-font-lock font-lock-mode) "font-lock" "lisp/font-lock.el")
 
-(defvar font-lock-auto-fontify t "\
-*Whether font-lock should automatically fontify files as they're loaded.
-This will only happen if font-lock has fontifying keywords for the major
-mode of the file.  You can get finer-grained control over auto-fontification
-by using this variable in combination with `font-lock-mode-enable-list' or
-`font-lock-mode-disable-list'.")
-
-(defvar font-lock-mode-enable-list nil "\
-*List of modes to auto-fontify, if `font-lock-auto-fontify' is nil.")
-
-(defvar font-lock-mode-disable-list nil "\
-*List of modes not to auto-fontify, if `font-lock-auto-fontify' is t.")
+(defcustom font-lock-auto-fontify t "*Whether font-lock should automatically fontify files as they're loaded.\nThis will only happen if font-lock has fontifying keywords for the major\nmode of the file.  You can get finer-grained control over auto-fontification\nby using this variable in combination with `font-lock-mode-enable-list' or\n`font-lock-mode-disable-list'." :type 'boolean :group 'font-lock)
 
-(defvar font-lock-use-colors '(color) "\
-*Specification for when Font Lock will set up color defaults.
-Normally this should be '(color), meaning that Font Lock will set up
-color defaults that are only used on color displays.  Set this to nil
-if you don't want Font Lock to set up color defaults at all.  This
-should be one of
+(defcustom font-lock-mode-enable-list nil "*List of modes to auto-fontify, if `font-lock-auto-fontify' is nil." :type '(repeat (symbol :tag "Mode")) :group 'font-lock)
 
--- a list of valid tags, meaning that the color defaults will be used
-   when all of the tags apply. (e.g. '(color x))
--- a list whose first element is 'or and whose remaining elements are
-   lists of valid tags, meaning that the defaults will be used when
-   any of the tag lists apply.
--- nil, meaning that the defaults should not be set up at all.
-
-\(If you specify face values in your init file, they will override any
-that Font Lock specifies, regardless of whether you specify the face
-values before or after loading Font Lock.)
+(defcustom font-lock-mode-disable-list nil "*List of modes not to auto-fontify, if `font-lock-auto-fontify' is t." :type '(repeat (symbol :tag "Mode")) :group 'font-lock)
 
-See also `font-lock-use-fonts'.  If you want more control over the faces
-used for fontification, see the documentation of `font-lock-mode' for
-how to do it.")
-
-(defvar font-lock-use-fonts '(or (mono) (grayscale)) "\
-*Specification for when Font Lock will set up non-color defaults.
-
-Normally this should be '(or (mono) (grayscale)), meaning that Font
-Lock will set up non-color defaults that are only used on either mono
-or grayscale displays.  Set this to nil if you don't want Font Lock to
-set up non-color defaults at all.  This should be one of
-
--- a list of valid tags, meaning that the non-color defaults will be used
-   when all of the tags apply. (e.g. '(grayscale x))
--- a list whose first element is 'or and whose remaining elements are
-   lists of valid tags, meaning that the defaults will be used when
-   any of the tag lists apply.
--- nil, meaning that the defaults should not be set up at all.
+(defcustom font-lock-use-colors '(color) "*Specification for when Font Lock will set up color defaults.\nNormally this should be '(color), meaning that Font Lock will set up\ncolor defaults that are only used on color displays.  Set this to nil\nif you don't want Font Lock to set up color defaults at all.  This\nshould be one of\n\n-- a list of valid tags, meaning that the color defaults will be used\n   when all of the tags apply. (e.g. '(color x))\n-- a list whose first element is 'or and whose remaining elements are\n   lists of valid tags, meaning that the defaults will be used when\n   any of the tag lists apply.\n-- nil, meaning that the defaults should not be set up at all.\n\n(If you specify face values in your init file, they will override any\nthat Font Lock specifies, regardless of whether you specify the face\nvalues before or after loading Font Lock.)\n\nSee also `font-lock-use-fonts'.  If you want more control over the faces\nused for fontification, see the documentation of `font-lock-mode' for\nhow to do it." :type 'sexp :group 'font-lock)
 
-\(If you specify face values in your init file, they will override any
-that Font Lock specifies, regardless of whether you specify the face
-values before or after loading Font Lock.)
-
-See also `font-lock-use-colors'.  If you want more control over the faces
-used for fontification, see the documentation of `font-lock-mode' for
-how to do it.")
+(defcustom font-lock-use-fonts '(or (mono) (grayscale)) "*Specification for when Font Lock will set up non-color defaults.\n\nNormally this should be '(or (mono) (grayscale)), meaning that Font\nLock will set up non-color defaults that are only used on either mono\nor grayscale displays.  Set this to nil if you don't want Font Lock to\nset up non-color defaults at all.  This should be one of\n\n-- a list of valid tags, meaning that the non-color defaults will be used\n   when all of the tags apply. (e.g. '(grayscale x))\n-- a list whose first element is 'or and whose remaining elements are\n   lists of valid tags, meaning that the defaults will be used when\n   any of the tag lists apply.\n-- nil, meaning that the defaults should not be set up at all.\n\n(If you specify face values in your init file, they will override any\nthat Font Lock specifies, regardless of whether you specify the face\nvalues before or after loading Font Lock.)\n\nSee also `font-lock-use-colors'.  If you want more control over the faces\nused for fontification, see the documentation of `font-lock-mode' for\nhow to do it." :type 'sexp :group 'font-lock)
 
-(defvar font-lock-maximum-decoration nil "\
-*If non-nil, the maximum decoration level for fontifying.
-If nil, use the minimum decoration (equivalent to level 0).
-If t, use the maximum decoration available.
-If a number, use that level of decoration (or if not available the maximum).
-If a list, each element should be a cons pair of the form (MAJOR-MODE . LEVEL),
-where MAJOR-MODE is a symbol or t (meaning the default).  For example:
- ((c++-mode . 2) (c-mode . t) (t . 1))
-means use level 2 decoration for buffers in `c++-mode', the maximum decoration
-available for buffers in `c-mode', and level 1 decoration otherwise.")
+(defcustom font-lock-maximum-decoration t "*If non-nil, the maximum decoration level for fontifying.\nIf nil, use the minimum decoration (equivalent to level 0).\nIf t, use the maximum decoration available.\nIf a number, use that level of decoration (or if not available the maximum).\nIf a list, each element should be a cons pair of the form (MAJOR-MODE . LEVEL),\nwhere MAJOR-MODE is a symbol or t (meaning the default).  For example:\n ((c++-mode . 2) (c-mode . t) (t . 1))\nmeans use level 2 decoration for buffers in `c++-mode', the maximum decoration\navailable for buffers in `c-mode', and level 1 decoration otherwise." :type '(choice (const :tag "default" nil) (const :tag "maximum" t) (integer :tag "level" 1) (repeat :menu-tag "mode specific" :tag "mode specific" :value ((t . t)) (cons :tag "Instance" (radio :tag "Mode" (const :tag "all" t) (symbol :tag "name")) (radio :tag "Decoration" (const :tag "default" nil) (const :tag "maximum" t) (integer :tag "level" 1))))) :group 'font-lock)
 
 (define-obsolete-variable-alias 'font-lock-use-maximal-decoration 'font-lock-maximum-decoration)
 
-(defvar font-lock-maximum-size (* 250 1024) "\
-*If non-nil, the maximum size for buffers for fontifying.
-Only buffers less than this can be fontified when Font Lock mode is turned on.
-If nil, means size is irrelevant.
-If a list, each element should be a cons pair of the form (MAJOR-MODE . SIZE),
-where MAJOR-MODE is a symbol or t (meaning the default).  For example:
- ((c++-mode . 256000) (c-mode . 256000) (rmail-mode . 1048576))
-means that the maximum size is 250K for buffers in `c++-mode' or `c-mode', one
-megabyte for buffers in `rmail-mode', and size is irrelevant otherwise.")
+(defcustom font-lock-maximum-size (* 250 1024) "*If non-nil, the maximum size for buffers for fontifying.\nOnly buffers less than this can be fontified when Font Lock mode is turned on.\nIf nil, means size is irrelevant.\nIf a list, each element should be a cons pair of the form (MAJOR-MODE . SIZE),\nwhere MAJOR-MODE is a symbol or t (meaning the default).  For example:\n ((c++-mode . 256000) (c-mode . 256000) (rmail-mode . 1048576))\nmeans that the maximum size is 250K for buffers in `c++-mode' or `c-mode', one\nmegabyte for buffers in `rmail-mode', and size is irrelevant otherwise." :type '(choice (const :tag "none" nil) (integer :tag "size") (repeat :menu-tag "mode specific" :tag "mode specific" :value ((t)) (cons :tag "Instance" (radio :tag "Mode" (const :tag "all" t) (symbol :tag "name")) (radio :tag "Size" (const :tag "none" nil) (integer :tag "size"))))) :group 'font-lock)
 
 (defvar font-lock-keywords nil "\
-*A list of the keywords to highlight.
+A list of the keywords to highlight.
 Each element should be of the form:
 
  MATCHER
@@ -1102,10 +1038,12 @@
 
 ;;;***
 
-;;;### (autoloads nil "help-macro" "lisp/help-macro.el")
+;;;### (autoloads (help-read-key) "help-macro" "lisp/help-macro.el")
 
 (defcustom three-step-help t "*Non-nil means give more info about Help command in three steps.\nThe three steps are simple prompt, prompt with all options,\nand window listing and describing the options.\nA value of nil means skip the middle step, so that\n\\[help-command] \\[help-command] gives the window that lists the options." :type 'boolean :group 'help-appearance)
 
+(autoload 'help-read-key "help-macro" nil nil nil)
+
 ;;;***
 
 ;;;### (autoloads (hyper-apropos-popup-menu hyper-apropos-set-variable hyper-set-variable hyper-apropos-read-variable-symbol hyper-describe-function hyper-describe-variable hyper-describe-face hyper-describe-key-briefly hyper-describe-key hyper-apropos) "hyper-apropos" "lisp/hyper-apropos.el")
--- a/lisp/cl-macs.el	Mon Aug 13 10:10:03 2007 +0200
+++ b/lisp/cl-macs.el	Mon Aug 13 10:10:54 2007 +0200
@@ -1700,6 +1700,42 @@
   `(letf (((selected-console) ,c))
      (set ,s ,store)))
 
+(defsetf buffer-dedicated-frame (&optional b) (v)
+  `(set-buffer-dedicated-frame ,b ,v))
+(defsetf console-type-image-conversion-list
+  set-console-type-image-conversion-list)
+(defsetf default-toolbar-position set-default-toolbar-position)
+(defsetf device-class (&optional d) (v)
+  `(set-device-class ,d ,v))
+(defsetf extent-begin-glyph set-extent-begin-glyph)
+(defsetf extent-begin-glyph-layout set-extent-begin-glyph-layout)
+(defsetf extent-end-glyph set-extent-end-glyph)
+(defsetf extent-end-glyph-layout set-extent-end-glyph-layout)
+(defsetf extent-keymap set-extent-keymap)
+(defsetf extent-parent set-extent-parent)
+(defsetf extent-properties set-extent-properties)
+;; Avoid adding various face and glyph functions.
+(defsetf frame-selected-window (&optional f) (v)
+  `(set-frame-selected-window ,f ,v))
+(defsetf itimer-function set-itimer-function)
+(defsetf itimer-function-arguments set-itimer-function-arguments)
+(defsetf itimer-is-idle set-itimer-is-idle)
+(defsetf itimer-recorded-run-time set-itimer-recorded-run-time)
+(defsetf itimer-restart set-itimer-restart)
+(defsetf itimer-uses-arguments set-itimer-uses-arguments)
+(defsetf itimer-value set-itimer-value)
+(defsetf keymap-parents set-keymap-parents)
+(defsetf marker-insertion-type set-marker-insertion-type)
+(defsetf mouse-pixel-position (&optional d) (v)
+  `(progn
+     set-mouse-pixel-position ,d ,(car v) ,(car (cdr v)) ,(cdr (cdr v))
+     ,v))
+(defsetf trunc-stack-length set-trunc-stack-length)
+(defsetf trunc-stack-stack set-trunc-stack-stack)
+(defsetf undoable-stack-max set-undoable-stack-max)
+(defsetf weak-list-list set-weak-list-list)
+
+
 (defsetf getenv setenv t)
 (defsetf get-register set-register)
 (defsetf global-key-binding global-set-key)
--- a/lisp/cus-dep.el	Mon Aug 13 10:10:03 2007 +0200
+++ b/lisp/cus-dep.el	Mon Aug 13 10:10:54 2007 +0200
@@ -154,7 +154,7 @@
 	      (with-temp-file cusload-file
 		(insert ";;; " cusload-base-file
 			" --- automatically extracted custom dependencies\n"
-			"\n\n;;; Code:\n\n")
+			"\n;;; Code:\n\n")
 		(mapatoms
 		 (lambda (sym)
 		   (let ((members (get sym 'custom-group))
--- a/lisp/cus-edit.el	Mon Aug 13 10:10:03 2007 +0200
+++ b/lisp/cus-edit.el	Mon Aug 13 10:10:54 2007 +0200
@@ -35,6 +35,17 @@
 ;; that interferes with completion.  Use `customize-' for commands
 ;; that the user will run with M-x, and `Custom-' for interactive commands.
 
+;; NOTE: In many places within this file we use `mapatoms', which is
+;; very slow in an average XEmacs because of the large number of
+;; symbols requiring a large number of funcalls -- XEmacs with Gnus
+;; can grow to some 17000 symbols without ever doing anything fancy.
+;; It would probably pay off to make a hashtable of symbols known to
+;; Custom, similar to custom-group-hash-table.
+
+;; This is not top priority, because none of the functions that do
+;; mapatoms are speed-critical (the one that was now uses
+;; custom-group-hash-table), but it would be nice to have.
+
 
 ;;; Code:
 
@@ -377,7 +388,7 @@
 		obarray (lambda (symbol)
 			  (and (boundp symbol)
 			       (or (get symbol 'custom-type)
-				   (user-variable-p symbol))))))
+				   (user-variable-p symbol)))) t))
      (list (if (equal val "")
 	       (if (symbolp v) v nil)
 	     (intern val)))))
@@ -830,6 +841,41 @@
 				(custom-unlispify-tag-name symbol))))
 
 ;;;###autoload
+(defun customize-changed-options (since-version)
+  "Customize all user option variables whose default values changed recently.
+This means, in other words, variables defined with a `:version' keyword."
+  (interactive "sCustomize options changed, since version (default all versions): ")
+  (if (equal since-version "")
+      (setq since-version nil))
+  (let ((found nil))
+    (mapatoms (lambda (symbol)
+		(and (boundp symbol)
+		     (let ((version (get symbol 'custom-version)))
+		       (and version
+			    (or (null since-version)
+				(customize-version-lessp since-version version))))
+		     (push (list symbol 'custom-variable) found))))
+    (unless found
+      (error "No user options have changed defaults %s"
+	     (if since-version
+		 (format "since XEmacs %s" since-version)
+	       "in recent Emacs versions")))
+    (custom-buffer-create (custom-sort-items found t nil)
+			  "*Customize Changed Options*")))
+
+(defun customize-version-lessp (version1 version2)
+  (let (major1 major2 minor1 minor2)
+    (string-match "\\([0-9]+\\)[.]\\([0-9]+\\)" version1)
+    (setq major1 (read (match-string 1 version1)))
+    (setq minor1 (read (match-string 2 version1)))
+    (string-match "\\([0-9]+\\)[.]\\([0-9]+\\)" version2)
+    (setq major2 (read (match-string 1 version2)))
+    (setq minor2 (read (match-string 2 version2)))
+    (or (< major1 major2)
+	(and (= major1 major2)
+	     (< minor1 minor2)))))
+
+;;;###autoload
 (defalias 'customize-variable-other-window 'customize-option-other-window)
 
 ;;;###autoload
--- a/lisp/cus-start.el	Mon Aug 13 10:10:03 2007 +0200
+++ b/lisp/cus-start.el	Mon Aug 13 10:10:54 2007 +0200
@@ -162,17 +162,7 @@
 	     (case-replace matching boolean)
 	     (query-replace-highlight matching boolean)
 	     (list-matching-lines-default-context-lines matching integer)))
-      this symbol group type
-      (quoter (lambda (sexp)
-		;; A copy of `custom-quote'
-		(if (or (memq sexp '(t nil))
-			(keywordp sexp)
-			(eq (car-safe sexp) 'lambda)
-			(stringp sexp)
-			(numberp sexp)
-			(characterp sexp))
-		    sexp
-		  (list 'quote sexp)))))
+      this symbol group type)
   (while all
     (setq this (car all)
 	  all (cdr all)
@@ -186,7 +176,7 @@
 	    (message "Intrinsic `%S' not bound" symbol))
       ;; This is called before any user can have changed the value.
       (put symbol 'standard-value 
-	   (list (funcall quoter (default-value symbol))))
+	   (list (quote-maybe (default-value symbol))))
       ;; Add it to the right group.
       (custom-add-to-group group symbol 'custom-variable)
       ;; Set the type.
--- a/lisp/custom.el	Mon Aug 13 10:10:03 2007 +0200
+++ b/lisp/custom.el	Mon Aug 13 10:10:54 2007 +0200
@@ -322,6 +322,8 @@
 Fourth argument TYPE is the custom option type."
   (cond ((eq keyword :group)
 	 (custom-add-to-group value symbol type))
+	((eq keyword :version)
+	 (custom-add-version symbol value))
 	((eq keyword :link)
 	 (custom-add-link symbol value))
 	((eq keyword :load)
@@ -346,9 +348,14 @@
     (unless (member widget links)
       (put symbol 'custom-links (cons widget links)))))
 
+(defun custom-add-version (symbol version)
+  "To the custom option SYMBOL add the version VERSION."
+  (put symbol 'custom-version version))
+
 (defun custom-add-load (symbol load)
   "To the custom option SYMBOL add the dependency LOAD.
 LOAD should be either a library file name, or a feature name."
+  (puthash symbol t custom-group-hash-table)
   (let ((loads (get symbol 'custom-loads)))
     (unless (member load loads)
       (put symbol 'custom-loads (cons load loads)))))
--- a/lisp/dumped-lisp.el	Mon Aug 13 10:10:03 2007 +0200
+++ b/lisp/dumped-lisp.el	Mon Aug 13 10:10:54 2007 +0200
@@ -189,4 +189,5 @@
 ;;	#+sparcworks "sun-eos-debugger-extra"
 ;;	#+sparcworks "sun-eos-menubar"
 	"loaddefs"		; <=== autoloads get loaded here
+	"cc-mode"
 ))
--- a/lisp/etags.el	Mon Aug 13 10:10:03 2007 +0200
+++ b/lisp/etags.el	Mon Aug 13 10:10:54 2007 +0200
@@ -1,39 +1,39 @@
 ;;; etags.el --- etags facility for Emacs
 
-;; Copyright 1985, 1986, 1988, 1990 Free Software Foundation, Inc.
+;; Copyright 1985, 1986, 1988, 1990, 1997 Free Software Foundation, Inc.
 
+;; Author: Their Name is Legion (see list below)
+;; Maintainer: XEmacs Development Team
 ;; Keywords: tools
 
 ;; This file is part of XEmacs.
 
-;; GNU Emacs is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY.  No author or distributor
-;; accepts responsibility to anyone for the consequences of using it
-;; or for whether it serves any particular purpose or works at all,
-;; unless he says so in writing.  Refer to the GNU Emacs General Public
-;; License for full details.
+;; XEmacs 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.
+
+;; XEmacs 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.
 
-;; Everyone is granted permission to copy, modify and redistribute
-;; GNU Emacs, but only under the conditions described in the
-;; GNU Emacs General Public License.   A copy of this license is
-;; supposed to have been given to you along with GNU Emacs so you
-;; can know your rights and responsibilities.  It should be in a
-;; file named COPYING.  Among other things, the copyright notice
-;; and this notice must be preserved on all copies.
+;; You should have received a copy of the GNU General Public License
+;; along with XEmacs; see the file COPYING.  If not, write to the 
+;; Free Software Foundation, 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;;; Synched up with: Not synched with FSF.
 
-;;; Synched up with: Not synched with FSF. (This file is almost
-;;; completely different from FSF's etags.el.  It appears that an
-;;; early version of this file (tags.el) was rewritten by two
-;;; different people; we got one, FSF got the other.  Various
-;;; people have said that our version is better and faster.
+;;; Commentary:
 
+;; This file is completely different from FSF's etags.el.  It appears
+;; that an early version of this file (tags.el) has been rewritten by
+;; two different people; we got one, FSF got the other.  Various
+;; people have said that our version is better and faster.
 
 ;; TODO:
-;; 1. place cursor in echo area while searching
-;; 2. document!
-;; 3. determine semantics of interactively setting the tags file for a buffer
-
-;; Comments with **** mean something is left to be done.
+;; - DOCUMENT!
 
 ;; Derived from the original lisp/tags.el.
 
@@ -52,52 +52,41 @@
 ;; Kyle Jones <kyle_jones@wonderworks.com>
 ;;   added "Exact match, then inexact" code
 ;;   added support for include directive.
+;; Hrvoje Niksic <hniksic@srce.hr>
+;;   various changes.
 
 
-;; Auxiliary functions
-
-(defun tags-delete (item list)
-  "Delete the item from the list, testing with equal.  Copies the list."
-  (delete item (copy-list list)))
-
-(defun tags-remove-duplicates (list)
-  "Delete equal duplicates from the list; copies the list."
-  (let (res)
-    (dolist (el list)
-      (unless (member el res)
-	(push el res)))
-    (nreverse res)))
-
-
-;; Tag tables for a buffer
+;;; User variables.
 
 (defgroup etags nil
-  "Etags facility for Emacs"
+  "Etags facility for Emacs.
+Using etags, you can create tag tables for any number of files, and
+easily access the symbols in those files, using the `\\[find-tag]'
+command."
   :prefix "tags-"
   :group 'tools)
 
 
-;;;###autoload
 (defcustom tags-build-completion-table 'ask
   "*If this variable is nil, then tags completion is disabled.
-If this variable is t, then things which prompt for tags will do so with 
- completion across all known tags.
-If this variable is the symbol `ask', then you will be asked whether each
- tags table should be added to the completion list as it is read in.
- (With the exception that for very small tags tables, you will not be asked,
+If it is t, then things which prompt for tags will do so with completion
+ across all known tags.
+If it is the symbol `ask', you will be asked whether each tags table
+ should be added to the completion list as it is read in.  (With the
+ exception that for very small tags tables, you will not be asked,
  since they can be parsed quickly.)"
-  :type '(radio (const :tag "Disabled" nil)
-		(const :tag "Complete All" t)
-		(const :tag "Ask" ask))
+  :type '(choice (const :tag "Disabled" nil)
+		 (const :tag "Complete All" t)
+		 (const :tag "Ask" ask))
   :group 'etags)
 
-;;;###autoload
 (defcustom tags-always-exact nil
-  "*If this variable is non-nil, then tags always looks for exact matches."
+  "*If this variable is non-nil, then tags always looks for exact matches.
+If it is nil (the default), tags will first go through exact matches,
+then through the non-exact ones."
   :type 'boolean
   :group 'etags)
 
-;;;###autoload
 (defcustom tag-table-alist nil
   "*A list which determines which tags files are active for a buffer.
 This is not really an association list, in that all elements are
@@ -144,17 +133,19 @@
 `buffer-tag-table' but before the tables specified by this list.)
 
 If the variable tags-file-name is set, then the tags file it names will apply
-to all buffers (for backwards compatibility.)  It is searched first.
-"
-  :type '(repeat (cons (choice :value ""
+to all buffers (for backwards compatibility.)  It is searched first."
+  :type '(repeat (cons :format "%v"
+		       (choice :value ""
 			       (regexp :tag "Buffer regexp")
-			       (function :tag "Expression"))
-		       (string :tag "Tag file or directory")))
+			       sexp)
+		       (choice :value ""
+			       (string :tag "Tag file or directory")
+			       sexp)))
   :group 'etags)
 
 (defvar buffer-tag-table nil
   "*The additional name of one TAGS table to be used for this buffer.
-You can set this with meta-x set-buffer-tag-table.  See the documentation
+You can set this with `\\[set-buffer-tag-table]'.  See the documentation
 for the variable `tag-table-alist' for more information.")
 (make-variable-buffer-local 'buffer-tag-table)
 
@@ -163,18 +154,43 @@
 This is for backwards compatibility, and is largely supplanted by the
 variable tag-table-alist.")
 
+(defcustom tags-auto-read-changed-tag-files nil
+  "*If non-nil, always re-read changed TAGS file without prompting.
+If nil, prompt whether to re-read the changed TAGS file."
+  :type 'boolean
+  :group 'etags)
 
-;; XEmacs change: added tags-auto-read-changed-tag-files
-(defcustom tags-auto-read-changed-tag-files nil
-  "*If non-nil, always re-read changed TAGS file without prompting, if nil
-then prompt if changed TAGS file should be re-read."
+(defcustom make-tags-files-invisible nil
+  "*If non-nil, TAGS-files will not show up in buffer-lists or be 
+selectable (or deletable.)"
   :type 'boolean
   :group 'etags)
 
+(defcustom tags-search-nuke-uninteresting-buffers t
+  "*If non-nil, keep newly-visited files if they contain the search target.
+This affects the `tags-search' and `tags-query-replace' commands."
+  :type 'boolean
+  :group 'etags)
+
+
+;; Auxiliary functions
+
+(defun tags-remove-duplicates (list)
+  "Delete equal duplicates from the list; copies the list."
+  (let (res)
+    (dolist (el list)
+      (unless (member el res)
+	(push el res)))
+    (nreverse res)))
+
+
+;; Buffer tag tables.
+
 (defun buffer-tag-table-list ()
   "Returns a list (ordered) of the tags tables which should be used for 
 the current buffer."
   (let (result)
+    ;; Explicitly set buffer-tag-table
     (when buffer-tag-table
       (push buffer-tag-table result))
     ;; Current directory
@@ -216,6 +232,7 @@
 					  (get-tag-table-buffer name))))
 	   result))
     (setq result (delq nil result))
+    ;; If no TAGS file has been found, ask the user explicitly.
     ;; #### tags-file-name is *evil*.
     (or result tags-file-name
 	(call-interactively 'visit-tags-table))
@@ -241,7 +258,7 @@
     ;; It used to be that, if a user pressed RET by mistake, the bogus
     ;; `tags-file-name' would remain, causing the error at
     ;; `buffer-tag-table'.
-    (when (file-readable-p file)
+    (when (file-exists-p file)
       (setq tags-file-name file))))
 
 (defun set-buffer-tag-table (file)
@@ -255,7 +272,7 @@
   (or file (error "No TAGS file name supplied"))
   (setq file (expand-file-name file))
   (when (file-directory-p file)
-    (setq file (concat file "TAGS")))
+    (setq file (expand-file-name "TAGS" file)))
   (or (file-exists-p file) (error "TAGS file missing: %s" file))
   (setq buffer-tag-table file))
 
@@ -263,83 +280,75 @@
 ;; Manipulating the tag table buffer
 
 (defconst tag-table-completion-status nil
-  "Indicates whether a completion table has been built, or has explicitly not 
-been built.  this is nil, t, or 'disabled.")
+  "Indicates whether a completion table has been built.
+Either nil, t, or `disabled'.")
 (make-variable-buffer-local 'tag-table-completion-status)
 
-(defcustom make-tags-files-invisible nil
-  "*If non-nil, TAGS-files will not show up in buffer-lists or be 
-selectable (or deletable.)"
-  :type 'boolean
-  :group 'etags)
-
 (defconst tag-table-files nil
   "If the current buffer is a TAGS table, this holds a list of the files 
 referenced by this file, or nil if that hasn't been computed yet.")
 (make-variable-buffer-local 'tag-table-files)
 
 (defun get-tag-table-buffer (tag-table)
-  "Returns a buffer visiting the given TAGS table, reverting if appropriate,
-and possibly building a completion-table."
+  "Returns a buffer visiting the given TAGS table.
+If appropriate, reverting the buffer, and possibly build a completion-table."
   (or (stringp tag-table)
       (error "Bad tags file name supplied: %s" tag-table))
-  ;; add support for removing symbolic links from name
-  (if (fboundp 'symlink-expand-file-name)
-      (setq tag-table (symlink-expand-file-name tag-table)))
+  ;; Remove symbolic links from name.
+  (setq tag-table (symlink-expand-file-name tag-table))
   (let (buf build-completion check-name)
     (setq buf (get-file-buffer tag-table))
-    (or buf
-	(if (file-readable-p tag-table)
-	    (setq buf (find-file-noselect tag-table)
-		  check-name t)
-	  (error "No such tags file: %s" tag-table)))
+    (unless buf
+      (if (file-readable-p tag-table)
+	  (setq buf (find-file-noselect tag-table)
+		check-name t)
+	(error "No such tags file: %s" tag-table)))
     (with-current-buffer buf
-      ;; make the TAGS buffer invisible
+      ;; Make the TAGS buffer invisible.
       (when (and check-name
 		 make-tags-files-invisible
 		 (string-match "\\`[^ ]" (buffer-name)))
 	(rename-buffer (generate-new-buffer-name
 			(concat " " (buffer-name)))))
       (or (verify-visited-file-modtime buf)
-          ;; XEmacs change: added tags-auto-read-changed-tag-files
-	  (cond ((or tags-auto-read-changed-tag-files (yes-or-no-p
-		  (format "Tags file %s has changed, read new contents? "
-                        tag-table)))
+	  (cond ((or tags-auto-read-changed-tag-files
+		     (yes-or-no-p
+		      (format "Tags file %s has changed, read new contents? "
+			      tag-table)))
 		 (when tags-auto-read-changed-tag-files
 		   (message "Tags file %s has changed, reading new contents..."
 			    tag-table))
 		 (revert-buffer t t)
-		 (if (eq tag-table-completion-status t)
-		     (setq tag-table-completion-status nil))
+		 (when (eq tag-table-completion-status t)
+		   (setq tag-table-completion-status nil))
 		 (setq tag-table-files nil))))
       (or (eq (char-after 1) ?\f)
 	  (error "File %s not a valid tags file" tag-table))
       (or (memq tag-table-completion-status '(t disabled))
 	  (setq build-completion t))
-      (and build-completion
-	   (if (cond
-		((eq tags-build-completion-table nil)
-		 nil)
-		((eq tags-build-completion-table t)
-		 t)
-		((eq tags-build-completion-table 'ask)
-		 ;; don't bother asking for small ones
-		 (or (< (buffer-size) 20000)
-		     (y-or-n-p
-		      (format "Build tag completion table for %s? "
-			      tag-table))))
-		(t (error
-		    "tags-build-completion-table is not t, nil, or ask.")))
-	       (condition-case nil
-		   (progn
-		     (add-to-tag-completion-table)
-		     (setq tag-table-completion-status t))
-		 ;; Allow user to C-g out correctly
-		 (quit
-		  (setq tag-table-completion-status nil)
-		  (setq quit-flag t)
-		  (eval t)))
-	     (setq tag-table-completion-status 'disabled))))
+      (when build-completion
+	(if (ecase tags-build-completion-table
+	      (nil nil)
+	      (t t)
+	      (ask
+	       ;; don't bother asking for small ones
+	       (or (< (buffer-size) 20000)
+		   (y-or-n-p
+		    (format "Build tag completion table for %s? "
+			    tag-table)))))
+	    ;; The user wants to build the table:
+	    (condition-case nil
+		(progn
+		  (add-to-tag-completion-table)
+		  (setq tag-table-completion-status t))
+	      ;; Allow user to C-g out correctly
+	      (quit
+	       (message "Tags completion table construction aborted")
+	       (setq tag-table-completion-status nil
+		     quit-flag t)
+	       t))
+	  ;; The table is verboten.
+	  (setq tag-table-completion-status 'disabled))))
     buf))
 
 (defun file-of-tag ()
@@ -349,24 +358,24 @@
   (let ((opoint (point))
 	prev size)
     (save-excursion
-     (goto-char (point-min))
-     (while (< (point) opoint)
-       (forward-line 1)
-       (end-of-line)
-       (skip-chars-backward "^,\n")
-       (setq prev (point)
-	     size (read (current-buffer)))
-       (goto-char prev)
-       (forward-line 1)
-       ;; New include syntax
-       ;;   filename,include
-       ;; tacked on to the end of a tag file means use filename
-       ;; as a tag file before giving up.
-       ;; Skip it here.
-       (if (not (eq size 'include))
-	   (forward-char size)))
-     (goto-char (1- prev))
-     (buffer-substring (point) (point-at-bol)))))
+      (goto-char (point-min))
+      (while (< (point) opoint)
+	(forward-line 1)
+	(end-of-line)
+	(skip-chars-backward "^,\n")
+	(setq prev (point)
+	      size (read (current-buffer)))
+	(goto-char prev)
+	(forward-line 1)
+	;; New include syntax
+	;;   filename,include
+	;; tacked on to the end of a tag file means use filename
+	;; as a tag file before giving up.
+	;; Skip it here.
+	(unless (eq size 'include)
+	  (forward-char size)))
+      (goto-char (1- prev))
+      (buffer-substring (point) (point-at-bol)))))
 
 (defun tag-table-include-files ()
   "Return all file names associated with `include' directives in a tag buffer."
@@ -376,34 +385,34 @@
   ;; tag file before giving up.
   (let ((files nil))
     (save-excursion
-     (goto-char (point-min))
-     (while (re-search-forward "\f\n\\(.*\\),include$" nil t)
-       (setq files (cons (match-string 1) files))))
-    files ))
+      (goto-char (point-min))
+      (while (re-search-forward "\f\n\\(.*\\),include$" nil t)
+	(push (match-string 1) files)))
+    files))
 
 (defun tag-table-files (tag-table)
   "Returns a list of the files referenced by the named TAGS table."
   (with-current-buffer (get-tag-table-buffer tag-table)
-    (or tag-table-files
-	(let (files prev size)
-	  (goto-char (point-min))
-	  (while (not (eobp))
-	    (forward-line 1)
-	    (end-of-line)
-	    (skip-chars-backward "^,\n")
-	    (setq prev (point)
-		  size (read (current-buffer)))
-	    (goto-char prev)
-	    (push (expand-file-name (buffer-substring (1- (point))
-						      (point-at-bol))
-				    default-directory)
-		  files)
-	    (forward-line 1)
-	    (forward-char size))
-	  (setq tag-table-files (nreverse files))))
+    (unless tag-table-files
+      (let (files prev size)
+	(goto-char (point-min))
+	(while (not (eobp))
+	  (forward-line 1)
+	  (end-of-line)
+	  (skip-chars-backward "^,\n")
+	  (setq prev (point)
+		size (read (current-buffer)))
+	  (goto-char prev)
+	  (push (expand-file-name (buffer-substring (1- (point))
+						    (point-at-bol))
+				  default-directory)
+		files)
+	  (forward-line 1)
+	  (forward-char size))
+	(setq tag-table-files (nreverse files))))
     tag-table-files))
 
-;; **** should this be on previous page?
+;; #### should this be on previous page?
 (defun buffer-tag-table-files ()
   "Returns a list of all files referenced by all TAGS tables that 
 this buffer uses."
@@ -476,29 +485,25 @@
       )
 (defconst tags-file-pattern "^\f\n\\(.+\\),[0-9]+\n")
 
+;; #### Should make it work with the `include' directive!
 (defun add-to-tag-completion-table ()
   "Sucks the current buffer (a TAGS table) into the completion-table."
-  (message "Adding %s to tags completion table..."
-	   buffer-file-name)
+  (message "Adding %s to tags completion table..." buffer-file-name)
   (goto-char (point-min))
   (let ((tag-table-symbol (intern buffer-file-name tag-completion-table))
 	;; tag-table-symbol is used by intern-tag-symbol
 	filename file-type name name2 tag-symbol
 	tag-symbol-tables
 	(case-fold-search nil))
-    ;; loop over the files mentioned in the TAGS file
-    ;; for each file, try to find its major-mode,
-    ;; then process tags appropriately
+    ;; Loop over the files mentioned in the TAGS file for each file,
+    ;; try to find its major-mode, then process tags appropriately.
     (while (looking-at tags-file-pattern)
       (goto-char (match-end 0))
-      (setq filename (file-name-sans-versions
-		      (buffer-substring (match-beginning 1)
-					(match-end 1)))
-	    ;; Old code used to check auto-mode-alist for the proper
-	    ;; file-type.  This is too slow, as it breaks the
-	    ;; compiled-regexp caching, and slows the whole thing
-	    ;; down.  We'll use the shotgun approach with only two
-	    ;; regexps.
+      (setq filename (file-name-sans-versions (match-string 1))
+	    ;; We used to check auto-mode-alist for the proper
+	    ;; file-type.  This was way too slow, as it had to process
+	    ;; an enormous amount of regexps for each time.  Now we
+	    ;; use the shotgun approach with only two regexps.
 	    file-type (cond ((string-match "\\.\\([cC]\\|cc\\|cxx\\)\\'"
 					   filename)
 			     'c-mode)
@@ -508,51 +513,48 @@
 			    ((string-match "\\.scm\\'" filename)
 			     'scheme-mode)
 			    (t nil)))
-      (cond ((and (eq file-type 'c-mode)
-		  c-mode-syntax-table)
-	     (set-syntax-table c-mode-syntax-table))
-	    ((eq file-type 'lisp-mode)
-	     (set-syntax-table lisp-mode-syntax-table))
-	    (t
-	     (set-syntax-table (standard-syntax-table))))
-      ;; clear loop variables
+      (set-syntax-table (cond ((and (eq file-type 'c-mode)
+				    c-mode-syntax-table)
+			       c-mode-syntax-table)
+			      ((eq file-type 'lisp-mode)
+			       lisp-mode-syntax-table)
+			      (t (standard-syntax-table))))
+      ;; Clear loop variables.
       (setq name nil name2 nil)
-      (message "%s..." filename)
-      ;; loop over the individual tag lines
-      (while (not (or (eobp) (eq (following-char) ?\f)))
+      (lmessage 'progress "%s..." filename)
+      ;; Loop over the individual tag lines.
+      (while (not (or (eobp) (eq (char-after) ?\f)))
 	(cond ((and (eq file-type 'c-mode)
 		    (looking-at "DEFUN[ \t]"))
+	       ;; DEFUN
 	       (or (looking-at tags-DEFUN-pattern)
 		   (error "DEFUN doesn't fit pattern"))
-	       (setq name (buffer-substring (match-beginning 1)
-					    (match-end 1))
-		     name2 (buffer-substring (match-beginning 2)
-					     (match-end 2))))
-;;;		  ((looking-at "\\s ")
-;;;		   ;; skip probably bogus entry:
-;;;		   )
+	       (setq name (match-string 1)
+		     name2 (match-string 2)))
+	      ;;((looking-at "\\s ")
+	      ;; skip probably bogus entry:
+	      ;;)
 	      ((and (eq file-type 'c-mode)
 		    (looking-at ".*\\["))
+	       ;; Array
 	       (cond ((not (looking-at tags-array-pattern))
 		      (message "array definition doesn't fit pattern")
 		      (setq name nil))
 		     (t
-		      (setq name (buffer-substring (match-beginning 1)
-						   (match-end 1))))))
+		      (setq name (match-string 1)))))
 	      ((and (eq file-type 'scheme-mode)
 		    (looking-at "\\s-*(\\s-*def\\sw*\\s-*(?\\s-*\\(\\(\\sw\\|\\s_\\|:\\)+\\))?\\s-*\C-?"))
-	       (setq name (buffer-substring (match-beginning 1)
-					    (match-end 1))))
+	       ;; Something Schemish (is this really necessary??)
+	       (setq name (match-string 1)))
 	      ((looking-at tags-def-pattern)
-	       (setq name (buffer-substring (match-beginning 2)
-					    (match-end 2)))))
+	       ;; ???
+	       (setq name (match-string 2))))
 	;; add the tags we found to the completion table
 	(and name (intern-tag-symbol name))
 	(and name2 (intern-tag-symbol name2))
 	(forward-line 1)))
     (or (eobp) (error "Bad TAGS file")))
-  (message "Adding %s to tags completion table...done"
-	   buffer-file-name))
+  (message "Adding %s to tags completion table...done" buffer-file-name))
 
 
 ;; Interactive find-tag
@@ -595,7 +597,7 @@
 	    (intern table-name tag-completion-table))
 	  (buffer-tag-table-list)))
 
-(defvar find-tag-history nil "History list for find-tag-tag")
+(defvar find-tag-history nil "History list for find-tag-tag.")
 
 (defun find-tag-tag (prompt)
   (let* ((default (find-tag-default))
@@ -641,7 +643,8 @@
 	tag-target exact-tagname
 	tag-tables tag-table-point file linebeg startpos buf
 	offset found pat syn-tab)
-    (if (consp tagname) (setq tagname (car tagname)))
+    (when (consp tagname)
+      (setq tagname (car tagname)))
     (cond (next
 	   (setq tagname (car last-tag-data))
 	   (setq tag-table-currently-matching-exact
@@ -654,53 +657,44 @@
       (aset exact-tagname (1- (match-end 0)) ?b))
     (save-excursion
       (catch 'found
-	;; loop searching for exact matches and then inexact matches.
+	;; Loop searching for exact matches and then inexact matches.
 	(while (not (eq tag-table-currently-matching-exact 'neither))
 	  (cond (tmpnext
-		 (setq tag-tables (cdr (cdr (cdr last-tag-data))))
-		 (setq tag-table-point (car (cdr last-tag-data)))
-		 ;; start from the beginning of the table list
-		 ;; on the next iteration of the loop.
+		 (setq tag-tables (cdr (cdr (cdr last-tag-data)))
+		       tag-table-point (car (cdr last-tag-data)))
+		 ;; Start from the beginning of the table list on the
+		 ;; next iteration of the loop.
 		 (setq tmpnext nil))
 		(t
-		 (setq tag-tables (buffer-tag-table-list))
-		 (setq tag-table-point 1)))
+		 (setq tag-tables (buffer-tag-table-list)
+		       tag-table-point 1)))
 	  (if tag-table-currently-matching-exact
-	      (progn
-		(setq tag-target exact-tagname)
-		(setq syn-tab exact-syntax-table))
-	    (setq tag-target tagname)
-	    (setq syn-tab normal-syntax-table))
+	      (setq tag-target exact-tagname
+		    syn-tab exact-syntax-table)
+	    (setq tag-target tagname
+		  syn-tab normal-syntax-table))
 	  (with-caps-disable-folding tag-target
 	    (while tag-tables
 	      (set-buffer (get-tag-table-buffer (car tag-tables)))
 	      (bury-buffer (current-buffer))
 	      (goto-char (or tag-table-point (point-min)))
 	      (setq tag-table-point nil)
-	      (let ((osyn (syntax-table))
-		    case-fold-search)
-		(unwind-protect
-		    (progn
-		      (set-syntax-table syn-tab)
-		      ;; **** should there be support for non-regexp
-		      ;;      tag searches?
-		      (while (re-search-forward tag-target nil t)
-			(if (and (save-match-data
-				   (looking-at "[^\n\C-?]*\C-?"))
-				 ;; if we're looking for inexact
-				 ;; matches, skip exact matches
-				 ;; since we've visited them
-				 ;; already.
-				 (or tag-table-currently-matching-exact
-				     (unwind-protect
-					 (save-excursion
-					   (set-syntax-table
-					    exact-syntax-table)
-					   (goto-char (match-beginning 0))
-					   (not (looking-at exact-tagname)))
-				       (set-syntax-table syn-tab))))
-			    (throw 'found t))))
-		  (set-syntax-table osyn)))
+	      (letf (((syntax-table) syn-tab)
+		     (case-fold-search nil))
+		;; #### should there be support for non-regexp
+		;; tag searches?
+		(while (re-search-forward tag-target nil t)
+		  (and (save-match-data
+			 (looking-at "[^\n\C-?]*\C-?"))
+		       ;; If we're looking for inexact matches, skip
+		       ;; exact matches since we've visited them
+		       ;; already.
+		       (or tag-table-currently-matching-exact
+			   (letf (((syntax-table) exact-syntax-table))
+			     (save-excursion
+			       (goto-char (match-beginning 0))
+			       (not (looking-at exact-tagname)))))
+		       (throw 'found t))))
 	      (setq tag-tables
 		    (nconc (tag-table-include-files) (cdr tag-tables)))))
 	  (if (and (not exact) (eq tag-table-currently-matching-exact t))
@@ -712,8 +706,8 @@
 	       tagname))
       (search-forward "\C-?")
       (setq file (expand-file-name (file-of-tag)
-				   ;; XEmacs change: this needs to be
-				   ;; relative to the 
+				   ;; In XEmacs, this needs to be
+				   ;; relative to:
 				   (or (file-name-directory (car tag-tables))
 				       "./")))
       (setq linebeg (buffer-substring (1- (point)) (point-at-bol)))
@@ -724,23 +718,31 @@
 		   tag-tables))
       (setq buf (find-file-noselect file))
       (with-current-buffer buf
-        (save-excursion
-          (save-restriction
-            (widen)
-            (setq offset 1000)
-            (setq pat (concat "^" (regexp-quote linebeg)))
-            (or startpos (setq startpos (point-min)))
-            (while (and (not found)
-                        (progn
-                          (goto-char (- startpos offset))
-                          (not (bobp))))
-              (setq found (re-search-forward pat (+ startpos offset) t))
-              (setq offset (* 3 offset)))
-            (or found
-                (re-search-forward pat nil t)
-                (error "%s not found in %s" pat file))
-            (beginning-of-line)
-            (setq startpos (point)))))
+	(save-excursion
+	  (save-restriction
+	    (widen)
+	    ;; Here we search for PAT in the range [STARTPOS - OFFSET,
+	    ;; STARTPOS + OFFSET], with increasing values of OFFSET.
+	    ;;
+	    ;; We used to set the initial offset to 1000, but the
+	    ;; actual sources show that finer-grained control is
+	    ;; needed (e.g. two `hash_string's in src/symbols.c.)  So,
+	    ;; I changed 100 to 100, and (* 3 offset) to (* 5 offset).
+	    (setq offset 100)
+	    (setq pat (concat "^" (regexp-quote linebeg)))
+	    (or startpos (setq startpos (point-min)))
+	    (while (and (not found)
+			(progn
+			  (goto-char (- startpos offset))
+			  (not (bobp))))
+	      (setq found (re-search-forward pat (+ startpos offset) t))
+	      (setq offset (* 5 offset)))
+	    ;; Finally, try finding it anywhere in the buffer.
+	    (or found
+		(re-search-forward pat nil t)
+		(error "%s not found in %s" pat file))
+	    (beginning-of-line)
+	    (setq startpos (point)))))
       (cons buf startpos))))
 
 ;;;###autoload
@@ -774,7 +776,7 @@
 	 (result (find-tag-internal tagname))
 	 (tag-buf (car result))
 	 (tag-point (cdr result)))
-    ;; push old position
+    ;; Push old position on the tags mark stack.
     (if (or (not next)
 	    (not (memq last-command
 		       '(find-tag find-tag-other-window tags-loop-continue))))
@@ -794,7 +796,6 @@
   ;; Return t in case used as the tags-loop-scan.
   t)
 
-;; This function is unchanged from lisp/tags.el:
 ;;;###autoload
 (defun find-tag-other-window (tagname &optional next)
   "*Find tag whose name contains TAGNAME.
@@ -825,22 +826,22 @@
     (find-tag tagname t)))
 
 
-;; Completion on tags in the buffer
+;; Completion on tags in the buffer.
 
 (defun complete-symbol (&optional table predicate prettify)
   (let* ((end (point))
 	 (beg (save-excursion
 		(backward-sexp 1)
-		(while (= (char-syntax (following-char)) ?\')
-		  (forward-char 1))
+		;;(while (= (char-syntax (following-char)) ?\')
+		;;  (forward-char 1))
+		(skip-syntax-forward "'")
 		(point)))
 	 (pattern (buffer-substring beg end))
 	 (table (or table obarray))
 	 (completion (try-completion pattern table predicate)))
     (cond ((eq completion t))
 	  ((null completion)
-	   (message "Can't find completion for \"%s\"" pattern)
-	   (ding))
+	   (error "Can't find completion for \"%s\"" pattern))
 	  ((not (string-equal pattern completion))
 	   (delete-region beg end)
 	   (insert completion))
@@ -853,6 +854,7 @@
 	       (display-completion-list list)))
 	   (message "Making completion list...%s" "done")))))
 
+;;;###autoload
 (defun tag-complete-symbol ()
   "The function used to do tags-completion (using 'tag-completion-predicate)."
   (interactive)
@@ -889,36 +891,29 @@
         (t
          ;; Initialize the list by evalling the argument.
          (setq next-file-list (eval initialize))))
-  (if (null next-file-list)
-      (progn
-	(and novisit
-	     (get-buffer " *next-file*")
- 	     (kill-buffer " *next-file*"))
-	(error "All files processed.")))
+  (when (null next-file-list)
+    (and novisit
+	 (get-buffer " *next-file*")
+	 (kill-buffer " *next-file*"))
+    (error "All files processed"))
   (let* ((file (car next-file-list))
 	 (buf (get-file-buffer file))
 	 (new (not buf)))
-    (setq next-file-list (cdr next-file-list))
+    (pop next-file-list)
 
     (if (not (and new novisit))
         (switch-to-buffer (find-file-noselect file novisit) t)
-      ;; Like find-file, but avoids random warning messages.
+      ;; Like find-file, but avoids random junk.
       (set-buffer (get-buffer-create " *next-file*"))
       (kill-all-local-variables)
       (erase-buffer)
       (insert-file-contents file nil))
     (widen)
-    (cond ((> (point) (point-min))
-	   (push-mark nil t)
-	   (goto-char (point-min))))
+    (when (> (point) (point-min))
+      (push-mark nil t)
+      (goto-char (point-min)))
     (and new file)))
 
-(defcustom tags-search-nuke-uninteresting-buffers t
-  "*If t (the default), tags-search and tags-query-replace will only
-keep newly-visited buffers if they contain the search target."
-  :type 'boolean
-  :group 'etags)
-
 ;;;###autoload
 (defun tags-loop-continue (&optional first-time)
   "Continue last \\[tags-search] or \\[tags-query-replace] command.
@@ -930,40 +925,41 @@
 and `tags-loop-operate' is a form to execute to operate on an interesting file
 If the latter returns non-nil, we exit; otherwise we scan the next file."
   (interactive)
-  (let (new
-        (messaged nil))
-    (while
-        (progn
-          ;; Scan files quickly for the first or next interesting one.
-          (while (or first-time
-                     (save-restriction
-                       (widen)
-                       (not (eval tags-loop-scan))))
-            (setq new (next-file first-time
-				 tags-search-nuke-uninteresting-buffers))
-            ;; If NEW is non-nil, we got a temp buffer,
-            ;; and NEW is the file name.
-            (if (or messaged
-                    (and (not first-time)
-                         (> (device-baud-rate) search-slow-speed)
-                         (setq messaged t)))
-                (message "Scanning file %s..." (or new buffer-file-name)))
-            (setq first-time nil)
-            (goto-char (point-min)))
+  (let ((messaged nil)
+	(more-files-p t)
+        new)
+    (while more-files-p
+      ;; Scan files quickly for the first or next interesting one.
+      (while (or first-time
+		 (save-restriction
+		   (widen)
+		   (not (eval tags-loop-scan))))
+	(setq new (next-file first-time
+			     tags-search-nuke-uninteresting-buffers))
+	;; If NEW is non-nil, we got a temp buffer,
+	;; and NEW is the file name.
+	(if (or messaged
+		(and (not first-time)
+		     (> (device-baud-rate) search-slow-speed)
+		     (setq messaged t)))
+	    (lmessage 'progress
+		"Scanning file %s..." (or new buffer-file-name)))
+	(setq first-time nil)
+	(goto-char (point-min)))
 
-          ;; If we visited it in a temp buffer, visit it now for real.
-          (if (and new tags-search-nuke-uninteresting-buffers)
-              (let ((pos (point)))
-                (erase-buffer)
-                (set-buffer (find-file-noselect new))
-                (widen)
-                (goto-char pos)))
+      ;; If we visited it in a temp buffer, visit it now for real.
+      (if (and new tags-search-nuke-uninteresting-buffers)
+	  (let ((pos (point)))
+	    (erase-buffer)
+	    (set-buffer (find-file-noselect new))
+	    (widen)
+	    (goto-char pos)))
 
-          (switch-to-buffer (current-buffer))
+      (switch-to-buffer (current-buffer))
 
-          ;; Now operate on the file.
-          ;; If value is non-nil, continue to scan the next file.
-          (eval tags-loop-operate)))
+      ;; Now operate on the file.
+      ;; If value is non-nil, continue to scan the next file.
+      (setq more-files-p (eval tags-loop-operate)))
     (and messaged
          (null tags-loop-operate)
          (message "Scanning file %s...found" buffer-file-name))))
@@ -980,13 +976,13 @@
   (if (and (equal regexp "")
            (eq (car tags-loop-scan) 'with-caps-disable-folding)
            (null tags-loop-operate))
-      ;; Continue last tags-search as if by M-,.
+      ;; Continue last tags-search as if by `M-,'.
       (tags-loop-continue nil)
     (setq tags-loop-scan `(with-caps-disable-folding ,regexp
                             (re-search-forward ,regexp nil t))
           tags-loop-operate nil)
     (tags-loop-continue (or file-list-form t))))
-  
+
 ;;;###autoload
 (defun tags-query-replace (from to &optional delimited file-list-form)
   "Query-replace-regexp FROM with TO through all files listed in tags table.
@@ -1009,33 +1005,38 @@
 
 ;; Miscellaneous
 
-;; **** need to alter
-;; This function is unchanged from lisp/tags.el:
 ;;;###autoload
-(defun list-tags (string)
-  "Display list of tags in file FILE.
-FILE should not contain a directory spec
-unless it has one in the tag table."
-  (interactive "fList tags (in file): ")
-  (setq string (expand-file-name string))
+(defun list-tags (file)
+  "Display list of tags in FILE."
+  (interactive (list (read-file-name
+		      (if (buffer-file-name)
+			  (format "List tags (in file, %s by default): "
+				  (file-name-nondirectory (buffer-file-name)))
+			"List tags (in file): ")
+		      nil (buffer-file-name) t)))
+  (find-file-noselect file)
   (with-output-to-temp-buffer "*Tags List*"
     (princ "Tags in file ")
-    (princ string)
+    (princ file)
     (terpri)
     (save-excursion
-     (visit-tags-table-buffer)
-     (goto-char 1)
-     (search-forward (concat "\f\n" string ","))
-     (forward-line 1)
-     (while (not (or (eobp) (looking-at "\f")))
-       (princ (buffer-substring (point)
-				(progn (skip-chars-forward "^\C-?")
-				       (point))))
-       (terpri)
-       (forward-line 1)))))
+      (dolist (tags-file (with-current-buffer (get-file-buffer file)
+			   (buffer-tag-table-list)))
+	;; We don't want completions getting in the way.
+	(let ((tags-build-completion-table nil))
+	  (set-buffer (get-tag-table-buffer tags-file)))
+	(goto-char (point-min))
+	(when
+	    (search-forward (concat "\f\n" (file-name-nondirectory file) ",")
+			    nil t)
+	  (forward-line 1)
+	  (while (not (or (eobp) (looking-at "\f")))
+	    (princ (buffer-substring (point)
+				     (progn (skip-chars-forward "^\C-?")
+					    (point))))
+	    (terpri)
+	    (forward-line 1)))))))
 
-;; **** need to alter
-;; This function is unchanged from lisp/tags.el:
 ;;;###autoload
 (defun tags-apropos (string)
   "Display list of all tags in tag table REGEXP matches."
@@ -1045,20 +1046,19 @@
     (prin1 string)
     (terpri)
     (save-excursion
-     (visit-tags-table-buffer)
-     (goto-char 1)
-     (while (re-search-forward string nil t)
-       (beginning-of-line)
-       (princ (buffer-substring (point)
-				(progn (skip-chars-forward "^\C-?")
-				       (point))))
-       (terpri)
-       (forward-line 1)))))
+      (visit-tags-table-buffer)
+      (goto-char 1)
+      (while (re-search-forward string nil t)
+	(beginning-of-line)
+	(princ (buffer-substring (point)
+				 (progn (skip-chars-forward "^\C-?")
+					(point))))
+	(terpri)
+	(forward-line 1)))))
 
-;; **** copied from tags.el
+;; #### copied from tags.el.  This function is *very* big in FSF.
 (defun visit-tags-table-buffer ()
-  "Select the buffer containing the current tag table.
-This is a file whose name is in the variable tags-file-name."
+  "Select the buffer containing the current tag table."
   (or tags-file-name
       (call-interactively 'visit-tags-table))
   (set-buffer (or (get-file-buffer tags-file-name)
@@ -1075,37 +1075,36 @@
 
 ;; Sample uses of find-tag-hook and find-tag-default-hook
 
+;; This is wrong.  We should either make this behaviour default and
+;; back it up, or not use it at all.  For now, I've commented it out.
+;; --hniksic
+
 ;; Example buffer-local tag finding
 
-(or (boundp 'emacs-lisp-mode-hook)
-    (setq emacs-lisp-mode-hook nil))
-(if (eq (car-safe emacs-lisp-mode-hook) 'lambda)
-    (setq emacs-lisp-mode-hook (list emacs-lisp-mode-hook)))
-(or (memq 'setup-emacs-lisp-default-tag-hook emacs-lisp-mode-hook)
-    (setq emacs-lisp-mode-hook
-	  (cons 'setup-emacs-lisp-default-tag-hook emacs-lisp-mode-hook)))
+;(add-hook 'emacs-lisp-mode-hook 'setup-emacs-lisp-default-tag-hook)
 
-(defun setup-emacs-lisp-default-tag-hook ()
-  (cond ((eq major-mode 'emacs-lisp-mode)
-	 (make-variable-buffer-local 'find-tag-default-hook)
-	 (setq find-tag-default-hook 'emacs-lisp-default-tag))))
-;; Run it once immediately
-(setup-emacs-lisp-default-tag-hook)
-(when (get-buffer "*scratch*")
-  (with-current-buffer "*scratch*"
-    (setup-emacs-lisp-default-tag-hook)))
+;(defun setup-emacs-lisp-default-tag-hook ()
+;  (cond ((eq major-mode 'emacs-lisp-mode)
+;	 (make-variable-buffer-local 'find-tag-default-hook)
+;	 (setq find-tag-default-hook 'emacs-lisp-default-tag))))
+;;; Run it once immediately
+;(setup-emacs-lisp-default-tag-hook)
+;(when (get-buffer "*scratch*")
+;  (with-current-buffer "*scratch*"
+;    (setup-emacs-lisp-default-tag-hook)))
 
-(defun emacs-lisp-default-tag ()
-  "Function to return a default tag for Emacs-Lisp mode."
-  (let ((tag (or (variable-at-point)
-		 (function-at-point))))
-    (if tag (symbol-name tag))))
+;(defun emacs-lisp-default-tag ()
+;  "Function to return a default tag for Emacs-Lisp mode."
+;  (let ((tag (or (variable-at-point)
+;		 (function-at-point))))
+;    (if tag (symbol-name tag))))
 
 
 ;; Display short info on tag in minibuffer
 
-(if (null (lookup-key esc-map "?"))
-    (define-key esc-map "?" 'display-tag-info))
+;; Don't pollute `M-?' -- we may need it for more important stuff.  --hniksic
+;(if (null (lookup-key esc-map "?"))
+;    (define-key esc-map "?" 'display-tag-info))
 
 (defun display-tag-info (tagname)
   "Prints a description of the first tag matching TAGNAME in the echo area.
@@ -1160,14 +1159,15 @@
   t)
 
 
-;; Keep track of old locations before finding tags
+;; Tag mark stack.
 
 (defvar tag-mark-stack1 nil)
 (defvar tag-mark-stack2 nil)
+
 (defcustom tag-mark-stack-max 16
   "*The maximum number of elements kept on the mark-stack used
-by tags-search.  See also the commands push-tag-mark (\\[push-tag-mark])
-and pop-tag-mark. (\\[pop-tag-mark])."
+by tags-search.  See also the commands `\\[push-tag-mark]' and
+and `\\[pop-tag-mark]'."
   :type 'integer
   :group 'etags)
 
@@ -1188,21 +1188,21 @@
     (set stack-symbol1 (cdr stack))
     (or m-buf
 	(error "Marker has no buffer"))
-    (if (null (buffer-name m-buf))
+    (or (buffer-live-p m-buf)
 	(error "Buffer has been killed"))
     (push-mark-on-stack stack-symbol2 max-size)
     (switch-to-buffer m-buf)
     (widen)
-    (goto-char (marker-position marker))))
+    (goto-char marker)))
 
 (defun push-tag-mark ()
   (push-mark-on-stack 'tag-mark-stack1 tag-mark-stack-max))
 
-(if (memq (lookup-key esc-map "*") '(nil undefined))
-    (define-key esc-map "*" 'pop-tag-mark))
+;;;###autoload (define-key esc-map "*" 'pop-tag-mark)
 
 (defun pop-tag-mark (arg)
-  "find-tag maintains a mark-stack seperate from the \\[set-mark-command] mark-stack.
+  "Go to last tag position.
+`find-tag' maintains a mark-stack seperate from the \\[set-mark-command] mark-stack.
 This function pops (and moves to) the tag at the top of this stack."
   (interactive "P")
   (if (not arg)
--- a/lisp/files.el	Mon Aug 13 10:10:03 2007 +0200
+++ b/lisp/files.el	Mon Aug 13 10:10:54 2007 +0200
@@ -2451,7 +2451,8 @@
   (if (file-directory-p filename)
       (signal 'file-error (list "Opening input file" "file is a directory"
 				filename)))
-  (let ((tem
+  (let* (format-alist ; format.el only confuses people in this context
+	 (tem
 	 (if codesys
 	     (let ((coding-system-for-read
 		    (get-coding-system codesys)))
--- a/lisp/format.el	Mon Aug 13 10:10:03 2007 +0200
+++ b/lisp/format.el	Mon Aug 13 10:10:54 2007 +0200
@@ -210,7 +210,6 @@
 	  (funcall to-fn from to orig-buf)))))
 
 (defun format-decode (format length &optional visit-flag)
-  ;; This function is called by insert-file-contents whenever a file is read.
   "Decode text from any known FORMAT.
 FORMAT is a symbol appearing in `format-alist' or a list of such symbols, 
 or nil, in which case this function tries to guess the format of the data by
@@ -225,7 +224,9 @@
 
 Returns the new length of the decoded region.
 
-For most purposes, consider using `format-decode-region' instead."
+For most purposes, consider using `format-decode-region' instead.
+
+This function is called by insert-file-contents whenever a file is read."
   (let ((mod (buffer-modified-p))
 	(begin (point))
 	(end (+ (point) length)))
--- a/lisp/help.el	Mon Aug 13 10:10:03 2007 +0200
+++ b/lisp/help.el	Mon Aug 13 10:10:54 2007 +0200
@@ -936,7 +936,7 @@
 	     (princ "a symbol with a void (unbound) function definition." stream))
             (t
              nil)))
-    (princ "\n")
+    (princ "\n" stream)
     (if autoload-file
 	(princ (format "  -- autoloads from \"%s\"\n" autoload-file) stream))
     (or file-name
@@ -1000,24 +1000,26 @@
 		 (terpri stream))))))))
 
 
-;;; ## this doesn't seem to be used for anything
-;; (defun describe-function-arglist (function)
-;;   (interactive (list (or (function-at-point)
-;; 			 (error "no function call at point"))))
-;;   (let ((b nil))
-;;     (unwind-protect
-;; 	(save-excursion
-;; 	  (set-buffer (setq b (get-buffer-create " *arglist*")))
-;; 	  (buffer-disable-undo b)
-;; 	  (erase-buffer)
-;; 	  (describe-function-1 function b t)
-;; 	  (goto-char (point-min))
-;; 	  (end-of-line)
-;; 	  (or (eobp) (delete-char 1))
-;; 	  (just-one-space)
-;; 	  (end-of-line)
-;; 	  (message (buffer-substring (point-min) (point))))
-;;       (and b (kill-buffer b)))))
+;;; this doesn't seem to be used for anything
+;;; Wrong!  Obnoxious, whining people who complain very LOUDLY on Usenet
+;;; are binding this to keys.
+(defun describe-function-arglist (function)
+  (interactive (list (or (function-at-point)
+			 (error "no function call at point"))))
+  (let ((b nil))
+    (unwind-protect
+	(save-excursion
+	  (set-buffer (setq b (get-buffer-create " *arglist*")))
+	  (buffer-disable-undo b)
+	  (erase-buffer)
+	  (describe-function-1 function b t)
+	  (goto-char (point-min))
+	  (end-of-line)
+	  (or (eobp) (delete-char 1))
+	  (just-one-space)
+	  (end-of-line)
+	  (message (buffer-substring (point-min) (point))))
+      (and b (kill-buffer b)))))
 
 
 (defun variable-at-point ()
--- a/lisp/keydefs.el	Mon Aug 13 10:10:03 2007 +0200
+++ b/lisp/keydefs.el	Mon Aug 13 10:10:54 2007 +0200
@@ -213,6 +213,8 @@
 ;; Changed from C-x ESC so that function keys work following C-x.
 (define-key global-map "\C-x\e\e" 'repeat-complex-command)
 ;(define-key global-map "\C-x\e" 'repeat-complex-command)
+;; From Emacs 20.
+(define-key global-map "\C-x\M-:" 'repeat-complex-command)
 (define-key global-map "\C-xu" 'advertised-undo)
 ;; Many people are used to typing C-/ on X terminals and getting C-_.
 (define-key global-map '(control /) 'undo)
--- a/lisp/loadup.el	Mon Aug 13 10:10:03 2007 +0200
+++ b/lisp/loadup.el	Mon Aug 13 10:10:54 2007 +0200
@@ -1,10 +1,11 @@
 ;;; loadup.el --- load up standardly loaded Lisp files for XEmacs.
 
-;; Copyright (C) 1985, 1986, 1992, 1994 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1986, 1992, 1994, 1997 Free Software Foundation, Inc.
 ;; Copyright (C) 1996 Richard Mlynarik.
 ;; Copyright (C) 1995, 1996 Ben Wing.
 
-;; Keywords: internal
+;; Maintainer: XEmacs Development Team
+;; Keywords: internal, dumped
 
 ;; This file is part of XEmacs.
 
@@ -27,10 +28,10 @@
 
 ;;; Commentary:
 
-;; It is not a good idea to edit this file.  Use site-init.el or site-load.el
-;; instead.
-;;
-;; This is loaded into a bare Emacs to make a dumpable one.
+;; Please do not edit this file.  Use site-init.el, site-load.el, or
+;; packaged dumped-lisp.el's instead.
+
+;; This is loaded into a bare XEmacs to make a dumpable one.
 
 ;;; Code:
 
--- a/lisp/make-docfile.el	Mon Aug 13 10:10:03 2007 +0200
+++ b/lisp/make-docfile.el	Mon Aug 13 10:10:54 2007 +0200
@@ -92,15 +92,7 @@
 (require 'packages)
 
 ;; We must have some lisp support at this point
-
-;(load "backquote")
-;(load "bytecomp-runtime")
-;(load "subr")
-;(load "replace")
-;(load "version.el")
-;(load "cl")
-
-;; (load "featurep")
+(packages-find-packages package-path t t)
 
 (let (preloaded-file-list)
  (load (concat default-directory "../lisp/dumped-lisp.el"))
--- a/lisp/mouse.el	Mon Aug 13 10:10:03 2007 +0200
+++ b/lisp/mouse.el	Mon Aug 13 10:10:54 2007 +0200
@@ -382,121 +382,6 @@
   (interactive))
 
 
-;;
-;; Commands for the scroll bar.
-;;
-
-;; this stuff has never ever been used and should be junked.
-
-;; Vertical bar
-
-;(defun mouse-scroll-down (nlines)
-;  "Junk me, please."
-;  (interactive "@p")
-;  (scroll-down nlines))
-
-;(defun mouse-scroll-up (nlines)
-;  "Junk me, please."
-;  (interactive "@p")
-;  (scroll-up nlines))
-
-;(defun mouse-scroll-down-full ()
-;  "Junk me, please."
-;  (interactive "@")
-;  (scroll-down nil))
-
-;(defun mouse-scroll-up-full ()
-;  "Junk me, please."
-;  (interactive "@")
-;  (scroll-up nil))
-
-;(defun mouse-scroll-move-cursor (nlines)
-;  "Junk me, please."
-;  (interactive "@p")
-;  (move-to-window-line nlines))
-
-;(defun mouse-scroll-absolute (event)
-;  "Junk me, please."
-;  (interactive "@e")
-;  (let* ((position (event-x event))
-;	 (length (event-y event))
-;	 (size (buffer-size))
-;	 (scale-factor (max 1 (/ 8000000 size)))
-;	 (newpos (* (/ (* (/ size scale-factor) position) length)
-;		    scale-factor)))
-;    (goto-char newpos)
-;    (recenter '(4))))
-
-;; These scroll while the invoking button is depressed.
-
-;(defvar scrolled-lines 0)
-;(defvar scroll-speed 1)
-
-;(defun incr-scroll-down (event)
-;  "Junk me, please."
-;  (interactive "@e")
-;  (setq scrolled-lines 0)
-;  (incremental-scroll scroll-speed))
-
-;(defun incr-scroll-up (event)
-;  "Junk me, please."
-;  (interactive "@e")
-;  (setq scrolled-lines 0)
-;  (incremental-scroll (- scroll-speed)))
-
-;(defun incremental-scroll (n)
-;  "Junk me, please."
-;  (let ((down t))
-;    (while down
-;      (sit-for mouse-track-scroll-delay)
-;      (cond ((input-pending-p)
-;	     (let ((event (next-command-event)))
-;	       (if (or (button-press-event-p event)
-;		       (button-release-event-p event))
-;		   (setq down nil))
-;	       (dispatch-event event))))
-;      (setq scrolled-lines (1+ (* scroll-speed scrolled-lines)))
-;      (scroll-down n))))
-
-;(defun incr-scroll-stop (event)
-;  "Junk me, please."
-;  (interactive "@e")
-;  (setq scrolled-lines 0)
-;  (sleep-for 1))
-
-
-;(defun mouse-scroll-left (ncolumns)
-;  "Junk me, please."
-;  (interactive "@p")
-;  (scroll-left ncolumns))
-
-;(defun mouse-scroll-right (ncolumns)
-;  "Junk me, please."
-;  (interactive "@p")
-;  (scroll-right ncolumns))
-
-;(defun mouse-scroll-left-full ()
-;  "Junk me, please."
-;  (interactive "@")
-;  (scroll-left nil))
-
-;(defun mouse-scroll-right-full ()
-;  "Junk me, please."
-;  (interactive "@")
-;  (scroll-right nil))
-
-;(defun mouse-scroll-move-cursor-horizontally (ncolumns)
-;  "Junk me, please."
-;  (interactive "@p")
-;  (move-to-column ncolumns))
-
-;(defun mouse-scroll-absolute-horizontally (event)
-;  "Junk me, please."
-;  (interactive "@e")
-;  (set-window-hscroll (selected-window) 33))
-
-
-
 ;;; mouse/selection tracking
 ;;; generalized mouse-track
 
@@ -653,23 +538,40 @@
 			 (copy-event event)))))
 
 (defun mouse-track-run-hook (hook event &rest args)
-  ;; ugh, can't use run-special-hook-with-args because we
-  ;; have to get the value using symbol-value-in-buffer.
-  ;; Doing a save-excursion/set-buffer is wrong because
-  ;; the hook might want to change the buffer, but just
-  ;; doing a set-buffer is wrong because the hook might
-  ;; not want to change the buffer.
+  ;; ugh, can't use run-hook-with-args-until-success because we have
+  ;; to get the value using symbol-value-in-buffer.  Doing a
+  ;; save-excursion/set-buffer is wrong because the hook might want to
+  ;; change the buffer, but just doing a set-buffer is wrong because
+  ;; the hook might not want to change the buffer.
+  ;; #### What we need here is a Lisp interface to
+  ;; run_hook_with_args_in_buffer.  Here is a poor man's version.
   (let ((buffer (event-buffer event)))
-    (if mouse-grabbed-buffer (setq buffer mouse-grabbed-buffer))
-    (if buffer
-	(let ((value (symbol-value-in-buffer hook buffer nil)))
-	  (if (and (listp value) (not (eq (car value) 'lambda)))
-	      (let (retval)
-		(while (and value
-			    (not (setq retval (apply (car value) event args))))
-		  (setq value (cdr value)))
-		retval)
-	    (apply value event args))))))
+    (and mouse-grabbed-buffer (setq buffer mouse-grabbed-buffer))
+    (when buffer
+      (let ((value (symbol-value-in-buffer hook buffer nil)))
+	(if (and (listp value) (not (eq (car value) 'lambda)))
+	    ;; List of functions.
+	    (let (retval)
+	      (while (and value (null retval))
+		;; Found `t': should process default value.  We could
+		;; splice it into the buffer-local value, but that
+		;; would cons, which is not a good thing for
+		;; mouse-track hooks.
+		(if (eq (car value) t)
+		    (let ((global (default-value hook)))
+		      (if (and (listp global) (not (eq (car global) 'lambda)))
+			  ;; List of functions.
+			  (while (and global
+				      (null (setq retval
+						  (apply (car global) event args))))
+			    (pop global))
+			;; lambda
+			(setq retval (apply (car global) event args))))
+		  (setq retval (apply (car value) event args)))
+		(pop value))
+	      retval)
+	  ;; lambda
+	  (apply value event args))))))
 
 (defun mouse-track-scroll-undefined (random)
   ;; the old implementation didn't actually define this function,
--- a/lisp/mule/mule-debug.el	Mon Aug 13 10:10:03 2007 +0200
+++ b/lisp/mule/mule-debug.el	Mon Aug 13 10:10:54 2007 +0200
@@ -43,11 +43,11 @@
     (princ
      "NAME                 REGISTRY        BYTES CHARS FINAL GRAPHIC DIR\n")
     (princ
-     "--------------------------------------------------------------------")
+     "--------------------------------------------------------------------\n")
     (dolist (charset (charset-list))
       (setq charset (get-charset charset))
       (princ (format
-	      "%20s %15s %5d %5d %5d %7d %s\n"
+	      "%-20.20s %-15.15s %5d %5d %5d %-7d %s\n"
 	      (charset-name charset)
 	      (charset-registry  charset)
 	      (charset-dimension charset)
@@ -56,7 +56,7 @@
 	      (charset-graphic   charset)
 	      (charset-direction charset)))
       (princ "        ")
-      (princ "%s\n" (charset-doc-string charset)))))
+      (princ (format "%s\n" (charset-doc-string charset))))))
 
 ;    (princ "## CCL PROGRAM TO CONVERT INTERNAL TO EXTERNAL CODE\n")
 ;    (princ "NAME                 CCL-PROGRAMS\n")
--- a/lisp/simple.el	Mon Aug 13 10:10:03 2007 +0200
+++ b/lisp/simple.el	Mon Aug 13 10:10:54 2007 +0200
@@ -1869,9 +1869,10 @@
         (setq goal-column nil)
         (display-message 'command "No goal column"))
     (setq goal-column (current-column))
-    (message (substitute-command-keys
-	      "Goal column %d (use \\[set-goal-column] with an arg to unset it)")
-	     goal-column))
+    (lmessage 'command
+	"Goal column %d (use %s with an arg to unset it)"
+      goal-column
+      (substitute-command-keys "\\[set-goal-column]")))
   nil)
 
 ;; deleted FSFmacs terminal randomness hscroll-point-visible stuff.
@@ -2490,99 +2491,99 @@
 
 ;; Put FSF one in until I can one or the other working properly, then the
 ;; other one is history.
-(defun fsf:do-auto-fill ()
-  (let (fc justify
-	   ;; bol
-	   give-up
-	   (fill-prefix fill-prefix))
-    (if (or (not (setq justify (current-justification)))
-	    (null (setq fc (current-fill-column)))
-	    (and (eq justify 'left)
-		 (<= (current-column) fc))
-	    (save-excursion (beginning-of-line) 
-			    ;; (setq bol (point))
-			    (and auto-fill-inhibit-regexp
-				 (looking-at auto-fill-inhibit-regexp))))
-	nil ;; Auto-filling not required
-      (if (memq justify '(full center right))
-	  (save-excursion (unjustify-current-line)))
-
-      ;; Choose a fill-prefix automatically.
-      (if (and adaptive-fill-mode
-	       (or (null fill-prefix) (string= fill-prefix "")))
-	  (let ((prefix
-		 (fill-context-prefix
-		  (save-excursion (backward-paragraph 1) (point))
-		  (save-excursion (forward-paragraph 1) (point))
-		  ;; Don't accept a non-whitespace fill prefix
-		  ;; from the first line of a paragraph.
-		  "^[ \t]*$")))
-	    (and prefix (not (equal prefix ""))
-		 (setq fill-prefix prefix))))
-
-      (while (and (not give-up) (> (current-column) fc))
-	;; Determine where to split the line.
-	(let ((fill-point
-	       (let ((opoint (point))
-		     bounce
-		     (first t))
-		 (save-excursion
-		   (move-to-column (1+ fc))
-		   ;; Move back to a word boundary.
-		   (while (or first
-			      ;; If this is after period and a single space,
-			      ;; move back once more--we don't want to break
-			      ;; the line there and make it look like a
-			      ;; sentence end.
-			      (and (not (bobp))
-				   (not bounce)
-				   sentence-end-double-space
-				   (save-excursion (forward-char -1)
-						   (and (looking-at "\\. ")
-							(not (looking-at "\\.  "))))))
-		     (setq first nil)
-		     (skip-chars-backward "^ \t\n")
-		     ;; If we find nowhere on the line to break it,
-		     ;; break after one word.  Set bounce to t
-		     ;; so we will not keep going in this while loop.
-		     (if (bolp)
-			 (progn
-			   (re-search-forward "[ \t]" opoint t)
-			   (setq bounce t)))
-		     (skip-chars-backward " \t"))
-		   ;; Let fill-point be set to the place where we end up.
-		   (point)))))
-	  ;; If that place is not the beginning of the line,
-	  ;; break the line there.
-	  (if (save-excursion
-		(goto-char fill-point)
-		(not (bolp)))
-	      (let ((prev-column (current-column)))
-		;; If point is at the fill-point, do not `save-excursion'.
-		;; Otherwise, if a comment prefix or fill-prefix is inserted,
-		;; point will end up before it rather than after it.
-		(if (save-excursion
-		      (skip-chars-backward " \t")
-		      (= (point) fill-point))
-		    (funcall comment-line-break-function t)
-		  (save-excursion
-		    (goto-char fill-point)
-		    (funcall comment-line-break-function t)))
-		;; Now do justification, if required
-		(if (not (eq justify 'left))
-		    (save-excursion 
-		      (end-of-line 0)
-		      (justify-current-line justify nil t)))
-		;; If making the new line didn't reduce the hpos of
-		;; the end of the line, then give up now;
-		;; trying again will not help.
-		(if (>= (current-column) prev-column)
-		    (setq give-up t)))
-	    ;; No place to break => stop trying.
-	    (setq give-up t))))
-      ;; Justify last line.
-      (justify-current-line justify t t)
-      t)))
+;(defun fsf:do-auto-fill ()
+;  (let (fc justify
+;	   ;; bol
+;	   give-up
+;	   (fill-prefix fill-prefix))
+;    (if (or (not (setq justify (current-justification)))
+;	    (null (setq fc (current-fill-column)))
+;	    (and (eq justify 'left)
+;		 (<= (current-column) fc))
+;	    (save-excursion (beginning-of-line) 
+;			    ;; (setq bol (point))
+;			    (and auto-fill-inhibit-regexp
+;				 (looking-at auto-fill-inhibit-regexp))))
+;	nil ;; Auto-filling not required
+;      (if (memq justify '(full center right))
+;	  (save-excursion (unjustify-current-line)))
+
+;      ;; Choose a fill-prefix automatically.
+;      (if (and adaptive-fill-mode
+;	       (or (null fill-prefix) (string= fill-prefix "")))
+;	  (let ((prefix
+;		 (fill-context-prefix
+;		  (save-excursion (backward-paragraph 1) (point))
+;		  (save-excursion (forward-paragraph 1) (point))
+;		  ;; Don't accept a non-whitespace fill prefix
+;		  ;; from the first line of a paragraph.
+;		  "^[ \t]*$")))
+;	    (and prefix (not (equal prefix ""))
+;		 (setq fill-prefix prefix))))
+
+;      (while (and (not give-up) (> (current-column) fc))
+;	;; Determine where to split the line.
+;	(let ((fill-point
+;	       (let ((opoint (point))
+;		     bounce
+;		     (first t))
+;		 (save-excursion
+;		   (move-to-column (1+ fc))
+;		   ;; Move back to a word boundary.
+;		   (while (or first
+;			      ;; If this is after period and a single space,
+;			      ;; move back once more--we don't want to break
+;			      ;; the line there and make it look like a
+;			      ;; sentence end.
+;			      (and (not (bobp))
+;				   (not bounce)
+;				   sentence-end-double-space
+;				   (save-excursion (forward-char -1)
+;						   (and (looking-at "\\. ")
+;							(not (looking-at "\\.  "))))))
+;		     (setq first nil)
+;		     (skip-chars-backward "^ \t\n")
+;		     ;; If we find nowhere on the line to break it,
+;		     ;; break after one word.  Set bounce to t
+;		     ;; so we will not keep going in this while loop.
+;		     (if (bolp)
+;			 (progn
+;			   (re-search-forward "[ \t]" opoint t)
+;			   (setq bounce t)))
+;		     (skip-chars-backward " \t"))
+;		   ;; Let fill-point be set to the place where we end up.
+;		   (point)))))
+;	  ;; If that place is not the beginning of the line,
+;	  ;; break the line there.
+;	  (if (save-excursion
+;		(goto-char fill-point)
+;		(not (bolp)))
+;	      (let ((prev-column (current-column)))
+;		;; If point is at the fill-point, do not `save-excursion'.
+;		;; Otherwise, if a comment prefix or fill-prefix is inserted,
+;		;; point will end up before it rather than after it.
+;		(if (save-excursion
+;		      (skip-chars-backward " \t")
+;		      (= (point) fill-point))
+;		    (funcall comment-line-break-function t)
+;		  (save-excursion
+;		    (goto-char fill-point)
+;		    (funcall comment-line-break-function t)))
+;		;; Now do justification, if required
+;		(if (not (eq justify 'left))
+;		    (save-excursion 
+;		      (end-of-line 0)
+;		      (justify-current-line justify nil t)))
+;		;; If making the new line didn't reduce the hpos of
+;		;; the end of the line, then give up now;
+;		;; trying again will not help.
+;		(if (>= (current-column) prev-column)
+;		    (setq give-up t)))
+;	    ;; No place to break => stop trying.
+;	    (setq give-up t))))
+;      ;; Justify last line.
+;      (justify-current-line justify t t)
+;      t)))
 
 (defvar normal-auto-fill-function 'do-auto-fill
   "The function to use for `auto-fill-function' if Auto Fill mode is turned on.
@@ -3218,15 +3219,11 @@
       (downcase-region (region-beginning) (region-end))
     (downcase-word arg)))
 
-;;;
-;;; Most of the zmacs code is now in elisp.  The only thing left in C
-;;; are the variables zmacs-regions, zmacs-region-active-p and
-;;; zmacs-region-stays plus the function zmacs_update_region which
-;;; calls the lisp level zmacs-update-region.  It must remain since it
-;;; must be called by core C code.
-;;;
-;;; Huh?  Why couldn't "core C code" just use
-;;; call0(Qzmacs_update_region)??? -hniksic
+;; Most of the zmacs code is now in elisp.  The only thing left in C
+;; are the variables zmacs-regions, zmacs-region-active-p and
+;; zmacs-region-stays plus the function zmacs_update_region which
+;; simply calls the lisp level zmacs-update-region.  It must remain
+;; for convenience, since it is called by core C code.
 
 (defvar zmacs-activate-region-hook nil
   "Function or functions called when the region becomes active;
@@ -3638,6 +3635,7 @@
     error         default label used for reporting errors
   * progress      progress indicators like \"Converting... 45%\"
   * prompt        prompt-like messages like \"I-search: foo\"
+  * command       helper command messages like \"Mark set\"
   * no-log        messages that should never be logged"
   (clear-message label frame stdout-p t)
   (append-message label message frame stdout-p))
--- a/lisp/undo-stack.el	Mon Aug 13 10:10:03 2007 +0200
+++ b/lisp/undo-stack.el	Mon Aug 13 10:10:54 2007 +0200
@@ -129,7 +129,7 @@
 
 ;;; Code:
 
-(define-error 'trunc-stack-bottom "Bottom of stack reached.")
+(define-error 'trunc-stack-bottom "Bottom of stack reached")
 
 (defsubst trunc-stack-stack (stack)
   ;; return the list representing the trunc-stack's elements.
--- a/lisp/update-elc.el	Mon Aug 13 10:10:03 2007 +0200
+++ b/lisp/update-elc.el	Mon Aug 13 10:10:54 2007 +0200
@@ -29,13 +29,13 @@
 
 ;; Byte compile the .EL files necessary to dump out xemacs.
 ;; Use this file like this:
-;;
+
 ;; temacs -batch -l ../lisp/update-elc.el $lisp
-;;
+
 ;; where $lisp comes from the Makefile.  .elc files listed in $lisp will
 ;; cause the corresponding .el file to be compiled.  .el files listed in
 ;; $lisp will be ignored.
-;;
+
 ;; (the idea here is that you can bootstrap if your .ELC files
 ;; are missing or badly out-of-date)
 
@@ -81,13 +81,8 @@
 					  nil 'dirs-only)
 			 (cons temp-path load-path))))
 
-;(load "backquote")
-;(load "bytecomp-runtime")
-;(load "subr")
-;(load "replace")
-;(load "version.el")
-;(load "cl")
-;(load "featurep")
+;; At this point we need to have the package path initialized
+(packages-find-packages package-path t t)
 
 ;; (print (prin1-to-string update-elc-files-to-compile))
 
--- a/lisp/window.el	Mon Aug 13 10:10:03 2007 +0200
+++ b/lisp/window.el	Mon Aug 13 10:10:54 2007 +0200
@@ -278,20 +278,16 @@
   (or window (setq window (selected-window)))
   (save-excursion
     (set-buffer (window-buffer window))
-    (let* ((w (selected-window))	;save-window-excursion can't win
-	   (buffer-file-name buffer-file-name)
-	   (p (point))
-	   (n 0)
-	   (ignore-final-newline
-	    ;; If buffer ends with a newline, ignore it when counting height
-	    ;; unless point is after it.
-	    (and (not (eobp))
-		 (eq ?\n (char-after (1- (point-max))))))
-	   (buffer-read-only nil)
-	   (modified (buffer-modified-p))
-	   (buffer (current-buffer))
-	   (mini (frame-property (window-frame window) 'minibuffer))
-	   (edges (window-pixel-edges (selected-window))))
+    (let ((n 0)
+	  (test-pos
+	   (- (point-max)
+	      ;; If buffer ends with a newline, ignore it when counting
+	      ;; height unless point is after it.
+	      (if (and (not (eobp))
+		       (eq ?\n (char-after (1- (point-max)))))
+		  1 0)))
+	  (mini (frame-property (window-frame window) 'minibuffer))
+	  (edges (window-pixel-edges (selected-window))))
       (if (and (< 1 (let ((frame (selected-frame)))
 		      (select-frame (window-frame window))
 		      (unwind-protect
@@ -307,33 +303,20 @@
 		   (< (nth 3 edges)
 		      (nth 1 (window-pixel-edges mini)))
 		   (> (nth 1 edges)
-		      ;FSFmacs (frame-property (window-frame window)
-		      ;			       'menu-bar-lines params)
 		      0)))
-	  (unwind-protect
-	      (let ((shrinkee (or window w)))
-		(set-buffer (window-buffer shrinkee))
-		(goto-char (point-min))
-		(while (pos-visible-in-window-p
-			(- (point-max)
-			   (if ignore-final-newline 1 0))
-			shrinkee)
-		  ;; defeat file locking... don't try this at home, kids!
-		  (setq buffer-file-name nil)
-		  (insert ?\n) (setq n (1+ n)))
-		(if (> n 0)
-		    (shrink-window (min (1- n)
-					(- (window-height shrinkee)
-					   window-min-height))
-				   nil
-				   shrinkee)))
-	    (delete-region (point-min) (point))
-	    (set-buffer-modified-p modified)
-	    (goto-char p)
-	    ;; (select-window w) ; Emacs
-	    ;; Make sure we unbind buffer-read-only
-	    ;; with the proper current buffer.
-	    (set-buffer buffer))))))
+	  (progn
+	    (save-window-excursion
+	      (goto-char (point-min))
+	      (while (and (window-live-p window)
+			  (pos-visible-in-window-p test-pos window))
+		(shrink-window 1 nil window)
+		(setq n (1+ n))))
+	    (if (> n 0)
+		(shrink-window (min (1- n)
+				    (- (window-height window)
+				       (1+ window-min-height)))
+			       nil
+			       window)))))))
 
 (defun kill-buffer-and-window ()
   "Kill the current buffer and delete the selected window."
--- a/lisp/x-toolbar.el	Mon Aug 13 10:10:03 2007 +0200
+++ b/lisp/x-toolbar.el	Mon Aug 13 10:10:54 2007 +0200
@@ -383,9 +383,10 @@
 (defun toolbar-news ()
   "Run News."
   (interactive)
-  (let ((command (assq toolbar-news-reader toolbar-news-commands-alist)))
+  (let ((command (cdr-safe
+		  (assq toolbar-news-reader toolbar-news-commands-alist))))
     (or command
-	(error "Uknown news reader %s" toolbar-news-reader))
+	(error "Unkown news reader %s" toolbar-news-reader))
     (if (symbolp command)
 	(call-interactively command)
       (eval command))))
--- a/man/ChangeLog	Mon Aug 13 10:10:03 2007 +0200
+++ b/man/ChangeLog	Mon Aug 13 10:10:54 2007 +0200
@@ -1,3 +1,7 @@
+1997-12-10  SL Baur  <steve@altair.xemacs.org>
+
+	* Makefile: Don't stop on errors.
+
 1997-12-06  SL Baur  <steve@altair.xemacs.org>
 
 	* Makefile: add skk manual.
--- a/man/Makefile	Mon Aug 13 10:10:03 2007 +0200
+++ b/man/Makefile	Mon Aug 13 10:10:54 2007 +0200
@@ -89,20 +89,20 @@
 
 .PHONY: dvi
 dvi : $(dvi)
-	for d in $(SUBDIR) ; do (cd $${d} && $(RECURSIVE_MAKE) $@) ; done
+	-for d in $(SUBDIR) ; do (cd $${d} && $(RECURSIVE_MAKE) $@) ; done
 
 .PHONY: mostlyclean clean distclean realclean extraclean
 mostlyclean:
-	for d in $(SUBDIR) ; do (cd $${d} && $(RECURSIVE_MAKE) $@) ; done
+	-for d in $(SUBDIR) ; do (cd $${d} && $(RECURSIVE_MAKE) $@) ; done
 	rm -f *.toc *.aux *.log \
 	      *.cp *.cps *.fn *.fns *.ky *.kys *.pg *.pgs *.vr *.vrs *.tp *.tps
 clean: mostlyclean
-	for d in $(SUBDIR) ; do (cd $${d} && $(RECURSIVE_MAKE) $@) ; done
+	-for d in $(SUBDIR) ; do (cd $${d} && $(RECURSIVE_MAKE) $@) ; done
 	rm -f *.o core *.dvi
 distclean: clean
-	for d in $(SUBDIR) ; do (cd $${d} && $(RECURSIVE_MAKE) $@) ; done
+	-for d in $(SUBDIR) ; do (cd $${d} && $(RECURSIVE_MAKE) $@) ; done
 realclean: distclean
-	for d in $(SUBDIR) ; do (cd $${d} && $(RECURSIVE_MAKE) $@) ; done
+	-for d in $(SUBDIR) ; do (cd $${d} && $(RECURSIVE_MAKE) $@) ; done
 extraclean: distclean
-	for d in $(SUBDIR) ; do (cd $${d} && $(RECURSIVE_MAKE) $@) ; done
+	-for d in $(SUBDIR) ; do (cd $${d} && $(RECURSIVE_MAKE) $@) ; done
 	-rm -f *~ \#*
--- a/nt/ChangeLog	Mon Aug 13 10:10:03 2007 +0200
+++ b/nt/ChangeLog	Mon Aug 13 10:10:54 2007 +0200
@@ -1,3 +1,9 @@
+1997-12-11  David Hobley <davidh@wr.com.au>
+
+        * Added support for auto generation of puresize-adjust.h
+	  in xemacs.mak. Also created new file puresize-adjust.h to copy
+ 	  into src on initial build.
+
 Mon December 08 1997 kkm@kis.ru
 
 	* xemacs.mak: added profile.c, removed event-unixod.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nt/puresize-adjust.h	Mon Aug 13 10:10:54 2007 +0200
@@ -0,0 +1,3 @@
+/*	Do not edit this file!
+	Automatically generated by XEmacs */
+# define PURESIZE_ADJUSTMENT (0)
--- a/nt/xemacs.mak	Mon Aug 13 10:10:03 2007 +0200
+++ b/nt/xemacs.mak	Mon Aug 13 10:10:54 2007 +0200
@@ -1,6 +1,6 @@
 XEMACS=..
 LISP=$(XEMACS)\lisp
-PACKAGE_PATH="~/.xemacs;h:/src/xemacs/packages"
+PACKAGE_PATH="~/.xemacs;f:/src/xemacs/packages"
 HAVE_X=0
 HAVE_MSW=1
 
@@ -43,6 +43,7 @@
 
 !if $(DEBUG_XEMACS)
 DEBUG_DEFINES=-DDEBUG_XEMACS
+DEBUG_FLAGS= -debugtype:both -debug:full
 !endif
 
 !include "..\version.sh"
@@ -55,9 +56,8 @@
 INCLUDES=$(X_INCLUDES) -I$(XEMACS)\nt\inc -I$(XEMACS)\src -I$(XEMACS)\lwlib -I"$(MSVCDIR)\include"
 
 DEFINES=$(X_DEFINES) $(MSW_DEFINES) $(MULE_DEFINES) -DWIN32 -D_WIN32 \
-	-D_M_IX86 -D_X86_ \
 	-DWIN32_LEAN_AND_MEAN -DWINDOWSNT -Demacs -DHAVE_CONFIG_H \
-	-D_MSC_VER=999 -D_DEBUG
+	-D_DEBUG
 
 OUTDIR=obj
 
@@ -71,7 +71,8 @@
 XEMACS_INCLUDES=\
  $(XEMACS)\src\config.h \
  $(XEMACS)\src\Emacs.ad.h \
- $(XEMACS)\src\paths.h
+ $(XEMACS)\src\paths.h \
+ $(XEMACS)\src\puresize-adjust.h
 
 $(XEMACS)\src\config.h:	config.h
 	!copy config.h $(XEMACS)\src
@@ -82,6 +83,9 @@
 $(XEMACS)\src\paths.h:	paths.h
 	!copy paths.h $(XEMACS)\src
 
+$(XEMACS)\src\puresize-adjust.h:	puresize-adjust.h
+	!copy puresize-adjust.h $(XEMACS)\src
+
 #------------------------------------------------------------------------------
 
 # LASTFILE Library
@@ -120,7 +124,7 @@
 	$(OUTDIR)\xlwscrollbar.obj
 
 $(LWLIB): $(LWLIB_OBJS)
-	link.exe -lib -nologo -debugtype:both -out:$@ $(LWLIB_OBJS)
+	link.exe -lib -nologo $(DEBUG_FLAGS) -out:$@ $(LWLIB_OBJS)
 
 $(OUTDIR)\lwlib-config.obj:	$(LWLIB_SRC)\lwlib-config.c
 	 $(CC) $(LWLIB_FLAGS) $**
@@ -153,8 +157,8 @@
 LIB_SRC_LIBS= kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
  advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib libc.lib
 LIB_SRC_LFLAGS=-nologo $(LIB_SRC_LIBS) -base:0x1000000\
- -subsystem:console -pdb:none -debugtype:both -machine:I386\
- -nodefaultlib -out:$@ -debug:full
+ -subsystem:console -pdb:none $(DEBUG_FLAGS) -machine:I386\
+ -nodefaultlib -out:$@
 
 DOC=$(LIB_SRC)\DOC
 DOC_SRC1=\
@@ -187,7 +191,6 @@
  $(XEMACS)\src\emacs.c \
  $(XEMACS)\src\eval.c \
  $(XEMACS)\src\event-stream.c \
- $(XEMACS)\src\event-unixoid.c \
  $(XEMACS)\src\events.c \
  $(XEMACS)\src\extents.c \
  $(XEMACS)\src\faces.c \
@@ -227,6 +230,7 @@
  $(XEMACS)\src\opaque.c \
  $(XEMACS)\src\print.c \
  $(XEMACS)\src\process.c \
+ $(XEMACS)\src\profile.c \
  $(XEMACS)\src\pure.c \
  $(XEMACS)\src\rangetab.c \
  $(XEMACS)\src\realpath.c \
@@ -321,7 +325,7 @@
 $(OUTDIR)\runemacs.obj:	$(XEMACS)\nt\runemacs.c
 	$(CC) -nologo -ML -w $(OPT) -c \
 	-D_DEBUG -DWIN32 -D_WIN32 -DWIN32_LEAN_AND_MEAN \
-	-D_M_IX86 -D_X86_ -Demacs -DHAVE_CONFIG_H -D_MSC_VER=999 \
+	-D_X86_ -Demacs -DHAVE_CONFIG_H \
 	$** -Fo$@
 
 SUPPORT_PROGS=$(MAKE_DOCFILE) $(RUNEMACS)
@@ -336,10 +340,10 @@
 TEMACS_SRC=$(XEMACS)\src
 TEMACS_LIBS=$(LASTFILE) $(LWLIB) $(X_LIBS) kernel32.lib user32.lib gdi32.lib \
  winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib \
- uuid.lib wsock32.lib libc.lib
-TEMACS_LFLAGS=-nologo $(LIBRARIES) -base:0x1000000\
+ uuid.lib wsock32.lib winmm.lib libc.lib
+TEMACS_LFLAGS=-nologo $(LIBRARIES) $(DEBUG_FLAGS) -base:0x1000000\
  -stack:0x800000 -entry:_start -subsystem:console\
- -pdb:$(TEMACS_DIR)\temacs.pdb -map:$(TEMACS_DIR)\temacs.map -debug:full\
+ -pdb:$(TEMACS_DIR)\temacs.pdb -map:$(TEMACS_DIR)\temacs.map \
  -heap:0x00100000 -out:$@
 TEMACS_CPP_FLAGS= $(INCLUDES) $(DEFINES) $(DEBUG_DEFINES) \
  -DEMACS_MAJOR_VERSION=$(emacs_major_version) \
@@ -437,7 +441,6 @@
 	$(OUTDIR)\emacs.obj \
 	$(OUTDIR)\eval.obj \
 	$(OUTDIR)\event-stream.obj \
-	$(OUTDIR)\event-unixoid.obj \
 	$(OUTDIR)\events.obj \
 	$(OUTDIR)\extents.obj \
 	$(OUTDIR)\faces.obj \
@@ -475,6 +478,7 @@
 	$(OUTDIR)\opaque.obj \
 	$(OUTDIR)\print.obj \
 	$(OUTDIR)\process.obj \
+	$(OUTDIR)\profile.obj \
 	$(OUTDIR)\pure.obj \
 	$(OUTDIR)\rangetab.obj \
 	$(OUTDIR)\realpath.obj \
@@ -511,6 +515,8 @@
 $(OUTDIR)\TransientEmacsShell.obj: $(TEMACS_SRC)\EmacsShell-sub.c
 	$(CC) $(TEMACS_FLAGS) -DDEFINE_TRANSIENT_EMACS_SHELL $** -Fo$@
 
+$(OUTDIR)\pure.obj: $(TEMACS_SRC)\pure.c $(TEMACS_SRC)\puresize-adjust.h
+
 #$(TEMACS_SRC)\Emacs.ad.h: $(XEMACS)\etc\Emacs.ad
 #	!"sed -f ad2c.sed < $(XEMACS)\etc\Emacs.ad > $(TEMACS_SRC)\Emacs.ad.h"
 
@@ -551,14 +557,23 @@
 update-elc: $(LOADPATH)\startup.el
 	!$(TEMACS) -batch -l update-elc.el
 
-dump-xemacs:
-	cd $(TEMACS_DIR)
-	!$(TEMACS) -batch -l loadup.el dump
+rebuild: $(TEMACS_DIR)\puresize-adjust.h
+        !nmake -f xemacs.mak dump-xemacs
+
+# This rule dumps xemacs and then checks to see if a rebuild is required due
+# to changing PURESPACE requirements.
+dump-xemacs: $(TEMACS)
+        !touch rebuild
+        cd $(TEMACS_DIR)
+        !$(TEMACS) -batch -l loadup.el dump
+        cd $(XEMACS)\nt
+        !nmake -f xemacs.mak rebuild
 
 #------------------------------------------------------------------------------
 
 # use this rule to build the complete system
 all: $(LASTFILE) $(LWLIB) $(SUPPORT_PROGS) $(TEMACS) $(TEMACS_BROWSE) $(DOC) dump-xemacs
+	-del rebuild
 
 # use this rule to install the system
 install:
--- a/src/ChangeLog	Mon Aug 13 10:10:03 2007 +0200
+++ b/src/ChangeLog	Mon Aug 13 10:10:54 2007 +0200
@@ -1,3 +1,156 @@
+1997-12-13   Kirill M. Katsnelson <kkm@kis.ru>
+
+	* msw-proc.c: added emulation for middle mouse button by chording
+	  left and right buttons
+	* event-msw.c: added lisp variables for resize behavior and middle
+ 	  button emulation thresholds
+	* msw-proc.c: {un}map-frame-hook now are not called directly from
+	  the window procedure, rather from magic event handler.
+	* Formulated golden rule for calling lisp from window procedure:
+	  "NOOOOOO!". May be violated under circumstances although.
+	* frame-msw.c: corrected problem with setting frame width and height
+	  properties, introduced by 95-style look.
+
+1997-12-12  SL Baur  <steve@altair.xemacs.org>
+
+	* input-method-xlib.c (describe_XIC): Add casts, use unsigned long 
+	int.
+
+	* eval.c (funcall_subr): Ifdef out as it is now unused.
+
+	* emacsfns.h: Declare Fdisplay_error.
+
+	* callint.c (Fquote_maybe): Don't use `==' on Lisp_Objects.
+
+1997-12-12  Michael Sperber  <sperber@informatik.uni-tuebingen.de>
+
+	* fileio.c: Removed stillborn set-buffer-modtime.
+
+1997-12-10  Hrvoje Niksic  <hniksic@srce.hr>
+
+	* elhash.c (hashtable_instantiate): If SIZE is nil, set it to
+	length of DATA.
+	(print_hashtable): Would bogusly print #(hashtable).
+	(verify_function): Use XCAR.
+
+1997-12-12  Hrvoje Niksic  <hniksic@srce.hr>
+
+	* elhash.c (print_hashtable_data_mapper): Use a C structure
+	instead of consing.
+
+1997-12-12  Hrvoje Niksic  <hniksic@srce.hr>
+
+	* callint.c (quotify_arg): Don't quotify vectors, keywords,
+ 	bit-vectors and lambdas.
+	(Fquote_maybe): New subr, from quotify_arg.
+	(quotify_args): Use it.
+	(Fcall_interactively): Ditto.
+
+1997-12-11  Hrvoje Niksic  <hniksic@srce.hr>
+
+	* window.c (Fset_window_point): Ditto for Fgoto_char.
+	(Fset_window_configuration): Ditto.
+
+	* undo.c (Fprimitive_undo): Ditto for Fset_buffer_modified_p,
+	Fgoto_char and Fdelete_region.
+
+	* print.c (temp_output_buffer_setup): Ditto.
+
+	* glyphs.c (make_string_from_file): Ditto.
+
+	* glyphs-x.c (pixmap_to_lisp_data): Ditto for Ferase_buffer.
+	(pixmap_to_lisp_data): Ditto for Fbuffer_substring.
+
+	* bytecode.c (Fbyte_code): Use Qnil instead of Fcurrent_buffer()
+ 	when calling functions that use decode_buffer() internally -- it
+ 	is faster.
+
+	Change done for Fgoto_char, Fchar_after, Ffollowing_char,
+ 	Fpreceding_char, Findent_to, Feolp, Feobp, Fbolp, Fbobp,
+ 	Fforward_char, Fforward_word, Fskip_chars_forward,
+ 	Fskip_chars_backward, Fforward_line, Fbuffer_substring,
+ 	Fdelete_region, Fnarrow_to_region, Fwiden, Fend_of_line, Fupcase
+ 	and Fdowncase.
+
+1997-12-11 Jonathan Harris <jhar@tardis.ed.ac.uk>, Kirill M. Katsnelson <kkm@kis.ru>
+
+	* The first collegial patch in the xemacs-nt history. Well...
+	* device-msw.c, event-msw.c, event-msw.h, frame-msw.c, msw-proc.c:
+	  xemacs is now single-threaded application. Due to this, the
+	  problem with crash during input events in GC got resolved.
+	* xemacs frames are given "95ish" look with raised border.
+	* stop character (ctrl+g) now works. SIGINT (ctrl+c or ctrl+break
+	  at the console) is still broken although.
+	* frame "as lisp object" is now stored in window-associated space
+	  provided by the system. This enables obtaining frame object given
+	  window handle in constant time.
+	* mswindows_cancel_dispatch_event() now has limited handling
+	  for key_press_event's in addition to timeout_event's.
+
+1997-12-11  SL Baur  <steve@altair.xemacs.org>
+
+	* intl.c (init_intl_very_early): Force LC_NUMERIC to "C".
+	* input-method-xfs.c (Initialize_Locale): Ditto.
+	* input-method-motif.c (Initialize_Locale): Ditto.
+	* input-method-xlib.c (Initialize_Locale): Ditto.
+	Suggested by Didier Verna <verna@inf.enst.fr> and
+	Martin Buchholz <martin@xemacs.org>
+	
+1997-12-10  Karl M. Hegbloom  <karlheg@bittersweet.inetarena.com>
+
+	* config.h.in: #undef MAGICK_HEADERS_ARE_UNDER_X11
+
+	* glyphs-x.c: #ifdef MAGICK_HEADERS_ARE_UNDER_X11 added.
+
+1997-12-11  SL Baur  <steve@altair.xemacs.org>
+
+	* glyphs-x.c (_XOS_H_): Try to avoid including Xos.h on Solaris.
+	Suggested by Samuel Tardieu <sam@inf.enst.fr>
+
+1997-12-11  David Hobley <davidh@wr.com.au>
+
+	* pure.c: Removed WINDOWSNT conditional.
+
+1997-12-10  SL Baur  <steve@altair.xemacs.org>
+
+	* Makefile.in.in: Doc changes, update dependencies.
+
+	* frame-x.c (x_init_frame_1): Remove unused variable.
+
+	* fns.c (internal_equal): Guard label with ifdef.
+	(internal_old_equal): Ditto.
+
+	* symsinit.h: Declare structure_type_create_hashtable.
+
+	* elhash.c (finish_marking_weak_hashtables): Move unused variable
+	so gcc doesn't complain about it.
+
+	* elhash.h: Declare new weak hashtables.
+
+	* elhash.c (print_hashtable): Fix format.
+
+1997-12-10  Hrvoje Niksic  <hniksic@srce.hr>
+
+	* frame-tty.c (tty_raise_frame_no_select): Use LIST_LOOP.
+	(tty_lower_frame): Ditto.
+
+	* faces.c (face_validate): Don't check for doubly defined
+	keywords; the reader does that.
+
+	* emacs.c (main_1): Call structure_type_create_hashtable().
+
+	* general.c (syms_of_general): Added Qtest and Qsize.
+
+	* elhash.c (structure_type_create_hashtable): New function.
+	(hashtable_type_validate): Ditto.
+	(hashtable_test_validate): Ditto.
+	(hashtable_size_validate): Ditto.
+	(hashtable_data_validate): Ditto.
+	(hashtable_instantiate): Ditto.
+
+	* extents.c (extent_putprop): Made it work.
+	(extent_remprop): Ditto.
+
 1997-12-08  Kirill M. Katsnelson <kkm@kis.ru>
 
 	* device.h: device::fdin and device::fdout are now defined for
--- a/src/Makefile.in.in	Mon Aug 13 10:10:03 2007 +0200
+++ b/src/Makefile.in.in	Mon Aug 13 10:10:54 2007 +0200
@@ -112,7 +112,7 @@
 $(lwlib_libs) :
 	cd ../lwlib && $(RECURSIVE_MAKE)
 
-## a seperate offix lib which merges with non-Xt event systems (TkStep, XEmacs)
+## a separate offix lib which merges with non-Xt event systems (TkStep, XEmacs)
 OFFIX_O = @OFFIX_O@
 
 x_objs=balloon_help.o balloon-x.o console-x.o device-x.o event-Xt.o frame-x.o\
@@ -231,7 +231,7 @@
 #    else
 motif_other_files = libextcli_Xm.a
 #    endif
-#endif
+#endif /* LWLIB_USES_MOTIF */
 
 #  ifdef EXTW_LINK
 shared_other_files = libextcli_Xt.so.1 libextcli_Xlib.so.1
@@ -439,11 +439,11 @@
 	$(PURECOV_PROG) $(LD) $(temacs_link_args)
 
 
-TopLevelEmacsShell.o : ${srcdir}/EmacsShell-sub.c
+TopLevelEmacsShell.o : ${srcdir}/EmacsShell-sub.c config.h xintrinsicp.h EmacsShellP.h
 	$(CC) -c $(cflags) -DDEFINE_TOP_LEVEL_EMACS_SHELL ${srcdir}/EmacsShell-sub.c
 	mv EmacsShell-sub.o TopLevelEmacsShell.o
 
-TransientEmacsShell.o : ${srcdir}/EmacsShell-sub.c TopLevelEmacsShell.o
+TransientEmacsShell.o : ${srcdir}/EmacsShell-sub.c TopLevelEmacsShell.o config.h xintrinsicp.h EmacsShellP.h
 	$(CC) -c $(cflags) -DDEFINE_TRANSIENT_EMACS_SHELL ${srcdir}/EmacsShell-sub.c
 	mv EmacsShell-sub.o TransientEmacsShell.o
 
@@ -647,6 +647,7 @@
 #endif /* GCC */
 
 ## Dependency processing using makedepend
+## This hasn't been used in over a year as of December 10, 1997.
 
 depend:
 	: > depend.tmp
@@ -731,7 +732,10 @@
 unexmips.o: config.h
 unexsunos4.o: config.h
 
-## Dependencies generated by 'make depend'
+## Dependencies (formerly) generated by 'make depend'
+
+## This has been hand-maintained since (at least) some time in 1996
+## Note:  We deliberately do not include a dependency on lisp.h
 
 #ifdef MULE
 EmacsFrame.o: mule-charset.h
@@ -880,10 +884,18 @@
 
 #ifdef HAVE_OFFIX_DND
 device-x.o: offix.h
-event-Xt.o: offix.h
+device-x.o: offix-types.h
+device-x.o: xintrinsic.h
+event-Xt.o: offix.h offix-types.h xintrinsic.h
+event-Xt.o: offix-types.h
+event-Xt.o: xintrinsic.h
 frame-x.o: offix.h
+frame-x.o: offix-types.h
+frame-x.o: xintrinsic.h
 offix.o: offix-cursors.h
 offix.o: offix.h
+offix.o: offix-types.h
+offix.o: xintrinsic.h
 #endif
 
 EmacsFrame.o: $(LWLIB_SRCDIR)/lwlib.h
@@ -1894,6 +1906,10 @@
 libsst.o: config.h
 libsst.o: dynarr.h
 libsst.o: libsst.h
+line-number.o: config.h
+line-number.o: buffer.h
+line-number.o: insdel.h
+line-number.o: line-number.h
 linuxplay.o: blocktype.h
 linuxplay.o: config.h
 linuxplay.o: dynarr.h
@@ -2456,7 +2472,6 @@
 vm-limit.o: dynarr.h
 vm-limit.o: mem-limits.h
 widget.o: config.h
-widget.o: lisp.h
 widget.o: buffer.h
 widget.o: insdel.h
 window.o: blocktype.h
--- a/src/bytecode.c	Mon Aug 13 10:10:03 2007 +0200
+++ b/src/bytecode.c	Mon Aug 13 10:10:54 2007 +0200
@@ -870,7 +870,7 @@
 	  break;
 
 	case Bgoto_char:
-	  TOP = Fgoto_char (TOP, Fcurrent_buffer ());
+	  TOP = Fgoto_char (TOP, Qnil);
 	  break;
 
 	case Binsert:
@@ -894,16 +894,16 @@
 	  break;
 
 	case Bchar_after:
-	  TOP = Fchar_after (TOP, Fcurrent_buffer ());
+	  TOP = Fchar_after (TOP, Qnil);
 	  break;
 
 	case Bfollowing_char:
-	  v1 = Ffollowing_char (Fcurrent_buffer ());
+	  v1 = Ffollowing_char (Qnil);
 	  PUSH (v1);
 	  break;
 
 	case Bpreceding_char:
-	  v1 = Fpreceding_char (Fcurrent_buffer ());
+	  v1 = Fpreceding_char (Qnil);
 	  PUSH (v1);
 	  break;
 
@@ -913,23 +913,23 @@
 	  break;
 
 	case Bindent_to:
-	  TOP = Findent_to (TOP, Qnil, Fcurrent_buffer ());
+	  TOP = Findent_to (TOP, Qnil, Qnil);
 	  break;
 
 	case Beolp:
-	  PUSH (Feolp (Fcurrent_buffer ()));
+	  PUSH (Feolp (Qnil));
 	  break;
 
 	case Beobp:
-	  PUSH (Feobp (Fcurrent_buffer ()));
+	  PUSH (Feobp (Qnil));
 	  break;
 
 	case Bbolp:
-	  PUSH (Fbolp (Fcurrent_buffer ()));
+	  PUSH (Fbolp (Qnil));
 	  break;
 
 	case Bbobp:
-	  PUSH (Fbobp (Fcurrent_buffer ()));
+	  PUSH (Fbobp (Qnil));
 	  break;
 
 	case Bcurrent_buffer:
@@ -950,25 +950,25 @@
 	  break;
 
 	case Bforward_char:
-	  TOP = Fforward_char (TOP, Fcurrent_buffer ());
+	  TOP = Fforward_char (TOP, Qnil);
 	  break;
 
 	case Bforward_word:
-	  TOP = Fforward_word (TOP, Fcurrent_buffer ());
+	  TOP = Fforward_word (TOP, Qnil);
 	  break;
 
 	case Bskip_chars_forward:
 	  v1 = POP;
-	  TOP = Fskip_chars_forward (TOP, v1, Fcurrent_buffer ());
+	  TOP = Fskip_chars_forward (TOP, v1, Qnil);
 	  break;
 
 	case Bskip_chars_backward:
 	  v1 = POP;
-	  TOP = Fskip_chars_backward (TOP, v1, Fcurrent_buffer ());
+	  TOP = Fskip_chars_backward (TOP, v1, Qnil);
 	  break;
 
 	case Bforward_line:
-	  TOP = Fforward_line (TOP, Fcurrent_buffer ());
+	  TOP = Fforward_line (TOP, Qnil);
 	  break;
 
 	case Bchar_syntax:
@@ -986,25 +986,25 @@
 
 	case Bbuffer_substring:
 	  v1 = POP;
-	  TOP = Fbuffer_substring (TOP, v1, Fcurrent_buffer ());
+	  TOP = Fbuffer_substring (TOP, v1, Qnil);
 	  break;
 
 	case Bdelete_region:
 	  v1 = POP;
-	  TOP = Fdelete_region (TOP, v1, Fcurrent_buffer ());
+	  TOP = Fdelete_region (TOP, v1, Qnil);
 	  break;
 
 	case Bnarrow_to_region:
 	  v1 = POP;
-	  TOP = Fnarrow_to_region (TOP, v1, Fcurrent_buffer ());
+	  TOP = Fnarrow_to_region (TOP, v1, Qnil);
 	  break;
 
 	case Bwiden:
-	  PUSH (Fwiden (Fcurrent_buffer ()));
+	  PUSH (Fwiden (Qnil));
 	  break;
 
 	case Bend_of_line:
-	  TOP = Fend_of_line (TOP, Fcurrent_buffer ());
+	  TOP = Fend_of_line (TOP, Qnil);
 	  break;
 
 	case Bset_marker:
@@ -1022,11 +1022,11 @@
 	  break;
 
 	case Bupcase:
-	  TOP = Fupcase (TOP, Fcurrent_buffer ());
+	  TOP = Fupcase (TOP, Qnil);
 	  break;
 
 	case Bdowncase:
-	  TOP = Fdowncase (TOP, Fcurrent_buffer ());
+	  TOP = Fdowncase (TOP, Qnil);
 	break;
 
 	case Bstringeqlsign:
--- a/src/callint.c	Mon Aug 13 10:10:03 2007 +0200
+++ b/src/callint.c	Mon Aug 13 10:10:54 2007 +0200
@@ -145,16 +145,25 @@
   return Qnil;
 }
 
-/* Quotify EXPR: if EXPR is constant, return it.
-   If EXPR is not constant, return (quote EXPR).  */
-static Lisp_Object
-quotify_arg (Lisp_Object expr)
+/* Originally, this was just a function -- but `custom' used a
+   garden-variety version, so why not make it a subr?  */
+/* #### Move it to another file! */
+DEFUN ("quote-maybe", Fquote_maybe, 1, 1, 0, /*
+Quote EXPR iff it is not self quoting.
+*/
+       (expr))
 {
-  return (INTP    (expr) ||
-	  CHARP   (expr) ||
-	  STRINGP (expr) ||
-	  NILP    (expr) ||
-	  EQ (Qt, expr)) ? expr : Fcons (Qquote, Fcons (expr, Qnil));
+  return ((NILP (expr)
+	   || EQ (expr, Qt)
+	   || INTP (expr)
+	   || FLOATP (expr)
+	   || CHARP (expr)
+	   || STRINGP (expr)
+	   || VECTORP (expr)
+	   || KEYWORDP (expr)
+	   || BIT_VECTORP (expr)
+	   || (CONSP (expr) && EQ(XCAR (expr), Qlambda)))
+	  ? expr : list2 (Qquote, expr));
 }
 
 /* Modify EXPR by quotifying each element (except the first).  */
@@ -166,7 +175,7 @@
   for (tail = expr; CONSP (tail); tail = ptr->cdr)
     {
       ptr = XCONS (tail);
-      ptr->car = quotify_arg (ptr->car);
+      ptr->car = Fquote_maybe (ptr->car);
     }
   return expr;
 }
@@ -909,7 +918,7 @@
 	    if (!NILP (varies[argnum]))
 	      visargs[argnum] = list1 (varies[argnum]);
 	    else
-	      visargs[argnum] = quotify_arg (args[argnum]);
+	      visargs[argnum] = Fquote_maybe (args[argnum]);
 	  }
 	Vcommand_history = Fcons (Fcons (args[-1], Flist (argcount, visargs)),
 				  Vcommand_history);
@@ -984,6 +993,7 @@
 #endif
 
   DEFSUBR (Finteractive);
+  DEFSUBR (Fquote_maybe);
   DEFSUBR (Fcall_interactively);
   DEFSUBR (Fprefix_numeric_value);
 }
--- a/src/config.h.in	Mon Aug 13 10:10:03 2007 +0200
+++ b/src/config.h.in	Mon Aug 13 10:10:54 2007 +0200
@@ -297,6 +297,7 @@
 
 /* Compile in support for ImageMagick (all image formats) */
 #undef HAVE_IMAGEMAGICK
+#undef MAGICK_HEADERS_ARE_UNDER_X11
 
 /* Do you have the Xmu library?
    This should always be the case except on losing HP-UX systems. */
--- a/src/console-msw.h	Mon Aug 13 10:10:03 2007 +0200
+++ b/src/console-msw.h	Mon Aug 13 10:10:54 2007 +0200
@@ -70,6 +70,20 @@
 
   /* DC for this win32 window */
   HDC hdc;
+
+  /* Time of last click event, for button 2 emul */
+  DWORD last_click_time;
+
+  /* Coordinates of last click event, screen-relative */
+  POINTS last_click_point;
+
+  /* Misc flags */
+  int button2_need_lbutton : 1;
+  int button2_need_rbutton : 1;
+  int button2_is_down : 1;
+  int ignore_next_lbutton_up : 1;
+  int ignore_next_rbutton_up : 1;
+  int sizing : 1;
 };
 
 #define FRAME_MSWINDOWS_DATA(f) FRAME_TYPE_DATA (f, mswindows)
--- a/src/device-msw.c	Mon Aug 13 10:10:03 2007 +0200
+++ b/src/device-msw.c	Mon Aug 13 10:10:54 2007 +0200
@@ -41,13 +41,12 @@
 
 Lisp_Object Qinit_pre_mswindows_win, Qinit_post_mswindows_win;
 
-DWORD mswindows_main_thread_id;
-DWORD mswindows_win_thread_id;
-
 static void
 mswindows_init_device (struct device *d, Lisp_Object props)
 {
   struct console *con = XCONSOLE (DEVICE_CONSOLE (d));
+  WNDCLASS wc;
+  mswindows_waitable_info_type info;
   HWND desktop;
   HDC hdc;
   MSG msg;
@@ -57,19 +56,6 @@
   init_baud_rate (d);
   init_one_device (d);
 
-  /* Ensure our message queue is created */
-  PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE);
-
-  mswindows_main_thread_id = GetCurrentThreadId ();
-#if 0
-  DuplicateHandle (GetCurrentProcess (), GetCurrentThread (), 
-		   GetCurrentProcess (), &hMainThread, 0, TRUE, DUPLICATE_SAME_ACCESS);
-#endif
-  handle = CreateThread (NULL, 0, 
-			 (LPTHREAD_START_ROUTINE) mswindows_win_thread,
-			 0, 0, &mswindows_win_thread_id);
-  AttachThreadInput (mswindows_main_thread_id, mswindows_win_thread_id, TRUE);
-
   d->device_data = xnew_and_zero (struct mswindows_device);
 
   desktop = GetDesktopWindow();
@@ -87,8 +73,21 @@
   ReleaseDC(desktop, hdc);
 
   DEVICE_CLASS(d) = Qcolor;
-  /* Wait for windows thread to be ready */
-  GetMessage (&msg, NULL, WM_XEMACS_ACK, WM_XEMACS_ACK);
+
+  /* Register the main window class */
+  wc.style = CS_OWNDC;	/* One DC per window */
+  wc.lpfnWndProc = (WNDPROC) mswindows_wnd_proc;
+  wc.cbClsExtra = 0;
+  wc.cbWndExtra = MSWINDOWS_WINDOW_EXTRA_BYTES;
+  wc.hInstance = NULL;	/* ? */
+  wc.hIcon = LoadIcon (NULL, XEMACS_CLASS);
+  wc.hCursor = LoadCursor (NULL, IDC_ARROW);
+  /* Background brush is only used during sizing, when XEmacs cannot
+     take over */
+  wc.hbrBackground = (HBRUSH)(COLOR_APPWORKSPACE + 1);
+  wc.lpszMenuName = NULL;
+  wc.lpszClassName = XEMACS_CLASS;
+  RegisterClass(&wc);		/* XXX FIXME: Should use RegisterClassEx */
 }
 
 static int
--- a/src/device-tty.c	Mon Aug 13 10:10:03 2007 +0200
+++ b/src/device-tty.c	Mon Aug 13 10:10:54 2007 +0200
@@ -121,7 +121,9 @@
 {
   int old_errno = errno;
   asynch_device_change_pending++;
+#ifdef HAVE_UNIXOID_EVENT_LOOP
   signal_fake_event ();
+#endif
   EMACS_REESTABLISH_SIGNAL (SIGWINCH, tty_device_size_change_signal);
   errno = old_errno;
   SIGRETURN;
--- a/src/device.h	Mon Aug 13 10:10:03 2007 +0200
+++ b/src/device.h	Mon Aug 13 10:10:54 2007 +0200
@@ -191,7 +191,7 @@
   unsigned int on_console_p :1;
   unsigned int connected_to_nas_p :1;
 
-#ifdef HAVE_UNIXOID_EVENT_LOOP
+
   /* File descriptors for input and output.  Much of the time
      (but not always) these will be the same.  For an X device,
      these both hold the file descriptor of the socket used
@@ -200,6 +200,11 @@
      is used for I/O. */
   int infd, outfd;
 
+  /* infd and outfd are moved outside HAVE_UNIXOID_EVENT_LOOP conditionals,
+     because Win32, presumably the first port which does not use select()
+     polling, DOES have handles for a console device. -- kkm */
+
+#ifdef HAVE_UNIXOID_EVENT_LOOP
   /* holds some data necessary for SIGIO control.  Perhaps this should
      be inside of device_data; but it is used for both TTY's and X
      device.  Perhaps it should be conditionalized on SIGIO; but
--- a/src/elhash.c	Mon Aug 13 10:10:03 2007 +0200
+++ b/src/elhash.c	Mon Aug 13 10:10:54 2007 +0200
@@ -1,6 +1,7 @@
 /* Lisp interface to hash tables.
    Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc.
    Copyright (C) 1995, 1996 Ben Wing.
+   Copyright (C) 1997 Free Software Foundation, Inc.
 
 This file is part of XEmacs.
 
@@ -27,7 +28,8 @@
 #include "elhash.h"
 #include "bytecode.h"
 
-Lisp_Object Qhashtablep;
+Lisp_Object Qhashtablep, Qhashtable;
+Lisp_Object Qweak, Qkey_weak, Qvalue_weak, Qnon_weak;
 
 #define LISP_OBJECTS_PER_HENTRY (sizeof (hentry) / sizeof (Lisp_Object))/* 2 */
 
@@ -69,28 +71,287 @@
   ((markobj) (table->zero_entry));
   return table->harray;
 }
+
+/* Printing hashtables.
+
+   This is non-trivial, because we use a readable structure-style
+   syntax for hashtables.  This means that a typical hashtable will be
+   readably printed in the form of:
+
+   #s(hashtable size 2 data (key1 value1 key2 value2))
+
+   The supported keywords are `type' (non-weak (or nil), weak,
+   key-weak and value-weak), `test' (eql (or nil), eq or equal),
+   `size' (a natnum or nil) and `data' (a list).
+
+   If `print-readably' is non-nil, then a simpler syntax is used; for
+   instance:
+
+   #<hashtable size 2/13 data (key1 value1 key2 value2) 0x874d>
+
+   The data is truncated to four pairs, and the rest is shown with
+   `...'.  The actual printer is non-consing.  */
+
+struct print_mapper_arg {
+  EMACS_INT count;		/* Used to implement the truncation
+				   for non-readable printing, as well
+				   as to avoid the unnecessary space
+				   at the beginning.  */
+  Lisp_Object printcharfun;
+};
+
+static void
+print_hashtable_data_mapper (void *key, void *contents, void *arg)
+{
+  Lisp_Object keytem, valuetem;
+  struct print_mapper_arg *closure = (struct print_mapper_arg *)arg;
+
+  if (closure->count < 4 || print_readably)
+    {
+      CVOID_TO_LISP (keytem, key);
+      CVOID_TO_LISP (valuetem, contents);
+
+      if (closure->count)
+	write_c_string (" ", closure->printcharfun);
+
+      print_internal (keytem, closure->printcharfun, 1);
+      write_c_string (" ", closure->printcharfun);
+      print_internal (valuetem, closure->printcharfun, 1);
+    }
+  ++closure->count;
+}
+
+/* Print the data of the hashtable.  This maps through a Lisp
+   hashtable and prints key/value pairs using PRINTCHARFUN.  */
+static void
+print_hashtable_data (Lisp_Object hashtable, Lisp_Object printcharfun)
+{
+  struct print_mapper_arg closure;
+  closure.count = 0;
+  closure.printcharfun = printcharfun;
+
+  write_c_string (" data (", printcharfun);
+  elisp_maphash (print_hashtable_data_mapper, hashtable, &closure);
+  write_c_string ((!print_readably && closure.count > 4) ? " ...)" : ")",
+		  printcharfun);
+}
+
+/* Needed for tests.  */
+static int lisp_object_eql_equal (CONST void *x1, CONST void *x2);
+static int lisp_object_equal_equal (CONST void *x1, CONST void *x2);
 
 static void
 print_hashtable (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
 {
   struct hashtable *table = XHASHTABLE (obj);
-  char buf[200];
+  char buf[128];
+
+  write_c_string (print_readably ? "#s(hashtable" : "#<hashtable",
+		  printcharfun);
+  if (table->type != HASHTABLE_NONWEAK)
+    {
+      sprintf (buf, " type %s",
+	       (table->type == HASHTABLE_WEAK ? "weak" :
+		table->type == HASHTABLE_KEY_WEAK ? "key-weak" :
+		table->type == HASHTABLE_VALUE_WEAK ? "value-weak" :
+		"you-d-better-not-see-this"));
+      write_c_string (buf, printcharfun);
+    }
+  /* These checks are way kludgy... */
+  if (table->test_function == NULL)
+    write_c_string (" test eq", printcharfun);
+  else if (table->test_function == lisp_object_equal_equal)
+    write_c_string (" test equal", printcharfun);
+  else if (table->test_function == lisp_object_eql_equal)
+      ;
+  else
+    abort ();
+  if (table->fullness || !print_readably)
+    {
+      if (print_readably)
+	sprintf (buf, " size %d", table->fullness);
+      else
+	sprintf (buf, " size %u/%ld", table->fullness,
+		 XVECTOR_LENGTH (table->harray) / LISP_OBJECTS_PER_HENTRY);
+      write_c_string (buf, printcharfun);
+    }
+  if (table->fullness)
+    print_hashtable_data (obj, printcharfun);
   if (print_readably)
-    error ("printing unreadable object #<hashtable 0x%x>",
-	   table->header.uid);
-  sprintf (buf, GETTEXT ("#<%shashtable %d/%ld 0x%x>"),
-	   (table->type == HASHTABLE_WEAK ? "weak " :
-	    table->type == HASHTABLE_KEY_WEAK ? "key-weak " :
-	    table->type == HASHTABLE_VALUE_WEAK ? "value-weak " :
-	    table->type == HASHTABLE_KEY_CAR_WEAK ? "key-car-weak " :
-	    table->type == HASHTABLE_VALUE_CAR_WEAK ? "value-car-weak " :
-	    ""),
-           table->fullness,
-           XVECTOR_LENGTH (table->harray) / LISP_OBJECTS_PER_HENTRY,
-           table->header.uid);
-  write_c_string (buf, printcharfun);
+    write_c_string (")", printcharfun);
+  else
+    {
+      sprintf (buf, " 0x%x>", table->header.uid);
+      write_c_string (buf, printcharfun);
+    }
+}
+
+
+/* Pretty reading of hashtables.
+
+   Here we use the existing structures mechanism (which is,
+   unfortunately, pretty cumbersome) for validating and instantiating
+   the hashtables.  The idea is that the side-effect of reading a
+   #s(hashtable PLIST) object is creation of a hashtable with desired
+   properties, and that the hashtable is returned.  */
+
+/* Validation functions: each keyword provides its own validation
+   function.  The errors should maybe be continuable, but it is
+   unclear how this would cope with ERRB.  */
+static int
+hashtable_type_validate (Lisp_Object keyword, Lisp_Object value,
+			 Error_behavior errb)
+{
+  if (!(NILP (value)
+	|| EQ (value, Qnon_weak)
+	|| EQ (value, Qweak)
+	|| EQ (value, Qkey_weak)
+	|| EQ (value, Qvalue_weak)))
+    {
+      maybe_signal_simple_error ("Invalid hashtable type", value,
+				 Qhashtable, errb);
+      return 0;
+    }
+  return 1;
+}
+
+static int
+hashtable_test_validate (Lisp_Object keyword, Lisp_Object value,
+			 Error_behavior errb)
+{
+  if (!(NILP (value)
+	|| EQ (value, Qeq)
+	|| EQ (value, Qeql)
+	|| EQ (value, Qequal)))
+    {
+      maybe_signal_simple_error ("Invalid hashtable test", value,
+				 Qhashtable, errb);
+      return 0;
+    }
+  return 1;
+}
+
+static int
+hashtable_size_validate (Lisp_Object keyword, Lisp_Object value,
+			 Error_behavior errb)
+{
+  if (!NATNUMP (value))
+    {
+      maybe_signal_error (Qwrong_type_argument, list2 (Qnatnump, value),
+			  Qhashtable, errb);
+      return 0;
+    }
+  return 1;
 }
 
+static int
+hashtable_data_validate (Lisp_Object keyword, Lisp_Object value,
+			 Error_behavior errb)
+{
+  int num = 0;
+  Lisp_Object tail;
+
+  /* #### Doesn't respect ERRB!  */
+  EXTERNAL_LIST_LOOP (tail, value)
+    {
+      ++num;
+      QUIT;
+    }
+  if (num & 1)
+    {
+      maybe_signal_simple_error
+	("Hashtable data must have alternating keyword/value pairs", value,
+	 Qhashtable, errb);
+      return 0;
+    }
+  return 1;
+}
+
+/* The actual instantiation of hashtable.  This does practically no
+   error checking, because it relies on the fact that the paranoid
+   functions above have error-checked everything to the last details.
+   If this assumption is wrong, we will get a crash immediately (with
+   error-checking compiled in), and we'll know if there is a bug in
+   the structure mechanism.  So there.  */
+static Lisp_Object
+hashtable_instantiate (Lisp_Object plist)
+{
+  /* I'm not sure whether this can GC, but better safe than sorry.  */
+  Lisp_Object hashtab = Qnil;
+  Lisp_Object type = Qnil, test = Qnil, size = Qnil, data = Qnil;
+  Lisp_Object key, value;
+  struct gcpro gcpro1;
+  GCPRO1 (hashtab);
+
+  while (!NILP (plist))
+    {
+      key = XCAR (plist);
+      plist = XCDR (plist);
+      value = XCAR (plist);
+      plist = XCDR (plist);
+      if (EQ (key, Qtype))
+	type = value;
+      else if (EQ (key, Qtest))
+	test = value;
+      else if (EQ (key, Qsize))
+	size = value;
+      else if (EQ (key, Qdata))
+	data = value;
+      else
+	abort ();
+    }
+  if (NILP (type))
+    type = Qnon_weak;
+  if (NILP (size))
+    {
+      /* Divide by two, because data is a plist. */
+      XSETINT (size, XINT (Flength (data)) / 2);
+    }
+
+  /* Create the hashtable.  */
+  if (EQ (type, Qnon_weak))
+    hashtab = Fmake_hashtable (size, test);
+  else if (EQ (type, Qweak))
+    hashtab = Fmake_weak_hashtable (size, test);
+  else if (EQ (type, Qkey_weak))
+    hashtab = Fmake_key_weak_hashtable (size, test);
+  else if (EQ (type, Qvalue_weak))
+    hashtab = Fmake_value_weak_hashtable (size, test);
+  else
+    abort ();
+
+  /* And fill it with data.  */
+  while (!NILP (data))
+    {
+      key = XCAR (data);
+      data = XCDR (data);
+      value = XCAR (data);
+      data = XCDR (data);
+      Fputhash (key, value, hashtab);
+    }
+
+  UNGCPRO;
+  return hashtab;
+}
+
+/* Initialize the hashtable as a structure type.  This is called from
+   emacs.c.  */
+void
+structure_type_create_hashtable (void)
+{
+  struct structure_type *st;
+
+  st = define_structure_type (Qhashtable, 0, hashtable_instantiate);
+  define_structure_type_keyword (st, Qtype, hashtable_type_validate);
+  define_structure_type_keyword (st, Qtest, hashtable_test_validate);
+  define_structure_type_keyword (st, Qsize, hashtable_size_validate);
+  define_structure_type_keyword (st, Qdata, hashtable_data_validate);
+}
+
+/* Basic conversion and allocation functions. */
+
+/* Create a C hashtable from the data in the Lisp hashtable.  The
+   actual vector is not copied, nor are the keys or values copied.  */
 static void
 ht_copy_to_c (struct hashtable *ht, c_hashtable c_table)
 {
@@ -453,6 +714,7 @@
 static void
 verify_function (Lisp_Object function, CONST char *description)
 {
+  /* #### Unused DESCRIPTION?  */
   if (SYMBOLP (function))
   {
     if (NILP (function))
@@ -464,7 +726,7 @@
     return;
   else if (CONSP (function))
   {
-    Lisp_Object funcar = Fcar (function);
+    Lisp_Object funcar = XCAR (function);
     if ((SYMBOLP (funcar)) && (EQ (funcar, Qlambda) ||
 			       EQ (funcar, Qautoload)))
       return;
@@ -717,7 +979,6 @@
 	   (The remhash above has taken care of zero_entry.)
 	   */
 	struct Lisp_Vector *ptr = XVECTOR (XHASHTABLE (rest)->harray);
-	int len = vector_length (ptr);
 #ifdef LRECORD_VECTOR
 	if (! MARKED_RECORD_P(XHASHTABLE(rest)->harray))
 	  {
@@ -725,6 +986,7 @@
 	    did_mark = 1;
 	  }
 #else
+	int len = vector_length (ptr);
 	if (len >= 0)
 	  {
 	    ptr->size = -1 - len;
@@ -879,6 +1141,11 @@
   DEFSUBR (Fmake_key_weak_hashtable);
   DEFSUBR (Fmake_value_weak_hashtable);
   defsymbol (&Qhashtablep, "hashtablep");
+  defsymbol (&Qhashtable, "hashtable");
+  defsymbol (&Qweak, "weak");
+  defsymbol (&Qkey_weak, "key-weak");
+  defsymbol (&Qvalue_weak, "value-weak");
+  defsymbol (&Qnon_weak, "non-weak");
 }
 
 void
--- a/src/elhash.h	Mon Aug 13 10:10:03 2007 +0200
+++ b/src/elhash.h	Mon Aug 13 10:10:54 2007 +0200
@@ -50,6 +50,9 @@
 };
 
 Lisp_Object Fmake_hashtable (Lisp_Object size, Lisp_Object test_fun);
+Lisp_Object Fmake_weak_hashtable(Lisp_Object size, Lisp_Object test);
+Lisp_Object Fmake_key_weak_hashtable(Lisp_Object size, Lisp_Object test);
+Lisp_Object Fmake_value_weak_hashtable(Lisp_Object size, Lisp_Object test);
 Lisp_Object Fcopy_hashtable (Lisp_Object old_table);
 Lisp_Object Fgethash (Lisp_Object obj, Lisp_Object table, Lisp_Object default_);
 Lisp_Object Fputhash (Lisp_Object obj, Lisp_Object val, Lisp_Object table);
--- a/src/emacs.c	Mon Aug 13 10:10:03 2007 +0200
+++ b/src/emacs.c	Mon Aug 13 10:10:54 2007 +0200
@@ -827,9 +827,7 @@
 #if !defined (NO_SUBPROCESSES)
       syms_of_process ();
 #endif
-#ifndef WINDOWSNT
       syms_of_profile ();
-#endif
 #if defined (HAVE_MMAP) && defined (REL_ALLOC)
       syms_of_ralloc ();
 #endif /* HAVE_MMAP && REL_ALLOC */
@@ -1009,6 +1007,7 @@
       structure_type_create_chartab ();
       structure_type_create_faces ();
       structure_type_create_rangetab ();
+      structure_type_create_hashtable ();
 
       /* Now initialize the image instantiator formats and associated symbols.
          Other than the first function below, the functions may
@@ -1153,9 +1152,7 @@
 #ifndef NO_SUBPROCESSES
       vars_of_process ();
 #endif
-#ifndef WINDOWSNT
       vars_of_profile ();
-#endif
 #if defined (HAVE_MMAP) && defined (REL_ALLOC)
       vars_of_ralloc ();
 #endif /* HAVE_MMAP && REL_ALLOC */
--- a/src/emacsfns.h	Mon Aug 13 10:10:03 2007 +0200
+++ b/src/emacsfns.h	Mon Aug 13 10:10:54 2007 +0200
@@ -1273,12 +1273,14 @@
 extern Lisp_Object Qold_rassq;
 extern Lisp_Object Qsearch;
 extern Lisp_Object Qsimple;
+extern Lisp_Object Qsize;
 extern Lisp_Object Qspace;
 extern Lisp_Object Qspecifier;
 extern Lisp_Object Qstream;
 extern Lisp_Object Qstring;
 extern Lisp_Object Qsymbol;
 extern Lisp_Object Qsyntax;
+extern Lisp_Object Qtest;
 extern Lisp_Object Qtext;
 extern Lisp_Object Qtimeout;
 extern Lisp_Object Qtimestamp;
@@ -1522,6 +1524,7 @@
 				   Bytecount len,
 				   enum external_data_format fmt);
 extern Lisp_Object Vprin1_to_string_buffer;
+Lisp_Object Fdisplay_error(Lisp_Object error_object, Lisp_Object stream);
 Lisp_Object Fprin1 (Lisp_Object obj, Lisp_Object printcharfun);
 Lisp_Object Fprinc (Lisp_Object obj, Lisp_Object printcharfun);
 Lisp_Object Fprint (Lisp_Object obj, Lisp_Object printcharfun);
--- a/src/eval.c	Mon Aug 13 10:10:03 2007 +0200
+++ b/src/eval.c	Mon Aug 13 10:10:54 2007 +0200
@@ -2856,7 +2856,9 @@
                                    int nargs, Lisp_Object args[]);
 static Lisp_Object apply_lambda (Lisp_Object fun,
                                  int nargs, Lisp_Object args);
+#if 0 /* #### Not called anymore */
 static Lisp_Object funcall_subr (struct Lisp_Subr *sub, Lisp_Object args[]);
+#endif
 
 static int in_warnings;
 
@@ -3551,11 +3553,13 @@
   return Qnil;	/* suppress compiler warning */
 }
 
+#if 0 /* #### Not called anymore */
 static Lisp_Object
 funcall_subr (struct Lisp_Subr *subr, Lisp_Object args[])
 {
   return primitive_funcall (subr_function (subr), subr->max_args, args);
 }
+#endif
 
 /* FSFmacs has an extra arg EVAL_FLAG.  If false, some of
    the statements below are not done.  But it's always true
--- a/src/event-msw.c	Mon Aug 13 10:10:03 2007 +0200
+++ b/src/event-msw.c	Mon Aug 13 10:10:54 2007 +0200
@@ -46,8 +46,15 @@
 #include "event-msw.h"
 
 static struct event_stream *mswindows_event_stream;
-static Lisp_Object mswindows_dispatch_event_queue, mswindows_dispatch_event_queue_tail;
-CRITICAL_SECTION mswindows_dispatch_crit;
+
+/*
+ * Two separate queues, for efficiency, one (_u_) for user events, and
+ * another (_s_) for non-user ones. We always return events out of the
+ * first one until it is empty and only then proceed with the second
+ * one.
+ */
+static Lisp_Object mswindows_u_dispatch_event_queue, mswindows_u_dispatch_event_queue_tail;
+static Lisp_Object mswindows_s_dispatch_event_queue, mswindows_s_dispatch_event_queue_tail;
 
 /*
  * List of mswindows waitable handles.
@@ -60,74 +67,132 @@
 /* random emacs info associated with each of the wait handles */
 static mswindows_waitable_info_type mswindows_waitable_info[MAX_WAITABLE];
 
+/* Count of quit chars currently in the queue */
+/* Incremented in WM_CHAR handler in msw-proc.c
+   Decremented in mswindows_dequeue_dispatch_event() */
+int mswindows_quit_chars_count = 0;
+
+/* These are Lisp integers; see DEFVARS in this file for description. */
+int mswindows_dynamic_frame_resize;
+int mswindows_num_mouse_buttons;
+int mswindows_button2_max_skew_x;
+int mswindows_button2_max_skew_y;
+int mswindows_button2_chord_time;
+
 /* Number of wait handles */
 static mswindows_waitable_count=0;
 
+static int
+mswindows_user_event_p (struct Lisp_Event* sevt)
+{
+  return (sevt->event_type == key_press_event
+	  || sevt->event_type == button_press_event
+	  || sevt->event_type == button_release_event
+	  || sevt->event_type == pointer_motion_event);
+}
+
 /*
- * Add an emacs event to the dispatch queue and increment the semaphore
+ * Add an emacs event to the proper dispatch queue
  */
 void
 mswindows_enqueue_dispatch_event (Lisp_Object event)
 {
-  enqueue_event (event, &mswindows_dispatch_event_queue,
-		 &mswindows_dispatch_event_queue_tail);
-  ReleaseSemaphore(mswindows_waitable[0], 1, NULL);
+  int user_p = mswindows_user_event_p (XEVENT(event));
+  enqueue_event (event,
+		 user_p ? &mswindows_u_dispatch_event_queue : 
+		 	&mswindows_s_dispatch_event_queue,
+		 user_p ? &mswindows_u_dispatch_event_queue_tail :
+		 	&mswindows_s_dispatch_event_queue_tail);
+
+  /* This one does not go to window procedure, hence does not
+     generate XM_BUMPQUEUE magic event! */
+  PostMessage (NULL, XM_BUMPQUEUE, 0, 0);
 }
 
 /*
- * Remove and return the first emacs event on the dispatch queue. Don't
- * decrement the queue's semaphore because it will be decremented by being
- * waited on.
+ * Remove and return the first emacs event on the dispatch queue.
+ * Give a preference to user events over non-user ones.
  */
 static Lisp_Object
-mswindows_dequeue_dispatch_event (void)
+mswindows_dequeue_dispatch_event ()
 {
   Lisp_Object event;
-  event = dequeue_event (&mswindows_dispatch_event_queue,
-			 &mswindows_dispatch_event_queue_tail);
+  struct Lisp_Event* sevt;
+
+  assert (!NILP(mswindows_u_dispatch_event_queue) ||
+	  !NILP(mswindows_s_dispatch_event_queue));
+
+  event = dequeue_event (
+		 NILP(mswindows_u_dispatch_event_queue) ? 
+			 &mswindows_s_dispatch_event_queue : 
+			 &mswindows_u_dispatch_event_queue,
+		 NILP(mswindows_u_dispatch_event_queue) ? 
+			 &mswindows_s_dispatch_event_queue_tail :
+			 &mswindows_u_dispatch_event_queue_tail);
+
+  sevt = XEVENT(event);
+  if (sevt->event_type == key_press_event
+      && (sevt->event.key.modifiers & FAKE_MOD_QUIT))
+    {
+      sevt->event.key.modifiers &= ~FAKE_MOD_QUIT;
+      --mswindows_quit_chars_count;
+    }
+
   return event;
 }
 
 /*
  * Remove and return the first emacs event on the dispatch queue that matches
- * the supplied event and decrement the queue's semaphore.
- * Only supports timeout events.
+ * the supplied event
+ * Timeout event matches if interval_id equals to that of the given event.
+ * Keypress event matches if logical AND between modifiers bitmask of the
+ * event in the queue and that of the given event is non-zero
+ * For all other event types, this function asserts.
  */
+
 Lisp_Object
-mswindows_cancel_dispatch_event (Lisp_Object match_event)
+mswindows_cancel_dispatch_event (struct Lisp_Event* match)
 {
   Lisp_Object event;
   Lisp_Object previous_event=Qnil;
-  struct Lisp_Event *match = XEVENT(match_event);
+  int user_p = mswindows_user_event_p (match);
+  Lisp_Object* head = user_p ? &mswindows_u_dispatch_event_queue : 
+    			       &mswindows_s_dispatch_event_queue;
+  Lisp_Object* tail = user_p ? &mswindows_u_dispatch_event_queue_tail : 
+    			       &mswindows_s_dispatch_event_queue_tail;
 
-  assert (match->event_type == timeout_event);
+  assert (match->event_type == timeout_event
+	  || match->event_type == key_press_event);
 
-  EVENT_CHAIN_LOOP (event, mswindows_dispatch_event_queue)
-    if (XEVENT_TYPE (event) == match->event_type)
-      {
-	/* We only handle timeouts */
-	if (XEVENT(event)->event.timeout.interval_id ==
-	    match->event.timeout.interval_id)
-	  {
-	    if (NILP (previous_event))
-	      dequeue_event (&mswindows_dispatch_event_queue,
-			     &mswindows_dispatch_event_queue_tail);
-	    else
-	      {
-		XSET_EVENT_NEXT (previous_event, XEVENT_NEXT (event));
-		if (EQ (mswindows_dispatch_event_queue_tail, event))
-		  mswindows_dispatch_event_queue_tail = previous_event;
-	      }
- 
-	    /* Decrement the dispatch queue counter */
-	    WaitForSingleObject(mswindows_waitable[0], INFINITE);
-	    return event;
-	  }
-      }
-    else
+  EVENT_CHAIN_LOOP (event, *head)
+    {
+      int found = 1;
+      if (XEVENT_TYPE (event) != match->event_type)
+	found = 0;
+      if (found && match->event_type == timeout_event
+	  && (XEVENT(event)->event.timeout.interval_id !=
+	      match->event.timeout.interval_id))
+	found = 0;
+      if (found && match->event_type == key_press_event
+	  && ((XEVENT(event)->event.key.modifiers &
+	      match->event.key.modifiers) == 0))
+	found = 0;
+
+      if (found)
+	{
+	  if (NILP (previous_event))
+	    dequeue_event (head, tail);
+	  else
+	    {
+	      XSET_EVENT_NEXT (previous_event, XEVENT_NEXT (event));
+	      if (EQ (*tail, event))
+		*tail = previous_event;
+	    }
+	  
+	  return event;
+	}
       previous_event = event;
-
-  return Qnil;
+    }
 }
 
 /*
@@ -156,26 +221,14 @@
   switch (info->type)
   {
   case mswindows_waitable_type_dispatch:
+    assert (0); /* kkm - should not get here */
     /* Can only have one waitable for the dispatch queue, and it's the first one */
     assert (mswindows_waitable_count++ == 0);
     waitable=0;
-    InitializeCriticalSection(&mswindows_dispatch_crit);
+//    InitializeCriticalSection(&mswindows_dispatch_crit);
     assert (mswindows_waitable[0] = CreateSemaphore (NULL, 0, 0x7fffffff, NULL));
     return mswindows_waitable_info+0;
 
-#if 0	/* Windows95 doesn't support WaitableTimers */
-  case mswindows_waitable_type_timeout:
-    {
-      LARGE_INTEGER due;
-      due.QuadPart = 10000 * (LONGLONG) info->data.timeout.milliseconds;
-      waitable = mswindows_find_free_waitable();
-      mswindows_waitable[waitable] = CreateWaitableTimer(NULL, TRUE, NULL);
-      SetWaitableTimer(mswindows_waitable[waitable], &due, 0, NULL, NULL, FALSE);
-      mswindows_waitable_info[waitable].data.timeout.id = waitable;
-    }
-    break;
-#endif
-
   default:
     assert(0);
   }
@@ -193,12 +246,6 @@
 
   switch (info->type)
   {
-#if 0
-  case mswindows_waitable_type_timeout:
-    waitable = info->data.timeout.id;
-    CancelWaitableTimeout(mswindows_waitable[waitable]);
-    break;
-#endif
 
   default:
     assert(0);
@@ -211,6 +258,106 @@
     --mswindows_waitable_count;
 }
 
+/* 
+ * Callback procedure for synchronous timer messages
+ */
+static void CALLBACK
+mswindows_wm_timer_callback (HWND hwnd, UINT umsg, UINT id_timer, DWORD dwtime)
+{
+  Lisp_Object emacs_event = Fmake_event (Qnil, Qnil);
+  struct Lisp_Event *event = XEVENT (emacs_event);
+
+  KillTimer (NULL, id_timer);
+
+  event->channel = Qnil;
+  event->timestamp = dwtime;
+  event->event_type = timeout_event;
+  event->event.timeout.interval_id = id_timer;
+
+  mswindows_enqueue_dispatch_event (emacs_event);
+}
+
+static void 
+mswindows_drain_windows_queue ()
+{
+  MSG msg;
+  while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
+    DispatchMessage (&msg);
+}
+
+/*
+ * This drains the event queue and fills up two internal queues until
+ * an event of a type specified by USER_P is retrieved.
+ *
+ * If user_p, then the function drains until the first user event, or
+ * the first non-user event if there no user events. Otherwise, If
+ * not user_p, it does not give preference to user events.
+ *
+ * If badly_p, then the function does not return until an event is
+ * available.
+ *
+ * The code does not rely on MsgWaitForMultipleObjects preference for
+ * messages over waitable handles.
+ *
+ * Used by emacs_mswindows_event_pending_p and emacs_mswindows_next_event
+ */
+static void
+mswindows_need_event (int user_p, int badly_p)
+{
+  int active;
+
+  /* Have to drain Windows message queue first, otherwise, we may miss
+     quit char when called from quit_p */
+  mswindows_drain_windows_queue ();
+
+  while (NILP (mswindows_u_dispatch_event_queue) &&
+	 (user_p || NILP (mswindows_s_dispatch_event_queue)))
+  {
+    /* If we already have an event, we've got someting to return - no wait! */
+    if (!NILP (mswindows_u_dispatch_event_queue)
+	|| !NILP (mswindows_s_dispatch_event_queue))
+      badly_p = 0;
+    
+    /* Now try getting a message */
+    active = MsgWaitForMultipleObjects (mswindows_waitable_count,
+					mswindows_waitable,
+					FALSE, badly_p ? INFINITE : 0,
+					QS_ALLINPUT);
+
+    /* This will assert if handle being waited for becomes abandoned.
+       Not the case currently tho */
+    assert ((!badly_p && active == WAIT_TIMEOUT) ||
+	    (active >= WAIT_OBJECT_0 &&
+	     active <= WAIT_OBJECT_0 + mswindows_waitable_count));
+    
+    if (active == WAIT_TIMEOUT)
+      {
+	/* No luck trying - just return what we've already got */
+	return;
+      }
+    else if (active == WAIT_OBJECT_0 + mswindows_waitable_count)
+      {
+	/* Got your message, thanks */
+	mswindows_drain_windows_queue ();
+      }
+    else
+      {
+	/* XXX FIXME: We should do some kind of round-robin scheme to ensure fairness */
+	int waitable = active - WAIT_OBJECT_0;
+	mswindows_waitable_info_type *info  = mswindows_waitable_info + waitable;
+
+	switch (info->type)
+	  {
+	    /* XXX FIXME: Should enque subprocess event here so that it is not lost */
+	  default:
+	    assert(0);
+	  }
+      }
+  } /* while */
+
+  return;
+}
+
 
 /************************************************************************/
 /*                            methods                                   */
@@ -219,27 +366,32 @@
 static int
 emacs_mswindows_add_timeout (EMACS_TIME thyme)
 {
+  int milliseconds;
   EMACS_TIME current_time;
-  int milliseconds;
-  int id;
-  mswindows_request_type request;
-
   EMACS_GET_TIME (current_time);
   EMACS_SUB_TIME (thyme, thyme, current_time);
-  milliseconds = EMACS_SECS (thyme) * 1000 + EMACS_USECS (thyme) / 1000;
+  milliseconds = EMACS_SECS (thyme) * 1000 +
+    (EMACS_USECS (thyme) + 500) / 1000;
   if (milliseconds < 1)
     milliseconds = 1;
-  request.thing1 = (void *) milliseconds;
-  id = mswindows_make_request(WM_XEMACS_SETTIMER, 0, &request);
-  assert(id);	/* XXX */
-  return id;
+  return SetTimer (NULL, 0, milliseconds, mswindows_wm_timer_callback);
 }
 
 static void
 emacs_mswindows_remove_timeout (int id)
 {
-  mswindows_request_type request = { (void *) id };
-  mswindows_make_request(WM_XEMACS_KILLTIMER, 0, &request);
+  struct Lisp_Event match_against;
+  Lisp_Object emacs_event;
+
+  KillTimer (NULL, id);
+
+  /* If there is a dispatch event generated by this
+     timeout in the queue, we have to remove it too. */
+  match_against.event_type = timeout_event;
+  match_against.event.timeout.interval_id = id;
+  emacs_event = mswindows_cancel_dispatch_event (&match_against);
+  if (!NILP (emacs_event))
+    Fdeallocate_event(emacs_event);
 }
 
 /* If `user_p' is false, then return whether there are any win32, timeout,
@@ -254,97 +406,36 @@
 static int
 emacs_mswindows_event_pending_p (int user_p)
 {
-  if (user_p)
-    {
-      /* Iterate over the dispatch queue looking for user-events */
-      int found = 0;
-      Lisp_Object event;
+  mswindows_need_event (user_p, 0);
 
-      EnterCriticalSection (&mswindows_dispatch_crit);
-      EVENT_CHAIN_LOOP (event, mswindows_dispatch_event_queue)
-	if (command_event_p (event))
-	  found = 1;
-      LeaveCriticalSection (&mswindows_dispatch_crit);
-      return found;
-    }
-  else
-    {
-      /* Check for any kind of input, including the dispatch queue */
-#if 0
-      /* Want do do the following, but it's not clear whether this would
-       * cause the waitables to become unsignalled */
-      return (WaitForMultipleObjects (mswindows_waitable_count,
-				      mswindows_waitable, FALSE, 0)
-	      != WAIT_TIMEOUT);
-#else
-      return !NILP (mswindows_dispatch_event_queue);
-#endif
-    }
-}
-
-static struct console *
-find_console_from_fd (int fd)
-{
-  return 0;
+  return (!NILP (mswindows_u_dispatch_event_queue)
+	  || (!user_p && !NILP (mswindows_s_dispatch_event_queue)));
 }
 
 /*
  * Return the next event
- * We return windows events off the dispatch event queue in preference to other events
  */
 static void
 emacs_mswindows_next_event (struct Lisp_Event *emacs_event)
 {
-  DWORD active;
-  active = WaitForMultipleObjects (mswindows_waitable_count, mswindows_waitable,
-				   FALSE, INFINITE);
-  assert(active >= WAIT_OBJECT_0 && active <= WAIT_OBJECT_0 + mswindows_waitable_count - 1);
-  
-  /* Windows events on the dispatch event queue */
-  if (active == WAIT_OBJECT_0)
-  {
-    /* XXX Copied from event-Xt.c */
-    Lisp_Object event, event2;
+  Lisp_Object event, event2;
+
+  /* Give strong preference to user events */
+  mswindows_need_event (1, 1);
 
-    EnterCriticalSection (&mswindows_dispatch_crit);
-    XSETEVENT (event2, emacs_event);
-    event = mswindows_dequeue_dispatch_event ();
-    Fcopy_event (event, event2);
-    Fdeallocate_event (event);
-    LeaveCriticalSection (&mswindows_dispatch_crit);
-  }
-  else
-  {
-    /* XXX FIXME: We should do some kind of round-robin scheme to ensure fairness */
-    int waitable = active - WAIT_OBJECT_0;
-    mswindows_waitable_info_type *info  = mswindows_waitable_info + waitable;
-
-    switch (info->type)
-    {
-    case mswindows_waitable_type_timeout:
-      emacs_event->channel = Qnil;
-      emacs_event->event_type = timeout_event;
-      emacs_event->event.timeout.interval_id = info->data.timeout.id;
-      mswindows_remove_waitable(info);
-      break;
-
-    default:
-      assert(0);
-    }
-  }
+  /* XXX Copied from event-Xt.c */
+  event = mswindows_dequeue_dispatch_event (!NILP(mswindows_u_dispatch_event_queue));
+  XSETEVENT (event2, emacs_event);
+  Fcopy_event (event, event2);
+  Fdeallocate_event (event);
 }
 
 /*
  * Handle a magic event off the dispatch queue.
- * XXX split into seperate functions for clarity.
  */
 static void
 emacs_mswindows_handle_magic_event (struct Lisp_Event *emacs_event)
 {
-  RECT *rect = &EVENT_MSWINDOWS_MAGIC_DATA(emacs_event);
-  struct frame *f = XFRAME (EVENT_CHANNEL (emacs_event));
-  Lisp_Object frame = Qnil;
-  XSETFRAME (frame, f);
 #if 0  
   stderr_out("magic %x, (%d,%d), (%d,%d)\n",
 	     EVENT_MSWINDOWS_MAGIC_TYPE(emacs_event),
@@ -355,8 +446,11 @@
   case WM_SETFOCUS:
   case WM_KILLFOCUS:
     {
+      Lisp_Object frame = EVENT_CHANNEL (emacs_event);
+      struct frame *f = XFRAME (frame);
       int in_p = (EVENT_MSWINDOWS_MAGIC_TYPE(emacs_event) == WM_SETFOCUS);
       Lisp_Object conser;
+
       /* struct gcpro gcpro1; */
 
       /* Clear sticky modifiers here (if we had any) */
@@ -368,53 +462,31 @@
 	 I Don't know why */
       emacs_handle_focus_change_final (conser);
       /* UNGCPRO; */
+
     }
     break;
 
-    /* XXX What about Enter & Leave */
+  case XM_BUMPQUEUE:
+    /* This is a nice event, when we're in need to queue *something* */
+    break;
+
+  case XM_MAPFRAME:
+  case XM_UNMAPFRAME:
+    {
+      Lisp_Object frame = EVENT_CHANNEL (emacs_event);
+      va_run_hook_with_args (EVENT_MSWINDOWS_MAGIC_TYPE(emacs_event) 
+			      == XM_MAPFRAME ?
+			      Qmap_frame_hook : Qunmap_frame_hook, 
+			      1, frame);
+    }
+    break;
+			    
+      /* XXX What about Enter & Leave */
 #if 0
       va_run_hook_with_args (in_p ? Qmouse_enter_frame_hook :
 			     Qmouse_leave_frame_hook, 1, frame);
-    break;
 #endif
 
-  case WM_SIZE:
-    if ((rect->left & rect->top & rect->right & rect->bottom) == -1)
-      {
-	/* Iconified */
-        FRAME_VISIBLE_P (f) = 0;
-        va_run_hook_with_args (Qunmap_frame_hook, 1, frame);
-	Fframe_iconified_p (frame);
-      }
-    else
-      {
-	/* If we're uniconified, our size may or may not have changed */
-        int columns, rows;
-	int was_visible = FRAME_VISIBLE_P (f);
-
-	FRAME_VISIBLE_P (f) = 1;
-        FRAME_PIXWIDTH(f) = rect->right;
-	FRAME_PIXHEIGHT(f) = rect->bottom;
-
-        pixel_to_char_size (f, rect->right, rect->bottom, &columns, &rows);
-	change_frame_size (f, rows, columns, 0);
-/*	      MARK_FRAME_WINDOWS_STRUCTURE_CHANGED (f); /* XXX Too extreme? */
-
-	if (!was_visible)
-          va_run_hook_with_args (Qmap_frame_hook, 1, frame);
-
-      }
-      break;
-
-  case WM_PAINT:
-    mswindows_redraw_exposed_area(f, rect->left, rect->top,
-				  rect->right, rect->bottom);
-    break;
-
-  case WM_CLOSE:
-    enqueue_misc_user_event (frame, Qeval, list3 (Qdelete_frame, frame, Qt));
-    break;
-
   default:
     assert(0);
   }
@@ -443,6 +515,26 @@
 static void
 emacs_mswindows_quit_p (void)
 {
+  mswindows_need_event (1, 0);
+
+  if (mswindows_quit_chars_count > 0)
+    {
+      /* Yes there's a hidden one... Throw it away */
+      struct Lisp_Event match_against;
+      Lisp_Object emacs_event;
+
+      match_against.event_type = key_press_event;
+      match_against.event.key.modifiers = FAKE_MOD_QUIT;
+
+      emacs_event = mswindows_cancel_dispatch_event (&match_against);
+      assert (!NILP (emacs_event));
+
+      Vquit_flag = (XEVENT(emacs_event)->event.key.modifiers & MOD_SHIFT
+		    ? Qcritical : Qt);
+
+      Fdeallocate_event(emacs_event);
+      --mswindows_quit_chars_count;
+    }
 }
 
 /* This is called from GC when a process object is about to be freed.
@@ -474,22 +566,71 @@
 void
 vars_of_event_mswindows (void)
 {
-  mswindows_dispatch_event_queue = Qnil;
-  staticpro (&mswindows_dispatch_event_queue);
-  mswindows_dispatch_event_queue_tail = Qnil;
+  mswindows_u_dispatch_event_queue = Qnil;
+  staticpro (&mswindows_u_dispatch_event_queue);
+  mswindows_u_dispatch_event_queue_tail = Qnil;
+
+  mswindows_s_dispatch_event_queue = Qnil;
+  staticpro (&mswindows_s_dispatch_event_queue);
+  mswindows_s_dispatch_event_queue_tail = Qnil;
 
   mswindows_event_stream = xnew (struct event_stream);
 
   mswindows_event_stream->event_pending_p 	= emacs_mswindows_event_pending_p;
-  mswindows_event_stream->next_event_cb	= emacs_mswindows_next_event;
+  mswindows_event_stream->next_event_cb		= emacs_mswindows_next_event;
   mswindows_event_stream->handle_magic_event_cb = emacs_mswindows_handle_magic_event;
   mswindows_event_stream->add_timeout_cb 	= emacs_mswindows_add_timeout;
   mswindows_event_stream->remove_timeout_cb 	= emacs_mswindows_remove_timeout;
   mswindows_event_stream->select_console_cb 	= emacs_mswindows_select_console;
-  mswindows_event_stream->unselect_console_cb = emacs_mswindows_unselect_console;
+  mswindows_event_stream->unselect_console_cb	= emacs_mswindows_unselect_console;
   mswindows_event_stream->select_process_cb 	= emacs_mswindows_select_process;
-  mswindows_event_stream->unselect_process_cb = emacs_mswindows_unselect_process;
+  mswindows_event_stream->unselect_process_cb	= emacs_mswindows_unselect_process;
   mswindows_event_stream->quit_p_cb		= emacs_mswindows_quit_p;
+
+  DEFVAR_BOOL ("w32-dynamic-frame-resize", &mswindows_dynamic_frame_resize /*
+*Controls redrawing frame contents during mouse-drag or keyboard resize
+operation. When non-nil, the frame is redrawn while being resized. When
+nil, frame is not redrawn, and exposed areas are filled with default
+MDI application background color. Note that this option only has effect
+if "Show window contents while dragging" is on in system Display/Plus!
+settings.
+Default is t on fast machines, nil on slow.
+*/ );
+
+/* The description copied verbatim from nt-emacs. (C) Geoff Voelker */
+  DEFVAR_INT ("w32-mouse-button-tolerance", &mswindows_button2_chord_time /*
+*Analogue of double click interval for faking middle mouse events.
+The value is the minimum time in milliseconds that must elapse between
+left/right button down events before they are considered distinct events.
+If both mouse buttons are depressed within this interval, a middle mouse
+button down event is generated instead.
+If negative or zero, currently set system default is used instead.
+*/ );
+
+/* The description copied verbatim from nt-emacs. (C) Geoff Voelker */
+  DEFVAR_INT ("w32-num-mouse-buttons", &mswindows_num_mouse_buttons /*
+Number of physical mouse buttons.
+*/ );
+
+  DEFVAR_INT ("w32-mouse-button-max-skew-x", &mswindows_button2_max_skew_x /*
+*Maximum horizontal distance in pixels between points in which left and
+right button clicks occured for them to be translated into single
+middle button event. Clicks must occur in time not longer than defined
+by the variable w32-mouse-button-tolerance.
+If negative or zero, currently set system default is used instead.
+*/ );
+
+  DEFVAR_INT ("w32-mouse-button-max-skew-y", &mswindows_button2_max_skew_y /*
+*Maximum vertical distance in pixels between points in which left and
+right button clicks occured for them to be translated into single
+middle button event. Clicks must occur in time not longer than defined
+by the variable w32-mouse-button-tolerance.
+If negative or zero, currently set system default is used instead.
+*/ );
+
+  mswindows_button2_max_skew_x = 0;
+  mswindows_button2_max_skew_y = 0;
+  mswindows_button2_chord_time = 0;
 }
 
 void
@@ -501,4 +642,7 @@
 init_event_mswindows_late (void)
 {
   event_stream = mswindows_event_stream;
+
+  mswindows_dynamic_frame_resize = !GetSystemMetrics (SM_SLOWMACHINE);
+  mswindows_num_mouse_buttons = GetSystemMetrics (SM_CMOUSEBUTTONS);
 }
--- a/src/event-msw.h	Mon Aug 13 10:10:03 2007 +0200
+++ b/src/event-msw.h	Mon Aug 13 10:10:54 2007 +0200
@@ -53,39 +53,24 @@
 #define MSW_TIMEOUT_GRANULARITY 25
 #define MSW_TIMEOUT_MAX	32
 
-/* Random globals shared between main and message-processing thread */
-extern DWORD mswindows_main_thread_id;
-extern DWORD mswindows_win_thread_id;
-extern CRITICAL_SECTION mswindows_dispatch_crit;
-
+/* Random globals */
+extern LRESULT WINAPI mswindows_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
+extern int mswindows_quit_chars_count;
 
-/*
- * Communication between main and windows thread
- */
-#define WM_XEMACS_BASE		(WM_APP + 0)
-#define WM_XEMACS_ACK		(WM_XEMACS_BASE + 0x00)
-#define WM_XEMACS_CREATEWINDOW	(WM_XEMACS_BASE + 0x01)
-#define WM_XEMACS_DESTROYWINDOW	(WM_XEMACS_BASE + 0x02)
-#define WM_XEMACS_SETTIMER	(WM_XEMACS_BASE + 0x03)
-#define WM_XEMACS_KILLTIMER	(WM_XEMACS_BASE + 0x04)
-#define WM_XEMACS_END		(WM_XEMACS_BASE + 0x10)
-
-typedef struct mswindows_request_type
-{
-  void *thing1;
-  void *thing2;
-} mswindows_request_type;
-
-LPARAM mswindows_make_request(UINT message, WPARAM wParam, mswindows_request_type *request);
-void mswindows_handle_request(MSG *msg);
-
+/* These are Lisp integer variables */
+/* Jonsthan, these need not to be globals after merge -- kkm */
+extern int mswindows_dynamic_frame_resize;
+extern int mswindows_num_mouse_buttons;
+extern int mswindows_button2_max_skew_x;
+extern int mswindows_button2_max_skew_y;
+extern int mswindows_button2_chord_time;
 
 /*
  * Event generating stuff
  */
 
 /* The number of things we can wait on */
-#define MAX_WAITABLE 256
+#define MAX_WAITABLE (MAXIMUM_WAIT_OBJECTS - 1)
 
 typedef enum mswindows_waitable_type
 {
@@ -117,10 +102,8 @@
 /*
  * Some random function declarations in msw-proc.c
  */
-DWORD mswindows_win_thread();
 extern void mswindows_enqeue_dispatch_event (Lisp_Object event);
-Lisp_Object mswindows_cancel_dispatch_event (Lisp_Object event);
-
+Lisp_Object mswindows_cancel_dispatch_event (struct Lisp_Event* event);
 
 /*
  * Inside mswindows magic events
@@ -132,5 +115,23 @@
 #define EVENT_MSWINDOWS_MAGIC_DATA(e)	\
 	(*((RECT *) (&(EVENT_MSWINDOWS_MAGIC_EVENT(e).data))))
 
+/*
+ * Messages and magic events IDs
+ */
+#define XM_BUMPQUEUE	(WM_USER + 101)
+#define XM_MAPFRAME	(WM_USER + 102)
+#define XM_UNMAPFRAME	(WM_USER + 103)
+
+/*
+ * Window LONGs indices
+ */
+#define XWL_FRAMEOBJ	0
+
+/* This must be number of the above long multiplied by 4 */
+#define MSWINDOWS_WINDOW_EXTRA_BYTES 4
+
+/* Fake key modifiers which attached to a quit char event.
+   Removed upon dequeueing an event */
+#define FAKE_MOD_QUIT	0x80
 
 #endif /* _XEMACS_EVENT_MSW_H_ */
--- a/src/events.c	Mon Aug 13 10:10:03 2007 +0200
+++ b/src/events.c	Mon Aug 13 10:10:54 2007 +0200
@@ -1320,6 +1320,7 @@
   else if (SYMBOLP (key))
     {
       CONST char *str = 0;
+#if 0 /* obsolete keynames */
       if (brief)
 	{
 	  if      (EQ (key, QKlinefeed))  str = "LFD";
@@ -1330,6 +1331,7 @@
 	  else if (EQ (key, QKspace))     str = "SPC";
 	  else if (EQ (key, QKbackspace)) str = "BS";
 	}
+#endif
       if (str)
 	{
 	  int i = strlen (str);
--- a/src/extents.c	Mon Aug 13 10:10:03 2007 +0200
+++ b/src/extents.c	Mon Aug 13 10:10:54 2007 +0200
@@ -3143,15 +3143,45 @@
 static int
 extent_putprop (Lisp_Object obj, Lisp_Object prop, Lisp_Object value)
 {
-  error ("Not yet implemented"); /* #### */
-  return 0;
+  Fset_extent_property (obj, prop, value);
+  return 1;
 }
 
 static int
 extent_remprop (Lisp_Object obj, Lisp_Object prop)
 {
-  error ("Not yet implemented"); /* #### */
-  return 0;
+  EXTENT ext = XEXTENT (obj);
+
+  /* This list is taken from Fset_extent_property, and should be kept
+     in synch.  */
+  if (EQ (prop, Qread_only)
+      || EQ (prop, Qunique)
+      || EQ (prop, Qduplicable)
+      || EQ (prop, Qinvisible)
+      || EQ (prop, Qdetachable)
+      || EQ (prop, Qdetached)
+      || EQ (prop, Qdestroyed)
+      || EQ (prop, Qpriority)
+      || EQ (prop, Qface)
+      || EQ (prop, Qinitial_redisplay_function)
+      || EQ (prop, Qmouse_face)
+      || EQ (prop, Qhighlight)
+      || EQ (prop, Qbegin_glyph_layout)
+      || EQ (prop, Qend_glyph_layout)
+      || EQ (prop, Qglyph_layout)
+      || EQ (prop, Qbegin_glyph)
+      || EQ (prop, Qend_glyph)
+      || EQ (prop, Qstart_open)
+      || EQ (prop, Qend_open)
+      || EQ (prop, Qstart_closed)
+      || EQ (prop, Qend_closed)
+      || EQ (prop, Qkeymap))
+    {
+      /* #### Is this correct, anyway?  */
+      return -1;
+    }
+
+  return external_remprop (&ext->plist, prop, 0, ERROR_ME);
 }
 
 static Lisp_Object
--- a/src/faces.c	Mon Aug 13 10:10:03 2007 +0200
+++ b/src/faces.c	Mon Aug 13 10:10:54 2007 +0200
@@ -319,15 +319,7 @@
       valw = Fcar (data);
       data = Fcdr (data);
       if (EQ (keyw, Qname))
-	{
-	  if (name_seen)
-	    {
-	      maybe_signal_simple_error ("Duplicate face name given", valw,
-					 Qface, errb);
-	      return 0;
-	    }
-	  name_seen = 1;
-	}
+	name_seen = 1;
       else
 	abort ();
     }
@@ -467,6 +459,8 @@
   mark_all_faces_internal (0);
 }
 
+/* Currently unused (see the comment in face_property_was_changed()).  */
+#if 0
 /* #### OBSOLETE ME, PLEASE.  Maybe.  Maybe this is just as good as
    any other solution. */
 struct face_inheritance_closure
@@ -561,6 +555,7 @@
 
   UNGCPRO;
 }
+#endif /* 0 */
 
 Lisp_Object
 face_property_matching_instance (Lisp_Object face, Lisp_Object property,
--- a/src/fileio.c	Mon Aug 13 10:10:03 2007 +0200
+++ b/src/fileio.c	Mon Aug 13 10:10:54 2007 +0200
@@ -355,7 +355,6 @@
 Lisp_Object Qwrite_region;
 Lisp_Object Qverify_visited_file_modtime;
 Lisp_Object Qset_visited_file_modtime;
-Lisp_Object Qset_buffer_modtime;
 
 /* If FILENAME is handled specially on account of its syntax,
    return its handler function.  Otherwise, return nil.  */
@@ -4126,85 +4125,6 @@
 
   return Qnil;
 }
-
-DEFUN ("set-buffer-modtime", Fset_buffer_modtime, 1, 2, 0, /*
-Update BUFFER's recorded modification time from the associated
-file's modtime, if there is an associated file. If not, use the
-current time. In either case, if the optional arg TIME is supplied,
-it will be used if it is either an integer or a cons of two integers.
-*/
-       (buf, in_time))
-{
-  /* This function can call lisp */
-  unsigned long time_to_use = 0;
-  int set_time_to_use = 0;
-  struct stat st;
-
-  CHECK_BUFFER (buf);
-
-  if (!NILP (in_time))
-    {
-      if (INTP (in_time))
-        {
-          time_to_use = XINT (in_time);
-          set_time_to_use = 1;
-        }
-      else if ((CONSP (in_time)) &&
-               (INTP (Fcar (in_time))) &&
-               (INTP (Fcdr (in_time))))
-	{
-	  time_t the_time;
-	  lisp_to_time (in_time, &the_time);
-	  time_to_use = (unsigned long) the_time;
-          set_time_to_use = 1;
-        }
-    }
-
-  if (!set_time_to_use)
-    {
-      Lisp_Object filename = Qnil;
-      struct gcpro gcpro1;
-      GCPRO1 (filename);
-      /* #### dmoore - do we need to protect XBUFFER (buf)->filename?
-	 What if a ^(*&^&*^*& handler renames a buffer?  I think I'm
-	 getting a headache now. */
-
-      if (STRINGP (XBUFFER (buf)->filename))
-        filename = Fexpand_file_name (XBUFFER (buf)->filename, Qnil);
-      else
-        filename = Qnil;
-
-      if (!NILP (filename) && !NILP (Ffile_exists_p (filename)))
-        {
-	  Lisp_Object handler;
-
-	  /* If the file name has special constructs in it,
-	     call the corresponding file handler.  */
-	  handler = Ffind_file_name_handler (filename, Qset_buffer_modtime);
-	  UNGCPRO;
-	  if (!NILP (handler))
-	    /* The handler can find the file name the same way we did. */
-	    return (call2 (handler, Qset_buffer_modtime, Qnil));
-	  else
-	    {
-	      if (stat ((char *) XSTRING_DATA (filename), &st) >= 0)
-		time_to_use = st.st_mtime;
-	      else
-		time_to_use = time ((time_t *) 0);
-	    }
-        }
-      else
-	{
-	  UNGCPRO;
-  	  time_to_use = time ((time_t *) 0);
-	}
-    }
-
-  XBUFFER (buf)->modtime = time_to_use;
-
-  return Qnil;
-}
-
 
 static Lisp_Object
 auto_save_error (Lisp_Object condition_object, Lisp_Object ignored)
@@ -4618,7 +4538,6 @@
   defsymbol (&Qwrite_region, "write-region");
   defsymbol (&Qverify_visited_file_modtime, "verify-visited-file-modtime");
   defsymbol (&Qset_visited_file_modtime, "set-visited-file-modtime");
-  defsymbol (&Qset_buffer_modtime, "set-buffer-modtime");
 #ifdef DOS_NT
   defsymbol (&Qfind_buffer_file_type, "find-buffer-file-type");
 #endif /* DOS_NT */
@@ -4687,7 +4606,6 @@
   DEFSUBR (Fclear_visited_file_modtime);
   DEFSUBR (Fvisited_file_modtime);
   DEFSUBR (Fset_visited_file_modtime);
-  DEFSUBR (Fset_buffer_modtime);
 
   DEFSUBR (Fdo_auto_save);
   DEFSUBR (Fset_buffer_auto_saved);
--- a/src/fns.c	Mon Aug 13 10:10:03 2007 +0200
+++ b/src/fns.c	Mon Aug 13 10:10:54 2007 +0200
@@ -2879,7 +2879,9 @@
 {
   if (depth > 200)
     error ("Stack overflow in equal");
+#ifndef LRECORD_CONS
  do_cdr:
+#endif
   QUIT;
   if (EQ_WITH_EBOLA_NOTICE (o1, o2))
     return 1;
@@ -2952,7 +2954,9 @@
 {
   if (depth > 200)
     error ("Stack overflow in equal");
+#ifndef LRECORD_CONS
  do_cdr:
+#endif
   QUIT;
   if (HACKEQ_UNSAFE (o1, o2))
     return 1;
--- a/src/frame-msw.c	Mon Aug 13 10:10:03 2007 +0200
+++ b/src/frame-msw.c	Mon Aug 13 10:10:54 2007 +0200
@@ -38,6 +38,18 @@
 #include "frame.h"
 #include "events.h"
 
+#define MSWINDOWS_FRAME_STYLE WS_CLIPCHILDREN|WS_CLIPSIBLINGS|WS_OVERLAPPEDWINDOW
+#define MSWINDOWS_POPUP_STYLE WS_CLIPCHILDREN|WS_CLIPSIBLINGS|WS_CAPTION|WS_POPUP
+
+#define MSWINDOWS_FRAME_EXSTYLE WS_EX_OVERLAPPEDWINDOW
+#define MSWINDOWS_POPUP_EXSTYLE WS_EX_OVERLAPPEDWINDOW
+
+#ifdef HAVE_MENUBARS
+#define ADJR_MENUFLAG TRUE
+#else
+#define ADJR_MENUFLAG FALSE
+#endif
+
 /* Default properties to use when creating frames.  */
 Lisp_Object Vdefault_mswindows_frame_plist;
 /* Lisp_Object Qname, Qheight, Qwidth, Qinitially_unmapped, Qpopup, Qtop, Qleft; */
@@ -46,21 +58,57 @@
 static void
 mswindows_init_frame_1 (struct frame *f, Lisp_Object props)
 {
-  mswindows_request_type request = { f, &props };
   Lisp_Object device = FRAME_DEVICE (f);
   struct device *d = XDEVICE (device);
   Lisp_Object lisp_window_id, initially_unmapped;
-  initially_unmapped = Fplist_get (props, Qinitially_unmapped, Qnil);
+  Lisp_Object name, height, width, popup, top, left;
+  Lisp_Object frame_obj;
+  int pixel_width, pixel_height;
+  RECT rect;
+  DWORD style, exstyle;
+  HWND hwnd;
 
-#if 0
-  if (NILP (DEVICE_SELECTED_FRAME (d)) &&	/* first frame on the device */
-      NILP (initially_unmapped))
-    f->visible = 1;
-#endif
+  initially_unmapped = Fplist_get (props, Qinitially_unmapped, Qnil);
+  name = Fplist_get (props, Qname, Qnil);
+  height = Fplist_get (props, Qheight, Qnil);
+  width = Fplist_get (props, Qwidth, Qnil);
+  popup = Fplist_get (props, Qpopup, Qnil);
+  top = Fplist_get (props, Qtop, Qnil);
+  left = Fplist_get (props, Qleft, Qnil);
 
   f->frame_data = xnew_and_zero (struct mswindows_frame);
-  FRAME_MSWINDOWS_HANDLE(f) = (HWND)mswindows_make_request(WM_XEMACS_CREATEWINDOW,
-					       0, &request);
+  FRAME_WIDTH (f) = INTP(width) ? XINT(width) : 80;
+  FRAME_HEIGHT (f) = INTP(height) ? XINT(height) : 30;
+  char_to_pixel_size (f, FRAME_WIDTH(f), FRAME_HEIGHT (f),
+		      &FRAME_PIXWIDTH (f), &FRAME_PIXHEIGHT (f));
+
+  style = (NILP(popup)) ? MSWINDOWS_FRAME_STYLE : MSWINDOWS_POPUP_STYLE;
+  exstyle = (NILP(popup)) ? MSWINDOWS_FRAME_EXSTYLE : MSWINDOWS_POPUP_EXSTYLE;
+  rect.left = rect.top = 0;
+  rect.right = FRAME_PIXWIDTH (f);
+  rect.bottom = FRAME_PIXHEIGHT (f);
+
+  FRAME_MSWINDOWS_DATA(f)->button2_need_lbutton = 0;
+  FRAME_MSWINDOWS_DATA(f)->button2_need_rbutton = 0;
+  FRAME_MSWINDOWS_DATA(f)->button2_is_down = 0;
+  FRAME_MSWINDOWS_DATA(f)->ignore_next_lbutton_up = 0;
+  FRAME_MSWINDOWS_DATA(f)->ignore_next_rbutton_up = 0;
+  FRAME_MSWINDOWS_DATA(f)->sizing = 0;
+
+  AdjustWindowRectEx(&rect, style, ADJR_MENUFLAG, exstyle);
+
+  FRAME_MSWINDOWS_HANDLE(f) =
+    CreateWindowEx (exstyle,
+		    XEMACS_CLASS,
+		    STRINGP(f->name) ? XSTRING_DATA(f->name) :
+		    	(STRINGP(name) ? XSTRING_DATA(name) : XEMACS_CLASS),
+		    style,
+		    INTP(left) ? XINT(left) : CW_USEDEFAULT,
+		    INTP(top) ? XINT(top) : CW_USEDEFAULT,
+		    rect.right-rect.left, rect.bottom-rect.top,
+		    NULL, NULL, NULL, NULL);
+  XSETFRAME (frame_obj, f);
+  SetWindowLong (FRAME_MSWINDOWS_HANDLE(f), XWL_FRAMEOBJ, (LONG)frame_obj);
   FRAME_MSWINDOWS_DC(f) = GetDC(FRAME_MSWINDOWS_HANDLE(f));
   SetTextAlign(FRAME_MSWINDOWS_DC(f), TA_BASELINE|TA_LEFT|TA_NOUPDATECP);
 }
@@ -91,8 +139,8 @@
 {
   if (f->frame_data)
     {
-      mswindows_request_type request = { f };
-      mswindows_make_request(WM_XEMACS_DESTROYWINDOW, 0, &request);
+      ReleaseDC(FRAME_MSWINDOWS_HANDLE(f), FRAME_MSWINDOWS_DC(f));
+      DestroyWindow(FRAME_MSWINDOWS_HANDLE(f));
     }
 }
 
@@ -104,8 +152,12 @@
   GetWindowRect (FRAME_MSWINDOWS_HANDLE(f), &rect1);
   rect2.left = rect2.top = 0;
   char_to_pixel_size (f, cols, rows, &rect2.right, &rect2.bottom);
-  AdjustWindowRect (&rect2, GetWindowLong (FRAME_MSWINDOWS_HANDLE(f),
-					   GWL_STYLE), FALSE);
+
+  AdjustWindowRectEx (&rect2,
+		      GetWindowLong (FRAME_MSWINDOWS_HANDLE(f), GWL_STYLE),
+		      GetMenu (FRAME_MSWINDOWS_HANDLE(f)) != NULL,
+		      GetWindowLong (FRAME_MSWINDOWS_HANDLE(f), GWL_EXSTYLE));
+		    
   MoveWindow (FRAME_MSWINDOWS_HANDLE(f), rect1.left, rect1.top,
  	      rect2.right-rect2.left, rect2.bottom-rect2.top, TRUE);
 }
@@ -265,8 +317,11 @@
       if (!y_specified_p)
 	y = rect.top;
 
-      AdjustWindowRect (&rect, GetWindowLong (FRAME_MSWINDOWS_HANDLE(f),
-					      GWL_STYLE), FALSE);
+      AdjustWindowRectEx (&rect,
+			  GetWindowLong (FRAME_MSWINDOWS_HANDLE(f), GWL_STYLE),
+			  GetMenu (FRAME_MSWINDOWS_HANDLE(f)) != NULL,
+			  GetWindowLong (FRAME_MSWINDOWS_HANDLE(f), GWL_EXSTYLE));
+
       MoveWindow (FRAME_MSWINDOWS_HANDLE(f), x, y, pixel_width, pixel_height,
 		  (width_specified_p || height_specified_p));
     }
--- a/src/frame-tty.c	Mon Aug 13 10:10:03 2007 +0200
+++ b/src/frame-tty.c	Mon Aug 13 10:10:54 2007 +0200
@@ -69,8 +69,8 @@
 static void
 tty_select_frame_if_unhidden (Lisp_Object frame)
 {
-    if (FRAME_REPAINT_P (XFRAME (frame)))
-      select_frame_1 (frame);
+  if (FRAME_REPAINT_P (XFRAME (frame)))
+    select_frame_1 (frame);
 }
 
 static void
@@ -160,11 +160,9 @@
 tty_raise_frame_no_select (struct frame *f)
 {
   struct frame *o;
-  struct device *d = XDEVICE (FRAME_DEVICE (f));
-  Lisp_Object frame_list = DEVICE_FRAME_LIST (d);
-  Lisp_Object tail = frame_list;
+  Lisp_Object tail;
 
-  while (CONSP (tail))
+  LIST_LOOP (tail, DEVICE_FRAME_LIST (XDEVICE (FRAME_DEVICE (f))))
     {
       o = XFRAME (XCAR (tail));
       if (o != f && FRAME_REPAINT_P(o))
@@ -172,7 +170,6 @@
 	   tty_make_frame_hidden (o);
 	   break;
 	}
-      tail = XCDR (tail);
     }
   tty_make_frame_unhidden (f);
 }
@@ -187,27 +184,21 @@
 static void
 tty_lower_frame (struct frame *f)
 {
-  struct frame *o;
-  struct device *d = XDEVICE (FRAME_DEVICE (f));
-  Lisp_Object frame_list = DEVICE_FRAME_LIST (d);
-  Lisp_Object tail;
-  Lisp_Object new;
+  Lisp_Object frame_list = DEVICE_FRAME_LIST (XDEVICE (FRAME_DEVICE (f)));
+  Lisp_Object tail, new;
 
   if (!FRAME_REPAINT_P (f))
     return;
 
-  tail = frame_list;
-  while (CONSP (tail))
+  LIST_LOOP (tail, frame_list)
     {
-      o = XFRAME (XCAR (tail));
-      if (o == f)
+      if (f == XFRAME (XCAR (tail)))
 	break;
-      tail = XCDR (tail);
     }
 
-  /* to lower this frame another frame has to be raised.
-     return if there is no other frame. */
-  if (!CONSP (tail) && EQ(frame_list, tail))
+  /* To lower this frame, another frame has to be raised.  Return if
+     there is no other frame. */
+  if (NILP (tail) && EQ(frame_list, tail))
     return;
 
   tty_make_frame_hidden (f);
@@ -222,10 +213,10 @@
 static void
 tty_delete_frame (struct frame *f)
 {
-    struct device *d = XDEVICE (FRAME_DEVICE (f));
+  struct device *d = XDEVICE (FRAME_DEVICE (f));
 
-    if (!NILP (DEVICE_SELECTED_FRAME (d)))
-      tty_raise_frame (XFRAME (DEVICE_SELECTED_FRAME (d)));
+  if (!NILP (DEVICE_SELECTED_FRAME (d)))
+    tty_raise_frame (XFRAME (DEVICE_SELECTED_FRAME (d)));
 }
 
 /************************************************************************/
--- a/src/frame-x.c	Mon Aug 13 10:10:03 2007 +0200
+++ b/src/frame-x.c	Mon Aug 13 10:10:54 2007 +0200
@@ -2031,7 +2031,6 @@
 {
   /* This function can GC */
   Lisp_Object device = FRAME_DEVICE (f);
-  struct device *d = XDEVICE (device);
   Lisp_Object lisp_window_id;
   Lisp_Object popup;
 
--- a/src/general.c	Mon Aug 13 10:10:03 2007 +0200
+++ b/src/general.c	Mon Aug 13 10:10:54 2007 +0200
@@ -66,9 +66,7 @@
 Lisp_Object Qdevice;
 Lisp_Object Qdimension;
 Lisp_Object Qdisplay;
-#ifdef HAVE_OFFIX_DND
 Lisp_Object Qdnd_data;
-#endif
 Lisp_Object Qdoc_string;
 Lisp_Object Qdynarr_overhead;
 Lisp_Object Qempty;
@@ -109,6 +107,7 @@
 Lisp_Object Qminus;
 Lisp_Object Qmodifiers;
 Lisp_Object Qmotion;
+Lisp_Object Qmswindows;
 Lisp_Object Qname;
 Lisp_Object Qnone;
 Lisp_Object Qnot;
@@ -137,12 +136,14 @@
 Lisp_Object Qold_rassq;
 Lisp_Object Qsearch;
 Lisp_Object Qsimple;
+Lisp_Object Qsize;
 Lisp_Object Qspace;
 Lisp_Object Qspecifier;
 Lisp_Object Qstream;
 Lisp_Object Qstring;
 Lisp_Object Qsymbol;
 Lisp_Object Qsyntax;
+Lisp_Object Qtest;
 Lisp_Object Qtext;
 Lisp_Object Qtimeout;
 Lisp_Object Qtimestamp;
@@ -155,7 +156,6 @@
 Lisp_Object Qvalue_assoc;
 Lisp_Object Qvector;
 Lisp_Object Qwarning;
-Lisp_Object Qmswindows;
 Lisp_Object Qwhite;
 Lisp_Object Qwidth;
 Lisp_Object Qwindow;
@@ -202,9 +202,7 @@
   defsymbol (&Qdevice, "device");
   defsymbol (&Qdimension, "dimension");
   defsymbol (&Qdisplay, "display");
-#ifdef HAVE_OFFIX_DND
   defsymbol (&Qdnd_data, "dnd-data");
-#endif
   defsymbol (&Qdoc_string, "doc-string");
   defsymbol (&Qdynarr_overhead, "dynarr-overhead");
   defsymbol (&Qempty, "empty");
@@ -242,9 +240,10 @@
   defsymbol (&Qmemory, "memory");
   defsymbol (&Qmenubar, "menubar");
   defsymbol (&Qmessage, "message");
+  defsymbol (&Qminus, "-");
   defsymbol (&Qmodifiers, "modifiers");
   defsymbol (&Qmotion, "motion");
-  defsymbol (&Qminus, "-");
+  defsymbol (&Qmswindows, "mswindows");
   defsymbol (&Qname, "name");
   defsymbol (&Qnone, "none");
   defsymbol (&Qnot, "not");
@@ -272,12 +271,14 @@
   defsymbol (&Qold_rassq, "old-rassq");
   defsymbol (&Qsearch, "search");
   defsymbol (&Qsimple, "simple");
+  defsymbol (&Qsize, "size");
   defsymbol (&Qspace, "space");
   defsymbol (&Qspecifier, "specifier");
   defsymbol (&Qstream, "stream");
   defsymbol (&Qstring, "string");
   defsymbol (&Qsymbol, "symbol");
   defsymbol (&Qsyntax, "syntax");
+  defsymbol (&Qtest, "test");
   defsymbol (&Qtext, "text");
   defsymbol (&Qtimeout, "timeout");
   defsymbol (&Qtimestamp, "timestamp");
@@ -292,7 +293,6 @@
   defsymbol (&Qwarning, "warning");
   defsymbol (&Qwhite, "white");
   defsymbol (&Qwidth, "width");
-  defsymbol (&Qmswindows, "mswindows");
   defsymbol (&Qwindow, "window");
   defsymbol (&Qwindow_system, "window-system");
   defsymbol (&Qx, "x");
--- a/src/glyphs-x.c	Mon Aug 13 10:10:03 2007 +0200
+++ b/src/glyphs-x.c	Mon Aug 13 10:10:54 2007 +0200
@@ -57,9 +57,16 @@
 #include "sysfile.h"
 
 #ifdef HAVE_IMAGEMAGICK
+#ifdef SOLARIS2 /* Try to trick magick.h into not including Xos.h */
+#define _XOS_H_
+#endif
+#ifdef MAGICK_HEADERS_ARE_UNDER_X11
+#include <X11/magick/magick.h>
+#else
 #include <magick/magick.h>
+#endif
 /*#include <image.h>*/
-#include <assert.h>
+/*#include <assert.h>*/
 
 #define OLDCOMPAT /* allow lisp code using the old names to still function */
 #endif
@@ -1099,7 +1106,7 @@
 
       specbind (Qinhibit_quit, Qt);
       set_buffer_internal (XBUFFER (temp_buffer));
-      Ferase_buffer (Fcurrent_buffer ());
+      Ferase_buffer (Qnil);
 
       buffer_insert_c_string (current_buffer, "/* XPM */\r");
       buffer_insert_c_string (current_buffer, "static char *pixmap[] = {\r");
@@ -1116,7 +1123,7 @@
 	    buffer_insert_c_string (current_buffer, "\"};\r");
 	}
 
-      retval = Fbuffer_substring (Qnil, Qnil, Fcurrent_buffer ());
+      retval = Fbuffer_substring (Qnil, Qnil, Qnil);
       XpmFree (data);
 
       set_buffer_internal (old_buffer);
--- a/src/glyphs.c	Mon Aug 13 10:10:03 2007 +0200
+++ b/src/glyphs.c	Mon Aug 13 10:10:54 2007 +0200
@@ -400,10 +400,10 @@
   temp_buffer = Fget_buffer_create (build_string (" *pixmap conversion*"));
   GCPRO1 (temp_buffer);
   set_buffer_internal (XBUFFER (temp_buffer));
-  Ferase_buffer (Fcurrent_buffer ());
+  Ferase_buffer (Qnil);
   specbind (intern ("format-alist"), Qnil);
   Finsert_file_contents_internal (file, Qnil, Qnil, Qnil, Qnil, Qnil, Qnil);
-  data = Fbuffer_substring (Qnil, Qnil, Fcurrent_buffer ());
+  data = Fbuffer_substring (Qnil, Qnil, Qnil);
   unbind_to (count, Qnil);
   UNGCPRO;
   return data;
--- a/src/input-method-motif.c	Mon Aug 13 10:10:03 2007 +0200
+++ b/src/input-method-motif.c	Mon Aug 13 10:10:54 2007 +0200
@@ -73,6 +73,8 @@
         }
     }
 
+  setlocale(LC_NUMERIC, "C");
+
   if (XSetLocaleModifiers ("") == NULL)
     {
       stderr_out ("XSetLocaleModifiers(\"\") failed\n");
--- a/src/input-method-xfs.c	Mon Aug 13 10:10:03 2007 +0200
+++ b/src/input-method-xfs.c	Mon Aug 13 10:10:54 2007 +0200
@@ -41,7 +41,7 @@
 Initialize_Locale (void)
 {
   char *locale;
-  
+
   XtSetLanguageProc (NULL, (XtLanguageProc) NULL, NULL);
   if ((locale = setlocale (LC_ALL, "")) == NULL)
     {
@@ -73,6 +73,8 @@
           return;
         }
     }
+
+  setlocale(LC_NUMERIC, "C");
   
   if (XSetLocaleModifiers ("") == NULL)
     {
--- a/src/input-method-xlib.c	Mon Aug 13 10:10:03 2007 +0200
+++ b/src/input-method-xlib.c	Mon Aug 13 10:10:54 2007 +0200
@@ -111,6 +111,8 @@
         }
     }
 
+  setlocale(LC_NUMERIC, "C");
+
   if (XSetLocaleModifiers ("") == NULL)
     {
       stderr_out ("XSetLocaleModifiers(\"\") failed\n");
@@ -766,19 +768,19 @@
 
   stderr_out ("\nInput method context attributes:\n");
   stderr_out ("Style: "); describe_XIMStyle (style);
-  stderr_out ("Client window: %x\n", client_win);
-  stderr_out ("Focus window: %x\n",  focus_win);
+  stderr_out ("Client window: %lx\n", (unsigned long int)client_win);
+  stderr_out ("Focus window: %lx\n",  (unsigned long int)focus_win);
   stderr_out ("Preedit:\n");
   describe_XRectangle ("  Area", p_area);
   describe_XRectangle ("  Area needed", p_needed);
-  stderr_out ("  foreground: %x\n", p_fg);
-  stderr_out ("  background: %x\n", p_bg);
+  stderr_out ("  foreground: %lx\n", (unsigned long int)p_fg);
+  stderr_out ("  background: %lx\n", (unsigned long int)p_bg);
   stderr_out ("  fontset: "); describe_XFontSet (p_fontset);
   stderr_out ("Status:\n");
   describe_XRectangle ("  Area", s_area);
   describe_XRectangle ("  Area needed", s_needed);
-  stderr_out ("  foreground: %x\n", s_fg);
-  stderr_out ("  background: %x\n", s_bg);
+  stderr_out ("  foreground: %lx\n", (unsigned long int)s_fg);
+  stderr_out ("  background: %lx\n", (unsigned long int)s_bg);
   stderr_out ("  fontset: \n"); describe_XFontSet (s_fontset);
   stderr_out ("XNResourceName: %s\n",  resourceName  ? resourceName  : "NULL");
   stderr_out ("XNResourceClass: %s\n", resourceClass ? resourceClass : "NULL");
--- a/src/intl.c	Mon Aug 13 10:10:03 2007 +0200
+++ b/src/intl.c	Mon Aug 13 10:10:54 2007 +0200
@@ -296,6 +296,7 @@
 {
 #if defined (I18N2) || defined (I18N3) || defined (I18N4)
   setlocale (LC_ALL, "");
+  setlocale(LC_NUMERIC, "C");
 #endif
 
 #ifdef I18N3
--- a/src/msw-proc.c	Mon Aug 13 10:10:03 2007 +0200
+++ b/src/msw-proc.c	Mon Aug 13 10:10:54 2007 +0200
@@ -25,46 +25,6 @@
    Jonathan Harris, November 1997 for 20.4.
  */
 
-/*
- * Comment:
- *
- * X on UNIX may be bad, but the win32 API really really really sucks.
- *
- * Windows user-input type events are stored in a per-thread message queue
- * and retrieved using GetMessage(). It is not possible to wait on this
- * queue and on other events (eg process input) simultaneously. Also, the
- * main event-handling code in windows (the "windows procedure") is called
- * asynchronously when windows has certain other types of events ("nonqueued
- * messages") to deliver. The documentation doesn't appear to specify the
- * context in which the windows procedure is called, but I assume that the
- * thread that created the window is temporarily highjacked for this purpose
- * when it calls GetMessage (a bit like X callbacks?).
- *
- * We spawn off a single thread to deal with both queued and non-queued
- * events. The thread turns both kinds of events into emacs_events and stuffs
- * them in a queue which XEmacs reads at its leisure. This file contains the
- * code for that thread.
- *
- * Unfortunately, under win32 a seemingly-random selection of resources are
- * owned by the thread that created/asked for them and not by the process. In
- * particular, only the thread that created a window can retrieve messages
- * destined for that window ("GetMessage does not retrieve messages for
- * windows that belong to other threads..."). This means that our message-
- * processing thread also has to do all window creation, deletion and various
- * other random stuff. We handle this bogosity by getting the main XEmacs
- * thread to send special user-defined messages to the message-processing
- * thread to instruct it to create windows etc.
- *
- * More bogosity: Windows95 doesn't offer any one-shot timers, only a
- * periodic timer. Worse, if you don't want a periodic timer to be associated
- * with a particular mswindows window (we don't) your periodic timers don't
- * have unique ids associated with them. We get round this lameness by
- * setting off a single periodic timer and we use this to schedule timeouts
- * manually. Implementing basic stuff like one-shot timers at the application
- * level is not particularly efficient, but Windows95 leaves us no choice.
- */
-
-
 #include <config.h>
 #include "lisp.h"
 
@@ -80,11 +40,15 @@
 # undef DEBUG_TIMEOUTS
 #endif
 
-#define MSWINDOWS_FRAME_STYLE WS_CLIPCHILDREN|WS_CLIPSIBLINGS|WS_TILEDWINDOW
-#define MSWINDOWS_POPUP_STYLE WS_CLIPCHILDREN|WS_CLIPSIBLINGS|WS_CAPTION|WS_POPUP
+#ifdef HAVE_MENUBARS
+#define ADJR_MENUFLAG TRUE
+#else
+#define ADJR_MENUFLAG FALSE
+#endif
 
-static LRESULT WINAPI mswindows_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
-static Lisp_Object mswindows_find_console (HWND hwnd);
+/* Timer ID used for button2 emulation */
+#define BUTTON_2_TIMER_ID 1
+
 static Lisp_Object mswindows_find_frame (HWND hwnd);
 static Lisp_Object mswindows_key_to_emacs_keysym(int mswindows_key, int mods);
 static int mswindows_modifier_state (void);
@@ -92,7 +56,7 @@
 static void mswindows_dequeue_timeout (int interval_id);
 
 /* Virtual keycode of the '@' key */
-static int virtual_at_key;
+static int virtual_at_key = -1;
 
 /* Timeout queue */
 struct mswindows_timeout
@@ -106,37 +70,12 @@
 static mswindows_timeout *timeout_head = NULL;
 static int timeout_mswindows_id;
 
+#if 0
 /*
  * Entry point for the "windows" message-processing thread
  */
 DWORD mswindows_win_thread()
 {
-  WNDCLASS wc;
-  MSG msg;
-  mswindows_waitable_info_type info;
-
-  /* Register the main window class */
-  wc.style = CS_OWNDC;	/* One DC per window */
-  wc.lpfnWndProc = (WNDPROC) mswindows_wnd_proc;
-  wc.cbClsExtra = 0;
-  wc.cbWndExtra = 0;	/* ? */
-  wc.hInstance = NULL;	/* ? */
-  wc.hIcon = LoadIcon (NULL, XEMACS_CLASS);
-  wc.hCursor = LoadCursor (NULL, IDC_ARROW);
-  wc.hbrBackground = NULL; /* GetStockObject (WHITE_BRUSH); */
-  wc.lpszMenuName = NULL;	/* XXX FIXME? Add a menu? */
-  wc.lpszClassName = XEMACS_CLASS;
-  RegisterClass(&wc);		/* XXX FIXME: Should use RegisterClassEx */
-
-  info.type = mswindows_waitable_type_dispatch;
-  mswindows_add_waitable(&info);
-
-  /* Ensure our message queue is created XXX FIXME: Is this necessary? */
-  PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE);
-
-  /* Notify the main thread that we're ready */
-  assert(PostThreadMessage (mswindows_main_thread_id, WM_XEMACS_ACK, 0, 0));
-
   /* Hack! Windows doesn't report Ctrl-@ characters so we have to find out
    * which virtual key generates '@' at runtime */
   virtual_at_key = VkKeyScan ('@');
@@ -193,62 +132,151 @@
       DispatchMessage (&msg);
   }
 }
+#endif /* 0 */
+
+static void
+mswindows_enqueue_magic_event (HWND hwnd, UINT message)
+{
+  Lisp_Object emacs_event = Fmake_event (Qnil, Qnil);
+  struct Lisp_Event* event = XEVENT (emacs_event);
+
+  event->channel = mswindows_find_frame (hwnd);
+  event->timestamp = GetMessageTime();
+  event->event_type = magic_event;
+  EVENT_MSWINDOWS_MAGIC_TYPE (event) = message;
+
+  mswindows_enqueue_dispatch_event (emacs_event);
+}
+
+static void
+mswindows_enqueue_mouse_button_event (HWND hwnd, UINT message, POINTS where, DWORD when)
+{
+
+  /* We always use last message time, because mouse button
+     events may get delayed, and XEmacs double click
+     recognition will fail */
+
+  Lisp_Object emacs_event = Fmake_event (Qnil, Qnil);
+  struct Lisp_Event* event = XEVENT(emacs_event);
+
+  event->channel = mswindows_find_frame(hwnd);
+  event->timestamp = when;
+  event->event.button.button =
+    (message==WM_LBUTTONDOWN || message==WM_LBUTTONUP) ? 1 :
+    ((message==WM_RBUTTONDOWN || message==WM_RBUTTONUP) ? 3 : 2);
+  event->event.button.x = where.x;
+  event->event.button.y = where.y;
+  event->event.button.modifiers = mswindows_modifier_state();
+      
+  if (message==WM_LBUTTONDOWN || message==WM_MBUTTONDOWN ||
+      message==WM_RBUTTONDOWN)
+    {
+      event->event_type = button_press_event;
+      SetCapture (hwnd);
+    }
+  else
+    {
+      event->event_type = button_release_event;
+      ReleaseCapture ();
+    }
+  
+  mswindows_enqueue_dispatch_event (emacs_event);
+}
+
+static void
+mswindows_set_chord_timer (HWND hwnd)
+{
+  int interval;
+
+  /* We get half system threshold as it seems to
+     long before drag-selection is shown */
+  if (mswindows_button2_chord_time <= 0)
+    interval = GetDoubleClickTime () / 2;
+  else
+    interval = mswindows_button2_chord_time;
+
+  SetTimer (hwnd, BUTTON_2_TIMER_ID, interval, 0);
+}
+
+static int
+mswindows_button2_near_enough (POINTS p1, POINTS p2)
+{
+  int dx, dy;
+  if (mswindows_button2_max_skew_x <= 0)
+    dx = GetSystemMetrics (SM_CXDOUBLECLK) / 2;
+  else
+    dx = mswindows_button2_max_skew_x;
+
+  if (mswindows_button2_max_skew_y <= 0)
+    dy = GetSystemMetrics (SM_CYDOUBLECLK) / 2;
+  else
+    dy = mswindows_button2_max_skew_y;
+
+  return abs (p1.x - p2.x) < dx && abs (p1.y- p2.y)< dy;
+}
 
 /*
  * The windows procedure for the window class XEMACS_CLASS
  * Stuffs messages in the mswindows event queue
  */
-static LRESULT WINAPI mswindows_wnd_proc(HWND hwnd, UINT message, WPARAM wParam,
-				   LPARAM lParam)
+LRESULT WINAPI
+mswindows_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
 {
   /* Note: Remember to initialise these before use */
   Lisp_Object emacs_event;
   struct Lisp_Event *event;
-
-  static sizing = 0;
-  MSG msg = { hwnd, message, wParam, lParam, 0, {0,0} };
-  msg.time = GetMessageTime();
-
-#ifdef DEBUG_MESSAGES
-  stderr_out("Message %04x, wParam=%04x, lParam=%08lx\n", message, wParam, lParam);
-#endif
+  Lisp_Object fobj;
+  struct frame *frame;
+  struct mswindows_frame* msframe;
+  
   switch (message)
   {
+  case WM_ERASEBKGND:
+    /* Erase background only during non-dynamic sizing */
+    msframe  = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
+    if (msframe->sizing && !mswindows_dynamic_frame_resize)
+      goto defproc;
+    return 1;
+
+  case WM_CLOSE:
+    fobj = mswindows_find_frame (hwnd);
+    enqueue_misc_user_event (fobj, Qeval, list3 (Qdelete_frame, fobj, Qt));
+    mswindows_enqueue_magic_event (hwnd, XM_BUMPQUEUE);
+    break;
+
   case WM_KEYDOWN:
   case WM_SYSKEYDOWN:
     {
+      MSG msg = { hwnd, message, wParam, lParam, GetMessageTime(), GetMessagePos() };
       /* Handle those keys that TranslateMessage won't generate a WM_CHAR for */
       Lisp_Object keysym;
       int mods = mswindows_modifier_state();
 
       if (!NILP (keysym = mswindows_key_to_emacs_keysym(wParam, mods)))
 	{
-          EnterCriticalSection (&mswindows_dispatch_crit);
 	  emacs_event = Fmake_event (Qnil, Qnil);
 	  event = XEVENT(emacs_event);
 
           event->channel = mswindows_find_console(hwnd);
-          event->timestamp = msg.time;
+          event->timestamp = GetMessageTime();
           event->event_type = key_press_event;
           event->event.key.keysym = keysym;
 	  event->event.key.modifiers = mods;
 	  mswindows_enqueue_dispatch_event (emacs_event);
-          LeaveCriticalSection (&mswindows_dispatch_crit);
 	  return (0);
 	}
+      TranslateMessage (&msg);
     }
-    TranslateMessage (&msg);  /* Maybe generates WM_[SYS]CHAR in message queue */
     goto defproc;
 
   case WM_CHAR:
   case WM_SYSCHAR:
     {
-      EnterCriticalSection (&mswindows_dispatch_crit);
       emacs_event = Fmake_event (Qnil, Qnil);
       event = XEVENT(emacs_event);
 
       event->channel = mswindows_find_console(hwnd);
-      event->timestamp = msg.time;
+      event->timestamp = GetMessageTime();
       event->event_type = key_press_event;
 
       /* XEmacs doesn't seem to like Shift on non-alpha keys */
@@ -256,6 +284,16 @@
 				   mswindows_modifier_state() :
 				   mswindows_modifier_state() & ~MOD_SHIFT;
 
+      /* If a quit char with no modifiers other than control and
+	 shift, then mark it with a fake modifier, which is removed
+	 upon dequeueing the event */
+      if (wParam == CONSOLE_QUIT_CHAR (XCONSOLE (mswindows_find_console (hwnd)))
+	  && ((event->event.key.modifiers & ~(MOD_CONTROL | MOD_SHIFT)) == 0))
+	  {
+	    event->event.key.modifiers |= FAKE_MOD_QUIT;
+	    ++mswindows_quit_chars_count;
+	  }
+
       if (wParam<' ')	/* Control char not already handled under WM_KEYDOWN */
       {
 	/* Don't capitalise alpha control keys */
@@ -270,95 +308,200 @@
       }
 
       mswindows_enqueue_dispatch_event (emacs_event);
-      LeaveCriticalSection (&mswindows_dispatch_crit);
     }
     break;
 
+  case WM_MBUTTONDOWN:
+  case WM_MBUTTONUP:
+    /* Real middle mouse button has nothing to do with emulated one:
+       if one wants to exercise fingers playing chords on the mouse,
+       he is allowed to do that! */
+    mswindows_enqueue_mouse_button_event (hwnd, message,
+					  MAKEPOINTS (lParam), GetMessageTime());
+    break;
+    
+  case WM_LBUTTONUP:
+    msframe  = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
+    msframe->last_click_time =  GetMessageTime();
+
+    KillTimer (hwnd, BUTTON_2_TIMER_ID);
+    msframe->button2_need_lbutton = 0;
+    if (msframe->ignore_next_lbutton_up)
+      {
+	msframe->ignore_next_lbutton_up = 0;
+      }
+    else if (msframe->button2_is_down)
+      {
+	msframe->button2_is_down = 0;
+	msframe->ignore_next_rbutton_up = 1;
+	mswindows_enqueue_mouse_button_event (hwnd, WM_MBUTTONUP,
+					      MAKEPOINTS (lParam), GetMessageTime());
+      }
+    else
+      {
+	if (msframe->button2_need_rbutton)
+	  {
+	    msframe->button2_need_rbutton = 0;
+	    mswindows_enqueue_mouse_button_event (hwnd, WM_LBUTTONDOWN,
+						  MAKEPOINTS (lParam), GetMessageTime());
+	  }
+	mswindows_enqueue_mouse_button_event (hwnd, WM_LBUTTONUP,
+					      MAKEPOINTS (lParam), GetMessageTime());
+      }
+    break;
+
+  case WM_RBUTTONUP:
+    msframe  = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
+    msframe->last_click_time =  GetMessageTime();
+
+    KillTimer (hwnd, BUTTON_2_TIMER_ID);
+    msframe->button2_need_rbutton = 0;
+    if (msframe->ignore_next_rbutton_up)
+      {
+	msframe->ignore_next_rbutton_up = 0;
+      }
+    else if (msframe->button2_is_down)
+      {
+	msframe->button2_is_down = 0;
+	msframe->ignore_next_lbutton_up = 1;
+	mswindows_enqueue_mouse_button_event (hwnd, WM_MBUTTONUP,
+					      MAKEPOINTS (lParam), GetMessageTime());
+      }
+    else
+      {
+	if (msframe->button2_need_lbutton)
+	  {
+	    msframe->button2_need_lbutton = 0;
+	    mswindows_enqueue_mouse_button_event (hwnd, WM_RBUTTONDOWN,
+						  MAKEPOINTS (lParam), GetMessageTime());
+	  }
+	mswindows_enqueue_mouse_button_event (hwnd, WM_RBUTTONUP,
+					      MAKEPOINTS (lParam), GetMessageTime());
+      }
+    break;
+
   case WM_LBUTTONDOWN:
-  case WM_MBUTTONDOWN:
+    msframe  = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
+
+    if (msframe->button2_need_lbutton)
+      {
+	KillTimer (hwnd, BUTTON_2_TIMER_ID);
+	msframe->button2_need_lbutton = 0;
+	msframe->button2_need_rbutton = 0;
+	msframe->button2_is_down = 1;
+	if (mswindows_button2_near_enough (msframe->last_click_point, MAKEPOINTS (lParam)))
+	  mswindows_enqueue_mouse_button_event (hwnd, WM_MBUTTONDOWN,
+						MAKEPOINTS (lParam), GetMessageTime());
+	else
+	  {
+	    mswindows_enqueue_mouse_button_event (hwnd, WM_RBUTTONDOWN,
+			msframe->last_click_point, msframe->last_click_time);
+	    mswindows_enqueue_mouse_button_event (hwnd, WM_LBUTTONDOWN,
+						  MAKEPOINTS (lParam), GetMessageTime());
+	  }
+      }
+    else
+      {
+	mswindows_set_chord_timer (hwnd);
+	msframe->button2_need_rbutton = 1;
+	msframe->last_click_point = MAKEPOINTS (lParam);
+      }
+    msframe->last_click_time =  GetMessageTime();
+    break;
+
   case WM_RBUTTONDOWN:
-  case WM_LBUTTONUP:
-  case WM_MBUTTONUP:
-  case WM_RBUTTONUP:
+    msframe  = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
+
+    if (msframe->button2_need_rbutton)
+      {
+	KillTimer (hwnd, BUTTON_2_TIMER_ID);
+	msframe->button2_need_lbutton = 0;
+	msframe->button2_need_rbutton = 0;
+	msframe->button2_is_down = 1;
+	if (mswindows_button2_near_enough (msframe->last_click_point, MAKEPOINTS (lParam)))
+	  mswindows_enqueue_mouse_button_event (hwnd, WM_MBUTTONDOWN,
+						MAKEPOINTS (lParam), GetMessageTime());
+	else
+	  {
+	    mswindows_enqueue_mouse_button_event (hwnd, WM_LBUTTONDOWN,
+				msframe->last_click_point, msframe->last_click_time);
+	    mswindows_enqueue_mouse_button_event (hwnd, WM_RBUTTONDOWN,
+						  MAKEPOINTS (lParam), GetMessageTime());
+	  }
+      }
+    else
+      {
+	mswindows_set_chord_timer (hwnd);
+	msframe->button2_need_lbutton = 1;
+	msframe->last_click_point = MAKEPOINTS (lParam);
+      }
+    msframe->last_click_time =  GetMessageTime();
+    break;
+	
+  case WM_TIMER:
+    if (wParam == BUTTON_2_TIMER_ID)
+      {
+	msframe  = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
+	KillTimer (hwnd, BUTTON_2_TIMER_ID);
+
+	if (msframe->button2_need_lbutton)
+	  {
+	    msframe->button2_need_lbutton = 0;
+	    mswindows_enqueue_mouse_button_event (hwnd, WM_RBUTTONDOWN,
+				msframe->last_click_point, msframe->last_click_time);
+	  }
+	else if (msframe->button2_need_rbutton)
+	  {
+	    msframe->button2_need_rbutton = 0;
+	    mswindows_enqueue_mouse_button_event (hwnd, WM_LBUTTONDOWN,
+				msframe->last_click_point, msframe->last_click_time);
+	  }
+      }
+    else
+      assert ("Spurious timer fired" == 0);
+    break;
+
+  case WM_MOUSEMOVE:
+    /* Optimization: don't report mouse movement while size is changind */
+    msframe  = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
+    if (!msframe->sizing)
     {
-      /* XXX FIXME: Do middle button emulation */
-      short x, y;
+      /* When waiting for the second mouse button to finish
+	 button2 emulation, and have moved too far, just pretend
+	 as if timer has expired. This impoves drag-select feedback */
+      if ((msframe->button2_need_lbutton || msframe->button2_need_rbutton)
+	  && !mswindows_button2_near_enough (msframe->last_click_point,
+					     MAKEPOINTS (lParam)))
+	{
+	  KillTimer (hwnd, BUTTON_2_TIMER_ID);
+	  SendMessage (hwnd, WM_TIMER, BUTTON_2_TIMER_ID, 0);
+	}
 
-      EnterCriticalSection (&mswindows_dispatch_crit);
       emacs_event = Fmake_event (Qnil, Qnil);
       event = XEVENT(emacs_event);
 
       event->channel = mswindows_find_frame(hwnd);
-      event->timestamp = msg.time;
-      event->event.button.button =
-	(message==WM_LBUTTONDOWN || message==WM_LBUTTONUP) ? 1 :
-	 ((message==WM_RBUTTONDOWN || message==WM_RBUTTONUP) ? 3 : 2);
-      x = LOWORD (lParam);
-      y = HIWORD (lParam);
-      event->event.button.x = x;
-      event->event.button.y = y;
-      event->event.button.modifiers = mswindows_modifier_state();
-      
-      if (message==WM_LBUTTONDOWN || message==WM_MBUTTONDOWN ||
-	  message==WM_RBUTTONDOWN)
-	{
-	  event->event_type = button_press_event;
-	  SetCapture (hwnd);
-	}
-      else
-	{
-	  event->event_type = button_release_event;
-	  ReleaseCapture ();
-	}
-
-      mswindows_enqueue_dispatch_event (emacs_event);
-      LeaveCriticalSection (&mswindows_dispatch_crit);
-    }
-    break;
-
-  case WM_MOUSEMOVE:
-    /* Optimization: don't report mouse movement while size is changind */
-    if (!sizing)
-    {
-      short x, y;
-
-      EnterCriticalSection (&mswindows_dispatch_crit);
-      emacs_event = Fmake_event (Qnil, Qnil);
-      event = XEVENT(emacs_event);
-
-      event->channel = mswindows_find_frame(hwnd);
-      event->timestamp = msg.time;
+      event->timestamp = GetMessageTime();
       event->event_type = pointer_motion_event;
-      x = LOWORD (lParam);
-      y = HIWORD (lParam);
-      event->event.motion.x = x;
-      event->event.motion.y = y;
+      event->event.motion.x = MAKEPOINTS(lParam).x;
+      event->event.motion.y = MAKEPOINTS(lParam).y;
       event->event.motion.modifiers = mswindows_modifier_state();
       
       mswindows_enqueue_dispatch_event (emacs_event);
-      LeaveCriticalSection (&mswindows_dispatch_crit);
     }
     break;
 
   case WM_PAINT:
-    if (GetUpdateRect(hwnd, NULL, FALSE))
     {
       PAINTSTRUCT paintStruct;
-
-      EnterCriticalSection (&mswindows_dispatch_crit);
-      emacs_event = Fmake_event (Qnil, Qnil);
-      event = XEVENT(emacs_event);
+      
+      frame = XFRAME (mswindows_find_frame (hwnd));
 
-      event->channel = mswindows_find_frame(hwnd);
-      event->timestamp = msg.time;
-      event->event_type = magic_event;
       BeginPaint (hwnd, &paintStruct);
-      EVENT_MSWINDOWS_MAGIC_TYPE(event) = message;
-      EVENT_MSWINDOWS_MAGIC_DATA(event) = paintStruct.rcPaint;
+      mswindows_redraw_exposed_area (frame,
+			paintStruct.rcPaint.left, paintStruct.rcPaint.top,
+			paintStruct.rcPaint.right, paintStruct.rcPaint.bottom);
       EndPaint (hwnd, &paintStruct);
-
-      mswindows_enqueue_dispatch_event (emacs_event);
-      LeaveCriticalSection (&mswindows_dispatch_crit);
     }
     break;
 
@@ -367,42 +510,46 @@
     if (wParam==SIZE_RESTORED || wParam==SIZE_MAXIMIZED || wParam==SIZE_MINIMIZED)
     {
       RECT rect;
-      EnterCriticalSection (&mswindows_dispatch_crit);
-      emacs_event = Fmake_event (Qnil, Qnil);
-      event = XEVENT(emacs_event);
+      int columns, rows;
 
-      event->channel = mswindows_find_frame(hwnd);
-      event->timestamp = msg.time;
-      event->event_type = magic_event;
+      fobj = mswindows_find_frame (hwnd);
+      frame = XFRAME (fobj);
+      msframe  = FRAME_MSWINDOWS_DATA (frame);
+
+      /* We cannot handle frame map and unmap hooks right in
+	 this routine, because these may throw. We queue
+	 magic events to run these hooks instead - kkm */
+
       if (wParam==SIZE_MINIMIZED)
-	rect.left = rect.top = rect.right = rect.bottom = -1;
+	{
+	  /* Iconified */
+	  FRAME_VISIBLE_P (frame) = 0;
+	  mswindows_enqueue_magic_event (hwnd, XM_UNMAPFRAME);
+	  Fframe_iconified_p (fobj);
+	}
       else
-	GetClientRect(hwnd, &rect);
-      EVENT_MSWINDOWS_MAGIC_TYPE(event) = message;
-      EVENT_MSWINDOWS_MAGIC_DATA(event) = rect;
+	{
+	  int was_visible = FRAME_VISIBLE_P (frame);
+	  if (!msframe->sizing && !was_visible)
+	    mswindows_enqueue_magic_event (hwnd, XM_MAPFRAME);
+	  
+	  GetClientRect(hwnd, &rect);
+      	  FRAME_VISIBLE_P(frame) = 1;
+	  FRAME_PIXWIDTH(frame) = rect.right;
+	  FRAME_PIXHEIGHT(frame) = rect.bottom;
+	  pixel_to_char_size (frame, rect.right, rect.bottom, &columns, &rows);
+	  change_frame_size (frame, rows, columns, 1);
 
-      mswindows_enqueue_dispatch_event (emacs_event);
-      LeaveCriticalSection (&mswindows_dispatch_crit);
+	  if (mswindows_dynamic_frame_resize)
+	    redisplay ();
+	}
     }
     break;
 
   /* Misc magic events which only require that the frame be identified */
   case WM_SETFOCUS:
   case WM_KILLFOCUS:
-  case WM_CLOSE:
-    {
-      EnterCriticalSection (&mswindows_dispatch_crit);
-      emacs_event = Fmake_event (Qnil, Qnil);
-      event = XEVENT (emacs_event);
-
-      event->channel = mswindows_find_frame (hwnd);
-      event->timestamp = msg.time;
-      event->event_type = magic_event;
-      EVENT_MSWINDOWS_MAGIC_TYPE (event) = message;
-
-      mswindows_enqueue_dispatch_event (emacs_event);
-      LeaveCriticalSection (&mswindows_dispatch_crit);
-    }
+    mswindows_enqueue_magic_event (hwnd, message);
     break;
 
   case WM_WINDOWPOSCHANGING:
@@ -416,7 +563,9 @@
       {
 	RECT ncsize = { 0, 0, 0, 0 };
 	int pixwidth, pixheight;
-	AdjustWindowRect (&ncsize, GetWindowLong (hwnd, GWL_STYLE), FALSE);
+ 	AdjustWindowRectEx (&ncsize, GetWindowLong (hwnd, GWL_STYLE),
+ 			    GetMenu(hwnd) != NULL,
+			    GetWindowLong (hwnd, GWL_EXSTYLE));
 
 	round_size_to_char (XFRAME (mswindows_find_frame (hwnd)),
 			    wp->cx - (ncsize.right - ncsize.left),
@@ -447,9 +596,16 @@
     break;
 
   case WM_ENTERSIZEMOVE:
+    msframe  = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
+    msframe->sizing = 1;
+    return 0;
+
   case WM_EXITSIZEMOVE:
-    sizing = (message == WM_ENTERSIZEMOVE);
-    goto defproc;
+    msframe  = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
+    msframe->sizing = 0;
+    /* Queue noop event */
+    mswindows_enqueue_magic_event (hwnd, XM_BUMPQUEUE);
+    return 0;
 
   defproc:
   default:
@@ -459,6 +615,7 @@
 }
 
 
+#if 0
 /*
  * Make a request to the message-processing thread to do things that
  * can't be done in the main thread.
@@ -466,94 +623,17 @@
 LPARAM
 mswindows_make_request(UINT message, WPARAM wParam, mswindows_request_type *request)
 {
-  MSG msg;
-  assert(PostThreadMessage (mswindows_win_thread_id, message, wParam,
-			    (LPARAM) request));
-  GetMessage (&msg, NULL, WM_XEMACS_ACK, WM_XEMACS_ACK);
-  return (msg.lParam);
-}
-
-
-/* 
- * Handle a request from the main thread to do things that have to be
- * done in the message-processing thread.
- */
-static void
-mswindows_handle_request (MSG *msg)
-{
-  mswindows_request_type *request = (mswindows_request_type *) msg->lParam;
-
-  switch (msg->message)
-  {
-  case WM_XEMACS_CREATEWINDOW:
-    {
-    struct frame *f = request->thing1;
-    Lisp_Object *props = request->thing2;
-    Lisp_Object name, height, width, popup, top, left;
-    int pixel_width, pixel_height;
-    RECT rect;
-    DWORD style;
-    HWND hwnd;
-
-    name = Fplist_get (*props, Qname, Qnil);
-    height = Fplist_get (*props, Qheight, Qnil);
-    width = Fplist_get (*props, Qwidth, Qnil);
-    popup = Fplist_get (*props, Qpopup, Qnil);
-    top = Fplist_get (*props, Qtop, Qnil);
-    left = Fplist_get (*props, Qleft, Qnil);
-
-    style = (NILP(popup)) ? MSWINDOWS_FRAME_STYLE : MSWINDOWS_POPUP_STYLE;
-
-    FRAME_WIDTH (f) = INTP(width) ? XINT(width) : 80;
-    FRAME_HEIGHT (f) = INTP(height) ? XINT(height) : 30;
-    char_to_pixel_size (f, FRAME_WIDTH(f), FRAME_HEIGHT (f),
-			&FRAME_PIXWIDTH (f), &FRAME_PIXHEIGHT (f));
-
-    rect.left = rect.top = 0;
-    rect.right = FRAME_PIXWIDTH (f);
-    rect.bottom = FRAME_PIXHEIGHT (f);
-#ifdef HAVE_MENUBARS
-    AdjustWindowRect(&rect, style, TRUE);
-#else
-    AdjustWindowRect(&rect, style, FALSE);
-#endif
-
-    hwnd = CreateWindow (XEMACS_CLASS,
-	STRINGP(f->name) ? XSTRING_DATA(f->name) :
-	  (STRINGP(name) ? XSTRING_DATA(name) : XEMACS_CLASS),
-	style,
-	INTP(left) ? XINT(left) : CW_USEDEFAULT,
-	INTP(top) ? XINT(top) : CW_USEDEFAULT,
-	rect.right-rect.left, rect.bottom-rect.top,
-	NULL, NULL, NULL, NULL);
-    assert(PostThreadMessage (mswindows_main_thread_id, WM_XEMACS_ACK, 0, (LPARAM) hwnd));
-    }
-    return;
-
-  case WM_XEMACS_DESTROYWINDOW:
-    {
-      struct frame *f = request->thing1;
-      ReleaseDC(FRAME_MSWINDOWS_HANDLE(f), FRAME_MSWINDOWS_DC(f));
-      DestroyWindow(FRAME_MSWINDOWS_HANDLE(f));
-      assert (PostThreadMessage (mswindows_main_thread_id, WM_XEMACS_ACK, 0, 0));
-    }
-    break;
-
   case WM_XEMACS_SETTIMER:
     {
       int id;
-      EnterCriticalSection (&mswindows_dispatch_crit);
       id = mswindows_enqueue_timeout((int) request->thing1);
-      LeaveCriticalSection (&mswindows_dispatch_crit);
       assert(PostThreadMessage (mswindows_main_thread_id, WM_XEMACS_ACK, 0, id));
     }
     break;
 
   case WM_XEMACS_KILLTIMER:
     {
-      EnterCriticalSection (&mswindows_dispatch_crit);
       mswindows_dequeue_timeout((int) request->thing1);
-      LeaveCriticalSection (&mswindows_dispatch_crit);
       assert(PostThreadMessage (mswindows_main_thread_id, WM_XEMACS_ACK, 0, 0));
     }
     break;
@@ -562,7 +642,7 @@
     assert(0);
   }
 }
-
+#endif
 
 /* Returns the state of the modifier keys in the format expected by the
  * Lisp_Event key_data, button_data and motion_data modifiers member */
@@ -650,7 +730,7 @@
   return Qnil;
 }
 
-
+#if 0
 /*
  * Add a timeout to the queue. Returns the id or 0 on failure
  */
@@ -791,12 +871,12 @@
     Fdeallocate_event(match_event);
   }
 }
-
+#endif
 
 /*
  * Find the console that matches the supplied mswindows window handle
  */
-static Lisp_Object
+Lisp_Object
 mswindows_find_console (HWND hwnd)
 {
   Lisp_Object concons;
@@ -817,19 +897,7 @@
 static Lisp_Object
 mswindows_find_frame (HWND hwnd)
 {
-  Lisp_Object frmcons, devcons, concons;
-
-  FRAME_LOOP_NO_BREAK (frmcons, devcons, concons)
-    {
-      struct frame *f;
-      Lisp_Object frame = XCAR (frmcons);
-      f = XFRAME (frame);
-      if (FRAME_TYPE_P(f, mswindows))	    /* Might be a stream-type frame */
-	if (FRAME_MSWINDOWS_HANDLE(f)==hwnd)
-	  return frame;
-    }
-  assert(0);  /* XXX Can't happen! we only get messages for our windows */
-  return Qnil;
+  return (Lisp_Object) GetWindowLong (hwnd, XWL_FRAMEOBJ);
 }
 
 
--- a/src/nt.c	Mon Aug 13 10:10:03 2007 +0200
+++ b/src/nt.c	Mon Aug 13 10:10:54 2007 +0200
@@ -33,10 +33,12 @@
 #include <fcntl.h>
 #include <ctype.h>
 #include <signal.h>
-#include <sys/time.h>
 
 /* must include CRT headers *before* config.h */
 #include "config.h"
+#include "systime.h"
+#include "syssignal.h"
+
 #undef access
 #undef chdir
 #undef chmod
@@ -66,6 +68,7 @@
 #include <pwd.h>
 
 #include <windows.h>
+#include <mmsystem.h>
 
 #ifdef HAVE_SOCKETS	/* TCP connection support, if kernel can do it */
 #include <sys/socket.h>
@@ -555,28 +558,11 @@
 /* Routines that are no-ops on NT but are defined to get Emacs to compile.  */
 
 int 
-sigsetmask (int signal_mask) 
-{ 
-  return 0;
-}
-
-int 
-sigblock (int sig) 
-{ 
-  return 0;
-}
-
-int 
 setpgrp (int pid, int gid) 
 { 
   return 0;
 }
 
-int 
-alarm (int seconds) 
-{ 
-  return 0;
-}
 
 int 
 unrequest_sigio (void) 
@@ -2804,4 +2790,226 @@
 }
 #endif
 
+/*--------------------------------------------------------------------*/
+/* Signal support                                                     */
+/*--------------------------------------------------------------------*/
+
+/* We need MS-defined signal and raise here */
+#undef signal
+#undef raise
+
+#define sigmask(nsig) (1U << nsig)
+
+/* We can support as many signals as fit into word */
+#define SIG_MAX 32
+
+/* Signal handlers. Initial value = 0 = SIG_DFL */
+static void (__cdecl *signal_handlers[SIG_MAX])(int) = {0};
+
+/* Signal block mask: bit set to 1 means blocked */
+unsigned signal_block_mask = 0;
+
+/* Signal pending mask: bit set to 1 means sig is pending */
+unsigned signal_pending_mask = 0;
+
+msw_sighandler msw_sigset (int nsig, msw_sighandler handler)
+{
+  /* We delegate some signals to the system function */
+  if (nsig == SIGFPE || nsig == SIGABRT || nsig == SIGINT)
+    {
+      signal (nsig, handler);
+      return;
+    }
+
+  if (nsig < 0 || nsig > SIG_MAX)
+    {
+      errno = EINVAL;
+      return;
+    }
+
+  /* Store handler ptr */
+  signal_handlers[nsig] = handler;
+}
+  
+int msw_sighold (int nsig)
+{
+  if (nsig < 0 || nsig > SIG_MAX)
+    return errno = EINVAL;
+
+  signal_block_mask |= sigmask(nsig);
+  return 0;
+}
+
+int msw_sigrelse (int nsig)
+{
+  if (nsig < 0 || nsig > SIG_MAX)
+    return errno = EINVAL;
+
+  signal_block_mask &= ~sigmask(nsig);
+
+  if (signal_pending_mask & sigmask(nsig))
+    msw_raise (nsig);
+
+  return 0;
+}
+
+int msw_sigpause (int nsig)
+{
+  /* This is currently not called, because the only
+     call to sigpause inside XEmacs is with SIGCHLD
+     parameter. Just in case, we put an assert here,
+     so anyone who will add a call to sigpause will
+     be surprised (or surprise someone else...) */
+  assert (0);
+  return 0;
+}
+
+int msw_raise (int nsig)
+{
+  /* We delegate some raises to the system routine */
+  if (nsig == SIGFPE || nsig == SIGABRT || nsig == SIGINT)
+    return raise (nsig);
+
+  if (nsig < 0 || nsig > SIG_MAX)
+    return errno = EINVAL;
+
+  /* If the signal is blocked, remember to issue later */
+  if (signal_block_mask & sigmask(nsig))
+    {
+      signal_pending_mask |= sigmask(nsig);
+      return 0;
+    }
+
+  if (signal_handlers[nsig] == SIG_IGN)
+    return 0;
+
+  if (signal_handlers[nsig] != SIG_DFL)
+    {
+      (*signal_handlers[nsig])(nsig);
+      return 0;
+    }
+
+  /* Default signal actions */
+  if (nsig == SIGALRM || nsig == SIGPROF)
+    exit (3);
+
+  /* Other signals are ignored by default */
+}
+
+/*--------------------------------------------------------------------*/
+/* Async timers                                                       */
+/*--------------------------------------------------------------------*/
+
+/* We emulate two timers, one for SIGALRM, another for SIGPROF.
+
+   itimerproc() function has an implementation limitation: it does
+   not allow to set *both* interval and period. If an attempt is
+   made to set both, and then they are unequal, the function
+   asserts.
+
+   Minimum timer resolution on Win32 systems varies, and is greater
+   than or equal than 1 ms. The resolution is always wrapped not to
+   attempt to get below the system defined limit.
+   */
+
+/* Timer precision, denominator of one fraction: for 100 ms
+   interval, request 10 ms precision
+   */
+const int timer_prec = 10;
+
+/* Last itimevals, as set by calls to setitimer */
+static struct itimerval it_alarm;
+static struct itimerval it_prof;
+
+/* Timer IDs as returned by MM */
+MMRESULT tid_alarm = 0;
+MMRESULT tid_prof = 0;
+
+static void CALLBACK timer_proc (UINT uID, UINT uMsg, DWORD dwUser,
+				 DWORD dw1, DWORD dw2)
+{
+  /* Just raise a signal indicated by dwUser parameter */
+  msw_raise (dwUser);
+}
+
+/* Divide time in ms specified by IT by DENOM. Return 1 ms
+   if division results in zero */
+static UINT period (const struct itimerval* it, UINT denom)
+{
+  static TIMECAPS time_caps;
+
+  UINT res;
+  const struct timeval* tv = 
+    (it->it_value.tv_sec == 0 && it->it_value.tv_usec == 0)
+    ? &it->it_interval : &it->it_value;
+  
+  /* Zero means stop timer */
+  if (tv->tv_sec == 0 && tv->tv_usec == 0)
+    return 0;
+  
+  /* Conver to ms and divide by denom */
+  res = (tv->tv_sec * 1000 + (tv->tv_usec + 500) / 1000) / denom;
+  
+  /* Converge to minimum timer resolution */
+  if (time_caps.wPeriodMin == 0)
+      timeGetDevCaps (&time_caps, sizeof(time_caps));
+
+  if (res < time_caps.wPeriodMin)
+    res = time_caps.wPeriodMin;
+
+  return res;
+}
+
+static int setitimer_helper (const struct itimerval* itnew,
+			     struct itimerval* itold, struct itimerval* itcurrent,
+			     MMRESULT* tid, DWORD sigkind)
+{
+  UINT delay, resolution, event_type;
+
+  /* First stop the old timer */
+  if (*tid)
+    {
+      timeKillEvent (*tid);
+      timeEndPeriod (period (itcurrent, timer_prec));
+      *tid = 0;
+    }
+
+  /* Return old itimerval if requested */
+  if (itold)
+    *itold = *itcurrent;
+
+  *itcurrent = *itnew;
+
+  /* Determine if to start new timer */
+  delay = period (itnew, 1);
+  if (delay)
+    {
+      resolution = period (itnew, timer_prec);
+      event_type = (itnew->it_value.tv_sec == 0 && itnew->it_value.tv_usec == 0)
+	? TIME_ONESHOT : TIME_PERIODIC;
+      timeBeginPeriod (resolution);
+      *tid = timeSetEvent (delay, resolution, timer_proc, sigkind, event_type);
+    }
+
+  return !delay || *tid;
+}
+ 
+int setitimer (int kind, const struct itimerval* itnew,
+	       struct itimerval* itold)
+{
+  /* In this version, both interval and value are allowed
+     only if they are equal. */
+  assert ((itnew->it_value.tv_sec == 0 && itnew->it_value.tv_usec == 0)
+	  || (itnew->it_interval.tv_sec == 0 && itnew->it_interval.tv_usec == 0)
+	  || (itnew->it_value.tv_sec == itnew->it_interval.tv_sec &&
+	      itnew->it_value.tv_usec == itnew->it_interval.tv_usec));
+
+  if (kind == ITIMER_REAL)
+    return setitimer_helper (itnew, itold, &it_alarm, &tid_alarm, SIGALRM);
+  else if (kind == ITIMER_PROF)
+    return setitimer_helper (itnew, itold, &it_prof, &tid_prof, SIGPROF);
+  else
+    return errno = EINVAL;
+}
+
 /* end of nt.c */
--- a/src/ntproc.c	Mon Aug 13 10:10:03 2007 +0200
+++ b/src/ntproc.c	Mon Aug 13 10:10:54 2007 +0200
@@ -45,6 +45,7 @@
 #include "nt.h"
 #include "ntheap.h" /* From 19.34.6 */
 #include "systime.h"
+#include "syssignal.h"
 #include "syswait.h"
 #include "process.h"
 /*#include "w32term.h"*/ /* From 19.34.6: sync in ? --marcpa */
@@ -105,26 +106,7 @@
 }
 #endif
 
-typedef void (_CALLBACK_ *signal_handler)(int);
-
-/* Signal handlers...SIG_DFL == 0 so this is initialized correctly.  */
-static signal_handler sig_handlers[NSIG];
-
-/* Fake signal implementation to record the SIGCHLD handler.  */
-signal_handler 
-sys_signal (int sig, signal_handler handler)
-{
-  signal_handler old;
-  
-  if (sig != SIGCHLD)
-    {
-      errno = EINVAL;
-      return SIG_ERR;
-    }
-  old = sig_handlers[sig];
-  sig_handlers[sig] = handler;
-  return old;
-}
+/* sys_signal moved to nt.c. It's now called msw_signal... */
 
 /* Defined in <process.h> which conflicts with the local copy */
 #define _P_NOWAIT 1
@@ -1205,18 +1187,17 @@
 	  if (cp->fd >= 0 && (fd_info[cp->fd].flags & FILE_AT_EOF) == 0)
 	    fd_info[cp->fd].flags |= FILE_SEND_SIGCHLD;
 	  /* SIG_DFL for SIGCHLD is ignore */
-	  else if (sig_handlers[SIGCHLD] != SIG_DFL &&
-		      sig_handlers[SIGCHLD] != SIG_IGN)
-		    {
+	  else 
+	    {
 #ifdef FULL_DEBUG
-		      DebPrint (("select calling SIGCHLD handler for pid %d\n",
-				 cp->pid));
+	      DebPrint (("select is raising SIGCHLD handler for pid %d\n",
+			 cp->pid));
 #endif
-		      dead_child = cp;
-		      sig_handlers[SIGCHLD] (SIGCHLD);
-		      dead_child = NULL;
-		    }
-		}
+	      dead_child = cp;
+	      msw_raise (SIGCHLD);
+	      dead_child = NULL;
+	    }
+	}
       else if (fdindex[active] == 0)
 	{
 	  /* Keyboard input available */
--- a/src/print.c	Mon Aug 13 10:10:03 2007 +0200
+++ b/src/print.c	Mon Aug 13 10:10:54 2007 +0200
@@ -417,7 +417,7 @@
   Fset_buffer (Fget_buffer_create (build_string (bufname)));
 
   current_buffer->read_only = Qnil;
-  Ferase_buffer (Fcurrent_buffer ());
+  Ferase_buffer (Qnil);
 
   XSETBUFFER (buf, current_buffer);
   specbind (Qstandard_output, buf);
--- a/src/process.c	Mon Aug 13 10:10:03 2007 +0200
+++ b/src/process.c	Mon Aug 13 10:10:54 2007 +0200
@@ -2360,7 +2360,9 @@
 #else
   sigchld_happened++;
 #endif
+#ifdef HAVE_UNIXOID_EVENT_LOOP
   signal_fake_event ();
+#endif
   /* WARNING - must come after wait3() for USG systems */
   EMACS_REESTABLISH_SIGNAL (signo, sigchld_handler);
   SIGRETURN;
--- a/src/pure.c	Mon Aug 13 10:10:03 2007 +0200
+++ b/src/pure.c	Mon Aug 13 10:10:54 2007 +0200
@@ -23,13 +23,7 @@
 
 /* Moved from puresize.h to here so alloc.c does not get recompiled */
 
-/* Current build process on NT does not generate a puresize-adjust.h */
-/* file. --marcpa */
-#ifdef WINDOWSNT
-# define PURESIZE_ADJUSTMENT 1000000
-#else
 # include <puresize-adjust.h>
-#endif
 #define PURESIZE ((RAW_PURESIZE) + (PURESIZE_ADJUSTMENT))
 
 long int
--- a/src/redisplay-msw.c	Mon Aug 13 10:10:03 2007 +0200
+++ b/src/redisplay-msw.c	Mon Aug 13 10:10:54 2007 +0200
@@ -713,15 +713,10 @@
 static void
 mswindows_ring_bell (struct device *d, int volume, int pitch, int duration)
 {
-  /* XXX FIXME: I'm guessing pitch=Hz and duration is milliseconds */
-
-  if ((pitch|duration) == -1)	/* Pitch and/or duration may be bogus */
-    MessageBeep(-1);		/* Default system sound via speaker */
-  else
-    Beep(pitch, duration);
+  /* Beep does not work at all, anyways! -kkm */
+  MessageBeep (MB_OK);
 }
 
-
 /*****************************************************************************
  mswindows_output_display_block
 
--- a/src/redisplay.c	Mon Aug 13 10:10:03 2007 +0200
+++ b/src/redisplay.c	Mon Aug 13 10:10:54 2007 +0200
@@ -5565,14 +5565,12 @@
   return 0;
 }
 
-#ifndef WINDOWSNT
 static Lisp_Object
 restore_profiling_redisplay_flag (Lisp_Object val)
 {
   profiling_redisplay_flag = XINT (val);
   return Qnil;
 }
-#endif /* WINDOWSNT */
 
 /* Ensure that all windows on all frames on all devices are displaying
    the current contents of their respective buffers. */
@@ -5584,14 +5582,12 @@
   int size_change_failed = 0;
   int count = specpdl_depth ();
 
-#ifndef WINDOWSNT
   if (profiling_active)
     {
       record_unwind_protect (restore_profiling_redisplay_flag,
 			     make_int (profiling_redisplay_flag));
       profiling_redisplay_flag = 1;
     }
-#endif /* WINDOWSNT */
 
   if (asynch_device_change_pending)
     handle_asynch_device_change ();
--- a/src/s/windowsnt.h	Mon Aug 13 10:10:03 2007 +0200
+++ b/src/s/windowsnt.h	Mon Aug 13 10:10:54 2007 +0200
@@ -28,6 +28,11 @@
 #define DOS_NT 	/* MSDOS or WINDOWSNT */
 #endif
 
+/* In case non-Microsoft compiler is used, we fake _MSC_VER */
+#ifndef _MSC_VER
+#define _MSC_VER  1
+#endif
+
 typedef unsigned short mode_t;
 typedef long ptrdiff_t;
 typedef int pid_t;
@@ -223,7 +228,6 @@
 #define spawnve sys_spawnve
 #define wait    sys_wait
 #define kill    sys_kill
-#define signal  sys_signal
 
 #define select  sys_select
 
@@ -258,6 +262,17 @@
 #define abort	win32_abort
 #endif
 
+/* Setitimer is emulated */
+#define HAVE_SETITIMER
+
+/* We now have emulation for some signals */
+#define HAVE_SIGHOLD
+#define sigset(s,h) msw_sigset(s,h)
+#define sighold(s) msw_sighold(s)
+#define sigrelse(s) msw_sigrelse(s)
+#define sigpause(s) msw_sigpause(s)
+#define signal sigset
+
 /* Defines that we need that aren't in the standard signal.h  */
 #define SIGHUP  1               /* Hang up */
 #define SIGQUIT 3               /* Quit process */
@@ -266,6 +281,7 @@
 #define SIGPIPE 13              /* Write on pipe with no readers */
 #define SIGALRM 14              /* Alarm */
 #define SIGCHLD 18              /* Death of child */
+#define SIGPROF 29		/* Profiling timer exp */
 
 /* For integration with MSDOS support.  */
 #define getdisk()               (_getdrive () - 1)
--- a/src/signal.c	Mon Aug 13 10:10:03 2007 +0200
+++ b/src/signal.c	Mon Aug 13 10:10:54 2007 +0200
@@ -180,6 +180,9 @@
 	 it needs to stay the way it is. */
       quit_check_signal_happened = 1;
 
+#ifdef _WIN32
+      can_break_system_calls = 0;
+#else
       /* can_break_system_calls is set when we want to break out of
 	 non-interruptible system calls. */
       if (can_break_system_calls)
@@ -192,6 +195,7 @@
 	  EMACS_REESTABLISH_SIGNAL (signo, alarm_signal);
 	  LONGJMP (break_system_call_jump, 0);
 	}
+#endif
 
       EMACS_REESTABLISH_SIGNAL (signo, alarm_signal);
       SIGRETURN;
@@ -207,7 +211,10 @@
      went off.  Rather than put the code in to compute this
      specially, we just set this flag.  Should fix this. */
   quit_check_signal_happened = 1;
+
+#ifdef HAVE_UNIXOID_EVENT_LOOP
   signal_fake_event ();
+#endif
 
   EMACS_REESTABLISH_SIGNAL (signo, alarm_signal);
   SIGRETURN;
@@ -438,7 +445,9 @@
       /* Else request quit when it's safe */
       Vquit_flag = Qt;
       sigint_happened = 1;
+#ifdef HAVE_UNIXOID_EVENT_LOOP
       signal_fake_event ();
+#endif
     }
   errno = old_errno;
   SIGRETURN;
--- a/src/symsinit.h	Mon Aug 13 10:10:03 2007 +0200
+++ b/src/symsinit.h	Mon Aug 13 10:10:54 2007 +0200
@@ -166,6 +166,7 @@
 void structure_type_create_chartab (void);
 void structure_type_create_faces (void);
 void structure_type_create_rangetab (void);
+void structure_type_create_hashtable (void);
 
 /* Initialize the image instantiator types (dump-time only). */
 
--- a/src/syssignal.h	Mon Aug 13 10:10:03 2007 +0200
+++ b/src/syssignal.h	Mon Aug 13 10:10:54 2007 +0200
@@ -228,4 +228,14 @@
 extern SIGTYPE memory_warning_signal (int sig);
 #endif
 
+#ifdef _WIN32
+/* Prototypes for signal functions, see nt.c */
+typedef void (__cdecl *msw_sighandler) (int);
+msw_sighandler msw_sigset (int sig, msw_sighandler handler);
+int msw_sighold (int nsig);
+int msw_sigrelse (int nsig);
+int msw_sigpause (int nsig);
+int msw_raise (int nsig);
+#endif /* _WIN32 */
+
 #endif /* _XEMACS_SYSSIGNAL_H_ */
--- a/src/systime.h	Mon Aug 13 10:10:03 2007 +0200
+++ b/src/systime.h	Mon Aug 13 10:10:54 2007 +0200
@@ -224,4 +224,22 @@
 extern void get_process_times (double *user_time, double *system_time,
 			       double *real_time);
 
+#ifdef _WIN32
+
+/* setitimer emulation for Win32 (see nt.c) */
+
+struct itimerval
+{
+  struct timeval it_value;
+  struct timeval it_interval;
+};
+
+int setitimer (int kind, const struct itimerval* itnew,
+	       struct itimerval* itold);
+
+#define ITIMER_REAL 1
+#define ITIMER_PROF 2
+
+#endif /* _WIN32 */
+
 #endif /* _XEMACS_SYSTIME_H_ */
--- a/src/undo.c	Mon Aug 13 10:10:03 2007 +0200
+++ b/src/undo.c	Mon Aug 13 10:10:54 2007 +0200
@@ -431,7 +431,8 @@
 #ifdef CLASH_DETECTION
 		  Funlock_buffer ();
 #endif /* CLASH_DETECTION */
-		  Fset_buffer_modified_p (Qnil, Fcurrent_buffer ()); /* may GC under ENERGIZE */
+		  /* may GC under ENERGIZE: */
+		  Fset_buffer_modified_p (Qnil, Qnil);
 		}
 	      else if (EXTENTP (car))
 		{
@@ -473,8 +474,8 @@
 		    error ("Changes to be undone are outside visible portion of buffer");
 		  /* Set point first thing, so that undoing this undo
 		     does not send point back to where it is now.  */
-		  Fgoto_char (car, Fcurrent_buffer ());
-		  Fdelete_region (car, cdr, Fcurrent_buffer ());
+		  Fgoto_char (car, Qnil);
+		  Fdelete_region (car, cdr, Qnil);
 		}
 	      else if (STRINGP (car) && INTP (cdr))
 		{
--- a/src/window.c	Mon Aug 13 10:10:03 2007 +0200
+++ b/src/window.c	Mon Aug 13 10:10:54 2007 +0200
@@ -1493,7 +1493,7 @@
 
   CHECK_INT_COERCE_MARKER (pos);
   if (w == XWINDOW (Fselected_window (Qnil)))
-    Fgoto_char (pos, Fcurrent_buffer ());
+    Fgoto_char (pos, Qnil);
   else
     set_marker_restricted (w->pointm[CURRENT_DISP], pos, w->buffer);
 
@@ -4901,7 +4901,7 @@
 		     when the window configuration was recorded.  */
 		  if (!EQ (p->buffer, new_current_buffer) &&
 		      XBUFFER (p->buffer) == current_buffer)
-		    Fgoto_char (w->pointm[CURRENT_DISP], Fcurrent_buffer ());
+		    Fgoto_char (w->pointm[CURRENT_DISP], Qnil);
 		}
 	      else if (NILP (w->buffer) ||
 		       !BUFFER_LIVE_P (XBUFFER (w->buffer)))
--- a/version.sh	Mon Aug 13 10:10:03 2007 +0200
+++ b/version.sh	Mon Aug 13 10:10:54 2007 +0200
@@ -1,5 +1,5 @@
 #!/bin/sh
 emacs_major_version=20
 emacs_minor_version=4
-emacs_beta_version=9
-xemacs_codename="Australian Goat"
+emacs_beta_version=10
+xemacs_codename="Barbari"