changeset 90208:890cc78a5a24

Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-74 Merge from emacs--cvs-trunk--0 Patches applied: * emacs--cvs-trunk--0 (patch 493-503) - Update from CVS - Update from CVS: lisp/startup.el (command-line): Fix typo. - Merge from gnus--rel--5.10 * gnus--rel--5.10 (patch 95-98) - Update from CVS
author Miles Bader <miles@gnu.org>
date Fri, 29 Jul 2005 01:54:54 +0000
parents 43ea22612328 (current diff) 89073e52939c (diff)
children 182221fb0f2c
files ChangeLog Makefile.in admin/FOR-RELEASE configure configure.in etc/ChangeLog etc/NEWS lib-src/ChangeLog lib-src/Makefile.in lib-src/getopt.c lib-src/getopt.h lib-src/getopt1.c lib-src/makefile.w32-in lisp/ChangeLog lisp/bookmark.el lisp/dired.el lisp/emacs-lisp/re-builder.el lisp/gnus/ChangeLog lisp/gnus/gnus-art.el lisp/gnus/gnus-util.el lisp/gnus/rfc2231.el lisp/image-file.el lisp/isearch.el lisp/man.el lisp/net/ange-ftp.el lisp/progmodes/compile.el lisp/progmodes/gdb-ui.el lisp/progmodes/grep.el lisp/ps-bdf.el lisp/recentf.el lisp/simple.el lisp/smerge-mode.el lisp/startup.el lisp/tempo.el lisp/term/apollo.el lisp/term/bobcat.el lisp/term/iris-ansi.el lisp/term/linux.el lisp/term/news.el lisp/term/rxvt.el lisp/term/sun.el lisp/term/tvi970.el lisp/term/vt100.el lisp/term/vt102.el lisp/term/vt125.el lisp/term/vt200.el lisp/term/vt201.el lisp/term/vt220.el lisp/term/vt240.el lisp/term/vt300.el lisp/term/vt320.el lisp/term/vt400.el lisp/term/vt420.el lisp/term/wyse50.el lisp/term/xterm.el lisp/tooltip.el lispref/ChangeLog lispref/internals.texi lispref/loading.texi lispref/modes.texi make-dist man/ChangeLog man/files.texi man/gnus.texi nt/ChangeLog nt/configure.bat nt/inc/gettext.h src/ChangeLog src/alloc.c src/bytecode.c src/config.in src/eval.c src/insdel.c src/keyboard.c src/lisp.h src/mac.c src/macfns.c src/macmenu.c src/s/cygwin.h src/w32fns.c src/w32menu.c src/w32term.c
diffstat 93 files changed, 3356 insertions(+), 2214 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Jul 26 12:03:19 2005 +0000
+++ b/ChangeLog	Fri Jul 29 01:54:54 2005 +0000
@@ -1,3 +1,19 @@
+2005-07-28  Juanma Barranquero  <lekktu@gmail.com>
+
+	* .cvsignore: Add `data' and `site-lisp' (for in-place installs).
+
+2005-07-26  Paul Eggert  <eggert@cs.ucla.edu>
+
+	Merge gnulib getopt implementation into Emacs.
+
+	* Makefile.in (AUTOCONF_INPUTS): New macro.
+	($(srcdir)/configure, $(srcdir)/src/stamp-h.in): Depend on it,
+	so that these files also depend on m4/getopt.m4.
+	* configure.in: Configure getopt by including m4/getopt.m4,
+	and configuring a getopt replacement if necessary.
+	* make-dist: Add m4 subdirectory.  Unlink lib-src/getopt.h.
+	* m4/getopt.m4: New file.
+
 2005-07-06  Lute Kamstra  <lute@gnu.org>
 
 	* configure.in: Fix capitalization.
--- a/Makefile.in	Tue Jul 26 12:03:19 2005 +0000
+++ b/Makefile.in	Fri Jul 29 01:54:54 2005 +0000
@@ -2,7 +2,7 @@
 # DIST: make most of the changes to this file you might want, so try
 # DIST: that first.
 
-# Copyright (C) 1992,93,94,95,96,97,98,1999,2000,01,02,03,2004
+# Copyright (C) 1992,93,94,95,96,97,98,1999,2000,01,02,03,04,2005
 #   Free Software Foundation, Inc.
 
 # This file is part of GNU Emacs.
@@ -302,12 +302,14 @@
 config.status: ${srcdir}/configure
 	./config.status --recheck
 
-${srcdir}/configure: @MAINT@ ${srcdir}/configure.in
+AUTOCONF_INPUTS = @MAINT@ $(srcdir)/configure.in $(srcdir)/m4/getopt.m4
+
+$(srcdir)/configure: $(AUTOCONF_INPUTS)
 	cd ${srcdir} && autoconf
 
 $(srcdir)/src/config.in: $(srcdir)/src/stamp-h.in
 	@true
-$(srcdir)/src/stamp-h.in: @MAINT@ ${srcdir}/configure.in
+$(srcdir)/src/stamp-h.in: $(AUTOCONF_INPUTS)
 	cd ${srcdir} && autoheader
 	rm -f $(srcdir)/src/stamp-h.in
 	echo timestamp > $(srcdir)/src/stamp-h.in
--- a/admin/FOR-RELEASE	Tue Jul 26 12:03:19 2005 +0000
+++ b/admin/FOR-RELEASE	Fri Jul 29 01:54:54 2005 +0000
@@ -79,32 +79,6 @@
 
 The class A seems to be missing.
 
-** Ange-ftp should ignore irrelevant IPv6 errors:
-
-Message-Id: <4121-Tue23Mar2004165249+0100-piet@cs.uu.nl>
-From: "Piet van Oostrum" <piet@cs.uu.nl>
-To: emacs-pretest-bug@gnu.org
-Subject: Ange-ftp can't deal with IPV6/IPV4 fallback
-
-Symptoms:
-
-C-x C-f /ftp.nluug.nl:/
-
-The problem is that the DNS first gives an IPV6 address. However our
-router doesn't do IPV6. Ftp then falls back to IPV4:
-
-ftp> open ftp.nluug.nl
-Trying 2001:610:1:80aa:192:87:102:36...
-ftp: connect to address 2001:610:1:80aa:192:87:102:36: No route to host
-Trying 192.87.102.36...
-Connected to ftp.nluug.nl.
-
-Ange-ftp chokes on the `No route to host' message and doesn't look any
-further.
-
-I think in the near future we will see more of this problem, so it might be
-time to make anfe-ftp more intelligent.
-
 * DOCUMENTATION
 
 ** Document Custom Themes.
--- a/configure	Tue Jul 26 12:03:19 2005 +0000
+++ b/configure	Fri Jul 29 01:54:54 2005 +0000
@@ -310,7 +310,7 @@
 # include <unistd.h>
 #endif"
 
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS MAINT build build_cpu build_vendor build_os host host_cpu host_vendor host_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT LN_S CPP INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA RANLIB ac_ct_RANLIB INSTALL_INFO EGREP LIBSOUND SET_MAKE PKG_CONFIG GTK_CFLAGS GTK_LIBS ALLOCA liblockfile LIBOBJS NEED_SETGID KMEM_GROUP GETLOADAVG_LIBS version configuration canonical srcdir lispdir locallisppath lisppath x_default_search_path etcdir archlibdir docdir bitmapdir gamedir gameuser c_switch_system c_switch_machine LD_SWITCH_X_SITE LD_SWITCH_X_SITE_AUX C_SWITCH_X_SITE X_TOOLKIT_TYPE machfile opsysfile carbon_appdir LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS MAINT build build_cpu build_vendor build_os host host_cpu host_vendor host_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT LN_S CPP INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA RANLIB ac_ct_RANLIB INSTALL_INFO EGREP LIBSOUND SET_MAKE PKG_CONFIG GTK_CFLAGS GTK_LIBS ALLOCA liblockfile LIBOBJS NEED_SETGID KMEM_GROUP GETLOADAVG_LIBS GETOPT_H GETOPTOBJS version configuration canonical srcdir lispdir locallisppath lisppath x_default_search_path etcdir archlibdir docdir bitmapdir gamedir gameuser c_switch_system c_switch_machine LD_SWITCH_X_SITE LD_SWITCH_X_SITE_AUX C_SWITCH_X_SITE X_TOOLKIT_TYPE machfile opsysfile carbon_appdir LTLIBOBJS'
 ac_subst_files=''
 
 # Initialize some variables set by options.
@@ -16828,6 +16828,490 @@
 fi
 
 
+# Configure getopt.
+# getopt.m4 serial 10
+
+# The getopt module assume you want GNU getopt, with getopt_long etc,
+# rather than vanilla POSIX getopt.  This means your your code should
+# always include <getopt.h> for the getopt prototypes.
+
+
+
+
+
+
+
+
+
+
+
+# Prerequisites of lib/getopt*.
+
+
+
+  GETOPT_H=
+
+for ac_header in getopt.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+else
+  # Is the header compilable?
+echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_header_compiler=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6
+
+# Is the header present?
+echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+    ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+rm -f conftest.err conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    (
+      cat <<\_ASBOX
+## ------------------------------------------ ##
+## Report this to the AC_PACKAGE_NAME lists.  ##
+## ------------------------------------------ ##
+_ASBOX
+    ) |
+      sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+else
+  GETOPT_H=getopt.h
+fi
+
+done
+
+  if test -z "$GETOPT_H"; then
+
+for ac_func in getopt_long_only
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
+if eval "test \"\${$as_ac_var+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+char (*f) () = $ac_func;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+int
+main ()
+{
+return f != $ac_func;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  eval "$as_ac_var=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+eval "$as_ac_var=no"
+fi
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+else
+  GETOPT_H=getopt.h
+fi
+done
+
+  fi
+
+      if test -z "$GETOPT_H"; then
+    echo "$as_me:$LINENO: checking whether optreset is declared" >&5
+echo $ECHO_N "checking whether optreset is declared... $ECHO_C" >&6
+if test "${ac_cv_have_decl_optreset+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <getopt.h>
+
+int
+main ()
+{
+#ifndef optreset
+  char *p = (char *) optreset;
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_have_decl_optreset=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_have_decl_optreset=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_have_decl_optreset" >&5
+echo "${ECHO_T}$ac_cv_have_decl_optreset" >&6
+if test $ac_cv_have_decl_optreset = yes; then
+  GETOPT_H=getopt.h
+fi
+
+  fi
+
+      if test -z "$GETOPT_H"; then
+    echo "$as_me:$LINENO: checking for working GNU getopt function" >&5
+echo $ECHO_N "checking for working GNU getopt function... $ECHO_C" >&6
+if test "${gl_cv_func_gnu_getopt+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test "$cross_compiling" = yes; then
+  	 	 	 echo "$as_me:$LINENO: checking whether getopt_clip is declared" >&5
+echo $ECHO_N "checking whether getopt_clip is declared... $ECHO_C" >&6
+if test "${ac_cv_have_decl_getopt_clip+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <getopt.h>
+
+int
+main ()
+{
+#ifndef getopt_clip
+  char *p = (char *) getopt_clip;
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_have_decl_getopt_clip=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_have_decl_getopt_clip=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_have_decl_getopt_clip" >&5
+echo "${ECHO_T}$ac_cv_have_decl_getopt_clip" >&6
+if test $ac_cv_have_decl_getopt_clip = yes; then
+  gl_cv_func_gnu_getopt=no
+else
+  gl_cv_func_gnu_getopt=yes
+fi
+
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <getopt.h>
+int
+main ()
+{
+
+	     char *myargv[3];
+	     myargv[0] = "conftest";
+	     myargv[1] = "-+";
+	     myargv[2] = 0;
+	     return getopt (2, myargv, "+a") != '?';
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  gl_cv_func_gnu_getopt=yes
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+gl_cv_func_gnu_getopt=no
+fi
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+fi
+echo "$as_me:$LINENO: result: $gl_cv_func_gnu_getopt" >&5
+echo "${ECHO_T}$gl_cv_func_gnu_getopt" >&6
+    if test "$gl_cv_func_gnu_getopt" = "no"; then
+      GETOPT_H=getopt.h
+    fi
+  fi
+
+
+
+  if test -n "$GETOPT_H"; then
+
+
+  GETOPT_H=getopt.h
+
+cat >>confdefs.h <<\_ACEOF
+#define __GETOPT_PREFIX rpl_
+_ACEOF
+
+
+
+  :
+  GETOPTOBJS='getopt.o getopt1.o'
+
+fi
+
+
+
+
 echo "$as_me:$LINENO: checking whether getpgrp requires zero arguments" >&5
 echo $ECHO_N "checking whether getpgrp requires zero arguments... $ECHO_C" >&6
 if test "${ac_cv_func_getpgrp_void+set}" = set; then
@@ -22646,6 +23130,8 @@
 s,@NEED_SETGID@,$NEED_SETGID,;t t
 s,@KMEM_GROUP@,$KMEM_GROUP,;t t
 s,@GETLOADAVG_LIBS@,$GETLOADAVG_LIBS,;t t
+s,@GETOPT_H@,$GETOPT_H,;t t
+s,@GETOPTOBJS@,$GETOPTOBJS,;t t
 s,@version@,$version,;t t
 s,@configuration@,$configuration,;t t
 s,@canonical@,$canonical,;t t
--- a/configure.in	Tue Jul 26 12:03:19 2005 +0000
+++ b/configure.in	Fri Jul 29 01:54:54 2005 +0000
@@ -2353,7 +2353,7 @@
   CFLAGS="$CFLAGS -framework Carbon"
   AC_CHECK_FUNC(CancelMenuTracking, have_cmt=yes, have_cmt=no)
   if test "$have_cmt" = yes; then
-    AC_DEFINE(HAVE_CANCELMENUTRACKING, 1, 
+    AC_DEFINE(HAVE_CANCELMENUTRACKING, 1,
               [Define to 1 if CancelMenuTracking is available (Mac OSX).])
   fi
   CFLAGS="$tmp_CFLAGS"
@@ -2434,6 +2434,15 @@
 
 AC_FUNC_FSEEKO
 
+# Configure getopt.
+m4_include([m4/getopt.m4])
+gl_GETOPT_IFELSE([
+  gl_GETOPT_SUBSTITUTE_HEADER
+  gl_PREREQ_GETOPT
+  GETOPTOBJS='getopt.o getopt1.o'
+])
+AC_SUBST(GETOPTOBJS)
+
 AC_FUNC_GETPGRP
 
 AC_FUNC_STRFTIME
--- a/etc/.cvsignore	Tue Jul 26 12:03:19 2005 +0000
+++ b/etc/.cvsignore	Fri Jul 29 01:54:54 2005 +0000
@@ -1,4 +1,5 @@
 fns-*
+icons
 *.ps
 *.log
 *.dvi
--- a/etc/ChangeLog	Tue Jul 26 12:03:19 2005 +0000
+++ b/etc/ChangeLog	Fri Jul 29 01:54:54 2005 +0000
@@ -1,10 +1,14 @@
+2005-07-28  Juanma Barranquero  <lekktu@gmail.com>
+
+	* .cvsignore: Add `icons' (for in-place installs).
+
 2005-07-19  Juri Linkov  <juri@jurta.org>
 
 	* grep.txt: New file.
 
 2005-07-19  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
 
-	* PROBLEMS (Fedora Core 4 GNU/Linux: Segfault during dumping): 
+	* PROBLEMS (Fedora Core 4 GNU/Linux: Segfault during dumping):
 	-R comes after i386 in setarch command.
 
 2005-07-12  Juri Linkov  <juri@jurta.org>
--- a/etc/NEWS	Tue Jul 26 12:03:19 2005 +0000
+++ b/etc/NEWS	Fri Jul 29 01:54:54 2005 +0000
@@ -2258,7 +2258,7 @@
 
 ** In sh-script, a continuation line is only indented if the backslash was
 preceded by a SPC or a TAB.
-	
+
 ---
 ** Perl mode has a new variable `perl-indent-continued-arguments'.
 
@@ -5105,8 +5105,8 @@
 
 +++
 *** New variable `gc-cons-percentage' automatically grows the GC cons threshold
-as the heap sizxe increases.
-	
+as the heap size increases.
+
 +++
 *** New variables `gc-elapsed' and `gcs-done' provide extra information
 on garbage collection.
--- a/lib-src/.cvsignore	Tue Jul 26 12:03:19 2005 +0000
+++ b/lib-src/.cvsignore	Fri Jul 29 01:54:54 2005 +0000
@@ -1,7 +1,7 @@
 DOC
 Makefile.c
 b2m
-ctags
+ctags*
 cvtmail
 digest-doc
 ebrowse
@@ -9,8 +9,7 @@
 emacsserver
 etags
 fakemail
-fns-*
-fns.el
+getopt.h
 hexl
 make-docfile
 movemail
--- a/lib-src/ChangeLog	Tue Jul 26 12:03:19 2005 +0000
+++ b/lib-src/ChangeLog	Fri Jul 29 01:54:54 2005 +0000
@@ -1,3 +1,27 @@
+2005-07-27  Juanma Barranquero  <lekktu@gmail.com>
+
+	* .cvsignore: Don't ignore fns-* and fns.el, which are no longer
+	generated.  Ignore also ctags.c and getopt.h.
+
+	* makefile.w32-in (clean): Delete getopt.h.
+	(getopt.h): New rule.
+
+2005-07-26  Paul Eggert  <eggert@cs.ucla.edu>
+
+	Merge gnulib getopt implementation into Emacs.
+
+	* Makefile.in (mostlyclean): Remove getopt.h, getopt.h-t.
+	(GETOPT_H): New macro, from gnulib.
+	(getopt.h): New rule, from gnulib.
+	(GETOPTOBJS): Now autoconfigured.
+	(GETOPTDEPS): getopt.h is now autoconfigured.
+	(getopt.o, getopt1.o): Depend on $(GETOPT_H), not ${srcdir}/getopt.h.
+	(getopt.o): Depend on ${srcdir}/gettext.h.
+	(movemail.o): Depend on $(GETOPT_H).
+	* getopt.c, getopt1.c: Sync from gnulib.
+	* getopt_.h, getopt_int.h, gettext.h: New files, from gnulib.
+	* getopt.h: Removed (now is getopt_.h).
+
 2005-07-13  Ken Raeburn  <raeburn@gnu.org>
 
 	* pop.c: Don't include des.h (or variants thereof); krb.h will do
--- a/lib-src/Makefile.in	Tue Jul 26 12:03:19 2005 +0000
+++ b/lib-src/Makefile.in	Fri Jul 29 01:54:54 2005 +0000
@@ -1,5 +1,5 @@
 # Makefile for lib-src subdirectory in GNU Emacs.
-# Copyright (C) 1985, 1987, 1988, 1993, 1994, 2002, 2003, 2004
+# Copyright (C) 1985, 1987, 1988, 1993, 1994, 2002, 2003, 2004, 2005
 #  Free Software Foundation, Inc.
 
 # This file is part of GNU Emacs.
@@ -344,7 +344,7 @@
 	 rm -f ${UTILITIES} ${INSTALLABLES} ${SCRIPTS} ${INSTALLABLE_SCRIPTS})
 
 mostlyclean:
-	-rm -f core *.o
+	-rm -f core *.o getopt.h getopt.h-t
 
 clean: mostlyclean
 	-rm -f ${INSTALLABLES} ${UTILITIES} ${DONT_INSTALL}
@@ -382,11 +382,18 @@
 	$(CC) ${ALL_CFLAGS} -o test-distrib ${srcdir}/test-distrib.c
 	./test-distrib ${srcdir}/testfile
 
-GETOPTOBJS = getopt.o getopt1.o
-GETOPTDEPS = $(GETOPTOBJS) ${srcdir}/getopt.h
-getopt.o: ${srcdir}/getopt.c ${srcdir}/getopt.h
+/* We need the following in order to create a <getopt.h> when the system
+   doesn't have one that works with the given compiler.  */
+GETOPT_H = @GETOPT_H@
+getopt.h: getopt_.h
+	cp $(srcdir)/getopt_.h $@-t
+	mv $@-t $@
+
+GETOPTOBJS = @GETOPTOBJS@
+GETOPTDEPS = $(GETOPTOBJS) $(GETOPT_H)
+getopt.o: ${srcdir}/getopt.c $(GETOPT_H) ${srcdir}/gettext.h
 	${CC} -c ${CPP_CFLAGS} ${srcdir}/getopt.c
-getopt1.o: ${srcdir}/getopt1.c ${srcdir}/getopt.h
+getopt1.o: ${srcdir}/getopt1.c $(GETOPT_H)
 	${CC} -c ${CPP_CFLAGS} ${srcdir}/getopt1.c
 
 #ifdef REGEXP_IN_LIBC
@@ -430,7 +437,7 @@
 movemail${EXEEXT}: movemail.o pop.o $(GETOPTDEPS)
 	$(CC) ${LINK_CFLAGS} ${MOVE_FLAGS} movemail.o pop.o $(GETOPTOBJS) $(LOADLIBES) $(LIBS_MAIL) $(LIBS_MOVE) -o movemail
 
-movemail.o: ${srcdir}/movemail.c ../src/config.h
+movemail.o: ${srcdir}/movemail.c ../src/config.h $(GETOPT_H)
 	$(CC) -c ${CPP_CFLAGS} -Demacs ${MOVE_FLAGS} ${srcdir}/movemail.c
 
 pop.o: ${srcdir}/pop.c  ../src/config.h
--- a/lib-src/getopt.c	Tue Jul 26 12:03:19 2005 +0000
+++ b/lib-src/getopt.c	Fri Jul 29 01:54:54 2005 +0000
@@ -2,8 +2,8 @@
    NOTE: getopt is now part of the C library, so if you don't know what
    "Keep this file name-space clean" means, talk to drepper@gnu.org
    before changing it!
-   Copyright (C) 1987,88,89,90,91,92,93,94,95,96,98,99,2000,2001,2002
-   	Free Software Foundation, Inc.
+   Copyright (C) 1987,88,89,90,91,92,93,94,95,96,98,99,2000,2001,2002,2003,2004
+	Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    This program is free software; you can redistribute it and/or modify
@@ -30,35 +30,8 @@
 # include <config.h>
 #endif
 
-#if !defined __STDC__ || !__STDC__
-/* This is a separate conditional since some stdc systems
-   reject `defined (const)'.  */
-# ifndef const
-#  define const
-# endif
-#endif
-
 #include <stdio.h>
 
-/* Comment out all this code if we are using the GNU C Library, and are not
-   actually compiling the library itself.  This code is part of the GNU C
-   Library, but also included in many other GNU distributions.  Compiling
-   and linking in this code is a waste when using the GNU C library
-   (especially if it is a shared library).  Rather than having every GNU
-   program understand `configure --with-gnu-libc' and omit the object files,
-   it is simpler to just do this in the source for each such file.  */
-
-#define GETOPT_INTERFACE_VERSION 2
-#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2
-# include <gnu-versions.h>
-# if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
-#  define ELIDE_CODE
-# endif
-#endif
-
-#ifndef ELIDE_CODE
-
-
 /* This needs to come after some library #include
    to get __GNU_LIBRARY__ defined.  */
 #ifdef	__GNU_LIBRARY__
@@ -68,32 +41,18 @@
 # include <unistd.h>
 #endif	/* GNU C library.  */
 
+#include <string.h>
+
 #ifdef VMS
 # include <unixlib.h>
-# if HAVE_STRING_H - 0
-#  include <string.h>
-# endif
 #endif
 
-#if HAVE_LIBINTL_H
+#ifdef _LIBC
 # include <libintl.h>
-#endif /* HAVE_LIBINTL_H */
-
-#if 0
-#  ifdef _LIBC
-#    include <libintl.h>
-#  else  /* not #ifdef _LIBC */
-/* This is for other GNU distributions with internationalized messages.  */
-#    include "gettext.h"
-#  endif  /* end #ifdef _LIBC */
-#endif  /* end #if 0 */
-
-#if HAVE_LIBINTL_H
-  /* Should I include libintl.h here as in regex.c ? */
-#  define _(msgid) gettext (msgid)
-#else  /* not #if HAVE_LIBINTL_H */
-#  define _(msgid) (msgid)
-#endif  /* end #if HAVE_LIBINTL_H */
+#else
+# include "gettext.h"
+# define _(msgid) gettext (msgid)
+#endif
 
 #if defined _LIBC && defined USE_IN_LIBIO
 # include <wchar.h>
@@ -103,21 +62,22 @@
 # define attribute_hidden
 #endif
 
-/* This version of `getopt' appears to the caller like standard Unix `getopt'
-   but it behaves differently for the user, since it allows the user
-   to intersperse the options with the other arguments.
+/* Unlike standard Unix `getopt', functions like `getopt_long'
+   let the user intersperse the options with the other arguments.
 
-   As `getopt' works, it permutes the elements of ARGV so that,
+   As `getopt_long' works, it permutes the elements of ARGV so that,
    when it is done, all the options precede everything else.  Thus
    all application programs are extended to handle flexible argument order.
 
-   Setting the environment variable POSIXLY_CORRECT disables permutation.
-   Then the behavior is completely standard.
+   Using `getopt' or setting the environment variable POSIXLY_CORRECT
+   disables permutation.
+   Then the application's behavior is completely standard.
 
    GNU application programs can use a third alternative mode in which
    they can distinguish the relative order of options and other arguments.  */
 
 #include "getopt.h"
+#include "getopt_int.h"
 
 /* For communication from `getopt' to the caller.
    When `getopt' finds an option that takes an argument,
@@ -142,21 +102,6 @@
 /* 1003.2 says this must be 1 before any call.  */
 int optind = 1;
 
-/* Formerly, initialization of getopt depended on optind==0, which
-   causes problems with re-calling getopt as programs generally don't
-   know that. */
-
-int __getopt_initialized attribute_hidden;
-
-/* The next char to be scanned in the option-element
-   in which the last option character we returned was found.
-   This allows us to pick up the scan where we left off.
-
-   If this is zero, or a null string, it means resume the scan
-   by advancing to the next ARGV-element.  */
-
-static char *nextchar;
-
 /* Callers store zero here to inhibit the error message
    for unrecognized options.  */
 
@@ -168,57 +113,12 @@
 
 int optopt = '?';
 
-/* Describe how to deal with options that follow non-option ARGV-elements.
-
-   If the caller did not specify anything,
-   the default is REQUIRE_ORDER if the environment variable
-   POSIXLY_CORRECT is defined, PERMUTE otherwise.
-
-   REQUIRE_ORDER means don't recognize them as options;
-   stop option processing when the first non-option is seen.
-   This is what Unix does.
-   This mode of operation is selected by either setting the environment
-   variable POSIXLY_CORRECT, or using `+' as the first character
-   of the list of option characters.
-
-   PERMUTE is the default.  We permute the contents of ARGV as we scan,
-   so that eventually all the non-options are at the end.  This allows options
-   to be given in any order, even with programs that were not written to
-   expect this.
-
-   RETURN_IN_ORDER is an option available to programs that were written
-   to expect options and other ARGV-elements in any order and that care about
-   the ordering of the two.  We describe each non-option ARGV-element
-   as if it were the argument of an option with character code 1.
-   Using `-' as the first character of the list of option characters
-   selects this mode of operation.
+/* Keep a global copy of all internal members of getopt_data.  */
 
-   The special argument `--' forces an end of option-scanning regardless
-   of the value of `ordering'.  In the case of RETURN_IN_ORDER, only
-   `--' can cause `getopt' to return -1 with `optind' != ARGC.  */
+static struct _getopt_data getopt_data;
 
-static enum
-{
-  REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
-} ordering;
-
-/* Value of POSIXLY_CORRECT environment variable.  */
-static char *posixly_correct;
 
-#ifdef	__GNU_LIBRARY__
-/* We want to avoid inclusion of string.h with non-GNU libraries
-   because there are many ways it can cause trouble.
-   On some systems, it contains special magic macros that don't work
-   in GCC.  */
-# include <string.h>
-# define my_index	strchr
-#else
-
-# if HAVE_STRING_H
-#  include <string.h>
-# else
-#  include <strings.h>
-# endif
+#ifndef __GNU_LIBRARY__
 
 /* Avoid depending on library functions or files
    whose names are inconsistent.  */
@@ -227,43 +127,8 @@
 extern char *getenv ();
 #endif
 
-static char *
-my_index (str, chr)
-     const char *str;
-     int chr;
-{
-  while (*str)
-    {
-      if (*str == chr)
-	return (char *) str;
-      str++;
-    }
-  return 0;
-}
-
-/* If using GCC, we can safely declare strlen this way.
-   If not using GCC, it is ok not to declare it.  */
-#ifdef __GNUC__
-/* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h.
-   That was relevant to code that was here before.  */
-# if (!defined __STDC__ || !__STDC__) && !defined strlen
-/* gcc with -traditional declares the built-in strlen to return int,
-   and has done so at least since version 2.4.5. -- rms.  */
-extern int strlen (const char *);
-# endif /* not __STDC__ */
-#endif /* __GNUC__ */
-
 #endif /* not __GNU_LIBRARY__ */
 
-/* Handle permutation of arguments.  */
-
-/* Describe the part of ARGV that contains non-options that have
-   been skipped.  `first_nonopt' is the index in ARGV of the first of them;
-   `last_nonopt' is the index after the last of them.  */
-
-static int first_nonopt;
-static int last_nonopt;
-
 #ifdef _LIBC
 /* Stored original parameters.
    XXX This is no good solution.  We should rather copy the args so
@@ -277,14 +142,11 @@
 # ifdef USE_NONOPTION_FLAGS
 /* Defined in getopt_init.c  */
 extern char *__getopt_nonoption_flags;
-
-static int nonoption_flags_max_len;
-static int nonoption_flags_len;
 # endif
 
 # ifdef USE_NONOPTION_FLAGS
 #  define SWAP_FLAGS(ch1, ch2) \
-  if (nonoption_flags_len > 0)						      \
+  if (d->__nonoption_flags_len > 0)					      \
     {									      \
       char __tmp = __getopt_nonoption_flags[ch1];			      \
       __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2];	      \
@@ -306,17 +168,12 @@
    `first_nonopt' and `last_nonopt' are relocated so that they describe
    the new indices of the non-options in ARGV after they are moved.  */
 
-#if defined __STDC__ && __STDC__
-static void exchange (char **);
-#endif
-
 static void
-exchange (argv)
-     char **argv;
+exchange (char **argv, struct _getopt_data *d)
 {
-  int bottom = first_nonopt;
-  int middle = last_nonopt;
-  int top = optind;
+  int bottom = d->__first_nonopt;
+  int middle = d->__last_nonopt;
+  int top = d->optind;
   char *tem;
 
   /* Exchange the shorter segment with the far end of the longer segment.
@@ -328,19 +185,19 @@
   /* First make sure the handling of the `__getopt_nonoption_flags'
      string can work normally.  Our top argument must be in the range
      of the string.  */
-  if (nonoption_flags_len > 0 && top >= nonoption_flags_max_len)
+  if (d->__nonoption_flags_len > 0 && top >= d->__nonoption_flags_max_len)
     {
       /* We must extend the array.  The user plays games with us and
 	 presents new arguments.  */
       char *new_str = malloc (top + 1);
       if (new_str == NULL)
-	nonoption_flags_len = nonoption_flags_max_len = 0;
+	d->__nonoption_flags_len = d->__nonoption_flags_max_len = 0;
       else
 	{
 	  memset (__mempcpy (new_str, __getopt_nonoption_flags,
-			     nonoption_flags_max_len),
-		  '\0', top + 1 - nonoption_flags_max_len);
-	  nonoption_flags_max_len = top + 1;
+			     d->__nonoption_flags_max_len),
+		  '\0', top + 1 - d->__nonoption_flags_max_len);
+	  d->__nonoption_flags_max_len = top + 1;
 	  __getopt_nonoption_flags = new_str;
 	}
     }
@@ -386,76 +243,71 @@
 
   /* Update records for the slots the non-options now occupy.  */
 
-  first_nonopt += (optind - last_nonopt);
-  last_nonopt = optind;
+  d->__first_nonopt += (d->optind - d->__last_nonopt);
+  d->__last_nonopt = d->optind;
 }
 
 /* Initialize the internal data when the first call is made.  */
 
-#if defined __STDC__ && __STDC__
-static const char *_getopt_initialize (int, char *const *, const char *);
-#endif
 static const char *
-_getopt_initialize (argc, argv, optstring)
-     int argc;
-     char *const *argv;
-     const char *optstring;
+_getopt_initialize (int argc, char **argv, const char *optstring,
+		    int posixly_correct, struct _getopt_data *d)
 {
   /* Start processing options with ARGV-element 1 (since ARGV-element 0
      is the program name); the sequence of previously skipped
      non-option ARGV-elements is empty.  */
 
-  first_nonopt = last_nonopt = optind;
+  d->__first_nonopt = d->__last_nonopt = d->optind;
 
-  nextchar = NULL;
+  d->__nextchar = NULL;
 
-  posixly_correct = getenv ("POSIXLY_CORRECT");
+  d->__posixly_correct = posixly_correct || !!getenv ("POSIXLY_CORRECT");
 
   /* Determine how to handle the ordering of options and nonoptions.  */
 
   if (optstring[0] == '-')
     {
-      ordering = RETURN_IN_ORDER;
+      d->__ordering = RETURN_IN_ORDER;
       ++optstring;
     }
   else if (optstring[0] == '+')
     {
-      ordering = REQUIRE_ORDER;
+      d->__ordering = REQUIRE_ORDER;
       ++optstring;
     }
-  else if (posixly_correct != NULL)
-    ordering = REQUIRE_ORDER;
+  else if (d->__posixly_correct)
+    d->__ordering = REQUIRE_ORDER;
   else
-    ordering = PERMUTE;
+    d->__ordering = PERMUTE;
 
 #if defined _LIBC && defined USE_NONOPTION_FLAGS
-  if (posixly_correct == NULL
+  if (!d->__posixly_correct
       && argc == __libc_argc && argv == __libc_argv)
     {
-      if (nonoption_flags_max_len == 0)
+      if (d->__nonoption_flags_max_len == 0)
 	{
 	  if (__getopt_nonoption_flags == NULL
 	      || __getopt_nonoption_flags[0] == '\0')
-	    nonoption_flags_max_len = -1;
+	    d->__nonoption_flags_max_len = -1;
 	  else
 	    {
 	      const char *orig_str = __getopt_nonoption_flags;
-	      int len = nonoption_flags_max_len = strlen (orig_str);
-	      if (nonoption_flags_max_len < argc)
-		nonoption_flags_max_len = argc;
+	      int len = d->__nonoption_flags_max_len = strlen (orig_str);
+	      if (d->__nonoption_flags_max_len < argc)
+		d->__nonoption_flags_max_len = argc;
 	      __getopt_nonoption_flags =
-		(char *) malloc (nonoption_flags_max_len);
+		(char *) malloc (d->__nonoption_flags_max_len);
 	      if (__getopt_nonoption_flags == NULL)
-		nonoption_flags_max_len = -1;
+		d->__nonoption_flags_max_len = -1;
 	      else
 		memset (__mempcpy (__getopt_nonoption_flags, orig_str, len),
-			'\0', nonoption_flags_max_len - len);
+			'\0', d->__nonoption_flags_max_len - len);
 	    }
 	}
-      nonoption_flags_len = nonoption_flags_max_len;
+      d->__nonoption_flags_len = d->__nonoption_flags_max_len;
     }
   else
-    nonoption_flags_len = 0;
+    d->__nonoption_flags_len = 0;
 #endif
 
   return optstring;
@@ -503,10 +355,6 @@
    `flag' field is nonzero, the value of the option's `val' field
    if the `flag' field is zero.
 
-   The elements of ARGV aren't really const, because we permute them.
-   But we pretend they're const in the prototype to be compatible
-   with other systems.
-
    LONGOPTS is a vector of `struct option' terminated by an
    element containing a name which is zero.
 
@@ -515,32 +363,32 @@
    recent call.
 
    If LONG_ONLY is nonzero, '-' as well as '--' can introduce
-   long-named options.  */
+   long-named options.
+
+   If POSIXLY_CORRECT is nonzero, behave as if the POSIXLY_CORRECT
+   environment variable were set.  */
 
 int
-_getopt_internal (argc, argv, optstring, longopts, longind, long_only)
-     int argc;
-     char *const *argv;
-     const char *optstring;
-     const struct option *longopts;
-     int *longind;
-     int long_only;
+_getopt_internal_r (int argc, char **argv, const char *optstring,
+		    const struct option *longopts, int *longind,
+		    int long_only, int posixly_correct, struct _getopt_data *d)
 {
-  int print_errors = opterr;
+  int print_errors = d->opterr;
   if (optstring[0] == ':')
     print_errors = 0;
 
   if (argc < 1)
     return -1;
 
-  optarg = NULL;
+  d->optarg = NULL;
 
-  if (optind == 0 || !__getopt_initialized)
+  if (d->optind == 0 || !d->__initialized)
     {
-      if (optind == 0)
-	optind = 1;	/* Don't scan ARGV[0], the program name.  */
-      optstring = _getopt_initialize (argc, argv, optstring);
-      __getopt_initialized = 1;
+      if (d->optind == 0)
+	d->optind = 1;	/* Don't scan ARGV[0], the program name.  */
+      optstring = _getopt_initialize (argc, argv, optstring,
+				      posixly_correct, d);
+      d->__initialized = 1;
     }
 
   /* Test whether ARGV[optind] points to a non-option argument.
@@ -548,40 +396,41 @@
      from the shell indicating it is not an option.  The later information
      is only used when the used in the GNU libc.  */
 #if defined _LIBC && defined USE_NONOPTION_FLAGS
-# define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0'	      \
-		      || (optind < nonoption_flags_len			      \
-			  && __getopt_nonoption_flags[optind] == '1'))
+# define NONOPTION_P (argv[d->optind][0] != '-' || argv[d->optind][1] == '\0' \
+		      || (d->optind < d->__nonoption_flags_len		      \
+			  && __getopt_nonoption_flags[d->optind] == '1'))
 #else
-# define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0')
+# define NONOPTION_P (argv[d->optind][0] != '-' || argv[d->optind][1] == '\0')
 #endif
 
-  if (nextchar == NULL || *nextchar == '\0')
+  if (d->__nextchar == NULL || *d->__nextchar == '\0')
     {
       /* Advance to the next ARGV-element.  */
 
       /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been
 	 moved back by the user (who may also have changed the arguments).  */
-      if (last_nonopt > optind)
-	last_nonopt = optind;
-      if (first_nonopt > optind)
-	first_nonopt = optind;
+      if (d->__last_nonopt > d->optind)
+	d->__last_nonopt = d->optind;
+      if (d->__first_nonopt > d->optind)
+	d->__first_nonopt = d->optind;
 
-      if (ordering == PERMUTE)
+      if (d->__ordering == PERMUTE)
 	{
 	  /* If we have just processed some options following some non-options,
 	     exchange them so that the options come first.  */
 
-	  if (first_nonopt != last_nonopt && last_nonopt != optind)
-	    exchange ((char **) argv);
-	  else if (last_nonopt != optind)
-	    first_nonopt = optind;
+	  if (d->__first_nonopt != d->__last_nonopt
+	      && d->__last_nonopt != d->optind)
+	    exchange ((char **) argv, d);
+	  else if (d->__last_nonopt != d->optind)
+	    d->__first_nonopt = d->optind;
 
 	  /* Skip any additional non-options
 	     and extend the range of non-options previously skipped.  */
 
-	  while (optind < argc && NONOPTION_P)
-	    optind++;
-	  last_nonopt = optind;
+	  while (d->optind < argc && NONOPTION_P)
+	    d->optind++;
+	  d->__last_nonopt = d->optind;
 	}
 
       /* The special ARGV-element `--' means premature end of options.
@@ -589,28 +438,29 @@
 	 then exchange with previous non-options as if it were an option,
 	 then skip everything else like a non-option.  */
 
-      if (optind != argc && !strcmp (argv[optind], "--"))
+      if (d->optind != argc && !strcmp (argv[d->optind], "--"))
 	{
-	  optind++;
+	  d->optind++;
 
-	  if (first_nonopt != last_nonopt && last_nonopt != optind)
-	    exchange ((char **) argv);
-	  else if (first_nonopt == last_nonopt)
-	    first_nonopt = optind;
-	  last_nonopt = argc;
+	  if (d->__first_nonopt != d->__last_nonopt
+	      && d->__last_nonopt != d->optind)
+	    exchange ((char **) argv, d);
+	  else if (d->__first_nonopt == d->__last_nonopt)
+	    d->__first_nonopt = d->optind;
+	  d->__last_nonopt = argc;
 
-	  optind = argc;
+	  d->optind = argc;
 	}
 
       /* If we have done all the ARGV-elements, stop the scan
 	 and back over any non-options that we skipped and permuted.  */
 
-      if (optind == argc)
+      if (d->optind == argc)
 	{
 	  /* Set the next-arg-index to point at the non-options
 	     that we previously skipped, so the caller will digest them.  */
-	  if (first_nonopt != last_nonopt)
-	    optind = first_nonopt;
+	  if (d->__first_nonopt != d->__last_nonopt)
+	    d->optind = d->__first_nonopt;
 	  return -1;
 	}
 
@@ -619,17 +469,17 @@
 
       if (NONOPTION_P)
 	{
-	  if (ordering == REQUIRE_ORDER)
+	  if (d->__ordering == REQUIRE_ORDER)
 	    return -1;
-	  optarg = argv[optind++];
+	  d->optarg = argv[d->optind++];
 	  return 1;
 	}
 
       /* We have found another option-ARGV-element.
 	 Skip the initial punctuation.  */
 
-      nextchar = (argv[optind] + 1
-		  + (longopts != NULL && argv[optind][1] == '-'));
+      d->__nextchar = (argv[d->optind] + 1
+		  + (longopts != NULL && argv[d->optind][1] == '-'));
     }
 
   /* Decode the current option-ARGV-element.  */
@@ -648,8 +498,9 @@
      This distinction seems to be the most useful approach.  */
 
   if (longopts != NULL
-      && (argv[optind][1] == '-'
-	  || (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1])))))
+      && (argv[d->optind][1] == '-'
+	  || (long_only && (argv[d->optind][2]
+			    || !strchr (optstring, argv[d->optind][1])))))
     {
       char *nameend;
       const struct option *p;
@@ -659,15 +510,15 @@
       int indfound = -1;
       int option_index;
 
-      for (nameend = nextchar; *nameend && *nameend != '='; nameend++)
+      for (nameend = d->__nextchar; *nameend && *nameend != '='; nameend++)
 	/* Do nothing.  */ ;
 
       /* Test all long options for either exact match
 	 or abbreviated matches.  */
       for (p = longopts, option_index = 0; p->name; p++, option_index++)
-	if (!strncmp (p->name, nextchar, nameend - nextchar))
+	if (!strncmp (p->name, d->__nextchar, nameend - d->__nextchar))
 	  {
-	    if ((unsigned int) (nameend - nextchar)
+	    if ((unsigned int) (nameend - d->__nextchar)
 		== (unsigned int) strlen (p->name))
 	      {
 		/* Exact match found.  */
@@ -698,37 +549,44 @@
 	      char *buf;
 
 	      if (__asprintf (&buf, _("%s: option `%s' is ambiguous\n"),
-			      argv[0], argv[optind]) >= 0)
+			      argv[0], argv[d->optind]) >= 0)
 		{
+		  _IO_flockfile (stderr);
+
+		  int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
+		  ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
 
 		  if (_IO_fwide (stderr, 0) > 0)
 		    __fwprintf (stderr, L"%s", buf);
 		  else
 		    fputs (buf, stderr);
 
+		  ((_IO_FILE *) stderr)->_flags2 = old_flags2;
+		  _IO_funlockfile (stderr);
+
 		  free (buf);
 		}
 #else
 	      fprintf (stderr, _("%s: option `%s' is ambiguous\n"),
-		       argv[0], argv[optind]);
+		       argv[0], argv[d->optind]);
 #endif
 	    }
-	  nextchar += strlen (nextchar);
-	  optind++;
-	  optopt = 0;
+	  d->__nextchar += strlen (d->__nextchar);
+	  d->optind++;
+	  d->optopt = 0;
 	  return '?';
 	}
 
       if (pfound != NULL)
 	{
 	  option_index = indfound;
-	  optind++;
+	  d->optind++;
 	  if (*nameend)
 	    {
 	      /* Don't test has_arg with >, because some C compilers don't
 		 allow it to be used on enums.  */
 	      if (pfound->has_arg)
-		optarg = nameend + 1;
+		d->optarg = nameend + 1;
 	      else
 		{
 		  if (print_errors)
@@ -738,7 +596,7 @@
 		      int n;
 #endif
 
-		      if (argv[optind - 1][1] == '-')
+		      if (argv[d->optind - 1][1] == '-')
 			{
 			  /* --option */
 #if defined _LIBC && defined USE_IN_LIBIO
@@ -757,38 +615,48 @@
 #if defined _LIBC && defined USE_IN_LIBIO
 			  n = __asprintf (&buf, _("\
 %s: option `%c%s' doesn't allow an argument\n"),
-					  argv[0], argv[optind - 1][0],
+					  argv[0], argv[d->optind - 1][0],
 					  pfound->name);
 #else
 			  fprintf (stderr, _("\
 %s: option `%c%s' doesn't allow an argument\n"),
-				   argv[0], argv[optind - 1][0], pfound->name);
+				   argv[0], argv[d->optind - 1][0],
+				   pfound->name);
 #endif
 			}
 
 #if defined _LIBC && defined USE_IN_LIBIO
 		      if (n >= 0)
 			{
+			  _IO_flockfile (stderr);
+
+			  int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
+			  ((_IO_FILE *) stderr)->_flags2
+			    |= _IO_FLAGS2_NOTCANCEL;
+
 			  if (_IO_fwide (stderr, 0) > 0)
 			    __fwprintf (stderr, L"%s", buf);
 			  else
 			    fputs (buf, stderr);
 
+			  ((_IO_FILE *) stderr)->_flags2 = old_flags2;
+			  _IO_funlockfile (stderr);
+
 			  free (buf);
 			}
 #endif
 		    }
 
-		  nextchar += strlen (nextchar);
+		  d->__nextchar += strlen (d->__nextchar);
 
-		  optopt = pfound->val;
+		  d->optopt = pfound->val;
 		  return '?';
 		}
 	    }
 	  else if (pfound->has_arg == 1)
 	    {
-	      if (optind < argc)
-		optarg = argv[optind++];
+	      if (d->optind < argc)
+		d->optarg = argv[d->optind++];
 	      else
 		{
 		  if (print_errors)
@@ -798,27 +666,36 @@
 
 		      if (__asprintf (&buf, _("\
 %s: option `%s' requires an argument\n"),
-				      argv[0], argv[optind - 1]) >= 0)
+				      argv[0], argv[d->optind - 1]) >= 0)
 			{
+			  _IO_flockfile (stderr);
+
+			  int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
+			  ((_IO_FILE *) stderr)->_flags2
+			    |= _IO_FLAGS2_NOTCANCEL;
+
 			  if (_IO_fwide (stderr, 0) > 0)
 			    __fwprintf (stderr, L"%s", buf);
 			  else
 			    fputs (buf, stderr);
 
+			  ((_IO_FILE *) stderr)->_flags2 = old_flags2;
+			  _IO_funlockfile (stderr);
+
 			  free (buf);
 			}
 #else
 		      fprintf (stderr,
 			       _("%s: option `%s' requires an argument\n"),
-			       argv[0], argv[optind - 1]);
+			       argv[0], argv[d->optind - 1]);
 #endif
 		    }
-		  nextchar += strlen (nextchar);
-		  optopt = pfound->val;
+		  d->__nextchar += strlen (d->__nextchar);
+		  d->optopt = pfound->val;
 		  return optstring[0] == ':' ? ':' : '?';
 		}
 	    }
-	  nextchar += strlen (nextchar);
+	  d->__nextchar += strlen (d->__nextchar);
 	  if (longind != NULL)
 	    *longind = option_index;
 	  if (pfound->flag)
@@ -833,8 +710,8 @@
 	 or the option starts with '--' or is not a valid short
 	 option, then it's an error.
 	 Otherwise interpret it as a short option.  */
-      if (!long_only || argv[optind][1] == '-'
-	  || my_index (optstring, *nextchar) == NULL)
+      if (!long_only || argv[d->optind][1] == '-'
+	  || strchr (optstring, *d->__nextchar) == NULL)
 	{
 	  if (print_errors)
 	    {
@@ -843,15 +720,15 @@
 	      int n;
 #endif
 
-	      if (argv[optind][1] == '-')
+	      if (argv[d->optind][1] == '-')
 		{
 		  /* --option */
 #if defined _LIBC && defined USE_IN_LIBIO
 		  n = __asprintf (&buf, _("%s: unrecognized option `--%s'\n"),
-				  argv[0], nextchar);
+				  argv[0], d->__nextchar);
 #else
 		  fprintf (stderr, _("%s: unrecognized option `--%s'\n"),
-			   argv[0], nextchar);
+			   argv[0], d->__nextchar);
 #endif
 		}
 	      else
@@ -859,28 +736,36 @@
 		  /* +option or -option */
 #if defined _LIBC && defined USE_IN_LIBIO
 		  n = __asprintf (&buf, _("%s: unrecognized option `%c%s'\n"),
-				  argv[0], argv[optind][0], nextchar);
+				  argv[0], argv[d->optind][0], d->__nextchar);
 #else
 		  fprintf (stderr, _("%s: unrecognized option `%c%s'\n"),
-			   argv[0], argv[optind][0], nextchar);
+			   argv[0], argv[d->optind][0], d->__nextchar);
 #endif
 		}
 
 #if defined _LIBC && defined USE_IN_LIBIO
 	      if (n >= 0)
 		{
+		  _IO_flockfile (stderr);
+
+		  int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
+		  ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
+
 		  if (_IO_fwide (stderr, 0) > 0)
 		    __fwprintf (stderr, L"%s", buf);
 		  else
 		    fputs (buf, stderr);
 
+		  ((_IO_FILE *) stderr)->_flags2 = old_flags2;
+		  _IO_funlockfile (stderr);
+
 		  free (buf);
 		}
 #endif
 	    }
-	  nextchar = (char *) "";
-	  optind++;
-	  optopt = 0;
+	  d->__nextchar = (char *) "";
+	  d->optind++;
+	  d->optopt = 0;
 	  return '?';
 	}
     }
@@ -888,12 +773,12 @@
   /* Look at and handle the next short option-character.  */
 
   {
-    char c = *nextchar++;
-    char *temp = my_index (optstring, c);
+    char c = *d->__nextchar++;
+    char *temp = strchr (optstring, c);
 
     /* Increment `optind' when we start to process its last character.  */
-    if (*nextchar == '\0')
-      ++optind;
+    if (*d->__nextchar == '\0')
+      ++d->optind;
 
     if (temp == NULL || c == ':')
       {
@@ -904,7 +789,7 @@
 	      int n;
 #endif
 
-	    if (posixly_correct)
+	    if (d->__posixly_correct)
 	      {
 		/* 1003.2 specifies the format of this message.  */
 #if defined _LIBC && defined USE_IN_LIBIO
@@ -927,16 +812,24 @@
 #if defined _LIBC && defined USE_IN_LIBIO
 	    if (n >= 0)
 	      {
+		_IO_flockfile (stderr);
+
+		int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
+		((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
+
 		if (_IO_fwide (stderr, 0) > 0)
 		  __fwprintf (stderr, L"%s", buf);
 		else
 		  fputs (buf, stderr);
 
+		((_IO_FILE *) stderr)->_flags2 = old_flags2;
+		_IO_funlockfile (stderr);
+
 		free (buf);
 	      }
 #endif
 	  }
-	optopt = c;
+	d->optopt = c;
 	return '?';
       }
     /* Convenience. Treat POSIX -W foo same as long option --foo */
@@ -951,14 +844,14 @@
 	int option_index;
 
 	/* This is an option that requires an argument.  */
-	if (*nextchar != '\0')
+	if (*d->__nextchar != '\0')
 	  {
-	    optarg = nextchar;
+	    d->optarg = d->__nextchar;
 	    /* If we end this ARGV-element by taking the rest as an arg,
 	       we must advance to the next element now.  */
-	    optind++;
+	    d->optind++;
 	  }
-	else if (optind == argc)
+	else if (d->optind == argc)
 	  {
 	    if (print_errors)
 	      {
@@ -970,11 +863,19 @@
 				_("%s: option requires an argument -- %c\n"),
 				argv[0], c) >= 0)
 		  {
+		    _IO_flockfile (stderr);
+
+		    int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
+		    ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
+
 		    if (_IO_fwide (stderr, 0) > 0)
 		      __fwprintf (stderr, L"%s", buf);
 		    else
 		      fputs (buf, stderr);
 
+		    ((_IO_FILE *) stderr)->_flags2 = old_flags2;
+		    _IO_funlockfile (stderr);
+
 		    free (buf);
 		  }
 #else
@@ -982,7 +883,7 @@
 			 argv[0], c);
 #endif
 	      }
-	    optopt = c;
+	    d->optopt = c;
 	    if (optstring[0] == ':')
 	      c = ':';
 	    else
@@ -990,22 +891,23 @@
 	    return c;
 	  }
 	else
-	  /* We already incremented `optind' once;
+	  /* We already incremented `d->optind' once;
 	     increment it again when taking next ARGV-elt as argument.  */
-	  optarg = argv[optind++];
+	  d->optarg = argv[d->optind++];
 
 	/* optarg is now the argument, see if it's in the
 	   table of longopts.  */
 
-	for (nextchar = nameend = optarg; *nameend && *nameend != '='; nameend++)
+	for (d->__nextchar = nameend = d->optarg; *nameend && *nameend != '=';
+	     nameend++)
 	  /* Do nothing.  */ ;
 
 	/* Test all long options for either exact match
 	   or abbreviated matches.  */
 	for (p = longopts, option_index = 0; p->name; p++, option_index++)
-	  if (!strncmp (p->name, nextchar, nameend - nextchar))
+	  if (!strncmp (p->name, d->__nextchar, nameend - d->__nextchar))
 	    {
-	      if ((unsigned int) (nameend - nextchar) == strlen (p->name))
+	      if ((unsigned int) (nameend - d->__nextchar) == strlen (p->name))
 		{
 		  /* Exact match found.  */
 		  pfound = p;
@@ -1031,22 +933,30 @@
 		char *buf;
 
 		if (__asprintf (&buf, _("%s: option `-W %s' is ambiguous\n"),
-				argv[0], argv[optind]) >= 0)
+				argv[0], argv[d->optind]) >= 0)
 		  {
+		    _IO_flockfile (stderr);
+
+		    int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
+		    ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
+
 		    if (_IO_fwide (stderr, 0) > 0)
 		      __fwprintf (stderr, L"%s", buf);
 		    else
 		      fputs (buf, stderr);
 
+		    ((_IO_FILE *) stderr)->_flags2 = old_flags2;
+		    _IO_funlockfile (stderr);
+
 		    free (buf);
 		  }
 #else
 		fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"),
-			 argv[0], argv[optind]);
+			 argv[0], argv[d->optind]);
 #endif
 	      }
-	    nextchar += strlen (nextchar);
-	    optind++;
+	    d->__nextchar += strlen (d->__nextchar);
+	    d->optind++;
 	    return '?';
 	  }
 	if (pfound != NULL)
@@ -1057,7 +967,7 @@
 		/* Don't test has_arg with >, because some C compilers don't
 		   allow it to be used on enums.  */
 		if (pfound->has_arg)
-		  optarg = nameend + 1;
+		  d->optarg = nameend + 1;
 		else
 		  {
 		    if (print_errors)
@@ -1069,11 +979,20 @@
 %s: option `-W %s' doesn't allow an argument\n"),
 					argv[0], pfound->name) >= 0)
 			  {
+			    _IO_flockfile (stderr);
+
+			    int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
+			    ((_IO_FILE *) stderr)->_flags2
+			      |= _IO_FLAGS2_NOTCANCEL;
+
 			    if (_IO_fwide (stderr, 0) > 0)
 			      __fwprintf (stderr, L"%s", buf);
 			    else
 			      fputs (buf, stderr);
 
+			    ((_IO_FILE *) stderr)->_flags2 = old_flags2;
+			    _IO_funlockfile (stderr);
+
 			    free (buf);
 			  }
 #else
@@ -1083,14 +1002,14 @@
 #endif
 		      }
 
-		    nextchar += strlen (nextchar);
+		    d->__nextchar += strlen (d->__nextchar);
 		    return '?';
 		  }
 	      }
 	    else if (pfound->has_arg == 1)
 	      {
-		if (optind < argc)
-		  optarg = argv[optind++];
+		if (d->optind < argc)
+		  d->optarg = argv[d->optind++];
 		else
 		  {
 		    if (print_errors)
@@ -1100,26 +1019,35 @@
 
 			if (__asprintf (&buf, _("\
 %s: option `%s' requires an argument\n"),
-					argv[0], argv[optind - 1]) >= 0)
+					argv[0], argv[d->optind - 1]) >= 0)
 			  {
+			    _IO_flockfile (stderr);
+
+			    int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
+			    ((_IO_FILE *) stderr)->_flags2
+			      |= _IO_FLAGS2_NOTCANCEL;
+
 			    if (_IO_fwide (stderr, 0) > 0)
 			      __fwprintf (stderr, L"%s", buf);
 			    else
 			      fputs (buf, stderr);
 
+			    ((_IO_FILE *) stderr)->_flags2 = old_flags2;
+			    _IO_funlockfile (stderr);
+
 			    free (buf);
 			  }
 #else
 			fprintf (stderr,
 				 _("%s: option `%s' requires an argument\n"),
-				 argv[0], argv[optind - 1]);
+				 argv[0], argv[d->optind - 1]);
 #endif
 		      }
-		    nextchar += strlen (nextchar);
+		    d->__nextchar += strlen (d->__nextchar);
 		    return optstring[0] == ':' ? ':' : '?';
 		  }
 	      }
-	    nextchar += strlen (nextchar);
+	    d->__nextchar += strlen (d->__nextchar);
 	    if (longind != NULL)
 	      *longind = option_index;
 	    if (pfound->flag)
@@ -1129,7 +1057,7 @@
 	      }
 	    return pfound->val;
 	  }
-	  nextchar = NULL;
+	  d->__nextchar = NULL;
 	  return 'W';	/* Let the application handle it.   */
       }
     if (temp[1] == ':')
@@ -1137,26 +1065,26 @@
 	if (temp[2] == ':')
 	  {
 	    /* This is an option that accepts an argument optionally.  */
-	    if (*nextchar != '\0')
+	    if (*d->__nextchar != '\0')
 	      {
-		optarg = nextchar;
-		optind++;
+		d->optarg = d->__nextchar;
+		d->optind++;
 	      }
 	    else
-	      optarg = NULL;
-	    nextchar = NULL;
+	      d->optarg = NULL;
+	    d->__nextchar = NULL;
 	  }
 	else
 	  {
 	    /* This is an option that requires an argument.  */
-	    if (*nextchar != '\0')
+	    if (*d->__nextchar != '\0')
 	      {
-		optarg = nextchar;
+		d->optarg = d->__nextchar;
 		/* If we end this ARGV-element by taking the rest as an arg,
 		   we must advance to the next element now.  */
-		optind++;
+		d->optind++;
 	      }
-	    else if (optind == argc)
+	    else if (d->optind == argc)
 	      {
 		if (print_errors)
 		  {
@@ -1168,11 +1096,19 @@
 %s: option requires an argument -- %c\n"),
 				    argv[0], c) >= 0)
 		      {
+			_IO_flockfile (stderr);
+
+			int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
+			((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
+
 			if (_IO_fwide (stderr, 0) > 0)
 			  __fwprintf (stderr, L"%s", buf);
 			else
 			  fputs (buf, stderr);
 
+			((_IO_FILE *) stderr)->_flags2 = old_flags2;
+			_IO_funlockfile (stderr);
+
 			free (buf);
 		      }
 #else
@@ -1181,7 +1117,7 @@
 			     argv[0], c);
 #endif
 		  }
-		optopt = c;
+		d->optopt = c;
 		if (optstring[0] == ':')
 		  c = ':';
 		else
@@ -1190,8 +1126,8 @@
 	    else
 	      /* We already incremented `optind' once;
 		 increment it again when taking next ARGV-elt as argument.  */
-	      optarg = argv[optind++];
-	    nextchar = NULL;
+	      d->optarg = argv[d->optind++];
+	    d->__nextchar = NULL;
 	  }
       }
     return c;
@@ -1199,18 +1135,40 @@
 }
 
 int
-getopt (argc, argv, optstring)
-     int argc;
-     char *const *argv;
-     const char *optstring;
+_getopt_internal (int argc, char **argv, const char *optstring,
+		  const struct option *longopts, int *longind,
+		  int long_only, int posixly_correct)
 {
-  return _getopt_internal (argc, argv, optstring,
-			   (const struct option *) 0,
-			   (int *) 0,
-			   0);
+  int result;
+
+  getopt_data.optind = optind;
+  getopt_data.opterr = opterr;
+
+  result = _getopt_internal_r (argc, argv, optstring, longopts, longind,
+			       long_only, posixly_correct, &getopt_data);
+
+  optind = getopt_data.optind;
+  optarg = getopt_data.optarg;
+  optopt = getopt_data.optopt;
+
+  return result;
 }
 
-#endif	/* Not ELIDE_CODE.  */
+/* glibc gets a LSB-compliant getopt.
+   Standalone applications get a POSIX-compliant getopt.  */
+#if _LIBC
+enum { POSIXLY_CORRECT = 0 };
+#else
+enum { POSIXLY_CORRECT = 1 };
+#endif
+
+int
+getopt (int argc, char *const *argv, const char *optstring)
+{
+  return _getopt_internal (argc, (char **) argv, optstring, NULL, NULL, 0,
+			   POSIXLY_CORRECT);
+}
+
 
 #ifdef TEST
 
@@ -1218,9 +1176,7 @@
    the above definition of `getopt'.  */
 
 int
-main (argc, argv)
-     int argc;
-     char **argv;
+main (int argc, char **argv)
 {
   int c;
   int digit_optind = 0;
--- a/lib-src/getopt.h	Tue Jul 26 12:03:19 2005 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,183 +0,0 @@
-/* Declarations for getopt.
-   Copyright (C) 1989-1994, 1996-1999, 2001 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   This program 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.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License along
-   with this program; if not, write to the Free Software Foundation,
-   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
-
-#ifndef _GETOPT_H
-
-#ifndef __need_getopt
-# define _GETOPT_H 1
-#endif
-
-/* If __GNU_LIBRARY__ is not already defined, either we are being used
-   standalone, or this is the first header included in the source file.
-   If we are being used with glibc, we need to include <features.h>, but
-   that does not exist if we are standalone.  So: if __GNU_LIBRARY__ is
-   not defined, include <ctype.h>, which will pull in <features.h> for us
-   if it's from glibc.  (Why ctype.h?  It's guaranteed to exist and it
-   doesn't flood the namespace with stuff the way some other headers do.)  */
-#if !defined __GNU_LIBRARY__
-# include <ctype.h>
-#endif
-
-#ifdef	__cplusplus
-extern "C" {
-#endif
-
-/* For communication from `getopt' to the caller.
-   When `getopt' finds an option that takes an argument,
-   the argument value is returned here.
-   Also, when `ordering' is RETURN_IN_ORDER,
-   each non-option ARGV-element is returned here.  */
-
-extern char *optarg;
-
-/* Index in ARGV of the next element to be scanned.
-   This is used for communication to and from the caller
-   and for communication between successive calls to `getopt'.
-
-   On entry to `getopt', zero means this is the first call; initialize.
-
-   When `getopt' returns -1, this is the index of the first of the
-   non-option elements that the caller should itself scan.
-
-   Otherwise, `optind' communicates from one call to the next
-   how much of ARGV has been scanned so far.  */
-
-extern int optind;
-
-/* Callers store zero here to inhibit the error message `getopt' prints
-   for unrecognized options.  */
-
-extern int opterr;
-
-/* Set to an option character which was unrecognized.  */
-
-extern int optopt;
-
-#ifndef __need_getopt
-/* Describe the long-named options requested by the application.
-   The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
-   of `struct option' terminated by an element containing a name which is
-   zero.
-
-   The field `has_arg' is:
-   no_argument		(or 0) if the option does not take an argument,
-   required_argument	(or 1) if the option requires an argument,
-   optional_argument 	(or 2) if the option takes an optional argument.
-
-   If the field `flag' is not NULL, it points to a variable that is set
-   to the value given in the field `val' when the option is found, but
-   left unchanged if the option is not found.
-
-   To have a long-named option do something other than set an `int' to
-   a compiled-in constant, such as set a value from `optarg', set the
-   option's `flag' field to zero and its `val' field to a nonzero
-   value (the equivalent single-letter option character, if there is
-   one).  For long options that have a zero `flag' field, `getopt'
-   returns the contents of the `val' field.  */
-
-struct option
-{
-# if (defined __STDC__ && __STDC__) || defined __cplusplus
-  const char *name;
-# else
-  char *name;
-# endif
-  /* has_arg can't be an enum because some compilers complain about
-     type mismatches in all the code that assumes it is an int.  */
-  int has_arg;
-  int *flag;
-  int val;
-};
-
-/* Names for the values of the `has_arg' field of `struct option'.  */
-
-# define no_argument		0
-# define required_argument	1
-# define optional_argument	2
-#endif	/* need getopt */
-
-
-/* Get definitions and prototypes for functions to process the
-   arguments in ARGV (ARGC of them, minus the program name) for
-   options given in OPTS.
-
-   Return the option character from OPTS just read.  Return -1 when
-   there are no more options.  For unrecognized options, or options
-   missing arguments, `optopt' is set to the option letter, and '?' is
-   returned.
-
-   The OPTS string is a list of characters which are recognized option
-   letters, optionally followed by colons, specifying that that letter
-   takes an argument, to be placed in `optarg'.
-
-   If a letter in OPTS is followed by two colons, its argument is
-   optional.  This behavior is specific to the GNU `getopt'.
-
-   The argument `--' causes premature termination of argument
-   scanning, explicitly telling `getopt' that there are no more
-   options.
-
-   If OPTS begins with `--', then non-option arguments are treated as
-   arguments to the option '\0'.  This behavior is specific to the GNU
-   `getopt'.  */
-
-#if (defined __STDC__ && __STDC__) || defined __cplusplus
-# ifdef __GNU_LIBRARY__
-/* Many other libraries have conflicting prototypes for getopt, with
-   differences in the consts, in stdlib.h.  To avoid compilation
-   errors, only prototype getopt for the GNU C library.  */
-extern int getopt (int ___argc, char *const *___argv, const char *__shortopts);
-# else /* not __GNU_LIBRARY__ */
-extern int getopt ();
-# endif /* __GNU_LIBRARY__ */
-
-# ifndef __need_getopt
-extern int getopt_long (int ___argc, char *const *___argv,
-			const char *__shortopts,
-		        const struct option *__longopts, int *__longind);
-extern int getopt_long_only (int ___argc, char *const *___argv,
-			     const char *__shortopts,
-		             const struct option *__longopts, int *__longind);
-
-/* Internal only.  Users should not call this directly.  */
-extern int _getopt_internal (int ___argc, char *const *___argv,
-			     const char *__shortopts,
-		             const struct option *__longopts, int *__longind,
-			     int __long_only);
-# endif
-#else /* not __STDC__ */
-extern int getopt ();
-# ifndef __need_getopt
-extern int getopt_long ();
-extern int getopt_long_only ();
-
-extern int _getopt_internal ();
-# endif
-#endif /* __STDC__ */
-
-#ifdef	__cplusplus
-}
-#endif
-
-/* Make sure we later can get all the definitions and declarations.  */
-#undef __need_getopt
-
-#endif /* getopt.h */
-
-/* arch-tag: 9adb7828-e6a6-40cd-8512-0cdf1f20ddd4
-   (do not change this comment) */
--- a/lib-src/getopt1.c	Tue Jul 26 12:03:19 2005 +0000
+++ b/lib-src/getopt1.c	Fri Jul 29 01:54:54 2005 +0000
@@ -1,5 +1,5 @@
 /* getopt_long and getopt_long_only entry points for GNU getopt.
-   Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98
+   Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98,2004
      Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -26,36 +26,10 @@
 #else
 # include "getopt.h"
 #endif
-
-#if !defined __STDC__ || !__STDC__
-/* This is a separate conditional since some stdc systems
-   reject `defined (const)'.  */
-#ifndef const
-#define const
-#endif
-#endif
+#include "getopt_int.h"
 
 #include <stdio.h>
 
-/* Comment out all this code if we are using the GNU C Library, and are not
-   actually compiling the library itself.  This code is part of the GNU C
-   Library, but also included in many other GNU distributions.  Compiling
-   and linking in this code is a waste when using the GNU C library
-   (especially if it is a shared library).  Rather than having every GNU
-   program understand `configure --with-gnu-libc' and omit the object files,
-   it is simpler to just do this in the source for each such file.  */
-
-#define GETOPT_INTERFACE_VERSION 2
-#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2
-#include <gnu-versions.h>
-#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
-#define ELIDE_CODE
-#endif
-#endif
-
-#ifndef ELIDE_CODE
-
-
 /* This needs to come after some library #include
    to get __GNU_LIBRARY__ defined.  */
 #ifdef __GNU_LIBRARY__
@@ -67,14 +41,20 @@
 #endif
 
 int
-getopt_long (argc, argv, options, long_options, opt_index)
-     int argc;
-     char *const *argv;
-     const char *options;
-     const struct option *long_options;
-     int *opt_index;
+getopt_long (int argc, char *__getopt_argv_const *argv, const char *options,
+	     const struct option *long_options, int *opt_index)
 {
-  return _getopt_internal (argc, argv, options, long_options, opt_index, 0);
+  return _getopt_internal (argc, (char **) argv, options, long_options,
+			   opt_index, 0, 0);
+}
+
+int
+_getopt_long_r (int argc, char **argv, const char *options,
+		const struct option *long_options, int *opt_index,
+		struct _getopt_data *d)
+{
+  return _getopt_internal_r (argc, argv, options, long_options, opt_index,
+			     0, 0, d);
 }
 
 /* Like getopt_long, but '-' as well as '--' can indicate a long option.
@@ -83,31 +63,30 @@
    instead.  */
 
 int
-getopt_long_only (argc, argv, options, long_options, opt_index)
-     int argc;
-     char *const *argv;
-     const char *options;
-     const struct option *long_options;
-     int *opt_index;
+getopt_long_only (int argc, char *__getopt_argv_const *argv,
+		  const char *options,
+		  const struct option *long_options, int *opt_index)
 {
-  return _getopt_internal (argc, argv, options, long_options, opt_index, 1);
+  return _getopt_internal (argc, (char **) argv, options, long_options,
+			   opt_index, 1, 0);
 }
 
-# ifdef _LIBC
-libc_hidden_def (getopt_long)
-libc_hidden_def (getopt_long_only)
-# endif
+int
+_getopt_long_only_r (int argc, char **argv, const char *options,
+		     const struct option *long_options, int *opt_index,
+		     struct _getopt_data *d)
+{
+  return _getopt_internal_r (argc, argv, options, long_options, opt_index,
+			     1, 0, d);
+}
 
-#endif	/* Not ELIDE_CODE.  */
 
 #ifdef TEST
 
 #include <stdio.h>
 
 int
-main (argc, argv)
-     int argc;
-     char **argv;
+main (int argc, char **argv)
 {
   int c;
   int digit_optind = 0;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lib-src/getopt_.h	Fri Jul 29 01:54:54 2005 +0000
@@ -0,0 +1,230 @@
+/* Declarations for getopt.
+   Copyright (C) 1989-1994,1996-1999,2001,2003,2004
+   Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   This program 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.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License along
+   with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#ifndef _GETOPT_H
+
+#ifndef __need_getopt
+# define _GETOPT_H 1
+#endif
+
+/* Standalone applications should #define __GETOPT_PREFIX to an
+   identifier that prefixes the external functions and variables
+   defined in this header.  When this happens, include the
+   headers that might declare getopt so that they will not cause
+   confusion if included after this file.  Then systematically rename
+   identifiers so that they do not collide with the system functions
+   and variables.  Renaming avoids problems with some compilers and
+   linkers.  */
+#if defined __GETOPT_PREFIX && !defined __need_getopt
+# include <stdlib.h>
+# include <stdio.h>
+# if HAVE_UNISTD_H
+#  include <unistd.h>
+# endif
+# undef __need_getopt
+# undef getopt
+# undef getopt_long
+# undef getopt_long_only
+# undef optarg
+# undef opterr
+# undef optind
+# undef optopt
+# define __GETOPT_CONCAT(x, y) x ## y
+# define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y)
+# define __GETOPT_ID(y) __GETOPT_XCONCAT (__GETOPT_PREFIX, y)
+# define getopt __GETOPT_ID (getopt)
+# define getopt_long __GETOPT_ID (getopt_long)
+# define getopt_long_only __GETOPT_ID (getopt_long_only)
+# define optarg __GETOPT_ID (optarg)
+# define opterr __GETOPT_ID (opterr)
+# define optind __GETOPT_ID (optind)
+# define optopt __GETOPT_ID (optopt)
+#endif
+
+/* Standalone applications get correct prototypes for getopt_long and
+   getopt_long_only; they declare "char **argv".  libc uses prototypes
+   with "char *const *argv" that are incorrect because getopt_long and
+   getopt_long_only can permute argv; this is required for backward
+   compatibility (e.g., for LSB 2.0.1).
+
+   This used to be `#if defined __GETOPT_PREFIX && !defined __need_getopt',
+   but it caused redefinition warnings if both unistd.h and getopt.h were
+   included, since unistd.h includes getopt.h having previously defined
+   __need_getopt.
+
+   The only place where __getopt_argv_const is used is in definitions
+   of getopt_long and getopt_long_only below, but these are visible
+   only if __need_getopt is not defined, so it is quite safe to rewrite
+   the conditional as follows:
+*/
+#if !defined __need_getopt
+# if defined __GETOPT_PREFIX
+#  define __getopt_argv_const /* empty */
+# else
+#  define __getopt_argv_const const
+# endif
+#endif
+
+/* If __GNU_LIBRARY__ is not already defined, either we are being used
+   standalone, or this is the first header included in the source file.
+   If we are being used with glibc, we need to include <features.h>, but
+   that does not exist if we are standalone.  So: if __GNU_LIBRARY__ is
+   not defined, include <ctype.h>, which will pull in <features.h> for us
+   if it's from glibc.  (Why ctype.h?  It's guaranteed to exist and it
+   doesn't flood the namespace with stuff the way some other headers do.)  */
+#if !defined __GNU_LIBRARY__
+# include <ctype.h>
+#endif
+
+#ifndef __THROW
+# ifndef __GNUC_PREREQ
+#  define __GNUC_PREREQ(maj, min) (0)
+# endif
+# if defined __cplusplus && __GNUC_PREREQ (2,8)
+#  define __THROW	throw ()
+# else
+#  define __THROW
+# endif
+#endif
+
+#ifdef	__cplusplus
+extern "C" {
+#endif
+
+/* For communication from `getopt' to the caller.
+   When `getopt' finds an option that takes an argument,
+   the argument value is returned here.
+   Also, when `ordering' is RETURN_IN_ORDER,
+   each non-option ARGV-element is returned here.  */
+
+extern char *optarg;
+
+/* Index in ARGV of the next element to be scanned.
+   This is used for communication to and from the caller
+   and for communication between successive calls to `getopt'.
+
+   On entry to `getopt', zero means this is the first call; initialize.
+
+   When `getopt' returns -1, this is the index of the first of the
+   non-option elements that the caller should itself scan.
+
+   Otherwise, `optind' communicates from one call to the next
+   how much of ARGV has been scanned so far.  */
+
+extern int optind;
+
+/* Callers store zero here to inhibit the error message `getopt' prints
+   for unrecognized options.  */
+
+extern int opterr;
+
+/* Set to an option character which was unrecognized.  */
+
+extern int optopt;
+
+#ifndef __need_getopt
+/* Describe the long-named options requested by the application.
+   The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
+   of `struct option' terminated by an element containing a name which is
+   zero.
+
+   The field `has_arg' is:
+   no_argument		(or 0) if the option does not take an argument,
+   required_argument	(or 1) if the option requires an argument,
+   optional_argument	(or 2) if the option takes an optional argument.
+
+   If the field `flag' is not NULL, it points to a variable that is set
+   to the value given in the field `val' when the option is found, but
+   left unchanged if the option is not found.
+
+   To have a long-named option do something other than set an `int' to
+   a compiled-in constant, such as set a value from `optarg', set the
+   option's `flag' field to zero and its `val' field to a nonzero
+   value (the equivalent single-letter option character, if there is
+   one).  For long options that have a zero `flag' field, `getopt'
+   returns the contents of the `val' field.  */
+
+struct option
+{
+  const char *name;
+  /* has_arg can't be an enum because some compilers complain about
+     type mismatches in all the code that assumes it is an int.  */
+  int has_arg;
+  int *flag;
+  int val;
+};
+
+/* Names for the values of the `has_arg' field of `struct option'.  */
+
+# define no_argument		0
+# define required_argument	1
+# define optional_argument	2
+#endif	/* need getopt */
+
+
+/* Get definitions and prototypes for functions to process the
+   arguments in ARGV (ARGC of them, minus the program name) for
+   options given in OPTS.
+
+   Return the option character from OPTS just read.  Return -1 when
+   there are no more options.  For unrecognized options, or options
+   missing arguments, `optopt' is set to the option letter, and '?' is
+   returned.
+
+   The OPTS string is a list of characters which are recognized option
+   letters, optionally followed by colons, specifying that that letter
+   takes an argument, to be placed in `optarg'.
+
+   If a letter in OPTS is followed by two colons, its argument is
+   optional.  This behavior is specific to the GNU `getopt'.
+
+   The argument `--' causes premature termination of argument
+   scanning, explicitly telling `getopt' that there are no more
+   options.
+
+   If OPTS begins with `--', then non-option arguments are treated as
+   arguments to the option '\0'.  This behavior is specific to the GNU
+   `getopt'.  */
+
+extern int getopt (int ___argc, char *const *___argv, const char *__shortopts)
+       __THROW;
+
+#ifndef __need_getopt
+extern int getopt_long (int ___argc, char *__getopt_argv_const *___argv,
+			const char *__shortopts,
+		        const struct option *__longopts, int *__longind)
+       __THROW;
+extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv,
+			     const char *__shortopts,
+		             const struct option *__longopts, int *__longind)
+       __THROW;
+
+#endif
+
+#ifdef	__cplusplus
+}
+#endif
+
+/* Make sure we later can get all the definitions and declarations.  */
+#undef __need_getopt
+
+#endif /* getopt.h */
+
+/* arch-tag: e36f5607-3ac6-4cdc-9aa7-c26c6525fe9b
+   (do not change this comment) */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lib-src/getopt_int.h	Fri Jul 29 01:54:54 2005 +0000
@@ -0,0 +1,134 @@
+/* Internal declarations for getopt.
+   Copyright (C) 1989-1994,1996-1999,2001,2003,2004
+   Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   This program 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.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License along
+   with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#ifndef _GETOPT_INT_H
+#define _GETOPT_INT_H	1
+
+extern int _getopt_internal (int ___argc, char **___argv,
+			     const char *__shortopts,
+		             const struct option *__longopts, int *__longind,
+			     int __long_only, int __posixly_correct);
+
+
+/* Reentrant versions which can handle parsing multiple argument
+   vectors at the same time.  */
+
+/* Data type for reentrant functions.  */
+struct _getopt_data
+{
+  /* These have exactly the same meaning as the corresponding global
+     variables, except that they are used for the reentrant
+     versions of getopt.  */
+  int optind;
+  int opterr;
+  int optopt;
+  char *optarg;
+
+  /* Internal members.  */
+
+  /* True if the internal members have been initialized.  */
+  int __initialized;
+
+  /* The next char to be scanned in the option-element
+     in which the last option character we returned was found.
+     This allows us to pick up the scan where we left off.
+
+     If this is zero, or a null string, it means resume the scan
+     by advancing to the next ARGV-element.  */
+  char *__nextchar;
+
+  /* Describe how to deal with options that follow non-option ARGV-elements.
+
+     If the caller did not specify anything,
+     the default is REQUIRE_ORDER if the environment variable
+     POSIXLY_CORRECT is defined, PERMUTE otherwise.
+
+     REQUIRE_ORDER means don't recognize them as options;
+     stop option processing when the first non-option is seen.
+     This is what Unix does.
+     This mode of operation is selected by either setting the environment
+     variable POSIXLY_CORRECT, or using `+' as the first character
+     of the list of option characters, or by calling getopt.
+
+     PERMUTE is the default.  We permute the contents of ARGV as we
+     scan, so that eventually all the non-options are at the end.
+     This allows options to be given in any order, even with programs
+     that were not written to expect this.
+
+     RETURN_IN_ORDER is an option available to programs that were
+     written to expect options and other ARGV-elements in any order
+     and that care about the ordering of the two.  We describe each
+     non-option ARGV-element as if it were the argument of an option
+     with character code 1.  Using `-' as the first character of the
+     list of option characters selects this mode of operation.
+
+     The special argument `--' forces an end of option-scanning regardless
+     of the value of `ordering'.  In the case of RETURN_IN_ORDER, only
+     `--' can cause `getopt' to return -1 with `optind' != ARGC.  */
+
+  enum
+    {
+      REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
+    } __ordering;
+
+  /* If the POSIXLY_CORRECT environment variable is set
+     or getopt was called.  */
+  int __posixly_correct;
+
+
+  /* Handle permutation of arguments.  */
+
+  /* Describe the part of ARGV that contains non-options that have
+     been skipped.  `first_nonopt' is the index in ARGV of the first
+     of them; `last_nonopt' is the index after the last of them.  */
+
+  int __first_nonopt;
+  int __last_nonopt;
+
+#if defined _LIBC && defined USE_NONOPTION_FLAGS
+  int __nonoption_flags_max_len;
+  int __nonoption_flags_len;
+# endif
+};
+
+/* The initializer is necessary to set OPTIND and OPTERR to their
+   default values and to clear the initialization flag.  */
+#define _GETOPT_DATA_INITIALIZER	{ 1, 1 }
+
+extern int _getopt_internal_r (int ___argc, char **___argv,
+			       const char *__shortopts,
+			       const struct option *__longopts, int *__longind,
+			       int __long_only, int __posixly_correct,
+			       struct _getopt_data *__data);
+
+extern int _getopt_long_r (int ___argc, char **___argv,
+			   const char *__shortopts,
+			   const struct option *__longopts, int *__longind,
+			   struct _getopt_data *__data);
+
+extern int _getopt_long_only_r (int ___argc, char **___argv,
+				const char *__shortopts,
+				const struct option *__longopts,
+				int *__longind,
+				struct _getopt_data *__data);
+
+#endif /* getopt_int.h */
+
+/* arch-tag: 8bfc548f-23d6-46aa-b5b5-2739b0edaf79
+   (do not change this comment) */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lib-src/gettext.h	Fri Jul 29 01:54:54 2005 +0000
@@ -0,0 +1,81 @@
+/* Convenience header for conditional use of GNU <libintl.h>.
+   Copyright (C) 1995-1998, 2000-2002, 2004 Free Software Foundation, Inc.
+
+   This program 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.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License along
+   with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#ifndef _LIBGETTEXT_H
+#define _LIBGETTEXT_H 1
+
+/* NLS can be disabled through the configure --disable-nls option.  */
+#if ENABLE_NLS
+
+/* Get declarations of GNU message catalog functions.  */
+# include <libintl.h>
+
+#else
+
+/* Solaris /usr/include/locale.h includes /usr/include/libintl.h, which
+   chokes if dcgettext is defined as a macro.  So include it now, to make
+   later inclusions of <locale.h> a NOP.  We don't include <libintl.h>
+   as well because people using "gettext.h" will not include <libintl.h>,
+   and also including <libintl.h> would fail on SunOS 4, whereas <locale.h>
+   is OK.  */
+#if defined(__sun)
+# include <locale.h>
+#endif
+
+/* Many header files from the libstdc++ coming with g++ 3.3 or newer include
+   <libintl.h>, which chokes if dcgettext is defined as a macro.  So include
+   it now, to make later inclusions of <libintl.h> a NOP.  */
+#if defined(__cplusplus) && defined(__GNUG__) && (__GNUC__ >= 3)
+# include <cstdlib>
+# if (__GLIBC__ >= 2) || _GLIBCXX_HAVE_LIBINTL_H
+#  include <libintl.h>
+# endif
+#endif
+
+/* Disabled NLS.
+   The casts to 'const char *' serve the purpose of producing warnings
+   for invalid uses of the value returned from these functions.
+   On pre-ANSI systems without 'const', the config.h file is supposed to
+   contain "#define const".  */
+# define gettext(Msgid) ((const char *) (Msgid))
+# define dgettext(Domainname, Msgid) ((const char *) (Msgid))
+# define dcgettext(Domainname, Msgid, Category) ((const char *) (Msgid))
+# define ngettext(Msgid1, Msgid2, N) \
+    ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
+# define dngettext(Domainname, Msgid1, Msgid2, N) \
+    ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
+# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \
+    ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
+# define textdomain(Domainname) ((const char *) (Domainname))
+# define bindtextdomain(Domainname, Dirname) ((const char *) (Dirname))
+# define bind_textdomain_codeset(Domainname, Codeset) ((const char *) (Codeset))
+
+#endif
+
+/* A pseudo function call that serves as a marker for the automated
+   extraction of messages, but does not call gettext().  The run-time
+   translation is done at a different place in the code.
+   The argument, String, should be a literal string.  Concatenated strings
+   and other string expressions won't work.
+   The macro's expansion is not parenthesized, so that it is suitable as
+   initializer for static 'char[]' or 'const char[]' variables.  */
+#define gettext_noop(String) String
+
+#endif /* _LIBGETTEXT_H */
+
+/* arch-tag: 3d01bb8e-82e3-4674-9812-de4c4224f7d1
+   (do not change this comment) */
--- a/lib-src/makefile.w32-in	Tue Jul 26 12:03:19 2005 +0000
+++ b/lib-src/makefile.w32-in	Fri Jul 29 01:54:54 2005 +0000
@@ -286,6 +286,7 @@
 clean:
 		- $(DEL) *~ DOC* $(COMPILER_TEMP_FILES)
 		- $(DEL) ctags.c
+		- $(DEL) getopt.h
 		- $(DEL_TREE) $(OBJDIR)
 
 cleanall:	clean
@@ -301,6 +302,8 @@
 			$(CP) $(ALL_DEPS) $@
 ../src/paths.h:		../nt/paths.h
 			$(CP) $(ALL_DEPS) $@
+getopt.h:		getopt_.h
+			$(CP) $(ALL_DEPS) $@
 
 ### DEPENDENCIES ###
 
--- a/lisp/ChangeLog	Tue Jul 26 12:03:19 2005 +0000
+++ b/lisp/ChangeLog	Fri Jul 29 01:54:54 2005 +0000
@@ -1,3 +1,173 @@
+2005-07-28  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* net/ange-ftp.el (ange-ftp-gateway-fatal-msgs)
+	(ange-ftp-pending-error-line): New vars.
+	(ange-ftp-process-handle-line, ange-ftp-process-filter): Use them
+	to handle the non-fatal no-route-to-host messages.
+	(internal-ange-ftp-mode): Make the no-match regexp more efficient.
+
+2005-07-28  Juanma Barranquero  <lekktu@gmail.com>
+
+	* isearch.el (isearch-mode-map, isearch-other-meta-char)
+	(isearch-quote-char, isearch-printing-char)
+	(isearch-text-char-description): "?\ " -> "?\s".
+	(isearch-lazy-highlight-cleanup)
+	(isearch-lazy-highlight-initial-delay)
+	(isearch-lazy-highlight-interval)
+	(isearch-lazy-highlight-max-at-a-time)
+	(isearch-lazy-highlight-face, isearch-lazy-highlight-cleanup):
+	Declare with define-obsolete-*-alias macros.
+	(isearch-forward): Fix typo in docstring.
+	(search-invisible, search-ring-yank-pointer)
+	(regexp-search-ring-yank-pointer): Doc fixes.
+
+	* recentf.el (recentf-menu-append-commands-p): Declare with
+	`define-obsolete-variable-alias'.
+	(recentf-max-saved-items, recentf-menu-filter)
+	(recentf-arrange-by-rule-subfilter): Doc fixes.
+	(recentf-menu-append-commands-flag)
+	(recentf-initialize-file-name-history, recentf-expand-file-name)
+	(recentf-clear-data): Fix typos in docstrings.
+
+2005-07-28  Nick Roberts  <nickrob@snap.net.nz>
+
+	* progmodes/gdb-ui.el: Smarten comments.
+	(gdb-info-breakpoints-custom): Use nowarn when finding file.
+
+2005-07-27  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* term/apollo.el (terminal-init-apollo): New function containing
+	all former top level forms in the file.
+	* term/bobcat.el (terminal-init-bobcat):
+	* term/cygwin.el (terminal-init-cygwin):
+	* term/iris-ansi.el (terminal-init-iris-ansi):
+	* term/linux.el (terminal-init-linux):
+	* term/news.el (terminal-init-news):
+	* term/rxvt.el (terminal-init-rxvt):
+	* term/sun.el (terminal-init-sun):
+	* term/tvi970.el (terminal-init-tvi970):
+	* term/vt100.el (terminal-init-vt100):
+	* term/vt102.el (terminal-init-vt102):
+	* term/vt125.el (terminal-init-vt125):
+	* term/vt200.el (terminal-init-vt200):
+	* term/vt201.el (terminal-init-vt201):
+	* term/vt220.el (terminal-init-vt220):
+	* term/vt240.el (terminal-init-vt240):
+	* term/vt300.el (terminal-init-vt300):
+	* term/vt320.el (terminal-init-vt320):
+	* term/vt400.el (terminal-init-vt400):
+	* term/vt420.el (terminal-init-vt420):
+	* term/wyse50.el (terminal-init-wyse50):
+	* term/xterm.el (terminal-init-xterm): Likewise.
+
+	* term/README: Describe the terminal-init-* functionality.
+
+	* startup.el (command-line): After loading the terminal
+	initialization file call the corresponding terminal initialization
+	function.
+
+2005-07-27  Kenichi Handa  <handa@m17n.org>
+
+	* ps-bdf.el (bdf-read-font-info): Ignore glyphs whose ENCODING is
+	negative.
+
+	* ps-mule.el (ps-mule-bitmap-prologue): Fix arguments to
+	setcharwidth.
+	(ps-mule-composition-prologue): Fix for the case that
+	RelativeCompose is false.
+
+2005-07-26  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* smerge-mode.el (smerge-ediff): Use insert-buffer-substring.
+
+	* descr-text.el (describe-char): Handle the case where the list of
+	chars is displayed in a separate frame.
+	Be a bit more discriminating when looking for the char.
+
+2005-07-26  Juanma Barranquero  <lekktu@gmail.com>
+
+	* bookmark.el (bookmark-automatically-show-annotations)
+	(bookmark-read-annotation-text-func): Doc fixes.
+	(bookmark-save): Improve argument/docstring consistency.
+	(bookmark-get-bookmark, bookmark-get-bookmark-record)
+	(bookmark-alist-from-buffer)
+	(bookmark-upgrade-file-format-from-0)
+	(bookmark-grok-file-format-version)
+	(bookmark-maybe-upgrade-file-format, bookmark-kill-line)
+	(bookmark-read-annotation-mode)
+	(bookmark-insert-current-bookmark, bookmark-jump)
+	(bookmark-exit-hook): Fix typos in docstrings.
+	(bookmark-exit-hooks): Define as obsolete alias.
+	(bookmark-exit-hook-internal): Run `bookmark-exit-hook',
+	not `bookmark-exit-hooks'.  Fix docstring.
+	(bookmark-bmenu-select): "?\ " -> "?\s".
+
+2005-07-25  Ari Roponen <arjuropo@cc.jyu.fi>  (tiny change)
+
+	* startup.el (command-line): Fix typo.
+
+2005-07-24  Richard M. Stallman  <rms@gnu.org>
+
+	* tooltip.el (tooltip-mode): Test emacs-basic-display,
+	not emacs-quick-startup.
+
+2005-07-24  Juanma Barranquero  <lekktu@gmail.com>
+
+	* emacs-lisp/re-builder.el (reb-with-current-window): Delete.
+	(reb-next-match, reb-show-subexp): Use `with-selected-window'
+	instead of `reb-with-current-window'.
+	(reb-prev-match): Likewise.  Also, don't move left if the search
+	was unsuccessful.
+	(reb-initialize-buffer): New function.
+	(re-builder, reb-change-syntax): Use it.
+
+	* man.el (Man-goto-page): Make second argument NOERROR optional.
+
+2005-07-23  Richard M. Stallman  <rms@gnu.org>
+
+	* man.el (Man-bgproc-sentinel): Check here for failure to find
+	any man page in the output, and report the error here.
+	(Man-arguments): Make it permanent local.
+	(Man-goto-page): New arg NOERROR.  Never kill the current buffer.
+	(Man-mode): Pass t for NOERROR.
+
+	* progmodes/grep.el (grep-error-face): Use font-lock-keyword-face.
+	(grep-mode-font-lock-keywords):
+	Don't use compilation-...-face for messages that are not file names.
+
+	* progmodes/compile.el (compilation-mode-font-lock-keywords):
+	Don't use compilation-...-face for messages that are not file names.
+
+2005-07-22  Juri Linkov  <juri@jurta.org>
+
+	* simple.el (line-move-1): Fix comments.
+
+	* startup.el (normal-splash-screen): Update menu name.
+
+	* tempo.el (tempo-insert-template): Fix 2005-07-16 change.
+
+2005-07-22  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* term/xterm.el: Load term/rxvt if the terminal is actually an
+	rxvt terminal.
+	(xterm-rxvt-set-background-mode): Remove, not used anymore.
+
+	* term/rxvt.el (function-key-map): Use substitute-key-definition
+	to bind {C,S,C-S}-{f1-f10}. Add a few missing key bindings.
+
+	* term/cygwin.el: New file.
+
+2005-07-22  Kim F. Storm  <storm@cua.dk>
+
+	* image-file.el (insert-image-file, image-file-yank-handler):
+	Fix last change to maintain a (unique) yank-handler on yanked images.
+
+2005-07-22  Eduardo Mu,Aq(Boz  <emufer@terra.es>  (tiny change)
+
+	* dired.el (dired-move-to-filename-regexp): Recognize the B suffix
+	of the file size (as in "177B" for 177 bytes).  This happens with
+	"ls -lh" on FreeBSD.
+
 2005-07-22  Juanma Barranquero  <lekktu@gmail.com>
 
 	* hilit-chg.el (highlight-changes-global-initial-state)
@@ -215,20 +385,20 @@
 
 	* textmodes/org.el (org-table-column-names)
 	(org-table-column-name-regexp)
-        (org-table-named-field-locations): New variables.
-        (org-archive-subtree): Protect `this-command' when calling
+	(org-table-named-field-locations): New variables.
+	(org-archive-subtree): Protect `this-command' when calling
 	`org-copy-subtree' and `org-cut-subtree', to avoid appending to
 	the kill buffer.
-        (org-complete): Remove fixed-formula completion.
-        (org-edit-formulas-map): New variable.
-        (org-table-edit-formulas): New command.
-        (org-finish-edit-formulas, org-abort-edit-formulas)
+	(org-complete): Remove fixed-formula completion.
+	(org-edit-formulas-map): New variable.
+	(org-table-edit-formulas): New command.
+	(org-finish-edit-formulas, org-abort-edit-formulas)
 	(org-show-variable, org-table-get-vertical-vector): New functions.
-        (org-table-maybe-eval-formula): Handle `:=' fields.
-        (org-table-get-stored-formulas, org-table-store-formulas)
-        (org-table-get-formula, org-table-modify-formulas)
-        (org-table-replace-in-formulas): Handle named field formulas.
-        (org-table-get-specials): Store locations of named fields.
+	(org-table-maybe-eval-formula): Handle `:=' fields.
+	(org-table-get-stored-formulas, org-table-store-formulas)
+	(org-table-get-formula, org-table-modify-formulas)
+	(org-table-replace-in-formulas): Handle named field formulas.
+	(org-table-get-specials): Store locations of named fields.
 
 2005-07-19  Juri Linkov  <juri@jurta.org>
 
@@ -290,8 +460,8 @@
 	more than 88 colors.  Use green for light backgrounds with
 	8 colors, and yellow for dark backgrounds with 8 colors.
 
-	* font-lock.el (font-lock-regexp-grouping-backslash): Don't
-	inherit from escape-glyph (use bold for all cases).
+	* font-lock.el (font-lock-regexp-grouping-backslash):
+	Don't inherit from escape-glyph (use bold for all cases).
 
 	* info.el (info-xref-visited): Use light foreground color `violet'
 	for dark backgrounds instead of dark color `magenta3'.
@@ -388,8 +558,8 @@
 	`insert-buffer'.
 
 	* calendar/icalendar.el (icalendar--get-unfolded-buffer):
-	* progmodes/ada-mode.el (ada-make-body): Use
-	`insert-buffer-substring' and `goto-char', not `insert-buffer'.
+	* progmodes/ada-mode.el (ada-make-body):
+	Use `insert-buffer-substring' and `goto-char', not `insert-buffer'.
 
 	* dired.el (dired-log):
 	* tar-mode.el (tar-subfile-save-buffer):
@@ -483,8 +653,8 @@
 
 	* emulation/viper-init.el (viper-activate-input-method): Avoid warning.
 
-	* emacs-lisp/re-builder.el (reb-cook-regexp): Avoid
-	warning calling lre-compile-string.
+	* emacs-lisp/re-builder.el (reb-cook-regexp):
+	Avoid warning calling lre-compile-string.
 	(reb-color-display-p): Avoid warning.
 
 	* calculator.el (calculator-last-input): Guard uses
@@ -501,8 +671,8 @@
 	(checkdoc-overlay-start, checkdoc-overlay-end)
 	(checkdoc-mode-line-update, checkdoc-char=):
 	Define such that compiler knows they are defined.
-	(checkdoc-call-eval-buffer): Deleted.  Use eval-buffer directly.
-	(checkdoc-read-event): Deleted.  Use read-event directly.
+	(checkdoc-call-eval-buffer): Delete.  Use eval-buffer directly.
+	(checkdoc-read-event): Delete.  Use read-event directly.
 
 	* whitespace.el (whitespace-make-overlay)
 	(whitespace-overlay-put, whitespace-delete-overlay)
--- a/lisp/bookmark.el	Tue Jul 26 12:03:19 2005 +0000
+++ b/lisp/bookmark.el	Fri Jul 29 01:54:54 2005 +0000
@@ -169,7 +169,7 @@
 
 
 (defcustom bookmark-automatically-show-annotations t
-  "*nil means don't show annotations when jumping to a bookmark."
+  "*Non-nil means show annotations when jumping to a bookmark."
   :type 'boolean
   :group 'bookmark)
 
@@ -333,14 +333,14 @@
 
 
 (defun bookmark-get-bookmark (bookmark)
-  "Return the full entry for BOOKMARK in bookmark-alist.
+  "Return the full entry for BOOKMARK in `bookmark-alist'.
 If BOOKMARK is not a string, return nil."
   (when (stringp bookmark)
     (assoc-string bookmark bookmark-alist bookmark-completion-ignore-case)))
 
 
 (defun bookmark-get-bookmark-record (bookmark)
-  "Return the guts of the entry for BOOKMARK in bookmark-alist.
+  "Return the guts of the entry for BOOKMARK in `bookmark-alist'.
 That is, all information but the name."
   (car (cdr (bookmark-get-bookmark bookmark))))
 
@@ -443,8 +443,7 @@
              (list (cons 'info-node node)))))
 
   (message "%S" (assq 'info-node (bookmark-get-bookmark-record bookmark)))
-  (sit-for 4)
-  )
+  (sit-for 4))
 
 
 (defvar bookmark-history nil
@@ -619,7 +618,7 @@
 
 
 (defun bookmark-alist-from-buffer ()
-  "Return a bookmark-alist (in any format) from the current buffer.
+  "Return a `bookmark-alist' (in any format) from the current buffer.
 The buffer must of course contain bookmark format information.
 Does not care from where in the buffer it is called, and does not
 affect point."
@@ -659,7 +658,7 @@
 
 (defun bookmark-upgrade-file-format-from-0 ()
   "Upgrade a bookmark file of format 0 (the original format) to format 1.
-This expects to be called from point-min in a bookmark file."
+This expects to be called from `point-min' in a bookmark file."
   (message "Upgrading bookmark format from 0 to %d..."
            bookmark-file-format-version)
   (let* ((old-list (bookmark-alist-from-buffer))
@@ -676,7 +675,7 @@
 
 (defun bookmark-grok-file-format-version ()
   "Return an integer which is the file-format version of this bookmark file.
-This expects to be called from point-min in a bookmark file."
+This expects to be called from `point-min' in a bookmark file."
   (if (looking-at "^;;;;")
       (save-excursion
         (save-match-data
@@ -691,7 +690,7 @@
 (defun bookmark-maybe-upgrade-file-format ()
   "Check the file-format version of this bookmark file.
 If the version is not up-to-date, upgrade it automatically.
-This expects to be called from point-min in a bookmark file."
+This expects to be called from `point-min' in a bookmark file."
   (let ((version (bookmark-grok-file-format-version)))
     (cond
      ((= version bookmark-file-format-version)
@@ -783,7 +782,7 @@
 (defun bookmark-kill-line (&optional newline-too)
   "Kill from point to end of line.
 If optional arg NEWLINE-TOO is non-nil, delete the newline too.
-Does not affect the kill-ring."
+Does not affect the kill ring."
   (let ((eol (save-excursion (end-of-line) (point))))
     (delete-region (point) eol)
     (if (and newline-too (looking-at "\n"))
@@ -842,11 +841,11 @@
 
 (defvar bookmark-read-annotation-text-func 'bookmark-default-annotation-text
   "Function to return default text to use for a bookmark annotation.
-It takes the name of the bookmark, as a string, as an arg.")
+It takes one argument, the name of the bookmark, as a string.")
 
 (defun bookmark-read-annotation-mode (buf point parg bookmark)
   "Mode for composing annotations for a bookmark.
-Wants BUF POINT PARG and BOOKMARK.
+Wants BUF, POINT, PARG, and BOOKMARK.
 When you have finished composing, type \\[bookmark-send-annotation] to send
 the annotation.
 
@@ -933,7 +932,7 @@
 
 
 (defun bookmark-insert-current-bookmark ()
-  "Insert this buffer's value of bookmark-current-bookmark.
+  "Insert this buffer's value of `bookmark-current-bookmark'.
 Default to file name if it's nil."
   (interactive)
   (let ((str
@@ -1044,7 +1043,7 @@
 this.
 
 If the file pointed to by BOOKMARK no longer exists, you will be asked
-if you wish to give the bookmark a new location, and bookmark-jump
+if you wish to give the bookmark a new location, and `bookmark-jump'
 will then jump to the new location, as well as recording it in place
 of the old one in the permanent bookmark record."
   (interactive
@@ -1304,8 +1303,8 @@
 `bookmark-default-file'.  With a prefix arg, save it in file FILE
 \(second argument\).
 
-If you are calling this from Lisp, the two arguments are PREFIX-ARG
-and FILE, and if you just want it to write to the default file, then
+If you are calling this from Lisp, the two arguments are PARG and
+FILE, and if you just want it to write to the default file, then
 pass no arguments.  Or pass in nil and FILE, and it will save in FILE
 instead.  If you pass in one argument, and it is non-nil, then the
 user will be interactively queried for a file to save in.
@@ -1804,7 +1803,7 @@
           (setq tem (bookmark-bmenu-bookmark))
           (let ((inhibit-read-only t))
             (delete-char -1)
-            (insert ?\ ))
+            (insert ?\s))
           (or (string-equal tem bmrk)
               (member tem others)
               (setq others (cons tem others))))
@@ -2093,7 +2092,7 @@
 	       (format "-*- %s (%d) -*-" name iter)
 	       (nreverse lst))
 	      pane-list)))
-    
+
     ;; Popup the menu and return the string.
     (x-popup-menu event (cons (concat "-*- " name " -*-")
 			      (nreverse pane-list)))))
@@ -2141,12 +2140,14 @@
 
 ;;; Exit Hook, called from kill-emacs-hook
 (defvar bookmark-exit-hook nil
-  "Hook run when emacs exits.")
+  "Hook run when Emacs exits.")
+
+(define-obsolete-variable-alias 'bookmark-exit-hooks 'bookmark-exit-hook "22.1")
 
 (defun bookmark-exit-hook-internal ()
   "Save bookmark state, if necessary, at Emacs exit time.
-This also runs `bookmark-exit-hooks'."
-  (run-hooks 'bookmark-exit-hooks)
+This also runs `bookmark-exit-hook'."
+  (run-hooks 'bookmark-exit-hook)
   (and bookmark-alist
        (bookmark-time-to-save-p t)
        (bookmark-save)))
--- a/lisp/dired.el	Tue Jul 26 12:03:19 2005 +0000
+++ b/lisp/dired.el	Fri Jul 29 01:54:54 2005 +0000
@@ -1865,11 +1865,11 @@
 	 ;; The "[0-9]" below requires the previous column to end in a digit.
 	 ;; This avoids recognizing `1 may 1997' as a date in the line:
 	 ;; -r--r--r--   1 may      1997        1168 Oct 19 16:49 README
-	 ;; The "[kKMGTPEZY]?" below supports "ls -alh" output.
+	 ;; The "[BkKMGTPEZY]?" below supports "ls -alh" output.
 	 ;; The ".*" below finds the last match if there are multiple matches.
 	 ;; This avoids recognizing `jservice  10  1024' as a date in the line:
 	 ;; drwxr-xr-x  3 jservice  10  1024 Jul  2  1997 esg-host
-    (concat ".*[0-9][kKMGTPEZY]?" s
+    (concat ".*[0-9][BkKMGTPEZY]?" s
 	    "\\(" western "\\|" western-comma "\\|" japanese "\\|" iso "\\)"
 	    s "+"))
   "Regular expression to match up to the file name in a directory listing.
--- a/lisp/emacs-lisp/re-builder.el	Tue Jul 26 12:03:19 2005 +0000
+++ b/lisp/emacs-lisp/re-builder.el	Fri Jul 29 01:54:54 2005 +0000
@@ -299,20 +299,6 @@
   (add-hook 'kill-buffer-hook 'reb-kill-buffer)
   (reb-auto-update nil nil nil))
 
-
-;; Handy macro for doing things in other windows
-(defmacro reb-with-current-window (window &rest body)
-  "With WINDOW selected evaluate BODY forms and reselect previous window."
-
-  (let ((oldwindow (make-symbol "*oldwindow*")))
-    `(let ((,oldwindow (selected-window)))
-       (select-window ,window)
-       (unwind-protect
-	   (progn
-	     ,@body)
-	 (select-window ,oldwindow)))))
-(put 'reb-with-current-window 'lisp-indent-function 0)
-
 (defun reb-color-display-p ()
   "Return t if display is capable of displaying colors."
   (eq 'color
@@ -330,6 +316,15 @@
   "Return binding for SYMBOL in the RE Builder target buffer."
   `(with-current-buffer reb-target-buffer ,symbol))
 
+(defun reb-initialize-buffer ()
+  "Initialize the current buffer as a RE Builder buffer."
+  (erase-buffer)
+  (reb-insert-regexp)
+  (goto-char (+ 2 (point-min)))
+  (cond ((reb-lisp-syntax-p)
+         (reb-lisp-mode))
+        (t (reb-mode))))
+
 ;;; This is to help people find this in Apropos.
 ;;;###autoload
 (defalias 'regexp-builder 're-builder)
@@ -349,13 +344,7 @@
           reb-window-config (current-window-configuration))
     (select-window (split-window (selected-window) (- (window-height) 4)))
     (switch-to-buffer (get-buffer-create reb-buffer))
-    (erase-buffer)
-    (reb-insert-regexp)
-    (goto-char (+ 2 (point-min)))
-    (cond
-     ((reb-lisp-syntax-p)
-      (reb-lisp-mode))
-     (t (reb-mode)))))
+    (reb-initialize-buffer)))
 
 (defun reb-change-target-buffer (buf)
   "Change the target buffer and display it in the target window."
@@ -393,8 +382,7 @@
   (interactive)
 
   (reb-assert-buffer-in-window)
-  (reb-with-current-window
-    reb-target-window
+  (with-selected-window reb-target-window
     (if (not (re-search-forward reb-regexp (point-max) t))
 	(message "No more matches.")
       (reb-show-subexp
@@ -406,13 +394,15 @@
   (interactive)
 
   (reb-assert-buffer-in-window)
-  (reb-with-current-window reb-target-window
-    (goto-char (1- (point)))
-    (if (not (re-search-backward reb-regexp (point-min) t))
-	(message "No more matches.")
-      (reb-show-subexp
-       (or (and reb-subexp-mode reb-subexp-displayed) 0)
-       t))))
+  (with-selected-window reb-target-window
+    (let ((p (point)))
+      (goto-char (1- p))
+      (if (re-search-backward reb-regexp (point-min) t)
+          (reb-show-subexp
+           (or (and reb-subexp-mode reb-subexp-displayed) 0)
+           t)
+        (goto-char p)
+        (message "No more matches.")))))
 
 (defun reb-toggle-case ()
   "Toggle case sensitivity of searches for RE Builder target buffer."
@@ -449,7 +439,7 @@
 the match should already be marked by an overlay.
 On other displays jump to the beginning and the end of it.
 If the optional PAUSE is non-nil then pause at the end in any case."
-  (reb-with-current-window reb-target-window
+  (with-selected-window reb-target-window
     (if (not (reb-color-display-p))
 	(progn (goto-char (match-beginning subexp))
 	       (sit-for reb-blink-delay)))
@@ -479,14 +469,9 @@
   (if (memq syntax '(read string lisp-re sregex rx))
       (let ((buffer (get-buffer reb-buffer)))
 	(setq reb-re-syntax syntax)
-	(if buffer
-	    (with-current-buffer buffer
-	      (erase-buffer)
-	      (reb-insert-regexp)
-	      (goto-char (+ 2 (point-min)))
-	      (cond ((reb-lisp-syntax-p)
-		     (reb-lisp-mode))
-		    (t (reb-mode))))))
+	(when buffer
+          (with-current-buffer buffer
+            (reb-initialize-buffer))))
     (error "Invalid syntax: %s" syntax)))
 
 
--- a/lisp/gnus/ChangeLog	Tue Jul 26 12:03:19 2005 +0000
+++ b/lisp/gnus/ChangeLog	Fri Jul 29 01:54:54 2005 +0000
@@ -1,3 +1,36 @@
+2005-07-28  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+	* rfc2231.el (rfc2231-parse-string): Take care that not only a
+	segmented parameter but also other parameters might be there.
+
+2005-07-26  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+	* gnus-art.el (gnus-article-next-page-1): Don't scroll if there're
+	fewer lines than that of scroll-margin.
+	(gnus-article-prev-page): Narrow the range to bind scroll-in-place.
+
+2005-07-25  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+	* gnus-art.el (gnus-article-next-page): Revert.
+	(gnus-article-beginning-of-window): New macro.
+	(gnus-article-next-page-1): Use it.
+	(gnus-article-prev-page): Ditto.
+	(gnus-mime-save-part-and-strip): Use insert-buffer-substring
+	instead of insert-buffer.
+	(gnus-mime-delete-part): Ditto.
+	(gnus-article-edit-exit): Ditto.
+
+	* gnus-util.el (gnus-beginning-of-window): Remove.
+	(gnus-end-of-window): Remove.
+
+	* lpath.el: Don't bind scroll-margin.
+
+2005-07-25  Simon Josefsson  <jas@extundo.com>
+
+	* pgg.el (pgg-insert-url-with-w3): Don't load w3, it is possible
+	to have the url package without w3.  Reported by Daiki Ueno
+	<ueno@unixuser.org> and Luigi Panzeri <matley@muppetslab.org>.
+
 2005-07-21  Stefan Monnier  <monnier@iro.umontreal.ca>
 
 	* mml.el (mml-minibuffer-read-disposition): Don't use inline by default
--- a/lisp/gnus/gnus-art.el	Tue Jul 26 12:03:19 2005 +0000
+++ b/lisp/gnus/gnus-art.el	Fri Jul 29 01:54:54 2005 +0000
@@ -4117,7 +4117,7 @@
 		       ',gnus-newsgroup-ignored-charsets))
 		  (mbl mml-buffer-list))
 	      (setq mml-buffer-list nil)
-	      (insert-buffer gnus-original-article-buffer)
+	      (insert-buffer-substring gnus-original-article-buffer)
 	      (mime-to-mml ',handles)
 	      (setq gnus-article-mime-handles nil)
 	      (let ((mbl1 mml-buffer-list))
@@ -4199,7 +4199,7 @@
 		     ',gnus-newsgroup-ignored-charsets))
 		(mbl mml-buffer-list))
 	    (setq mml-buffer-list nil)
-	    (insert-buffer gnus-original-article-buffer)
+	    (insert-buffer-substring gnus-original-article-buffer)
 	    (mime-to-mml ',handles)
 	    (setq gnus-article-mime-handles nil)
 	    (let ((mbl1 mml-buffer-list))
@@ -5160,7 +5160,7 @@
 If end of article, return non-nil.  Otherwise return nil.
 Argument LINES specifies lines to be scrolled up."
   (interactive "p")
-  (gnus-end-of-window)
+  (move-to-window-line -1)
   (if (save-excursion
 	(end-of-line)
 	(and (pos-visible-in-window-p)	;Not continuation line.
@@ -5182,20 +5182,38 @@
     (gnus-article-next-page-1 lines)
     nil))
 
+(defmacro gnus-article-beginning-of-window ()
+  "Move point to the beginning of the window.
+In Emacs, the point is placed at the line number which `scroll-margin'
+specifies."
+  (if (featurep 'xemacs)
+      '(move-to-window-line 0)
+    '(move-to-window-line
+      (min (max 0 scroll-margin)
+	   (max 1 (- (window-height)
+		     (if mode-line-format 1 0)
+		     (if (and (boundp 'header-line-format)
+			      (symbol-value 'header-line-format))
+			 1 0)))))))
+
 (defun gnus-article-next-page-1 (lines)
-  (let ((scroll-in-place nil))
+  (unless (and (not (featurep 'xemacs))
+	       (> (symbol-value 'scroll-margin) 0)
+	       (<= (count-lines (window-start) (point-max))
+		   (symbol-value 'scroll-margin)))
     (condition-case ()
-	(scroll-up lines)
+	(let ((scroll-in-place nil))
+	  (scroll-up lines))
       (end-of-buffer
        ;; Long lines may cause an end-of-buffer error.
-       (goto-char (point-max)))))
-  (gnus-beginning-of-window))
+       (goto-char (point-max))))
+    (gnus-article-beginning-of-window)))
 
 (defun gnus-article-prev-page (&optional lines)
   "Show previous page of current article.
 Argument LINES specifies lines to be scrolled down."
   (interactive "p")
-  (gnus-beginning-of-window)
+  (move-to-window-line 0)
   (if (and gnus-page-broken
 	   (bobp)
 	   (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
@@ -5203,13 +5221,13 @@
 	(gnus-narrow-to-page -1)	;Go to previous page.
 	(goto-char (point-max))
 	(recenter -1))
-    (let ((scroll-in-place nil))
-      (prog1
-	  (condition-case ()
-	      (scroll-down lines)
-	    (beginning-of-buffer
-	     (goto-char (point-min))))
-	(gnus-beginning-of-window)))))
+    (prog1
+	(condition-case ()
+	    (let ((scroll-in-place nil))
+	      (scroll-down lines))
+	  (beginning-of-buffer
+	   (goto-char (point-min))))
+      (gnus-article-beginning-of-window))))
 
 (defun gnus-article-only-boring-p ()
   "Decide whether there is only boring text remaining in the article.
@@ -5818,7 +5836,7 @@
 	  (window-start (window-start)))
       (erase-buffer)
       (if (gnus-buffer-live-p gnus-original-article-buffer)
-	  (insert-buffer gnus-original-article-buffer))
+	  (insert-buffer-substring gnus-original-article-buffer))
       (let ((winconf gnus-prev-winconf))
 	(kill-all-local-variables)
 	(gnus-article-mode)
--- a/lisp/gnus/gnus-util.el	Tue Jul 26 12:03:19 2005 +0000
+++ b/lisp/gnus/gnus-util.el	Fri Jul 29 01:54:54 2005 +0000
@@ -1577,30 +1577,6 @@
   (defalias 'gnus-set-process-query-on-exit-flag
     'process-kill-without-query))
 
-(defun gnus-beginning-of-window ()
-  "Move point to the beginning of the window."
-  (move-to-window-line
-   (if (featurep 'xemacs)
-       0
-     (min scroll-margin
-	  (max 1 (- (window-height)
-		    (if mode-line-format 1 0)
-		    (if (and (boundp 'header-line-format)
-			     (symbol-value 'header-line-format))
-			1 0)))))))
-
-(defun gnus-end-of-window ()
-  "Move point to the end of the window."
-  (move-to-window-line
-   (if (featurep 'xemacs)
-       -1
-     (max (- -1 scroll-margin)
-	  (- -1 (max 1 (- (window-height)
-			  (if mode-line-format 1 0)
-			  (if (and (boundp 'header-line-format)
-				   (symbol-value 'header-line-format))
-			      1 0))))))))
-
 (provide 'gnus-util)
 
 ;;; arch-tag: f94991af-d32b-4c97-8c26-ca12a934de49
--- a/lisp/gnus/pgg.el	Tue Jul 26 12:03:19 2005 +0000
+++ b/lisp/gnus/pgg.el	Fri Jul 29 01:54:54 2005 +0000
@@ -410,7 +410,6 @@
 
 (defun pgg-insert-url-with-w3 (url)
   (ignore-errors
-    (require 'w3)
     (require 'url)
     (let (buffer-file-name)
       (url-insert-file-contents url))))
--- a/lisp/gnus/rfc2231.el	Tue Jul 26 12:03:19 2005 +0000
+++ b/lisp/gnus/rfc2231.el	Fri Jul 29 01:54:54 2005 +0000
@@ -1,6 +1,6 @@
 ;;; rfc2231.el --- Functions for decoding rfc2231 headers
 
-;; Copyright (C) 1998, 1999, 2000, 2002, 2003, 2004
+;; Copyright (C) 1998, 1999, 2000, 2002, 2003, 2004, 2005
 ;;        Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
@@ -52,7 +52,7 @@
 	  (prev-value "")
 	  display-name mailbox c display-string parameters
 	  attribute value type subtype number encoded
-	  prev-attribute)
+	  prev-attribute prev-encoded)
       (ietf-drums-init (mail-header-remove-whitespace
 			(mail-header-remove-comments string)))
       (let ((table (copy-syntax-table ietf-drums-syntax-table)))
@@ -106,9 +106,14 @@
 	    ;; See if we have any previous continuations.
 	    (when (and prev-attribute
 		       (not (eq prev-attribute attribute)))
-	      (push (cons prev-attribute prev-value) parameters)
+	      (push (cons prev-attribute
+			  (if prev-encoded
+			      (rfc2231-decode-encoded-string prev-value)
+			    prev-value))
+		    parameters)
 	      (setq prev-attribute nil
-		    prev-value ""))
+		    prev-value ""
+		    prev-encoded nil))
 	    (unless (eq c ?=)
 	      (error "Invalid header: %s" string))
 	    (forward-char 1)
@@ -127,7 +132,8 @@
 	      (error "Invalid header: %s" string)))
 	    (if number
 		(setq prev-attribute attribute
-		      prev-value (concat prev-value value))
+		      prev-value (concat prev-value value)
+		      prev-encoded encoded)
 	      (push (cons attribute
 			  (if encoded
 			      (rfc2231-decode-encoded-string value)
@@ -137,7 +143,7 @@
 	;; Take care of any final continuations.
 	(when prev-attribute
 	  (push (cons prev-attribute
-		      (if encoded
+		      (if prev-encoded
 			  (rfc2231-decode-encoded-string prev-value)
 			prev-value))
 		parameters))
--- a/lisp/image-file.el	Tue Jul 26 12:03:19 2005 +0000
+++ b/lisp/image-file.el	Fri Jul 29 01:54:54 2005 +0000
@@ -118,7 +118,8 @@
 	      (create-image data nil t))
 	     (props
 	      `(display ,image
-			yank-handler (image-file-yank-handler)
+			yank-handler
+			(image-file-yank-handler nil t)
 			intangible ,image
 			rear-nonsticky (display intangible)
 			;; This a cheap attempt to make the whole buffer
@@ -141,12 +142,18 @@
 ;; recognized as two different images.
 (defun image-file-yank-handler (string)
   "Yank handler for inserting an image into a buffer."
-  (let ((image (get-text-property 0 'display string)))
+  (let ((len (length string))
+	(image (get-text-property 0 'display string)))
+    (remove-text-properties 0 len yank-excluded-properties string)
     (if (consp image)
-	(put-text-property 0 (length string)
-			   'display
-			   (cons (car image) (cdr image))
-			   string))
+	(add-text-properties 0
+			     (or (next-single-property-change 0 'image-counter string)
+				 (length string))
+			     `(display
+			       ,(cons (car image) (cdr image))
+			       yank-handler
+			       ,(cons 'image-file-yank-handler '(nil t)))
+			     string))
     (insert string)))
 
 (put 'image-file-handler 'safe-magic t)
--- a/lisp/isearch.el	Tue Jul 26 12:03:19 2005 +0000
+++ b/lisp/isearch.el	Fri Jul 29 01:54:54 2005 +0000
@@ -122,8 +122,8 @@
 
 (defcustom search-invisible 'open
   "If t incremental search can match hidden text.
-nil means don't match invisible text.
-If the value is `open', if the text matched is made invisible by
+A nil value means don't match invisible text.
+When the value is `open', if the text matched is made invisible by
 an overlay having an `invisible' property and that overlay has a property
 `isearch-open-invisible', then incremental search will show the contents.
 \(This applies when using `outline.el' and `hideshow.el'.)
@@ -188,10 +188,10 @@
 
 (defvar search-ring-yank-pointer nil
   "Index in `search-ring' of last string reused.
-nil if none yet.")
+It is nil if none yet.")
 (defvar regexp-search-ring-yank-pointer nil
   "Index in `regexp-search-ring' of last string reused.
-nil if none yet.")
+It is nil if none yet.")
 
 (defcustom search-ring-update nil
   "*Non-nil if advancing or retreating in the search ring should cause search.
@@ -246,22 +246,25 @@
 \\[lazy-highlight-cleanup]."
   :type 'boolean
   :group 'lazy-highlight)
-(defvaralias 'isearch-lazy-highlight-cleanup 'lazy-highlight-cleanup)
-(make-obsolete-variable 'isearch-lazy-highlight-cleanup 'lazy-highlight-cleanup "22.1")
+(define-obsolete-variable-alias 'isearch-lazy-highlight-cleanup
+                                'lazy-highlight-cleanup
+                                "22.1")
 
 (defcustom lazy-highlight-initial-delay 0.25
   "*Seconds to wait before beginning to lazily highlight all matches."
   :type 'number
   :group 'lazy-highlight)
-(defvaralias 'isearch-lazy-highlight-initial-delay 'lazy-highlight-initial-delay)
-(make-obsolete-variable 'isearch-lazy-highlight-initial-delay 'lazy-highlight-initial-delay "22.1")
+(define-obsolete-variable-alias 'isearch-lazy-highlight-initial-delay
+                                'lazy-highlight-initial-delay
+                                "22.1")
 
 (defcustom lazy-highlight-interval 0 ; 0.0625
   "*Seconds between lazily highlighting successive matches."
   :type 'number
   :group 'lazy-highlight)
-(defvaralias 'isearch-lazy-highlight-interval 'lazy-highlight-interval)
-(make-obsolete-variable 'isearch-lazy-highlight-interval 'lazy-highlight-interval "22.1")
+(define-obsolete-variable-alias 'isearch-lazy-highlight-interval
+                                'lazy-highlight-interval
+                                "22.1")
 
 (defcustom lazy-highlight-max-at-a-time 20
   "*Maximum matches to highlight at a time (for `lazy-highlight').
@@ -271,8 +274,9 @@
   :type '(choice (const :tag "All" nil)
 		 (integer :tag "Some"))
   :group 'lazy-highlight)
-(defvaralias 'isearch-lazy-highlight-max-at-a-time 'lazy-highlight-max-at-a-time)
-(make-obsolete-variable 'isearch-lazy-highlight-max-at-a-time 'lazy-highlight-max-at-a-time "22.1")
+(define-obsolete-variable-alias 'isearch-lazy-highlight-max-at-a-time
+                                'lazy-highlight-max-at-a-time
+                                "22.1")
 
 (defface lazy-highlight
   '((((class color) (min-colors 88) (background light))
@@ -288,8 +292,9 @@
   :group 'lazy-highlight)
 (put 'isearch-lazy-highlight-face 'face-alias 'lazy-highlight)
 (defvar lazy-highlight-face 'lazy-highlight)
-(defvaralias 'isearch-lazy-highlight-face 'lazy-highlight-face)
-(make-obsolete-variable 'isearch-lazy-highlight-face 'lazy-highlight-face "22.1")
+(define-obsolete-variable-alias 'isearch-lazy-highlight-face
+                                'lazy-highlight-face
+                                "22.1")
 
 ;; Define isearch-mode keymap.
 
@@ -308,12 +313,12 @@
     ;; We need these explicit definitions because, in a dense keymap,
     ;; the binding for t does not affect characters.
     ;; We use a dense keymap to save space.
-    (while (< i ?\ )
+    (while (< i ?\s)
       (define-key map (make-string 1 i) 'isearch-other-control-char)
       (setq i (1+ i)))
 
     ;; Single-byte printing chars extend the search string by default.
-    (setq i ?\ )
+    (setq i ?\s)
     (while (< i 256)
       (define-key map (vector i) 'isearch-printing-char)
       (setq i (1+ i)))
@@ -527,7 +532,7 @@
 Type \\[isearch-query-replace] to start `query-replace' with string to\
  replace from last search string.
 Type \\[isearch-query-replace-regexp] to start `query-replace-regexp'\
- with string to replace from last search string..
+ with string to replace from last search string.
 
 Type \\[isearch-toggle-case-fold] to toggle search case-sensitivity.
 Type \\[isearch-toggle-regexp] to toggle regular-expression mode.
@@ -1653,7 +1658,7 @@
 	       ;; directly to avoid the input method and keyboard
 	       ;; coding system translating it.
 	       (if (and (integerp key)
-			(>= key ?\ ) (/= key 127) (< key 256))
+			(>= key ?\s) (/= key 127) (< key 256))
 		   (progn
 		     (isearch-process-search-char key)
 		     (setq keylist (cdr keylist)))
@@ -1745,7 +1750,7 @@
     ;; Assume character codes 0200 - 0377 stand for characters in some
     ;; single-byte character set, and convert them to Emacs
     ;; characters.
-    (if (and isearch-regexp (= char ?\ ))
+    (if (and isearch-regexp (= char ?\s))
 	(if (subregexp-context-p isearch-string (length isearch-string))
 	    (isearch-process-search-string "[ ]" " ")
 	  (isearch-process-search-char char))
@@ -1766,7 +1771,7 @@
   (interactive)
   (let ((char last-command-char))
     (if (= char ?\S-\ )
-	(setq char ?\ ))
+	(setq char ?\s))
     (if (and enable-multibyte-characters
 	     (>= char ?\200)
 	     (<= char ?\377))
@@ -2196,7 +2201,7 @@
 
 (defun isearch-text-char-description (c)
   (cond
-   ((< c ?\ ) (format "^%c" (+ c 64)))
+   ((< c ?\s) (format "^%c" (+ c 64)))
    ((= c ?\^?) "^?")
    (t (char-to-string c))))
 
@@ -2283,8 +2288,9 @@
     (cancel-timer isearch-lazy-highlight-timer)
     (setq isearch-lazy-highlight-timer nil)))
 
-(defalias 'isearch-lazy-highlight-cleanup 'lazy-highlight-cleanup)
-(make-obsolete 'isearch-lazy-highlight-cleanup 'lazy-highlight-cleanup "22.1")
+(define-obsolete-function-alias 'isearch-lazy-highlight-cleanup
+                                'lazy-highlight-cleanup
+                                "22.1")
 
 (defun isearch-lazy-highlight-new-loop (&optional beg end)
   "Cleanup any previous `lazy-highlight' loop and begin a new one.
--- a/lisp/man.el	Tue Jul 26 12:03:19 2005 +0000
+++ b/lisp/man.el	Fri Jul 29 01:54:54 2005 +0000
@@ -352,6 +352,7 @@
 (make-variable-buffer-local 'Man-page-mode-string)
 (make-variable-buffer-local 'Man-original-frame)
 (make-variable-buffer-local 'Man-arguments)
+(put 'Man-arguments 'permanent-local t)
 
 (setq-default Man-sections-alist nil)
 (setq-default Man-refpages-alist nil)
@@ -1005,8 +1006,15 @@
           (if Man-fontify-manpage-flag
               (Man-fontify-manpage)
             (Man-cleanup-manpage))
+
           (run-hooks 'Man-cooked-hook)
-          (Man-mode)
+	  (Man-mode)
+
+	  (if (not Man-page-list)
+	      (let ((args Man-arguments))
+		(kill-buffer (current-buffer))
+		(error "Can't find the %s manpage" args)))
+
           (set-buffer-modified-p nil)
           ))
 	;; Restore case-fold-search before calling
@@ -1082,7 +1090,7 @@
   (Man-build-page-list)
   (Man-strip-page-headers)
   (Man-unindent)
-  (Man-goto-page 1)
+  (Man-goto-page 1 t)
   (run-mode-hooks 'Man-mode-hook))
 
 (defsubst Man-build-section-alist ()
@@ -1342,35 +1350,32 @@
   (interactive)
   (quit-window))
 
-(defun Man-goto-page (page)
+(defun Man-goto-page (page &optional noerror)
   "Go to the manual page on page PAGE."
   (interactive
    (if (not Man-page-list)
-       (let ((args Man-arguments))
-	 (kill-buffer (current-buffer))
-	 (error "Can't find the %s manpage" args))
+       (error "Not a man page buffer")
      (if (= (length Man-page-list) 1)
 	 (error "You're looking at the only manpage in the buffer")
        (list (read-minibuffer (format "Go to manpage [1-%d]: "
 				      (length Man-page-list)))))))
-  (if (not Man-page-list)
-      (let ((args Man-arguments))
-	(kill-buffer (current-buffer))
-	(error "Can't find the %s manpage" args)))
-  (if (or (< page 1)
-	  (> page (length Man-page-list)))
-      (error "No manpage %d found" page))
-  (let* ((page-range (nth (1- page) Man-page-list))
-	 (page-start (car page-range))
-	 (page-end (car (cdr page-range))))
-    (setq Man-current-page page
-	  Man-page-mode-string (Man-make-page-mode-string))
-    (widen)
-    (goto-char page-start)
-    (narrow-to-region page-start page-end)
-    (Man-build-section-alist)
-    (Man-build-references-alist)
-    (goto-char (point-min))))
+  (if (and (not Man-page-list) (not noerror))
+      (error "Not a man page buffer"))
+  (when Man-page-list
+    (if (or (< page 1)
+	    (> page (length Man-page-list)))
+	(error "No manpage %d found" page))
+    (let* ((page-range (nth (1- page) Man-page-list))
+	   (page-start (car page-range))
+	   (page-end (car (cdr page-range))))
+      (setq Man-current-page page
+	    Man-page-mode-string (Man-make-page-mode-string))
+      (widen)
+      (goto-char page-start)
+      (narrow-to-region page-start page-end)
+      (Man-build-section-alist)
+      (Man-build-references-alist)
+      (goto-char (point-min)))))
 
 
 (defun Man-next-manpage ()
--- a/lisp/net/ange-ftp.el	Tue Jul 26 12:03:19 2005 +0000
+++ b/lisp/net/ange-ftp.el	Fri Jul 29 01:54:54 2005 +0000
@@ -743,6 +743,21 @@
   :group 'ange-ftp
   :type 'regexp)
 
+(defcustom ange-ftp-potential-error-msgs
+  ;; On Mac OS X we sometimes get things like:
+  ;; 
+  ;;     ftp> open ftp.nluug.nl
+  ;;     Trying 2001:610:1:80aa:192:87:102:36...
+  ;;     ftp: connect to address 2001:610:1:80aa:192:87:102:36: No route to host
+  ;;     Trying 192.87.102.36...
+  ;;     Connected to ftp.nluug.nl.
+  "^ftp: connect to address .*: No route to host"
+  "*Regular expression matching ftp messages that can indicate serious errors.
+These mean that something went wrong, but they may be followed by more
+messages indicating that the error was somehow corrected."
+  :group 'ange-ftp
+  :type 'regexp)
+
 (defcustom ange-ftp-gateway-fatal-msgs
   "No route to host\\|Connection closed\\|No such host\\|Login incorrect"
   "*Regular expression matching login failure messages from rlogin/telnet."
@@ -1071,6 +1086,7 @@
 (defvar ange-ftp-xfer-size nil)
 (defvar ange-ftp-process-string nil)
 (defvar ange-ftp-process-result-line nil)
+(defvar ange-ftp-pending-error-line nil)
 (defvar ange-ftp-process-busy nil)
 (defvar ange-ftp-process-result nil)
 (defvar ange-ftp-process-multi-skip nil)
@@ -1544,6 +1560,7 @@
 	((string-match ange-ftp-good-msgs line)
 	 (setq ange-ftp-process-busy nil
 	       ange-ftp-process-result t
+               ange-ftp-pending-error-line nil
 	       ange-ftp-process-result-line line))
 	;; Check this before checking for errors.
 	;; Otherwise the last line of these three seems to be an error:
@@ -1552,11 +1569,17 @@
 	;; 230-"ftp.stsci.edu: unknown host", the new IP address will be...
 	((string-match ange-ftp-multi-msgs line)
 	 (setq ange-ftp-process-multi-skip t))
+	((string-match ange-ftp-potential-error-msgs line)
+         ;; This looks like an error, but we have to keep reading the output
+         ;; to see if it was fixed or not.  E.g. it may indicate that IPv6
+         ;; failed, but maybe a subsequent IPv4 fallback succeeded.
+         (set (make-local-variable 'ange-ftp-pending-error-line) line)
+         t)
 	((string-match ange-ftp-fatal-msgs line)
 	 (delete-process proc)
 	 (setq ange-ftp-process-busy nil
 	       ange-ftp-process-result-line line))
-	(ange-ftp-process-multi-skip
+        (ange-ftp-process-multi-skip
 	 t)
 	(t
 	 (setq ange-ftp-process-busy nil
@@ -1651,12 +1674,21 @@
 			  (string-match "\n" ange-ftp-process-string))
 		(let ((line (substring ange-ftp-process-string
 				       0
-				       (match-beginning 0))))
+				       (match-beginning 0)))
+                      (seen-prompt nil))
 		  (setq ange-ftp-process-string (substring ange-ftp-process-string
 							   (match-end 0)))
 		  (while (string-match "^ftp> *" line)
+                    (setq seen-prompt t)
 		    (setq line (substring line (match-end 0))))
-		  (ange-ftp-process-handle-line line proc)))
+                  (if (not (and seen-prompt ange-ftp-pending-error-line))
+                      (ange-ftp-process-handle-line line proc)
+                    ;; If we've seen a potential error message and it
+                    ;; hasn't been cancelled by a good message before
+                    ;; seeing a propt, then the error was real.
+                    (delete-process proc)
+                    (setq ange-ftp-process-busy nil
+                          ange-ftp-process-result-line ange-ftp-pending-error-line))))
 
 	      ;; has the ftp client finished?  if so then do some clean-up
 	      ;; actions.
@@ -1988,7 +2020,7 @@
   (make-local-variable 'comint-password-prompt-regexp)
   ;; This is a regexp that can't match anything.
   ;; ange-ftp has its own ways of handling passwords.
-  (setq comint-password-prompt-regexp "^a\\'z")
+  (setq comint-password-prompt-regexp "\\`a\\`")
   (make-local-variable 'paragraph-start)
   (setq paragraph-start comint-prompt-regexp)
   (run-mode-hooks 'internal-ange-ftp-mode-hook))
@@ -4543,9 +4575,9 @@
   (setq ange-ftp-ls-cache-file nil)	;Stop confusing Dired.
   0)
 
-;;; This is turned off because it has nothing properly to do
-;;; with dired.  It could be reasonable to adapt this to
-;;; replace ange-ftp-copy-file.
+;; This is turned off because it has nothing properly to do
+;; with dired.  It could be reasonable to adapt this to
+;; replace ange-ftp-copy-file.
 
 ;;;;; ------------------------------------------------------------
 ;;;;; Noddy support for async copy-file within dired.
--- a/lisp/progmodes/compile.el	Tue Jul 26 12:03:19 2005 +0000
+++ b/lisp/progmodes/compile.el	Fri Jul 29 01:54:54 2005 +0000
@@ -377,13 +377,13 @@
    '(;; configure output lines.
      ("^[Cc]hecking \\(?:[Ff]or \\|[Ii]f \\|[Ww]hether \\(?:to \\)?\\)?\\(.+\\)\\.\\.\\. *\\(?:(cached) *\\)?\\(\\(yes\\(?: .+\\)?\\)\\|no\\|\\(.*\\)\\)$"
       (1 font-lock-variable-name-face)
-      (2 (compilation-face '(4 . 3))))
+      (2 font-lock-keyword-face))
      ;; Command output lines.  Recognize `make[n]:' lines too.
      ("^\\([[:alnum:]_/.+-]+\\)\\(\\[\\([0-9]+\\)\\]\\)?[ \t]*:"
       (1 font-lock-function-name-face) (3 compilation-line-face nil t))
      (" --?o\\(?:utfile\\|utput\\)?[= ]?\\(\\S +\\)" . 1)
-     ("^Compilation finished" . compilation-info-face)
-     ("^Compilation exited abnormally" . compilation-error-face))
+     ("^Compilation finished" . font-lock-keyword-face)
+     ("^Compilation exited abnormally" . font-lock-keyword-face))
    "Additional things to highlight in Compilation mode.
 This gets tacked on the end of the generated expressions.")
 
--- a/lisp/progmodes/gdb-ui.el	Tue Jul 26 12:03:19 2005 +0000
+++ b/lisp/progmodes/gdb-ui.el	Fri Jul 29 01:54:54 2005 +0000
@@ -524,9 +524,9 @@
   (setq gdb-pending-triggers
    (delq 'gdb-var-update gdb-pending-triggers))
   (when (and (boundp 'speedbar-frame) (frame-live-p speedbar-frame))
-    ;; dummy command to update speedbar at right time
+    ;; Dummy command to update speedbar at right time.
     (gdb-enqueue-input (list "server pwd\n" 'gdb-speedbar-timer-fn))
-    ;; keep gdb-pending-triggers non-nil till end
+    ;; Keep gdb-pending-triggers non-nil till end.
     (push 'gdb-speedbar-timer gdb-pending-triggers)))
 
 (defun gdb-speedbar-timer-fn ()
@@ -1023,7 +1023,7 @@
     (gdb-invalidate-threads)
     (unless (eq system-type 'darwin) ;Breaks on Darwin's GDB-5.3.
       ;; FIXME: with GDB-6 on Darwin, this might very well work.
-      ;; only needed/used with speedbar/watch expressions
+      ;; Only needed/used with speedbar/watch expressions.
       (when (and (boundp 'speedbar-frame) (frame-live-p speedbar-frame))
 	(setq gdb-var-changed t)    ; force update
 	(dolist (var gdb-var-list)
@@ -1043,9 +1043,9 @@
   (if gdb-flush-pending-output
       nil
     (if gdb-enable-debug-log (push (cons 'recv string) gdb-debug-log))
-    ;; Recall the left over gud-marker-acc from last time
+    ;; Recall the left over gud-marker-acc from last time.
     (setq gud-marker-acc (concat gud-marker-acc string))
-    ;; Start accumulating output for the GUD buffer
+    ;; Start accumulating output for the GUD buffer.
     (let ((output ""))
       ;;
       ;; Process all the complete markers in this chunk.
@@ -1295,7 +1295,7 @@
      :weight bold))
   "Face for enabled breakpoint icon in fringe."
   :group 'gud)
-;; compatibility alias for old name
+;; Compatibility alias for old name.
 (put 'breakpoint-enabled-bitmap-face 'face-alias 'breakpoint-enabled)
 
 (defface breakpoint-disabled
@@ -1306,13 +1306,13 @@
     (((background light)) :foreground "grey40"))
   "Face for disabled breakpoint icon in fringe."
   :group 'gud)
-;; compatibility alias for old name
+;; Compatibility alias for old name.
 (put 'breakpoint-disabled-bitmap-face 'face-alias 'breakpoint-disabled)
 
-;;-put breakpoint icons in relevant margins (even those set in the GUD buffer)
+;; Put breakpoint icons in relevant margins (even those set in the GUD buffer).
 (defun gdb-info-breakpoints-custom ()
   (let ((flag) (bptno))
-    ;; remove all breakpoint-icons in source buffers but not assembler buffer
+    ;; Remove all breakpoint-icons in source buffers but not assembler buffer.
     (dolist (buffer (buffer-list))
       (with-current-buffer buffer
 	(if (and (eq gud-minor-mode 'gdba)
@@ -1342,13 +1342,14 @@
 			   (setq file (cdr (assoc bptno gdb-location-alist))))
 			(if (and file
 				 (not (string-equal file "File not found")))
-			    (with-current-buffer (find-file-noselect file)
+			    (with-current-buffer
+				(find-file-noselect file 'nowarn)
 			      (set (make-local-variable 'gud-minor-mode)
 				   'gdba)
 			      (set (make-local-variable 'tool-bar-map)
 				   gud-tool-bar-map)
-			      ;; only want one breakpoint icon at each
-			      ;; location
+			      ;; Only want one breakpoint icon at each
+			      ;; location.
 			      (save-excursion
 				(goto-line (string-to-number line))
 				(gdb-put-breakpoint-icon (eq flag ?y) bptno)))
@@ -1388,11 +1389,7 @@
 	(with-selected-window (posn-window posn)
 	  (save-excursion
 	    (goto-char (posn-point posn))
-	    (if
-;		(or
-		 (posn-object posn)
-;		 (eq (car (fringe-bitmaps-at-pos (posn-point posn)))
-;		     'breakpoint))
+	    (if	(posn-object posn)
 		(gdb-enqueue-input
 		 (list
 		  (let ((bptno (get-text-property
@@ -1980,7 +1977,7 @@
 	     'mouse-1
 	     #'(lambda () (interactive)
 		 (let ((gdb-memory-address
-			;; let GDB do the arithmetic
+			;; Let GDB do the arithmetic.
 			(concat
 			 gdb-memory-address " - "
 			 (number-to-string
--- a/lisp/progmodes/grep.el	Tue Jul 26 12:03:19 2005 +0000
+++ b/lisp/progmodes/grep.el	Fri Jul 29 01:54:54 2005 +0000
@@ -277,7 +277,8 @@
 (defvar grep-hit-face	compilation-info-face
   "Face name to use for grep hits.")
 
-(defvar grep-error-face	compilation-error-face
+;; compilation-error-face is wrong for this; it's designed to look like a link.
+(defvar grep-error-face	font-lock-keyword-face
   "Face name to use for grep error messages.")
 
 (defvar grep-match-face	'match
@@ -291,12 +292,12 @@
      ;; remove match from grep-regexp-alist before fontifying
      ("^Grep finished \\(?:(\\(matches found\\))\\|with \\(no matches found\\)\\).*"
       (0 '(face nil message nil help-echo nil mouse-face nil) t)
-      (1 grep-hit-face nil t)
-      (2 grep-error-face nil t))
+      (1 font-lock-keyword-face nil t)
+      (2 font-lock-keyword-face nil t))
      ("^Grep \\(exited abnormally\\) with code \\([0-9]+\\).*"
       (0 '(face nil message nil help-echo nil mouse-face nil) t)
-      (1 compilation-warning-face)
-      (2 compilation-line-face))
+      (1 grep-error-face)
+      (2 grep-error-face))
      ;; Highlight grep matches and delete markers
      ("\\(\033\\[01;31m\\)\\(.*?\\)\\(\033\\[[0-9]*m\\)"
       ;; Refontification does not work after the markers have been
--- a/lisp/ps-bdf.el	Tue Jul 26 12:03:19 2005 +0000
+++ b/lisp/ps-bdf.el	Fri Jul 29 01:54:54 2005 +0000
@@ -272,18 +272,20 @@
 	    (while (search-forward "\nSTARTCHAR" nil t)
 	      (setq offset (line-beginning-position))
 	      (search-forward "\nENCODING")
-	      (setq code (read (current-buffer))
-		    code0 (lsh code -8)
-		    code1 (logand code 255)
-		    min-code (min min-code code)
-		    max-code (max max-code code)
-		    min-code0 (min min-code0 code0)
-		    max-code0 (max max-code0 code0)
-		    min-code1 (min min-code1 code1)
-		    max-code1 (max max-code1 code1))
-	      (search-forward "ENDCHAR")
-	      (setq maxlen (max maxlen (- (point) offset))
-		    glyph-list (cons (cons code offset) glyph-list)))
+	      (setq code (read (current-buffer)))
+	      (if (< code 0)
+		  (search-forward "ENDCHAR")
+		(setq code0 (lsh code -8)
+		      code1 (logand code 255)
+		      min-code (min min-code code)
+		      max-code (max max-code code)
+		      min-code0 (min min-code0 code0)
+		      max-code0 (max max-code0 code0)
+		      min-code1 (min min-code1 code1)
+		      max-code1 (max max-code1 code1))
+		(search-forward "ENDCHAR")
+		(setq maxlen (max maxlen (- (point) offset))
+		      glyph-list (cons (cons code offset) glyph-list))))
 
 	    (setq code-range
 		  (vector min-code0 max-code0 min-code1 max-code1
--- a/lisp/recentf.el	Tue Jul 26 12:03:19 2005 +0000
+++ b/lisp/recentf.el	Fri Jul 29 01:54:54 2005 +0000
@@ -65,7 +65,7 @@
 
 (defcustom recentf-max-saved-items 20
   "*Maximum number of items of the recent list that will be saved.
-nil means to save the whole list.
+A nil value means to save the whole list.
 See the command `recentf-save-list'."
   :group 'recentf
   :type 'integer)
@@ -145,7 +145,7 @@
 
 (defcustom recentf-menu-filter nil
   "*Function used to filter files displayed in the recentf menu.
-nil means no filter.  The following functions are predefined:
+A nil value means no filter.  The following functions are predefined:
 
 - `recentf-sort-ascending'
     Sort menu items in ascending order.
@@ -199,16 +199,14 @@
   :set 'recentf-menu-customization-changed)
 
 (defcustom recentf-menu-append-commands-flag t
-  "*non-nil means to append command items to the menu."
+  "*Non-nil means to append command items to the menu."
   :group 'recentf
   :type 'boolean
   :set 'recentf-menu-customization-changed)
 
-(defvaralias 'recentf-menu-append-commands-p
-  'recentf-menu-append-commands-flag)
-(make-obsolete-variable 'recentf-menu-append-commands-p
-                        'recentf-menu-append-commands-flag
-                        "22.1")
+(define-obsolete-variable-alias 'recentf-menu-append-commands-p
+                                'recentf-menu-append-commands-flag
+                                "22.1")
 
 (defcustom recentf-auto-cleanup 'mode
   "*Define when to automatically cleanup the recent list.
@@ -244,7 +242,7 @@
            (recentf-auto-cleanup))))
 
 (defcustom recentf-initialize-file-name-history t
-  "*non-nil means to initialize `file-name-history' with the recent list.
+  "*Non-nil means to initialize `file-name-history' with the recent list.
 If `file-name-history' is not empty, do nothing."
   :group 'recentf
   :type  'boolean)
@@ -350,8 +348,8 @@
 (defsubst recentf-expand-file-name (name)
   "Convert filename NAME to absolute, and canonicalize it.
 See also the function `expand-file-name'.
-If defined, call the function `recentf-filename-handler' to post
-process the canonical name."
+If defined, call the function `recentf-filename-handler'
+to postprocess the canonical name."
   (let* ((filename (expand-file-name name)))
     (or (and recentf-filename-handler
              (funcall recentf-filename-handler filename))
@@ -557,7 +555,7 @@
 
 (defun recentf-clear-data ()
   "Clear data used to build the recentf menu.
-This force a rebuild of the menu."
+This forces a rebuild of the menu."
   (easy-menu-remove-item (recentf-menu-bar)
                          recentf-menu-path recentf-menu-title)
   (setq recentf-data-cache nil))
@@ -703,7 +701,7 @@
 
 (defcustom recentf-arrange-by-rule-subfilter nil
   "*Function called by a rule based filter to filter sub-menu elements.
-nil means no filter.  See also `recentf-menu-filter'.
+A nil value means no filter.  See also `recentf-menu-filter'.
 You can't use another rule based filter here."
   :group 'recentf-filters
   :type '(choice (const nil) function)
--- a/lisp/simple.el	Tue Jul 26 12:03:19 2005 +0000
+++ b/lisp/simple.el	Fri Jul 29 01:54:54 2005 +0000
@@ -3491,8 +3491,8 @@
 	     ;; at least go to end of line.
 	     (end-of-line))
 	    ((< arg 0)
-	     ;; If we did not move down as far as desired,
-	     ;; at least go to end of line.
+	     ;; If we did not move up as far as desired,
+	     ;; at least go to beginning of line.
 	     (beginning-of-line))
 	    (t
 	     (line-move-finish (or goal-column temporary-goal-column)
--- a/lisp/smerge-mode.el	Tue Jul 26 12:03:19 2005 +0000
+++ b/lisp/smerge-mode.el	Fri Jul 29 01:54:54 2005 +0000
@@ -670,7 +670,7 @@
 	     (ediff-cleanup-mess)
 	     (with-current-buffer buf
 	       (erase-buffer)
-	       (insert-buffer buffer-C)
+	       (insert-buffer-substring buffer-C)
 	       (kill-buffer buffer-A)
 	       (kill-buffer buffer-B)
 	       (kill-buffer buffer-C)
--- a/lisp/startup.el	Tue Jul 26 12:03:19 2005 +0000
+++ b/lisp/startup.el	Fri Jul 29 01:54:54 2005 +0000
@@ -575,7 +575,7 @@
 
   ;; Choose a reasonable location for temporary files.
   (custom-reevaluate-setting 'temporary-file-directory)
-  (custom-reevaluate-setting 'small-emporary-file-directory)
+  (custom-reevaluate-setting 'small-temporary-file-directory)
   (custom-reevaluate-setting 'auto-save-file-name-transforms)
 
   ;; See if we should import version-control from the environment variable.
@@ -984,7 +984,13 @@
         (setq term
               (if (setq hyphend (string-match "[-_][^-_]+$" term))
                   (substring term 0 hyphend)
-                nil)))))
+                nil)))
+      (when term
+	;; The terminal file has been loaded, now call the terminal
+	;; specific initialization function.
+	(let ((term-init-func (intern (concat "terminal-init-" term))))
+	  (when (fboundp term-init-func)
+	    (funcall term-init-func))))))
 
   ;; Update the out-of-memory error message based on user's key bindings
   ;; for save-some-buffers.
@@ -1346,7 +1352,7 @@
 
 Useful File menu items:
 Exit Emacs		(or type Control-x followed by Control-c)
-Recover Session		Recover files you were editing before a crash
+Recover Crashed Session	Recover files you were editing before a crash
 
 Important Help menu items:
 Emacs Tutorial		Learn how to use Emacs efficiently
--- a/lisp/tempo.el	Tue Jul 26 12:03:19 2005 +0000
+++ b/lisp/tempo.el	Fri Jul 29 01:54:54 2005 +0000
@@ -303,7 +303,7 @@
 		     transient-mark-mode
 		     mark-active)
 		(if (featurep 'xemacs)
-		     zmacs-regions (mark)))
+		    (and zmacs-regions (mark))))
 	    (setq on-region t))
 	(and on-region
 	     (set-marker tempo-region-start (min (mark) (point)))
--- a/lisp/term/README	Tue Jul 26 12:03:19 2005 +0000
+++ b/lisp/term/README	Fri Jul 29 01:54:54 2005 +0000
@@ -8,7 +8,12 @@
 yield a file that exists, the previous hyphen is stripped, and so on until all
 hyphens are gone.  For example, if the terminal type is `aaa-48-foo', Emacs
 will try first `term/aaa-48-foo.el', then `term/aaa-48.el' and finally
-`term/aaa.el'.
+`term/aaa.el'.  Each terminal specific file should contain a function
+named terminal-init-TERMINALNAME (eg terminal-init-aaa-48 for
+term/aaa-48.el) that Emacs will call in order to initialize the
+terminal. The terminal files should not contain any top level forms
+that are executed when the file is loaded, all the initialization
+actions are performed by the terminal-init-TERMINALNAME functions.
 
    When writing terminal packages, there are some things it is good to keep in
 mind.
--- a/lisp/term/apollo.el	Tue Jul 26 12:03:19 2005 +0000
+++ b/lisp/term/apollo.el	Fri Jul 29 01:54:54 2005 +0000
@@ -1,6 +1,7 @@
 ;; -*- no-byte-compile: t -*-
-
-(load "term/vt100" nil t)
+(defun terminal-init-apollo ()
+  "Terminal initialization function for apollo."  
+  (load "term/vt100" nil t))
 
 ;;; arch-tag: c72f446f-e6b7-4749-90a4-bd68632adacf
 ;;; apollo.el ends here
--- a/lisp/term/bobcat.el	Tue Jul 26 12:03:19 2005 +0000
+++ b/lisp/term/bobcat.el	Fri Jul 29 01:54:54 2005 +0000
@@ -1,7 +1,10 @@
 ;; -*- no-byte-compile: t -*-
-;;; HP terminals usually encourage using ^H as the rubout character
-(keyboard-translate ?\177 ?\^h)
-(keyboard-translate ?\^h ?\177)
+
+(defun terminal-init-bobcat ()
+  "Terminal initialization function for bobcat."  
+  ;; HP terminals usually encourage using ^H as the rubout character
+  (keyboard-translate ?\177 ?\^h)
+  (keyboard-translate ?\^h ?\177))
 
 ;;; arch-tag: 754e4520-0a3e-4e6e-8ca5-9481b1f85cf7
 ;;; bobcat.el ends here
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lisp/term/cygwin.el	Fri Jul 29 01:54:54 2005 +0000
@@ -0,0 +1,10 @@
+;;; cygwin.el --- support for the Cygwin terminal -*- no-byte-compile: t -*-
+
+;;; The Cygwin terminal can't really display underlines.
+
+(defun terminal-init-cygwin ()
+  "Terminal initialization function for cygwin."  
+  (tty-no-underline))
+
+;; arch-tag: ca81ce67-3c41-4883-a29b-4c3d64a21191
+;;; cygwin.el ends here
--- a/lisp/term/iris-ansi.el	Tue Jul 26 12:03:19 2005 +0000
+++ b/lisp/term/iris-ansi.el	Fri Jul 29 01:54:54 2005 +0000
@@ -1,6 +1,6 @@
 ;;; iris-ansi.el --- configure Emacs for SGI xwsh and winterm apps -*- no-byte-compile: t -*-
 
-;; Copyright (C) 1997 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 2005 Free Software Foundation, Inc.
 
 ;; Author: Dan Nicolaescu <dann@ics.uci.edu>
 
@@ -25,302 +25,306 @@
 
 ;;; Code:
 
-(define-key function-key-map "\e[120q" [S-escape])
-(define-key function-key-map "\e[121q" [C-escape])
-
-(define-key function-key-map "\e[001q" [f1])
-(define-key function-key-map "\e[013q" [S-f1])
-(define-key function-key-map "\e[025q" [C-f1])
-
-
-(define-key function-key-map "\e[002q" [f2])
-(define-key function-key-map "\e[014q" [S-f2])
-(define-key function-key-map "\e[026q" [C-f2])
-(define-key function-key-map "\e[038q" [M-f2])
-
-(define-key function-key-map "\e[003q" [f3])
-(define-key function-key-map "\e[015q" [S-f3])
-(define-key function-key-map "\e[027q" [C-f3])
-
+(defun iris-ansi-initialize-terminal ()
+  "Terminal initialization function for iris-ansi."
+  (define-key function-key-map "\e[120q" [S-escape])
+  (define-key function-key-map "\e[121q" [C-escape])
 
-(define-key function-key-map "\e[004q" [f4])
-(define-key function-key-map "\e[016q" [S-f4])
-(define-key function-key-map "\e[028q" [C-f4])
-
-
-(define-key function-key-map "\e[005q" [f5])
-(define-key function-key-map "\e[017q" [S-f5])
-(define-key function-key-map "\e[029q" [C-f5])
-
-
-(define-key function-key-map "\e[006q" [f6])
-(define-key function-key-map "\e[018q" [S-f6])
-(define-key function-key-map "\e[030q" [C-f6])
-
-
-(define-key function-key-map "\e[007q" [f7])
-(define-key function-key-map "\e[019q" [S-f7])
-(define-key function-key-map "\e[031q" [C-f7])
+  (define-key function-key-map "\e[001q" [f1])
+  (define-key function-key-map "\e[013q" [S-f1])
+  (define-key function-key-map "\e[025q" [C-f1])
 
 
-(define-key function-key-map "\e[008q" [f8])
-(define-key function-key-map "\e[020q" [S-f8])
-(define-key function-key-map "\e[032q" [C-f8])
-
+  (define-key function-key-map "\e[002q" [f2])
+  (define-key function-key-map "\e[014q" [S-f2])
+  (define-key function-key-map "\e[026q" [C-f2])
+  (define-key function-key-map "\e[038q" [M-f2])
 
-(define-key function-key-map "\e[009q" [f9])
-(define-key function-key-map "\e[021q" [S-f9])
-(define-key function-key-map "\e[033q" [C-f9])
-
-
-(define-key function-key-map "\e[010q" [f10])
-(define-key function-key-map "\e[022q" [S-f10])
-(define-key function-key-map "\e[034q" [C-f10])
+  (define-key function-key-map "\e[003q" [f3])
+  (define-key function-key-map "\e[015q" [S-f3])
+  (define-key function-key-map "\e[027q" [C-f3])
 
 
-(define-key function-key-map "\e[011q" [f11])
-(define-key function-key-map "\e[023q" [S-f11])
-(define-key function-key-map "\e[035q" [C-f11])
-(define-key function-key-map "\e[047q" [M-f11])
-
-(define-key function-key-map "\e[012q" [f12])
-(define-key function-key-map "\e[024q" [S-f12])
-(define-key function-key-map "\e[036q" [C-f12])
-(define-key function-key-map "\e[048q" [M-f12])
+  (define-key function-key-map "\e[004q" [f4])
+  (define-key function-key-map "\e[016q" [S-f4])
+  (define-key function-key-map "\e[028q" [C-f4])
 
 
-(define-key function-key-map "\e[057q" [C-`])
-(define-key function-key-map "\e[115q" [M-`])
-
-(define-key function-key-map "\e[049q" [?\C-1])
-(define-key function-key-map "\e[058q" [?\M-1])
-
-
-(define-key function-key-map "\e[059q" [?\M-2])
-
-(define-key function-key-map "\e[050q" [?\C-3])
-(define-key function-key-map "\e[060q" [?\M-3])
-
-(define-key function-key-map "\e[051q" [?\C-4])
-(define-key function-key-map "\e[061q" [?\M-4])
-
-(define-key function-key-map "\e[052q" [?\C-5])
-(define-key function-key-map "\e[062q" [?\M-5])
+  (define-key function-key-map "\e[005q" [f5])
+  (define-key function-key-map "\e[017q" [S-f5])
+  (define-key function-key-map "\e[029q" [C-f5])
 
 
-(define-key function-key-map "\e[063q" [?\M-6])
-
-(define-key function-key-map "\e[053q" [?\C-7])
-(define-key function-key-map "\e[064q" [?\M-7])
+  (define-key function-key-map "\e[006q" [f6])
+  (define-key function-key-map "\e[018q" [S-f6])
+  (define-key function-key-map "\e[030q" [C-f6])
+  
 
-(define-key function-key-map "\e[054q" [?\C-8])
-(define-key function-key-map "\e[065q" [?\M-8])
-
-(define-key function-key-map "\e[055q" [?\C-9])
-(define-key function-key-map "\e[066q" [?\M-9])
+  (define-key function-key-map "\e[007q" [f7])
+  (define-key function-key-map "\e[019q" [S-f7])
+  (define-key function-key-map "\e[031q" [C-f7])
+  
+  
+  (define-key function-key-map "\e[008q" [f8])
+  (define-key function-key-map "\e[020q" [S-f8])
+  (define-key function-key-map "\e[032q" [C-f8])
+  
 
-(define-key function-key-map "\e[056q" [?\C-0])
-(define-key function-key-map "\e[067q" [?\M-0])
-
-(define-key function-key-map "\e[068q" [?\M--])
-
-(define-key function-key-map "\e[069q" [?\C-=])
-(define-key function-key-map "\e[070q" [?\M-=])
-
-;; I don't know what to do with those.
-;(define-key function-key-map "^H" [<del>])
-;(define-key function-key-map "^H" [S-<del>])
-;(define-key function-key-map "\177" [C-<del>])
-;(define-key function-key-map "\e[071q" [M-<del>])
+  (define-key function-key-map "\e[009q" [f9])
+  (define-key function-key-map "\e[021q" [S-f9])
+  (define-key function-key-map "\e[033q" [C-f9])
+  
+  
+  (define-key function-key-map "\e[010q" [f10])
+  (define-key function-key-map "\e[022q" [S-f10])
+  (define-key function-key-map "\e[034q" [C-f10])
+  
+  
+  (define-key function-key-map "\e[011q" [f11])
+  (define-key function-key-map "\e[023q" [S-f11])
+  (define-key function-key-map "\e[035q" [C-f11])
+  (define-key function-key-map "\e[047q" [M-f11])
 
-(define-key function-key-map "\e[Z" [?\S-\t])
-(define-key function-key-map "\e[072q" [?\C-\t])
-;; This only works if you remove the M-TAB keybing from the system.4Dwmrc
-;; our your ~/.4Dwmrc, if you use the 4Dwm window manager.
-(define-key function-key-map "\e[073q" [?\M-\t])
-
-(define-key function-key-map "\e[074q" [?\M-q])
-
-(define-key function-key-map "\e[075q" [?\M-w])
-
-(define-key function-key-map "\e[076q" [?\M-e])
-
-(define-key function-key-map "\e[077q" [?\M-r])
-
-(define-key function-key-map "\e[078q" [?\M-t])
-
-(define-key function-key-map "\e[079q" [?\M-y])
+  (define-key function-key-map "\e[012q" [f12])
+  (define-key function-key-map "\e[024q" [S-f12])
+  (define-key function-key-map "\e[036q" [C-f12])
+  (define-key function-key-map "\e[048q" [M-f12])
+  
+  
+  (define-key function-key-map "\e[057q" [?\C-`])
+  (define-key function-key-map "\e[115q" [?\M-`])
+  
+  (define-key function-key-map "\e[049q" [?\C-1])
+  (define-key function-key-map "\e[058q" [?\M-1])
+  
+  
+  (define-key function-key-map "\e[059q" [?\M-2])
+  
+  (define-key function-key-map "\e[050q" [?\C-3])
+  (define-key function-key-map "\e[060q" [?\M-3])
+  
+  (define-key function-key-map "\e[051q" [?\C-4])
+  (define-key function-key-map "\e[061q" [?\M-4])
+  
+  (define-key function-key-map "\e[052q" [?\C-5])
+  (define-key function-key-map "\e[062q" [?\M-5])
+  
 
-(define-key function-key-map "\e[080q" [?\M-u])
-
-(define-key function-key-map "\e[081q" [?\M-i])
-
-(define-key function-key-map "\e[082q" [?\M-o])
-
-(define-key function-key-map "\e[083q" [?\M-p])
+  (define-key function-key-map "\e[063q" [?\M-6])
+  
+  (define-key function-key-map "\e[053q" [?\C-7])
+  (define-key function-key-map "\e[064q" [?\M-7])
+  
+  (define-key function-key-map "\e[054q" [?\C-8])
+  (define-key function-key-map "\e[065q" [?\M-8])
+  
+  (define-key function-key-map "\e[055q" [?\C-9])
+  (define-key function-key-map "\e[066q" [?\M-9])
+  
+  (define-key function-key-map "\e[056q" [?\C-0])
+  (define-key function-key-map "\e[067q" [?\M-0])
+  
+  (define-key function-key-map "\e[068q" [?\M--])
+  
+  (define-key function-key-map "\e[069q" [?\C-=])
+  (define-key function-key-map "\e[070q" [?\M-=])
+  
+  ;; I don't know what to do with those.
+  ;;(define-key function-key-map "^H" [<del>])
+  ;;(define-key function-key-map "^H" [S-<del>])
+  ;;(define-key function-key-map "\177" [C-<del>])
+  ;;(define-key function-key-map "\e[071q" [M-<del>])
+  
+  (define-key function-key-map "\e[Z" [?\S-\t])
+  (define-key function-key-map "\e[072q" [?\C-\t])
+  ;; This only works if you remove the M-TAB keybing from the system.4Dwmrc
+  ;; our your ~/.4Dwmrc, if you use the 4Dwm window manager.
+  (define-key function-key-map "\e[073q" [?\M-\t])
+  
+  (define-key function-key-map "\e[074q" [?\M-q])
 
-(define-key function-key-map "\e[084q" [?\M-\[])
-
-(define-key function-key-map "\e[085q" [?\M-\]])
-
-(define-key function-key-map "\e[086q" [?\M-\\])
-
-(define-key function-key-map "\e[087q" [?\M-a])
-
-(define-key function-key-map "\e[088q" [?\M-s])
+  (define-key function-key-map "\e[075q" [?\M-w])
+  
+  (define-key function-key-map "\e[076q" [?\M-e])
 
-(define-key function-key-map "\e[089q" [?\M-d])
-
-(define-key function-key-map "\e[090q" [?\M-f])
-
-(define-key function-key-map "\e[091q" [?\M-g])
-
-(define-key function-key-map "\e[092q" [?\M-h])
-
-(define-key function-key-map "\e[093q" [?\M-j])
-
-(define-key function-key-map "\e[094q" [?\M-k])
-
-(define-key function-key-map "\e[095q" [?\M-l])
+  (define-key function-key-map "\e[077q" [?\M-r])
+  
+  (define-key function-key-map "\e[078q" [?\M-t])
+  
+  (define-key function-key-map "\e[079q" [?\M-y])
+  
+  (define-key function-key-map "\e[080q" [?\M-u])
+  
+  (define-key function-key-map "\e[081q" [?\M-i])
 
-(define-key function-key-map "\e[096q" [?\C-\;])
-(define-key function-key-map "\e[097q" [?\M-:]) ;; we are cheating
-						;; here, this is realy
-						;; M-;, but M-:
-						;; generates the same
-						;; string and is more
-						;; usefull.
-
-(define-key function-key-map "\e[098q" [?\C-'])
-(define-key function-key-map "\e[099q" [?\M-'])
-
-(define-key function-key-map "\e[100q" [?\M-\n])
-
-(define-key function-key-map "\e[101q" [?\M-z])
-
-(define-key function-key-map "\e[102q" [?\M-x])
+  (define-key function-key-map "\e[082q" [?\M-o])
+  
+  (define-key function-key-map "\e[083q" [?\M-p])
+  
+  (define-key function-key-map "\e[084q" [?\M-\[])
+  
+  (define-key function-key-map "\e[085q" [?\M-\]])
+  
+  (define-key function-key-map "\e[086q" [?\M-\\])
+  
+  (define-key function-key-map "\e[087q" [?\M-a])
+  
+  (define-key function-key-map "\e[088q" [?\M-s])
+  
+  (define-key function-key-map "\e[089q" [?\M-d])
+  
+  (define-key function-key-map "\e[090q" [?\M-f])
+  
+  (define-key function-key-map "\e[091q" [?\M-g])
+  
+  (define-key function-key-map "\e[092q" [?\M-h])
+  
+  (define-key function-key-map "\e[093q" [?\M-j])
+  
+  (define-key function-key-map "\e[094q" [?\M-k])
+  
+  (define-key function-key-map "\e[095q" [?\M-l])
+  
+  (define-key function-key-map "\e[096q" [?\C-\;])
+  (define-key function-key-map "\e[097q" [?\M-:]) ;; we are cheating
+						  ;; here, this is
+						  ;; realy M-;, but
+						  ;; M-: generates the
+						  ;; same string and
+						  ;; is more usefull.
 
-(define-key function-key-map "\e[103q" [?\M-c])
-
-(define-key function-key-map "\e[104q" [?\M-v])
-
-(define-key function-key-map "\e[105q" [?\M-b])
-
-(define-key function-key-map "\e[106q" [M-n])
-
-(define-key function-key-map "\e[107q" [M-m])
-
-(define-key function-key-map "\e[108q" [?\C-,])
-(define-key function-key-map "\e[109q" [?\M-,])
-
-(define-key function-key-map "\e[110q" [?\C-.])
-(define-key function-key-map "\e[111q" [?\M-.])
+  (define-key function-key-map "\e[098q" [?\C-'])
+  (define-key function-key-map "\e[099q" [?\M-'])
+  
+  (define-key function-key-map "\e[100q" [?\M-\n])
+  
+  (define-key function-key-map "\e[101q" [?\M-z])
+  
+  (define-key function-key-map "\e[102q" [?\M-x])
+  
+  (define-key function-key-map "\e[103q" [?\M-c])
+  
+  (define-key function-key-map "\e[104q" [?\M-v])
+  
+  (define-key function-key-map "\e[105q" [?\M-b])
+  
+  (define-key function-key-map "\e[106q" [M-n])
+  
+  (define-key function-key-map "\e[107q" [M-m])
+  
+  (define-key function-key-map "\e[108q" [?\C-,])
+  (define-key function-key-map "\e[109q" [?\M-,])
+  
+  (define-key function-key-map "\e[110q" [?\C-.])
+  (define-key function-key-map "\e[111q" [?\M-.])
+  
+  (define-key function-key-map "\e[112q" [?\C-/])
+  (define-key function-key-map "\e[113q" [?\M-/])
+  
+  (define-key function-key-map "\e[139q" [insert])
+  (define-key function-key-map "\e[139q" [S-insert])
+  (define-key function-key-map "\e[140q" [C-insert])
+  (define-key function-key-map "\e[141q" [M-insert])
+  
+  (define-key function-key-map "\e[H" [home])
+  (define-key function-key-map "\e[143q" [S-home])
+  (define-key function-key-map "\e[144q" [C-home])
+  
 
-(define-key function-key-map "\e[112q" [?\C-/])
-(define-key function-key-map "\e[113q" [?\M-/])
-
-(define-key function-key-map "\e[139q" [insert])
-(define-key function-key-map "\e[139q" [S-insert])
-(define-key function-key-map "\e[140q" [C-insert])
-(define-key function-key-map "\e[141q" [M-insert])
+  (define-key function-key-map "\e[150q" [prior])
+  (define-key function-key-map "\e[151q" [S-prior]) ;; those don't
+						    ;; seem to
+						    ;; generate
+						    ;; anything
+  (define-key function-key-map "\e[152q" [C-prior])
 
-(define-key function-key-map "\e[H" [home])
-(define-key function-key-map "\e[143q" [S-home])
-(define-key function-key-map "\e[144q" [C-home])
-
-
-(define-key function-key-map "\e[150q" [prior])
-(define-key function-key-map "\e[151q" [S-prior]) ;; those don't seem
+  
+  ;; (define-key function-key-map "^?" [delete]) 
+  (define-key function-key-map "\e[P" [S-delete])
+  (define-key function-key-map "\e[142q" [C-delete])
+  (define-key function-key-map "\e[M" [M-delete])
+  
+  (define-key function-key-map "\e[146q" [end])
+  (define-key function-key-map "\e[147q" [S-end]) ;; those don't seem
 						  ;; to generate
 						  ;; anything
-(define-key function-key-map "\e[152q" [C-prior])
-
-
-;; (define-key function-key-map "^?" [delete]) ?? something else seems to take care of this.
-(define-key function-key-map "\e[P" [S-delete])
-(define-key function-key-map "\e[142q" [C-delete])
-(define-key function-key-map "\e[M" [M-delete])
-
-(define-key function-key-map "\e[146q" [end])
-(define-key function-key-map "\e[147q" [S-end]) ;; those don't seem to
-						;; generate anything
-(define-key function-key-map "\e[148q" [C-end])
-
-(define-key function-key-map "\e[154q" [next])
-(define-key function-key-map "\e[155q" [S-next])
-(define-key function-key-map "\e[156q" [C-next])
-
-
-(define-key function-key-map "\e[161q" [S-up])
-(define-key function-key-map "\e[162q" [C-up])
-(define-key function-key-map "\e[163q" [M-up])
-
-(define-key function-key-map "\e[158q" [S-left])
-(define-key function-key-map "\e[159q" [C-left])
-(define-key function-key-map "\e[160q" [M-left])
-
-(define-key function-key-map "\e[164q" [S-down])
-(define-key function-key-map "\e[165q" [C-down])
-(define-key function-key-map "\e[166q" [M-down])
-
-(define-key function-key-map "\e[167q" [S-right])
-(define-key function-key-map "\e[168q" [C-right])
-(define-key function-key-map "\e[169q" [M-right])
-
-;; Keypad functions, most of those are untested.
-(define-key function-key-map "\e[179q" [?\C-/])
-(define-key function-key-map "\e[180q" [?\M-/])
-
-(define-key function-key-map "\e[187q" [?\C-*])
-(define-key function-key-map "\e[188q" [?\M-*])
-
-(define-key function-key-map "\e[198q" [?\C--])
-(define-key function-key-map "\e[199q" [?\M--])
+  (define-key function-key-map "\e[148q" [C-end])
+  
+  (define-key function-key-map "\e[154q" [next])
+  (define-key function-key-map "\e[155q" [S-next])
+  (define-key function-key-map "\e[156q" [C-next])
+  
 
-;; Something else takes care of home, up, prior, down, left, right, next
-;(define-key function-key-map "\e[H" [home])
-(define-key function-key-map "\e[172q" [C-home])
-
-;(define-key function-key-map "\e[A" [up])
-(define-key function-key-map "\e[182q" [C-up])
-
-
-;(define-key function-key-map "\e[150q" [prior])
-(define-key function-key-map "\e[190q" [C-prior])
-
-
-(define-key function-key-map "\e[200q" [?\C-+])
-(define-key function-key-map "\e[201q" [?\M-+])
-
-;(define-key function-key-map "\e[D" [left])
-(define-key function-key-map "\e[174q" [C-left])
-
-
-(define-key function-key-map "\e[000q" [begin])
-(define-key function-key-map "\e[184q" [C-begin])
+  (define-key function-key-map "\e[161q" [S-up])
+  (define-key function-key-map "\e[162q" [C-up])
+  (define-key function-key-map "\e[163q" [M-up])
+  
+  (define-key function-key-map "\e[158q" [S-left])
+  (define-key function-key-map "\e[159q" [C-left])
+  (define-key function-key-map "\e[160q" [M-left])
+  
+  (define-key function-key-map "\e[164q" [S-down])
+  (define-key function-key-map "\e[165q" [C-down])
+  (define-key function-key-map "\e[166q" [M-down])
+  
+  (define-key function-key-map "\e[167q" [S-right])
+  (define-key function-key-map "\e[168q" [C-right])
+  (define-key function-key-map "\e[169q" [M-right])
+  
+  ;; Keypad functions, most of those are untested.
+  (define-key function-key-map "\e[179q" [?\C-/])
+  (define-key function-key-map "\e[180q" [?\M-/])
+  
+  (define-key function-key-map "\e[187q" [?\C-*])
+  (define-key function-key-map "\e[188q" [?\M-*])
+  
+  (define-key function-key-map "\e[198q" [?\C--])
+  (define-key function-key-map "\e[199q" [?\M--])
+  
+  ;; Something else takes care of home, up, prior, down, left, right, next
+  ;;(define-key function-key-map "\e[H" [home])
+  (define-key function-key-map "\e[172q" [C-home])
+  
+  ;;(define-key function-key-map "\e[A" [up])
+  (define-key function-key-map "\e[182q" [C-up])
+  
+  
+  ;;(define-key function-key-map "\e[150q" [prior])
+  (define-key function-key-map "\e[190q" [C-prior])
+  
+  
+  (define-key function-key-map "\e[200q" [?\C-+])
+  (define-key function-key-map "\e[201q" [?\M-+])
+  
+  ;;(define-key function-key-map "\e[D" [left])
+  (define-key function-key-map "\e[174q" [C-left])
 
-
-;(define-key function-key-map "\e[C" [right])
-(define-key function-key-map "\e[192q" [C-right])
-
-;(define-key function-key-map "\e[146q" [end])
-(define-key function-key-map "\e[176q" [C-end])
-
-;(define-key function-key-map "\e[B" [down])
-(define-key function-key-map "\e[186q" [C-down])
+  
+  (define-key function-key-map "\e[000q" [begin])
+  (define-key function-key-map "\e[184q" [C-begin])
 
-;(define-key function-key-map "\e[154q" [next])
-(define-key function-key-map "\e[194q" [C-next])
-
-
-(define-key function-key-map "\e[100q" [M-enter])
-
-(define-key function-key-map "\e[139q" [insert])
-(define-key function-key-map "\e[178q" [C-inset])
-
-(define-key function-key-map "\e[P" [delete])
-(define-key function-key-map "\e[196q" [C-delete])
-(define-key function-key-map "\e[197q" [M-delete])
+  
+  ;;(define-key function-key-map "\e[C" [right])
+  (define-key function-key-map "\e[192q" [C-right])
+  
+  ;;(define-key function-key-map "\e[146q" [end])
+  (define-key function-key-map "\e[176q" [C-end])
+  
+  ;;(define-key function-key-map "\e[B" [down])
+  (define-key function-key-map "\e[186q" [C-down])
+  
+  ;;(define-key function-key-map "\e[154q" [next])
+  (define-key function-key-map "\e[194q" [C-next])
+  
+  
+  (define-key function-key-map "\e[100q" [M-enter])
+  
+  (define-key function-key-map "\e[139q" [insert])
+  (define-key function-key-map "\e[178q" [C-inset])
+  
+  (define-key function-key-map "\e[P" [delete])
+  (define-key function-key-map "\e[196q" [C-delete])
+  (define-key function-key-map "\e[197q" [M-delete]))
 
 ;;; arch-tag: b1d0e73a-bb7d-47be-9fb2-6fb126469a1b
 ;;; iris-ansi.el ends here
--- a/lisp/term/linux.el	Tue Jul 26 12:03:19 2005 +0000
+++ b/lisp/term/linux.el	Fri Jul 29 01:54:54 2005 +0000
@@ -1,19 +1,21 @@
 ;; -*- no-byte-compile: t -*-
 ;; The Linux console handles Latin-1 by default.
 
-(unless (terminal-coding-system)
-  (set-terminal-coding-system 'iso-latin-1))
+(defun terminal-init-linux ()
+  "Terminal initialization function for linux."  
+  (unless (terminal-coding-system)
+    (set-terminal-coding-system 'iso-latin-1))
 
-;; It can't really display underlines.
-(tty-no-underline)
+  ;; It can't really display underlines.
+  (tty-no-underline)
 
-;; Make Latin-1 input characters work, too.
-;; Meta will continue to work, because the kernel
-;; turns that into Escape.
+  ;; Make Latin-1 input characters work, too.
+  ;; Meta will continue to work, because the kernel
+  ;; turns that into Escape.
 
-(let ((value (current-input-mode)))
-  ;; The third arg only matters in that it is not t or nil.
-  (set-input-mode (nth 0 value) (nth 1 value) 'iso-latin-1 (nth 3 value)))
+  (let ((value (current-input-mode)))
+    ;; The third arg only matters in that it is not t or nil.
+    (set-input-mode (nth 0 value) (nth 1 value) 'iso-latin-1 (nth 3 value))))
 
 ;;; arch-tag: 5d0c4f63-739b-4862-abf3-041fe42adb8f
 ;;; linux.el ends here
--- a/lisp/term/news.el	Tue Jul 26 12:03:19 2005 +0000
+++ b/lisp/term/news.el	Fri Jul 29 01:54:54 2005 +0000
@@ -1,6 +1,6 @@
 ;;; news.el --- keypad and function key bindings for the Sony NEWS keyboard -*- no-byte-compile: t -*-
 
-;; Copyright (C) 1989, 1993 Free Software Foundation, Inc.
+;; Copyright (C) 1989, 1993, 2005 Free Software Foundation, Inc.
 
 ;; Author: FSF
 ;; Keywords: terminals
@@ -28,47 +28,49 @@
 
 ;;; Code:
 
-(if (boundp 'news-fkey-prefix)
-    nil
-  ;; The terminal initialization should already have set up some keys
-  (setq news-fkey-prefix (lookup-key function-key-map "\eO"))
-  (if (not (keymapp news-fkey-prefix))
-      (error "What?  Your news termcap/terminfo has no keycaps in it"))
+(defun terminal-init-news ()
+  "Terminal initialization function for news."  
+  (if (boundp 'news-fkey-prefix)
+      nil
+    ;; The terminal initialization should already have set up some keys
+    (setq news-fkey-prefix (lookup-key function-key-map "\eO"))
+    (if (not (keymapp news-fkey-prefix))
+	(error "What?  Your news termcap/terminfo has no keycaps in it"))
 
-  ;; Termcap or terminfo will set these
-  ;; (define-key news-fkey-prefix "P" [f1])
-  ;; (define-key news-fkey-prefix "Q" [f2])
-  ;; (define-key news-fkey-prefix "R" [f3])
-  ;; (define-key news-fkey-prefix "S" [f4])
-  ;; (define-key news-fkey-prefix "T" [f5])
-  ;; (define-key news-fkey-prefix "U" [f6])
-  ;; (define-key news-fkey-prefix "V" [f7])
-  ;; (define-key news-fkey-prefix "W" [f8])
-  ;; (define-key news-fkey-prefix "X" [f9])
-  ;; (define-key news-fkey-prefix "Y" [f10])
+    ;; Termcap or terminfo will set these
+    ;; (define-key news-fkey-prefix "P" [f1])
+    ;; (define-key news-fkey-prefix "Q" [f2])
+    ;; (define-key news-fkey-prefix "R" [f3])
+    ;; (define-key news-fkey-prefix "S" [f4])
+    ;; (define-key news-fkey-prefix "T" [f5])
+    ;; (define-key news-fkey-prefix "U" [f6])
+    ;; (define-key news-fkey-prefix "V" [f7])
+    ;; (define-key news-fkey-prefix "W" [f8])
+    ;; (define-key news-fkey-prefix "X" [f9])
+    ;; (define-key news-fkey-prefix "Y" [f10])
 
-  ;; Terminfo will set these
-  (define-key news-fkey-prefix "a" [execute])
-  (define-key news-fkey-prefix "b" [select])
-  (define-key news-fkey-prefix "c" [cancel])
-  (define-key news-fkey-prefix "M" [kp-enter])
-  (define-key news-fkey-prefix "q" [kp-1])
-  (define-key news-fkey-prefix "s" [kp-3])
-  (define-key news-fkey-prefix "u" [kp-5])
-  (define-key news-fkey-prefix "w" [kp-7])
-  (define-key news-fkey-prefix "y" [kp-9])
+    ;; Terminfo will set these
+    (define-key news-fkey-prefix "a" [execute])
+    (define-key news-fkey-prefix "b" [select])
+    (define-key news-fkey-prefix "c" [cancel])
+    (define-key news-fkey-prefix "M" [kp-enter])
+    (define-key news-fkey-prefix "q" [kp-1])
+    (define-key news-fkey-prefix "s" [kp-3])
+    (define-key news-fkey-prefix "u" [kp-5])
+    (define-key news-fkey-prefix "w" [kp-7])
+    (define-key news-fkey-prefix "y" [kp-9])
 
-  ;; These aren't in either termcap or terminfo's repertoire
-  (define-key news-fkey-prefix "m" [kp-subtract])
-  (define-key news-fkey-prefix "k" [kp-add])
-  (define-key news-fkey-prefix "l" [kp-separator])
-  (define-key news-fkey-prefix "n" [kp-decimal])
-  (define-key news-fkey-prefix "p" [kp-0])
-  (define-key news-fkey-prefix "r" [kp-2])
-  (define-key news-fkey-prefix "t" [kp-4])
-  (define-key news-fkey-prefix "v" [kp-6])
-  (define-key news-fkey-prefix "x" [kp-8])
-  )
+    ;; These aren't in either termcap or terminfo's repertoire
+    (define-key news-fkey-prefix "m" [kp-subtract])
+    (define-key news-fkey-prefix "k" [kp-add])
+    (define-key news-fkey-prefix "l" [kp-separator])
+    (define-key news-fkey-prefix "n" [kp-decimal])
+    (define-key news-fkey-prefix "p" [kp-0])
+    (define-key news-fkey-prefix "r" [kp-2])
+    (define-key news-fkey-prefix "t" [kp-4])
+    (define-key news-fkey-prefix "v" [kp-6])
+    (define-key news-fkey-prefix "x" [kp-8])
+    ))
 
 ;;; arch-tag: bfe141a0-623b-4b42-b753-5d9353776c5e
 ;;; news.el ends here
--- a/lisp/term/rxvt.el	Tue Jul 26 12:03:19 2005 +0000
+++ b/lisp/term/rxvt.el	Fri Jul 29 01:54:54 2005 +0000
@@ -1,6 +1,6 @@
 ;;; rxvt.el --- define function key sequences and standard colors for rxvt
 
-;; Copyright (C) 2002 Free Software Foundation, Inc.
+;; Copyright (C) 2002, 2005 Free Software Foundation, Inc.
 
 ;; Author: Eli Zaretskii
 ;; Keywords: terminals
@@ -26,73 +26,143 @@
 
 ;;; Code:
 
-;; Set up function-key-map entries that termcap and terminfo don't know.
-(let ((map (make-sparse-keymap)))
-  (define-key map "\e[A" [up])
-  (define-key map "\e[B" [down])
-  (define-key map "\e[C" [right])
-  (define-key map "\e[D" [left])
-  (define-key map "\e[7~" [home])
-  (define-key map "\e[2~" [insert])
-  (define-key map "\e[3~" [delete])
-  (define-key map "\e[4~" [select])
-  (define-key map "\e[5~" [prior])
-  (define-key map "\e[6~" [next])
-  (define-key map "\e[11~" [f1])
-  (define-key map "\e[12~" [f2])
-  (define-key map "\e[13~" [f3])
-  (define-key map "\e[14~" [f4])
-  (define-key map "\e[15~" [f5])
-  (define-key map "\e[17~" [f6])
-  (define-key map "\e[18~" [f7])
-  (define-key map "\e[19~" [f8])
-  (define-key map "\e[20~" [f9])
-  (define-key map "\e[21~" [f10])
-  (define-key map "\e[23~" [f11])
-  (define-key map "\e[24~" [f12])
-  (define-key map "\e[29~" [print])
+(defun terminal-init-rxvt ()
+  "Terminal initialization function for rxvt."
+  ;; The terminal intialization C code file might have initialized
+  ;; function keys F11->F42 from the termcap/terminfo information.  On
+  ;; a PC-style keyboard these keys correspond to
+  ;; MODIFIER-FUNCTION_KEY, where modifier is S-, C-, C-S-.  The
+  ;; code here subsitutes the corresponding defintions in
+  ;; function-key-map. This substitution is needed because if a key
+  ;; definition if found in function-key-map, there are no further
+  ;; lookups in other keymaps.
+  (substitute-key-definition [f11] [S-f1] function-key-map) 
+  (substitute-key-definition [f12] [S-f2] function-key-map)
+  (substitute-key-definition [f13] [S-f3] function-key-map)
+  (substitute-key-definition [f14] [S-f4] function-key-map)
+  (substitute-key-definition [f15] [S-f5] function-key-map)
+  (substitute-key-definition [f16] [S-f6] function-key-map)
+  (substitute-key-definition [f17] [S-f7] function-key-map)
+  (substitute-key-definition [f18] [S-f8] function-key-map)
+  (substitute-key-definition [f19] [S-f9] function-key-map)
+  (substitute-key-definition [f20] [S-f10] function-key-map)
+
+  (substitute-key-definition [f23] [C-f1] function-key-map) 
+  (substitute-key-definition [f24] [C-f2] function-key-map)
+  (substitute-key-definition [f25] [C-f3] function-key-map)
+  (substitute-key-definition [f26] [C-f4] function-key-map)
+  (substitute-key-definition [f27] [C-f5] function-key-map)
+  (substitute-key-definition [f28] [C-f6] function-key-map)
+  (substitute-key-definition [f29] [C-f7] function-key-map)
+  (substitute-key-definition [f30] [C-f8] function-key-map)
+  (substitute-key-definition [f31] [C-f9] function-key-map)
+  (substitute-key-definition [f32] [C-f10] function-key-map)
+
+  (substitute-key-definition [f33] [C-S-f1] function-key-map) 
+  (substitute-key-definition [f34] [C-S-f2] function-key-map)
+  (substitute-key-definition [f35] [C-S-f3] function-key-map)
+  (substitute-key-definition [f36] [C-S-f4] function-key-map)
+  (substitute-key-definition [f37] [C-S-f5] function-key-map)
+  (substitute-key-definition [f38] [C-S-f6] function-key-map)
+  (substitute-key-definition [f39] [C-S-f7] function-key-map)
+  (substitute-key-definition [f40] [C-S-f8] function-key-map)
+  (substitute-key-definition [f41] [C-S-f9] function-key-map)
+  (substitute-key-definition [f42] [C-S-f10] function-key-map)
 
-  (define-key map "\e[11^" [C-f1])
-  (define-key map "\e[12^" [C-f2])
-  (define-key map "\e[13^" [C-f3])
-  (define-key map "\e[14^" [C-f4])
-  (define-key map "\e[15^" [C-f5])
-  (define-key map "\e[17^" [C-f6])
-  (define-key map "\e[18^" [C-f7])
-  (define-key map "\e[19^" [C-f8])
-  (define-key map "\e[20^" [C-f9])
-  (define-key map "\e[21^" [C-f10])
-  (define-key map "\e[23^" [C-f11])
-  (define-key map "\e[24^" [C-f12])
+  ;; Set up function-key-map entries that termcap and terminfo don't know.
+  (let ((map (make-sparse-keymap)))
+    (define-key map "\e[A" [up])
+    (define-key map "\e[B" [down])
+    (define-key map "\e[C" [right])
+    (define-key map "\e[D" [left])
+    (define-key map "\e[7~" [home])
+    (define-key map "\e[2~" [insert])
+    (define-key map "\e[3~" [delete])
+    (define-key map "\e[4~" [select])
+    (define-key map "\e[5~" [prior])
+    (define-key map "\e[6~" [next])
+    (define-key map "\e[11~" [f1])
+    (define-key map "\e[12~" [f2])
+    (define-key map "\e[13~" [f3])
+    (define-key map "\e[14~" [f4])
+    (define-key map "\e[15~" [f5])
+    (define-key map "\e[17~" [f6])
+    (define-key map "\e[18~" [f7])
+    (define-key map "\e[19~" [f8])
+    (define-key map "\e[20~" [f9])
+    (define-key map "\e[21~" [f10])
+    ;; The strings emitted by f11 and f12 are the same as the strings
+    ;; emitted by S-f1 and S-f2, so don't define f11 and f12.
+    ;; (define-key map "\e[23~" [f11])
+    ;; (define-key map "\e[24~" [f12])
+    (define-key map "\e[29~" [print])
 
-  (define-key map "\e[29~" [print])
-
-  (define-key map "\e[2;2~" [S-insert])
-  (define-key map "\e[3$" [S-delete])
+    (define-key map "\e[11^" [C-f1])
+    (define-key map "\e[12^" [C-f2])
+    (define-key map "\e[13^" [C-f3])
+    (define-key map "\e[14^" [C-f4])
+    (define-key map "\e[15^" [C-f5])
+    (define-key map "\e[17^" [C-f6])
+    (define-key map "\e[18^" [C-f7])
+    (define-key map "\e[19^" [C-f8])
+    (define-key map "\e[20^" [C-f9])
+    (define-key map "\e[21^" [C-f10])
 
-  (define-key map "\e[2^" [C-insert])
-  (define-key map "\e[3^" [C-delete])
-  (define-key map "\e[5^" [C-prior])
-  (define-key map "\e[6^" [C-next])
-  (define-key map "\eOd" [C-left])
-  (define-key map "\eOc" [C-right])
-  (define-key map "\eOa" [C-up])
-  (define-key map "\eOb" [C-down])
+    (define-key map "\e[23~" [S-f1])
+    (define-key map "\e[24~" [S-f2])
+    (define-key map "\e[25~" [S-f3])
+    (define-key map "\e[26~" [S-f4])
+    (define-key map "\e[28~" [S-f5])
+    (define-key map "\e[29~" [S-f6])
+    (define-key map "\e[31~" [S-f7])
+    (define-key map "\e[32~" [S-f8])
+    (define-key map "\e[33~" [S-f9])
+    (define-key map "\e[34~" [S-f10])
+
+    (define-key map "\e[23^" [C-S-f1])
+    (define-key map "\e[24^" [C-S-f2])
+    (define-key map "\e[25^" [C-S-f3])
+    (define-key map "\e[26^" [C-S-f4])
+    (define-key map "\e[28^" [C-S-f5])
+    (define-key map "\e[29^" [C-S-f6])
+    (define-key map "\e[31^" [C-S-f7])
+    (define-key map "\e[32^" [C-S-f8])
+    (define-key map "\e[33^" [C-S-f9])
+    (define-key map "\e[34^" [C-S-f10])
 
-  (define-key map "\e[5$" [S-prior])
-  (define-key map "\e[6$" [S-next])
-  (define-key map "\e[8$" [S-end])
-  (define-key map "\e[7$" [S-home])
-  (define-key map "\e[d" [S-left])
-  (define-key map "\e[c" [S-right])
-  (define-key map "\e[a" [S-up])
-  (define-key map "\e[b" [S-down])
+    (define-key map "\e[2^" [C-insert])
+    (define-key map "\e[3^" [C-delete])
+    (define-key map "\e[5^" [C-prior])
+    (define-key map "\e[6^" [C-next])
+    (define-key map "\e[7^" [C-home])
+    (define-key map "\e[8^" [C-end])
+    (define-key map "\eOd" [C-left])
+    (define-key map "\eOc" [C-right])
+    (define-key map "\eOa" [C-up])
+    (define-key map "\eOb" [C-down])
 
-  ;; Use inheritance to let the main keymap override those defaults.
-  ;; This way we don't override terminfo-derived settings or settings
-  ;; made in the .emacs file.
-  (set-keymap-parent map (keymap-parent function-key-map))
-  (set-keymap-parent function-key-map map))
+    (define-key map "\e[2;2~" [S-insert])
+    (define-key map "\e[3$" [S-delete])
+    (define-key map "\e[5$" [S-prior])
+    (define-key map "\e[6$" [S-next])
+    (define-key map "\e[8$" [S-end])
+    (define-key map "\e[7$" [S-home])
+    (define-key map "\e[d" [S-left])
+    (define-key map "\e[c" [S-right])
+    (define-key map "\e[a" [S-up])
+    (define-key map "\e[b" [S-down])
+
+    ;; Use inheritance to let the main keymap override those defaults.
+    ;; This way we don't override terminfo-derived settings or settings
+    ;; made in the .emacs file.
+    (set-keymap-parent map (keymap-parent function-key-map))
+    (set-keymap-parent function-key-map map))
+
+  ;; Initialize colors and background mode.
+  (rxvt-register-default-colors)
+  (rxvt-set-background-mode)
+  ;; This recomputes all the default faces given the colors we've just set up.
+  (tty-set-up-initial-frame-faces))
 
 ;; Set up colors, for those versions of rxvt that support it.
 (defvar rxvt-standard-colors
@@ -166,11 +236,5 @@
 	  (setq default-frame-background-mode 'dark)))
     (frame-set-background-mode (selected-frame))))
 
-;; Do it!
-(rxvt-register-default-colors)
-(rxvt-set-background-mode)
-;; This recomputes all the default faces given the colors we've just set up.
-(tty-set-up-initial-frame-faces)
-
 ;;; arch-tag: 20cf2fb6-6318-4bab-9dbf-1d15048f2257
 ;;; rxvt.el ends here
--- a/lisp/term/sun.el	Tue Jul 26 12:03:19 2005 +0000
+++ b/lisp/term/sun.el	Fri Jul 29 01:54:54 2005 +0000
@@ -1,6 +1,6 @@
 ;;; sun.el --- keybinding for standard default sunterm keys
 
-;; Copyright (C) 1987, 2001 Free Software Foundation, Inc.
+;; Copyright (C) 1987, 2001, 2005 Free Software Foundation, Inc.
 
 ;; Author: Jeff Peck <peck@sun.com>
 ;; Keywords: terminals
@@ -93,58 +93,6 @@
 ;;
 
 (defvar sun-raw-prefix (make-sparse-keymap))
-(define-key function-key-map "\e[" sun-raw-prefix)
-
-(define-key sun-raw-prefix "210z" [r3])
-(define-key sun-raw-prefix "213z" [r6])
-(define-key sun-raw-prefix "214z" [r7])
-(define-key sun-raw-prefix "216z" [r9])
-(define-key sun-raw-prefix "218z" [r11])
-(define-key sun-raw-prefix "220z" [r13])
-(define-key sun-raw-prefix "222z" [r15])
-(define-key sun-raw-prefix "193z" [redo])
-(define-key sun-raw-prefix "194z" [props])
-(define-key sun-raw-prefix "195z" [undo])
-;; (define-key sun-raw-prefix "196z" 'ignore)		; Expose-down
-;; (define-key sun-raw-prefix "197z" [put])
-;; (define-key sun-raw-prefix "198z" 'ignore)		; Open-down
-;; (define-key sun-raw-prefix "199z" [get])
-(define-key sun-raw-prefix "200z" [find])
-;; (define-key sun-raw-prefix "201z" 'kill-region-and-unmark)	; Delete
-(define-key sun-raw-prefix "224z" [f1])
-(define-key sun-raw-prefix "225z" [f2])
-(define-key sun-raw-prefix "226z" [f3])
-(define-key sun-raw-prefix "227z" [f4])
-(define-key sun-raw-prefix "228z" [f5])
-(define-key sun-raw-prefix "229z" [f6])
-(define-key sun-raw-prefix "230z" [f7])
-(define-key sun-raw-prefix "231z" [f8])
-(define-key sun-raw-prefix "232z" [f9])
-(define-key sun-raw-prefix "233z" [f10])
-(define-key sun-raw-prefix "234z" [f11])
-(define-key sun-raw-prefix "235z" [f12])
-(define-key sun-raw-prefix "A" [up])			; R8
-(define-key sun-raw-prefix "B" [down])			; R14
-(define-key sun-raw-prefix "C" [right])			; R12
-(define-key sun-raw-prefix "D" [left])			; R10
-
-(global-set-key [r3]	'backward-page)
-(global-set-key [r6]	'forward-page)
-(global-set-key [r7]	'beginning-of-buffer)
-(global-set-key [r9]	'scroll-down)
-(global-set-key [r11]	'recenter)
-(global-set-key [r13]	'end-of-buffer)
-(global-set-key [r15]	'scroll-up)
-(global-set-key [redo]	'redraw-display)  ;FIXME: collides with default.
-(global-set-key [props]	'list-buffers)
-(global-set-key [put]	'sun-select-region)
-(global-set-key [get]	'sun-yank-selection)
-(global-set-key [find]	'exchange-point-and-mark)
-(global-set-key [f3]	'scroll-down-in-place)
-(global-set-key [f4]	'scroll-up-in-place)
-(global-set-key [f6]	'shrink-window)
-(global-set-key [f7]	'enlarge-window)
-
 
 ;; Since .emacs gets loaded before this file, a hook is supplied
 ;; for you to put your own bindings in.
@@ -152,13 +100,6 @@
 (defvar sun-raw-prefix-hooks nil
   "List of forms to evaluate after setting sun-raw-prefix.")
 
-(when sun-raw-prefix-hooks
-  (message "sun-raw-prefix-hooks is obsolete!  Use term-setup-hook instead!")
-  (let ((hooks sun-raw-prefix-hooks))
-    (while hooks
-      (eval (car hooks))
-      (setq hooks (cdr hooks)))))
-
 
 ;;; This section adds definitions for the emacstool users
 ;; emacstool event filter converts function keys to C-x*{c}{lrt}
@@ -188,44 +129,6 @@
 (defvar suntool-map (make-sparse-keymap)
   "*Keymap for Emacstool bindings.")
 
-(define-key suntool-map "gr" 'beginning-of-buffer)	; r7
-(define-key suntool-map "iR" 'backward-page)		; R9
-(define-key suntool-map "ir" 'scroll-down)		; r9
-(define-key suntool-map "kr" 'recenter)			; r11
-(define-key suntool-map "mr" 'end-of-buffer)		; r13
-(define-key suntool-map "oR" 'forward-page)		; R15
-(define-key suntool-map "or" 'scroll-up)		; r15
-(define-key suntool-map "b\M-L" 'rerun-prev-command)	; M-AGAIN
-(define-key suntool-map "b\M-l" 'prev-complex-command)	; M-Again
-(define-key suntool-map "bl" 'redraw-display)		; Again
-(define-key suntool-map "cl" 'list-buffers)		; Props
-(define-key suntool-map "dl" 'undo)			; Undo
-(define-key suntool-map "el" 'ignore)			; Expose-Open
-(define-key suntool-map "fl" 'sun-select-region)	; Put
-(define-key suntool-map "f," 'copy-region-as-kill)	; C-Put
-(define-key suntool-map "gl" 'ignore)			; Open-Open
-(define-key suntool-map "hl" 'sun-yank-selection)	; Get
-(define-key suntool-map "h," 'yank)			; C-Get
-(define-key suntool-map "il" 'research-forward)		; Find
-(define-key suntool-map "i," 're-search-forward)	; C-Find
-(define-key suntool-map "i\M-l" 'research-backward)	; M-Find
-(define-key suntool-map "i\M-," 're-search-backward)	; C-M-Find
-
-(define-key suntool-map "jL" 'yank)			; DELETE
-(define-key suntool-map "jl" 'kill-region-and-unmark)	; Delete
-(define-key suntool-map "j\M-l" 'exchange-point-and-mark); M-Delete
-(define-key suntool-map "j,"
-  (lambda () (interactive) (pop-mark)))		; C-Delete
-
-(define-key suntool-map "fT" 'shrink-window-horizontally)	; T6
-(define-key suntool-map "gT" 'enlarge-window-horizontally)	; T7
-(define-key suntool-map "ft" 'shrink-window)			; t6
-(define-key suntool-map "gt" 'enlarge-window)			; t7
-(define-key suntool-map "cT" (lambda (n) (interactive "p") (scroll-down n)))
-(define-key suntool-map "dT" (lambda (n) (interactive "p") (scroll-up n)))
-(define-key suntool-map "ct" 'scroll-down-in-place)		; t3
-(define-key suntool-map "dt" 'scroll-up-in-place)		; t4
-(define-key ctl-x-map "*" suntool-map)
 
 ;; Since .emacs gets loaded before this file, a hook is supplied
 ;; for you to put your own bindings in.
@@ -233,13 +136,6 @@
 (defvar suntool-map-hooks nil
   "List of forms to evaluate after setting suntool-map.")
 
-(when suntool-map-hooks
-  (message "suntool-map-hooks is obsolete!  Use term-setup-hook instead!")
-  (let ((hooks suntool-map-hooks))
-    (while hooks
-      (eval (car hooks))
-      (setq hooks (cdr hooks)))))
-
 ;;
 ;; If running under emacstool, arrange to call suspend-emacstool
 ;; instead of suspend-emacs.
@@ -251,6 +147,115 @@
 (autoload 'sun-mouse-handler "sun-mouse"
 	  "Sun Emacstool handler for mouse blips (not loaded)." t)
 
+(defun terminal-init-sun ()
+  "Terminal initialization function for sun."
+  (define-key function-key-map "\e[" sun-raw-prefix)
+
+  (define-key sun-raw-prefix "210z" [r3])
+  (define-key sun-raw-prefix "213z" [r6])
+  (define-key sun-raw-prefix "214z" [r7])
+  (define-key sun-raw-prefix "216z" [r9])
+  (define-key sun-raw-prefix "218z" [r11])
+  (define-key sun-raw-prefix "220z" [r13])
+  (define-key sun-raw-prefix "222z" [r15])
+  (define-key sun-raw-prefix "193z" [redo])
+  (define-key sun-raw-prefix "194z" [props])
+  (define-key sun-raw-prefix "195z" [undo])
+  ;; (define-key sun-raw-prefix "196z" 'ignore)		; Expose-down
+  ;; (define-key sun-raw-prefix "197z" [put])
+  ;; (define-key sun-raw-prefix "198z" 'ignore)		; Open-down
+  ;; (define-key sun-raw-prefix "199z" [get])
+  (define-key sun-raw-prefix "200z" [find])
+  ;; (define-key sun-raw-prefix "201z" 'kill-region-and-unmark)	; Delete
+  (define-key sun-raw-prefix "224z" [f1])
+  (define-key sun-raw-prefix "225z" [f2])
+  (define-key sun-raw-prefix "226z" [f3])
+  (define-key sun-raw-prefix "227z" [f4])
+  (define-key sun-raw-prefix "228z" [f5])
+  (define-key sun-raw-prefix "229z" [f6])
+  (define-key sun-raw-prefix "230z" [f7])
+  (define-key sun-raw-prefix "231z" [f8])
+  (define-key sun-raw-prefix "232z" [f9])
+  (define-key sun-raw-prefix "233z" [f10])
+  (define-key sun-raw-prefix "234z" [f11])
+  (define-key sun-raw-prefix "235z" [f12])
+  (define-key sun-raw-prefix "A" [up])			; R8
+  (define-key sun-raw-prefix "B" [down])		; R14
+  (define-key sun-raw-prefix "C" [right])		; R12
+  (define-key sun-raw-prefix "D" [left])		; R10
+
+  (global-set-key [r3]	'backward-page)
+  (global-set-key [r6]	'forward-page)
+  (global-set-key [r7]	'beginning-of-buffer)
+  (global-set-key [r9]	'scroll-down)
+  (global-set-key [r11]	'recenter)
+  (global-set-key [r13]	'end-of-buffer)
+  (global-set-key [r15]	'scroll-up)
+  (global-set-key [redo]	'redraw-display) ;FIXME: collides with default.
+  (global-set-key [props]	'list-buffers)
+  (global-set-key [put]	'sun-select-region)
+  (global-set-key [get]	'sun-yank-selection)
+  (global-set-key [find]	'exchange-point-and-mark)
+  (global-set-key [f3]	'scroll-down-in-place)
+  (global-set-key [f4]	'scroll-up-in-place)
+  (global-set-key [f6]	'shrink-window)
+  (global-set-key [f7]	'enlarge-window)
+
+  (when sun-raw-prefix-hooks
+    (message "sun-raw-prefix-hooks is obsolete!  Use term-setup-hook instead!")
+    (let ((hooks sun-raw-prefix-hooks))
+      (while hooks
+	(eval (car hooks))
+	(setq hooks (cdr hooks)))))
+
+  (define-key suntool-map "gr" 'beginning-of-buffer)	; r7
+  (define-key suntool-map "iR" 'backward-page)		; R9
+  (define-key suntool-map "ir" 'scroll-down)		; r9
+  (define-key suntool-map "kr" 'recenter)		; r11
+  (define-key suntool-map "mr" 'end-of-buffer)		; r13
+  (define-key suntool-map "oR" 'forward-page)		; R15
+  (define-key suntool-map "or" 'scroll-up)		; r15
+  (define-key suntool-map "b\M-L" 'rerun-prev-command)	; M-AGAIN
+  (define-key suntool-map "b\M-l" 'prev-complex-command) ; M-Again
+  (define-key suntool-map "bl" 'redraw-display)		 ; Again
+  (define-key suntool-map "cl" 'list-buffers)		 ; Props
+  (define-key suntool-map "dl" 'undo)			 ; Undo
+  (define-key suntool-map "el" 'ignore)			 ; Expose-Open
+  (define-key suntool-map "fl" 'sun-select-region)	 ; Put
+  (define-key suntool-map "f," 'copy-region-as-kill)	 ; C-Put
+  (define-key suntool-map "gl" 'ignore)			 ; Open-Open
+  (define-key suntool-map "hl" 'sun-yank-selection)	 ; Get
+  (define-key suntool-map "h," 'yank)			 ; C-Get
+  (define-key suntool-map "il" 'research-forward)	 ; Find
+  (define-key suntool-map "i," 're-search-forward)	 ; C-Find
+  (define-key suntool-map "i\M-l" 'research-backward)	 ; M-Find
+  (define-key suntool-map "i\M-," 're-search-backward)	 ; C-M-Find
+
+  (define-key suntool-map "jL" 'yank)			; DELETE
+  (define-key suntool-map "jl" 'kill-region-and-unmark)	; Delete
+  (define-key suntool-map "j\M-l" 'exchange-point-and-mark) ; M-Delete
+  (define-key suntool-map "j,"
+    (lambda () (interactive) (pop-mark))) ; C-Delete
+
+  (define-key suntool-map "fT" 'shrink-window-horizontally)	; T6
+  (define-key suntool-map "gT" 'enlarge-window-horizontally)	; T7
+  (define-key suntool-map "ft" 'shrink-window)			; t6
+  (define-key suntool-map "gt" 'enlarge-window)			; t7
+  (define-key suntool-map "cT" (lambda (n) (interactive "p") (scroll-down n)))
+  (define-key suntool-map "dT" (lambda (n) (interactive "p") (scroll-up n)))
+  (define-key suntool-map "ct" 'scroll-down-in-place)		; t3
+  (define-key suntool-map "dt" 'scroll-up-in-place)		; t4
+  (define-key ctl-x-map "*" suntool-map)
+
+  (when suntool-map-hooks
+    (message "suntool-map-hooks is obsolete!  Use term-setup-hook instead!")
+    (let ((hooks suntool-map-hooks))
+      (while hooks
+	(eval (car hooks))
+	(setq hooks (cdr hooks)))))
+  
+  (define-key ctl-x-map "\C-@" 'sun-mouse-once))
+
 (defun emacstool-init ()
   "Set up Emacstool window, if you know you are in an emacstool."
   ;; Make sure sun-mouse and sun-fns are loaded.
@@ -272,7 +277,6 @@
   (interactive)
   (emacstool-init)
   (sun-mouse-handler))			; Now, execute this mouse blip.
-(define-key ctl-x-map "\C-@" 'sun-mouse-once)
 
 ;;; arch-tag: db761d47-fd7d-42b4-aae1-04fa116b6ba6
 ;;; sun.el ends here
--- a/lisp/term/tvi970.el	Tue Jul 26 12:03:19 2005 +0000
+++ b/lisp/term/tvi970.el	Fri Jul 29 01:54:54 2005 +0000
@@ -3,7 +3,7 @@
 ;; Author: Jim Blandy <jimb@occs.cs.oberlin.edu>, January 1992
 ;; Keywords: terminals
 
-;; Copyright (C) 1992 Free Software Foundation, Inc.
+;; Copyright (C) 1992, 2005 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
@@ -28,77 +28,80 @@
 
 ;;; Code:
 
-(or (lookup-key function-key-map "\e[")
-    (define-key function-key-map "\e[" (make-keymap)))
-;; (or (lookup-key function-key-map "\eO")
-;;    (define-key function-key-map "\eO" (make-keymap)))
+(defun terminal-init-tvi970 ()
+  "Terminal initialization function for tvi970."
+  (or (lookup-key function-key-map "\e[")
+      (define-key function-key-map "\e[" (make-keymap)))
+  ;; (or (lookup-key function-key-map "\eO")
+  ;;    (define-key function-key-map "\eO" (make-keymap)))
 
-;; Miscellaneous keys
-(mapcar (function (lambda (key-binding)
-		    (define-key function-key-map
-		      (car key-binding) (nth 1 key-binding))))
-	'(
-	  ;; These are set up by termcap or terminfo
-	  ;; ("\eOP"	[kp-f1])
-	  ;; ("\eOQ"	[kp-f2])
-	  ;; ("\eOR"	[kp-f3])
-	  ;; ("\eOS"	[kp-f4])
+  ;; Miscellaneous keys
+  (mapcar (function (lambda (key-binding)
+		      (define-key function-key-map
+			(car key-binding) (nth 1 key-binding))))
+	  '(
+	    ;; These are set up by termcap or terminfo
+	    ;; ("\eOP"	[kp-f1])
+	    ;; ("\eOQ"	[kp-f2])
+	    ;; ("\eOR"	[kp-f3])
+	    ;; ("\eOS"	[kp-f4])
 
-	  ;; These might br set by terminfo
-	  ("\e[H"	[home])
-	  ("\e[Z"	[backtab])
-	  ("\e[i"	[print])
-	  ("\e[@"	[insert])
-	  ("\e[L"	[insertline])
-	  ("\e[M"	[deleteline])
-	  ("\e[U"	[next])		;; actually the `page' key
+	    ;; These might br set by terminfo
+	    ("\e[H"	[home])
+	    ("\e[Z"	[backtab])
+	    ("\e[i"	[print])
+	    ("\e[@"	[insert])
+	    ("\e[L"	[insertline])
+	    ("\e[M"	[deleteline])
+	    ("\e[U"	[next])	;; actually the `page' key
 
-	  ;; These won't be set up by either
-	  ("\eOm"	[kp-subtract])
-	  ("\eOl"	[kp-separator])
-	  ("\eOn"	[kp-decimal])
-	  ("\eOM"	[kp-enter])
+	    ;; These won't be set up by either
+	    ("\eOm"	[kp-subtract])
+	    ("\eOl"	[kp-separator])
+	    ("\eOn"	[kp-decimal])
+	    ("\eOM"	[kp-enter])
 
-	  ;; These won't be set up by either either
-	  ("\e[K"	[key_eol])	;; Not an X keysym
-	  ("\e[J"	[key_eos])	;; Not an X keysym
-	  ("\e[2J"	[key_clear])	;; Not an X keysym
-	  ("\e[P"	[key_dc])	;; Not an X keysym
-	  ("\e[g"	[S-tab])	;; Not an X keysym
-	  ("\e[2N"	[clearentry])	;; Not an X keysym
-	  ("\e[2K"	[S-clearentry])	;; Not an X keysym
-	  ("\e[E"	[?\C-j])	;; Not an X keysym
-	  ("\e[g"	[S-backtab])	;; Not an X keysym
-	  ("\e[?1i"	[key_sprint])	;; Not an X keysym
-	  ("\e[4h"	[key_sic])	;; Not an X keysym
-	  ("\e[4l"	[S-delete])	;; Not an X keysym
-	  ("\e[Q"	[S-insertline])	;; Not an X keysym
-	  ("\e[1Q"	[key_sdl])	;; Not an X keysym
-	  ("\e[19l"	[key_seol])	;; Not an X keysym
-	  ("\e[19h"	[S-erasepage])	;; Not an X keysym
-	  ("\e[V"	[S-page])	;; Not an X keysym
-	  ("\eS"	[send])		;; Not an X keysym
-	  ("\e5"	[S-send])	;; Not an X keysym
-	  ))
+	    ;; These won't be set up by either either
+	    ("\e[K"	[key_eol])	;; Not an X keysym
+	    ("\e[J"	[key_eos])	;; Not an X keysym
+	    ("\e[2J"	[key_clear])	;; Not an X keysym
+	    ("\e[P"	[key_dc])	;; Not an X keysym
+	    ("\e[g"	[S-tab])	;; Not an X keysym
+	    ("\e[2N"	[clearentry])	;; Not an X keysym
+	    ("\e[2K"	[S-clearentry])	;; Not an X keysym
+	    ("\e[E"	[?\C-j])	;; Not an X keysym
+	    ("\e[g"	[S-backtab])	;; Not an X keysym
+	    ("\e[?1i"	[key_sprint])	;; Not an X keysym
+	    ("\e[4h"	[key_sic])	;; Not an X keysym
+	    ("\e[4l"	[S-delete])	;; Not an X keysym
+	    ("\e[Q"	[S-insertline])	;; Not an X keysym
+	    ("\e[1Q"	[key_sdl])	;; Not an X keysym
+	    ("\e[19l"	[key_seol])	;; Not an X keysym
+	    ("\e[19h"	[S-erasepage])	;; Not an X keysym
+	    ("\e[V"	[S-page])	;; Not an X keysym
+	    ("\eS"	[send])		;; Not an X keysym
+	    ("\e5"	[S-send])	;; Not an X keysym
+	    ))
 
-;; The numeric keypad keys.
-(let ((i 0))
-  (while (< i 10)
-    (define-key function-key-map
-      (format "\eO%c" (+ i ?p))
-      (vector (intern (format "kp-%d" i))))
-    (setq i (1+ i))))
-;; The numbered function keys.
-(let ((i 0))
-  (while (< i 16)
-    (define-key function-key-map
-      (format "\e?%c" (+ i ?a))
-      (vector (intern (format "f%d" (1+ i)))))
-    (define-key function-key-map
-      (format "\e?%c" (+ i ?A))
-      (vector (intern (format "S-f%d" (1+ i)))))
-    (setq i (1+ i))))
+  ;; The numeric keypad keys.
+  (let ((i 0))
+    (while (< i 10)
+      (define-key function-key-map
+	(format "\eO%c" (+ i ?p))
+	(vector (intern (format "kp-%d" i))))
+      (setq i (1+ i))))
+  ;; The numbered function keys.
+  (let ((i 0))
+    (while (< i 16)
+      (define-key function-key-map
+	(format "\e?%c" (+ i ?a))
+	(vector (intern (format "f%d" (1+ i)))))
+      (define-key function-key-map
+	(format "\e?%c" (+ i ?A))
+	(vector (intern (format "S-f%d" (1+ i)))))
+      (setq i (1+ i))))
 
+  (tvi970-set-keypad-mode 1))
 
 ;;; Should keypad numbers send ordinary digits or distinct escape sequences?
 (defvar tvi970-keypad-numeric nil
@@ -121,7 +124,5 @@
 	  (> (prefix-numeric-value arg) 0)))
   (send-string-to-terminal (if tvi970-keypad-numeric "\e=" "\e>")))
 
-(tvi970-set-keypad-mode 1)
-
 ;;; arch-tag: c1334cf0-1462-41c3-a963-c077d175f8f0
 ;;; tvi970.el ends here
--- a/lisp/term/vt100.el	Tue Jul 26 12:03:19 2005 +0000
+++ b/lisp/term/vt100.el	Fri Jul 29 01:54:54 2005 +0000
@@ -36,8 +36,12 @@
 ;;; Code:
 
 ;; Set up function-key-map entries that termcap and terminfo don't know.
-(load "term/lk201" nil t)
+
 
+(defun terminal-init-vt100 ()
+  "Terminal initialization function for vt100."
+  (load "term/lk201" nil t))
+  
 ;;; Controlling the screen width.
 (defvar vt100-wide-mode (= (frame-width) 132)
   "t if vt100 is in 132-column mode.")
--- a/lisp/term/vt102.el	Tue Jul 26 12:03:19 2005 +0000
+++ b/lisp/term/vt102.el	Fri Jul 29 01:54:54 2005 +0000
@@ -1,6 +1,8 @@
 ;; -*- no-byte-compile: t -*-
 
-(load "term/vt100" nil t)
+(defun terminal-init-vt102 ()
+  "Terminal initialization function for vt102."  
+  (load "term/vt100" nil t))
 
 ;;; arch-tag: 6e839cfc-125a-4574-82f1-c23a51f7c50f
 ;;; vt102.el ends here
--- a/lisp/term/vt125.el	Tue Jul 26 12:03:19 2005 +0000
+++ b/lisp/term/vt125.el	Fri Jul 29 01:54:54 2005 +0000
@@ -1,6 +1,8 @@
 ;; -*- no-byte-compile: t -*-
 
-(load "term/vt100" nil t)
+(defun terminal-init-vt125 ()
+  "Terminal initialization function for vt125."  
+  (load "term/vt100" nil t))
 
 ;;; arch-tag: 1d92d70f-dd55-4a1d-9088-e215a4883801
 ;;; vt125.el ends here
--- a/lisp/term/vt200.el	Tue Jul 26 12:03:19 2005 +0000
+++ b/lisp/term/vt200.el	Fri Jul 29 01:54:54 2005 +0000
@@ -1,10 +1,12 @@
 ;; -*- no-byte-compile: t -*-
 ;; For our purposes we can treat the vt200 and vt100 almost alike.
 ;; Most differences are handled by the termcap entry.
-(load "term/vt100" nil t)
 
-;; Make F11 an escape key.
-(define-key function-key-map "\e[23~" [?\e])
+(defun terminal-init-vt200 ()
+  "Terminal initialization function for vt200."  
+  (load "term/vt100" nil t)
+  ;; Make F11 an escape key.
+  (define-key function-key-map "\e[23~" [?\e]))
 
 ;;; arch-tag: 0f78f583-9f32-4237-b106-28bcfff21d89
 ;;; vt200.el ends here
--- a/lisp/term/vt201.el	Tue Jul 26 12:03:19 2005 +0000
+++ b/lisp/term/vt201.el	Fri Jul 29 01:54:54 2005 +0000
@@ -1,10 +1,11 @@
 ;; -*- no-byte-compile: t -*-
 ;; For our purposes we can treat the vt200 and vt100 almost alike.
 ;; Most differences are handled by the termcap entry.
-(load "term/vt100" nil t)
-
-;; Make F11 an escape key.
-(define-key function-key-map "\e[23~" [?\e])
+(defun terminal-init-vt201 ()
+  "Terminal initialization function for vt201."  
+  (load "term/vt100" nil t)
+  ;; Make F11 an escape key.
+  (define-key function-key-map "\e[23~" [?\e]))
 
 ;;; arch-tag: a6abb38f-60ea-449e-a9e9-3fb8572c52ae
 ;;; vt201.el ends here
--- a/lisp/term/vt220.el	Tue Jul 26 12:03:19 2005 +0000
+++ b/lisp/term/vt220.el	Fri Jul 29 01:54:54 2005 +0000
@@ -1,10 +1,11 @@
 ;; -*- no-byte-compile: t -*-
 ;; For our purposes we can treat the vt200 and vt100 almost alike.
 ;; Most differences are handled by the termcap entry.
-(load "term/vt100" nil t)
-
-;; Make F11 an escape key.
-(define-key function-key-map "\e[23~" [?\e])
+(defun terminal-init-vt220 ()
+  "Terminal initialization function for vt220."  
+  (load "term/vt100" nil t)
+  ;; Make F11 an escape key.
+  (define-key function-key-map "\e[23~" [?\e]))
 
 ;;; arch-tag: 98fc4867-a20d-46a1-a276-d7be31e49871
 ;;; vt220.el ends here
--- a/lisp/term/vt240.el	Tue Jul 26 12:03:19 2005 +0000
+++ b/lisp/term/vt240.el	Fri Jul 29 01:54:54 2005 +0000
@@ -1,10 +1,11 @@
 ;; -*- no-byte-compile: t -*-
 ;; For our purposes we can treat the vt200 and vt100 almost alike.
 ;; Most differences are handled by the termcap entry.
-(load "term/vt100" nil t)
-
-;; Make F11 an escape key.
-(define-key function-key-map "\e[23~" [?\e])
+(defun terminal-init-vt240 ()
+  "Terminal initialization function for vt240."  
+  (load "term/vt100" nil t)
+  ;; Make F11 an escape key.
+  (define-key function-key-map "\e[23~" [?\e]))
 
 ;;; arch-tag: d9f88e9c-02dc-49ff-871c-a415f08e4eb7
 ;;; vt240.el ends here
--- a/lisp/term/vt300.el	Tue Jul 26 12:03:19 2005 +0000
+++ b/lisp/term/vt300.el	Fri Jul 29 01:54:54 2005 +0000
@@ -1,8 +1,9 @@
 ;; -*- no-byte-compile: t -*-
-(load "term/vt100" nil t)
-
-;; Make F11 an escape key.
-(define-key function-key-map "\e[23~" [?\e])
+(defun terminal-init-vt300 ()
+  "Terminal initialization function for vt300."  
+  (load "term/vt100" nil t)
+  ;; Make F11 an escape key.
+  (define-key function-key-map "\e[23~" [?\e]))
 
 ;;; arch-tag: 876831c9-a6f2-444a-b033-706e6fbc149f
 ;;; vt300.el ends here
--- a/lisp/term/vt320.el	Tue Jul 26 12:03:19 2005 +0000
+++ b/lisp/term/vt320.el	Fri Jul 29 01:54:54 2005 +0000
@@ -1,8 +1,9 @@
 ;; -*- no-byte-compile: t -*-
-(load "term/vt100" nil t)
-
-;; Make F11 an escape key.
-(define-key function-key-map "\e[23~" [?\e])
+(defun terminal-init-vt320 ()
+  "Terminal initialization function for vt320."  
+  (load "term/vt100" nil t)
+  ;; Make F11 an escape key.
+  (define-key function-key-map "\e[23~" [?\e]))
 
 ;;; arch-tag: f9f4c954-0b9e-45f9-b450-a320d32abd9c
 ;;; vt320.el ends here
--- a/lisp/term/vt400.el	Tue Jul 26 12:03:19 2005 +0000
+++ b/lisp/term/vt400.el	Fri Jul 29 01:54:54 2005 +0000
@@ -1,8 +1,9 @@
 ;; -*- no-byte-compile: t -*-
-(load "term/vt100" nil t)
-
-;; Make F11 an escape key.
-(define-key function-key-map "\e[23~" [?\e])
+(defun terminal-init-vt400 ()
+  "Terminal initialization function for vt400."  
+  (load "term/vt100" nil t)
+  ;; Make F11 an escape key.
+  (define-key function-key-map "\e[23~" [?\e]))
 
 ;;; arch-tag: a70809c5-6b21-42cc-ba20-536683e5e7d5
 ;;; vt400.el ends here
--- a/lisp/term/vt420.el	Tue Jul 26 12:03:19 2005 +0000
+++ b/lisp/term/vt420.el	Fri Jul 29 01:54:54 2005 +0000
@@ -1,8 +1,9 @@
 ;; -*- no-byte-compile: t -*-
-(load "term/vt100" nil t)
-
-;; Make F11 an escape key.
-(define-key function-key-map "\e[23~" [?\e])
+(defun terminal-init-vt420 ()
+  "Terminal initialization function for vt420."  
+  (load "term/vt100" nil t)
+  ;; Make F11 an escape key.
+  (define-key function-key-map "\e[23~" [?\e]))
 
 ;;; arch-tag: df2f897c-3a12-4b3c-9259-df089f96c160
 ;;; vt420.el ends here
--- a/lisp/term/wyse50.el	Tue Jul 26 12:03:19 2005 +0000
+++ b/lisp/term/wyse50.el	Fri Jul 29 01:54:54 2005 +0000
@@ -1,6 +1,6 @@
 ;;; wyse50.el --- terminal support code for Wyse 50 -*- no-byte-compile: t -*-
 
-;; Copyright (C) 1989, 1993, 1994 Free Software Foundation, Inc.
+;; Copyright (C) 1989, 1993, 1994, 2005 Free Software Foundation, Inc.
 
 ;; Author: Daniel Pfeiffer <occitan@esperanto.org>,
 ;;	Jim Blandy <jimb@occs.cs.oberlin.edu>
@@ -37,74 +37,92 @@
 
 ;;; Code:
 
-(define-key function-key-map "\C-a" (make-keymap))
-(mapcar (function (lambda (key-definition)
-		    (define-key function-key-map
-		      (car key-definition) (nth 1 key-definition))))
-	'(
-	  ;; These might be set up by termcap and terminfo
-	  ("\C-k"	[up])
-	  ("\C-j"	[down])
-	  ("\C-l"	[right])
-	  ("\C-h"	[left])
-	  ("\^a@\^m"	[f1])
-	  ("\^aA\^m"	[f2])
-	  ("\^aB\^m"	[f3])
-	  ("\^aC\^m"	[f4])
-	  ("\^aD\^m"	[f5])
-	  ("\^aE\^m"	[f6])
-	  ("\^aF\^m"	[f7])
-	  ("\^aG\^m"	[f8])
-	  ("\^aH\^m"	[f9])
+(defun terminal-init-wyse50 ()
+  "Terminal initialization function for wyse50."
+  (define-key function-key-map "\C-a" (make-keymap))
+  (mapcar (function (lambda (key-definition)
+		      (define-key function-key-map
+			(car key-definition) (nth 1 key-definition))))
+	  '(
+	    ;; These might be set up by termcap and terminfo
+	    ("\C-k"	[up])
+	    ("\C-j"	[down])
+	    ("\C-l"	[right])
+	    ("\C-h"	[left])
+	    ("\^a@\^m"	[f1])
+	    ("\^aA\^m"	[f2])
+	    ("\^aB\^m"	[f3])
+	    ("\^aC\^m"	[f4])
+	    ("\^aD\^m"	[f5])
+	    ("\^aE\^m"	[f6])
+	    ("\^aF\^m"	[f7])
+	    ("\^aG\^m"	[f8])
+	    ("\^aH\^m"	[f9])
 
-	  ;; These might be set up by terminfo
-	  ("\eK"	[next])
-	  ("\eT"	[clearline])
-	  ("\^^"	[home])
-	  ("\e\^^"	[end])
-	  ("\eQ"	[insert])
-	  ("\eE"	[insertline])
-	  ("\eR"	[deleteline])
-	  ("\eP"	[print])
-	  ("\er"	[replace])
-	  ("\^aI\^m"	[f10])
-	  ("\^aJ\^m"	[f11])
-	  ("\^aK\^m"	[f12])
-	  ("\^aL\^m"	[f13])
-	  ("\^aM\^m"	[f14])
-	  ("\^aN\^m"	[f15])
-	  ("\^aO\^m"	[f16])
-	  ("\^a`\^m"	[f17])
-	  ("\^aa\^m"	[f18])
-	  ("\^ab\^m"	[f19])
-	  ("\^ac\^m"	[f20])
-	  ("\^ad\^m"	[f21])
-	  ("\^ae\^m"	[f22])
-	  ("\^af\^m"	[f23])
-	  ("\^ag\^m"	[f24])
-	  ("\^ah\^m"	[f25])
-	  ("\^ai\^m"	[f26])
-	  ("\^aj\^m"	[f27])
-	  ("\^ak\^m"	[f28])
-	  ("\^al\^m"	[f29])
-	  ("\^am\^m"	[f30])
-	  ("\^an\^m"	[f31])
-	  ("\^ao\^m"	[f32])
+	    ;; These might be set up by terminfo
+	    ("\eK"	[next])
+	    ("\eT"	[clearline])
+	    ("\^^"	[home])
+	    ("\e\^^"	[end])
+	    ("\eQ"	[insert])
+	    ("\eE"	[insertline])
+	    ("\eR"	[deleteline])
+	    ("\eP"	[print])
+	    ("\er"	[replace])
+	    ("\^aI\^m"	[f10])
+	    ("\^aJ\^m"	[f11])
+	    ("\^aK\^m"	[f12])
+	    ("\^aL\^m"	[f13])
+	    ("\^aM\^m"	[f14])
+	    ("\^aN\^m"	[f15])
+	    ("\^aO\^m"	[f16])
+	    ("\^a`\^m"	[f17])
+	    ("\^aa\^m"	[f18])
+	    ("\^ab\^m"	[f19])
+	    ("\^ac\^m"	[f20])
+	    ("\^ad\^m"	[f21])
+	    ("\^ae\^m"	[f22])
+	    ("\^af\^m"	[f23])
+	    ("\^ag\^m"	[f24])
+	    ("\^ah\^m"	[f25])
+	    ("\^ai\^m"	[f26])
+	    ("\^aj\^m"	[f27])
+	    ("\^ak\^m"	[f28])
+	    ("\^al\^m"	[f29])
+	    ("\^am\^m"	[f30])
+	    ("\^an\^m"	[f31])
+	    ("\^ao\^m"	[f32])
 
-	  ;; Terminfo may know about these, but X won't
-	  ("\eI"	[key-stab])		;; Not an X keysym
-	  ("\eJ"	[key-snext])		;; Not an X keysym
-	  ("\eY"	[key-clear])		;; Not an X keysym
+	    ;; Terminfo may know about these, but X won't
+	    ("\eI"	[key-stab])		;; Not an X keysym
+	    ("\eJ"	[key-snext])		;; Not an X keysym
+	    ("\eY"	[key-clear])		;; Not an X keysym
+
+	    ;; These are totally strange :-)
+	    ("\eW"	[?\C-?])	    ;; Not an X keysym
+	    ("\^a\^k\^m"	[funct-up]) ;; Not an X keysym
+	    ("\^a\^j\^m"	[funct-down])  ;; Not an X keysym
+	    ("\^a\^l\^m"	[funct-right]) ;; Not an X keysym
+	    ("\^a\^h\^m"	[funct-left])  ;; Not an X keysym
+	    ("\^a\^m\^m"	[funct-return])	;; Not an X keysym
+	    ("\^a\^i\^m"	[funct-tab])	;; Not an X keysym
+	    ))
 
-	  ;; These are totally strange :-)
-	  ("\eW"	[?\C-?])	;; Not an X keysym
-	  ("\^a\^k\^m"	[funct-up])	;; Not an X keysym
-	  ("\^a\^j\^m"	[funct-down])	;; Not an X keysym
-	  ("\^a\^l\^m"	[funct-right])	;; Not an X keysym
-	  ("\^a\^h\^m"	[funct-left])	;; Not an X keysym
-	  ("\^a\^m\^m"	[funct-return])	;; Not an X keysym
-	  ("\^a\^i\^m"	[funct-tab])	;; Not an X keysym
-))
+  ;; Miscellaneous hacks
+
+  ;; This is an ugly hack for a nasty problem:
+  ;; Wyse 50 takes one character cell to store video attributes (which seems to
+  ;; explain width 79 rather than 80, column 1 is not used!!!).
+  ;; On killing (C-x C-c) the end inverse code (on column 1 of line 24)
+  ;; of the mode line is overwritten AFTER all the y-or-n questions.
+  ;; This causes the attribute to remain in effect until the mode line has
+  ;; scrolled of the screen.  Suspending (C-z) does not cause this problem.
+  ;; On such terminals, Emacs should sacrifice the first and last character of
+  ;; each mode line, rather than a whole screen column!
+  (add-hook 'kill-emacs-hook
+	    (function (lambda () (interactive)
+			(send-string-to-terminal
+			 (concat "\ea23R" (1+ (frame-width)) "C\eG0"))))))
 
 (defun enable-arrow-keys ()
   "To be called by term-setup-hook. Overrides 6 Emacs standard keys
@@ -131,22 +149,5 @@
 	    ("\er"	nil)))
   (fset 'enable-arrow-keys nil))
 
-
-;;; Miscellaneous hacks
-
-;;; This is an ugly hack for a nasty problem:
-;;; Wyse 50 takes one character cell to store video attributes (which seems to
-;;; explain width 79 rather than 80, column 1 is not used!!!).
-;;; On killing (C-x C-c) the end inverse code (on column 1 of line 24)
-;;; of the mode line is overwritten AFTER all the y-or-n questions.
-;;; This causes the attribute to remain in effect until the mode line has
-;;; scrolled of the screen.  Suspending (C-z) does not cause this problem.
-;;; On such terminals, Emacs should sacrifice the first and last character of
-;;; each mode line, rather than a whole screen column!
-(add-hook 'kill-emacs-hook
-	  (function (lambda () (interactive)
-		      (send-string-to-terminal
-		       (concat "\ea23R" (1+ (frame-width)) "C\eG0")))))
-
 ;;; arch-tag: b6a05d37-eead-4cf6-b997-0f956c68881c
 ;;; wyse50.el ends here
--- a/lisp/term/xterm.el	Tue Jul 26 12:03:19 2005 +0000
+++ b/lisp/term/xterm.el	Fri Jul 29 01:54:54 2005 +0000
@@ -26,222 +26,238 @@
 
 ;;; Code:
 
-;;; The terminal intialization C code file might have initialized
-;;; function keys F13->F60 from the termcap/terminfo information.  On
-;;; a PC-style keyboard these keys correspond to
-;;; MODIFIER-FUNCTION_KEY, where modifier is S-, C, A-, C-S-.  The
-;;; code here subsitutes the corresponding defintions in
-;;; function-key-map. This substitution is needed because if a key
-;;; definition if found in function-key-map, there are no further
-;;; lookups in other keymaps.
-(substitute-key-definition [f13] [S-f1] function-key-map) 
-(substitute-key-definition [f14] [S-f2] function-key-map)
-(substitute-key-definition [f15] [S-f3] function-key-map)
-(substitute-key-definition [f16] [S-f4] function-key-map)
-(substitute-key-definition [f17] [S-f5] function-key-map)
-(substitute-key-definition [f18] [S-f6] function-key-map)
-(substitute-key-definition [f19] [S-f7] function-key-map)
-(substitute-key-definition [f20] [S-f8] function-key-map)
-(substitute-key-definition [f21] [S-f9] function-key-map)
-(substitute-key-definition [f22] [S-f10] function-key-map)
-(substitute-key-definition [f23] [S-f11] function-key-map)
-(substitute-key-definition [f24] [S-f12] function-key-map)
+(defun terminal-init-xterm ()
+  "Terminal initialization function for xterm."
+  ;; rxvt terminals sometimes set the TERM variable to "xterm", but
+  ;; rxvt's keybindings that are incompatible with xterm's. It is
+  ;; better in that case to use rxvt's initializion function.
+  (if (and (getenv "COLORTERM")
+	   (string-match "\\`rxvt" (getenv "COLORTERM")))
+      (progn 
+	(load "term/rxvt")
+	(terminal-init-rxvt))
 
-(substitute-key-definition [f25] [C-f1] function-key-map) 
-(substitute-key-definition [f26] [C-f2] function-key-map)
-(substitute-key-definition [f27] [C-f3] function-key-map)
-(substitute-key-definition [f28] [C-f4] function-key-map)
-(substitute-key-definition [f29] [C-f5] function-key-map)
-(substitute-key-definition [f30] [C-f6] function-key-map)
-(substitute-key-definition [f31] [C-f7] function-key-map)
-(substitute-key-definition [f32] [C-f8] function-key-map)
-(substitute-key-definition [f33] [C-f9] function-key-map)
-(substitute-key-definition [f34] [C-f10] function-key-map)
-(substitute-key-definition [f35] [C-f11] function-key-map)
-(substitute-key-definition [f36] [C-f12] function-key-map)
+    ;; The terminal intialization C code file might have initialized
+    ;; function keys F13->F60 from the termcap/terminfo information.  On
+    ;; a PC-style keyboard these keys correspond to
+    ;; MODIFIER-FUNCTION_KEY, where modifier is S-, C, A-, C-S-.  The
+    ;; code here subsitutes the corresponding defintions in
+    ;; function-key-map. This substitution is needed because if a key
+    ;; definition if found in function-key-map, there are no further
+    ;; lookups in other keymaps.
+    (substitute-key-definition [f13] [S-f1] function-key-map) 
+    (substitute-key-definition [f14] [S-f2] function-key-map)
+    (substitute-key-definition [f15] [S-f3] function-key-map)
+    (substitute-key-definition [f16] [S-f4] function-key-map)
+    (substitute-key-definition [f17] [S-f5] function-key-map)
+    (substitute-key-definition [f18] [S-f6] function-key-map)
+    (substitute-key-definition [f19] [S-f7] function-key-map)
+    (substitute-key-definition [f20] [S-f8] function-key-map)
+    (substitute-key-definition [f21] [S-f9] function-key-map)
+    (substitute-key-definition [f22] [S-f10] function-key-map)
+    (substitute-key-definition [f23] [S-f11] function-key-map)
+    (substitute-key-definition [f24] [S-f12] function-key-map)
 
-(substitute-key-definition [f37] [C-S-f1] function-key-map) 
-(substitute-key-definition [f38] [C-S-f2] function-key-map)
-(substitute-key-definition [f39] [C-S-f3] function-key-map)
-(substitute-key-definition [f40] [C-S-f4] function-key-map)
-(substitute-key-definition [f41] [C-S-f5] function-key-map)
-(substitute-key-definition [f42] [C-S-f6] function-key-map)
-(substitute-key-definition [f43] [C-S-f7] function-key-map)
-(substitute-key-definition [f44] [C-S-f8] function-key-map)
-(substitute-key-definition [f45] [C-S-f9] function-key-map)
-(substitute-key-definition [f46] [C-S-f10] function-key-map)
-(substitute-key-definition [f47] [C-S-f11] function-key-map)
-(substitute-key-definition [f48] [C-S-f12] function-key-map)
+    (substitute-key-definition [f25] [C-f1] function-key-map) 
+    (substitute-key-definition [f26] [C-f2] function-key-map)
+    (substitute-key-definition [f27] [C-f3] function-key-map)
+    (substitute-key-definition [f28] [C-f4] function-key-map)
+    (substitute-key-definition [f29] [C-f5] function-key-map)
+    (substitute-key-definition [f30] [C-f6] function-key-map)
+    (substitute-key-definition [f31] [C-f7] function-key-map)
+    (substitute-key-definition [f32] [C-f8] function-key-map)
+    (substitute-key-definition [f33] [C-f9] function-key-map)
+    (substitute-key-definition [f34] [C-f10] function-key-map)
+    (substitute-key-definition [f35] [C-f11] function-key-map)
+    (substitute-key-definition [f36] [C-f12] function-key-map)
 
-(substitute-key-definition [f49] [A-f1] function-key-map) 
-(substitute-key-definition [f50] [A-f2] function-key-map)
-(substitute-key-definition [f51] [A-f3] function-key-map)
-(substitute-key-definition [f52] [A-f4] function-key-map)
-(substitute-key-definition [f53] [A-f5] function-key-map)
-(substitute-key-definition [f54] [A-f6] function-key-map)
-(substitute-key-definition [f55] [A-f7] function-key-map)
-(substitute-key-definition [f56] [A-f8] function-key-map)
-(substitute-key-definition [f57] [A-f9] function-key-map)
-(substitute-key-definition [f58] [A-f10] function-key-map)
-(substitute-key-definition [f59] [A-f11] function-key-map)
-(substitute-key-definition [f60] [A-f12] function-key-map)
+    (substitute-key-definition [f37] [C-S-f1] function-key-map) 
+    (substitute-key-definition [f38] [C-S-f2] function-key-map)
+    (substitute-key-definition [f39] [C-S-f3] function-key-map)
+    (substitute-key-definition [f40] [C-S-f4] function-key-map)
+    (substitute-key-definition [f41] [C-S-f5] function-key-map)
+    (substitute-key-definition [f42] [C-S-f6] function-key-map)
+    (substitute-key-definition [f43] [C-S-f7] function-key-map)
+    (substitute-key-definition [f44] [C-S-f8] function-key-map)
+    (substitute-key-definition [f45] [C-S-f9] function-key-map)
+    (substitute-key-definition [f46] [C-S-f10] function-key-map)
+    (substitute-key-definition [f47] [C-S-f11] function-key-map)
+    (substitute-key-definition [f48] [C-S-f12] function-key-map)
+
+    (substitute-key-definition [f49] [A-f1] function-key-map) 
+    (substitute-key-definition [f50] [A-f2] function-key-map)
+    (substitute-key-definition [f51] [A-f3] function-key-map)
+    (substitute-key-definition [f52] [A-f4] function-key-map)
+    (substitute-key-definition [f53] [A-f5] function-key-map)
+    (substitute-key-definition [f54] [A-f6] function-key-map)
+    (substitute-key-definition [f55] [A-f7] function-key-map)
+    (substitute-key-definition [f56] [A-f8] function-key-map)
+    (substitute-key-definition [f57] [A-f9] function-key-map)
+    (substitute-key-definition [f58] [A-f10] function-key-map)
+    (substitute-key-definition [f59] [A-f11] function-key-map)
+    (substitute-key-definition [f60] [A-f12] function-key-map)
 
-(let ((map (make-sparse-keymap)))
-  (define-key map "\e[A" [up])
-  (define-key map "\e[B" [down])
-  (define-key map "\e[C" [right])
-  (define-key map "\e[D" [left])
-  (define-key map "\e[1~" [home])
-  (define-key map "\e[2~" [insert])
-  (define-key map "\e[3~" [delete])
-  (define-key map "\e[4~" [select])
-  (define-key map "\e[5~" [prior])
-  (define-key map "\e[6~" [next])
-  (define-key map "\e[11~" [f1])
-  (define-key map "\e[12~" [f2])
-  (define-key map "\e[13~" [f3])
-  (define-key map "\e[14~" [f4])
-  (define-key map "\e[15~" [f5])
-  (define-key map "\e[17~" [f6])
-  (define-key map "\e[18~" [f7])
-  (define-key map "\e[19~" [f8])
-  (define-key map "\e[20~" [f9])
-  (define-key map "\e[21~" [f10])
-  (define-key map "\e[23~" [f11])
-  (define-key map "\e[24~" [f12])
-  (define-key map "\e[29~" [print])
+    (let ((map (make-sparse-keymap)))
+      (define-key map "\e[A" [up])
+      (define-key map "\e[B" [down])
+      (define-key map "\e[C" [right])
+      (define-key map "\e[D" [left])
+      (define-key map "\e[1~" [home])
+      (define-key map "\e[2~" [insert])
+      (define-key map "\e[3~" [delete])
+      (define-key map "\e[4~" [select])
+      (define-key map "\e[5~" [prior])
+      (define-key map "\e[6~" [next])
+      (define-key map "\e[11~" [f1])
+      (define-key map "\e[12~" [f2])
+      (define-key map "\e[13~" [f3])
+      (define-key map "\e[14~" [f4])
+      (define-key map "\e[15~" [f5])
+      (define-key map "\e[17~" [f6])
+      (define-key map "\e[18~" [f7])
+      (define-key map "\e[19~" [f8])
+      (define-key map "\e[20~" [f9])
+      (define-key map "\e[21~" [f10])
+      (define-key map "\e[23~" [f11])
+      (define-key map "\e[24~" [f12])
+      (define-key map "\e[29~" [print])
 
-  (define-key map "\eOP" [f1])
-  (define-key map "\eOQ" [f2])
-  (define-key map "\eOR" [f3])
-  (define-key map "\eOS" [f4])
+      (define-key map "\eOP" [f1])
+      (define-key map "\eOQ" [f2])
+      (define-key map "\eOR" [f3])
+      (define-key map "\eOS" [f4])
 
-  (define-key map "\eO2P" [S-f1])
-  (define-key map "\eO2Q" [S-f2])
-  (define-key map "\eO2R" [S-f3])
-  (define-key map "\eO2S" [S-f4])
-  (define-key map "\e[15;2~" [S-f5])
-  (define-key map "\e[17;2~" [S-f6])
-  (define-key map "\e[18;2~" [S-f7])
-  (define-key map "\e[19;2~" [S-f8])
-  (define-key map "\e[20;2~" [S-f9])
-  (define-key map "\e[21;2~" [S-f10])
-  (define-key map "\e[23;2~" [S-f11])
-  (define-key map "\e[24;2~" [S-f12])
+      (define-key map "\eO2P" [S-f1])
+      (define-key map "\eO2Q" [S-f2])
+      (define-key map "\eO2R" [S-f3])
+      (define-key map "\eO2S" [S-f4])
+      (define-key map "\e[15;2~" [S-f5])
+      (define-key map "\e[17;2~" [S-f6])
+      (define-key map "\e[18;2~" [S-f7])
+      (define-key map "\e[19;2~" [S-f8])
+      (define-key map "\e[20;2~" [S-f9])
+      (define-key map "\e[21;2~" [S-f10])
+      (define-key map "\e[23;2~" [S-f11])
+      (define-key map "\e[24;2~" [S-f12])
 
-  (define-key map "\eO5P" [C-f1])
-  (define-key map "\eO5Q" [C-f2])
-  (define-key map "\eO5R" [C-f3])
-  (define-key map "\eO5S" [C-f4])
-  (define-key map "\e[15;5~" [C-f5])
-  (define-key map "\e[17;5~" [C-f6])
-  (define-key map "\e[18;5~" [C-f7])
-  (define-key map "\e[19;5~" [C-f8])
-  (define-key map "\e[20;5~" [C-f9])
-  (define-key map "\e[21;5~" [C-f10])
-  (define-key map "\e[23;5~" [C-f11])
-  (define-key map "\e[24;5~" [C-f12])
+      (define-key map "\eO5P" [C-f1])
+      (define-key map "\eO5Q" [C-f2])
+      (define-key map "\eO5R" [C-f3])
+      (define-key map "\eO5S" [C-f4])
+      (define-key map "\e[15;5~" [C-f5])
+      (define-key map "\e[17;5~" [C-f6])
+      (define-key map "\e[18;5~" [C-f7])
+      (define-key map "\e[19;5~" [C-f8])
+      (define-key map "\e[20;5~" [C-f9])
+      (define-key map "\e[21;5~" [C-f10])
+      (define-key map "\e[23;5~" [C-f11])
+      (define-key map "\e[24;5~" [C-f12])
 
-  (define-key map "\eO6P" [C-S-f1])
-  (define-key map "\eO6Q" [C-S-f2])
-  (define-key map "\eO6R" [C-S-f3])
-  (define-key map "\eO6S" [C-S-f4])
-  (define-key map "\e[15;6~" [C-S-f5])
-  (define-key map "\e[17;6~" [C-S-f6])
-  (define-key map "\e[18;6~" [C-S-f7])
-  (define-key map "\e[19;6~" [C-S-f8])
-  (define-key map "\e[20;6~" [C-S-f9])
-  (define-key map "\e[21;6~" [C-S-f10])
-  (define-key map "\e[23;6~" [C-S-f11])
-  (define-key map "\e[24;6~" [C-S-f12])
+      (define-key map "\eO6P" [C-S-f1])
+      (define-key map "\eO6Q" [C-S-f2])
+      (define-key map "\eO6R" [C-S-f3])
+      (define-key map "\eO6S" [C-S-f4])
+      (define-key map "\e[15;6~" [C-S-f5])
+      (define-key map "\e[17;6~" [C-S-f6])
+      (define-key map "\e[18;6~" [C-S-f7])
+      (define-key map "\e[19;6~" [C-S-f8])
+      (define-key map "\e[20;6~" [C-S-f9])
+      (define-key map "\e[21;6~" [C-S-f10])
+      (define-key map "\e[23;6~" [C-S-f11])
+      (define-key map "\e[24;6~" [C-S-f12])
 
-  (define-key map "\eO3P" [A-f1])
-  (define-key map "\eO3Q" [A-f2])
-  (define-key map "\eO3R" [A-f3])
-  (define-key map "\eO3S" [A-f4])
-  (define-key map "\e[15;3~" [A-f5])
-  (define-key map "\e[17;3~" [A-f6])
-  (define-key map "\e[18;3~" [A-f7])
-  (define-key map "\e[19;3~" [A-f8])
-  (define-key map "\e[20;3~" [A-f9])
-  (define-key map "\e[21;3~" [A-f10])
-  (define-key map "\e[23;3~" [A-f11])
-  (define-key map "\e[24;3~" [A-f12])
+      (define-key map "\eO3P" [A-f1])
+      (define-key map "\eO3Q" [A-f2])
+      (define-key map "\eO3R" [A-f3])
+      (define-key map "\eO3S" [A-f4])
+      (define-key map "\e[15;3~" [A-f5])
+      (define-key map "\e[17;3~" [A-f6])
+      (define-key map "\e[18;3~" [A-f7])
+      (define-key map "\e[19;3~" [A-f8])
+      (define-key map "\e[20;3~" [A-f9])
+      (define-key map "\e[21;3~" [A-f10])
+      (define-key map "\e[23;3~" [A-f11])
+      (define-key map "\e[24;3~" [A-f12])
 
-  (define-key map "\e[1;2A" [S-up])
-  (define-key map "\e[1;2B" [S-down])
-  (define-key map "\e[1;2C" [S-right])
-  (define-key map "\e[1;2D" [S-left])
-  (define-key map "\e[1;2F" [S-end])
-  (define-key map "\e[1;2H" [S-home])
+      (define-key map "\e[1;2A" [S-up])
+      (define-key map "\e[1;2B" [S-down])
+      (define-key map "\e[1;2C" [S-right])
+      (define-key map "\e[1;2D" [S-left])
+      (define-key map "\e[1;2F" [S-end])
+      (define-key map "\e[1;2H" [S-home])
 
-  (define-key map "\e[1;5A" [C-up])
-  (define-key map "\e[1;5B" [C-down])
-  (define-key map "\e[1;5C" [C-right])
-  (define-key map "\e[1;5D" [C-left])
-  (define-key map "\e[1;5F" [C-end])
-  (define-key map "\e[1;5H" [C-home])
+      (define-key map "\e[1;5A" [C-up])
+      (define-key map "\e[1;5B" [C-down])
+      (define-key map "\e[1;5C" [C-right])
+      (define-key map "\e[1;5D" [C-left])
+      (define-key map "\e[1;5F" [C-end])
+      (define-key map "\e[1;5H" [C-home])
 
-  (define-key map "\e[1;6A" [C-S-up])
-  (define-key map "\e[1;6B" [C-S-down])
-  (define-key map "\e[1;6C" [C-S-right])
-  (define-key map "\e[1;6D" [C-S-left])
-  (define-key map "\e[1;6F" [C-S-end])
-  (define-key map "\e[1;6H" [C-S-home])
+      (define-key map "\e[1;6A" [C-S-up])
+      (define-key map "\e[1;6B" [C-S-down])
+      (define-key map "\e[1;6C" [C-S-right])
+      (define-key map "\e[1;6D" [C-S-left])
+      (define-key map "\e[1;6F" [C-S-end])
+      (define-key map "\e[1;6H" [C-S-home])
 
-  (define-key map "\e[1;3A" [A-up])
-  (define-key map "\e[1;3B" [A-down])
-  (define-key map "\e[1;3C" [A-right])
-  (define-key map "\e[1;3D" [A-left])
-  (define-key map "\e[1;3F" [A-end])
-  (define-key map "\e[1;3H" [A-home])
+      (define-key map "\e[1;3A" [A-up])
+      (define-key map "\e[1;3B" [A-down])
+      (define-key map "\e[1;3C" [A-right])
+      (define-key map "\e[1;3D" [A-left])
+      (define-key map "\e[1;3F" [A-end])
+      (define-key map "\e[1;3H" [A-home])
 
-  (define-key map "\e[2;2~" [S-insert])
-  (define-key map "\e[3;2~" [S-delete])
-  (define-key map "\e[5;2~" [S-prior])
-  (define-key map "\e[6;2~" [S-next])
+      (define-key map "\e[2;2~" [S-insert])
+      (define-key map "\e[3;2~" [S-delete])
+      (define-key map "\e[5;2~" [S-prior])
+      (define-key map "\e[6;2~" [S-next])
 
-  (define-key map "\e[2;5~" [C-insert])
-  (define-key map "\e[3;5~" [C-delete])
-  (define-key map "\e[5;5~" [C-prior])
-  (define-key map "\e[6;5~" [C-next])
+      (define-key map "\e[2;5~" [C-insert])
+      (define-key map "\e[3;5~" [C-delete])
+      (define-key map "\e[5;5~" [C-prior])
+      (define-key map "\e[6;5~" [C-next])
 
-  (define-key map "\e[2;6~" [C-S-insert])
-  (define-key map "\e[3;6~" [C-S-delete])
-  (define-key map "\e[5;6~" [C-S-prior])
-  (define-key map "\e[6;6~" [C-S-next])
+      (define-key map "\e[2;6~" [C-S-insert])
+      (define-key map "\e[3;6~" [C-S-delete])
+      (define-key map "\e[5;6~" [C-S-prior])
+      (define-key map "\e[6;6~" [C-S-next])
 
-  (define-key map "\e[2;3~" [A-insert])
-  (define-key map "\e[3;3~" [A-delete])
-  (define-key map "\e[5;3~" [A-prior])
-  (define-key map "\e[6;3~" [A-next])
+      (define-key map "\e[2;3~" [A-insert])
+      (define-key map "\e[3;3~" [A-delete])
+      (define-key map "\e[5;3~" [A-prior])
+      (define-key map "\e[6;3~" [A-next])
 
-  (define-key map "\eOA" [up])
-  (define-key map "\eOB" [down])
-  (define-key map "\eOC" [right])
-  (define-key map "\eOD" [left])
-  (define-key map "\eOF" [end])
-  (define-key map "\eOH" [home])
+      (define-key map "\eOA" [up])
+      (define-key map "\eOB" [down])
+      (define-key map "\eOC" [right])
+      (define-key map "\eOD" [left])
+      (define-key map "\eOF" [end])
+      (define-key map "\eOH" [home])
 
-  (define-key map "\eO2A" [S-up])
-  (define-key map "\eO2B" [S-down])
-  (define-key map "\eO2C" [S-right])
-  (define-key map "\eO2D" [S-left])
-  (define-key map "\eO2F" [S-end])
-  (define-key map "\eO2H" [S-home])
+      (define-key map "\eO2A" [S-up])
+      (define-key map "\eO2B" [S-down])
+      (define-key map "\eO2C" [S-right])
+      (define-key map "\eO2D" [S-left])
+      (define-key map "\eO2F" [S-end])
+      (define-key map "\eO2H" [S-home])
 
-  (define-key map "\eO5A" [C-up])
-  (define-key map "\eO5B" [C-down])
-  (define-key map "\eO5C" [C-right])
-  (define-key map "\eO5D" [C-left])
-  (define-key map "\eO5F" [C-end])
-  (define-key map "\eO5H" [C-home])
+      (define-key map "\eO5A" [C-up])
+      (define-key map "\eO5B" [C-down])
+      (define-key map "\eO5C" [C-right])
+      (define-key map "\eO5D" [C-left])
+      (define-key map "\eO5F" [C-end])
+      (define-key map "\eO5H" [C-home])
 
-  ;; Use inheritance to let the main keymap override those defaults.
-  ;; This way we don't override terminfo-derived settings or settings
-  ;; made in the .emacs file.
-  (set-keymap-parent map (keymap-parent function-key-map))
-  (set-keymap-parent function-key-map map))
+      ;; Use inheritance to let the main keymap override those defaults.
+      ;; This way we don't override terminfo-derived settings or settings
+      ;; made in the .emacs file.
+      (set-keymap-parent map (keymap-parent function-key-map))
+      (set-keymap-parent function-key-map map))
+
+    ;; Do it!
+    (xterm-register-default-colors)
+    ;; This recomputes all the default faces given the colors we've just set up.
+    (tty-set-up-initial-frame-faces)))
 
 ;; Set up colors, for those versions of xterm that support it.
 (defvar xterm-standard-colors
@@ -359,38 +375,5 @@
     ;; right colors, so clear them.
     (clear-face-cache)))
 
-;; rxvt puts the default colors into an environment variable
-;; COLORFGBG.  We use this to set the background mode in a more
-;; intelligent way than the default guesswork in startup.el.
-(defun xterm-rxvt-set-background-mode ()
-  "Set background mode as appropriate for the default rxvt colors."
-  (let ((fgbg (getenv "COLORFGBG"))
-	bg rgb)
-    (setq default-frame-background-mode 'light)
-    (when (and fgbg
-	       (string-match ".*;\\([0-9][0-9]?\\)\\'" fgbg))
-      (setq bg (string-to-number (substring fgbg (match-beginning 1))))
-      ;; The next line assumes that xterm-standard-colors are ordered
-      ;; by the color index in the ascending order!
-      (setq rgb (car (cddr (nth bg xterm-standard-colors))))
-      ;; See the commentary in frame-set-background-mode about the
-      ;; computation below.
-      (if (< (apply '+ rgb)
-	     ;; The following line assumes that white is the 15th
-	     ;; color in xterm-standard-colors.
-	     (* (apply '+ (car (cddr (nth 15 xterm-standard-colors)))) 0.6))
-	  (setq default-frame-background-mode 'dark)))
-    (frame-set-background-mode (selected-frame))))
-
-;; Do it!
-(xterm-register-default-colors)
-;; If this xterm is actually a disguised rxvt, be more intelligent about
-;; determining the background mode.
-(and (getenv "COLORTERM")
-     (string-match "\\`rxvt" (getenv "COLORTERM"))
-     (xterm-rxvt-set-background-mode))
-;; This recomputes all the default faces given the colors we've just set up.
-(tty-set-up-initial-frame-faces)
-
 ;; arch-tag: 12e7ebdd-1e6c-4b25-b0f9-35ace25e855a
 ;;; xterm.el ends here
--- a/lisp/tooltip.el	Tue Jul 26 12:03:19 2005 +0000
+++ b/lisp/tooltip.el	Fri Jul 29 01:54:54 2005 +0000
@@ -159,7 +159,7 @@
 With ARG, turn tooltip mode on if and only if ARG is positive."
   :global t
   :init-value (not (or noninteractive
-		       emacs-quick-startup
+		       emacs-basic-display
 		       (not (display-graphic-p))
 		       (not (fboundp 'x-show-tip))))
   :initialize 'custom-initialize-safe-default
--- a/lispref/ChangeLog	Tue Jul 26 12:03:19 2005 +0000
+++ b/lispref/ChangeLog	Fri Jul 29 01:54:54 2005 +0000
@@ -1,3 +1,18 @@
+2005-07-27  Luc Teirlinck  <teirllm@auburn.edu>
+
+	* modes.texi (Defining Minor Modes): The keyword for the initial
+	value is :init-value, not :initial-value.
+
+2005-07-23  Eli Zaretskii  <eliz@gnu.org>
+
+	* loading.texi (Autoload): Make the `doctor' example be consistent
+	with what's in current loaddefs.el.  Describe the "fn" magic in
+	the usage portion of the doc string.
+
+2005-07-22  Richard M. Stallman  <rms@gnu.org>
+
+	* internals.texi (Garbage Collection): Clarify previous change.
+
 2005-07-21  Stefan Monnier  <monnier@iro.umontreal.ca>
 
 	* internals.texi (Garbage Collection): Add gc-cons-percentage.
--- a/lispref/internals.texi	Tue Jul 26 12:03:19 2005 +0000
+++ b/lispref/internals.texi	Fri Jul 29 01:54:54 2005 +0000
@@ -369,15 +369,14 @@
 @end defopt
 
 @defopt gc-cons-percentage
-The value of this variable is the minimum portion of the heap that
-should be allocated before a garbage collection takes place.  It is
-used only if the specified size is larger than
-@code{gc-cons-threshold}.
+The value of this variable specifies the amount of consing before a
+garbage collection occurs, as a fraction of the current heap size.
+This criterion and @code{gc-cons-threshold} apply in parallel, and
+garbage collection occurs only when both criteria are satisfied.
 
 As the heap size increases, the time to perform a garbage collection
-increases, so in order to compensate, this variable tries to
-correspondingly reduce the frequency of collection by letting Emacs
-allocate more memory between each collection.
+increases.  Thus, it can be desirable to do them less frequently in
+proportion.
 @end defopt
 
   The value returned by @code{garbage-collect} describes the amount of
--- a/lispref/loading.texi	Tue Jul 26 12:03:19 2005 +0000
+++ b/lispref/loading.texi	Fri Jul 29 01:54:54 2005 +0000
@@ -481,17 +481,22 @@
 Here's what that produces in @file{loaddefs.el}:
 
 @smallexample
-(autoload 'doctor "doctor" "\
-Switch to *doctor* buffer and start giving psychotherapy."
-  t)
+(autoload (quote doctor) "doctor" "\
+Switch to *doctor* buffer and start giving psychotherapy.
+
+\(fn)" t nil)
 @end smallexample
 
 @noindent
+@cindex @code{fn} in function's documentation string
 The backslash and newline immediately following the double-quote are a
 convention used only in the preloaded uncompiled Lisp files such as
 @file{loaddefs.el}; they tell @code{make-docfile} to put the
 documentation string in the @file{etc/DOC} file.  @xref{Building Emacs}.
-See also the commentary in @file{lib-src/make-docfile.c}.
+See also the commentary in @file{lib-src/make-docfile.c}.  @samp{(fn)}
+in the usage part of the documentation string is replaced with the
+function's name when the various help functions (@pxref{Help
+Functions}) display it.
 
   If you write a function definition with an unusual macro that is not
 one of the known and recognized function definition methods, use of an
--- a/lispref/modes.texi	Tue Jul 26 12:03:19 2005 +0000
+++ b/lispref/modes.texi	Fri Jul 29 01:54:54 2005 +0000
@@ -1472,7 +1472,7 @@
 gobbles all preceding whitespace except the last.
 See the command \\[hungry-electric-delete]."
  ;; The initial value.
- :initial-value nil
+ :init-value nil
  ;; The indicator for the mode line.
  :lighter " Hungry"
  ;; The minor mode bindings.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m4/getopt.m4	Fri Jul 29 01:54:54 2005 +0000
@@ -0,0 +1,82 @@
+# getopt.m4 serial 10
+dnl Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+# The getopt module assume you want GNU getopt, with getopt_long etc,
+# rather than vanilla POSIX getopt.  This means your your code should
+# always include <getopt.h> for the getopt prototypes.
+
+AC_DEFUN([gl_GETOPT_SUBSTITUTE],
+[
+  AC_LIBOBJ([getopt])
+  AC_LIBOBJ([getopt1])
+  gl_GETOPT_SUBSTITUTE_HEADER
+  gl_PREREQ_GETOPT
+])
+
+AC_DEFUN([gl_GETOPT_SUBSTITUTE_HEADER],
+[
+  GETOPT_H=getopt.h
+  AC_DEFINE([__GETOPT_PREFIX], [[rpl_]],
+    [Define to rpl_ if the getopt replacement functions and variables
+     should be used.])
+  AC_SUBST([GETOPT_H])
+])
+
+AC_DEFUN([gl_GETOPT_CHECK_HEADERS],
+[
+  GETOPT_H=
+  AC_CHECK_HEADERS([getopt.h], [], [GETOPT_H=getopt.h])
+  if test -z "$GETOPT_H"; then
+    AC_CHECK_FUNCS([getopt_long_only], [], [GETOPT_H=getopt.h])
+  fi
+
+  dnl BSD getopt_long uses an incompatible method to reset option processing,
+  dnl and (as of 2004-10-15) mishandles optional option-arguments.
+  if test -z "$GETOPT_H"; then
+    AC_CHECK_DECL([optreset], [GETOPT_H=getopt.h], [], [#include <getopt.h>])
+  fi
+
+  dnl Solaris 10 getopt doesn't handle `+' as a leading character in an
+  dnl option string (as of 2005-05-05).
+  if test -z "$GETOPT_H"; then
+    AC_CACHE_CHECK([for working GNU getopt function], [gl_cv_func_gnu_getopt],
+      [AC_RUN_IFELSE(
+	[AC_LANG_PROGRAM([#include <getopt.h>],
+	   [[
+	     char *myargv[3];
+	     myargv[0] = "conftest";
+	     myargv[1] = "-+";
+	     myargv[2] = 0;
+	     return getopt (2, myargv, "+a") != '?';
+	   ]])],
+	[gl_cv_func_gnu_getopt=yes],
+	[gl_cv_func_gnu_getopt=no],
+	[dnl cross compiling - pessimistically guess based on decls
+	 dnl Solaris 10 getopt doesn't handle `+' as a leading character in an
+	 dnl option string (as of 2005-05-05).
+	 AC_CHECK_DECL([getopt_clip],
+	   [gl_cv_func_gnu_getopt=no], [gl_cv_func_gnu_getopt=yes],
+	   [#include <getopt.h>])])])
+    if test "$gl_cv_func_gnu_getopt" = "no"; then
+      GETOPT_H=getopt.h
+    fi
+  fi
+])
+
+AC_DEFUN([gl_GETOPT_IFELSE],
+[
+  AC_REQUIRE([gl_GETOPT_CHECK_HEADERS])
+  AS_IF([test -n "$GETOPT_H"], [$1], [$2])
+])
+
+AC_DEFUN([gl_GETOPT], [gl_GETOPT_IFELSE([gl_GETOPT_SUBSTITUTE])])
+
+# Prerequisites of lib/getopt*.
+AC_DEFUN([gl_PREREQ_GETOPT], [:])
+
+ifelse(dnl	Do not change this comment
+   arch-tag: 6c64a021-551c-4a7f-9c63-cd7e1ce54707
+)dnl
--- a/make-dist	Tue Jul 26 12:03:19 2005 +0000
+++ b/make-dist	Fri Jul 29 01:54:54 2005 +0000
@@ -6,7 +6,7 @@
 #### be distributed.  This means that if you add a file with an odd name,
 #### you should make sure that this script will include it.
 
-# Copyright (C) 1995, 1997, 1998, 2000, 2001, 2002, 2005 
+# Copyright (C) 1995, 1997, 1998, 2000, 2001, 2002, 2005
 #   Free Software Foundation, Inc.
 #
 # This file is part of GNU Emacs.
@@ -323,7 +323,7 @@
 	      nt nt/inc nt/inc/sys nt/inc/arpa nt/inc/netinet nt/icons \
 	      etc etc/e etc/images etc/images/gnus etc/images/smilies \
 	      etc/tree-widget etc/tree-widget/default etc/tree-widget/folder \
-	      info man msdos vms mac mac/inc mac/inc/sys \
+	      info man m4 msdos vms mac mac/inc mac/inc/sys \
 	      mac/src mac/Emacs.app mac/Emacs.app/Contents \
 	      mac/Emacs.app/Contents/MacOS mac/Emacs.app/Contents/Resources \
 	      mac/Emacs.app/Contents/Resources/English.lproj
@@ -487,8 +487,13 @@
  done
  cd ../${tempdir}/lib-src
  rm -f Makefile.c
+ rm -f getopt.h
  rm -f =* TAGS)
 
+echo "Making links to \`m4'"
+(cd m4
+ ln *.m4 ../${tempdir}/m4)
+
 echo "Making links to \`nt'"
 (cd nt
  ln emacs.rc config.nt [a-z]*.c ../${tempdir}/nt
--- a/man/ChangeLog	Tue Jul 26 12:03:19 2005 +0000
+++ b/man/ChangeLog	Fri Jul 29 01:54:54 2005 +0000
@@ -1,3 +1,13 @@
+2005-07-27  Reiner Steib  <Reiner.Steib@gmx.de>
+
+	* gnus.texi (Startup Files): Fix name of gnus-site-init-file.
+	Mention that gnus-init-file is not read when Emacs is invoked with
+	--no-init-file or -q.
+
+2005-07-22  Eli Zaretskii  <eliz@gnu.org>
+
+	* files.texi (Quoted File Names): Add index entry.
+
 2005-07-19  Carsten Dominik  <dominik@science.uva.nl>
 
 	* org.texi: Version 3.14
--- a/man/files.texi	Tue Jul 26 12:03:19 2005 +0000
+++ b/man/files.texi	Fri Jul 29 01:54:54 2005 +0000
@@ -3256,6 +3256,7 @@
 @section Quoted File Names
 
 @cindex quoting file names
+@cindex file names, quote special characters
   You can @dfn{quote} an absolute file name to prevent special
 characters and syntax in it from having their special effects.
 The way to do this is to add @samp{/:} at the beginning.
--- a/man/gnus.texi	Tue Jul 26 12:03:19 2005 +0000
+++ b/man/gnus.texi	Fri Jul 29 01:54:54 2005 +0000
@@ -1468,15 +1468,17 @@
 @vindex gnus-init-file
 @vindex gnus-site-init-file
 When Gnus starts, it will read the @code{gnus-site-init-file}
-(@file{.../site-lisp/gnus} by default) and @code{gnus-init-file}
+(@file{.../site-lisp/gnus-init} by default) and @code{gnus-init-file}
 (@file{~/.gnus} by default) files.  These are normal Emacs Lisp files
 and can be used to avoid cluttering your @file{~/.emacs} and
 @file{site-init} files with Gnus stuff.  Gnus will also check for files
 with the same names as these, but with @file{.elc} and @file{.el}
 suffixes.  In other words, if you have set @code{gnus-init-file} to
 @file{~/.gnus}, it will look for @file{~/.gnus.elc}, @file{~/.gnus.el},
-and finally @file{~/.gnus} (in this order).
-
+and finally @file{~/.gnus} (in this order).  If Emacs was invoked with
+the @option{-q} or @option{--no-init-file} options (@pxref{Initial
+Options, ,Initial Options, emacs, The Emacs Manual}), Gnus doesn't read
+@code{gnus-init-file}.
 
 
 @node Auto Save
--- a/nt/.cvsignore	Tue Jul 26 12:03:19 2005 +0000
+++ b/nt/.cvsignore	Fri Jul 29 01:54:54 2005 +0000
@@ -1,3 +1,5 @@
 *-spd
 *.pdb
 .arch-inventory
+makefile
+config.log
--- a/nt/ChangeLog	Tue Jul 26 12:03:19 2005 +0000
+++ b/nt/ChangeLog	Fri Jul 29 01:54:54 2005 +0000
@@ -1,3 +1,18 @@
+2005-07-29  Juanma Barranquero  <lekktu@gmail.com>
+
+	* configure.bat: Don't create lisp/Makefile.unix.
+
+2005-07-28  Juanma Barranquero  <lekktu@gmail.com>
+
+	* .cvsignore: Add `makefile' and `config.log'.
+
+2005-07-26  Paul Eggert  <eggert@cs.ucla.edu>
+
+	Merge gnulib getopt implementation into Emacs.
+
+	* inc/gettext.h: Remove; no longer needed now that
+	lib-src/gettext.h exists.
+
 2005-07-16  Eli Zaretskii  <eliz@gnu.org>
 
 	* configure.bat: Finish config.log with a line that indicates that
--- a/nt/configure.bat	Tue Jul 26 12:03:19 2005 +0000
+++ b/nt/configure.bat	Fri Jul 29 01:54:54 2005 +0000
@@ -1,7 +1,7 @@
 @echo off
 rem   ----------------------------------------------------------------------
 rem   Configuration script for MS Windows 95/98/Me and NT/2000/XP
-rem   Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005 
+rem   Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
 rem      Free Software Foundation, Inc.
 
 rem   This file is part of GNU Emacs.
@@ -499,7 +499,6 @@
 copy /b config.settings+%MAKECMD%.defs+..\man\makefile.w32-in ..\man\makefile
 copy /b config.settings+%MAKECMD%.defs+..\lispref\makefile.w32-in ..\lispref\makefile
 copy /b config.settings+%MAKECMD%.defs+..\lispintro\makefile.w32-in ..\lispintro\makefile
-if not exist ..\lisp\Makefile.unix rename ..\lisp\Makefile.in Makefile.unix
 if exist ..\lisp\makefile rm -f ../lisp/[Mm]akefile
 copy /b config.settings+%MAKECMD%.defs+..\lisp\makefile.w32-in ..\lisp\makefile
 rem   Use the default (no-op) Makefile.in if the nt version is not present.
--- a/nt/inc/gettext.h	Tue Jul 26 12:03:19 2005 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,72 +0,0 @@
-/* Convenience header for conditional use of GNU <libintl.h>.
-   Copyright (C) 1995-1998, 2000-2002 Free Software Foundation, Inc.
-
-   This program is free software; you can redistribute it and/or modify it
-   under the terms of the GNU Library General Public License as published
-   by the Free Software Foundation; either version 2, or (at your option)
-   any later version.
-
-   This program 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
-   Library General Public License for more details.
-
-   You should have received a copy of the GNU Library General Public
-   License along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-   USA.  */
-
-#ifndef _LIBGETTEXT_H
-#define _LIBGETTEXT_H 1
-
-/* NLS can be disabled through the configure --disable-nls option.  */
-#if ENABLE_NLS
-
-/* Get declarations of GNU message catalog functions.  */
-# include <libintl.h>
-
-#else
-
-/* Solaris /usr/include/locale.h includes /usr/include/libintl.h, which
-   chokes if dcgettext is defined as a macro.  So include it now, to make
-   later inclusions of <locale.h> a NOP.  We don't include <libintl.h>
-   as well because people using "gettext.h" will not include <libintl.h>,
-   and also including <libintl.h> would fail on SunOS 4, whereas <locale.h>
-   is OK.  */
-#if defined(__sun)
-# include <locale.h>
-#endif
-
-/* Disabled NLS.
-   The casts to 'const char *' serve the purpose of producing warnings
-   for invalid uses of the value returned from these functions.
-   On pre-ANSI systems without 'const', the config.h file is supposed to
-   contain "#define const".  */
-# define gettext(Msgid) ((const char *) (Msgid))
-# define dgettext(Domainname, Msgid) ((const char *) (Msgid))
-# define dcgettext(Domainname, Msgid, Category) ((const char *) (Msgid))
-# define ngettext(Msgid1, Msgid2, N) \
-    ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
-# define dngettext(Domainname, Msgid1, Msgid2, N) \
-    ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
-# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \
-    ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
-# define textdomain(Domainname) ((const char *) (Domainname))
-# define bindtextdomain(Domainname, Dirname) ((const char *) (Dirname))
-# define bind_textdomain_codeset(Domainname, Codeset) ((const char *) (Codeset))
-
-#endif
-
-/* A pseudo function call that serves as a marker for the automated
-   extraction of messages, but does not call gettext().  The run-time
-   translation is done at a different place in the code.
-   The argument, String, should be a literal string.  Concatenated strings
-   and other string expressions won't work.
-   The macro's expansion is not parenthesized, so that it is suitable as
-   initializer for static 'char[]' or 'const char[]' variables.  */
-#define gettext_noop(String) String
-
-#endif /* _LIBGETTEXT_H */
-
-/* arch-tag: 07b35a70-3531-4cda-9674-2968467143ec
-   (do not change this comment) */
--- a/src/ChangeLog	Tue Jul 26 12:03:19 2005 +0000
+++ b/src/ChangeLog	Fri Jul 29 01:54:54 2005 +0000
@@ -1,3 +1,85 @@
+2005-07-28  Juanma Barranquero  <lekktu@gmail.com>
+
+	* w32fns.c (my_set_window_pos, my_show_window): Don't declare.
+	(my_create_window, my_create_tip_window): Make static.
+
+	* w32term.c (my_show_window, my_set_window_pos, my_set_focus)
+	(my_set_foreground_window, my_destroy_window): Make static.
+
+2005-07-26  Paul Eggert  <eggert@cs.ucla.edu>
+
+	Merge gnulib getopt implementation into Emacs.
+
+	* s/cygwin.h (C_SWITCH_SYSTEM): Remove, since gettext.h is
+	now part of lib-src.
+
+2005-07-26  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* eval.c (Fdefvar): Allow (defvar enable-multibyte-characters).
+
+2005-07-25  Jason Rumney  <jasonr@gnu.org>
+
+	* w32menu.c (w32_menu_display_help): Suppress tooltip when
+	navigating menus with the keyboard.
+
+2005-07-23  Richard M. Stallman  <rms@gnu.org>
+
+	* insdel.c (syms_of_insdel): staticpro combine_after_change_buffer.
+
+	* bytecode.c (MAYBE_GC): Test gc_cons_threshold and
+	gc_relative_threshold, one by one.
+
+	* keyboard.c (read_char): Test gc_cons_threshold.
+	(syms_of_keyboard): staticpro Qecho_area_clear_hook.
+
+	* eval.c (Feval, Ffuncall): Test gc_cons_threshold and
+	gc_relative_threshold, one by one.
+
+	* alloc.c (gc_cons_threshold): Not static.
+	(gc_cons_combined_threshold): Var deleted.
+	(gc_relative_threshold): New variable.
+	(Fgarbage_collect, init_alloc_once): Compute gc_relative_threshold
+	instead of gc_cons_combined_threshold.
+
+	* lisp.h (gc_cons_threshold, gc_relative_threshold): Declare.
+	(gc_cons_combined_threshold): Declaration deleted.
+
+2005-07-23  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
+
+	* mac.c: Don't include stdlib.h or string.h.
+	(Fdo_applescript, Fmac_file_name_to_posix)
+	(Fmac_file_name_to_posix): Doc fixes.
+	[TARGET_API_MAC_CARBON] (Fmac_get_preference)
+	(Fmac_code_convert_string): Likewise.
+	[MAC_OSX] (init_mac_osx_environment): Fall back on terminal mode
+	if the executable is not contained in a bundle.
+
+	* macfns.c: Don't include stdlib.h or string.h.  Include atimer.h.
+	(gray_width, gray_height): Remove defines.
+	(gray_bits, gray_bitmap_width, gray_bitmap_height)
+	(gray_bitmap_bits): Remove variables.
+	(lispy_function_keys): Remove extern.
+	(free_frame_menubar): Add extern.
+	(x_window_to_frame): Remove function.
+	(unwind_create_tip_frame): Add declaration.
+	(x_set_name_internal): New function.
+	(x_set_name, x_set_title): Use it.
+	(Fx_create_frame, Fx_display_grayscale_p, Fx_display_pixel_width)
+	(Fx_display_pixel_height, Fx_display_planes)
+	(Fx_display_color_cells, Fx_server_max_request_size)
+	(Fx_server_vendor, Fx_server_version, Fx_display_screens)
+	(Fx_display_mm_height, Fx_display_mm_width)
+	(Fx_display_backing_store, Fx_display_visual_class)
+	(Fx_display_save_under, Fx_synchronize, Fx_show_tip): Doc fixes.
+
+	* macmenu.c (Fx_popup_menu, Fx_popup_dialog): Doc fixes.
+
+	* macselect.c (Fx_own_selection_internal): Follow error
+	conventions.
+	(Fx_get_selection_internal, Fx_selection_owner_p)
+	(Fx_selection_exists_p): Doc fixes.
+	(syms_of_macselect) <selection-converter-alist>: Likewise.
+
 2005-07-21  Juanma Barranquero  <lekktu@gmail.com>
 
 	* buffer.c (syms_of_buffer) <cursor-type>: Doc fix.
--- a/src/alloc.c	Tue Jul 26 12:03:19 2005 +0000
+++ b/src/alloc.c	Fri Jul 29 01:54:54 2005 +0000
@@ -172,10 +172,14 @@
 EMACS_INT intervals_consed;
 EMACS_INT strings_consed;
 
-/* Number of bytes of consing since GC before another GC should be done. */
-
-static EMACS_INT gc_cons_threshold;
-EMACS_INT gc_cons_combined_threshold;
+/* Minimum number of bytes of consing since GC before next GC. */
+
+EMACS_INT gc_cons_threshold;
+
+/* Similar minimum, computed from Vgc_cons_percentage.  */
+
+EMACS_INT gc_relative_threshold;
+
 static Lisp_Object Vgc_cons_percentage;
 
 /* Nonzero during GC.  */
@@ -4856,12 +4860,10 @@
   if (gc_cons_threshold < 10000)
     gc_cons_threshold = 10000;
 
-  gc_cons_combined_threshold = gc_cons_threshold;
-
   if (FLOATP (Vgc_cons_percentage))
     { /* Set gc_cons_combined_threshold.  */
       EMACS_INT total = 0;
-      EMACS_INT threshold;
+
       total += total_conses  * sizeof (struct Lisp_Cons);
       total += total_symbols * sizeof (struct Lisp_Symbol);
       total += total_markers * sizeof (union Lisp_Misc);
@@ -4871,10 +4873,10 @@
       total += total_intervals * sizeof (struct interval);
       total += total_strings * sizeof (struct Lisp_String);
       
-      threshold = total * XFLOAT_DATA (Vgc_cons_percentage);
-      if (threshold > gc_cons_combined_threshold)
-	gc_cons_combined_threshold = threshold;
+      gc_relative_threshold = total * XFLOAT_DATA (Vgc_cons_percentage);
     }
+  else
+    gc_relative_threshold = 0;
 
   if (garbage_collection_messages)
     {
@@ -5965,7 +5967,8 @@
   staticidx = 0;
   consing_since_gc = 0;
   gc_cons_threshold = 100000 * sizeof (Lisp_Object);
-  gc_cons_combined_threshold = gc_cons_threshold;
+  gc_relative_threshold = 0;
+
 #ifdef VIRT_ADDR_VARIES
   malloc_sbrk_unused = 1<<22;	/* A large number */
   malloc_sbrk_used = 100000;	/* as reasonable as any number */
--- a/src/bytecode.c	Tue Jul 26 12:03:19 2005 +0000
+++ b/src/bytecode.c	Fri Jul 29 01:54:54 2005 +0000
@@ -355,13 +355,14 @@
 /* Garbage collect if we have consed enough since the last time.
    We do this at every branch, to avoid loops that never GC.  */
 
-#define MAYBE_GC()				     \
-  if (consing_since_gc > gc_cons_combined_threshold) \
-    {						     \
-      BEFORE_POTENTIAL_GC ();			     \
-      Fgarbage_collect ();			     \
-      AFTER_POTENTIAL_GC ();			     \
-    }						     \
+#define MAYBE_GC()					\
+  if (consing_since_gc > gc_cons_threshold		\
+      && consing_since_gc > gc_relative_threshold)	\
+    {							\
+      BEFORE_POTENTIAL_GC ();				\
+      Fgarbage_collect ();				\
+      AFTER_POTENTIAL_GC ();				\
+    }							\
   else
 
 /* Check for jumping out of range.  */
--- a/src/config.in	Tue Jul 26 12:03:19 2005 +0000
+++ b/src/config.in	Fri Jul 29 01:54:54 2005 +0000
@@ -191,6 +191,12 @@
 /* Define to 1 if you have the `getloadavg' function. */
 #undef HAVE_GETLOADAVG
 
+/* Define to 1 if you have the <getopt.h> header file. */
+#undef HAVE_GETOPT_H
+
+/* Define to 1 if you have the `getopt_long_only' function. */
+#undef HAVE_GETOPT_LONG_ONLY
+
 /* Define to 1 if you have the `getpagesize' function. */
 #undef HAVE_GETPAGESIZE
 
@@ -785,9 +791,9 @@
 /* If using the C implementation of alloca, define if you know the
    direction of stack growth for your system; otherwise it will be
    automatically deduced at run-time.
-        STACK_DIRECTION > 0 => grows toward higher addresses
-        STACK_DIRECTION < 0 => grows toward lower addresses
-        STACK_DIRECTION = 0 => direction of growth unknown */
+	STACK_DIRECTION > 0 => grows toward higher addresses
+	STACK_DIRECTION < 0 => grows toward lower addresses
+	STACK_DIRECTION = 0 => direction of growth unknown */
 #undef STACK_DIRECTION
 
 /* Define to 1 if you have the ANSI C header files. */
@@ -846,6 +852,10 @@
 /* Define for large files, on AIX-style hosts. */
 #undef _LARGE_FILES
 
+/* Define to rpl_ if the getopt replacement functions and variables should be
+   used. */
+#undef __GETOPT_PREFIX
+
 /* Define like PROTOTYPES; this can be used by system headers. */
 #undef __PROTOTYPES
 
--- a/src/eval.c	Tue Jul 26 12:03:19 2005 +0000
+++ b/src/eval.c	Fri Jul 29 01:54:54 2005 +0000
@@ -807,18 +807,6 @@
   register Lisp_Object sym, tem, tail;
 
   sym = Fcar (args);
-  if (SYMBOL_CONSTANT_P (sym))
-    {
-      /* For updward compatibility, allow (defvar :foo (quote :foo)).  */
-      tem = Fcar (Fcdr (args));
-      if (! (CONSP (tem)
-	     && EQ (XCAR (tem), Qquote)
-	     && CONSP (XCDR (tem))
-	     && EQ (XCAR (XCDR (tem)), sym)))
-	error ("Constant symbol `%s' specified in defvar",
-	       SDATA (SYMBOL_NAME (sym)));
-    }
-
   tail = Fcdr (args);
   if (!NILP (Fcdr (Fcdr (tail))))
     error ("Too many arguments");
@@ -826,6 +814,18 @@
   tem = Fdefault_boundp (sym);
   if (!NILP (tail))
     {
+      if (SYMBOL_CONSTANT_P (sym))
+	{
+	  /* For upward compatibility, allow (defvar :foo (quote :foo)).  */
+	  Lisp_Object tem = Fcar (tail);
+	  if (! (CONSP (tem)
+		 && EQ (XCAR (tem), Qquote)
+		 && CONSP (XCDR (tem))
+		 && EQ (XCAR (XCDR (tem)), sym)))
+	    error ("Constant symbol `%s' specified in defvar",
+		   SDATA (SYMBOL_NAME (sym)));
+	}
+
       if (NILP (tem))
 	Fset_default (sym, Feval (Fcar (tail)));
       else
@@ -2094,7 +2094,8 @@
     return form;
 
   QUIT;
-  if (consing_since_gc > gc_cons_combined_threshold)
+  if (consing_since_gc > gc_cons_threshold
+      && consing_since_gc > gc_relative_threshold)
     {
       GCPRO1 (form);
       Fgarbage_collect ();
@@ -2794,7 +2795,8 @@
   register int i;
 
   QUIT;
-  if (consing_since_gc > gc_cons_combined_threshold)
+  if (consing_since_gc > gc_cons_threshold
+      && consing_since_gc > gc_relative_threshold)
     Fgarbage_collect ();
 
   if (++lisp_eval_depth > max_lisp_eval_depth)
--- a/src/insdel.c	Tue Jul 26 12:03:19 2005 +0000
+++ b/src/insdel.c	Fri Jul 29 01:54:54 2005 +0000
@@ -2426,6 +2426,7 @@
 syms_of_insdel ()
 {
   staticpro (&combine_after_change_list);
+  staticpro (&combine_after_change_buffer);
   combine_after_change_list = Qnil;
   combine_after_change_buffer = Qnil;
 
--- a/src/keyboard.c	Tue Jul 26 12:03:19 2005 +0000
+++ b/src/keyboard.c	Fri Jul 29 01:54:54 2005 +0000
@@ -2778,7 +2778,7 @@
 		 available, garbage collect if there has been enough
 		 consing going on to make it worthwhile.  */
 	      if (!detect_input_pending_run_timers (0)
-		  && consing_since_gc > gc_cons_combined_threshold / 2)
+		  && consing_since_gc > gc_cons_threshold / 2)
 		Fgarbage_collect ();
 
 	      redisplay ();
@@ -11280,6 +11280,7 @@
 	       doc: /* Normal hook run when clearing the echo area.  */);
 #endif
   Qecho_area_clear_hook = intern ("echo-area-clear-hook");
+  staticpro (&Qecho_area_clear_hook);
   SET_SYMBOL_VALUE (Qecho_area_clear_hook, Qnil);
 
   DEFVAR_LISP ("lucid-menu-bar-dirty-flag", &Vlucid_menu_bar_dirty_flag,
--- a/src/lisp.h	Tue Jul 26 12:03:19 2005 +0000
+++ b/src/lisp.h	Fri Jul 29 01:54:54 2005 +0000
@@ -1886,9 +1886,11 @@
 
 extern int consing_since_gc;
 
-/* Threshold for doing another gc.  */
-
-extern EMACS_INT gc_cons_combined_threshold;
+/* Thresholds for doing another gc.  */
+
+extern EMACS_INT gc_cons_threshold;
+
+extern EMACS_INT gc_relative_threshold;
 
 /* Structure for recording stack slots that need marking.  */
 
--- a/src/mac.c	Tue Jul 26 12:03:19 2005 +0000
+++ b/src/mac.c	Fri Jul 29 01:54:54 2005 +0000
@@ -59,11 +59,9 @@
 #include <dirent.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <string.h>
 #include <pwd.h>
 #include <grp.h>
 #include <sys/param.h>
-#include <stdlib.h>
 #include <fcntl.h>
 #if __MWERKS__
 #include <unistd.h>
@@ -3447,7 +3445,7 @@
 
 DEFUN ("mac-get-file-creator", Fmac_get_file_creator, Smac_get_file_creator, 1, 1, 0,
        doc: /* Get the creator code of FILENAME as a four character string. */)
-  (filename)
+     (filename)
      Lisp_Object filename;
 {
   OSErr	status;
@@ -3502,7 +3500,7 @@
 
 DEFUN ("mac-get-file-type", Fmac_get_file_type, Smac_get_file_type, 1, 1, 0,
        doc: /* Get the type code of FILENAME as a four character string. */)
-  (filename)
+     (filename)
      Lisp_Object filename;
 {
   OSErr	status;
@@ -3559,7 +3557,7 @@
        doc: /* Set creator code of file FILENAME to CODE.
 If non-nil, CODE must be a 4-character string.  Otherwise, 'EMAx' is
 assumed. Return non-nil if successful.  */)
-  (filename, code)
+     (filename, code)
      Lisp_Object filename, code;
 {
   OSErr	status;
@@ -3619,7 +3617,7 @@
 DEFUN ("mac-set-file-type", Fmac_set_file_type, Smac_set_file_type, 2, 2, 0,
        doc: /* Set file code of file FILENAME to CODE.
 CODE must be a 4-character string.  Return non-nil if successful.  */)
-  (filename, code)
+     (filename, code)
      Lisp_Object filename, code;
 {
   OSErr	status;
@@ -3766,12 +3764,12 @@
 
 
 DEFUN ("do-applescript", Fdo_applescript, Sdo_applescript, 1, 1, 0,
-       doc: /* Compile and execute AppleScript SCRIPT and retrieve and return the result.
+       doc: /* Compile and execute AppleScript SCRIPT and return the result.
 If compilation and execution are successful, the resulting script
 value is returned as a string.  Otherwise the function aborts and
 displays the error message returned by the AppleScript scripting
 component.  */)
-  (script)
+    (script)
     Lisp_Object script;
 {
   char *result, *temp;
@@ -3811,16 +3809,15 @@
 
 DEFUN ("mac-file-name-to-posix", Fmac_file_name_to_posix,
        Smac_file_name_to_posix, 1, 1, 0,
-       doc: /* Convert Macintosh filename to Posix form.  */)
-     (mac_filename)
-     Lisp_Object mac_filename;
+       doc: /* Convert Macintosh FILENAME to Posix form.  */)
+     (filename)
+     Lisp_Object filename;
 {
   char posix_filename[MAXPATHLEN+1];
 
-  CHECK_STRING (mac_filename);
-
-  if (mac_to_posix_pathname (SDATA (mac_filename), posix_filename,
-			   MAXPATHLEN))
+  CHECK_STRING (filename);
+
+  if (mac_to_posix_pathname (SDATA (filename), posix_filename, MAXPATHLEN))
     return build_string (posix_filename);
   else
     return Qnil;
@@ -3829,16 +3826,15 @@
 
 DEFUN ("posix-file-name-to-mac", Fposix_file_name_to_mac,
        Sposix_file_name_to_mac, 1, 1, 0,
-       doc: /* Convert Posix filename to Mac form.  */)
-     (posix_filename)
-     Lisp_Object posix_filename;
+       doc: /* Convert Posix FILENAME to Mac form.  */)
+     (filename)
+     Lisp_Object filename;
 {
   char mac_filename[MAXPATHLEN+1];
 
-  CHECK_STRING (posix_filename);
-
-  if (posix_to_mac_pathname (SDATA (posix_filename), mac_filename,
-			   MAXPATHLEN))
+  CHECK_STRING (filename);
+
+  if (posix_to_mac_pathname (SDATA (filename), mac_filename, MAXPATHLEN))
     return build_string (mac_filename);
   else
     return Qnil;
@@ -3853,8 +3849,8 @@
        doc: /* Return the application preference value for KEY.
 KEY is either a string specifying a preference key, or a list of key
 strings.  If it is a list, the (i+1)-th element is used as a key for
-the CFDictionary value obtained by the i-th element.  If lookup is
-failed at some stage, nil is returned.
+the CFDictionary value obtained by the i-th element.  Return nil if
+lookup is failed at some stage.
 
 Optional arg APPLICATION is an application ID string.  If omitted or
 nil, that stands for the current application.
@@ -3885,7 +3881,7 @@
 generate alists.  If HASH-BOUND >= 0, generate an alist if the number
 of keys in the dictionary is smaller than HASH-BOUND, and a hash table
 otherwise.  */)
-  (key, application, format, hash_bound)
+     (key, application, format, hash_bound)
      Lisp_Object key, application, format, hash_bound;
 {
   CFStringRef app_id, key_str;
@@ -4122,9 +4118,8 @@
 On Mac OS X 10.2 and later, you can do Unicode Normalization by
 specifying the optional argument NORMALIZATION-FORM with a symbol NFD,
 NFKD, NFC, NFKC, HFS+D, or HFS+C.
-On successful conversion, returns the result string, else returns
-nil.  */)
-  (string, source, target, normalization_form)
+On successful conversion, return the result string, else return nil.  */)
+     (string, source, target, normalization_form)
      Lisp_Object string, source, target, normalization_form;
 {
   Lisp_Object result = Qnil;
@@ -4183,7 +4178,7 @@
 
 DEFUN ("mac-clear-font-name-table", Fmac_clear_font_name_table, Smac_clear_font_name_table, 0, 0, 0,
        doc: /* Clear the font name table.  */)
-  ()
+     ()
 {
   check_mac ();
   mac_clear_font_name_table ();
@@ -4483,8 +4478,13 @@
      app_bundle_pathname.  */
 
   bundle = CFBundleGetMainBundle ();
-  if (!bundle)
-    return;
+  if (!bundle || CFBundleGetIdentifier (bundle) == NULL)
+    {
+      /* We could not find the bundle identifier.  For now, prevent
+	 the fatal error by bringing it up in the terminal. */
+      inhibit_window_system = 1;
+      return;
+    }
 
   bundleURL = CFBundleCopyBundleURL (bundle);
   if (!bundleURL)
--- a/src/macfns.c	Tue Jul 26 12:03:19 2005 +0000
+++ b/src/macfns.c	Fri Jul 29 01:54:54 2005 +0000
@@ -21,58 +21,34 @@
 /* Contributed by Andrew Choi (akochoi@mac.com).  */
 
 #include <config.h>
-
 #include <stdio.h>
 #include <math.h>
-#include <limits.h>
-#include <errno.h>
 
 #include "lisp.h"
-#include "charset.h"
 #include "macterm.h"
 #include "frame.h"
 #include "window.h"
 #include "buffer.h"
+#include "intervals.h"
 #include "dispextern.h"
-#include "fontset.h"
-#include "intervals.h"
 #include "keyboard.h"
 #include "blockinput.h"
-#include "epaths.h"
-#include "termhooks.h"
+#include <epaths.h>
+#include "charset.h"
 #include "coding.h"
+#include "fontset.h"
 #include "systime.h"
-
-/* #include "bitmaps/gray.xbm" */
-#define gray_width 2
-#define gray_height 2
-static unsigned char gray_bits[] = {
-   0x01, 0x02};
-
-/*#include <commdlg.h>
-#include <shellapi.h>*/
+#include "termhooks.h"
+#include "atimer.h"
+
 #include <ctype.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <limits.h>
+#include <errno.h>
 #include <sys/param.h>
 
-#include <stdlib.h>
-#include <string.h>
-
-/*extern void free_frame_menubar ();
-extern double atof ();
-extern int w32_console_toggle_lock_key (int vk_code, Lisp_Object new_state);
-extern int quit_char;*/
-
-extern char *lispy_function_keys[];
-
-/* The gray bitmap `bitmaps/gray'.  This is done because macterm.c uses
-   it, and including `bitmaps/gray' more than once is a problem when
-   config.h defines `static' as an empty replacement string.  */
-
-int gray_bitmap_width = gray_width;
-int gray_bitmap_height = gray_height;
-unsigned char *gray_bitmap_bits = gray_bits;
+extern void free_frame_menubar ();
 
 /* Non-zero means we're allowed to display an hourglass cursor.  */
 
@@ -109,46 +85,13 @@
 
 Lisp_Object Vx_pixel_size_width_font_regexp;
 
-/* Evaluate this expression to rebuild the section of syms_of_macfns
-   that initializes and staticpros the symbols declared below.  Note
-   that Emacs 18 has a bug that keeps C-x C-e from being able to
-   evaluate this expression.
-
-(progn
-  ;; Accumulate a list of the symbols we want to initialize from the
-  ;; declarations at the top of the file.
-  (goto-char (point-min))
-  (search-forward "/\*&&& symbols declared here &&&*\/\n")
-  (let (symbol-list)
-    (while (looking-at "Lisp_Object \\(Q[a-z_]+\\)")
-      (setq symbol-list
-	    (cons (buffer-substring (match-beginning 1) (match-end 1))
-		  symbol-list))
-      (forward-line 1))
-    (setq symbol-list (nreverse symbol-list))
-    ;; Delete the section of syms_of_... where we initialize the symbols.
-    (search-forward "\n  /\*&&& init symbols here &&&*\/\n")
-    (let ((start (point)))
-      (while (looking-at "^  Q")
-	(forward-line 2))
-      (kill-region start (point)))
-    ;; Write a new symbol initialization section.
-    (while symbol-list
-      (insert (format "  %s = intern (\"" (car symbol-list)))
-      (let ((start (point)))
-	(insert (substring (car symbol-list) 1))
-	(subst-char-in-region start (point) ?_ ?-))
-      (insert (format "\");\n  staticpro (&%s);\n" (car symbol-list)))
-      (setq symbol-list (cdr symbol-list)))))
-
-  */
-
-/*&&& symbols declared here &&&*/
 Lisp_Object Qnone;
 Lisp_Object Qsuppress_icon;
 Lisp_Object Qundefined_color;
 Lisp_Object Qcancel_timer;
 
+/* In dispnew.c */
+
 extern Lisp_Object Vwindow_system_version;
 
 #if 0 /* Use xstricmp instead.  */
@@ -243,40 +186,11 @@
 
   return dpyinfo;
 }
-
-/* Return the Emacs frame-object corresponding to a mac window.
-   It could be the frame's main window or an icon window.  */
-
-/* This function can be called during GC, so use GC_xxx type test macros.  */
-
-struct frame *
-x_window_to_frame (dpyinfo, wdesc)
-     struct mac_display_info *dpyinfo;
-     WindowPtr wdesc;
-{
-  Lisp_Object tail, frame;
-  struct frame *f;
-
-  for (tail = Vframe_list; GC_CONSP (tail); tail = XCDR (tail))
-    {
-      frame = XCAR (tail);
-      if (!GC_FRAMEP (frame))
-        continue;
-      f = XFRAME (frame);
-      if (!FRAME_W32_P (f) || FRAME_MAC_DISPLAY_INFO (f) != dpyinfo)
-	continue;
-      /*if (f->output_data.w32->hourglass_window == wdesc)
-        return f;*/
-
-      /* MAC_TODO: Check tooltips when supported.  */
-      if (FRAME_MAC_WINDOW (f) == wdesc)
-        return f;
-    }
-  return 0;
-}
 
 
+
 static Lisp_Object unwind_create_frame P_ ((Lisp_Object));
+static Lisp_Object unwind_create_tip_frame P_ ((Lisp_Object));
 
 void x_set_foreground_color P_ ((struct frame *, Lisp_Object, Lisp_Object));
 void x_set_background_color P_ ((struct frame *, Lisp_Object, Lisp_Object));
@@ -302,6 +216,8 @@
 
 extern void mac_get_window_bounds P_ ((struct frame *, Rect *, Rect *));
 
+
+
 /* Store the screen positions of frame F into XPTR and YPTR.
    These are the positions of the containing window manager window,
    not Emacs's own window.  */
@@ -1834,61 +1750,14 @@
 }
 
 
-/* Change the name of frame F to NAME.  If NAME is nil, set F's name to
-       w32_id_name.
-
-   If EXPLICIT is non-zero, that indicates that lisp code is setting the
-       name; if NAME is a string, set F's name to NAME and set
-       F->explicit_name; if NAME is Qnil, then clear F->explicit_name.
-
-   If EXPLICIT is zero, that indicates that Emacs redisplay code is
-       suggesting a new name, which lisp code should override; if
-       F->explicit_name is set, ignore the new name; otherwise, set it.  */
-
-void
-x_set_name (f, name, explicit)
-     struct frame *f;
+
+/* Set the Mac window title to NAME for frame F.  */
+
+static void
+x_set_name_internal (f, name)
+     FRAME_PTR f;
      Lisp_Object name;
-     int explicit;
 {
-  /* Make sure that requests from lisp code override requests from
-     Emacs redisplay code.  */
-  if (explicit)
-    {
-      /* If we're switching from explicit to implicit, we had better
-	 update the mode lines and thereby update the title.  */
-      if (f->explicit_name && NILP (name))
-	update_mode_lines = 1;
-
-      f->explicit_name = ! NILP (name);
-    }
-  else if (f->explicit_name)
-    return;
-
-  /* If NAME is nil, set the name to the w32_id_name.  */
-  if (NILP (name))
-    {
-      /* Check for no change needed in this very common case
-	 before we do any consing.  */
-      if (!strcmp (FRAME_MAC_DISPLAY_INFO (f)->mac_id_name,
-		   SDATA (f->name)))
-	return;
-      name = build_string (FRAME_MAC_DISPLAY_INFO (f)->mac_id_name);
-    }
-  else
-    CHECK_STRING (name);
-
-  /* Don't change the name if it's already NAME.  */
-  if (! NILP (Fstring_equal (name, f->name)))
-    return;
-
-  f->name = name;
-
-  /* For setting the frame title, the title parameter should override
-     the name parameter.  */
-  if (! NILP (f->title))
-    name = f->title;
-
   if (FRAME_MAC_WINDOW (f))
     {
       if (STRING_MULTIBYTE (name))
@@ -1922,6 +1791,64 @@
     }
 }
 
+/* Change the name of frame F to NAME.  If NAME is nil, set F's name to
+       mac_id_name.
+
+   If EXPLICIT is non-zero, that indicates that lisp code is setting the
+       name; if NAME is a string, set F's name to NAME and set
+       F->explicit_name; if NAME is Qnil, then clear F->explicit_name.
+
+   If EXPLICIT is zero, that indicates that Emacs redisplay code is
+       suggesting a new name, which lisp code should override; if
+       F->explicit_name is set, ignore the new name; otherwise, set it.  */
+
+void
+x_set_name (f, name, explicit)
+     struct frame *f;
+     Lisp_Object name;
+     int explicit;
+{
+  /* Make sure that requests from lisp code override requests from
+     Emacs redisplay code.  */
+  if (explicit)
+    {
+      /* If we're switching from explicit to implicit, we had better
+	 update the mode lines and thereby update the title.  */
+      if (f->explicit_name && NILP (name))
+	update_mode_lines = 1;
+
+      f->explicit_name = ! NILP (name);
+    }
+  else if (f->explicit_name)
+    return;
+
+  /* If NAME is nil, set the name to the mac_id_name.  */
+  if (NILP (name))
+    {
+      /* Check for no change needed in this very common case
+	 before we do any consing.  */
+      if (!strcmp (FRAME_MAC_DISPLAY_INFO (f)->mac_id_name,
+		   SDATA (f->name)))
+	return;
+      name = build_string (FRAME_MAC_DISPLAY_INFO (f)->mac_id_name);
+    }
+  else
+    CHECK_STRING (name);
+
+  /* Don't change the name if it's already NAME.  */
+  if (! NILP (Fstring_equal (name, f->name)))
+    return;
+
+  f->name = name;
+
+  /* For setting the frame title, the title parameter should override
+     the name parameter.  */
+  if (! NILP (f->title))
+    name = f->title;
+
+  x_set_name_internal (f, name);
+}
+
 /* This function should be called when the user's lisp code has
    specified a name for the frame; the name will override any set by the
    redisplay code.  */
@@ -1970,38 +1897,10 @@
 
   if (NILP (name))
     name = f->name;
-
-  if (FRAME_MAC_WINDOW (f))
-    {
-      if (STRING_MULTIBYTE (name))
-#if TARGET_API_MAC_CARBON
-	name = ENCODE_UTF_8 (name);
-#else
-	name = ENCODE_SYSTEM (name);
-#endif
-
-      BLOCK_INPUT;
-
-      {
-#if TARGET_API_MAC_CARBON
-	CFStringRef windowTitle =
-	  cfstring_create_with_utf8_cstring (SDATA (name));
-
-	SetWindowTitleWithCFString (FRAME_MAC_WINDOW (f), windowTitle);
-	CFRelease (windowTitle);
-#else
-	Str255 windowTitle;
-	if (strlen (SDATA (name)) < 255)
-	  {
-	    strcpy (windowTitle, SDATA (name));
-	    c2pstr (windowTitle);
-	    SetWTitle (FRAME_MAC_WINDOW (f), windowTitle);
-	  }
-#endif
-      }
-
-      UNBLOCK_INPUT;
-    }
+  else
+    CHECK_STRING (name);
+
+  x_set_name_internal (f, name);
 }
 
 void
@@ -2470,7 +2369,7 @@
 
 DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
        1, 1, 0,
-       doc: /* Make a new window, which is called a \"frame\" in Emacs terms.
+       doc: /* Make a new window, which is called a "frame" in Emacs terms.
 Returns an Emacs frame object.
 ALIST is an alist of frame parameters.
 If the parameters specify that the frame should not have a minibuffer,
@@ -2479,7 +2378,7 @@
 be shared by the new frame.
 
 This function is an internal primitive--use `make-frame' instead.  */)
-  (parms)
+     (parms)
      Lisp_Object parms;
 {
   struct frame *f;
@@ -2804,7 +2703,7 @@
 
 DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0,
        doc: /* Internal function called by `color-defined-p', which see.  */)
-  (color, frame)
+     (color, frame)
      Lisp_Object color, frame;
 {
   XColor foo;
@@ -2820,7 +2719,7 @@
 
 DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0,
        doc: /* Internal function called by `color-values', which see.  */)
-  (color, frame)
+     (color, frame)
      Lisp_Object color, frame;
 {
   XColor foo;
@@ -2843,7 +2742,7 @@
 
 DEFUN ("xw-display-color-p", Fxw_display_color_p, Sxw_display_color_p, 0, 1, 0,
        doc: /* Internal function called by `display-color-p', which see.  */)
-  (display)
+     (display)
      Lisp_Object display;
 {
   struct mac_display_info *dpyinfo = check_x_display_info (display);
@@ -2856,12 +2755,12 @@
 
 DEFUN ("x-display-grayscale-p", Fx_display_grayscale_p, Sx_display_grayscale_p,
        0, 1, 0,
-       doc: /* Return t if the X display supports shades of gray.
+       doc: /* Return t if DISPLAY supports shades of gray.
 Note that color displays do support shades of gray.
 The optional argument DISPLAY specifies which display to ask about.
 DISPLAY should be either a frame or a display name (a string).
 If omitted or nil, that stands for the selected frame's display.  */)
-  (display)
+     (display)
      Lisp_Object display;
 {
   struct mac_display_info *dpyinfo = check_x_display_info (display);
@@ -2874,11 +2773,11 @@
 
 DEFUN ("x-display-pixel-width", Fx_display_pixel_width, Sx_display_pixel_width,
        0, 1, 0,
-       doc: /* Returns the width in pixels of the X display DISPLAY.
+       doc: /* Returns the width in pixels of DISPLAY.
 The optional argument DISPLAY specifies which display to ask about.
 DISPLAY should be either a frame or a display name (a string).
 If omitted or nil, that stands for the selected frame's display.  */)
-  (display)
+     (display)
      Lisp_Object display;
 {
   struct mac_display_info *dpyinfo = check_x_display_info (display);
@@ -2888,11 +2787,11 @@
 
 DEFUN ("x-display-pixel-height", Fx_display_pixel_height,
        Sx_display_pixel_height, 0, 1, 0,
-       doc: /* Returns the height in pixels of the X display DISPLAY.
+       doc: /* Returns the height in pixels of DISPLAY.
 The optional argument DISPLAY specifies which display to ask about.
 DISPLAY should be either a frame or a display name (a string).
 If omitted or nil, that stands for the selected frame's display.  */)
-  (display)
+     (display)
      Lisp_Object display;
 {
   struct mac_display_info *dpyinfo = check_x_display_info (display);
@@ -2902,11 +2801,11 @@
 
 DEFUN ("x-display-planes", Fx_display_planes, Sx_display_planes,
        0, 1, 0,
-       doc: /* Returns the number of bitplanes of the display DISPLAY.
+       doc: /* Returns the number of bitplanes of DISPLAY.
 The optional argument DISPLAY specifies which display to ask about.
 DISPLAY should be either a frame or a display name (a string).
 If omitted or nil, that stands for the selected frame's display.  */)
-  (display)
+     (display)
      Lisp_Object display;
 {
   struct mac_display_info *dpyinfo = check_x_display_info (display);
@@ -2916,11 +2815,11 @@
 
 DEFUN ("x-display-color-cells", Fx_display_color_cells, Sx_display_color_cells,
        0, 1, 0,
-       doc: /* Returns the number of color cells of the display DISPLAY.
+       doc: /* Returns the number of color cells of DISPLAY.
 The optional argument DISPLAY specifies which display to ask about.
 DISPLAY should be either a frame or a display name (a string).
 If omitted or nil, that stands for the selected frame's display.  */)
-  (display)
+     (display)
      Lisp_Object display;
 {
   struct mac_display_info *dpyinfo = check_x_display_info (display);
@@ -2932,11 +2831,11 @@
 DEFUN ("x-server-max-request-size", Fx_server_max_request_size,
        Sx_server_max_request_size,
        0, 1, 0,
-       doc: /* Returns the maximum request size of the server of display DISPLAY.
+       doc: /* Returns the maximum request size of the server of DISPLAY.
 The optional argument DISPLAY specifies which display to ask about.
 DISPLAY should be either a frame or a display name (a string).
 If omitted or nil, that stands for the selected frame's display.  */)
-  (display)
+     (display)
      Lisp_Object display;
 {
   struct mac_display_info *dpyinfo = check_x_display_info (display);
@@ -2945,18 +2844,18 @@
 }
 
 DEFUN ("x-server-vendor", Fx_server_vendor, Sx_server_vendor, 0, 1, 0,
-       doc: /* Returns the vendor ID string of the Mac OS system (Apple).
+       doc: /* Returns the "vendor ID" string of the Mac OS system (Apple).
 The optional argument DISPLAY specifies which display to ask about.
 DISPLAY should be either a frame or a display name (a string).
 If omitted or nil, that stands for the selected frame's display.  */)
-  (display)
+     (display)
      Lisp_Object display;
 {
   return build_string ("Apple Computers");
 }
 
 DEFUN ("x-server-version", Fx_server_version, Sx_server_version, 0, 1, 0,
-       doc: /* Returns the version numbers of the server of display DISPLAY.
+       doc: /* Returns the version numbers of the Mac OS system.
 The value is a list of three integers: the major and minor
 version numbers, and the vendor-specific release
 number.  See also the function `x-server-vendor'.
@@ -2964,7 +2863,7 @@
 The optional argument DISPLAY specifies which display to ask about.
 DISPLAY should be either a frame or a display name (a string).
 If omitted or nil, that stands for the selected frame's display.  */)
-  (display)
+     (display)
      Lisp_Object display;
 {
   int mac_major_version;
@@ -2989,22 +2888,22 @@
 }
 
 DEFUN ("x-display-screens", Fx_display_screens, Sx_display_screens, 0, 1, 0,
-       doc: /* Return the number of screens on the server of display DISPLAY.
+       doc: /* Return the number of screens on the server of DISPLAY.
 The optional argument DISPLAY specifies which display to ask about.
 DISPLAY should be either a frame or a display name (a string).
 If omitted or nil, that stands for the selected frame's display.  */)
-  (display)
+     (display)
      Lisp_Object display;
 {
   return make_number (1);
 }
 
 DEFUN ("x-display-mm-height", Fx_display_mm_height, Sx_display_mm_height, 0, 1, 0,
-       doc: /* Return the height in millimeters of the X display DISPLAY.
+       doc: /* Return the height in millimeters of DISPLAY.
 The optional argument DISPLAY specifies which display to ask about.
 DISPLAY should be either a frame or a display name (a string).
 If omitted or nil, that stands for the selected frame's display.  */)
-  (display)
+     (display)
      Lisp_Object display;
 {
   /* MAC_TODO: this is an approximation, and only of the main display */
@@ -3015,11 +2914,11 @@
 }
 
 DEFUN ("x-display-mm-width", Fx_display_mm_width, Sx_display_mm_width, 0, 1, 0,
-       doc: /* Return the width in millimeters of the X display DISPLAY.
+       doc: /* Return the width in millimeters of DISPLAY.
 The optional argument DISPLAY specifies which display to ask about.
 DISPLAY should be either a frame or a display name (a string).
 If omitted or nil, that stands for the selected frame's display.  */)
-  (display)
+     (display)
      Lisp_Object display;
 {
   /* MAC_TODO: this is an approximation, and only of the main display */
@@ -3031,12 +2930,12 @@
 
 DEFUN ("x-display-backing-store", Fx_display_backing_store,
        Sx_display_backing_store, 0, 1, 0,
-       doc: /* Returns an indication of whether display DISPLAY does backing store.
+       doc: /* Returns an indication of whether DISPLAY does backing store.
 The value may be `always', `when-mapped', or `not-useful'.
 The optional argument DISPLAY specifies which display to ask about.
 DISPLAY should be either a frame or a display name (a string).
 If omitted or nil, that stands for the selected frame's display.  */)
-  (display)
+     (display)
      Lisp_Object display;
 {
   return intern ("not-useful");
@@ -3044,14 +2943,14 @@
 
 DEFUN ("x-display-visual-class", Fx_display_visual_class,
        Sx_display_visual_class, 0, 1, 0,
-       doc: /* Returns the visual class of the display DISPLAY.
+       doc: /* Returns the visual class of DISPLAY.
 The value is one of the symbols `static-gray', `gray-scale',
 `static-color', `pseudo-color', `true-color', or `direct-color'.
 
 The optional argument DISPLAY specifies which display to ask about.
 DISPLAY should be either a frame or a display name (a string).
 If omitted or nil, that stands for the selected frame's display.  */)
-	(display)
+     (display)
      Lisp_Object display;
 {
   struct mac_display_info *dpyinfo = check_x_display_info (display);
@@ -3075,11 +2974,11 @@
 
 DEFUN ("x-display-save-under", Fx_display_save_under,
        Sx_display_save_under, 0, 1, 0,
-       doc: /* Returns t if the display DISPLAY supports the save-under feature.
+       doc: /* Returns t if DISPLAY supports the save-under feature.
 The optional argument DISPLAY specifies which display to ask about.
 DISPLAY should be either a frame or a display name (a string).
 If omitted or nil, that stands for the selected frame's display.  */)
-  (display)
+     (display)
      Lisp_Object display;
 {
   return Qnil;
@@ -3169,7 +3068,7 @@
 Optional second arg XRM-STRING is a string of resources in xrdb format.
 If the optional third arg MUST-SUCCEED is non-nil,
 terminate Emacs if we can't open the connection.  */)
-  (display, xrm_string, must_succeed)
+     (display, xrm_string, must_succeed)
      Lisp_Object display, xrm_string, must_succeed;
 {
   unsigned char *xrm_option;
@@ -3214,8 +3113,8 @@
        doc: /* Close the connection to DISPLAY's server.
 For DISPLAY, specify either a frame or a display name (a string).
 If DISPLAY is nil, that stands for the selected frame's display.  */)
-  (display)
-  Lisp_Object display;
+     (display)
+     Lisp_Object display;
 {
   struct mac_display_info *dpyinfo = check_x_display_info (display);
   int i;
@@ -3241,7 +3140,7 @@
 
 DEFUN ("x-display-list", Fx_display_list, Sx_display_list, 0, 0, 0,
        doc: /* Return the list of display names that Emacs has connections to.  */)
-  ()
+     ()
 {
   Lisp_Object tail, result;
 
@@ -3253,13 +3152,8 @@
 }
 
 DEFUN ("x-synchronize", Fx_synchronize, Sx_synchronize, 1, 2, 0,
-       doc: /* If ON is non-nil, report errors as soon as the erring request is made.
-If ON is nil, allow buffering of requests.
-This is a noop on Mac OS systems.
-The optional second argument DISPLAY specifies which display to act on.
-DISPLAY should be either a frame or a display name (a string).
-If DISPLAY is omitted or nil, that stands for the selected frame's display.  */)
-  (on, display)
+       doc: /* This is a noop on Mac OS systems.  */)
+    (on, display)
     Lisp_Object display, on;
 {
   return Qnil;
@@ -3318,7 +3212,7 @@
        Sx_delete_window_property, 1, 2, 0,
        doc: /* Remove window property PROP from X window of FRAME.
 FRAME nil or omitted means use the selected frame.  Value is PROP.  */)
-  (prop, frame)
+     (prop, frame)
      Lisp_Object prop, frame;
 {
 #if 0 /* MAC_TODO : port window properties to Mac */
@@ -3346,7 +3240,7 @@
 If FRAME is nil or omitted, use the selected frame.  Value is nil
 if FRAME hasn't a property with name PROP or if PROP has no string
 value.  */)
-  (prop, frame)
+     (prop, frame)
      Lisp_Object prop, frame;
 {
 #if 0 /* MAC_TODO : port window properties to Mac */
@@ -3948,7 +3842,7 @@
 
 DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, 0,
        doc: /* Show STRING in a "tooltip" window on frame FRAME.
-A tooltip window is a small X window displaying a string.
+A tooltip window is a small window displaying a string.
 
 FRAME nil or omitted means use the selected frame.
 
@@ -3958,7 +3852,7 @@
 Automatically hide the tooltip after TIMEOUT seconds.  TIMEOUT nil
 means use the default timeout of 5 seconds.
 
-If the list of frame parameters PARAMS contains a `left' parameters,
+If the list of frame parameters PARMS contains a `left' parameter,
 the tooltip is displayed at that x-position.  Otherwise it is
 displayed at the mouse position, with offset DX added (default is 5 if
 DX isn't specified).  Likewise for the y-position; if a `top' frame
@@ -4216,7 +4110,7 @@
 Select DEFAULT-FILENAME in the dialog's file selection box, if
 specified.  Ensure that file exists if MUSTMATCH is non-nil.
 If ONLY-DIR-P is non-nil, the user can only select directories.  */)
-  (prompt, dir, default_filename, mustmatch, only_dir_p)
+     (prompt, dir, default_filename, mustmatch, only_dir_p)
      Lisp_Object prompt, dir, default_filename, mustmatch, only_dir_p;
 {
   struct frame *f = SELECTED_FRAME ();
--- a/src/macmenu.c	Tue Jul 26 12:03:19 2005 +0000
+++ b/src/macmenu.c	Fri Jul 29 01:54:54 2005 +0000
@@ -611,37 +611,48 @@
 
 DEFUN ("x-popup-menu", Fx_popup_menu, Sx_popup_menu, 2, 2, 0,
        doc: /* Pop up a deck-of-cards menu and return user's selection.
-POSITION is a position specification.  This is either a mouse button
-event or a list ((XOFFSET YOFFSET) WINDOW) where XOFFSET and YOFFSET
-are positions in pixels from the top left corner of WINDOW's frame
-\(WINDOW may be a frame object instead of a window).  This controls the
-position of the center of the first line in the first pane of the
-menu, not the top left of the menu as a whole.  If POSITION is t, it
-means to use the current mouse position.
+POSITION is a position specification.  This is either a mouse button event
+or a list ((XOFFSET YOFFSET) WINDOW)
+where XOFFSET and YOFFSET are positions in pixels from the top left
+corner of WINDOW.  (WINDOW may be a window or a frame object.)
+This controls the position of the top left of the menu as a whole.
+If POSITION is t, it means to use the current mouse position.
 
 MENU is a specifier for a menu.  For the simplest case, MENU is a keymap.
 The menu items come from key bindings that have a menu string as well as
-a definition; actually, the \"definition\" in such a key binding looks like
+a definition; actually, the "definition" in such a key binding looks like
 \(STRING . REAL-DEFINITION).  To give the menu a title, put a string into
 the keymap as a top-level element.
 
 If REAL-DEFINITION is nil, that puts a nonselectable string in the menu.
 Otherwise, REAL-DEFINITION should be a valid key binding definition.
 
-You can also use a list of keymaps as MENU.  Then each keymap makes a
-separate pane.  When MENU is a keymap or a list of keymaps, the return
-value is a list of events.
+You can also use a list of keymaps as MENU.
+  Then each keymap makes a separate pane.
 
-Alternatively, you can specify a menu of multiple panes with a list of
-the form (TITLE PANE1 PANE2...), where each pane is a list of
-form (TITLE ITEM1 ITEM2...).
-Each ITEM is normally a cons cell (STRING . VALUE); but a string can
-appear as an item--that makes a nonselectable line in the menu.
+When MENU is a keymap or a list of keymaps, the return value is the
+list of events corresponding to the user's choice. Note that
+`x-popup-menu' does not actually execute the command bound to that
+sequence of events.
+
+Alternatively, you can specify a menu of multiple panes
+  with a list of the form (TITLE PANE1 PANE2...),
+where each pane is a list of form (TITLE ITEM1 ITEM2...).
+Each ITEM is normally a cons cell (STRING . VALUE);
+but a string can appear as an item--that makes a nonselectable line
+in the menu.
 With this form of menu, the return value is VALUE from the chosen item.
 
 If POSITION is nil, don't display the menu at all, just precalculate the
-cached information about equivalent key sequences.  */)
-  (position, menu)
+cached information about equivalent key sequences.
+
+If the user gets rid of the menu without making a valid choice, for
+instance by clicking the mouse away from a valid choice or by typing
+keyboard input, then this normally results in a quit and
+`x-popup-menu' does not return.  But if POSITION is a mouse button
+event (indicating that the user invoked the menu with the mouse) then
+no quit occurs and `x-popup-menu' returns nil.  */)
+     (position, menu)
      Lisp_Object position, menu;
 {
   Lisp_Object keymap, tem;
@@ -840,7 +851,7 @@
 The dialog box appears in the middle of the specified frame.
 
 CONTENTS specifies the alternatives to display in the dialog box.
-It is a list of the form (TITLE ITEM1 ITEM2...).
+It is a list of the form (DIALOG ITEM1 ITEM2...).
 Each ITEM is a cons cell (STRING . VALUE).
 The return value is VALUE from the chosen item.
 
@@ -850,8 +861,12 @@
 \(By default, approximately half appear on each side.)
 
 If HEADER is non-nil, the frame title for the box is "Information",
-otherwise it is "Question". */)
-  (position, contents, header)
+otherwise it is "Question".
+
+If the user gets rid of the dialog box without making a valid choice,
+for instance using the window manager, then this produces a quit and
+`x-popup-dialog' does not return.  */)
+     (position, contents, header)
      Lisp_Object position, contents, header;
 {
   FRAME_PTR f = NULL;
--- a/src/macselect.c	Tue Jul 26 12:03:19 2005 +0000
+++ b/src/macselect.c	Fri Jul 29 01:54:54 2005 +0000
@@ -712,7 +712,7 @@
 {
   check_mac ();
   CHECK_SYMBOL (selection_name);
-  if (NILP (selection_value)) error ("selection-value may not be nil");
+  if (NILP (selection_value)) error ("SELECTION-VALUE may not be nil");
   x_own_selection (selection_name, selection_value);
   return selection_value;
 }
@@ -724,11 +724,11 @@
 
 DEFUN ("x-get-selection-internal", Fx_get_selection_internal,
        Sx_get_selection_internal, 2, 3, 0,
-       doc: /* Return text selected from some Mac window.
+       doc: /* Return text selected from some Mac application.
 SELECTION is a symbol, typically `PRIMARY', `SECONDARY', or `CLIPBOARD'.
 TYPE is the type of data desired, typically `STRING'.
 TIME_STAMP is ignored on Mac.  */)
-  (selection_symbol, target_type, time_stamp)
+     (selection_symbol, target_type, time_stamp)
      Lisp_Object selection_symbol, target_type, time_stamp;
 {
   Lisp_Object val = Qnil;
@@ -821,7 +821,7 @@
 
 DEFUN ("x-selection-owner-p", Fx_selection_owner_p, Sx_selection_owner_p,
        0, 1, 0,
-       doc: /* Whether the current Emacs process owns the given Selection.
+       doc: /* Whether the current Emacs process owns the given SELECTION.
 The arg should be the name of the selection in question, typically one of
 the symbols `PRIMARY', `SECONDARY', or `CLIPBOARD'.
 For convenience, the symbol nil is the same as `PRIMARY',
@@ -866,7 +866,7 @@
 
 DEFUN ("x-selection-exists-p", Fx_selection_exists_p, Sx_selection_exists_p,
        0, 1, 0,
-       doc: /* Whether there is an owner for the given Selection.
+       doc: /* Whether there is an owner for the given SELECTION.
 The arg should be the name of the selection in question, typically one of
 the symbols `PRIMARY', `SECONDARY', or `CLIPBOARD'.
 For convenience, the symbol nil is the same as `PRIMARY',
@@ -1077,7 +1077,7 @@
 and the local selection value (whatever was given to `x-own-selection').
 
 The function should return the value to send to the Scrap Manager
-\(a string).  A return value of nil
+\(must be a string).  A return value of nil
 means that the conversion could not be done.
 A return value which is the symbol `NULL'
 means that a side-effect was executed,
--- a/src/s/cygwin.h	Tue Jul 26 12:03:19 2005 +0000
+++ b/src/s/cygwin.h	Fri Jul 29 01:54:54 2005 +0000
@@ -1,7 +1,7 @@
 /* Template for system description header files.
    This file describes the parameters that system description files
    should define or not.
-   Copyright (C) 1985, 1986, 1992, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1985, 1986, 1992, 1999, 2005 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -123,8 +123,6 @@
    emacs lisp pointers */
 #define DATA_SEG_BITS 0x20000000
 #define LINKER $(CC) -Wl,--image-base,DATA_SEG_BITS
-/* gettext.h is in a strange place */
-#define C_SWITCH_SYSTEM -I/usr/share/gettext
 
 /* Use terminfo instead of termcap.  Fewer environment variables to
    go wrong, more terminal types. */
--- a/src/w32fns.c	Tue Jul 26 12:03:19 2005 +0000
+++ b/src/w32fns.c	Fri Jul 29 01:54:54 2005 +0000
@@ -396,10 +396,10 @@
 }
 
 
-BOOL my_show_window P_ ((struct frame *, HWND, int));
-void my_set_window_pos P_ ((HWND, HWND, int, int, int, int, UINT));
 static Lisp_Object unwind_create_frame P_ ((Lisp_Object));
 static Lisp_Object unwind_create_tip_frame P_ ((Lisp_Object));
+static void my_create_window P_ ((struct frame *));
+static void my_create_tip_window P_ ((struct frame *));
 
 /* TODO: Native Input Method support; see x_create_im.  */
 void x_set_foreground_color P_ ((struct frame *, Lisp_Object, Lisp_Object));
@@ -3848,7 +3848,7 @@
   return 0;
 }
 
-void
+static void
 my_create_window (f)
      struct frame * f;
 {
@@ -3864,7 +3864,7 @@
    indirectly via the Window thread, as we do not need to process Window
    messages for the tooltip.  Creating tooltips indirectly also creates
    deadlocks when tooltips are created for menu items.  */
-void
+static void
 my_create_tip_window (f)
      struct frame *f;
 {
--- a/src/w32menu.c	Tue Jul 26 12:03:19 2005 +0000
+++ b/src/w32menu.c	Fri Jul 29 01:54:54 2005 +0000
@@ -2418,8 +2418,11 @@
       struct frame *f = x_window_to_frame (&one_w32_display_info, owner);
       Lisp_Object frame, help;
 
-      /* No help echo on owner-draw menu items.  */
-      if (flags & MF_OWNERDRAW || flags & MF_POPUP)
+      /* No help echo on owner-draw menu items, or when the keyboard is used
+	 to navigate the menus, since tooltips are distracting if they pop
+	 up elsewhere.  */
+      if (flags & MF_OWNERDRAW || flags & MF_POPUP
+	  || !(flags & MF_MOUSESELECT))
 	help = Qnil;
       else
 	{
--- a/src/w32term.c	Tue Jul 26 12:03:19 2005 +0000
+++ b/src/w32term.c	Fri Jul 29 01:54:54 2005 +0000
@@ -299,6 +299,11 @@
 static void x_draw_bar_cursor P_ ((struct window *, struct glyph_row *, int,
 				   enum text_cursor_kinds));
 static void w32_clip_to_row P_ ((struct window *, struct glyph_row *, int, HDC));
+static BOOL my_show_window P_ ((struct frame *, HWND, int));
+static void my_set_window_pos P_ ((HWND, HWND, int, int, int, int, UINT));
+static void my_set_focus P_ ((struct frame *, HWND));
+static void my_set_foreground_window P_ ((HWND));
+static void my_destroy_window P_ ((struct frame *, HWND));
 
 static Lisp_Object Qvendor_specific_keysyms;
 
@@ -3783,7 +3788,7 @@
 
 /*#define ATTACH_THREADS*/
 
-BOOL
+static BOOL
 my_show_window (FRAME_PTR f, HWND hwnd, int how)
 {
 #ifndef ATTACH_THREADS
@@ -3794,7 +3799,7 @@
 #endif
 }
 
-void
+static void
 my_set_window_pos (HWND hwnd, HWND hwndAfter,
 		   int x, int y, int cx, int cy, UINT flags)
 {
@@ -3812,7 +3817,7 @@
 #endif
 }
 
-void
+static void
 my_set_focus (f, hwnd)
      struct frame * f;
      HWND hwnd;
@@ -3821,14 +3826,15 @@
 	       (WPARAM) hwnd, 0);
 }
 
-void
+static void
 my_set_foreground_window (hwnd)
      HWND hwnd;
 {
   SendMessage (hwnd, WM_EMACS_SETFOREGROUND, (WPARAM) hwnd, 0);
 }
 
-void
+
+static void
 my_destroy_window (f, hwnd)
      struct frame * f;
      HWND hwnd;