changeset 111234:0576327092ab

merge trunk
author Kenichi Handa <handa@m17n.org>
date Thu, 28 Oct 2010 19:57:59 +0900
parents d86e0c3de741 (current diff) 5d7d30110595 (diff)
children 24c75a5f002a
files lib-src/digest-doc.c lib-src/sorted-doc.c nextstep/AUTHORS
diffstat 243 files changed, 9158 insertions(+), 6041 deletions(-) [+]
line wrap: on
line diff
--- a/BUGS	Thu Oct 14 16:21:40 2010 +0900
+++ b/BUGS	Thu Oct 28 19:57:59 2010 +0900
@@ -1,26 +1,23 @@
-If you think you may have found a bug in GNU Emacs, please
-read the Bugs section of the Emacs manual for advice on
+If you think you may have found a bug in GNU Emacs, please read the
+Bugs section of the Emacs manual for advice on
+
 (1) how to tell when to report a bug, and
-(2) how to write a useful bug report and what information
-it needs to have.
-
-There are three ways to read the Bugs section.
+(2) how to write a useful bug report and what information it needs to have.
 
-(1) In a printed copy of the Emacs manual.
-You can order one from the Free Software Foundation;
-see the file etc/ORDERS.  But if you don't have a copy on
-hand and you think you have found a bug, you shouldn't wait
-to get a printed manual; you should read the section right away
-as described below.
+You can read the read the Bugs section of the manual from inside Emacs.
+Start Emacs, do C-h i to enter Info, then m Emacs RET to get to the
+Emacs manual, then m Bugs RET to get to the section on bugs.
+Or you can use the standalone Info program in a like manner.
+(Standalone Info is part of the Texinfo distribution, not part of the
+Emacs distribution.)
 
-(2) With Info.  Start Emacs, do C-h i to enter Info,
-then m Emacs RET to get to the Emacs manual, then m Bugs RET
-to get to the section on bugs.  Or use standalone Info in
-a like manner.  (Standalone Info is part of the Texinfo distribution,
-not part of the Emacs distribution.)
+Printed copies of the Emacs manual can be purchased from the Free
+Software Foundation's online store at <http://shop.fsf.org/>.
 
-(3) By hand.  Do
+If necessary, you can read the manual without an info program:
+
     cat info/emacs* | more "+/^File: emacs,  Node: Bugs,"
 
+
 Please first check the file etc/PROBLEMS (e.g. with C-h C-p in Emacs) to
 make sure it isn't a known issue.
--- a/ChangeLog	Thu Oct 14 16:21:40 2010 +0900
+++ b/ChangeLog	Thu Oct 28 19:57:59 2010 +0900
@@ -1,3 +1,37 @@
+2010-10-25  Andreas Schwab  <schwab@linux-m68k.org>
+
+	* configure.in (checking for -znocombreloc): Use AC_LANG_PROGRAM
+	to avoid warning.
+
+2010-10-24  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* configure.in: Remove the BROKEN annotation from gnutls.
+
+2010-10-22  Glenn Morris  <rgm@gnu.org>
+
+	* make-dist: Avoid listing .el files twice.  Don't try to run
+	autoconf if --no-update.
+
+2010-10-20  Glenn Morris  <rgm@gnu.org>
+
+	* make-dist: No longer create lisp/MANIFEST.
+
+2010-10-14  Glenn Morris  <rgm@gnu.org>
+
+	* BUGS, INSTALL.BZR, README: Updates.
+
+2010-10-13  Glenn Morris  <rgm@gnu.org>
+
+	* make-dist: Remove --compress.  Check for the appropriate
+	gzip-like executable, and if not found, don't compress.
+	Check version number in README, don't change it.
+	Use find for nt/inc/*.h.
+
+2010-10-12  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* configure (ns_appdir, OLDXMENU, TOOLTIP_SUPPORT): Remove
+	trailing / from directory names.
+
 2010-10-12  Glenn Morris  <rgm@gnu.org>
 
 	* make-dist: Update and simplify.
--- a/INSTALL	Thu Oct 14 16:21:40 2010 +0900
+++ b/INSTALL	Thu Oct 28 19:57:59 2010 +0900
@@ -676,8 +676,7 @@
 the paths to the values specified in `./Makefile'.
 
 2) Go to directory `./lib-src' and run `make'.  This creates
-executables named `ctags' and `etags' and `make-docfile' and
-`digest-doc' and `test-distrib'.  And others.
+executables named `etags', `make-docfile', and others.
 
 3) Go to directory `./src' and run `make'.  This refers to files in
 the `./lisp' and `./lib-src' subdirectories using names `../lisp' and
@@ -709,8 +708,6 @@
     are intended to be run by users; they are handled below.
 - The programs `make-docfile' and `test-distrib' were
     used in building Emacs, and are not needed any more.
-- The programs `digest-doc' and `sorted-doc' convert a `DOC' file into
-    a file for users to read.  There is no important reason to move them.
 
 2) Copy the files in `./info' to the place specified in
 `./lisp/site-init.el' or `./lisp/paths.el'.  Note that if the
--- a/INSTALL.BZR	Thu Oct 14 16:21:40 2010 +0900
+++ b/INSTALL.BZR	Thu Oct 28 19:57:59 2010 +0900
@@ -31,13 +31,9 @@
 subdirectories of lisp/, e.g. mh-e/ and calendar/) will need to be
 updated to reflect new autoloaded functions.  If you see errors (rather
 than warnings) about undefined lisp functions during compilation, that
-may be the reason.  Another symptom may be an error saying that
-"loaddefs.el" could not be found; this is due to a change in the way
-loaddefs.el was handled in version control, and should only happen
-once, for users that are updating old sources.  Finally, sometimes
-there can be build failures related to *loaddefs.el (e.g. "required
-feature `esh-groups' was not provided").  In that case, follow the
-instructions below.
+may be the reason.  Finally, sometimes there can be build failures
+related to *loaddefs.el (e.g. "required feature `esh-groups' was not
+provided").  In that case, follow the instructions below.
 
 To update loaddefs.el (and similar files), do:
 
@@ -53,10 +49,6 @@
 etc.) before "make bootstrap" or "make"; the rest of the procedure is
 applicable to those systems as well.
 
-Questions, requests, and bug reports about the Bazaar versions of Emacs
-should be sent to bug-gnu-emacs@gnu.org rather than gnu.emacs.help.
-Ideally, use M-x report-emacs-bug RET.
-
 Because the Bazaar version of Emacs is a work in progress, it will
 sometimes fail to build.  Please wait a day or so (and check the bug
 and development mailing list archives) before reporting such problems.
--- a/README	Thu Oct 14 16:21:40 2010 +0900
+++ b/README	Thu Oct 28 19:57:59 2010 +0900
@@ -65,16 +65,15 @@
             which can't be directly produced by your keyboard.
 `lib-src'   holds the source code for some utility programs for use by or
             with Emacs, like movemail and etags.
-`etc'       holds miscellaneous architecture-independent data files
-            Emacs uses, like the tutorial text and the Zippy the Pinhead
-            quote database.  The contents of the `lisp', `leim', `info',
-            `man', `lispref', and `lispintro' subdirectories are
-            architecture-independent too.
+`etc'       holds miscellaneous architecture-independent data files Emacs
+            uses, like the tutorial text and tool bar images.
+            The contents of the `lisp', `leim', `info', and `doc'
+            subdirectories are architecture-independent too.
 `info'      holds the Info documentation tree for Emacs.
 `doc/emacs' holds the source code for the Emacs Manual.  If you modify the
             manual sources, you will need the `makeinfo' program to produce
             an updated manual.  `makeinfo' is part of the GNU Texinfo
-            package; you need version 4.6 or later of Texinfo.
+            package; you need a suitably recent version of Texinfo.
 `doc/lispref'   holds the source code for the Emacs Lisp reference manual.
 `doc/lispintro' holds the source code for the Introduction to Programming
                 in Emacs Lisp manual.
@@ -85,10 +84,9 @@
             to building and running Emacs on Windows 9X/ME/NT/2000/XP.
 `test'      holds tests for various aspects of Emacs's functionality.
 
-   Building Emacs on non-Posix platforms requires to install tools
-that aren't part of the standard distribution of the OS.  The
-platform-specific README files and installation instructions should
-list the required tools.
+   Building Emacs on non-Posix platforms requires tools that aren't part
+of the standard distribution of the OS.  The platform-specific README
+files and installation instructions should list the required tools.
 
 
 This file is part of GNU Emacs.
--- a/admin/make-tarball.txt	Thu Oct 14 16:21:40 2010 +0900
+++ b/admin/make-tarball.txt	Thu Oct 28 19:57:59 2010 +0900
@@ -4,7 +4,8 @@
 
 For each step, check for possible errors.
 
-1.   cvs -q update -Pd
+1.  `bzr update' (for a bound branch), or `bzr pull'.
+     bzr status # check for locally modified files
 
 2.  Bootstrap to make 100% sure all elc files are up-to-date, and to
     make sure that the later tagged version will bootstrap, should it be
@@ -27,24 +28,23 @@
     refer to a newer release of Emacs.  (This is probably needed only
     when preparing a major Emacs release, or branching for it.)
 
-5.   rm configure; autoconf
+5.   rm configure src/config.in; autoconf; autoheader
      make bootstrap
 
-6.  Commit configure, README, doc/emacs/emacs.texi,
-    doc/lispref/elisp.texi, etc/AUTHORS, src/emacs.c, nt/emacs.rc,
-    and lisp/cus-edit.el (if modified).  Copy lisp/loaddefs.el to
-    lisp/ldefs-boot.el and commit lisp/ldefs-boot.el.  For a release,
-    also commit the ChangeLog files in all directories.
+6.  Commit configure, src/config.in, etc/AUTHORS, all the files changed
+    by M-x set-version, and lisp/cus-edit.el (if modified).
+    Copy lisp/loaddefs.el to lisp/ldefs-boot.el and commit lisp/ldefs-boot.el.
+    For a release, also commit the ChangeLog files in all directories.
 
 7.   make-dist --snapshot.  Check the contents of the new tar with
     admin/diff-tar-files against an older tar file.  Some old pretest
-    tarballs are kept under fencepost.gnu.org:~pot/emacs-pretest/, while
-    old emacs tarballs are at <ftp://ftp.gnu.org/pub/gnu/emacs/>.
+    tarballs may be found at <ftp://alpha.gnu.org/gnu/emacs/pretest>;
+    old release tarballs are at <ftp://ftp.gnu.org/pub/gnu/emacs/>.
 
     If this is the first pretest of a major release, just comparing
     with the previous release may overlook many new files.  You can try
-    something like `find -f | grep -v CVS...etc' in a clean CVS tree,
-    and compare the results against the new tar contents.
+    something like `find . | sort' in a clean bzr tree, and compare the
+    results against the new tar contents.
 
 8.   xdelta delta emacs-OLD.tar.gz emacs-NEW.tar.gz emacs-OLD-NEW.xdelta
 
@@ -108,5 +108,3 @@
     For a release, announce it on info-gnu@gnu.org,
     info-gnu-emacs@gnu.org, and emacs-devel.
 
-
-# arch-tag: c23c771f-ca26-4584-8a04-50ecf0989390
--- a/configure	Thu Oct 14 16:21:40 2010 +0900
+++ b/configure	Thu Oct 28 19:57:59 2010 +0900
@@ -1,11 +1,11 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.65 for emacs 24.0.50.
+# Generated by GNU Autoconf 2.68 for emacs 24.0.50.
 #
 #
 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
-# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
-# Inc.
+# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
+# Foundation, Inc.
 #
 #
 # This configure script is free software; the Free Software Foundation
@@ -89,6 +89,7 @@
 IFS=" ""	$as_nl"
 
 # Find who we are.  Look in the path if we contain no directory separator.
+as_myself=
 case $0 in #((
   *[\\/]* ) as_myself=$0 ;;
   *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
@@ -214,11 +215,18 @@
   # We cannot yet assume a decent shell, so we have to provide a
 	# neutralization value for shells without unset; and this also
 	# works around shells that cannot unset nonexistent variables.
+	# Preserve -v and -x to the replacement shell.
 	BASH_ENV=/dev/null
 	ENV=/dev/null
 	(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
 	export CONFIG_SHELL
-	exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"}
+	case $- in # ((((
+	  *v*x* | *x*v* ) as_opts=-vx ;;
+	  *v* ) as_opts=-v ;;
+	  *x* ) as_opts=-x ;;
+	  * ) as_opts= ;;
+	esac
+	exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"}
 fi
 
     if test x$as_have_required = xno; then :
@@ -316,7 +324,7 @@
       test -d "$as_dir" && break
     done
     test -z "$as_dirs" || eval "mkdir $as_dirs"
-  } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir"
+  } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
 
 
 } # as_fn_mkdir_p
@@ -356,19 +364,19 @@
 fi # as_fn_arith
 
 
-# as_fn_error ERROR [LINENO LOG_FD]
-# ---------------------------------
+# as_fn_error STATUS ERROR [LINENO LOG_FD]
+# ----------------------------------------
 # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
 # provided, also output the error to LOG_FD, referencing LINENO. Then exit the
-# script with status $?, using 1 if that was 0.
+# script with STATUS, using 1 if that was 0.
 as_fn_error ()
 {
-  as_status=$?; test $as_status -eq 0 && as_status=1
-  if test "$3"; then
-    as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-    $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3
-  fi
-  $as_echo "$as_me: error: $1" >&2
+  as_status=$1; test $as_status -eq 0 && as_status=1
+  if test "$4"; then
+    as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+    $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
+  fi
+  $as_echo "$as_me: error: $2" >&2
   as_fn_exit $as_status
 } # as_fn_error
 
@@ -530,7 +538,7 @@
 exec 6>&1
 
 # Name of the host.
-# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
+# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status,
 # so uname gets run too.
 ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
 
@@ -912,8 +920,9 @@
   fi
 
   case $ac_option in
-  *=*)	ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
-  *)	ac_optarg=yes ;;
+  *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
+  *=)   ac_optarg= ;;
+  *)    ac_optarg=yes ;;
   esac
 
   # Accept the important Cygnus configure options, so we can diagnose typos.
@@ -958,7 +967,7 @@
     ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
     # Reject names that are not valid shell variable names.
     expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-      as_fn_error "invalid feature name: $ac_useropt"
+      as_fn_error $? "invalid feature name: $ac_useropt"
     ac_useropt_orig=$ac_useropt
     ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
     case $ac_user_opts in
@@ -984,7 +993,7 @@
     ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
     # Reject names that are not valid shell variable names.
     expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-      as_fn_error "invalid feature name: $ac_useropt"
+      as_fn_error $? "invalid feature name: $ac_useropt"
     ac_useropt_orig=$ac_useropt
     ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
     case $ac_user_opts in
@@ -1188,7 +1197,7 @@
     ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
     # Reject names that are not valid shell variable names.
     expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-      as_fn_error "invalid package name: $ac_useropt"
+      as_fn_error $? "invalid package name: $ac_useropt"
     ac_useropt_orig=$ac_useropt
     ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
     case $ac_user_opts in
@@ -1204,7 +1213,7 @@
     ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`
     # Reject names that are not valid shell variable names.
     expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-      as_fn_error "invalid package name: $ac_useropt"
+      as_fn_error $? "invalid package name: $ac_useropt"
     ac_useropt_orig=$ac_useropt
     ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
     case $ac_user_opts in
@@ -1234,8 +1243,8 @@
   | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
     x_libraries=$ac_optarg ;;
 
-  -*) as_fn_error "unrecognized option: \`$ac_option'
-Try \`$0 --help' for more information."
+  -*) as_fn_error $? "unrecognized option: \`$ac_option'
+Try \`$0 --help' for more information"
     ;;
 
   *=*)
@@ -1243,7 +1252,7 @@
     # Reject names that are not valid shell variable names.
     case $ac_envvar in #(
       '' | [0-9]* | *[!_$as_cr_alnum]* )
-      as_fn_error "invalid variable name: \`$ac_envvar'" ;;
+      as_fn_error $? "invalid variable name: \`$ac_envvar'" ;;
     esac
     eval $ac_envvar=\$ac_optarg
     export $ac_envvar ;;
@@ -1253,7 +1262,7 @@
     $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2
     expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
       $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2
-    : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
+    : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}"
     ;;
 
   esac
@@ -1261,13 +1270,13 @@
 
 if test -n "$ac_prev"; then
   ac_option=--`echo $ac_prev | sed 's/_/-/g'`
-  as_fn_error "missing argument to $ac_option"
+  as_fn_error $? "missing argument to $ac_option"
 fi
 
 if test -n "$ac_unrecognized_opts"; then
   case $enable_option_checking in
     no) ;;
-    fatal) as_fn_error "unrecognized options: $ac_unrecognized_opts" ;;
+    fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;;
     *)     $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
   esac
 fi
@@ -1290,7 +1299,7 @@
     [\\/$]* | ?:[\\/]* )  continue;;
     NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
   esac
-  as_fn_error "expected an absolute directory name for --$ac_var: $ac_val"
+  as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val"
 done
 
 # There might be people who depend on the old broken behavior: `$host'
@@ -1304,8 +1313,8 @@
 if test "x$host_alias" != x; then
   if test "x$build_alias" = x; then
     cross_compiling=maybe
-    $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
-    If a cross compiler is detected then cross compile mode will be used." >&2
+    $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host.
+    If a cross compiler is detected then cross compile mode will be used" >&2
   elif test "x$build_alias" != "x$host_alias"; then
     cross_compiling=yes
   fi
@@ -1320,9 +1329,9 @@
 ac_pwd=`pwd` && test -n "$ac_pwd" &&
 ac_ls_di=`ls -di .` &&
 ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
-  as_fn_error "working directory cannot be determined"
+  as_fn_error $? "working directory cannot be determined"
 test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
-  as_fn_error "pwd does not report name of working directory"
+  as_fn_error $? "pwd does not report name of working directory"
 
 
 # Find the source files, if location was not specified.
@@ -1361,11 +1370,11 @@
 fi
 if test ! -r "$srcdir/$ac_unique_file"; then
   test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
-  as_fn_error "cannot find sources ($ac_unique_file) in $srcdir"
+  as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir"
 fi
 ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
 ac_abs_confdir=`(
-	cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error "$ac_msg"
+	cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg"
 	pwd)`
 # When building in place, set srcdir=.
 if test "$ac_abs_confdir" = "$ac_pwd"; then
@@ -1405,7 +1414,7 @@
       --help=short        display options specific to this package
       --help=recursive    display the short help of all the included packages
   -V, --version           display version information and exit
-  -q, --quiet, --silent   do not print \`checking...' messages
+  -q, --quiet, --silent   do not print \`checking ...' messages
       --cache-file=FILE   cache test results in FILE [disabled]
   -C, --config-cache      alias for \`--cache-file=config.cache'
   -n, --no-create         do not create output files
@@ -1624,9 +1633,9 @@
 if $ac_init_version; then
   cat <<\_ACEOF
 emacs configure 24.0.50
-generated by GNU Autoconf 2.65
-
-Copyright (C) 2009 Free Software Foundation, Inc.
+generated by GNU Autoconf 2.68
+
+Copyright (C) 2010 Free Software Foundation, Inc.
 This configure script is free software; the Free Software Foundation
 gives unlimited permission to copy, distribute and modify it.
 _ACEOF
@@ -1670,7 +1679,7 @@
 
 	ac_retval=1
 fi
-  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
   as_fn_set_status $ac_retval
 
 } # ac_fn_c_try_compile
@@ -1716,7 +1725,7 @@
   # interfere with the next link command; also delete a directory that is
   # left behind by Apple's compiler.  We do this before executing the actions.
   rm -rf conftest.dSYM conftest_ipa8_conftest.oo
-  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
   as_fn_set_status $ac_retval
 
 } # ac_fn_c_try_link
@@ -1742,7 +1751,7 @@
     mv -f conftest.er1 conftest.err
   fi
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } >/dev/null && {
+  test $ac_status = 0; } > conftest.i && {
 	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
 	 test ! -s conftest.err
        }; then :
@@ -1753,7 +1762,7 @@
 
     ac_retval=1
 fi
-  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
   as_fn_set_status $ac_retval
 
 } # ac_fn_c_try_cpp
@@ -1766,10 +1775,10 @@
 ac_fn_c_check_header_mongrel ()
 {
   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
+  if eval \${$3+:} false; then :
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
 $as_echo_n "checking for $2... " >&6; }
-if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
+if eval \${$3+:} false; then :
   $as_echo_n "(cached) " >&6
 fi
 eval ac_res=\$$3
@@ -1805,7 +1814,7 @@
 else
   ac_header_preproc=no
 fi
-rm -f conftest.err conftest.$ac_ext
+rm -f conftest.err conftest.i conftest.$ac_ext
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5
 $as_echo "$ac_header_preproc" >&6; }
 
@@ -1832,7 +1841,7 @@
 esac
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
 $as_echo_n "checking for $2... " >&6; }
-if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
+if eval \${$3+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   eval "$3=\$ac_header_compiler"
@@ -1841,7 +1850,7 @@
 	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
 $as_echo "$ac_res" >&6; }
 fi
-  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
 
 } # ac_fn_c_check_header_mongrel
 
@@ -1882,7 +1891,7 @@
        ac_retval=$ac_status
 fi
   rm -rf conftest.dSYM conftest_ipa8_conftest.oo
-  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
   as_fn_set_status $ac_retval
 
 } # ac_fn_c_try_run
@@ -1896,7 +1905,7 @@
   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
 $as_echo_n "checking for $2... " >&6; }
-if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
+if eval \${$3+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -1914,19 +1923,22 @@
 eval ac_res=\$$3
 	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
 $as_echo "$ac_res" >&6; }
-  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
 
 } # ac_fn_c_check_header_compile
 
-# ac_fn_c_check_decl LINENO SYMBOL VAR
-# ------------------------------------
-# Tests whether SYMBOL is declared, setting cache variable VAR accordingly.
+# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
+# ---------------------------------------------
+# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
+# accordingly.
 ac_fn_c_check_decl ()
 {
   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $2 is declared" >&5
-$as_echo_n "checking whether $2 is declared... " >&6; }
-if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
+  as_decl_name=`echo $2|sed 's/ *(.*//'`
+  as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5
+$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
+if eval \${$3+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -1935,8 +1947,12 @@
 int
 main ()
 {
-#ifndef $2
-  (void) $2;
+#ifndef $as_decl_name
+#ifdef __cplusplus
+  (void) $as_decl_use;
+#else
+  (void) $as_decl_name;
+#endif
 #endif
 
   ;
@@ -1953,7 +1969,7 @@
 eval ac_res=\$$3
 	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
 $as_echo "$ac_res" >&6; }
-  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
 
 } # ac_fn_c_check_decl
 
@@ -1965,7 +1981,7 @@
   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
 $as_echo_n "checking for $2... " >&6; }
-if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
+if eval \${$3+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -1977,12 +1993,12 @@
 else
   eval "$3=no"
 fi
-rm -f conftest.err conftest.$ac_ext
+rm -f conftest.err conftest.i conftest.$ac_ext
 fi
 eval ac_res=\$$3
 	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
 $as_echo "$ac_res" >&6; }
-  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
 
 } # ac_fn_c_check_header_preproc
 
@@ -1995,7 +2011,7 @@
   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2.$3" >&5
 $as_echo_n "checking for $2.$3... " >&6; }
-if { as_var=$4; eval "test \"\${$as_var+set}\" = set"; }; then :
+if eval \${$4+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -2039,7 +2055,7 @@
 eval ac_res=\$$4
 	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
 $as_echo "$ac_res" >&6; }
-  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
 
 } # ac_fn_c_check_member
 
@@ -2051,7 +2067,7 @@
   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
 $as_echo_n "checking for $2... " >&6; }
-if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
+if eval \${$3+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -2106,7 +2122,7 @@
 eval ac_res=\$$3
 	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
 $as_echo "$ac_res" >&6; }
-  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
 
 } # ac_fn_c_check_func
 
@@ -2119,7 +2135,7 @@
   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
 $as_echo_n "checking for $2... " >&6; }
-if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
+if eval \${$3+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   eval "$3=no"
@@ -2160,7 +2176,7 @@
 eval ac_res=\$$3
 	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
 $as_echo "$ac_res" >&6; }
-  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
 
 } # ac_fn_c_check_type
 cat >config.log <<_ACEOF
@@ -2168,7 +2184,7 @@
 running configure, to aid debugging if configure makes a mistake.
 
 It was created by emacs $as_me 24.0.50, which was
-generated by GNU Autoconf 2.65.  Invocation command line was
+generated by GNU Autoconf 2.68.  Invocation command line was
 
   $ $0 $@
 
@@ -2278,11 +2294,9 @@
   {
     echo
 
-    cat <<\_ASBOX
-## ---------------- ##
+    $as_echo "## ---------------- ##
 ## Cache variables. ##
-## ---------------- ##
-_ASBOX
+## ---------------- ##"
     echo
     # The following way of writing the cache mishandles newlines in values,
 (
@@ -2316,11 +2330,9 @@
 )
     echo
 
-    cat <<\_ASBOX
-## ----------------- ##
+    $as_echo "## ----------------- ##
 ## Output variables. ##
-## ----------------- ##
-_ASBOX
+## ----------------- ##"
     echo
     for ac_var in $ac_subst_vars
     do
@@ -2333,11 +2345,9 @@
     echo
 
     if test -n "$ac_subst_files"; then
-      cat <<\_ASBOX
-## ------------------- ##
+      $as_echo "## ------------------- ##
 ## File substitutions. ##
-## ------------------- ##
-_ASBOX
+## ------------------- ##"
       echo
       for ac_var in $ac_subst_files
       do
@@ -2351,11 +2361,9 @@
     fi
 
     if test -s confdefs.h; then
-      cat <<\_ASBOX
-## ----------- ##
+      $as_echo "## ----------- ##
 ## confdefs.h. ##
-## ----------- ##
-_ASBOX
+## ----------- ##"
       echo
       cat confdefs.h
       echo
@@ -2410,7 +2418,12 @@
 ac_site_file1=NONE
 ac_site_file2=NONE
 if test -n "$CONFIG_SITE"; then
-  ac_site_file1=$CONFIG_SITE
+  # We do not want a PATH search for config.site.
+  case $CONFIG_SITE in #((
+    -*)  ac_site_file1=./$CONFIG_SITE;;
+    */*) ac_site_file1=$CONFIG_SITE;;
+    *)   ac_site_file1=./$CONFIG_SITE;;
+  esac
 elif test "x$prefix" != xNONE; then
   ac_site_file1=$prefix/share/config.site
   ac_site_file2=$prefix/etc/config.site
@@ -2425,7 +2438,11 @@
     { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5
 $as_echo "$as_me: loading site script $ac_site_file" >&6;}
     sed 's/^/| /' "$ac_site_file" >&5
-    . "$ac_site_file"
+    . "$ac_site_file" \
+      || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "failed to load site script $ac_site_file
+See \`config.log' for more details" "$LINENO" 5; }
   fi
 done
 
@@ -2506,7 +2523,7 @@
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
   { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5
 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}
-  as_fn_error "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
+  as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
 fi
 ## -------------------- ##
 ## Main body of script. ##
@@ -2680,7 +2697,7 @@
 	    g | gt | gtk  )	val=gtk ;;
 	    gtk3  )	val=gtk3 ;;
 	    * )
-as_fn_error "\`--with-x-toolkit=$withval' is invalid;
+as_fn_error $? "\`--with-x-toolkit=$withval' is invalid;
 this option's value should be \`yes', \`no', \`lucid', \`athena', \`motif', \`gtk' or
 \`gtk3'.  \`yes' and \`gtk' are synonyms. \`athena' and \`lucid' are synonyms." "$LINENO" 5
 	    ;;
@@ -2983,7 +3000,7 @@
 	stringfreelist) ac_gc_check_string_free_list=1 ;;
 	xmallocoverrun)	ac_xmalloc_overrun=1 ;;
 	conslist)	ac_gc_check_cons_list=1 ;;
-	*)	as_fn_error "unknown check category $check" "$LINENO" 5 ;;
+	*)	as_fn_error $? "unknown check category $check" "$LINENO" 5 ;;
 	esac
 done
 IFS="$ac_save_IFS"
@@ -3098,16 +3115,22 @@
 
 ac_aux_dir=
 for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
-  for ac_t in install-sh install.sh shtool; do
-    if test -f "$ac_dir/$ac_t"; then
-      ac_aux_dir=$ac_dir
-      ac_install_sh="$ac_aux_dir/$ac_t -c"
-      break 2
-    fi
-  done
+  if test -f "$ac_dir/install-sh"; then
+    ac_aux_dir=$ac_dir
+    ac_install_sh="$ac_aux_dir/install-sh -c"
+    break
+  elif test -f "$ac_dir/install.sh"; then
+    ac_aux_dir=$ac_dir
+    ac_install_sh="$ac_aux_dir/install.sh -c"
+    break
+  elif test -f "$ac_dir/shtool"; then
+    ac_aux_dir=$ac_dir
+    ac_install_sh="$ac_aux_dir/shtool install -c"
+    break
+  fi
 done
 if test -z "$ac_aux_dir"; then
-  as_fn_error "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5
+  as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5
 fi
 
 # These three variables are undocumented and unsupported,
@@ -3121,27 +3144,27 @@
 
 # Make sure we can run config.sub.
 $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
-  as_fn_error "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5
+  as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5
 $as_echo_n "checking build system type... " >&6; }
-if test "${ac_cv_build+set}" = set; then :
+if ${ac_cv_build+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_build_alias=$build_alias
 test "x$ac_build_alias" = x &&
   ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
 test "x$ac_build_alias" = x &&
-  as_fn_error "cannot guess build type; you must specify one" "$LINENO" 5
+  as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5
 ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
-  as_fn_error "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5
+  as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5
 
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5
 $as_echo "$ac_cv_build" >&6; }
 case $ac_cv_build in
 *-*-*) ;;
-*) as_fn_error "invalid value of canonical build" "$LINENO" 5;;
+*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;;
 esac
 build=$ac_cv_build
 ac_save_IFS=$IFS; IFS='-'
@@ -3159,14 +3182,14 @@
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5
 $as_echo_n "checking host system type... " >&6; }
-if test "${ac_cv_host+set}" = set; then :
+if ${ac_cv_host+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   if test "x$host_alias" = x; then
   ac_cv_host=$ac_cv_build
 else
   ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
-    as_fn_error "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5
+    as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5
 fi
 
 fi
@@ -3174,7 +3197,7 @@
 $as_echo "$ac_cv_host" >&6; }
 case $ac_cv_host in
 *-*-*) ;;
-*) as_fn_error "invalid value of canonical host" "$LINENO" 5;;
+*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;;
 esac
 host=$ac_cv_host
 ac_save_IFS=$IFS; IFS='-'
@@ -3468,7 +3491,7 @@
 
 
 if test $unported = yes; then
-  as_fn_error "Emacs hasn't been ported to \`${canonical}' systems.
+  as_fn_error $? "Emacs hasn't been ported to \`${canonical}' systems.
 Check \`etc/MACHINES' for recognized configuration names." "$LINENO" 5
 fi
 
@@ -3492,7 +3515,7 @@
 set dummy ${ac_tool_prefix}gcc; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_CC+set}" = set; then :
+if ${ac_cv_prog_CC+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   if test -n "$CC"; then
@@ -3532,7 +3555,7 @@
 set dummy gcc; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_ac_ct_CC+set}" = set; then :
+if ${ac_cv_prog_ac_ct_CC+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   if test -n "$ac_ct_CC"; then
@@ -3585,7 +3608,7 @@
 set dummy ${ac_tool_prefix}cc; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_CC+set}" = set; then :
+if ${ac_cv_prog_CC+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   if test -n "$CC"; then
@@ -3625,7 +3648,7 @@
 set dummy cc; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_CC+set}" = set; then :
+if ${ac_cv_prog_CC+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   if test -n "$CC"; then
@@ -3684,7 +3707,7 @@
 set dummy $ac_tool_prefix$ac_prog; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_CC+set}" = set; then :
+if ${ac_cv_prog_CC+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   if test -n "$CC"; then
@@ -3728,7 +3751,7 @@
 set dummy $ac_prog; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_ac_ct_CC+set}" = set; then :
+if ${ac_cv_prog_ac_ct_CC+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   if test -n "$ac_ct_CC"; then
@@ -3782,8 +3805,8 @@
 
 test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error "no acceptable C compiler found in \$PATH
-See \`config.log' for more details." "$LINENO" 5; }
+as_fn_error $? "no acceptable C compiler found in \$PATH
+See \`config.log' for more details" "$LINENO" 5; }
 
 # Provide some information about the compiler.
 $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
@@ -3897,9 +3920,8 @@
 
 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-{ as_fn_set_status 77
-as_fn_error "C compiler cannot create executables
-See \`config.log' for more details." "$LINENO" 5; }; }
+as_fn_error 77 "C compiler cannot create executables
+See \`config.log' for more details" "$LINENO" 5; }
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
@@ -3941,8 +3963,8 @@
 else
   { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error "cannot compute suffix of executables: cannot compile and link
-See \`config.log' for more details." "$LINENO" 5; }
+as_fn_error $? "cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details" "$LINENO" 5; }
 fi
 rm -f conftest conftest$ac_cv_exeext
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5
@@ -3999,9 +4021,9 @@
     else
 	{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error "cannot run C compiled programs.
+as_fn_error $? "cannot run C compiled programs.
 If you meant to cross compile, use \`--host'.
-See \`config.log' for more details." "$LINENO" 5; }
+See \`config.log' for more details" "$LINENO" 5; }
     fi
   fi
 fi
@@ -4012,7 +4034,7 @@
 ac_clean_files=$ac_clean_files_save
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5
 $as_echo_n "checking for suffix of object files... " >&6; }
-if test "${ac_cv_objext+set}" = set; then :
+if ${ac_cv_objext+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -4052,8 +4074,8 @@
 
 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error "cannot compute suffix of object files: cannot compile
-See \`config.log' for more details." "$LINENO" 5; }
+as_fn_error $? "cannot compute suffix of object files: cannot compile
+See \`config.log' for more details" "$LINENO" 5; }
 fi
 rm -f conftest.$ac_cv_objext conftest.$ac_ext
 fi
@@ -4063,7 +4085,7 @@
 ac_objext=$OBJEXT
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5
 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
-if test "${ac_cv_c_compiler_gnu+set}" = set; then :
+if ${ac_cv_c_compiler_gnu+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -4100,7 +4122,7 @@
 ac_save_CFLAGS=$CFLAGS
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5
 $as_echo_n "checking whether $CC accepts -g... " >&6; }
-if test "${ac_cv_prog_cc_g+set}" = set; then :
+if ${ac_cv_prog_cc_g+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_save_c_werror_flag=$ac_c_werror_flag
@@ -4178,7 +4200,7 @@
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5
 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
-if test "${ac_cv_prog_cc_c89+set}" = set; then :
+if ${ac_cv_prog_cc_c89+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_cv_prog_cc_c89=no
@@ -4286,7 +4308,7 @@
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using a Sun C compiler" >&5
 $as_echo_n "checking whether we are using a Sun C compiler... " >&6; }
 
-if test "${emacs_cv_sunpro_c+set}" = set; then :
+if ${emacs_cv_sunpro_c+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -4355,7 +4377,7 @@
   CPP=
 fi
 if test -z "$CPP"; then
-  if test "${ac_cv_prog_CPP+set}" = set; then :
+  if ${ac_cv_prog_CPP+:} false; then :
   $as_echo_n "(cached) " >&6
 else
       # Double quotes because CPP needs to be expanded
@@ -4385,7 +4407,7 @@
   # Broken: fails on valid input.
 continue
 fi
-rm -f conftest.err conftest.$ac_ext
+rm -f conftest.err conftest.i conftest.$ac_ext
 
   # OK, works on sane cases.  Now check whether nonexistent headers
   # can be detected and how.
@@ -4401,11 +4423,11 @@
 ac_preproc_ok=:
 break
 fi
-rm -f conftest.err conftest.$ac_ext
+rm -f conftest.err conftest.i conftest.$ac_ext
 
 done
 # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.err conftest.$ac_ext
+rm -f conftest.i conftest.err conftest.$ac_ext
 if $ac_preproc_ok; then :
   break
 fi
@@ -4444,7 +4466,7 @@
   # Broken: fails on valid input.
 continue
 fi
-rm -f conftest.err conftest.$ac_ext
+rm -f conftest.err conftest.i conftest.$ac_ext
 
   # OK, works on sane cases.  Now check whether nonexistent headers
   # can be detected and how.
@@ -4460,18 +4482,18 @@
 ac_preproc_ok=:
 break
 fi
-rm -f conftest.err conftest.$ac_ext
+rm -f conftest.err conftest.i conftest.$ac_ext
 
 done
 # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.err conftest.$ac_ext
+rm -f conftest.i conftest.err conftest.$ac_ext
 if $ac_preproc_ok; then :
 
 else
   { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error "C preprocessor \"$CPP\" fails sanity check
-See \`config.log' for more details." "$LINENO" 5; }
+as_fn_error $? "C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details" "$LINENO" 5; }
 fi
 
 ac_ext=c
@@ -4483,7 +4505,7 @@
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
 $as_echo_n "checking for grep that handles long lines and -e... " >&6; }
-if test "${ac_cv_path_GREP+set}" = set; then :
+if ${ac_cv_path_GREP+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   if test -z "$GREP"; then
@@ -4532,7 +4554,7 @@
   done
 IFS=$as_save_IFS
   if test -z "$ac_cv_path_GREP"; then
-    as_fn_error "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+    as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
   fi
 else
   ac_cv_path_GREP=$GREP
@@ -4546,7 +4568,7 @@
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
 $as_echo_n "checking for egrep... " >&6; }
-if test "${ac_cv_path_EGREP+set}" = set; then :
+if ${ac_cv_path_EGREP+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
@@ -4598,7 +4620,7 @@
   done
 IFS=$as_save_IFS
   if test -z "$ac_cv_path_EGREP"; then
-    as_fn_error "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+    as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
   fi
 else
   ac_cv_path_EGREP=$EGREP
@@ -4613,7 +4635,7 @@
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
 $as_echo_n "checking for ANSI C header files... " >&6; }
-if test "${ac_cv_header_stdc+set}" = set; then :
+if ${ac_cv_header_stdc+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -4730,8 +4752,7 @@
   as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
 ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
 "
-eval as_val=\$$as_ac_Header
-   if test "x$as_val" = x""yes; then :
+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
 _ACEOF
@@ -4743,7 +4764,7 @@
 
 
   ac_fn_c_check_header_mongrel "$LINENO" "minix/config.h" "ac_cv_header_minix_config_h" "$ac_includes_default"
-if test "x$ac_cv_header_minix_config_h" = x""yes; then :
+if test "x$ac_cv_header_minix_config_h" = xyes; then :
   MINIX=yes
 else
   MINIX=
@@ -4765,7 +4786,7 @@
 
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether it is safe to define __EXTENSIONS__" >&5
 $as_echo_n "checking whether it is safe to define __EXTENSIONS__... " >&6; }
-if test "${ac_cv_safe_to_define___extensions__+set}" = set; then :
+if ${ac_cv_safe_to_define___extensions__+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -4945,7 +4966,7 @@
   CPP=
 fi
 if test -z "$CPP"; then
-  if test "${ac_cv_prog_CPP+set}" = set; then :
+  if ${ac_cv_prog_CPP+:} false; then :
   $as_echo_n "(cached) " >&6
 else
       # Double quotes because CPP needs to be expanded
@@ -4975,7 +4996,7 @@
   # Broken: fails on valid input.
 continue
 fi
-rm -f conftest.err conftest.$ac_ext
+rm -f conftest.err conftest.i conftest.$ac_ext
 
   # OK, works on sane cases.  Now check whether nonexistent headers
   # can be detected and how.
@@ -4991,11 +5012,11 @@
 ac_preproc_ok=:
 break
 fi
-rm -f conftest.err conftest.$ac_ext
+rm -f conftest.err conftest.i conftest.$ac_ext
 
 done
 # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.err conftest.$ac_ext
+rm -f conftest.i conftest.err conftest.$ac_ext
 if $ac_preproc_ok; then :
   break
 fi
@@ -5034,7 +5055,7 @@
   # Broken: fails on valid input.
 continue
 fi
-rm -f conftest.err conftest.$ac_ext
+rm -f conftest.err conftest.i conftest.$ac_ext
 
   # OK, works on sane cases.  Now check whether nonexistent headers
   # can be detected and how.
@@ -5050,18 +5071,18 @@
 ac_preproc_ok=:
 break
 fi
-rm -f conftest.err conftest.$ac_ext
+rm -f conftest.err conftest.i conftest.$ac_ext
 
 done
 # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.err conftest.$ac_ext
+rm -f conftest.i conftest.err conftest.$ac_ext
 if $ac_preproc_ok; then :
 
 else
   { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error "C preprocessor \"$CPP\" fails sanity check
-See \`config.log' for more details." "$LINENO" 5; }
+as_fn_error $? "C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details" "$LINENO" 5; }
 fi
 
 ac_ext=c
@@ -5087,7 +5108,7 @@
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5
 $as_echo_n "checking for a BSD-compatible install... " >&6; }
 if test -z "$INSTALL"; then
-if test "${ac_cv_path_install+set}" = set; then :
+if ${ac_cv_path_install+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
@@ -5169,7 +5190,7 @@
 set dummy ${ac_tool_prefix}ranlib; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_RANLIB+set}" = set; then :
+if ${ac_cv_prog_RANLIB+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   if test -n "$RANLIB"; then
@@ -5209,7 +5230,7 @@
 set dummy ranlib; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then :
+if ${ac_cv_prog_ac_ct_RANLIB+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   if test -n "$ac_ct_RANLIB"; then
@@ -5264,7 +5285,7 @@
 ## is running in i386 mode, we can help them out.
 if test "$machine" = "amdx86-64"; then
   ac_fn_c_check_decl "$LINENO" "i386" "ac_cv_have_decl_i386" "$ac_includes_default"
-if test "x$ac_cv_have_decl_i386" = x""yes; then :
+if test "x$ac_cv_have_decl_i386" = xyes; then :
 
 fi
 
@@ -5279,7 +5300,7 @@
 set dummy install-info; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_INSTALL_INFO+set}" = set; then :
+if ${ac_cv_path_INSTALL_INFO+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   case $INSTALL_INFO in
@@ -5319,7 +5340,7 @@
 set dummy install-info; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_INSTALL_INFO+set}" = set; then :
+if ${ac_cv_path_INSTALL_INFO+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   case $INSTALL_INFO in
@@ -5359,7 +5380,7 @@
 set dummy install-info; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_INSTALL_INFO+set}" = set; then :
+if ${ac_cv_path_INSTALL_INFO+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   case $INSTALL_INFO in
@@ -5400,7 +5421,7 @@
 set dummy gzip; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_GZIP_PROG+set}" = set; then :
+if ${ac_cv_path_GZIP_PROG+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   case $GZIP_PROG in
@@ -5443,7 +5464,7 @@
 set dummy makeinfo; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_MAKEINFO+set}" = set; then :
+if ${ac_cv_path_MAKEINFO+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   case $MAKEINFO in
@@ -5498,7 +5519,7 @@
   if test "x${with_makeinfo}" = "xno"; then
     MAKEINFO=off
   elif test ! -e $srcdir/info/emacs; then
-    as_fn_error "You do not seem to have makeinfo >= 4.6, and your
+    as_fn_error $? "You do not seem to have makeinfo >= 4.6, and your
 source tree does not seem to have pre-built manuals in the \`info' directory.
 Either install a suitable version of makeinfo, or re-run configure
 with the \`--without-makeinfo' option to build without the manuals. " "$LINENO" 5
@@ -5506,19 +5527,17 @@
 fi
 
 
-if test x$GCC = xyes && test "x$GCC_LINK_TEST_OPTIONS" != x
-then
-  ac_link="$ac_link $GCC_LINK_TEST_OPTIONS"
-fi
-
-if test x$GCC = x && test "x$NON_GCC_LINK_TEST_OPTIONS" != x
-then
-  ac_link="$ac_link $NON_GCC_LINK_TEST_OPTIONS"
+if test x$GCC = xyes; then
+  test "x$GCC_LINK_TEST_OPTIONS" != x && \
+    ac_link="$ac_link $GCC_LINK_TEST_OPTIONS"
+else
+  test "x$NON_GCC_LINK_TEST_OPTIONS" != x && \
+    ac_link="$ac_link $NON_GCC_LINK_TEST_OPTIONS"
 fi
 
 
 late_LDFLAGS=$LDFLAGS
-if test "$GCC" = yes; then
+if test x$GCC = xyes; then
   LDFLAGS="$LDFLAGS -Wl,-znocombreloc"
 else
   LDFLAGS="$LDFLAGS -znocombreloc"
@@ -5528,7 +5547,14 @@
 $as_echo_n "checking for -znocombreloc... " >&6; }
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
-main(){return 0;}
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
@@ -5639,7 +5665,7 @@
 C_SWITCH_MACHINE=
 if test "$machine" = "alpha"; then
   ac_fn_c_check_decl "$LINENO" "__ELF__" "ac_cv_have_decl___ELF__" "$ac_includes_default"
-if test "x$ac_cv_have_decl___ELF__" = x""yes; then :
+if test "x$ac_cv_have_decl___ELF__" = xyes; then :
 
 fi
 
@@ -5652,7 +5678,7 @@
     if test "x$GCC" = "xyes"; then
       C_SWITCH_MACHINE="-fno-common"
     else
-      as_fn_error "What gives?  Fix me if DEC Unix supports ELF now." "$LINENO" 5
+      as_fn_error $? "What gives?  Fix me if DEC Unix supports ELF now." "$LINENO" 5
     fi
   else
     UNEXEC_OBJ=unexalpha.o
@@ -5709,7 +5735,7 @@
 
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for special C compiler options needed for large files" >&5
 $as_echo_n "checking for special C compiler options needed for large files... " >&6; }
-if test "${ac_cv_sys_largefile_CC+set}" = set; then :
+if ${ac_cv_sys_largefile_CC+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_cv_sys_largefile_CC=no
@@ -5760,7 +5786,7 @@
 
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _FILE_OFFSET_BITS value needed for large files" >&5
 $as_echo_n "checking for _FILE_OFFSET_BITS value needed for large files... " >&6; }
-if test "${ac_cv_sys_file_offset_bits+set}" = set; then :
+if ${ac_cv_sys_file_offset_bits+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   while :; do
@@ -5829,7 +5855,7 @@
   if test $ac_cv_sys_file_offset_bits = unknown; then
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _LARGE_FILES value needed for large files" >&5
 $as_echo_n "checking for _LARGE_FILES value needed for large files... " >&6; }
-if test "${ac_cv_sys_large_files+set}" = set; then :
+if ${ac_cv_sys_large_files+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   while :; do
@@ -5930,7 +5956,7 @@
   ## Some platforms don't use any of these files, so it is not
   ## appropriate to put this test outside the if block.
   test -e $CRT_DIR/crtn.o || test -e $CRT_DIR/crt0.o || \
-    as_fn_error "crt*.o not found in specified location." "$LINENO" 5
+    as_fn_error $? "crt*.o not found in specified location." "$LINENO" 5
 
 fi
 
@@ -5985,8 +6011,7 @@
 do :
   as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
 ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
-eval as_val=\$$as_ac_Header
-   if test "x$as_val" = x""yes; then :
+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
 _ACEOF
@@ -5998,7 +6023,7 @@
   # Emulation library used on NetBSD.
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _oss_ioctl in -lossaudio" >&5
 $as_echo_n "checking for _oss_ioctl in -lossaudio... " >&6; }
-if test "${ac_cv_lib_ossaudio__oss_ioctl+set}" = set; then :
+if ${ac_cv_lib_ossaudio__oss_ioctl+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -6032,7 +6057,7 @@
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ossaudio__oss_ioctl" >&5
 $as_echo "$ac_cv_lib_ossaudio__oss_ioctl" >&6; }
-if test "x$ac_cv_lib_ossaudio__oss_ioctl" = x""yes; then :
+if test "x$ac_cv_lib_ossaudio__oss_ioctl" = xyes; then :
   LIBSOUND=-lossaudio
 else
   LIBSOUND=
@@ -6049,7 +6074,7 @@
 set dummy pkg-config; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_PKG_CONFIG+set}" = set; then :
+if ${ac_cv_path_PKG_CONFIG+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   case $PKG_CONFIG in
@@ -6177,7 +6202,7 @@
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
       if test "$emacs_alsa_subdir" != yes; then
-        as_fn_error "pkg-config found alsa, but it does not compile.  See config.log for error messages." "$LINENO" 5
+        as_fn_error $? "pkg-config found alsa, but it does not compile.  See config.log for error messages." "$LINENO" 5
       fi
       ALSA_CFLAGS="$ALSA_CFLAGS -DALSA_SUBDIR_INCLUDE"
     fi
@@ -6212,8 +6237,7 @@
 do :
   as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
 ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
-eval as_val=\$$as_ac_Header
-   if test "x$as_val" = x""yes; then :
+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
 _ACEOF
@@ -6254,7 +6278,7 @@
 for ac_header in term.h
 do :
   ac_fn_c_check_header_preproc "$LINENO" "term.h" "ac_cv_header_term_h"
-if test "x$ac_cv_header_term_h" = x""yes; then :
+if test "x$ac_cv_header_term_h" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_TERM_H 1
 _ACEOF
@@ -6265,7 +6289,7 @@
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
 $as_echo_n "checking for ANSI C header files... " >&6; }
-if test "${ac_cv_header_stdc+set}" = set; then :
+if ${ac_cv_header_stdc+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -6377,7 +6401,7 @@
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5
 $as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; }
-if test "${ac_cv_header_time+set}" = set; then :
+if ${ac_cv_header_time+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -6411,7 +6435,7 @@
 fi
 
 ac_fn_c_check_decl "$LINENO" "sys_siglist" "ac_cv_have_decl_sys_siglist" "$ac_includes_default"
-if test "x$ac_cv_have_decl_sys_siglist" = x""yes; then :
+if test "x$ac_cv_have_decl_sys_siglist" = xyes; then :
   ac_have_decl=1
 else
   ac_have_decl=0
@@ -6424,7 +6448,7 @@
 if test $ac_cv_have_decl_sys_siglist != yes; then
   # For Tru64, at least:
   ac_fn_c_check_decl "$LINENO" "__sys_siglist" "ac_cv_have_decl___sys_siglist" "$ac_includes_default"
-if test "x$ac_cv_have_decl___sys_siglist" = x""yes; then :
+if test "x$ac_cv_have_decl___sys_siglist" = xyes; then :
   ac_have_decl=1
 else
   ac_have_decl=0
@@ -6442,7 +6466,7 @@
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sys/wait.h that is POSIX.1 compatible" >&5
 $as_echo_n "checking for sys/wait.h that is POSIX.1 compatible... " >&6; }
-if test "${ac_cv_header_sys_wait_h+set}" = set; then :
+if ${ac_cv_header_sys_wait_h+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -6484,7 +6508,7 @@
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct utimbuf" >&5
 $as_echo_n "checking for struct utimbuf... " >&6; }
-if test "${emacs_cv_struct_utimbuf+set}" = set; then :
+if ${emacs_cv_struct_utimbuf+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -6527,7 +6551,7 @@
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking return type of signal handlers" >&5
 $as_echo_n "checking return type of signal handlers... " >&6; }
-if test "${ac_cv_type_signal+set}" = set; then :
+if ${ac_cv_type_signal+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -6561,7 +6585,7 @@
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for speed_t" >&5
 $as_echo_n "checking for speed_t... " >&6; }
-if test "${emacs_cv_speed_t+set}" = set; then :
+if ${emacs_cv_speed_t+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -6592,7 +6616,7 @@
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct timeval" >&5
 $as_echo_n "checking for struct timeval... " >&6; }
-if test "${emacs_cv_struct_timeval+set}" = set; then :
+if ${emacs_cv_struct_timeval+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -6633,7 +6657,7 @@
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct exception" >&5
 $as_echo_n "checking for struct exception... " >&6; }
-if test "${emacs_cv_struct_exception+set}" = set; then :
+if ${emacs_cv_struct_exception+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -6666,7 +6690,7 @@
 for ac_header in sys/socket.h
 do :
   ac_fn_c_check_header_mongrel "$LINENO" "sys/socket.h" "ac_cv_header_sys_socket_h" "$ac_includes_default"
-if test "x$ac_cv_header_sys_socket_h" = x""yes; then :
+if test "x$ac_cv_header_sys_socket_h" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_SYS_SOCKET_H 1
 _ACEOF
@@ -6682,7 +6706,7 @@
 #include <sys/socket.h>
 #endif
 "
-if test "x$ac_cv_header_net_if_h" = x""yes; then :
+if test "x$ac_cv_header_net_if_h" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_NET_IF_H 1
 _ACEOF
@@ -6694,7 +6718,7 @@
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether struct tm is in sys/time.h or time.h" >&5
 $as_echo_n "checking whether struct tm is in sys/time.h or time.h... " >&6; }
-if test "${ac_cv_struct_tm+set}" = set; then :
+if ${ac_cv_struct_tm+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -6731,7 +6755,7 @@
 #include <$ac_cv_struct_tm>
 
 "
-if test "x$ac_cv_member_struct_tm_tm_zone" = x""yes; then :
+if test "x$ac_cv_member_struct_tm_tm_zone" = xyes; then :
 
 cat >>confdefs.h <<_ACEOF
 #define HAVE_STRUCT_TM_TM_ZONE 1
@@ -6747,7 +6771,7 @@
 else
   ac_fn_c_check_decl "$LINENO" "tzname" "ac_cv_have_decl_tzname" "#include <time.h>
 "
-if test "x$ac_cv_have_decl_tzname" = x""yes; then :
+if test "x$ac_cv_have_decl_tzname" = xyes; then :
   ac_have_decl=1
 else
   ac_have_decl=0
@@ -6759,7 +6783,7 @@
 
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for tzname" >&5
 $as_echo_n "checking for tzname... " >&6; }
-if test "${ac_cv_var_tzname+set}" = set; then :
+if ${ac_cv_var_tzname+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -6796,7 +6820,7 @@
 
 ac_fn_c_check_member "$LINENO" "struct tm" "tm_gmtoff" "ac_cv_member_struct_tm_tm_gmtoff" "#include <time.h>
 "
-if test "x$ac_cv_member_struct_tm_tm_gmtoff" = x""yes; then :
+if test "x$ac_cv_member_struct_tm_tm_gmtoff" = xyes; then :
 
 $as_echo "#define HAVE_TM_GMTOFF 1" >>confdefs.h
 
@@ -6810,7 +6834,7 @@
 #include <net/if.h>
 #endif
 "
-if test "x$ac_cv_member_struct_ifreq_ifr_flags" = x""yes; then :
+if test "x$ac_cv_member_struct_ifreq_ifr_flags" = xyes; then :
 
 cat >>confdefs.h <<_ACEOF
 #define HAVE_STRUCT_IFREQ_IFR_FLAGS 1
@@ -6826,7 +6850,7 @@
 #include <net/if.h>
 #endif
 "
-if test "x$ac_cv_member_struct_ifreq_ifr_hwaddr" = x""yes; then :
+if test "x$ac_cv_member_struct_ifreq_ifr_hwaddr" = xyes; then :
 
 cat >>confdefs.h <<_ACEOF
 #define HAVE_STRUCT_IFREQ_IFR_HWADDR 1
@@ -6842,7 +6866,7 @@
 #include <net/if.h>
 #endif
 "
-if test "x$ac_cv_member_struct_ifreq_ifr_netmask" = x""yes; then :
+if test "x$ac_cv_member_struct_ifreq_ifr_netmask" = xyes; then :
 
 cat >>confdefs.h <<_ACEOF
 #define HAVE_STRUCT_IFREQ_IFR_NETMASK 1
@@ -6858,7 +6882,7 @@
 #include <net/if.h>
 #endif
 "
-if test "x$ac_cv_member_struct_ifreq_ifr_broadaddr" = x""yes; then :
+if test "x$ac_cv_member_struct_ifreq_ifr_broadaddr" = xyes; then :
 
 cat >>confdefs.h <<_ACEOF
 #define HAVE_STRUCT_IFREQ_IFR_BROADADDR 1
@@ -6874,7 +6898,7 @@
 #include <net/if.h>
 #endif
 "
-if test "x$ac_cv_member_struct_ifreq_ifr_addr" = x""yes; then :
+if test "x$ac_cv_member_struct_ifreq_ifr_addr" = xyes; then :
 
 cat >>confdefs.h <<_ACEOF
 #define HAVE_STRUCT_IFREQ_IFR_ADDR 1
@@ -6903,7 +6927,7 @@
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working volatile" >&5
 $as_echo_n "checking for working volatile... " >&6; }
-if test "${ac_cv_c_volatile+set}" = set; then :
+if ${ac_cv_c_volatile+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -6937,7 +6961,7 @@
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5
 $as_echo_n "checking for an ANSI C-conforming const... " >&6; }
-if test "${ac_cv_c_const+set}" = set; then :
+if ${ac_cv_c_const+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -7017,7 +7041,7 @@
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for void * support" >&5
 $as_echo_n "checking for void * support... " >&6; }
-if test "${emacs_cv_void_star+set}" = set; then :
+if ${emacs_cv_void_star+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -7050,7 +7074,7 @@
 
  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5
 $as_echo_n "checking whether byte ordering is bigendian... " >&6; }
-if test "${ac_cv_c_bigendian+set}" = set; then :
+if ${ac_cv_c_bigendian+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_cv_c_bigendian=unknown
@@ -7268,7 +7292,7 @@
 
      ;; #(
    *)
-     as_fn_error "unknown endianness
+     as_fn_error $? "unknown endianness
  presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;;
  esac
 
@@ -7277,7 +7301,7 @@
 $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; }
 set x ${MAKE-make}
 ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'`
-if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then :
+if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat >conftest.make <<\_ACEOF
@@ -7285,7 +7309,7 @@
 all:
 	@echo '@@@%%%=$(MAKE)=@@@%%%'
 _ACEOF
-# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
+# GNU make sometimes prints "make[1]: Entering ...", which would confuse us.
 case `${MAKE-make} -f conftest.make 2>/dev/null` in
   *@@@%%%=?*=@@@%%%*)
     eval ac_cv_prog_make_${ac_make}_set=yes;;
@@ -7365,7 +7389,7 @@
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for long file names" >&5
 $as_echo_n "checking for long file names... " >&6; }
-if test "${ac_cv_sys_long_file_names+set}" = set; then :
+if ${ac_cv_sys_long_file_names+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_cv_sys_long_file_names=yes
@@ -7421,8 +7445,8 @@
   have_x=disabled
 else
   case $x_includes,$x_libraries in #(
-    *\'*) as_fn_error "cannot use X directory names containing '" "$LINENO" 5;; #(
-    *,NONE | NONE,*) if test "${ac_cv_have_x+set}" = set; then :
+    *\'*) as_fn_error $? "cannot use X directory names containing '" "$LINENO" 5;; #(
+    *,NONE | NONE,*) if ${ac_cv_have_x+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   # One or both of the vars are not set, and there is no cached value.
@@ -7439,7 +7463,7 @@
 	@echo libdir='${LIBDIR}'
 _ACEOF
   if (export CC; ${XMKMF-xmkmf}) >/dev/null 2>/dev/null && test -f Makefile; then
-    # GNU make sometimes prints "make[1]: Entering...", which would confuse us.
+    # GNU make sometimes prints "make[1]: Entering ...", which would confuse us.
     for ac_var in incroot usrlibdir libdir; do
       eval "ac_im_$ac_var=\`\${MAKE-make} $ac_var 2>/dev/null | sed -n 's/^$ac_var=//p'\`"
     done
@@ -7525,7 +7549,7 @@
   fi
 done
 fi
-rm -f conftest.err conftest.$ac_ext
+rm -f conftest.err conftest.i conftest.$ac_ext
 fi # $ac_x_includes = no
 
 if test "$ac_x_libraries" = no; then
@@ -7679,15 +7703,15 @@
 if test "${with_ns}" != no; then
   if test "${opsys}" = darwin; then
      NS_IMPL_COCOA=yes
-     ns_appdir=`pwd`/nextstep/Emacs.app/
-     ns_appbindir=${ns_appdir}Contents/MacOS/
-     ns_appresdir=${ns_appdir}Contents/Resources
+     ns_appdir=`pwd`/nextstep/Emacs.app
+     ns_appbindir=${ns_appdir}/Contents/MacOS/
+     ns_appresdir=${ns_appdir}/Contents/Resources
      ns_appsrc=${srcdir}/nextstep/Cocoa/Emacs.base
   elif test -f $GNUSTEP_CONFIG_FILE; then
      NS_IMPL_GNUSTEP=yes
-     ns_appdir=`pwd`/nextstep/Emacs.app/
+     ns_appdir=`pwd`/nextstep/Emacs.app
      ns_appbindir=${ns_appdir}
-     ns_appresdir=${ns_appdir}Resources
+     ns_appresdir=${ns_appdir}/Resources
      ns_appsrc=${srcdir}/nextstep/GNUstep/Emacs.base
           GNUSTEP_SYSTEM_HEADERS="$(. $GNUSTEP_CONFIG_FILE; echo $GNUSTEP_SYSTEM_HEADERS)"
      GNUSTEP_SYSTEM_LIBRARIES="$(. $GNUSTEP_CONFIG_FILE; echo $GNUSTEP_SYSTEM_LIBRARIES)"
@@ -7705,10 +7729,10 @@
      TEMACS_LDFLAGS2=
   fi
   ac_fn_c_check_header_mongrel "$LINENO" "AppKit/AppKit.h" "ac_cv_header_AppKit_AppKit_h" "$ac_includes_default"
-if test "x$ac_cv_header_AppKit_AppKit_h" = x""yes; then :
+if test "x$ac_cv_header_AppKit_AppKit_h" = xyes; then :
   HAVE_NS=yes
 else
-  as_fn_error "\`--with-ns' was specified, but the include
+  as_fn_error $? "\`--with-ns' was specified, but the include
   files are missing or cannot be compiled." "$LINENO" 5
 fi
 
@@ -7751,7 +7775,7 @@
   fi
   ns_frag=$srcdir/src/ns.mk
   NS_OBJ="nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o fontset.o fringe.o image.o"
-  NS_SUPPORT="\${lispsource}emacs-lisp/easymenu.elc \${lispsource}term/ns-win.elc"
+  NS_SUPPORT="\${lispsource}/emacs-lisp/easymenu.elc \${lispsource}/term/ns-win.elc"
 fi
 CFLAGS="$tmp_CFLAGS"
 CPPFLAGS="$tmp_CPPFLAGS"
@@ -7787,7 +7811,7 @@
 set dummy X; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_HAVE_XSERVER+set}" = set; then :
+if ${ac_cv_prog_HAVE_XSERVER+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   if test -n "$HAVE_XSERVER"; then
@@ -7824,7 +7848,7 @@
    if test "$HAVE_XSERVER" = true ||
       test -n "$DISPLAY" ||
       test "`echo /usr/lib/libX11.*`" != "/usr/lib/libX11.*"; then
-        as_fn_error "You seem to be running X, but no X development libraries
+        as_fn_error $? "You seem to be running X, but no X development libraries
 were found.  You should install the relevant development files for X
 and for the toolkit you want, such as Gtk+, Lesstif or Motif.  Also make
 sure you have development files for image handling, i.e.
@@ -7846,14 +7870,14 @@
 GNU_MALLOC=yes
 doug_lea_malloc=yes
 ac_fn_c_check_func "$LINENO" "malloc_get_state" "ac_cv_func_malloc_get_state"
-if test "x$ac_cv_func_malloc_get_state" = x""yes; then :
+if test "x$ac_cv_func_malloc_get_state" = xyes; then :
 
 else
   doug_lea_malloc=no
 fi
 
 ac_fn_c_check_func "$LINENO" "malloc_set_state" "ac_cv_func_malloc_set_state"
-if test "x$ac_cv_func_malloc_set_state" = x""yes; then :
+if test "x$ac_cv_func_malloc_set_state" = xyes; then :
 
 else
   doug_lea_malloc=no
@@ -7861,7 +7885,7 @@
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether __after_morecore_hook exists" >&5
 $as_echo_n "checking whether __after_morecore_hook exists... " >&6; }
-if test "${emacs_cv_var___after_morecore_hook+set}" = set; then :
+if ${emacs_cv_var___after_morecore_hook+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -7947,8 +7971,7 @@
   as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
 ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
 "
-eval as_val=\$$as_ac_Header
-   if test "x$as_val" = x""yes; then :
+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
 _ACEOF
@@ -7967,7 +7990,7 @@
 for ac_func in getpagesize
 do :
   ac_fn_c_check_func "$LINENO" "getpagesize" "ac_cv_func_getpagesize"
-if test "x$ac_cv_func_getpagesize" = x""yes; then :
+if test "x$ac_cv_func_getpagesize" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_GETPAGESIZE 1
 _ACEOF
@@ -7977,7 +8000,7 @@
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working mmap" >&5
 $as_echo_n "checking for working mmap... " >&6; }
-if test "${ac_cv_func_mmap_fixed_mapped+set}" = set; then :
+if ${ac_cv_func_mmap_fixed_mapped+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   if test "$cross_compiling" = yes; then :
@@ -8054,6 +8077,7 @@
 main ()
 {
   char *data, *data2, *data3;
+  const char *cdata2;
   int i, pagesize;
   int fd, fd2;
 
@@ -8078,10 +8102,10 @@
   fd2 = open ("conftest.txt", O_RDWR | O_CREAT | O_TRUNC, 0600);
   if (fd2 < 0)
     return 4;
-  data2 = "";
-  if (write (fd2, data2, 1) != 1)
+  cdata2 = "";
+  if (write (fd2, cdata2, 1) != 1)
     return 5;
-  data2 = mmap (0, pagesize, PROT_READ | PROT_WRITE, MAP_SHARED, fd2, 0L);
+  data2 = (char *) mmap (0, pagesize, PROT_READ | PROT_WRITE, MAP_SHARED, fd2, 0L);
   if (data2 == MAP_FAILED)
     return 6;
   for (i = 0; i < pagesize; ++i)
@@ -8151,7 +8175,7 @@
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dnet_ntoa in -ldnet" >&5
 $as_echo_n "checking for dnet_ntoa in -ldnet... " >&6; }
-if test "${ac_cv_lib_dnet_dnet_ntoa+set}" = set; then :
+if ${ac_cv_lib_dnet_dnet_ntoa+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -8185,7 +8209,7 @@
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dnet_dnet_ntoa" >&5
 $as_echo "$ac_cv_lib_dnet_dnet_ntoa" >&6; }
-if test "x$ac_cv_lib_dnet_dnet_ntoa" = x""yes; then :
+if test "x$ac_cv_lib_dnet_dnet_ntoa" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_LIBDNET 1
 _ACEOF
@@ -8197,7 +8221,7 @@
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lXbsd" >&5
 $as_echo_n "checking for main in -lXbsd... " >&6; }
-if test "${ac_cv_lib_Xbsd_main+set}" = set; then :
+if ${ac_cv_lib_Xbsd_main+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -8225,14 +8249,14 @@
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_Xbsd_main" >&5
 $as_echo "$ac_cv_lib_Xbsd_main" >&6; }
-if test "x$ac_cv_lib_Xbsd_main" = x""yes; then :
+if test "x$ac_cv_lib_Xbsd_main" = xyes; then :
   LD_SWITCH_X_SITE="$LD_SWITCH_X_SITE -lXbsd"
 fi
 
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for cma_open in -lpthreads" >&5
 $as_echo_n "checking for cma_open in -lpthreads... " >&6; }
-if test "${ac_cv_lib_pthreads_cma_open+set}" = set; then :
+if ${ac_cv_lib_pthreads_cma_open+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -8266,7 +8290,7 @@
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthreads_cma_open" >&5
 $as_echo "$ac_cv_lib_pthreads_cma_open" >&6; }
-if test "x$ac_cv_lib_pthreads_cma_open" = x""yes; then :
+if test "x$ac_cv_lib_pthreads_cma_open" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_LIBPTHREADS 1
 _ACEOF
@@ -8293,7 +8317,7 @@
 aix*)
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -bbigtoc option" >&5
 $as_echo_n "checking for -bbigtoc option... " >&6; }
-if test "${gdb_cv_bigtoc+set}" = set; then :
+if ${gdb_cv_bigtoc+:} false; then :
   $as_echo_n "(cached) " >&6
 else
 
@@ -8454,8 +8478,7 @@
 do :
   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-eval as_val=\$$as_ac_var
-   if test "x$as_val" = x""yes; then :
+if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
 _ACEOF
@@ -8468,7 +8491,7 @@
 if test "${window_system}" = "x11"; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking X11 version 6" >&5
 $as_echo_n "checking X11 version 6... " >&6; }
-  if test "${emacs_cv_x11_version_6+set}" = set; then :
+  if ${emacs_cv_x11_version_6+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -8533,7 +8556,7 @@
 set dummy pkg-config; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_PKG_CONFIG+set}" = set; then :
+if ${ac_cv_path_PKG_CONFIG+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   case $PKG_CONFIG in
@@ -8644,7 +8667,7 @@
 set dummy pkg-config; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_PKG_CONFIG+set}" = set; then :
+if ${ac_cv_path_PKG_CONFIG+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   case $PKG_CONFIG in
@@ -8743,7 +8766,7 @@
       for ac_func in MagickExportImagePixels
 do :
   ac_fn_c_check_func "$LINENO" "MagickExportImagePixels" "ac_cv_func_MagickExportImagePixels"
-if test "x$ac_cv_func_MagickExportImagePixels" = x""yes; then :
+if test "x$ac_cv_func_MagickExportImagePixels" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_MAGICKEXPORTIMAGEPIXELS 1
 _ACEOF
@@ -8769,7 +8792,7 @@
 set dummy pkg-config; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_PKG_CONFIG+set}" = set; then :
+if ${ac_cv_path_PKG_CONFIG+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   case $PKG_CONFIG in
@@ -8857,7 +8880,7 @@
   fi
 
   if test "$pkg_check_gtk" = "no" && test "$USE_X_TOOLKIT" != "maybe"; then
-     as_fn_error "$GTK_PKG_ERRORS" "$LINENO" 5
+     as_fn_error $? "$GTK_PKG_ERRORS" "$LINENO" 5
   fi
 fi
 
@@ -8875,7 +8898,7 @@
 set dummy pkg-config; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_PKG_CONFIG+set}" = set; then :
+if ${ac_cv_path_PKG_CONFIG+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   case $PKG_CONFIG in
@@ -8963,7 +8986,7 @@
   fi
 
   if test "$pkg_check_gtk" = "no" && test "$USE_X_TOOLKIT" != "maybe"; then
-     as_fn_error "$GTK_PKG_ERRORS" "$LINENO" 5
+     as_fn_error $? "$GTK_PKG_ERRORS" "$LINENO" 5
   fi
 fi
 fi
@@ -8980,7 +9003,7 @@
   for ac_func in gtk_main
 do :
   ac_fn_c_check_func "$LINENO" "gtk_main" "ac_cv_func_gtk_main"
-if test "x$ac_cv_func_gtk_main" = x""yes; then :
+if test "x$ac_cv_func_gtk_main" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_GTK_MAIN 1
 _ACEOF
@@ -8990,7 +9013,7 @@
 
   if test "${GTK_COMPILES}" != "yes"; then
     if test "$USE_X_TOOLKIT" != "maybe"; then
-      as_fn_error "Gtk+ wanted, but it does not compile, see config.log.  Maybe some x11-devel files missing?" "$LINENO" 5;
+      as_fn_error $? "Gtk+ wanted, but it does not compile, see config.log.  Maybe some x11-devel files missing?" "$LINENO" 5;
     fi
   else
     HAVE_GTK=yes
@@ -9028,7 +9051,7 @@
   ac_fn_c_check_decl "$LINENO" "GTK_TYPE_FILE_SELECTION" "ac_cv_have_decl_GTK_TYPE_FILE_SELECTION" "$ac_includes_default
 #include <gtk/gtk.h>
 "
-if test "x$ac_cv_have_decl_GTK_TYPE_FILE_SELECTION" = x""yes; then :
+if test "x$ac_cv_have_decl_GTK_TYPE_FILE_SELECTION" = xyes; then :
   HAVE_GTK_FILE_SELECTION=yes
 else
   HAVE_GTK_FILE_SELECTION=no
@@ -9038,7 +9061,7 @@
     for ac_func in gtk_file_selection_new
 do :
   ac_fn_c_check_func "$LINENO" "gtk_file_selection_new" "ac_cv_func_gtk_file_selection_new"
-if test "x$ac_cv_func_gtk_file_selection_new" = x""yes; then :
+if test "x$ac_cv_func_gtk_file_selection_new" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_GTK_FILE_SELECTION_NEW 1
 _ACEOF
@@ -9052,7 +9075,7 @@
     for ac_header in pthread.h
 do :
   ac_fn_c_check_header_mongrel "$LINENO" "pthread.h" "ac_cv_header_pthread_h" "$ac_includes_default"
-if test "x$ac_cv_header_pthread_h" = x""yes; then :
+if test "x$ac_cv_header_pthread_h" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_PTHREAD_H 1
 _ACEOF
@@ -9064,7 +9087,7 @@
     if test "$ac_cv_header_pthread_h"; then
       { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_self in -lpthread" >&5
 $as_echo_n "checking for pthread_self in -lpthread... " >&6; }
-if test "${ac_cv_lib_pthread_pthread_self+set}" = set; then :
+if ${ac_cv_lib_pthread_pthread_self+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -9098,7 +9121,7 @@
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_pthread_self" >&5
 $as_echo "$ac_cv_lib_pthread_pthread_self" >&6; }
-if test "x$ac_cv_lib_pthread_pthread_self" = x""yes; then :
+if test "x$ac_cv_lib_pthread_pthread_self" = xyes; then :
   HAVE_GTK_AND_PTHREAD=yes
 fi
 
@@ -9120,8 +9143,7 @@
 do :
   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-eval as_val=\$$as_ac_var
-   if test "x$as_val" = x""yes; then :
+if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
 _ACEOF
@@ -9142,7 +9164,7 @@
 set dummy pkg-config; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_PKG_CONFIG+set}" = set; then :
+if ${ac_cv_path_PKG_CONFIG+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   case $PKG_CONFIG in
@@ -9237,7 +9259,7 @@
      for ac_func in dbus_watch_get_unix_fd
 do :
   ac_fn_c_check_func "$LINENO" "dbus_watch_get_unix_fd" "ac_cv_func_dbus_watch_get_unix_fd"
-if test "x$ac_cv_func_dbus_watch_get_unix_fd" = x""yes; then :
+if test "x$ac_cv_func_dbus_watch_get_unix_fd" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_DBUS_WATCH_GET_UNIX_FD 1
 _ACEOF
@@ -9259,7 +9281,7 @@
 set dummy pkg-config; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_PKG_CONFIG+set}" = set; then :
+if ${ac_cv_path_PKG_CONFIG+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   case $PKG_CONFIG in
@@ -9358,7 +9380,7 @@
 if test "${with_selinux}" = "yes"; then
    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for lgetfilecon in -lselinux" >&5
 $as_echo_n "checking for lgetfilecon in -lselinux... " >&6; }
-if test "${ac_cv_lib_selinux_lgetfilecon+set}" = set; then :
+if ${ac_cv_lib_selinux_lgetfilecon+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -9392,7 +9414,7 @@
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_selinux_lgetfilecon" >&5
 $as_echo "$ac_cv_lib_selinux_lgetfilecon" >&6; }
-if test "x$ac_cv_lib_selinux_lgetfilecon" = x""yes; then :
+if test "x$ac_cv_lib_selinux_lgetfilecon" = xyes; then :
   HAVE_LIBSELINUX=yes
 else
   HAVE_LIBSELINUX=no
@@ -9416,7 +9438,7 @@
 set dummy pkg-config; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_PKG_CONFIG+set}" = set; then :
+if ${ac_cv_path_PKG_CONFIG+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   case $PKG_CONFIG in
@@ -9518,7 +9540,7 @@
   if test "$with_xaw3d" != no; then
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for xaw3d" >&5
 $as_echo_n "checking for xaw3d... " >&6; }
-    if test "${emacs_cv_xaw3d+set}" = set; then :
+    if ${emacs_cv_xaw3d+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -9560,7 +9582,7 @@
 $as_echo "no" >&6; }
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libXaw" >&5
 $as_echo_n "checking for libXaw... " >&6; }
-    if test "${emacs_cv_xaw+set}" = set; then :
+    if ${emacs_cv_xaw+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -9591,7 +9613,7 @@
       USE_X_TOOLKIT=LUCID
       LUCID_LIBW=-lXaw
     elif test x"${USE_X_TOOLKIT}" = xLUCID; then
-      as_fn_error "Lucid toolkit requires X11/Xaw include files" "$LINENO" 5
+      as_fn_error $? "Lucid toolkit requires X11/Xaw include files" "$LINENO" 5
     else
       { $as_echo "$as_me:${as_lineno-$LINENO}: result: no; do not use toolkit by default" >&5
 $as_echo "no; do not use toolkit by default" >&6; }
@@ -9606,7 +9628,7 @@
 if test "${USE_X_TOOLKIT}" != "none"; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking X11 toolkit version" >&5
 $as_echo_n "checking X11 toolkit version... " >&6; }
-  if test "${emacs_cv_x11_toolkit_version_6+set}" = set; then :
+  if ${emacs_cv_x11_toolkit_version_6+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -9657,7 +9679,7 @@
   fi
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for XmuConvertStandardSelection in -lXmu" >&5
 $as_echo_n "checking for XmuConvertStandardSelection in -lXmu... " >&6; }
-if test "${ac_cv_lib_Xmu_XmuConvertStandardSelection+set}" = set; then :
+if ${ac_cv_lib_Xmu_XmuConvertStandardSelection+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -9691,7 +9713,7 @@
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_Xmu_XmuConvertStandardSelection" >&5
 $as_echo "$ac_cv_lib_Xmu_XmuConvertStandardSelection" >&6; }
-if test "x$ac_cv_lib_Xmu_XmuConvertStandardSelection" = x""yes; then :
+if test "x$ac_cv_lib_Xmu_XmuConvertStandardSelection" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_LIBXMU 1
 _ACEOF
@@ -9718,7 +9740,7 @@
   if test "${USE_X_TOOLKIT}" != "none"; then
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for XShapeQueryExtension in -lXext" >&5
 $as_echo_n "checking for XShapeQueryExtension in -lXext... " >&6; }
-if test "${ac_cv_lib_Xext_XShapeQueryExtension+set}" = set; then :
+if ${ac_cv_lib_Xext_XShapeQueryExtension+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -9752,7 +9774,7 @@
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_Xext_XShapeQueryExtension" >&5
 $as_echo "$ac_cv_lib_Xext_XShapeQueryExtension" >&6; }
-if test "x$ac_cv_lib_Xext_XShapeQueryExtension" = x""yes; then :
+if test "x$ac_cv_lib_Xext_XShapeQueryExtension" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_LIBXEXT 1
 _ACEOF
@@ -9768,7 +9790,7 @@
 if test "${USE_X_TOOLKIT}" = "MOTIF"; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Motif version 2.1" >&5
 $as_echo_n "checking for Motif version 2.1... " >&6; }
-if test "${emacs_cv_motif_version_2_1+set}" = set; then :
+if ${emacs_cv_motif_version_2_1+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -9798,7 +9820,7 @@
   if test $emacs_cv_motif_version_2_1 = yes; then
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for XpCreateContext in -lXp" >&5
 $as_echo_n "checking for XpCreateContext in -lXp... " >&6; }
-if test "${ac_cv_lib_Xp_XpCreateContext+set}" = set; then :
+if ${ac_cv_lib_Xp_XpCreateContext+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -9832,14 +9854,14 @@
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_Xp_XpCreateContext" >&5
 $as_echo "$ac_cv_lib_Xp_XpCreateContext" >&6; }
-if test "x$ac_cv_lib_Xp_XpCreateContext" = x""yes; then :
+if test "x$ac_cv_lib_Xp_XpCreateContext" = xyes; then :
   LIBXP=-lXp
 fi
 
   else
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for LessTif where some systems put it" >&5
 $as_echo_n "checking for LessTif where some systems put it... " >&6; }
-if test "${emacs_cv_lesstif+set}" = set; then :
+if ${emacs_cv_lesstif+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   # We put this in CFLAGS temporarily to precede other -I options
@@ -9998,7 +10020,7 @@
 set dummy pkg-config; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_PKG_CONFIG+set}" = set; then :
+if ${ac_cv_path_PKG_CONFIG+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   case $PKG_CONFIG in
@@ -10100,7 +10122,7 @@
 set dummy pkg-config; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_PKG_CONFIG+set}" = set; then :
+if ${ac_cv_path_PKG_CONFIG+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   case $PKG_CONFIG in
@@ -10192,7 +10214,7 @@
       HAVE_XRENDER=no
       { $as_echo "$as_me:${as_lineno-$LINENO}: checking for XRenderQueryExtension in -lXrender" >&5
 $as_echo_n "checking for XRenderQueryExtension in -lXrender... " >&6; }
-if test "${ac_cv_lib_Xrender_XRenderQueryExtension+set}" = set; then :
+if ${ac_cv_lib_Xrender_XRenderQueryExtension+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -10226,7 +10248,7 @@
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_Xrender_XRenderQueryExtension" >&5
 $as_echo "$ac_cv_lib_Xrender_XRenderQueryExtension" >&6; }
-if test "x$ac_cv_lib_Xrender_XRenderQueryExtension" = x""yes; then :
+if test "x$ac_cv_lib_Xrender_XRenderQueryExtension" = xyes; then :
   HAVE_XRENDER=yes
 fi
 
@@ -10239,10 +10261,10 @@
 	XFT_LIBS="-lXrender $XFT_LIBS"
 	LIBS="$XFT_LIBS $LIBS"
 	ac_fn_c_check_header_mongrel "$LINENO" "X11/Xft/Xft.h" "ac_cv_header_X11_Xft_Xft_h" "$ac_includes_default"
-if test "x$ac_cv_header_X11_Xft_Xft_h" = x""yes; then :
+if test "x$ac_cv_header_X11_Xft_Xft_h" = xyes; then :
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for XftFontOpen in -lXft" >&5
 $as_echo_n "checking for XftFontOpen in -lXft... " >&6; }
-if test "${ac_cv_lib_Xft_XftFontOpen+set}" = set; then :
+if ${ac_cv_lib_Xft_XftFontOpen+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -10276,7 +10298,7 @@
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_Xft_XftFontOpen" >&5
 $as_echo "$ac_cv_lib_Xft_XftFontOpen" >&6; }
-if test "x$ac_cv_lib_Xft_XftFontOpen" = x""yes; then :
+if test "x$ac_cv_lib_Xft_XftFontOpen" = xyes; then :
   HAVE_XFT=yes
 fi
 
@@ -10325,7 +10347,7 @@
 set dummy pkg-config; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_PKG_CONFIG+set}" = set; then :
+if ${ac_cv_path_PKG_CONFIG+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   case $PKG_CONFIG in
@@ -10418,7 +10440,7 @@
 
 	  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OTF_get_variation_glyphs in -lotf" >&5
 $as_echo_n "checking for OTF_get_variation_glyphs in -lotf... " >&6; }
-if test "${ac_cv_lib_otf_OTF_get_variation_glyphs+set}" = set; then :
+if ${ac_cv_lib_otf_OTF_get_variation_glyphs+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -10452,7 +10474,7 @@
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_otf_OTF_get_variation_glyphs" >&5
 $as_echo "$ac_cv_lib_otf_OTF_get_variation_glyphs" >&6; }
-if test "x$ac_cv_lib_otf_OTF_get_variation_glyphs" = x""yes; then :
+if test "x$ac_cv_lib_otf_OTF_get_variation_glyphs" = xyes; then :
   HAVE_OTF_GET_VARIATION_GLYPHS=yes
 else
   HAVE_OTF_GET_VARIATION_GLYPHS=no
@@ -10477,7 +10499,7 @@
 set dummy pkg-config; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_PKG_CONFIG+set}" = set; then :
+if ${ac_cv_path_PKG_CONFIG+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   case $PKG_CONFIG in
@@ -10595,10 +10617,10 @@
 if test "${HAVE_X11}" = "yes"; then
   if test "${with_xpm}" != "no"; then
     ac_fn_c_check_header_mongrel "$LINENO" "X11/xpm.h" "ac_cv_header_X11_xpm_h" "$ac_includes_default"
-if test "x$ac_cv_header_X11_xpm_h" = x""yes; then :
+if test "x$ac_cv_header_X11_xpm_h" = xyes; then :
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for XpmReadFileToPixmap in -lXpm" >&5
 $as_echo_n "checking for XpmReadFileToPixmap in -lXpm... " >&6; }
-if test "${ac_cv_lib_Xpm_XpmReadFileToPixmap+set}" = set; then :
+if ${ac_cv_lib_Xpm_XpmReadFileToPixmap+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -10632,7 +10654,7 @@
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_Xpm_XpmReadFileToPixmap" >&5
 $as_echo "$ac_cv_lib_Xpm_XpmReadFileToPixmap" >&6; }
-if test "x$ac_cv_lib_Xpm_XpmReadFileToPixmap" = x""yes; then :
+if test "x$ac_cv_lib_Xpm_XpmReadFileToPixmap" = xyes; then :
   HAVE_XPM=yes
 fi
 
@@ -10684,10 +10706,10 @@
 if test "${HAVE_X11}" = "yes"; then
   if test "${with_jpeg}" != "no"; then
             ac_fn_c_check_header_mongrel "$LINENO" "jerror.h" "ac_cv_header_jerror_h" "$ac_includes_default"
-if test "x$ac_cv_header_jerror_h" = x""yes; then :
+if test "x$ac_cv_header_jerror_h" = xyes; then :
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for jpeg_destroy_compress in -ljpeg" >&5
 $as_echo_n "checking for jpeg_destroy_compress in -ljpeg... " >&6; }
-if test "${ac_cv_lib_jpeg_jpeg_destroy_compress+set}" = set; then :
+if ${ac_cv_lib_jpeg_jpeg_destroy_compress+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -10721,7 +10743,7 @@
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_jpeg_jpeg_destroy_compress" >&5
 $as_echo "$ac_cv_lib_jpeg_jpeg_destroy_compress" >&6; }
-if test "x$ac_cv_lib_jpeg_jpeg_destroy_compress" = x""yes; then :
+if test "x$ac_cv_lib_jpeg_jpeg_destroy_compress" = xyes; then :
   HAVE_JPEG=yes
 fi
 
@@ -10768,8 +10790,7 @@
 do :
   as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
 ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
-eval as_val=\$$as_ac_Header
-   if test "x$as_val" = x""yes; then :
+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
 _ACEOF
@@ -10781,7 +10802,7 @@
     if test "$ac_cv_header_png_h" = yes || test "$ac_cv_header_libpng_png_h" = yes ; then
       { $as_echo "$as_me:${as_lineno-$LINENO}: checking for png_get_channels in -lpng" >&5
 $as_echo_n "checking for png_get_channels in -lpng... " >&6; }
-if test "${ac_cv_lib_png_png_get_channels+set}" = set; then :
+if ${ac_cv_lib_png_png_get_channels+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -10815,7 +10836,7 @@
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_png_png_get_channels" >&5
 $as_echo "$ac_cv_lib_png_png_get_channels" >&6; }
-if test "x$ac_cv_lib_png_png_get_channels" = x""yes; then :
+if test "x$ac_cv_lib_png_png_get_channels" = xyes; then :
   HAVE_PNG=yes
 fi
 
@@ -10837,13 +10858,13 @@
 if test "${HAVE_X11}" = "yes"; then
   if test "${with_tiff}" != "no"; then
     ac_fn_c_check_header_mongrel "$LINENO" "tiffio.h" "ac_cv_header_tiffio_h" "$ac_includes_default"
-if test "x$ac_cv_header_tiffio_h" = x""yes; then :
+if test "x$ac_cv_header_tiffio_h" = xyes; then :
   tifflibs="-lz -lm"
       # At least one tiff package requires the jpeg library.
       if test "${HAVE_JPEG}" = yes; then tifflibs="-ljpeg $tifflibs"; fi
       { $as_echo "$as_me:${as_lineno-$LINENO}: checking for TIFFGetVersion in -ltiff" >&5
 $as_echo_n "checking for TIFFGetVersion in -ltiff... " >&6; }
-if test "${ac_cv_lib_tiff_TIFFGetVersion+set}" = set; then :
+if ${ac_cv_lib_tiff_TIFFGetVersion+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -10877,7 +10898,7 @@
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_tiff_TIFFGetVersion" >&5
 $as_echo "$ac_cv_lib_tiff_TIFFGetVersion" >&6; }
-if test "x$ac_cv_lib_tiff_TIFFGetVersion" = x""yes; then :
+if test "x$ac_cv_lib_tiff_TIFFGetVersion" = xyes; then :
   HAVE_TIFF=yes
 fi
 
@@ -10900,12 +10921,12 @@
 LIBGIF=
 if test "${HAVE_X11}" = "yes" && test "${with_gif}" != "no"; then
   ac_fn_c_check_header_mongrel "$LINENO" "gif_lib.h" "ac_cv_header_gif_lib_h" "$ac_includes_default"
-if test "x$ac_cv_header_gif_lib_h" = x""yes; then :
+if test "x$ac_cv_header_gif_lib_h" = xyes; then :
   # EGifPutExtensionLast only exists from version libungif-4.1.0b1.
 # Earlier versions can crash Emacs.
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for EGifPutExtensionLast in -lgif" >&5
 $as_echo_n "checking for EGifPutExtensionLast in -lgif... " >&6; }
-if test "${ac_cv_lib_gif_EGifPutExtensionLast+set}" = set; then :
+if ${ac_cv_lib_gif_EGifPutExtensionLast+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -10939,7 +10960,7 @@
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gif_EGifPutExtensionLast" >&5
 $as_echo "$ac_cv_lib_gif_EGifPutExtensionLast" >&6; }
-if test "x$ac_cv_lib_gif_EGifPutExtensionLast" = x""yes; then :
+if test "x$ac_cv_lib_gif_EGifPutExtensionLast" = xyes; then :
   HAVE_GIF=yes
 else
   HAVE_GIF=maybe
@@ -10955,7 +10976,7 @@
 # If gif_lib.h but no libgif, try libungif.
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for EGifPutExtensionLast in -lungif" >&5
 $as_echo_n "checking for EGifPutExtensionLast in -lungif... " >&6; }
-if test "${ac_cv_lib_ungif_EGifPutExtensionLast+set}" = set; then :
+if ${ac_cv_lib_ungif_EGifPutExtensionLast+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -10989,7 +11010,7 @@
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ungif_EGifPutExtensionLast" >&5
 $as_echo "$ac_cv_lib_ungif_EGifPutExtensionLast" >&6; }
-if test "x$ac_cv_lib_ungif_EGifPutExtensionLast" = x""yes; then :
+if test "x$ac_cv_lib_ungif_EGifPutExtensionLast" = xyes; then :
   HAVE_GIF=yes
 else
   HAVE_GIF=no
@@ -11021,7 +11042,7 @@
     MISSING="$MISSING libtiff" && WITH_NO="$WITH_NO --with-tiff=no"
 
   if test "X${MISSING}" != X; then
-    as_fn_error "The following required libraries were not found:
+    as_fn_error $? "The following required libraries were not found:
     $MISSING
 Maybe some development libraries/packages are missing?
 If you don't want to link with them give
@@ -11036,10 +11057,10 @@
 MOUSE_SUPPORT=
 if test "${with_gpm}" != "no"; then
   ac_fn_c_check_header_mongrel "$LINENO" "gpm.h" "ac_cv_header_gpm_h" "$ac_includes_default"
-if test "x$ac_cv_header_gpm_h" = x""yes; then :
+if test "x$ac_cv_header_gpm_h" = xyes; then :
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Gpm_Open in -lgpm" >&5
 $as_echo_n "checking for Gpm_Open in -lgpm... " >&6; }
-if test "${ac_cv_lib_gpm_Gpm_Open+set}" = set; then :
+if ${ac_cv_lib_gpm_Gpm_Open+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -11073,7 +11094,7 @@
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gpm_Gpm_Open" >&5
 $as_echo "$ac_cv_lib_gpm_Gpm_Open" >&6; }
-if test "x$ac_cv_lib_gpm_Gpm_Open" = x""yes; then :
+if test "x$ac_cv_lib_gpm_Gpm_Open" = xyes; then :
   HAVE_GPM=yes
 fi
 
@@ -11093,7 +11114,7 @@
 
 
 ac_fn_c_check_header_mongrel "$LINENO" "malloc/malloc.h" "ac_cv_header_malloc_malloc_h" "$ac_includes_default"
-if test "x$ac_cv_header_malloc_malloc_h" = x""yes; then :
+if test "x$ac_cv_header_malloc_malloc_h" = xyes; then :
 
 $as_echo "#define HAVE_MALLOC_MALLOC_H 1" >>confdefs.h
 
@@ -11138,10 +11159,10 @@
 LIBXSM=
 if test "${HAVE_X11}" = "yes"; then
   ac_fn_c_check_header_mongrel "$LINENO" "X11/SM/SMlib.h" "ac_cv_header_X11_SM_SMlib_h" "$ac_includes_default"
-if test "x$ac_cv_header_X11_SM_SMlib_h" = x""yes; then :
+if test "x$ac_cv_header_X11_SM_SMlib_h" = xyes; then :
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for SmcOpenConnection in -lSM" >&5
 $as_echo_n "checking for SmcOpenConnection in -lSM... " >&6; }
-if test "${ac_cv_lib_SM_SmcOpenConnection+set}" = set; then :
+if ${ac_cv_lib_SM_SmcOpenConnection+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -11175,7 +11196,7 @@
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_SM_SmcOpenConnection" >&5
 $as_echo "$ac_cv_lib_SM_SmcOpenConnection" >&6; }
-if test "x$ac_cv_lib_SM_SmcOpenConnection" = x""yes; then :
+if test "x$ac_cv_lib_SM_SmcOpenConnection" = xyes; then :
   HAVE_X_SM=yes
 fi
 
@@ -11206,7 +11227,7 @@
 set dummy pkg-config; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_PKG_CONFIG+set}" = set; then :
+if ${ac_cv_path_PKG_CONFIG+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   case $PKG_CONFIG in
@@ -11297,7 +11318,7 @@
     LIBS="$LIBXML2_LIBS $LIBS"
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for htmlReadMemory in -lxml2" >&5
 $as_echo_n "checking for htmlReadMemory in -lxml2... " >&6; }
-if test "${ac_cv_lib_xml2_htmlReadMemory+set}" = set; then :
+if ${ac_cv_lib_xml2_htmlReadMemory+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -11331,7 +11352,7 @@
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_xml2_htmlReadMemory" >&5
 $as_echo "$ac_cv_lib_xml2_htmlReadMemory" >&6; }
-if test "x$ac_cv_lib_xml2_htmlReadMemory" = x""yes; then :
+if test "x$ac_cv_lib_xml2_htmlReadMemory" = xyes; then :
   HAVE_LIBXML2=yes
 else
   HAVE_LIBXML2=no
@@ -11353,7 +11374,7 @@
 # If netdb.h doesn't declare h_errno, we must declare it by hand.
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether netdb declares h_errno" >&5
 $as_echo_n "checking whether netdb declares h_errno... " >&6; }
-if test "${emacs_cv_netdb_declares_h_errno+set}" = set; then :
+if ${emacs_cv_netdb_declares_h_errno+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -11383,11 +11404,22 @@
 
 fi
 
+ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default"
+if test "x$ac_cv_type_size_t" = xyes; then :
+
+else
+
+cat >>confdefs.h <<_ACEOF
+#define size_t unsigned int
+_ACEOF
+
+fi
+
 # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
 # for constant arguments.  Useless!
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working alloca.h" >&5
 $as_echo_n "checking for working alloca.h... " >&6; }
-if test "${ac_cv_working_alloca_h+set}" = set; then :
+if ${ac_cv_working_alloca_h+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -11420,7 +11452,7 @@
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for alloca" >&5
 $as_echo_n "checking for alloca... " >&6; }
-if test "${ac_cv_func_alloca_works+set}" = set; then :
+if ${ac_cv_func_alloca_works+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -11439,7 +11471,7 @@
  #pragma alloca
 #   else
 #    ifndef alloca /* predefined by HP cc +Olibcalls */
-char *alloca ();
+void *alloca (size_t);
 #    endif
 #   endif
 #  endif
@@ -11483,7 +11515,7 @@
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether \`alloca.c' needs Cray hooks" >&5
 $as_echo_n "checking whether \`alloca.c' needs Cray hooks... " >&6; }
-if test "${ac_cv_os_cray+set}" = set; then :
+if ${ac_cv_os_cray+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -11510,8 +11542,7 @@
   for ac_func in _getb67 GETB67 getb67; do
     as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-eval as_val=\$$as_ac_var
-   if test "x$as_val" = x""yes; then :
+if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
 
 cat >>confdefs.h <<_ACEOF
 #define CRAY_STACKSEG_END $ac_func
@@ -11525,7 +11556,7 @@
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking stack direction for C alloca" >&5
 $as_echo_n "checking stack direction for C alloca... " >&6; }
-if test "${ac_cv_c_stack_direction+set}" = set; then :
+if ${ac_cv_c_stack_direction+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   if test "$cross_compiling" = yes; then :
@@ -11575,14 +11606,14 @@
 
 
 if test x"$ac_cv_func_alloca_works" != xyes; then
-   as_fn_error "a system implementation of alloca is required " "$LINENO" 5
+   as_fn_error $? "a system implementation of alloca is required " "$LINENO" 5
 fi
 
 # fmod, logb, and frexp are found in -lm on most systems.
 # On HPUX 9.01, -lm does not contain logb, so check for sqrt.
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sqrt in -lm" >&5
 $as_echo_n "checking for sqrt in -lm... " >&6; }
-if test "${ac_cv_lib_m_sqrt+set}" = set; then :
+if ${ac_cv_lib_m_sqrt+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -11616,7 +11647,7 @@
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_sqrt" >&5
 $as_echo "$ac_cv_lib_m_sqrt" >&6; }
-if test "x$ac_cv_lib_m_sqrt" = x""yes; then :
+if test "x$ac_cv_lib_m_sqrt" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_LIBM 1
 _ACEOF
@@ -11630,7 +11661,7 @@
 # have the same check as for liblockfile below.
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for maillock in -lmail" >&5
 $as_echo_n "checking for maillock in -lmail... " >&6; }
-if test "${ac_cv_lib_mail_maillock+set}" = set; then :
+if ${ac_cv_lib_mail_maillock+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -11664,7 +11695,7 @@
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_mail_maillock" >&5
 $as_echo "$ac_cv_lib_mail_maillock" >&6; }
-if test "x$ac_cv_lib_mail_maillock" = x""yes; then :
+if test "x$ac_cv_lib_mail_maillock" = xyes; then :
   have_mail=yes
 else
   have_mail=no
@@ -11681,7 +11712,7 @@
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for maillock in -llockfile" >&5
 $as_echo_n "checking for maillock in -llockfile... " >&6; }
-if test "${ac_cv_lib_lockfile_maillock+set}" = set; then :
+if ${ac_cv_lib_lockfile_maillock+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -11715,7 +11746,7 @@
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lockfile_maillock" >&5
 $as_echo "$ac_cv_lib_lockfile_maillock" >&6; }
-if test "x$ac_cv_lib_lockfile_maillock" = x""yes; then :
+if test "x$ac_cv_lib_lockfile_maillock" = xyes; then :
   have_lockfile=yes
 else
   have_lockfile=no
@@ -11735,7 +11766,7 @@
 set dummy liblockfile.so; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_liblockfile+set}" = set; then :
+if ${ac_cv_prog_liblockfile+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   if test -n "$liblockfile"; then
@@ -11771,7 +11802,7 @@
 
 
   if test $ac_cv_prog_liblockfile = yes; then
-    as_fn_error "Shared liblockfile found but can't link against it.
+    as_fn_error $? "Shared liblockfile found but can't link against it.
 This probably means that movemail could lose mail.
 There may be a \`development' package to install containing liblockfile." "$LINENO" 5
   fi
@@ -11779,7 +11810,7 @@
 for ac_func in touchlock
 do :
   ac_fn_c_check_func "$LINENO" "touchlock" "ac_cv_func_touchlock"
-if test "x$ac_cv_func_touchlock" = x""yes; then :
+if test "x$ac_cv_func_touchlock" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_TOUCHLOCK 1
 _ACEOF
@@ -11790,7 +11821,7 @@
 for ac_header in maillock.h
 do :
   ac_fn_c_check_header_mongrel "$LINENO" "maillock.h" "ac_cv_header_maillock_h" "$ac_includes_default"
-if test "x$ac_cv_header_maillock_h" = x""yes; then :
+if test "x$ac_cv_header_maillock_h" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_MAILLOCK_H 1
 _ACEOF
@@ -11860,8 +11891,7 @@
 do :
   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-eval as_val=\$$as_ac_var
-   if test "x$as_val" = x""yes; then :
+if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
 _ACEOF
@@ -11873,7 +11903,7 @@
 for ac_header in sys/un.h
 do :
   ac_fn_c_check_header_mongrel "$LINENO" "sys/un.h" "ac_cv_header_sys_un_h" "$ac_includes_default"
-if test "x$ac_cv_header_sys_un_h" = x""yes; then :
+if test "x$ac_cv_header_sys_un_h" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_SYS_UN_H 1
 _ACEOF
@@ -11892,8 +11922,7 @@
 do :
   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-eval as_val=\$$as_ac_var
-   if test "x$as_val" = x""yes; then :
+if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
 _ACEOF
@@ -11907,7 +11936,7 @@
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working mktime" >&5
 $as_echo_n "checking for working mktime... " >&6; }
-if test "${ac_cv_func_working_mktime+set}" = set; then :
+if ${ac_cv_func_working_mktime+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   if test "$cross_compiling" = yes; then :
@@ -11945,8 +11974,8 @@
 static time_t time_t_min;
 
 /* Values we'll use to set the TZ environment variable.  */
-static char *tz_strings[] = {
-  (char *) 0, "TZ=GMT0", "TZ=JST-9",
+static const char *tz_strings[] = {
+  (const char *) 0, "TZ=GMT0", "TZ=JST-9",
   "TZ=EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00"
 };
 #define N_STRINGS (sizeof (tz_strings) / sizeof (tz_strings[0]))
@@ -11963,7 +11992,7 @@
      instead of "TZ=America/Vancouver" in order to detect the bug even
      on systems that don't support the Olson extension, or don't have the
      full zoneinfo tables installed.  */
-  putenv ("TZ=PST8PDT,M4.1.0,M10.5.0");
+  putenv ((char*) "TZ=PST8PDT,M4.1.0,M10.5.0");
 
   tm.tm_year = 98;
   tm.tm_mon = 3;
@@ -11976,16 +12005,14 @@
 }
 
 static int
-mktime_test1 (now)
-     time_t now;
+mktime_test1 (time_t now)
 {
   struct tm *lt;
   return ! (lt = localtime (&now)) || mktime (lt) == now;
 }
 
 static int
-mktime_test (now)
-     time_t now;
+mktime_test (time_t now)
 {
   return (mktime_test1 (now)
 	  && mktime_test1 ((time_t) (time_t_max - now))
@@ -12009,8 +12036,7 @@
 }
 
 static int
-bigtime_test (j)
-     int j;
+bigtime_test (int j)
 {
   struct tm tm;
   time_t now;
@@ -12054,7 +12080,7 @@
      instead of "TZ=America/Vancouver" in order to detect the bug even
      on systems that don't support the Olson extension, or don't have the
      full zoneinfo tables installed.  */
-  putenv ("TZ=PST8PDT,M4.1.0,M10.5.0");
+  putenv ((char*) "TZ=PST8PDT,M4.1.0,M10.5.0");
 
   t = mktime (&tm);
 
@@ -12089,7 +12115,7 @@
   for (i = 0; i < N_STRINGS; i++)
     {
       if (tz_strings[i])
-	putenv (tz_strings[i]);
+	putenv ((char*) tz_strings[i]);
 
       for (t = 0; t <= time_t_max - delta; t += delta)
 	if (! mktime_test (t))
@@ -12141,13 +12167,13 @@
 
 # Make sure getloadavg.c is where it belongs, at configure-time.
 test -f "$srcdir/$ac_config_libobj_dir/getloadavg.c" ||
-  as_fn_error "$srcdir/$ac_config_libobj_dir/getloadavg.c is missing" "$LINENO" 5
+  as_fn_error $? "$srcdir/$ac_config_libobj_dir/getloadavg.c is missing" "$LINENO" 5
 
 ac_save_LIBS=$LIBS
 
 # Check for getloadavg, but be sure not to touch the cache variable.
 (ac_fn_c_check_func "$LINENO" "getloadavg" "ac_cv_func_getloadavg"
-if test "x$ac_cv_func_getloadavg" = x""yes; then :
+if test "x$ac_cv_func_getloadavg" = xyes; then :
   exit 0
 else
   exit 1
@@ -12158,7 +12184,7 @@
 for ac_func in pstat_getdynamic
 do :
   ac_fn_c_check_func "$LINENO" "pstat_getdynamic" "ac_cv_func_pstat_getdynamic"
-if test "x$ac_cv_func_pstat_getdynamic" = x""yes; then :
+if test "x$ac_cv_func_pstat_getdynamic" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_PSTAT_GETDYNAMIC 1
 _ACEOF
@@ -12170,7 +12196,7 @@
 # Solaris has libkstat which does not require root.
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for kstat_open in -lkstat" >&5
 $as_echo_n "checking for kstat_open in -lkstat... " >&6; }
-if test "${ac_cv_lib_kstat_kstat_open+set}" = set; then :
+if ${ac_cv_lib_kstat_kstat_open+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -12204,7 +12230,7 @@
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_kstat_kstat_open" >&5
 $as_echo "$ac_cv_lib_kstat_kstat_open" >&6; }
-if test "x$ac_cv_lib_kstat_kstat_open" = x""yes; then :
+if test "x$ac_cv_lib_kstat_kstat_open" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_LIBKSTAT 1
 _ACEOF
@@ -12222,7 +12248,7 @@
 if test $ac_have_func = no; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for elf_begin in -lelf" >&5
 $as_echo_n "checking for elf_begin in -lelf... " >&6; }
-if test "${ac_cv_lib_elf_elf_begin+set}" = set; then :
+if ${ac_cv_lib_elf_elf_begin+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -12256,7 +12282,7 @@
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_elf_elf_begin" >&5
 $as_echo "$ac_cv_lib_elf_elf_begin" >&6; }
-if test "x$ac_cv_lib_elf_elf_begin" = x""yes; then :
+if test "x$ac_cv_lib_elf_elf_begin" = xyes; then :
   LIBS="-lelf $LIBS"
 fi
 
@@ -12264,7 +12290,7 @@
 if test $ac_have_func = no; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for kvm_open in -lkvm" >&5
 $as_echo_n "checking for kvm_open in -lkvm... " >&6; }
-if test "${ac_cv_lib_kvm_kvm_open+set}" = set; then :
+if ${ac_cv_lib_kvm_kvm_open+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -12298,14 +12324,14 @@
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_kvm_kvm_open" >&5
 $as_echo "$ac_cv_lib_kvm_kvm_open" >&6; }
-if test "x$ac_cv_lib_kvm_kvm_open" = x""yes; then :
+if test "x$ac_cv_lib_kvm_kvm_open" = xyes; then :
   LIBS="-lkvm $LIBS"
 fi
 
   # Check for the 4.4BSD definition of getloadavg.
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for getloadavg in -lutil" >&5
 $as_echo_n "checking for getloadavg in -lutil... " >&6; }
-if test "${ac_cv_lib_util_getloadavg+set}" = set; then :
+if ${ac_cv_lib_util_getloadavg+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -12339,7 +12365,7 @@
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_util_getloadavg" >&5
 $as_echo "$ac_cv_lib_util_getloadavg" >&6; }
-if test "x$ac_cv_lib_util_getloadavg" = x""yes; then :
+if test "x$ac_cv_lib_util_getloadavg" = xyes; then :
   LIBS="-lutil $LIBS" ac_have_func=yes ac_cv_func_getloadavg_setgid=yes
 fi
 
@@ -12352,7 +12378,7 @@
   LIBS="-L/usr/local/lib $LIBS"
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for getloadavg in -lgetloadavg" >&5
 $as_echo_n "checking for getloadavg in -lgetloadavg... " >&6; }
-if test "${ac_cv_lib_getloadavg_getloadavg+set}" = set; then :
+if ${ac_cv_lib_getloadavg_getloadavg+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -12386,7 +12412,7 @@
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_getloadavg_getloadavg" >&5
 $as_echo "$ac_cv_lib_getloadavg_getloadavg" >&6; }
-if test "x$ac_cv_lib_getloadavg_getloadavg" = x""yes; then :
+if test "x$ac_cv_lib_getloadavg_getloadavg" = xyes; then :
   LIBS="-lgetloadavg $LIBS"
 else
   LIBS=$ac_getloadavg_LIBS
@@ -12399,7 +12425,7 @@
 for ac_func in getloadavg
 do :
   ac_fn_c_check_func "$LINENO" "getloadavg" "ac_cv_func_getloadavg"
-if test "x$ac_cv_func_getloadavg" = x""yes; then :
+if test "x$ac_cv_func_getloadavg" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_GETLOADAVG 1
 _ACEOF
@@ -12417,14 +12443,14 @@
 # Figure out what our getloadavg.c needs.
 ac_have_func=no
 ac_fn_c_check_header_mongrel "$LINENO" "sys/dg_sys_info.h" "ac_cv_header_sys_dg_sys_info_h" "$ac_includes_default"
-if test "x$ac_cv_header_sys_dg_sys_info_h" = x""yes; then :
+if test "x$ac_cv_header_sys_dg_sys_info_h" = xyes; then :
   ac_have_func=yes
 
 $as_echo "#define DGUX 1" >>confdefs.h
 
  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dg_sys_info in -ldgc" >&5
 $as_echo_n "checking for dg_sys_info in -ldgc... " >&6; }
-if test "${ac_cv_lib_dgc_dg_sys_info+set}" = set; then :
+if ${ac_cv_lib_dgc_dg_sys_info+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -12458,7 +12484,7 @@
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dgc_dg_sys_info" >&5
 $as_echo "$ac_cv_lib_dgc_dg_sys_info" >&6; }
-if test "x$ac_cv_lib_dgc_dg_sys_info" = x""yes; then :
+if test "x$ac_cv_lib_dgc_dg_sys_info" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_LIBDGC 1
 _ACEOF
@@ -12472,7 +12498,7 @@
 
 
 ac_fn_c_check_header_mongrel "$LINENO" "locale.h" "ac_cv_header_locale_h" "$ac_includes_default"
-if test "x$ac_cv_header_locale_h" = x""yes; then :
+if test "x$ac_cv_header_locale_h" = xyes; then :
 
 fi
 
@@ -12480,7 +12506,7 @@
 for ac_func in setlocale
 do :
   ac_fn_c_check_func "$LINENO" "setlocale" "ac_cv_func_setlocale"
-if test "x$ac_cv_func_setlocale" = x""yes; then :
+if test "x$ac_cv_func_setlocale" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_SETLOCALE 1
 _ACEOF
@@ -12492,7 +12518,8 @@
 # We cannot check for <dwarf.h>, because Solaris 2 does not use dwarf (it
 # uses stabs), but it is still SVR4.  We cannot check for <elf.h> because
 # Irix 4.0.5F has the header but not the library.
-if test $ac_have_func = no && test "$ac_cv_lib_elf_elf_begin" = yes; then
+if test $ac_have_func = no && test "$ac_cv_lib_elf_elf_begin" = yes \
+    && test "$ac_cv_lib_kvm_kvm_open" = yes; then
   ac_have_func=yes
 
 $as_echo "#define SVR4 1" >>confdefs.h
@@ -12501,7 +12528,7 @@
 
 if test $ac_have_func = no; then
   ac_fn_c_check_header_mongrel "$LINENO" "inq_stats/cpustats.h" "ac_cv_header_inq_stats_cpustats_h" "$ac_includes_default"
-if test "x$ac_cv_header_inq_stats_cpustats_h" = x""yes; then :
+if test "x$ac_cv_header_inq_stats_cpustats_h" = xyes; then :
   ac_have_func=yes
 
 $as_echo "#define UMAX 1" >>confdefs.h
@@ -12516,7 +12543,7 @@
 
 if test $ac_have_func = no; then
   ac_fn_c_check_header_mongrel "$LINENO" "sys/cpustats.h" "ac_cv_header_sys_cpustats_h" "$ac_includes_default"
-if test "x$ac_cv_header_sys_cpustats_h" = x""yes; then :
+if test "x$ac_cv_header_sys_cpustats_h" = xyes; then :
   ac_have_func=yes; $as_echo "#define UMAX 1" >>confdefs.h
 
 fi
@@ -12528,7 +12555,7 @@
   for ac_header in mach/mach.h
 do :
   ac_fn_c_check_header_mongrel "$LINENO" "mach/mach.h" "ac_cv_header_mach_mach_h" "$ac_includes_default"
-if test "x$ac_cv_header_mach_mach_h" = x""yes; then :
+if test "x$ac_cv_header_mach_mach_h" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_MACH_MACH_H 1
 _ACEOF
@@ -12542,13 +12569,13 @@
 for ac_header in nlist.h
 do :
   ac_fn_c_check_header_mongrel "$LINENO" "nlist.h" "ac_cv_header_nlist_h" "$ac_includes_default"
-if test "x$ac_cv_header_nlist_h" = x""yes; then :
+if test "x$ac_cv_header_nlist_h" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_NLIST_H 1
 _ACEOF
  ac_fn_c_check_member "$LINENO" "struct nlist" "n_un.n_name" "ac_cv_member_struct_nlist_n_un_n_name" "#include <nlist.h>
 "
-if test "x$ac_cv_member_struct_nlist_n_un_n_name" = x""yes; then :
+if test "x$ac_cv_member_struct_nlist_n_un_n_name" = xyes; then :
 
 cat >>confdefs.h <<_ACEOF
 #define HAVE_STRUCT_NLIST_N_UN_N_NAME 1
@@ -12571,7 +12598,7 @@
 # Some definitions of getloadavg require that the program be installed setgid.
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether getloadavg requires setgid" >&5
 $as_echo_n "checking whether getloadavg requires setgid... " >&6; }
-if test "${ac_cv_func_getloadavg_setgid+set}" = set; then :
+if ${ac_cv_func_getloadavg_setgid+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -12604,7 +12631,7 @@
 if test $ac_cv_func_getloadavg_setgid = yes; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking group of /dev/kmem" >&5
 $as_echo_n "checking group of /dev/kmem... " >&6; }
-if test "${ac_cv_group_kmem+set}" = set; then :
+if ${ac_cv_group_kmem+:} false; then :
   $as_echo_n "(cached) " >&6
 else
    # On Solaris, /dev/kmem is a symlink.  Get info on the real file.
@@ -12632,7 +12659,7 @@
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _LARGEFILE_SOURCE value needed for large files" >&5
 $as_echo_n "checking for _LARGEFILE_SOURCE value needed for large files... " >&6; }
-if test "${ac_cv_sys_largefile_source+set}" = set; then :
+if ${ac_cv_sys_largefile_source+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   while :; do
@@ -12725,7 +12752,7 @@
   for ac_header in getopt.h
 do :
   ac_fn_c_check_header_mongrel "$LINENO" "getopt.h" "ac_cv_header_getopt_h" "$ac_includes_default"
-if test "x$ac_cv_header_getopt_h" = x""yes; then :
+if test "x$ac_cv_header_getopt_h" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_GETOPT_H 1
 _ACEOF
@@ -12740,7 +12767,7 @@
     for ac_func in getopt_long_only
 do :
   ac_fn_c_check_func "$LINENO" "getopt_long_only" "ac_cv_func_getopt_long_only"
-if test "x$ac_cv_func_getopt_long_only" = x""yes; then :
+if test "x$ac_cv_func_getopt_long_only" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_GETOPT_LONG_ONLY 1
 _ACEOF
@@ -12755,7 +12782,7 @@
       if test -z "$GETOPT_H"; then
     ac_fn_c_check_decl "$LINENO" "optreset" "ac_cv_have_decl_optreset" "#include <getopt.h>
 "
-if test "x$ac_cv_have_decl_optreset" = x""yes; then :
+if test "x$ac_cv_have_decl_optreset" = xyes; then :
   GETOPT_H=getopt.h
 fi
 
@@ -12764,13 +12791,13 @@
       if test -z "$GETOPT_H"; then
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working GNU getopt function" >&5
 $as_echo_n "checking for working GNU getopt function... " >&6; }
-if test "${gl_cv_func_gnu_getopt+set}" = set; then :
+if ${gl_cv_func_gnu_getopt+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   if test "$cross_compiling" = yes; then :
   	 	 	 ac_fn_c_check_decl "$LINENO" "getopt_clip" "ac_cv_have_decl_getopt_clip" "#include <getopt.h>
 "
-if test "x$ac_cv_have_decl_getopt_clip" = x""yes; then :
+if test "x$ac_cv_have_decl_getopt_clip" = xyes; then :
   gl_cv_func_gnu_getopt=no
 else
   gl_cv_func_gnu_getopt=yes
@@ -12831,7 +12858,7 @@
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether getpgrp requires zero arguments" >&5
 $as_echo_n "checking whether getpgrp requires zero arguments... " >&6; }
-if test "${ac_cv_func_getpgrp_void+set}" = set; then :
+if ${ac_cv_func_getpgrp_void+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   # Use it with a single arg.
@@ -12866,7 +12893,7 @@
 for ac_func in strftime
 do :
   ac_fn_c_check_func "$LINENO" "strftime" "ac_cv_func_strftime"
-if test "x$ac_cv_func_strftime" = x""yes; then :
+if test "x$ac_cv_func_strftime" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_STRFTIME 1
 _ACEOF
@@ -12875,7 +12902,7 @@
   # strftime is in -lintl on SCO UNIX.
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for strftime in -lintl" >&5
 $as_echo_n "checking for strftime in -lintl... " >&6; }
-if test "${ac_cv_lib_intl_strftime+set}" = set; then :
+if ${ac_cv_lib_intl_strftime+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -12909,7 +12936,7 @@
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_intl_strftime" >&5
 $as_echo "$ac_cv_lib_intl_strftime" >&6; }
-if test "x$ac_cv_lib_intl_strftime" = x""yes; then :
+if test "x$ac_cv_lib_intl_strftime" = xyes; then :
   $as_echo "#define HAVE_STRFTIME 1" >>confdefs.h
 
 LIBS="-lintl $LIBS"
@@ -12923,7 +12950,7 @@
 for ac_func in grantpt
 do :
   ac_fn_c_check_func "$LINENO" "grantpt" "ac_cv_func_grantpt"
-if test "x$ac_cv_func_grantpt" = x""yes; then :
+if test "x$ac_cv_func_grantpt" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_GRANTPT 1
 _ACEOF
@@ -12936,7 +12963,7 @@
 for ac_func in getpt
 do :
   ac_fn_c_check_func "$LINENO" "getpt" "ac_cv_func_getpt"
-if test "x$ac_cv_func_getpt" = x""yes; then :
+if test "x$ac_cv_func_getpt" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_GETPT 1
 _ACEOF
@@ -12953,7 +12980,7 @@
 have_tputs_et_al=true
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing tputs" >&5
 $as_echo_n "checking for library containing tputs... " >&6; }
-if test "${ac_cv_search_tputs+set}" = set; then :
+if ${ac_cv_search_tputs+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_func_search_save_LIBS=$LIBS
@@ -12987,11 +13014,11 @@
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext
-  if test "${ac_cv_search_tputs+set}" = set; then :
+  if ${ac_cv_search_tputs+:} false; then :
   break
 fi
 done
-if test "${ac_cv_search_tputs+set}" = set; then :
+if ${ac_cv_search_tputs+:} false; then :
 
 else
   ac_cv_search_tputs=no
@@ -13010,7 +13037,7 @@
 fi
 
 if test "$have_tputs_et_al" != true; then
-  as_fn_error "I couldn't find termcap functions (tputs and friends).
+  as_fn_error $? "I couldn't find termcap functions (tputs and friends).
 Maybe some development libraries/packages are missing?  Try installing
 libncurses-dev(el), libterminfo-dev(el) or similar." "$LINENO" 5
 fi
@@ -13050,7 +13077,7 @@
   freebsd)
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether FreeBSD is new enough to use terminfo" >&5
 $as_echo_n "checking whether FreeBSD is new enough to use terminfo... " >&6; }
-    if test "${emacs_cv_freebsd_terminfo+set}" = set; then :
+    if ${emacs_cv_freebsd_terminfo+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -13192,16 +13219,16 @@
 if test "$with_hesiod" != no ; then
   # Don't set $LIBS here -- see comments above.  FIXME which comments?
   ac_fn_c_check_func "$LINENO" "res_send" "ac_cv_func_res_send"
-if test "x$ac_cv_func_res_send" = x""yes; then :
+if test "x$ac_cv_func_res_send" = xyes; then :
 
 else
   ac_fn_c_check_func "$LINENO" "__res_send" "ac_cv_func___res_send"
-if test "x$ac_cv_func___res_send" = x""yes; then :
+if test "x$ac_cv_func___res_send" = xyes; then :
 
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for res_send in -lresolv" >&5
 $as_echo_n "checking for res_send in -lresolv... " >&6; }
-if test "${ac_cv_lib_resolv_res_send+set}" = set; then :
+if ${ac_cv_lib_resolv_res_send+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -13235,12 +13262,12 @@
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_resolv_res_send" >&5
 $as_echo "$ac_cv_lib_resolv_res_send" >&6; }
-if test "x$ac_cv_lib_resolv_res_send" = x""yes; then :
+if test "x$ac_cv_lib_resolv_res_send" = xyes; then :
   resolv=yes
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __res_send in -lresolv" >&5
 $as_echo_n "checking for __res_send in -lresolv... " >&6; }
-if test "${ac_cv_lib_resolv___res_send+set}" = set; then :
+if ${ac_cv_lib_resolv___res_send+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -13274,7 +13301,7 @@
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_resolv___res_send" >&5
 $as_echo "$ac_cv_lib_resolv___res_send" >&6; }
-if test "x$ac_cv_lib_resolv___res_send" = x""yes; then :
+if test "x$ac_cv_lib_resolv___res_send" = xyes; then :
   resolv=yes
 fi
 
@@ -13290,12 +13317,12 @@
     RESOLVLIB=
   fi
   ac_fn_c_check_func "$LINENO" "hes_getmailhost" "ac_cv_func_hes_getmailhost"
-if test "x$ac_cv_func_hes_getmailhost" = x""yes; then :
+if test "x$ac_cv_func_hes_getmailhost" = xyes; then :
 
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for hes_getmailhost in -lhesiod" >&5
 $as_echo_n "checking for hes_getmailhost in -lhesiod... " >&6; }
-if test "${ac_cv_lib_hesiod_hes_getmailhost+set}" = set; then :
+if ${ac_cv_lib_hesiod_hes_getmailhost+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -13329,7 +13356,7 @@
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_hesiod_hes_getmailhost" >&5
 $as_echo "$ac_cv_lib_hesiod_hes_getmailhost" >&6; }
-if test "x$ac_cv_lib_hesiod_hes_getmailhost" = x""yes; then :
+if test "x$ac_cv_lib_hesiod_hes_getmailhost" = xyes; then :
   hesiod=yes
 else
   :
@@ -13368,7 +13395,7 @@
 if test "${with_kerberos}" != no; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for com_err in -lcom_err" >&5
 $as_echo_n "checking for com_err in -lcom_err... " >&6; }
-if test "${ac_cv_lib_com_err_com_err+set}" = set; then :
+if ${ac_cv_lib_com_err_com_err+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -13402,7 +13429,7 @@
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_com_err_com_err" >&5
 $as_echo "$ac_cv_lib_com_err_com_err" >&6; }
-if test "x$ac_cv_lib_com_err_com_err" = x""yes; then :
+if test "x$ac_cv_lib_com_err_com_err" = xyes; then :
   have_com_err=yes
 else
   have_com_err=no
@@ -13417,7 +13444,7 @@
   fi
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for mit_des_cbc_encrypt in -lcrypto" >&5
 $as_echo_n "checking for mit_des_cbc_encrypt in -lcrypto... " >&6; }
-if test "${ac_cv_lib_crypto_mit_des_cbc_encrypt+set}" = set; then :
+if ${ac_cv_lib_crypto_mit_des_cbc_encrypt+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -13451,7 +13478,7 @@
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_crypto_mit_des_cbc_encrypt" >&5
 $as_echo "$ac_cv_lib_crypto_mit_des_cbc_encrypt" >&6; }
-if test "x$ac_cv_lib_crypto_mit_des_cbc_encrypt" = x""yes; then :
+if test "x$ac_cv_lib_crypto_mit_des_cbc_encrypt" = xyes; then :
   have_crypto=yes
 else
   have_crypto=no
@@ -13466,7 +13493,7 @@
   fi
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for mit_des_cbc_encrypt in -lk5crypto" >&5
 $as_echo_n "checking for mit_des_cbc_encrypt in -lk5crypto... " >&6; }
-if test "${ac_cv_lib_k5crypto_mit_des_cbc_encrypt+set}" = set; then :
+if ${ac_cv_lib_k5crypto_mit_des_cbc_encrypt+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -13500,7 +13527,7 @@
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_k5crypto_mit_des_cbc_encrypt" >&5
 $as_echo "$ac_cv_lib_k5crypto_mit_des_cbc_encrypt" >&6; }
-if test "x$ac_cv_lib_k5crypto_mit_des_cbc_encrypt" = x""yes; then :
+if test "x$ac_cv_lib_k5crypto_mit_des_cbc_encrypt" = xyes; then :
   have_k5crypto=yes
 else
   have_k5crypto=no
@@ -13515,7 +13542,7 @@
   fi
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for krb5_init_context in -lkrb5" >&5
 $as_echo_n "checking for krb5_init_context in -lkrb5... " >&6; }
-if test "${ac_cv_lib_krb5_krb5_init_context+set}" = set; then :
+if ${ac_cv_lib_krb5_krb5_init_context+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -13549,7 +13576,7 @@
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_krb5_krb5_init_context" >&5
 $as_echo "$ac_cv_lib_krb5_krb5_init_context" >&6; }
-if test "x$ac_cv_lib_krb5_krb5_init_context" = x""yes; then :
+if test "x$ac_cv_lib_krb5_krb5_init_context" = xyes; then :
   have_krb5=yes
 else
   have_krb5=no
@@ -13565,7 +13592,7 @@
     if test "${with_kerberos5}" = no; then
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for des_cbc_encrypt in -ldes425" >&5
 $as_echo_n "checking for des_cbc_encrypt in -ldes425... " >&6; }
-if test "${ac_cv_lib_des425_des_cbc_encrypt+set}" = set; then :
+if ${ac_cv_lib_des425_des_cbc_encrypt+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -13599,7 +13626,7 @@
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_des425_des_cbc_encrypt" >&5
 $as_echo "$ac_cv_lib_des425_des_cbc_encrypt" >&6; }
-if test "x$ac_cv_lib_des425_des_cbc_encrypt" = x""yes; then :
+if test "x$ac_cv_lib_des425_des_cbc_encrypt" = xyes; then :
   have_des425=yes
 else
   have_des425=no
@@ -13614,7 +13641,7 @@
     else
       { $as_echo "$as_me:${as_lineno-$LINENO}: checking for des_cbc_encrypt in -ldes" >&5
 $as_echo_n "checking for des_cbc_encrypt in -ldes... " >&6; }
-if test "${ac_cv_lib_des_des_cbc_encrypt+set}" = set; then :
+if ${ac_cv_lib_des_des_cbc_encrypt+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -13648,7 +13675,7 @@
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_des_des_cbc_encrypt" >&5
 $as_echo "$ac_cv_lib_des_des_cbc_encrypt" >&6; }
-if test "x$ac_cv_lib_des_des_cbc_encrypt" = x""yes; then :
+if test "x$ac_cv_lib_des_des_cbc_encrypt" = xyes; then :
   have_des=yes
 else
   have_des=no
@@ -13664,7 +13691,7 @@
     fi
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for krb_get_cred in -lkrb4" >&5
 $as_echo_n "checking for krb_get_cred in -lkrb4... " >&6; }
-if test "${ac_cv_lib_krb4_krb_get_cred+set}" = set; then :
+if ${ac_cv_lib_krb4_krb_get_cred+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -13698,7 +13725,7 @@
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_krb4_krb_get_cred" >&5
 $as_echo "$ac_cv_lib_krb4_krb_get_cred" >&6; }
-if test "x$ac_cv_lib_krb4_krb_get_cred" = x""yes; then :
+if test "x$ac_cv_lib_krb4_krb_get_cred" = xyes; then :
   have_krb4=yes
 else
   have_krb4=no
@@ -13713,7 +13740,7 @@
     else
       { $as_echo "$as_me:${as_lineno-$LINENO}: checking for krb_get_cred in -lkrb" >&5
 $as_echo_n "checking for krb_get_cred in -lkrb... " >&6; }
-if test "${ac_cv_lib_krb_krb_get_cred+set}" = set; then :
+if ${ac_cv_lib_krb_krb_get_cred+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -13747,7 +13774,7 @@
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_krb_krb_get_cred" >&5
 $as_echo "$ac_cv_lib_krb_krb_get_cred" >&6; }
-if test "x$ac_cv_lib_krb_krb_get_cred" = x""yes; then :
+if test "x$ac_cv_lib_krb_krb_get_cred" = xyes; then :
   have_krb=yes
 else
   have_krb=no
@@ -13767,13 +13794,13 @@
     for ac_header in krb5.h
 do :
   ac_fn_c_check_header_mongrel "$LINENO" "krb5.h" "ac_cv_header_krb5_h" "$ac_includes_default"
-if test "x$ac_cv_header_krb5_h" = x""yes; then :
+if test "x$ac_cv_header_krb5_h" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_KRB5_H 1
 _ACEOF
  ac_fn_c_check_member "$LINENO" "krb5_error" "text" "ac_cv_member_krb5_error_text" "#include <krb5.h>
 "
-if test "x$ac_cv_member_krb5_error_text" = x""yes; then :
+if test "x$ac_cv_member_krb5_error_text" = xyes; then :
 
 cat >>confdefs.h <<_ACEOF
 #define HAVE_KRB5_ERROR_TEXT 1
@@ -13783,7 +13810,7 @@
 fi
 ac_fn_c_check_member "$LINENO" "krb5_error" "e_text" "ac_cv_member_krb5_error_e_text" "#include <krb5.h>
 "
-if test "x$ac_cv_member_krb5_error_e_text" = x""yes; then :
+if test "x$ac_cv_member_krb5_error_e_text" = xyes; then :
 
 cat >>confdefs.h <<_ACEOF
 #define HAVE_KRB5_ERROR_E_TEXT 1
@@ -13800,7 +13827,7 @@
     for ac_header in des.h
 do :
   ac_fn_c_check_header_mongrel "$LINENO" "des.h" "ac_cv_header_des_h" "$ac_includes_default"
-if test "x$ac_cv_header_des_h" = x""yes; then :
+if test "x$ac_cv_header_des_h" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_DES_H 1
 _ACEOF
@@ -13809,7 +13836,7 @@
   for ac_header in kerberosIV/des.h
 do :
   ac_fn_c_check_header_mongrel "$LINENO" "kerberosIV/des.h" "ac_cv_header_kerberosIV_des_h" "$ac_includes_default"
-if test "x$ac_cv_header_kerberosIV_des_h" = x""yes; then :
+if test "x$ac_cv_header_kerberosIV_des_h" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_KERBEROSIV_DES_H 1
 _ACEOF
@@ -13818,7 +13845,7 @@
   for ac_header in kerberos/des.h
 do :
   ac_fn_c_check_header_mongrel "$LINENO" "kerberos/des.h" "ac_cv_header_kerberos_des_h" "$ac_includes_default"
-if test "x$ac_cv_header_kerberos_des_h" = x""yes; then :
+if test "x$ac_cv_header_kerberos_des_h" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_KERBEROS_DES_H 1
 _ACEOF
@@ -13838,7 +13865,7 @@
     for ac_header in krb.h
 do :
   ac_fn_c_check_header_mongrel "$LINENO" "krb.h" "ac_cv_header_krb_h" "$ac_includes_default"
-if test "x$ac_cv_header_krb_h" = x""yes; then :
+if test "x$ac_cv_header_krb_h" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_KRB_H 1
 _ACEOF
@@ -13847,7 +13874,7 @@
   for ac_header in kerberosIV/krb.h
 do :
   ac_fn_c_check_header_mongrel "$LINENO" "kerberosIV/krb.h" "ac_cv_header_kerberosIV_krb_h" "$ac_includes_default"
-if test "x$ac_cv_header_kerberosIV_krb_h" = x""yes; then :
+if test "x$ac_cv_header_kerberosIV_krb_h" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_KERBEROSIV_KRB_H 1
 _ACEOF
@@ -13856,7 +13883,7 @@
   for ac_header in kerberos/krb.h
 do :
   ac_fn_c_check_header_mongrel "$LINENO" "kerberos/krb.h" "ac_cv_header_kerberos_krb_h" "$ac_includes_default"
-if test "x$ac_cv_header_kerberos_krb_h" = x""yes; then :
+if test "x$ac_cv_header_kerberos_krb_h" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_KERBEROS_KRB_H 1
 _ACEOF
@@ -13877,7 +13904,7 @@
   for ac_header in com_err.h
 do :
   ac_fn_c_check_header_mongrel "$LINENO" "com_err.h" "ac_cv_header_com_err_h" "$ac_includes_default"
-if test "x$ac_cv_header_com_err_h" = x""yes; then :
+if test "x$ac_cv_header_com_err_h" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_COM_ERR_H 1
 _ACEOF
@@ -13898,7 +13925,7 @@
 # to return localized messages.
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dgettext in -lintl" >&5
 $as_echo_n "checking for dgettext in -lintl... " >&6; }
-if test "${ac_cv_lib_intl_dgettext+set}" = set; then :
+if ${ac_cv_lib_intl_dgettext+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -13932,7 +13959,7 @@
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_intl_dgettext" >&5
 $as_echo "$ac_cv_lib_intl_dgettext" >&6; }
-if test "x$ac_cv_lib_intl_dgettext" = x""yes; then :
+if test "x$ac_cv_lib_intl_dgettext" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_LIBINTL 1
 _ACEOF
@@ -13944,7 +13971,7 @@
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether localtime caches TZ" >&5
 $as_echo_n "checking whether localtime caches TZ... " >&6; }
-if test "${emacs_cv_localtime_cache+set}" = set; then :
+if ${emacs_cv_localtime_cache+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   if test x$ac_cv_func_tzset = xyes; then
@@ -14011,7 +14038,7 @@
   for ac_func in gettimeofday
 do :
   ac_fn_c_check_func "$LINENO" "gettimeofday" "ac_cv_func_gettimeofday"
-if test "x$ac_cv_func_gettimeofday" = x""yes; then :
+if test "x$ac_cv_func_gettimeofday" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_GETTIMEOFDAY 1
 _ACEOF
@@ -14022,7 +14049,7 @@
   if test $ac_cv_func_gettimeofday = yes; then
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether gettimeofday can accept two arguments" >&5
 $as_echo_n "checking whether gettimeofday can accept two arguments... " >&6; }
-if test "${emacs_cv_gettimeofday_two_arguments+set}" = set; then :
+if ${emacs_cv_gettimeofday_two_arguments+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -14066,7 +14093,7 @@
 
 ok_so_far=yes
 ac_fn_c_check_func "$LINENO" "socket" "ac_cv_func_socket"
-if test "x$ac_cv_func_socket" = x""yes; then :
+if test "x$ac_cv_func_socket" = xyes; then :
 
 else
   ok_so_far=no
@@ -14074,7 +14101,7 @@
 
 if test $ok_so_far = yes; then
   ac_fn_c_check_header_mongrel "$LINENO" "netinet/in.h" "ac_cv_header_netinet_in_h" "$ac_includes_default"
-if test "x$ac_cv_header_netinet_in_h" = x""yes; then :
+if test "x$ac_cv_header_netinet_in_h" = xyes; then :
 
 else
   ok_so_far=no
@@ -14084,7 +14111,7 @@
 fi
 if test $ok_so_far = yes; then
   ac_fn_c_check_header_mongrel "$LINENO" "arpa/inet.h" "ac_cv_header_arpa_inet_h" "$ac_includes_default"
-if test "x$ac_cv_header_arpa_inet_h" = x""yes; then :
+if test "x$ac_cv_header_arpa_inet_h" = xyes; then :
 
 else
   ok_so_far=no
@@ -14101,7 +14128,7 @@
 for ac_header in sys/ioctl.h
 do :
   ac_fn_c_check_header_mongrel "$LINENO" "sys/ioctl.h" "ac_cv_header_sys_ioctl_h" "$ac_includes_default"
-if test "x$ac_cv_header_sys_ioctl_h" = x""yes; then :
+if test "x$ac_cv_header_sys_ioctl_h" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_SYS_IOCTL_H 1
 _ACEOF
@@ -14131,7 +14158,7 @@
 fi
 
 ac_fn_c_check_type "$LINENO" "pid_t" "ac_cv_type_pid_t" "$ac_includes_default"
-if test "x$ac_cv_type_pid_t" = x""yes; then :
+if test "x$ac_cv_type_pid_t" = xyes; then :
 
 else
 
@@ -14144,7 +14171,7 @@
 for ac_header in vfork.h
 do :
   ac_fn_c_check_header_mongrel "$LINENO" "vfork.h" "ac_cv_header_vfork_h" "$ac_includes_default"
-if test "x$ac_cv_header_vfork_h" = x""yes; then :
+if test "x$ac_cv_header_vfork_h" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_VFORK_H 1
 _ACEOF
@@ -14157,8 +14184,7 @@
 do :
   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-eval as_val=\$$as_ac_var
-   if test "x$as_val" = x""yes; then :
+if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
 _ACEOF
@@ -14169,7 +14195,7 @@
 if test "x$ac_cv_func_fork" = xyes; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working fork" >&5
 $as_echo_n "checking for working fork... " >&6; }
-if test "${ac_cv_func_fork_works+set}" = set; then :
+if ${ac_cv_func_fork_works+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   if test "$cross_compiling" = yes; then :
@@ -14222,7 +14248,7 @@
 if test "x$ac_cv_func_vfork" = xyes; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working vfork" >&5
 $as_echo_n "checking for working vfork... " >&6; }
-if test "${ac_cv_func_vfork_works+set}" = set; then :
+if ${ac_cv_func_vfork_works+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   if test "$cross_compiling" = yes; then :
@@ -14358,7 +14384,7 @@
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for nl_langinfo and CODESET" >&5
 $as_echo_n "checking for nl_langinfo and CODESET... " >&6; }
-if test "${emacs_cv_langinfo_codeset+set}" = set; then :
+if ${emacs_cv_langinfo_codeset+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -14390,7 +14416,7 @@
 fi
 
 ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default"
-if test "x$ac_cv_type_size_t" = x""yes; then :
+if test "x$ac_cv_type_size_t" = xyes; then :
 
 cat >>confdefs.h <<_ACEOF
 #define HAVE_SIZE_T 1
@@ -14402,7 +14428,7 @@
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for mbstate_t" >&5
 $as_echo_n "checking for mbstate_t... " >&6; }
-if test "${ac_cv_type_mbstate_t+set}" = set; then :
+if ${ac_cv_type_mbstate_t+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -14438,7 +14464,7 @@
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C restrict keyword" >&5
 $as_echo_n "checking for C restrict keyword... " >&6; }
-if test "${emacs_cv_c_restrict+set}" = set; then :
+if ${emacs_cv_c_restrict+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -14492,7 +14518,7 @@
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C restricted array declarations" >&5
 $as_echo_n "checking for C restricted array declarations... " >&6; }
-if test "${emacs_cv_c_restrict_arr+set}" = set; then :
+if ${emacs_cv_c_restrict_arr+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -14539,7 +14565,7 @@
 version=`grep 'const char emacs_version' ${srcdir}/src/emacs.c \
 	 | sed -e 's/^[^"]*"\([^"]*\)".*$/\1/'`
 if test x"${version}" = x; then
-  as_fn_error "can't find current emacs version in \`${srcdir}/src/emacs.c'." "$LINENO" 5
+  as_fn_error $? "can't find current emacs version in \`${srcdir}/src/emacs.c'." "$LINENO" 5
 fi
 if test x"${version}" != x"$PACKAGE_VERSION"; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: version mismatch between \`${srcdir}/configure.in' and \`${srcdir}/src/emacs.c'." >&5
@@ -14696,9 +14722,9 @@
 
 
   if test "$USE_X_TOOLKIT" = "none"; then
-    OLDXMENU="\${oldXMenudir}libXMenu11.a"
+    OLDXMENU="\${oldXMenudir}/libXMenu11.a"
   else
-    OLDXMENU="\${lwlibdir}liblw.a"
+    OLDXMENU="\${lwlibdir}/liblw.a"
   fi
   LIBXMENU="\$(OLDXMENU)"
   LIBX_OTHER="\$(LIBXT) \$(LIBX_EXTRA)"
@@ -14909,7 +14935,7 @@
 $as_echo "#define HAVE_MOUSE 1" >>confdefs.h
 
   MOUSE_SUPPORT="\$(REAL_MOUSE_SUPPORT)"
-  TOOLTIP_SUPPORT="\${lispsource}mouse.elc"
+  TOOLTIP_SUPPORT="\${lispsource}/mouse.elc"
 
   WINDOW_SUPPORT="\$(BASE_WINDOW_SUPPORT)"
   test "$HAVE_X_WINDOWS" = "yes" && \
@@ -14968,7 +14994,7 @@
 echo "  Does Emacs use -ldbus?                                  ${HAVE_DBUS}"
 echo "  Does Emacs use -lgconf?                                 ${HAVE_GCONF}"
 echo "  Does Emacs use -lselinux?                               ${HAVE_LIBSELINUX}"
-echo "  Does Emacs use -lgnutls (BROKEN)?                       ${HAVE_GNUTLS}"
+echo "  Does Emacs use -lgnutls?                       	        ${HAVE_GNUTLS}"
 echo "  Does Emacs use -lxml2?                                  ${HAVE_LIBXML2}"
 
 echo "  Does Emacs use -lfreetype?                              ${HAVE_FREETYPE}"
@@ -15081,10 +15107,21 @@
      :end' >>confcache
 if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
   if test -w "$cache_file"; then
-    test "x$cache_file" != "x/dev/null" &&
+    if test "x$cache_file" != "x/dev/null"; then
       { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5
 $as_echo "$as_me: updating cache $cache_file" >&6;}
-    cat confcache >$cache_file
+      if test ! -f "$cache_file" || test -h "$cache_file"; then
+	cat confcache >"$cache_file"
+      else
+        case $cache_file in #(
+        */* | ?:*)
+	  mv -f confcache "$cache_file"$$ &&
+	  mv -f "$cache_file"$$ "$cache_file" ;; #(
+        *)
+	  mv -f confcache "$cache_file" ;;
+	esac
+      fi
+    fi
   else
     { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5
 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;}
@@ -15100,6 +15137,7 @@
 
 ac_libobjs=
 ac_ltlibobjs=
+U=
 for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
   # 1. Remove the extension, and $U if already installed.
   ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
@@ -15116,7 +15154,7 @@
 
 
 
-: ${CONFIG_STATUS=./config.status}
+: "${CONFIG_STATUS=./config.status}"
 ac_write_fail=0
 ac_clean_files_save=$ac_clean_files
 ac_clean_files="$ac_clean_files $CONFIG_STATUS"
@@ -15217,6 +15255,7 @@
 IFS=" ""	$as_nl"
 
 # Find who we are.  Look in the path if we contain no directory separator.
+as_myself=
 case $0 in #((
   *[\\/]* ) as_myself=$0 ;;
   *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
@@ -15262,19 +15301,19 @@
 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
 
 
-# as_fn_error ERROR [LINENO LOG_FD]
-# ---------------------------------
+# as_fn_error STATUS ERROR [LINENO LOG_FD]
+# ----------------------------------------
 # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
 # provided, also output the error to LOG_FD, referencing LINENO. Then exit the
-# script with status $?, using 1 if that was 0.
+# script with STATUS, using 1 if that was 0.
 as_fn_error ()
 {
-  as_status=$?; test $as_status -eq 0 && as_status=1
-  if test "$3"; then
-    as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-    $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3
-  fi
-  $as_echo "$as_me: error: $1" >&2
+  as_status=$1; test $as_status -eq 0 && as_status=1
+  if test "$4"; then
+    as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+    $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
+  fi
+  $as_echo "$as_me: error: $2" >&2
   as_fn_exit $as_status
 } # as_fn_error
 
@@ -15470,7 +15509,7 @@
       test -d "$as_dir" && break
     done
     test -z "$as_dirs" || eval "mkdir $as_dirs"
-  } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir"
+  } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
 
 
 } # as_fn_mkdir_p
@@ -15524,7 +15563,7 @@
 # values after options handling.
 ac_log="
 This file was extended by emacs $as_me 24.0.50, which was
-generated by GNU Autoconf 2.65.  Invocation command line was
+generated by GNU Autoconf 2.68.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
   CONFIG_HEADERS  = $CONFIG_HEADERS
@@ -15590,10 +15629,10 @@
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
 emacs config.status 24.0.50
-configured by $0, generated by GNU Autoconf 2.65,
+configured by $0, generated by GNU Autoconf 2.68,
   with options \\"\$ac_cs_config\\"
 
-Copyright (C) 2009 Free Software Foundation, Inc.
+Copyright (C) 2010 Free Software Foundation, Inc.
 This config.status script is free software; the Free Software Foundation
 gives unlimited permission to copy, distribute and modify it."
 
@@ -15609,11 +15648,16 @@
 while test $# != 0
 do
   case $1 in
-  --*=*)
+  --*=?*)
     ac_option=`expr "X$1" : 'X\([^=]*\)='`
     ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
     ac_shift=:
     ;;
+  --*=)
+    ac_option=`expr "X$1" : 'X\([^=]*\)='`
+    ac_optarg=
+    ac_shift=:
+    ;;
   *)
     ac_option=$1
     ac_optarg=$2
@@ -15635,6 +15679,7 @@
     $ac_shift
     case $ac_optarg in
     *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
+    '') as_fn_error $? "missing file argument" ;;
     esac
     as_fn_append CONFIG_FILES " '$ac_optarg'"
     ac_need_defaults=false;;
@@ -15647,7 +15692,7 @@
     ac_need_defaults=false;;
   --he | --h)
     # Conflict between --help and --header
-    as_fn_error "ambiguous option: \`$1'
+    as_fn_error $? "ambiguous option: \`$1'
 Try \`$0 --help' for more information.";;
   --help | --hel | -h )
     $as_echo "$ac_cs_usage"; exit ;;
@@ -15656,7 +15701,7 @@
     ac_cs_silent=: ;;
 
   # This is an error.
-  -*) as_fn_error "unrecognized option: \`$1'
+  -*) as_fn_error $? "unrecognized option: \`$1'
 Try \`$0 --help' for more information." ;;
 
   *) as_fn_append ac_config_targets " $1"
@@ -15724,7 +15769,7 @@
     "leim/Makefile") CONFIG_FILES="$CONFIG_FILES leim/Makefile" ;;
     "default") CONFIG_COMMANDS="$CONFIG_COMMANDS default" ;;
 
-  *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
+  *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
   esac
 done
 
@@ -15747,9 +15792,10 @@
 # after its creation but before its name has been assigned to `$tmp'.
 $debug ||
 {
-  tmp=
+  tmp= ac_tmp=
   trap 'exit_status=$?
-  { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status
+  : "${ac_tmp:=$tmp}"
+  { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status
 ' 0
   trap 'as_fn_exit 1' 1 2 13 15
 }
@@ -15757,12 +15803,13 @@
 
 {
   tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
-  test -n "$tmp" && test -d "$tmp"
+  test -d "$tmp"
 }  ||
 {
   tmp=./conf$$-$RANDOM
   (umask 077 && mkdir "$tmp")
-} || as_fn_error "cannot create a temporary directory in ." "$LINENO" 5
+} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5
+ac_tmp=$tmp
 
 # Set up the scripts for CONFIG_FILES section.
 # No need to generate them if there are no CONFIG_FILES.
@@ -15796,24 +15843,24 @@
 fi
 ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`
 if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
-  ac_cs_awk_cr='\r'
+  ac_cs_awk_cr='\\r'
 else
   ac_cs_awk_cr=$ac_cr
 fi
 
-echo 'BEGIN {' >"$tmp/subs1.awk" &&
+echo 'BEGIN {' >"$ac_tmp/subs1.awk" &&
 _ACEOF
 
 # Create commands to substitute file output variables.
 {
   echo "cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1" &&
-  echo 'cat >>"\$tmp/subs1.awk" <<\\_ACAWK &&' &&
+  echo 'cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK &&' &&
   echo "$ac_subst_files" | sed 's/.*/F["&"]="$&"/' &&
   echo "_ACAWK" &&
   echo "_ACEOF"
 } >conf$$files.sh &&
 . ./conf$$files.sh ||
-  as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
+  as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
 rm -f conf$$files.sh
 
 {
@@ -15821,18 +15868,18 @@
   echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&
   echo "_ACEOF"
 } >conf$$subs.sh ||
-  as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
-ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'`
+  as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
+ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'`
 ac_delim='%!_!# '
 for ac_last_try in false false false false false :; do
   . ./conf$$subs.sh ||
-    as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
+    as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
 
   ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`
   if test $ac_delim_n = $ac_delim_num; then
     break
   elif $ac_last_try; then
-    as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
+    as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
   else
     ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
   fi
@@ -15840,7 +15887,7 @@
 rm -f conf$$subs.sh
 
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-cat >>"\$tmp/subs1.awk" <<\\_ACAWK &&
+cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK &&
 _ACEOF
 sed -n '
 h
@@ -15888,7 +15935,7 @@
 rm -f conf$$subs.awk
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 _ACAWK
-cat >>"\$tmp/subs1.awk" <<_ACAWK &&
+cat >>"\$ac_tmp/subs1.awk" <<_ACAWK &&
   for (key in S) S_is_set[key] = 1
   FS = ""
   \$ac_cs_awk_pipe_init
@@ -15926,21 +15973,29 @@
   sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"
 else
   cat
-fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \
-  || as_fn_error "could not setup config files machinery" "$LINENO" 5
-_ACEOF
-
-# VPATH may cause trouble with some makes, so we remove $(srcdir),
-# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
+fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \
+  || as_fn_error $? "could not setup config files machinery" "$LINENO" 5
+_ACEOF
+
+# VPATH may cause trouble with some makes, so we remove sole $(srcdir),
+# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and
 # trailing colons and then remove the whole line if VPATH becomes empty
 # (actually we leave an empty line to preserve line numbers).
 if test "x$srcdir" = x.; then
-  ac_vpsub='/^[	 ]*VPATH[	 ]*=/{
-s/:*\$(srcdir):*/:/
-s/:*\${srcdir}:*/:/
-s/:*@srcdir@:*/:/
-s/^\([^=]*=[	 ]*\):*/\1/
+  ac_vpsub='/^[	 ]*VPATH[	 ]*=[	 ]*/{
+h
+s///
+s/^/:/
+s/[	 ]*$/:/
+s/:\$(srcdir):/:/g
+s/:\${srcdir}:/:/g
+s/:@srcdir@:/:/g
+s/^:*//
 s/:*$//
+x
+s/\(=[	 ]*\).*/\1/
+G
+s/\n//
 s/^[^=]*=[	 ]*$//
 }'
 fi
@@ -15952,7 +16007,7 @@
 # No need to generate them if there are no CONFIG_HEADERS.
 # This happens for instance with `./config.status Makefile'.
 if test -n "$CONFIG_HEADERS"; then
-cat >"$tmp/defines.awk" <<\_ACAWK ||
+cat >"$ac_tmp/defines.awk" <<\_ACAWK ||
 BEGIN {
 _ACEOF
 
@@ -15964,11 +16019,11 @@
 # handling of long lines.
 ac_delim='%!_!# '
 for ac_last_try in false false :; do
-  ac_t=`sed -n "/$ac_delim/p" confdefs.h`
-  if test -z "$ac_t"; then
+  ac_tt=`sed -n "/$ac_delim/p" confdefs.h`
+  if test -z "$ac_tt"; then
     break
   elif $ac_last_try; then
-    as_fn_error "could not make $CONFIG_HEADERS" "$LINENO" 5
+    as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5
   else
     ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
   fi
@@ -16053,7 +16108,7 @@
 _ACAWK
 _ACEOF
 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-  as_fn_error "could not setup config headers machinery" "$LINENO" 5
+  as_fn_error $? "could not setup config headers machinery" "$LINENO" 5
 fi # test -n "$CONFIG_HEADERS"
 
 
@@ -16066,7 +16121,7 @@
   esac
   case $ac_mode$ac_tag in
   :[FHL]*:*);;
-  :L* | :C*:*) as_fn_error "invalid tag \`$ac_tag'" "$LINENO" 5;;
+  :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;;
   :[FH]-) ac_tag=-:-;;
   :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
   esac
@@ -16085,7 +16140,7 @@
     for ac_f
     do
       case $ac_f in
-      -) ac_f="$tmp/stdin";;
+      -) ac_f="$ac_tmp/stdin";;
       *) # Look for the file first in the build tree, then in the source tree
 	 # (if the path is not absolute).  The absolute path cannot be DOS-style,
 	 # because $ac_f cannot contain `:'.
@@ -16094,7 +16149,7 @@
 	   [\\/$]*) false;;
 	   *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
 	   esac ||
-	   as_fn_error "cannot find input file: \`$ac_f'" "$LINENO" 5;;
+	   as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;;
       esac
       case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
       as_fn_append ac_file_inputs " '$ac_f'"
@@ -16120,8 +16175,8 @@
     esac
 
     case $ac_tag in
-    *:-:* | *:-) cat >"$tmp/stdin" \
-      || as_fn_error "could not create $ac_file" "$LINENO" 5 ;;
+    *:-:* | *:-) cat >"$ac_tmp/stdin" \
+      || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;;
     esac
     ;;
   esac
@@ -16253,26 +16308,27 @@
 "
 eval sed \"\$ac_sed_extra\" "$ac_file_inputs" |
 if $ac_cs_awk_getline; then
-  $AWK -f "$tmp/subs.awk"
-else
-  $AWK -f "$tmp/subs.awk" | $SHELL
-fi >$tmp/out \
-  || as_fn_error "could not create $ac_file" "$LINENO" 5
+  $AWK -f "$ac_tmp/subs.awk"
+else
+  $AWK -f "$ac_tmp/subs.awk" | $SHELL
+fi \
+  >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5
 
 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
-  { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } &&
-  { ac_out=`sed -n '/^[	 ]*datarootdir[	 ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } &&
+  { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } &&
+  { ac_out=`sed -n '/^[	 ]*datarootdir[	 ]*:*=/p' \
+      "$ac_tmp/out"`; test -z "$ac_out"; } &&
   { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir'
-which seems to be undefined.  Please make sure it is defined." >&5
+which seems to be undefined.  Please make sure it is defined" >&5
 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
-which seems to be undefined.  Please make sure it is defined." >&2;}
-
-  rm -f "$tmp/stdin"
+which seems to be undefined.  Please make sure it is defined" >&2;}
+
+  rm -f "$ac_tmp/stdin"
   case $ac_file in
-  -) cat "$tmp/out" && rm -f "$tmp/out";;
-  *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";;
+  -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";;
+  *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";;
   esac \
-  || as_fn_error "could not create $ac_file" "$LINENO" 5
+  || as_fn_error $? "could not create $ac_file" "$LINENO" 5
  ;;
   :H)
   #
@@ -16281,21 +16337,21 @@
   if test x"$ac_file" != x-; then
     {
       $as_echo "/* $configure_input  */" \
-      && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs"
-    } >"$tmp/config.h" \
-      || as_fn_error "could not create $ac_file" "$LINENO" 5
-    if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then
+      && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs"
+    } >"$ac_tmp/config.h" \
+      || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+    if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then
       { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5
 $as_echo "$as_me: $ac_file is unchanged" >&6;}
     else
       rm -f "$ac_file"
-      mv "$tmp/config.h" "$ac_file" \
-	|| as_fn_error "could not create $ac_file" "$LINENO" 5
+      mv "$ac_tmp/config.h" "$ac_file" \
+	|| as_fn_error $? "could not create $ac_file" "$LINENO" 5
     fi
   else
     $as_echo "/* $configure_input  */" \
-      && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \
-      || as_fn_error "could not create -" "$LINENO" 5
+      && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \
+      || as_fn_error $? "could not create -" "$LINENO" 5
   fi
  ;;
 
@@ -16332,7 +16388,7 @@
 ac_clean_files=$ac_clean_files_save
 
 test $ac_write_fail = 0 ||
-  as_fn_error "write failure creating $CONFIG_STATUS" "$LINENO" 5
+  as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5
 
 
 # configure is writing to config.log, and then calls config.status.
@@ -16353,7 +16409,7 @@
   exec 5>>config.log
   # Use ||, not &&, to avoid exiting from the if with $? = 1, which
   # would make configure fail if this is the last instruction.
-  $ac_cs_success || as_fn_exit $?
+  $ac_cs_success || as_fn_exit 1
 fi
 if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
--- a/configure.in	Thu Oct 14 16:21:40 2010 +0900
+++ b/configure.in	Thu Oct 28 19:57:59 2010 +0900
@@ -869,7 +869,7 @@
 fi
 
 AC_MSG_CHECKING([for -znocombreloc])
-AC_LINK_IFELSE([main(){return 0;}],
+AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
   [AC_MSG_RESULT(yes)],
   LDFLAGS=$late_LDFLAGS
   [AC_MSG_RESULT(no)])
@@ -1491,15 +1491,15 @@
 if test "${with_ns}" != no; then
   if test "${opsys}" = darwin; then
      NS_IMPL_COCOA=yes
-     ns_appdir=`pwd`/nextstep/Emacs.app/
-     ns_appbindir=${ns_appdir}Contents/MacOS/
-     ns_appresdir=${ns_appdir}Contents/Resources
+     ns_appdir=`pwd`/nextstep/Emacs.app
+     ns_appbindir=${ns_appdir}/Contents/MacOS/
+     ns_appresdir=${ns_appdir}/Contents/Resources
      ns_appsrc=${srcdir}/nextstep/Cocoa/Emacs.base
   elif test -f $GNUSTEP_CONFIG_FILE; then
      NS_IMPL_GNUSTEP=yes
-     ns_appdir=`pwd`/nextstep/Emacs.app/
+     ns_appdir=`pwd`/nextstep/Emacs.app
      ns_appbindir=${ns_appdir}
-     ns_appresdir=${ns_appdir}Resources
+     ns_appresdir=${ns_appdir}/Resources
      ns_appsrc=${srcdir}/nextstep/GNUstep/Emacs.base
      dnl FIXME sourcing this several times in subshells seems inefficient.
      GNUSTEP_SYSTEM_HEADERS="$(. $GNUSTEP_CONFIG_FILE; echo $GNUSTEP_SYSTEM_HEADERS)"
@@ -1546,7 +1546,7 @@
   fi
   ns_frag=$srcdir/src/ns.mk
   NS_OBJ="nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o fontset.o fringe.o image.o"
-  NS_SUPPORT="\${lispsource}emacs-lisp/easymenu.elc \${lispsource}term/ns-win.elc"
+  NS_SUPPORT="\${lispsource}/emacs-lisp/easymenu.elc \${lispsource}/term/ns-win.elc"
 fi
 CFLAGS="$tmp_CFLAGS"
 CPPFLAGS="$tmp_CPPFLAGS"
@@ -3260,9 +3260,9 @@
 	     Otherwise, Emacs expects to use version 10.])
 
   if test "$USE_X_TOOLKIT" = "none"; then
-    OLDXMENU="\${oldXMenudir}libXMenu11.a"
+    OLDXMENU="\${oldXMenudir}/libXMenu11.a"
   else
-    OLDXMENU="\${lwlibdir}liblw.a"
+    OLDXMENU="\${lwlibdir}/liblw.a"
   fi
   LIBXMENU="\$(OLDXMENU)"
   LIBX_OTHER="\$(LIBXT) \$(LIBX_EXTRA)"
@@ -3468,7 +3468,7 @@
   AC_DEFINE(HAVE_WINDOW_SYSTEM, 1, [Define if you have a window system.])
   AC_DEFINE(HAVE_MOUSE, 1, [Define if you have mouse support.])
   MOUSE_SUPPORT="\$(REAL_MOUSE_SUPPORT)"
-  TOOLTIP_SUPPORT="\${lispsource}mouse.elc"
+  TOOLTIP_SUPPORT="\${lispsource}/mouse.elc"
 
   WINDOW_SUPPORT="\$(BASE_WINDOW_SUPPORT)"
   test "$HAVE_X_WINDOWS" = "yes" && \
@@ -3712,7 +3712,7 @@
 echo "  Does Emacs use -ldbus?                                  ${HAVE_DBUS}"
 echo "  Does Emacs use -lgconf?                                 ${HAVE_GCONF}"
 echo "  Does Emacs use -lselinux?                               ${HAVE_LIBSELINUX}"
-echo "  Does Emacs use -lgnutls (BROKEN)?                       ${HAVE_GNUTLS}"
+echo "  Does Emacs use -lgnutls?                       	        ${HAVE_GNUTLS}"
 echo "  Does Emacs use -lxml2?                                  ${HAVE_LIBXML2}"
 
 echo "  Does Emacs use -lfreetype?                              ${HAVE_FREETYPE}"
--- a/doc/lispref/ChangeLog	Thu Oct 14 16:21:40 2010 +0900
+++ b/doc/lispref/ChangeLog	Thu Oct 28 19:57:59 2010 +0900
@@ -1,3 +1,26 @@
+2010-10-28  Glenn Morris  <rgm@gnu.org>
+
+	* Makefile.in (elisp.dvi, elisp.pdf): Also include $emacsdir.
+
+2010-10-24  Eli Zaretskii  <eliz@gnu.org>
+
+	* display.texi (Window Systems): Deprecate use of window-system as
+	a predicate.
+
+2010-10-23  Glenn Morris  <rgm@gnu.org>
+
+	* help.texi (Documentation Basics): Remove mentions of digest-doc and
+	sorted-doc.
+
+2010-10-15  Eli Zaretskii  <eliz@gnu.org>
+
+	* os.texi (Dynamic Libraries): New node, with slightly modified
+	text deleted from "Image Formats".
+	(System Interface): Add @menu entry for "Dynamic Libraries".
+
+	* display.texi (Image Formats): Remove description of
+	image-library-alist.  (Renamed in revno 101949.)
+
 2010-10-12  Glenn Morris  <rgm@gnu.org>
 
 	* book-spine.texinfo: Rename to book-spine.texi.
--- a/doc/lispref/Makefile.in	Thu Oct 14 16:21:40 2010 +0900
+++ b/doc/lispref/Makefile.in	Thu Oct 28 19:57:59 2010 +0900
@@ -109,7 +109,7 @@
 	$(MAKEINFO) -o $@ $<
 
 elisp.dvi: $(srcs)
-	$(TEXI2DVI) -I $(srcdir) -I $(texinfodir) $<
+	$(TEXI2DVI) -I $(srcdir) -I $(texinfodir) -I $(emacsdir) $<
 
 elisp.html: $(srcs)
 	$(MAKEINFO) --html -o $@ $<
@@ -118,7 +118,7 @@
 	$(DVIPS) -o $@ $<
 
 elisp.pdf: $(srcs)
-	$(TEXI2PDF) -I $(srcdir) -I $(texinfodir) $<
+	$(TEXI2PDF) -I $(srcdir) -I $(texinfodir) -I $(emacsdir) $<
 
 .PHONY: mostlyclean clean distclean maintainer-clean infoclean
 
--- a/doc/lispref/display.texi	Thu Oct 14 16:21:40 2010 +0900
+++ b/doc/lispref/display.texi	Thu Oct 28 19:57:59 2010 +0900
@@ -4055,10 +4055,12 @@
 
   Emacs can display a number of different image formats; some of them
 are supported only if particular support libraries are installed on
-your machine.  In some environments, Emacs can load image
-libraries on demand; if so, the variable @code{image-library-alist}
-can be used to modify the set of known names for these dynamic
-libraries (though it is not possible to add new image formats).
+your machine.  In some environments, Emacs can load support libraries
+on demand; if so, the variable @code{dynamic-library-alist}
+(@pxref{Dynamic Libraries}) can be used to modify the set of known
+names for these dynamic libraries (though it is not possible to add
+new image formats).  Note that image types @code{pbm} and @code{xbm}
+do not depend on external libraries and are always available in Emacs.
 
   The supported image formats include XBM, XPM (this requires the
 libraries @code{libXpm} version 3.4k and @code{libz}), GIF (requiring
@@ -4082,24 +4084,6 @@
 @code{image-type-available-p}.
 @end defvar
 
-@defvar image-library-alist
-This in an alist of image types vs external libraries needed to
-display them.
-
-Each element is a list @code{(@var{image-type} @var{library}...)},
-where the car is a supported image format from @code{image-types}, and
-the rest are strings giving alternate filenames for the corresponding
-external libraries to load.
-
-Emacs tries to load the libraries in the order they appear on the
-list; if none is loaded, the running session of Emacs won't support
-the image type.  @code{pbm} and @code{xbm} don't need to be listed;
-they're always supported.
-
-This variable is ignored if the image libraries are statically linked
-into Emacs.
-@end defvar
-
 @defun image-type-available-p type
 This function returns non-@code{nil} if image type @var{type} is
 available, i.e., if images of this type can be loaded and displayed in
@@ -5944,6 +5928,14 @@
 one documented for the variable @code{window-system} above.
 @end defun
 
+  Do @emph{not} use @code{window-system} and
+@code{initial-window-system} as predicates or boolean flag variables,
+if you want to write code that works differently on text terminals and
+graphic displays.  That is because @code{window-system} is not a good
+indicator of Emacs capabilities on a given display type.  Instead, use
+@code{display-graphic-p} or any of the other @code{display-*-p}
+predicates described in @ref{Display Feature Testing}.
+
 @defvar window-setup-hook
 This variable is a normal hook which Emacs runs after handling the
 initialization files.  Emacs runs this hook after it has completed
--- a/doc/lispref/frames.texi	Thu Oct 14 16:21:40 2010 +0900
+++ b/doc/lispref/frames.texi	Thu Oct 28 19:57:59 2010 +0900
@@ -1748,6 +1748,15 @@
 value is not significant.
 @end defun
 
+@defun frame-pointer-visible-p &optional frame
+This predicate function returns non-@code{nil} if the mouse pointer
+displayed on @var{frame} is visible; otherwise it returns @code{nil}.
+@var{frame} omitted or @code{nil} means the selected frame.  This is
+useful when @code{make-pointer-invisible} is set to @code{t}: it
+allows to know if the pointer has been hidden.
+@xref{Mouse Avoidance,,,emacs}.
+@end defun
+
 @need 3000
 
 @node Pop-Up Menus
--- a/doc/lispref/help.texi	Thu Oct 14 16:21:40 2010 +0900
+++ b/doc/lispref/help.texi	Thu Oct 28 19:57:59 2010 +0900
@@ -1,7 +1,8 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
 @c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1998, 1999, 2001,
-@c   2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010  Free Software Foundation, Inc.
+@c   2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+@c   Free Software Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 @setfilename ../../info/help
 @node Documentation, Files, Modes, Top
@@ -106,12 +107,6 @@
 documentation string from the appropriate file; this is transparent to
 the user.
 
-@c Wordy to prevent overfull hbox.  --rjc 15mar92
-  The @file{emacs/lib-src} directory contains two utilities that you can
-use to print nice-looking hardcopy for the file
-@file{emacs/etc/DOC-@var{version}}.  These are @file{sorted-doc} and
-@file{digest-doc}.
-
 @node Accessing Documentation
 @section Access to Documentation Strings
 
@@ -701,6 +696,3 @@
 if the user types the help character again.
 @end defopt
 
-@ignore
-   arch-tag: ba36b4c2-e60f-49e2-bc25-61158fdcd815
-@end ignore
--- a/doc/lispref/os.texi	Thu Oct 14 16:21:40 2010 +0900
+++ b/doc/lispref/os.texi	Thu Oct 28 19:57:59 2010 +0900
@@ -37,6 +37,7 @@
 * X11 Keysyms::         Operating on key symbols for X Windows.
 * Batch Mode::          Running Emacs without terminal interaction.
 * Session Management::  Saving and restoring state with X Session Management.
+* Dynamic Libraries::   On-demand loading of support libraries.
 @end menu
 
 @node Starting Up
@@ -2186,6 +2187,57 @@
 @end group
 @end example
 
+@node Dynamic Libraries
+@section Dynamically Loaded Libraries
+@cindex dynamic libraries
+
+  A @dfn{dynamically loaded library} is a library that is loaded on
+demand, when its facilities are first needed.  Emacs supports such
+on-demand loading of support libraries for some of its features.
+
+@defvar dynamic-library-alist
+This is an alist of dynamic libraries and external library files
+implementing them.
+
+Each element is a list of the form
+@w{@code{(@var{library} @var{files}@dots{})}}, where the @code{car} is
+a symbol representing a supported external library, and the rest are
+strings giving alternate filenames for that library.
+
+Emacs tries to load the library from the files in the order they
+appear in the list; if none is found, the running session of Emacs
+won't have access to that library, and the features that depend on the
+library will be unavailable.
+
+Image support on some platforms uses this facility.  Here's an example
+of setting this variable for supporting images on MS-Windows:
+
+@lisp
+(setq dynamic-library-alist
+      '((xpm "libxpm.dll" "xpm4.dll" "libXpm-nox4.dll")
+        (png "libpng12d.dll" "libpng12.dll" "libpng.dll"
+	 "libpng13d.dll" "libpng13.dll")
+        (jpeg "jpeg62.dll" "libjpeg.dll" "jpeg-62.dll" "jpeg.dll")
+        (tiff "libtiff3.dll" "libtiff.dll")
+        (gif "giflib4.dll" "libungif4.dll" "libungif.dll")
+        (svg "librsvg-2-2.dll")
+        (gdk-pixbuf "libgdk_pixbuf-2.0-0.dll")
+        (glib "libglib-2.0-0.dll")
+	(gobject "libgobject-2.0-0.dll")))
+@end lisp
+
+Note that image types @code{pbm} and @code{xbm} do not need entries in
+this variable because they do not depend on external libraries and are
+always available in Emacs.
+
+Also note that this variable is not meant to be a generic facility for
+accessing external libraries; only those already known by Emacs can
+be loaded through it.
+
+This variable is ignored if the given @var{library} is statically
+linked into Emacs.
+@end defvar
+
 @ignore
    arch-tag: 8378814a-30d7-467c-9615-74a80b9988a7
 @end ignore
--- a/doc/misc/ChangeLog	Thu Oct 14 16:21:40 2010 +0900
+++ b/doc/misc/ChangeLog	Thu Oct 28 19:57:59 2010 +0900
@@ -1,3 +1,79 @@
+2010-10-28  Glenn Morris  <rgm@gnu.org>
+
+	* Makefile.in (MAKEINFO, ENVADD): Add $emacsdir to include path.
+	(($(infodir)/calc, calc.dvi, calc.pdf): Depend on emacsver.texi.
+	($(infodir)/efaq): Remove -I option now in $MAKEINFO.
+
+2010-10-25  Daiki Ueno  <ueno@unixuser.org>
+
+	* epa.texi (Mail-mode integration): Add alternative key bindings
+	for epa-mail commands; escape comma.
+	Don't use the word "PGP", since it is a non-free program.
+
+2010-10-24  Jay Belanger  <jay.p.belanger@gmail.com>
+
+	* calc.texi:  Use emacsver.texi to determine Emacs version.
+
+2010-10-24  Juanma Barranquero  <lekktu@gmail.com>
+
+	* gnus.texi (Group Parameters, Buttons): Fix typos.
+
+2010-10-22  Tassilo Horn  <tassilo@member.fsf.org>
+
+	* gnus.texi (Subscription Commands): Mention that you can also
+	subscribe to new groups via the Server buffer, which is probably more
+	convenient when subscribing to many groups.
+
+2010-10-21  Julien Danjou  <julien@danjou.info>
+
+	* message.texi (Message Headers): Allow message-default-headers to be a
+	function.
+
+2010-10-21  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* gnus-news.texi: Mention new archive defaults.
+
+2010-10-21  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+	* gnus.texi (RSS): Remove nnrss-wash-html-in-text-plain-parts.
+
+2010-10-20  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* gnus.texi (HTML): Document the function value of
+	gnus-blocked-images.
+	(Article Washing): shr and gnus-w3m, not the direct function names.
+
+2010-10-20  Julien Danjou  <julien@danjou.info>
+
+	* emacs-mime.texi (Flowed text): Add a note about mml-enable-flowed
+	variable.
+
+2010-10-19  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* gnus.texi (Customizing the IMAP Connection): The port strings are
+	strings.
+	(Document Groups): Mention git.
+
+2010-10-18  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* gnus-coding.texi (Gnus Maintainance Guide): Update to mention Emacs
+	bzr/Gnus git sync.
+
+2010-10-15  Eli Zaretskii  <eliz@gnu.org>
+
+	* auth.texi (GnuPG and EasyPG Assistant Configuration): Fix last
+	change.
+
+2010-10-13  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* auth.texi (GnuPG and EasyPG Assistant Configuration): Fix up the
+	@item syntax for in-Emacs makeinfo.
+
+2010-10-13  Teodor Zlatanov  <tzz@lifelogs.com>
+
+	* auth.texi (GnuPG and EasyPG Assistant Configuration): Fix syntax and
+	trim sentence.
+
 2010-10-12  Daiki Ueno  <ueno@unixuser.org>
 
 	* epa.texi (Caching Passphrases):
--- a/doc/misc/Makefile.in	Thu Oct 14 16:21:40 2010 +0900
+++ b/doc/misc/Makefile.in	Thu Oct 28 19:57:59 2010 +0900
@@ -37,12 +37,12 @@
 ## Note that the setfilename command in the .texi files assumes this.
 infodir=../../info
 ## Directory with emacsver.texi.
-## Currently only used by efaq; could be added to MAKEINFO.
+## Currently only used by efaq and calc.
 emacsdir = $(srcdir)/../emacs
 
 # The makeinfo program is part of the Texinfo distribution.
 # Use --force so that it generates output even if there are errors.
-MAKEINFO = makeinfo --force
+MAKEINFO = makeinfo --force -I$(emacsdir)
 
 # Also add new entries to INFO_FILES in the top-level Makefile.in.
 INFO_TARGETS = \
@@ -198,7 +198,7 @@
 TEXI2DVI = texi2dvi
 TEXI2PDF = texi2pdf
 
-ENVADD = TEXINPUTS="$(srcdir):$(TEXINPUTS)" MAKEINFO="$(MAKEINFO) -I$(srcdir)"
+ENVADD = TEXINPUTS="$(srcdir):$(emacsdir):$(TEXINPUTS)" MAKEINFO="$(MAKEINFO) -I$(srcdir)"
 
 mkinfodir = @cd ${srcdir}; test -d ${infodir} || mkdir ${infodir} || test -d ${infodir}
 
@@ -244,12 +244,12 @@
 	$(ENVADD) $(TEXI2PDF) $<
 
 calc : $(infodir)/calc
-$(infodir)/calc: calc.texi
+$(infodir)/calc: calc.texi $(emacsdir)/emacsver.texi
 	$(mkinfodir)
 	cd $(srcdir); $(MAKEINFO) $<
-calc.dvi: ${srcdir}/calc.texi
+calc.dvi: ${srcdir}/calc.texi $(emacsdir)/emacsver.texi
 	$(ENVADD) $(TEXI2DVI) $<
-calc.pdf: ${srcdir}/calc.texi
+calc.pdf: ${srcdir}/calc.texi $(emacsdir)/emacsver.texi
 	$(ENVADD) $(TEXI2PDF) $<
 
 ccmode : $(infodir)/ccmode
@@ -381,7 +381,7 @@
 efaq : $(infodir)/efaq
 $(infodir)/efaq: faq.texi $(emacsdir)/emacsver.texi
 	$(mkinfodir)
-	cd $(srcdir); $(MAKEINFO) -I $(emacsdir) $<
+	cd $(srcdir); $(MAKEINFO) $<
 faq.dvi: ${srcdir}/faq.texi $(emacsdir)/emacsver.texi
 	$(ENVADD) $(TEXI2DVI) $<
 faq.pdf: ${srcdir}/faq.texi $(emacsdir)/emacsver.texi
--- a/doc/misc/auth.texi	Thu Oct 14 16:21:40 2010 +0900
+++ b/doc/misc/auth.texi	Thu Oct 28 19:57:59 2010 +0900
@@ -177,8 +177,8 @@
 
 If you don't customize @code{auth-sources}, you'll have to live with
 the defaults: any host and any port are looked up in the netrc
-file @code{~/.authinfo.gpg}, which is a GnuPG encrypted file.
-@xref{GnuPG and EasyPG Assistant Configuration}.
+file @code{~/.authinfo.gpg}, which is a GnuPG encrypted file
+(@pxref{GnuPG and EasyPG Assistant Configuration}).
 
 The simplest working netrc line example is one without a port.
 
@@ -271,9 +271,8 @@
 reads @code{~/.authinfo.gpg}, which is a GnuPG encrypted file.
 
 In Emacs 23 or later there is an option @code{auto-encryption-mode} to
-automatically decrypt @code{*.gpg} files.  It is enabled by default so
-there is no setting is needed.  If you are using earlier versions of
-Emacs, you will need:
+automatically decrypt @code{*.gpg} files.  It is enabled by default.
+If you are using earlier versions of Emacs, you will need:
 
 @lisp
 (require 'epa-file)
@@ -282,14 +281,17 @@
 
 If you want your GnuPG passwords to be cached, set up @code{gpg-agent}
 or EasyPG Assitant
-@pxref{Caching Passphrases, , Caching Passphrases, epa}
+(@pxref{Caching Passphrases, , Caching Passphrases, epa}).
 
 To quick start, here are some questions:
 
 @enumerate
-@item Do you use GnuPG version 2 instead of GnuPG version 1?
-@item Do you use symmetric encryption rather than public key encryption?
-@item Do you want to use gpg-agent?
+@item
+Do you use GnuPG version 2 instead of GnuPG version 1?
+@item
+Do you use symmetric encryption rather than public key encryption?
+@item
+Do you want to use gpg-agent?
 @end enumerate
 
 Here are configurations depending on your answers:
@@ -306,8 +308,8 @@
 @item No @tab No @tab No @tab You can't, without gpg-agent.
 @end multitable
 
-To set up gpg-agent, follow the instruction in GnuPG manual.
-@pxref{Invoking GPG-AGENT, , Invoking GPG-AGENT, gnupg}.
+To set up gpg-agent, follow the instruction in GnuPG manual
+(@pxref{Invoking GPG-AGENT, , Invoking GPG-AGENT, gnupg}).
 
 To set up elisp passphrase cache, set
 @code{epa-file-cache-passphrase-for-symmetric-encryption}.
--- a/doc/misc/calc.texi	Thu Oct 14 16:21:40 2010 +0900
+++ b/doc/misc/calc.texi	Thu Oct 28 19:57:59 2010 +0900
@@ -7,6 +7,8 @@
 @setchapternewpage odd
 @comment %**end of header (This is for running Texinfo on a region.)
 
+@include emacsver.texi
+
 @c The following macros are used for conditional output for single lines.
 @c @texline foo
 @c    `foo' will appear only in TeX output
@@ -88,7 +90,8 @@
 This file documents Calc, the GNU Emacs calculator.
 @end ifinfo
 @ifnotinfo
-This file documents Calc, the GNU Emacs calculator, included with GNU Emacs 23.1.
+This file documents Calc, the GNU Emacs calculator, included with 
+GNU Emacs @value{EMACSVER}.
 @end ifnotinfo
 
 Copyright @copyright{} 1990, 1991, 2001, 2002, 2003, 2004,
@@ -36582,7 +36585,3 @@
 
 @bye
 
-
-@ignore
-   arch-tag: 77a71809-fa4d-40be-b2cc-da3e8fb137c0
-@end ignore
--- a/doc/misc/emacs-mime.texi	Thu Oct 14 16:21:40 2010 +0900
+++ b/doc/misc/emacs-mime.texi	Thu Oct 28 19:57:59 2010 +0900
@@ -1040,6 +1040,10 @@
 newline characters are not present in the buffer, no flow encoding
 occurs.
 
+You can customize the value of the @code{mml-enable-flowed} variable
+to enable or disable the flowed encoding usage when newline
+characteres are present in the buffer.
+
 On decoding flowed text, lines with soft newline characters are filled
 together and wrapped after the column decided by
 @code{fill-flowed-display-column}.  The default is to wrap after
--- a/doc/misc/epa.texi	Thu Oct 14 16:21:40 2010 +0900
+++ b/doc/misc/epa.texi	Thu Oct 28 19:57:59 2010 +0900
@@ -306,14 +306,14 @@
 @section Mail-mode integration
 
 EasyPG Assistant provides a minor mode @code{epa-mail-mode} to help
-user compose inline PGP messages.  Inline PGP is a traditional style
-of sending signed/encrypted emails by embedding raw OpenPGP blobs
-inside a message body, not using modern MIME format.
+user compose inline OpenPGP messages.  Inline OpenPGP is a traditional
+style of sending signed/encrypted emails by embedding raw OpenPGP
+blobs inside a message body, not using modern MIME format.
 
-NOTE: Inline PGP is not recommended and you should consider to use
+NOTE: Inline OpenPGP is not recommended and you should consider to use
 PGP/MIME.  See
 @uref{http://josefsson.org/inline-openpgp-considered-harmful.html,
-Inline PGP in E-mail is bad, Mm'kay?}.
+Inline OpenPGP in E-mail is bad@comma{} Mm'kay?}.
 
 @noindent
 Once @code{epa-mail-mode} is enabled, the following keys are assigned.
@@ -321,22 +321,26 @@
 interface.  Try @kbd{M-x customize-variable epa-global-mail-mode}.
 
 @table @kbd
-@item C-c C-e d
+@item C-c C-e C-d and C-c C-e d
+@kindex @kbd{C-c C-e C-d}
 @kindex @kbd{C-c C-e d}
 @findex epa-mail-decrypt
 Decrypt OpenPGP armors in the current buffer.
 
-@item C-c C-e v
+@item C-c C-e C-v and C-c C-e v
+@kindex @kbd{C-c C-e C-v}
 @kindex @kbd{C-c C-e v}
 @findex epa-mail-verify
 Verify OpenPGP cleartext signed messages in the current buffer.
 
-@item C-c C-e s
+@item C-c C-e C-s and C-c C-e s
+@kindex @kbd{C-c C-e C-s}
 @kindex @kbd{C-c C-e s}
 @findex epa-mail-sign
 Compose a signed message from the current buffer.
 
-@item C-c C-e e
+@item C-c C-e C-e and C-c C-e e
+@kindex @kbd{C-c C-e C-e}
 @kindex @kbd{C-c C-e e}
 @findex epa-mail-encrypt
 Compose an encrypted message from the current buffer.
--- a/doc/misc/gnus-coding.texi	Thu Oct 14 16:21:40 2010 +0900
+++ b/doc/misc/gnus-coding.texi	Thu Oct 28 19:57:59 2010 +0900
@@ -288,14 +288,21 @@
 
 With the inclusion of Gnus 5.10, Miles Bader has set up an Emacs-Gnus
 gateway to ensure the bug fixes from Emacs CVS are propagated to Gnus
-CVS semi-automatically.  These bug fixes are installed on the stable
-branch and on the trunk.  Basically the idea is that the gateway will
-cause all common files in Emacs and Gnus v5-10 to be identical except
-when there's a very good reason (e.g., the Gnus version string in Emacs
-says @samp{5.11}, but the v5-10 version string remains @samp{5.10.x}).
-Furthermore, all changes in these files in either Emacs or the v5-10
-branch will be installed into the Gnus CVS trunk, again except where
-there's a good reason.
+CVS semi-automatically.
+
+After Emacs moved to bzr and Gnus moved to git, Katsumi Yamaoka has
+taken over the chore of keeping Emacs and Gnus in sync.  In general,
+changes made to one repository will usually be replicated in the other
+within a few days.
+
+Basically the idea is that the gateway will cause all common files in
+Emacs and Gnus v5-13 to be identical except when there's a very good
+reason (e.g., the Gnus version string in Emacs says @samp{5.11}, but
+the v5-13 version string remains @samp{5.13.x}).  Furthermore, all
+changes in these files in either Emacs or the v5-13 branch will be
+installed into the Gnus git trunk, again except where there's a good
+reason.
+
 @c (typically so far the only exception has been that the changes
 @c already exist in the trunk in modified form).
 Because of this, when the next major version of Gnus will be included in
@@ -311,9 +318,9 @@
 new @file{encrypt.el}), you should probably make the change in the Emacs
 tree, and it will show up in the Gnus tree a few days later.
 
-If you don't have Emacs CVS access (or it's inconvenient), you can
+If you don't have Emacs bzr access (or it's inconvenient), you can
 change such a file in the v5-10 branch, and it should propagate to Emacs
-CVS -- however, it will get some extra scrutiny (by Miles) to see if the
+bzr -- however, it will get some extra scrutiny (by Miles) to see if the
 changes are possibly controversial and need discussion on the mailing
 list.  Many changes are obvious bug-fixes however, so often there won't
 be any problem.
@@ -321,12 +328,12 @@
 @item
 If it's to a Gnus file, and it's important enough that it should be part
 of Emacs and the v5-10 branch, then you can make the change on the v5-10
-branch, and it will go into Emacs CVS and the Gnus CVS trunk (a few days
+branch, and it will go into Emacs bzr and the Gnus git trunk (a few days
 later).  The most prominent examples for such changes are bug-fixed
 including improvements on the documentation.
 
 If you know that there will be conflicts (perhaps because the affected
-source code is different in v5-10 and the Gnus CVS trunk), then you can
+source code is different in v5-10 and the Gnus git trunk), then you can
 install your change in both places, and when I try to sync them, there
 will be a conflict -- however, since in most such cases there would be a
 conflict @emph{anyway}, it's often easier for me to resolve it simply if
@@ -338,9 +345,6 @@
 change on the Gnus Git trunk and it goes into Emacs a few years
 later... :-)
 
-With the new Git repository, we'll probably set up something to
-automatically synchronize with Emacs when possible.  CVS was much less
-powerful for this kind of synchronization.
 @end itemize
 
 Of course in any case, if you just can't wait for me to sync your
--- a/doc/misc/gnus-news.texi	Thu Oct 14 16:21:40 2010 +0900
+++ b/doc/misc/gnus-news.texi	Thu Oct 28 19:57:59 2010 +0900
@@ -124,6 +124,9 @@
 
 @itemize @bullet
 
+@item There's now only one variable that determines how @acronym{HTML}
+is rendered: @code{mm-text-html-renderer}.
+
 @item Gnus now supports sticky article buffers.  Those are article buffers
 that are not reused when you select another article.  @xref{Sticky
 Articles}.
@@ -221,6 +224,9 @@
 @item Changes in Message mode
 
 @itemize @bullet
+@item Gnus now defaults to saving all outgoing messages in per-month
+nnfolder archives.
+
 @item Gnus now supports the ``hashcash'' client puzzle anti-spam mechanism.
 Use @code{(setq message-generate-hashcash t)} to enable.
 @xref{Hashcash}.
--- a/doc/misc/gnus.texi	Thu Oct 14 16:21:40 2010 +0900
+++ b/doc/misc/gnus.texi	Thu Oct 28 19:57:59 2010 +0900
@@ -2211,6 +2211,12 @@
 @section Subscription Commands
 @cindex subscription
 
+The following commands allow for managing your subscriptions in the
+Group buffer.  If you want to subscribe to many groups, it's probably
+more convenient to go to the @ref{Server Buffer}, and choose the
+server there using @kbd{RET} or @kbd{SPC}.  Then you'll have the
+commands listed in @ref{Browse Foreign Server} at hand.
+
 @table @kbd
 
 @item S t
@@ -2409,6 +2415,9 @@
 All groups with a level less than or equal to
 @code{gnus-group-default-list-level} will be listed in the group buffer
 by default.
+This variable can also be a function.  In that case, that function will
+be called and the result will be used as value.
+
 
 @vindex gnus-group-list-inactive-groups
 If @code{gnus-group-list-inactive-groups} is non-@code{nil}, non-active
@@ -3085,8 +3094,8 @@
 Top, sieve, Emacs Sieve}.
 
 @item (agent parameters)
-If the agent has been enabled, you can set any of the its parameters
-to control the behavior of the agent in individual groups. See Agent
+If the agent has been enabled, you can set any of its parameters to
+control the behavior of the agent in individual groups.  See Agent
 Parameters in @ref{Category Syntax}.  Most users will choose to set
 agent parameters in either an agent category or group topic to
 minimize the configuration effort.
@@ -9803,19 +9812,16 @@
 the charset defined in @code{gnus-summary-show-article-charset-alist}
 (@pxref{Paging the Article}) will be used.
 
-@vindex gnus-article-wash-function
 The default is to use the function specified by
 @code{mm-text-html-renderer} (@pxref{Display Customization, ,Display
 Customization, emacs-mime, The Emacs MIME Manual}) to convert the
-@acronym{HTML}, but this is controlled by the
-@code{gnus-article-wash-function} variable.  Pre-defined functions you
-can use include:
-
-@table @code
-@item mm-shr
+@acronym{HTML}.  Pre-defined functions you can use include:
+
+@table @code
+@item shr
 Use Gnus simple html renderer.
 
-@item gnus-article-html
+@item gnus-w3m
 Use Gnus rendered based on w3m.
 
 @item w3
@@ -12462,15 +12468,20 @@
 
 @item gnus-blocked-images
 @vindex gnus-blocked-images
-Images that have @acronym{URL}s that match this regexp won't be
-fetched and displayed.  For instance, do block all @acronym{URL}s that
-have the string ``ads'' in them, do the following:
+External images that have @acronym{URL}s that match this regexp won't
+be fetched and displayed.  For instance, do block all @acronym{URL}s
+that have the string ``ads'' in them, do the following:
 
 @lisp
 (setq gnus-blocked-images "ads")
 @end lisp
 
-The default is to block all external images.
+This can also be a function to be evaluated.  If so, it will be
+called with the group name as the parameter.  The default value is
+@code{gnus-block-private-groups}, which will return @samp{"."} for
+anything that isn't a newsgroup.  This means that no external images
+will be fetched as a result of reading mail, so that nobody can use
+web bugs (and the like) to track whether you've read email.
 
 @item gnus-html-cache-directory
 @vindex gnus-html-cache-directory
@@ -14872,7 +14883,7 @@
 
 @item nnimap-server-port
 If the server uses a non-standard port, that can be specified here.  A
-typical port would be @samp{imap} or @samp{imaps}.
+typical port would be @code{"imap"} or @code{"imaps"}.
 
 @item nnimap-stream
 How @code{nnimap} should connect to the server.  Possible values are:
@@ -17711,15 +17722,6 @@
 the feeds from local files in @code{nnrss-directory}.  You can use
 the command @code{nnrss-generate-download-script} to generate a
 download script using @command{wget}.
-
-@item nnrss-wash-html-in-text-plain-parts
-Non-@code{nil} means that @code{nnrss} renders text in @samp{text/plain}
-parts as @acronym{HTML}.  The function specified by the
-@code{mm-text-html-renderer} variable (@pxref{Display Customization,
-,Display Customization, emacs-mime, The Emacs MIME Manual}) will be used
-to render text.  If it is @code{nil}, which is the default, text will
-simply be folded.  Leave it @code{nil} if you prefer to see
-@samp{text/html} parts.
 @end table
 
 The following code may be helpful, if you want to show the description in
@@ -17969,6 +17971,10 @@
 @item lanl-gov-announce
 Announcement messages from LANL Gov Announce.
 
+@cindex git commit messages
+@item git
+@code{git} commit messages.
+
 @cindex forwarded messages
 @item rfc822-forward
 A message forwarded according to RFC822.
--- a/doc/misc/message.texi	Thu Oct 14 16:21:40 2010 +0900
+++ b/doc/misc/message.texi	Thu Oct 28 19:57:59 2010 +0900
@@ -1450,8 +1450,10 @@
 
 @item message-default-headers
 @vindex message-default-headers
-This string is inserted at the end of the headers in all message
-buffers.
+Header lines to be inserted in outgoing messages before you edit the
+message, so you can edit or delete their lines. If set to a string, it
+is directly inserted. If set to a function, it is called and its
+result is inserted.
 
 @item message-subject-re-regexp
 @vindex message-subject-re-regexp
--- a/etc/ChangeLog	Thu Oct 14 16:21:40 2010 +0900
+++ b/etc/ChangeLog	Thu Oct 28 19:57:59 2010 +0900
@@ -1,3 +1,41 @@
+2010-10-26  Glenn Morris  <rgm@gnu.org>
+
+	* images/README: Add (un)checked.xpm
+	* images/checked.xpm, images/unchecked.xpm: Add copyright.
+
+2010-10-24  Chong Yidong  <cyd@stupidchicken.com>
+
+	* images/checked.xpm:
+	* images/unchecked.xpm: New images.
+
+2010-10-24  Richard Stallman  <rms@gnu.org>
+
+	* DISTRIB: Update donation section.
+
+2010-10-24  Glenn Morris  <rgm@gnu.org>
+
+	* DISTRIB: Small updates.
+
+2010-10-19  Julien Danjou  <julien@danjou.info>
+
+	* tutorials/TUTORIAL: Don't mention mode-line end dashes.
+
+2010-10-16  Chong Yidong  <cyd@stupidchicken.com>
+
+	* themes: New directory for custom theme files, moved from lisp/.
+
+2010-10-14  Juanma Barranquero  <lekktu@gmail.com>
+
+	* tutorials/TUTORIAL.es: Fix typos.
+
+2010-10-13  Juanma Barranquero  <lekktu@gmail.com>
+
+	* NEWS: Mention `dynamic-library-alist'.
+
+2010-10-13  Glenn Morris  <rgm@gnu.org>
+
+	* NEXTSTEP: New file, extracted from ../nextstep/{AUTHORS,README}.
+
 2010-10-12  Glenn Morris  <rgm@gnu.org>
 
 	* TODO: Merge ../nextstep/FOR-RELEASE into this file.
--- a/etc/DISTRIB	Thu Oct 14 16:21:40 2010 +0900
+++ b/etc/DISTRIB	Thu Oct 28 19:57:59 2010 +0900
@@ -1,12 +1,9 @@
 						-*- text -*-
-For an order form for all Emacs and FSF distributions deliverable from
-the USA, see http://www.gnu.org/order/order.html.
-
-	   GNU Emacs availability information, October 2000
+            GNU Emacs availability information
 
 Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1995,
-  1998, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
-  Free Software Foundation, Inc.
+  1998, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
+  2010  Free Software Foundation, Inc.
 See the end of the file for license conditions.
 
 
@@ -29,31 +26,17 @@
 (including modified versions) has the freedom to redistribute and
 change it.
 
-If you do not know anyone to get a copy of GNU Emacs from, you can
-order a cd-rom from the Free Software Foundation.  We distribute
-several Emacs versions.  We also distribute nicely typeset copies of
-the Emacs user manual, Emacs Lisp Reference Manual, the Emacs
-reference card, etc.  See http://www.gnu.org/order/order.html.
-
-If you have Internet access, you can copy the latest Emacs
-distribution from hosts, such as ftp.gnu.org.  There are several ways
-to do this; see http://www.gnu.org/software/software.html for more
-information.
+For information on how to get GNU software, see
+http://www.gnu.org/software/software.html.  Printed copies of GNU
+manuals, including the Emacs manual, are available from the FSF's
+online store at http://shop.fsf.org.
 
 Emacs has been run on GNU/Linux, FreeBSD, NetBSD, OpenBSD, and on many
 Unix systems, on a variety of types of cpu, as well as on MSDOS,
-Windows and MacOS.  It also formerly worked on VMS and on Apollo
-computers, though with some deficiencies that reflect problems in
-these operating systems.  See the file `MACHINES' in this directory
-(see above) for a full list of machines that GNU Emacs has been tested
+Windows and MacOS.  See the file `etc/MACHINES' in the Emacs
+distribution for a full list of machines that GNU Emacs has been tested
 on, with machine-specific installation notes and warnings.
 
-Note that there is significant variation between Unix systems
-supposedly running the same version of Unix; it is possible that what
-works in GNU Emacs for me does not work on your system due to such an
-incompatibility.  Since I must avoid reading Unix source code, I
-cannot even guess what such problems may exist.
-
 GNU Emacs is distributed with no warranty (see the General Public
 License for full details, in the file `COPYING' in this directory (see
 above)), and neither I nor the Free Software Foundation promises any
@@ -62,14 +45,13 @@
 See http://www.gnu.org/help/gethelp.html.
 
 However, we plan to continue to improve GNU Emacs and keep it
-reliable, so please send me any complaints and suggestions you have.
-I will probably fix anything that I consider a malfunction.  I may
-make improvements that are suggested, but I may choose not to.
+reliable, so please send us any complaints and suggestions you have.
+We will probably fix anything that we consider a malfunction.  We may
+make improvements that are suggested, but we may choose not to.
 
-If you are on the Internet, report bugs to bug-gnu-emacs@gnu.org.  You
-can use the Emacs command M-x report-bug RET to mail a bug report.
-Please read the Bugs section of the Emacs manual before reporting
-bugs.
+If you are on the Internet, report bugs to bug-gnu-emacs@gnu.org.
+You can use the Emacs command M-x report-bug RET to mail a bug report.
+Please read the Bugs section of the Emacs manual before reporting bugs.
 
 General questions about the GNU Project can be asked of gnu@gnu.org.
 
@@ -80,12 +62,14 @@
 if you estimate what it would cost to distribute some commercial
 product and divide it by five, that is a good amount.
 
-If you like GNU Emacs, please express your satisfaction with a
-donation: send me or the Foundation what you feel Emacs has been worth
-to you.  If you are glad that I developed GNU Emacs and distribute it
-as free software, rather than following the obstructive and antisocial
-practices typical of software developers, reward me.  If you would
-like the Foundation to develop more free software, contribute.
+If you like GNU Emacs, please express your satisfaction with a donation:
+send me (please email me about how) or the Foundation
+(https://my.fsf.org/donate) what you feel Emacs has been worth to you.
+If you are glad that I developed GNU Emacs and distribute it as free
+software, rather than following the obstructive and antisocial
+practices of proprietary software, you can reward me.  If you would
+like the Foundation to do more to forward the cause of free software,
+you can contribute.
 
 Your donations will help to support the development of additional GNU
 software.  GNU/Linux systems (variants of GNU, based on the kernel
--- a/etc/NEWS	Thu Oct 14 16:21:40 2010 +0900
+++ b/etc/NEWS	Thu Oct 28 19:57:59 2010 +0900
@@ -138,7 +138,11 @@
 off by customizing x-gtk-use-system-tooltips.
 
 ** Lucid menus and dialogs can display antialiased fonts if Emacs is built
-with Xft.
+with Xft.  To change font, use X resource faceName, for example:
+Emacs.pane.menubar.faceName:  Courier-12
+Set faceName to none and use font to use the old X fonts.
+
+** On graphical displays, the mode-line no longer ends in dashes.
 
 ** Basic SELinux support has been added.
 This requires Emacs to be linked with libselinux at build time.
@@ -199,9 +203,17 @@
 
 *** `M-x customize-themes' lists Custom themes which can be enabled.
 
+*** New option `custom-theme-load-path' is the load path for themes.
+Emacs no longer looks for custom themes in `load-path'.  The default
+is to search in `custom-theme-directory', followed by a built-in theme
+directory named "themes/" in `data-directory'.
+
 ** The user option `remote-file-name-inhibit-cache' controls whether
 the remote file-name cache is used for read access.
 
+** The standalone programs lib-src/digest-doc and sorted-doc have been
+replaced with Lisp commands `doc-file-to-man' and `doc-file-to-info'.
+
 
 * Editing Changes in Emacs 24.1
 
@@ -230,22 +242,63 @@
 The default handling of clipboard and primary selections has been
 changed to conform with other X applications.
 
+The new behavior is that by default Emacs does not put selected text
+into the clipboard, and does not add it to kill-ring, merely because
+the text was selected.  Only commands that kill text or copy it to the
+kill-ring (C-w, M-w, C-k, etc.) put the killed text into the
+clipboard.  Selected text is put into the primary selection (on
+systems, such as X, that support the primary selection separately from
+the clipboard).
+
+Similarly, Emacs by default does not retrieve text from the clipboard
+when the mouse (e.g., mouse-2) is used for pasting text selected in
+another application.  Mouse commands that paste text retrieve text
+from the primary selection, on systems that support it separately from
+the clipboard.  Text from the clipboard is retrieved only by C-y, M-y
+and other commands that yank text from the kill-ring.
+
+In other words, the default behavior is that mouse gestures that
+select and paste text work with the primary selection (on X), while
+keyboard commands that kill/copy and paste text work with the
+clipboard.
+
+This change also means that the "Copy", "Cut", and "Paste" items of
+the menu-bar "Edit" menu are now exactly equivalent to, respectively
+M-w, C-w, and C-y.
+
+To get back the previous behavior, whereby mouse gestures set the
+clipboard and retrieve text from there, customize the variables
+`mouse-drag-copy-region' and (on X only) `x-select-enable-primary' to
+non-nil values.  If you don't want Emacs to put the text into the
+clipboard, only to the primary selection, additionally customize
+`x-select-enable-clipboard' to nil.
+
+These changes in the default behavior are reflected in the default
+values of several variables:
+
 *** `select-active-regions' now defaults to t, so active regions set
-the primary selection.
+the primary selection.  It was nil in previous versions.
 
-It also accepts a new value, `lazy', which means to only set the
+It also accepts a new value, `only', which means to only set the
 primary selection for temporarily active regions (usually made by
 mouse-dragging or shift-selection).
 
 *** `mouse-2' is now bound to `mouse-yank-primary'.
+Previously, it was bound to `mouse-yank-at-click' (which is now
+unbound by default).
 
-*** `x-select-enable-clipboard' now defaults to t.
+*** `x-select-enable-clipboard' now defaults to t on all platforms.
 Thus, killing and yanking now use the clipboard (in addition to the
-kill ring).
+kill ring).  Note that this variable was already non-nil by default on
+MS-Windows, which does not support the primary selection between
+applications.
 
 *** `x-select-enable-primary' now defaults to nil.
+This variable exists only on X; its default value was t in previous
+versions.
 
 *** `mouse-drag-copy-region' now defaults to nil.
+Its previous default value was t.
 
 *** Support for X cut buffers has been removed.
 
@@ -276,6 +329,8 @@
 
 ** mpc.el: Can use pseudo tags of the form tag1|tag2 as a union of two tags.
 
+** server can listen on a specific port using the server-port option.
+
 ** Calendar, Diary, and Appt
 
 ---
@@ -578,6 +633,11 @@
 
 * Lisp changes in Emacs 24.1
 
+** `image-library-alist' is renamed to `dynamic-library-alist'.
+The variable is now used to load all kind of supported dynamic libraries,
+not just image libraries.  The previous name is still available as an
+obsolete alias.
+
 ** New variable syntax-propertize-function to set syntax-table properties.
 Replaces font-lock-syntactic-keywords which are now obsolete.
 This allows syntax-table properties to be set independently from font-lock:
@@ -605,6 +665,12 @@
 
 ** New completion style `substring'.
 
+** `facemenu-read-color' is now an alias for `read-color'.
+The command `read-color' now requires a match for a color name or RGB
+triplet, instead of signalling an error if the user provides a invalid
+input.
+
+
 ** Image API
 
 *** When the image type is one of listed in `image-animated-types'
--- a/etc/NEWS.1-17	Thu Oct 14 16:21:40 2010 +0900
+++ b/etc/NEWS.1-17	Thu Oct 28 19:57:59 2010 +0900
@@ -235,7 +235,7 @@
 
 * Nroff mode and TeX mode.
 
-The are two new major modes for editing nroff input and TeX input.
+There are two new major modes for editing nroff input and TeX input.
 See the Emacs manual for full information.
 
 * New C indentation style variable `c-brace-imaginary-offset'.
--- a/etc/NEWS.23	Thu Oct 14 16:21:40 2010 +0900
+++ b/etc/NEWS.23	Thu Oct 28 19:57:59 2010 +0900
@@ -34,6 +34,11 @@
 ** The appt-add command takes an optional argument for the warning time.
 This can be used in place of the default appt-message-warning-time.
 
+** Obsolete packages
+
++++
+*** lmenu.el and cl-compat.el are now obsolete.
+
 
 * New Modes and Packages in Emacs 23.3
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/etc/NEXTSTEP	Thu Oct 28 19:57:59 2010 +0900
@@ -0,0 +1,311 @@
+Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
+See the end of the file for license conditions.
+
+This file contains information about GNU Emacs on "Nextstep" platforms.
+The Nextstep support code works on many POSIX systems (and possibly
+W32) using the GNUstep libraries, and on MacOS X systems using the
+Cocoa libraries.
+
+Background
+----------
+Within Emacs, the port and its code are referred to using the term
+"Nextstep", despite the fact that no system or API has been released
+under this name in more than 10 years.  Here's some background on why:
+
+NeXT, Inc. introduced the NeXTstep API with its computer and operating
+system in the late 1980's.  Later on, in collaboration with Sun, this
+API was published as a specification called OpenStep.  The GNUstep
+project started in the early 1990's to provide a free implementation
+of this API.  Later on, Apple bought NeXT (some would say "NeXT bought
+Apple") and made OpenStep the basis of OS X, calling the API "Cocoa".
+Since then, Cocoa has evolved beyond the OpenStep specification, and
+GNUstep has followed it.
+
+Thus, calling this port "OpenStep" is not technically accurate, and in
+the absence of any other determinant, we are using the term
+"Nextstep", both because it signifies the original inspiration that
+created these APIs, and because all of the classes and functions still
+begin with the letters "NS".
+
+(See http://en.wikipedia.org/wiki/Nextstep)
+
+This Emacs port was first released in the early 1990's on the NeXT
+computer, and was successively updated to OpenStep, Rhapsody, OS X,
+and then finally GNUstep, tracking GNU emacs core releases in the
+meantime.
+
+
+Release History
+---------------
+
+1990-1992	1.0-3.0 (?)	Michael Brouwer's socket/terminal communication 
+				based version (GUI ran as a separate process.)
+
+1993/10/25	3.0.1		Last (?) release of Brouwer version.  Supports
+				NeXTstep 3.x and below.
+
+1994/04/24	4.0		Carl Edman's version using direct API following
+				the X-Windows port.  NeXTstep 3.x only.
+
+1995/06/15	4.1        	Second (and last) Carl Edman release, based on
+				Emacs 19.28.
+
+1996/07/28	4.2		First Christian Limpach release, based on
+				Emacs 19.29.
+
+??		5.0		??
+
+1997/12/??	6.0b1		Ported to OpenStep by Scott Bender.  Updated
+				to Emacs 20.2.
+
+??		6.0b2		(?) Scott Bender: ported to Rhapsody.
+
+1999/05/??	6.0b3		Scott Bender: "OS X Server", Emacs 20.3.
+
+2001/06/25	7.0		Ported to MacOS X (10.1) by Christophe de
+				Dinechin. Release based on Emacs 20.7. Hosting
+				moved to SourceForge.
+
+2002/01/03	7.0.1		Bug fixes.
+
+2002/08/27	7.0.2		Jaguar (OS X 10.2) support. Added an autoconf
+				option for sys_nerr being in stdio. Added
+				libncurses to the build libraries. Fixed a
+				problem with ns-alternate-is-meta. Changed the
+				icon color to blue, since Jaguar is yellow.
+
+2004/10/07	8.0-pre1	Ported to GNUstep by Adrian Robert.
+
+2004/11/04	8.0-pre2	Restored functionality on OS X (menu code
+				cleanup).  Improved scrollbar handling and
+				paste from other applications.  File icons
+				obtained properly from NSWorkspace.  Dropped
+				Gorm and Nib files.  Background refresh bug
+				fixed (in GNUstep).  Various small fixes and
+				code cleanups.  Now starts up under Art.
+
+2005/01/27	8.0-pre3	Bold and italic faces supported.  Cursor and
+				mouse highlighting rendering bugs
+				fixed. Drag/drop and cut/paste interaction
+				w/external apps fixed.  File load/save panels
+				available.  Stability and rendering speed
+				improvements. Some ObjC and VC mode bugs fixed.
+
+2005/02/27	8.0-rc1		Dynamic path detection at startup so Emacs.app
+				can be moved anywhere.  Added binary packages
+				and simplified source installation to running
+				two scripts.  Thorough cleanup of menu code;
+				now fully functional.  Fixed all detected
+				memory leaks.  Minor frame focus and title
+				bugs fixed.
+
+2005/03/30	8.0-rc2		"Configure" info directory now uses dynamic
+				path setting, so info files can go under .app.
+				Improved select() handling and PTY fixes so
+				shell mode and tramp run smoothly.
+				Significant rendering optimizations under
+				GNUstep, and now works under Art backend.
+				Non-Latin text rendering works (but not
+				fontsets), and LEIM is bundled.  UTF8 is used
+				for clipboard interaction.
+				Arrow cursor now used on scrollbar.
+				objc-mode and tramp now bundled in site-lisp.
+
+2005/05/30	8.0-rc3		Fixed bug with parsing of "easymenu" menus.
+       				Many problems with modes such as SLIME, MatLab,
+				and Planner go away.  Improved scrollbar
+				handling and rendering speed.  Color panel
+				and other bug fixes. mac-fix-env utility.
+				Font handling improvements (OS X 10.3, 10.4):
+				- heed 'GSFontAntiAlias' default
+				- heed system antialiasing threshold
+				- added 'UseQuickdrawSmoothing' default to
+				  invoke less heavy antialiasing
+
+2005/07/05	8.0-rc4		Added a Preferences panel.  Cleaned up
+				rendering for synthetic italic fonts.  Further
+				improved menu parsing.  Use system highlight
+				color.  Added previous- and next-mark history
+				navigation commmands bound to M-p,M-n.
+				Miscellaneous bug fixes.
+
+2005/08/04	8.0-rc5		All internal string handling changed to UTF-8.
+				This means menu items, color and color list
+				names, and a few other things will now display
+				properly.  It does NOT mean UTF-8 filenames
+				are displayed correctly in the minibuffer.
+				Also relating to UTF-8, contents of files
+				using this coding can now be displayed (though
+				not auto-recognized; add extensions to your
+				default coding alist).  Limited mac-roman
+				support was also added (also sans recognition).
+				Certain characters are not displayed properly
+				due to a translation problem.  (UTF-8 based on
+				work by Otfried Cheong; mac-roman from
+				emacs-21.)  Partial support for "dead-key"
+				handling now added.  Transparency (e.g., M-x
+				set-background-color ARGB88FFFFFF) improved:
+				only the background is made transparent.
+				Cursor drawing glitches fixed.  Preferences 
+				handling improved.  Fixed some portability
+				problems on Tiger and Puma.
+
+2005/09/12	8.0		Bundled ispell on OS X.  Minor bug fixes and
+				stability improvements.  Compiles under gcc-4.
+
+2005/09/26	8.0.1		Correct clipped rendering for synthetic
+				italics. Include the info directory.
+				Fix grabenv. Bundle whitespace package.
+
+2005/10/27	8.0.2		Correct rendering for wide characters during
+				cursor movement.  Fix bungled hack in ispell
+				bundling.
+
+2005/11/05	9.0-pre1	Updated to latest Emacs CVS code on unicode-2
+				branch (proposed to be released 2006/2007 as
+				Emacs 23).
+
+2005/11/11	9.0-pre2	Fix crashes for deiconifying and loading
+				certain images.  Improve vertical font metrics
+				(fixes inaccurate page up/down, window size,
+				and partial lines).  Support better remapping
+				of Alt/Opt and remapping of Command.  More
+				insistent defaulting of scrollbar to right.
+				Modest improvements to build process.
+
+2006/04/22	9.0-pre2a	Stopgap interim release to sync w/latest
+				unicode-2 CVS.  Includes XPM and partial
+				toolbar support.
+
+2006/06/08	9.0-pre3	Major upgrade to keyboard handling:
+				system-selected compositional input methods
+				should now work, as well as more keys /
+				keyboards.  XPM, toolbar, and tooltip support.
+				Some improvements to scrollbars, zoom, italic
+				rendering, pasting, Color panel.  Added function
+				ns-set-background-alpha to work around
+				inability to customize with numeric colors.
+				
+2006/12/24	9.0-rc1		Reworked font handling and text rendering to
+				use Kenichi Handa's new font back-end system.
+				Font sets are now supported and automatically
+				created when a font is selected.  Added recent
+				X11 colors to Emacs.clr (remove
+				~/Library/Colors/Emacs.clr to pick up).  Added
+				ns-option-modifier, ns-control-modifier,
+				ns-function-modifier customization variables.
+				Update menus to Emacs 21+ conventions.  Right
+				mouse button now generates mouse-3 events.
+				Various bug fixes and rendering improvements.
+
+2007/09/10	9.0-rc2		Improve menubar, popup menu, and scrollbar
+				behavior, let accented char entry work in
+				isearch, follow system keymap for shortcut
+				keys, fix border and box drawing, remove
+				glitches in modeline drawing, support
+				overstrike for unavailable bold fonts, fix XPM
+				related crasher bugs.  Incremental font
+				metrics caching and other performance
+				improvements.  Shared-lisp builds now possible.
+
+2007/09/20	9.0-rc2a	Interim release.  New features: composed
+				character display, colored fringe bitmaps,
+				colored relief drawing, dynamic resizing,
+				Bug fixes: popup menu position and selection,
+				font width calculation, face color adaptation
+				to background, submenu keyboard navigation.
+				NOT TESTED ON GNUSTEP.
+
+2007/11/19	9.0-rc3		Integrated the multi-TTY functionality from
+				emacs core (however, mixed TTY and GUI
+				sessions are not working yet).  Support 10.5.
+				Give site-lisp load precedence over lisp and
+				add a compile option to prefer an additional
+				directory, use miniaturized miniwindow images
+				in some cases, rename cursor types for
+				consistency w/other emacs terms, improved font
+				selection for symbol scripts.
+				Bug fixes: fringe and bitmap, frame deletion,
+				resizing, cursor blink, workspace open-file,
+				image backgrounds, toolbar item enablement,
+				context menu positioning.
+
+2008/07/15	(none)		Merge to GNU Emacs CVS trunk.
+
+
+Contributors
+------------
+In addition to the folks listed in etc/AUTHORS responsible for GNU Emacs
+itself, the NeXTstep port owes to the following people:
+
+Carl Edman
+    original author and maintainer, mainly UI
+Michael Brouwer
+    heavy contributor, input handling and other areas
+Christian Limpach
+    help / maintenance on NeXTstep
+Scott Bender
+    OpenStep, Rhapsody ports
+Christophe de Dinechin
+    MacOS X port
+Adrian Robert
+    GNUstep port, update Emacs 20 -> 21+
+
+Joe Reiss
+    popup menu, dialog boxes; icons
+Andrew Athan
+    font panel integration
+Scott Byer
+    improved rendering code
+Scott Hess
+    keyboard handling suggestions
+
+Rahul Abrol
+    "hide others" patch
+Adam Ratcliffe
+    preferences panel documentation
+Peter Dyballa
+    assistance with non-ASCII rendering and keyboard handling
+David M. Cooke
+    fix to XPM crash bug
+Carsten Bormann
+    initial patch and assistance getting dired working for non-ASCII filenames
+Andrew Moore
+    assistance on ns-mark-nav extension
+
+The GNUstep port was made possible through the assistance of Adam
+Fedor, Fred Kiefer, M. Uli Klusterer, Alexander Malmberg, Jonas
+Matton, and Riccardo Mottola.  Leigh Smith maintained the SourceForge
+project for a period.
+
+Suggestions from Darcy Brockbank, Timothy Bissell, Scott Byer, David
+Griffiths, Scott Hess, Eberhard Mandler, John C. Randolph, and Bradley
+Taylor all helped things along at one point or another.  Axel Seibert
+and Paul J. Sanchez offered their time and machines to make a
+binary release possible.
+
+We would also like to thank a number of people who kept up the
+constant supply of bug reports, suggested features and praise: Hardy
+Mayer, Gisli Ottarsson, Anthony Heading, David Bau, Jamie Zawinski,
+Martin Moncrieffe, Simson L. Garfinkel, Richard Stallman, Stephen
+Anderson, Ivo Welch, Magnus Nordborg, Tom Epperly, Andreas Koenig,
+Yves Arrouye, Anil Somayaji, Gregor Hoffleit; and the few hundred
+other people on the mailing list from whom we didn't hear much, but
+the presence of which assured us that maybe this project was actually
+worth doing.
+
+
+This file is part of GNU Emacs.
+
+GNU Emacs is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+GNU Emacs is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
--- a/etc/PROBLEMS	Thu Oct 14 16:21:40 2010 +0900
+++ b/etc/PROBLEMS	Thu Oct 28 19:57:59 2010 +0900
@@ -235,19 +235,18 @@
 On platforms such as Solaris, you can also work around this problem by
 configuring your compiler to use the native linker instead of GNU ld.
 
-** Emacs compiled with Gtk+ crashes when closing a display (x-close-connection).
-
-This happens because of bugs in Gtk+.  Gtk+ 2.10 seems to be OK.  See bug
-http://bugzilla.gnome.org/show_bug.cgi?id=85715.
-
-** Emacs compiled with Gtk+ may loop forever if a display crashes.
-
-This is related to the bug above.  A scenario for this is when emacs is run
-as a server, and an X frame is created.  If the X server for the frame
-crashes or exits unexpectedly and an attempt is made to create a new
-frame on another X display, then a Gtk+ error happens in the emacs
-server that results in an endless loop.  This is not fixed in any known
-Gtk+ version (2.14.4 being current).
+** When Emacs is compiled with Gtk+, closing a display kills Emacs.
+
+There is a long-standing bug in GTK that prevents it from recovering
+from disconnects: http://bugzilla.gnome.org/show_bug.cgi?id=85715.
+
+Thus, for instance, when Emacs is run as a server on a text terminal,
+and an X frame is created, and the X server for that frame crashes or
+exits unexpectedly, Emacs must exit to prevent a GTK error that would
+result in an endless loop.
+
+If you need Emacs to be able to recover from closing displays, compile
+it with the Lucid toolkit instead of GTK.
 
 * General runtime problems
 
--- a/etc/images/README	Thu Oct 14 16:21:40 2010 +0900
+++ b/etc/images/README	Thu Oct 28 19:57:59 2010 +0900
@@ -35,6 +35,10 @@
   Author: Francesc Rocher <rocher@member.fsf.org>
   Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
 
+Files: checked.xpm, unchecked.xpm
+  Author: Chong Yidong <cyd@stupidchicken.com>
+  Copyright (C) 2010 Free Software Foundation, Inc.
+
 
 * The following icons are from GTK+ 2.x. They are not part of Emacs, but
 are distributed and used by Emacs.  They are licensed under the
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/etc/images/checked.xpm	Thu Oct 28 19:57:59 2010 +0900
@@ -0,0 +1,39 @@
+/* XPM */
+/* Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ * Author: Chong Yidong <cyd@stupidchicken.com>
+ *
+ * This file is part of GNU Emacs.
+ *
+ * GNU Emacs is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GNU Emacs is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
+ */
+static char * checked_xpm[] = {
+"12 12 5 1",
+" 	c None",
+".	c gray20",
+"+	c white",
+"@	c gray70",
+"#	c black",
+"............",
+"............",
+"..@@@@@@##+.",
+"..@@@@@@##+.",
+"..#@@@@##@+.",
+"..##@@@##@+.",
+"..###@##@@+.",
+"..@#####@@+.",
+"..@@###@@@+.",
+"..@++##++++.",
+".@+++++++++.",
+"............"};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/etc/images/unchecked.xpm	Thu Oct 28 19:57:59 2010 +0900
@@ -0,0 +1,39 @@
+/* XPM */
+/* Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ * Author: Chong Yidong <cyd@stupidchicken.com>
+ *
+ * This file is part of GNU Emacs.
+ *
+ * GNU Emacs is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GNU Emacs is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
+ */
+static char * unchecked_xpm[] = {
+"12 12 5 1",
+" 	c None",
+".	c gray20",
+"+	c white",
+"@	c gray70",
+"#	c black",
+"............",
+"............",
+"..@@@@@@@@+.",
+"..@@@@@@@@+.",
+"..@@@@@@@@+.",
+"..@@@@@@@@+.",
+"..@@@@@@@@+.",
+"..@@@@@@@@+.",
+"..@@@@@@@@+.",
+"..@++++++++.",
+".@+++++++++.",
+"............"};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/etc/themes/tango-dark-theme.el	Thu Oct 28 19:57:59 2010 +0900
@@ -0,0 +1,92 @@
+;;; tango-dark-theme.el --- Tango-based custom theme for faces
+
+;; Copyright (C) 2010 Free Software Foundation, Inc.
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary
+
+;; The colors in this theme come from the Tango palette, which is in
+;; the public domain: http://tango.freedesktop.org/
+
+;;; Code:
+
+(deftheme tango-dark
+  "Theme for faces, based on the Tango palette on a dark background.
+Basic, Font Lock, Isearch, Gnus, and Message faces are included.")
+
+(custom-theme-set-faces
+ 'tango-dark
+ '(default ((t (:foreground "#eeeeec" :background "#2e3436"))))
+ '(cursor ((t (:foreground "#2e3436" :background "#fce94f"))))
+ '(highlight ((t (:foreground "#2e3436" :background "#edd400"))))
+ '(region ((t (:background "#555753"))))
+ '(font-lock-builtin-face ((t (:foreground "#ad7fa8"))))
+ '(font-lock-comment-face ((t (:foreground "#73d216"))))
+ '(font-lock-constant-face ((t (:foreground "#e6a8df"))))
+ '(font-lock-function-name-face ((t (:foreground "#fce94f"))))
+ '(font-lock-keyword-face ((t (:foreground "#8cc4ff"))))
+ '(font-lock-string-face ((t (:foreground "#e9b96e"))))
+ '(font-lock-type-face ((t (:foreground "#a5ff4d"))))
+ '(font-lock-variable-name-face ((t (:foreground "#fcaf3e"))))
+ '(font-lock-warning-face ((t (:foreground "#ef2929"))))
+ '(button ((t (:underline t :foreground "#729fcf"))))
+ '(link ((t (:underline t :foreground "#729fcf"))))
+ '(link-visited ((t (:underline t :foreground "#3465a4"))))
+ '(mode-line ((t (:box (:line-width -1 :style released-button)
+		       :background "#d3d7cf" :foreground "black"))))
+ '(mode-line-inactive ((t (:box (:line-width -1 :style released-button)
+				:background "#555753" :foreground "white"))))
+ '(isearch ((t (:foreground "#ffffff" :background "#ce5c00"))))
+ '(lazy-highlight ((t (:background "#8f5902"))))
+ '(gnus-group-news-1 ((t (:foreground "#ad7fa8"))))
+ '(gnus-group-news-1-low ((t (:foreground "#75507b"))))
+ '(gnus-group-news-2 ((t (:foreground "#729fcf"))))
+ '(gnus-group-news-2-low ((t (:foreground "#3465a4"))))
+ '(gnus-group-news-3 ((t (:foreground "#8ae234"))))
+ '(gnus-group-news-3-low ((t (:foreground "#73d216"))))
+ '(gnus-group-news-4 ((t (:foreground "#e9b9e6"))))
+ '(gnus-group-news-4-low ((t (:foreground "#c17d11"))))
+ '(gnus-group-news-5 ((t (:foreground "#fcaf3e"))))
+ '(gnus-group-news-5-low ((t (:foreground "#f57900"))))
+ '(gnus-group-news-low ((t (:foreground "#edd400"))))
+ '(gnus-group-mail-1 ((t (:foreground "#ad7fa8"))))
+ '(gnus-group-mail-1-low ((t (:foreground "#75507b"))))
+ '(gnus-group-mail-2 ((t (:foreground "#729fcf"))))
+ '(gnus-group-mail-2-low ((t (:foreground "#3465a4"))))
+ '(gnus-group-mail-3 ((t (:foreground "#8ae234"))))
+ '(gnus-group-mail-3-low ((t (:foreground "#73d216"))))
+ '(gnus-group-mail-low ((t (:foreground "#edd400"))))
+ '(gnus-header-content ((t (:weight normal :foreground "#c4a000"))))
+ '(gnus-header-from ((t (:foreground "#edd400"))))
+ '(gnus-header-subject ((t (:foreground "#8ae234"))))
+ '(gnus-header-name ((t (:foreground "#729fcf"))))
+ '(gnus-header-newsgroups ((t (:foreground "#c17d11"))))
+ '(message-header-name ((t (:foreground "#729fcf"))))
+ '(message-header-cc ((t (:foreground "#c4a000"))))
+ '(message-header-other ((t (:foreground "#c17d11"))))
+ '(message-header-subject ((t (:foreground "#8ae234"))))
+ '(message-header-to ((t (:foreground "#edd400"))))
+ '(message-cited-text ((t (:foreground "#8ae234"))))
+ '(message-separator ((t (:foreground "#ad7fa8")))))
+
+(provide-theme 'tango-dark)
+
+;; Local Variables:
+;; no-byte-compile: t
+;; End:
+
+;;; tango-dark-theme.el ends here
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/etc/themes/tango-theme.el	Thu Oct 28 19:57:59 2010 +0900
@@ -0,0 +1,92 @@
+;;; tango-theme.el --- Tango-based custom theme for faces
+
+;; Copyright (C) 2010 Free Software Foundation, Inc.
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary
+
+;; The colors in this theme come from the Tango palette, which is in
+;; the public domain: http://tango.freedesktop.org/
+
+;;; Code:
+
+(deftheme tango
+  "Theme for faces, based on the Tango palette on a light background.
+Basic, Font Lock, Isearch, Gnus, and Message faces are included.")
+
+(custom-theme-set-faces
+ 'tango
+ '(default ((t (:foreground "#16191a" :background "#eeeeec"))))
+ '(cursor ((t (:foreground "#eeeeec" :background "#204a87"))))
+ '(highlight ((t (:background "#babdb6"))))
+ '(region ((t (:background "#babdb6"))))
+ '(font-lock-builtin-face ((t (:weight bold :foreground "#204a87"))))
+ '(font-lock-comment-face ((t (:foreground "#204a87"))))
+ '(font-lock-constant-face ((t (:weight bold :foreground "#5c3566"))))
+ '(font-lock-function-name-face ((t (:weight bold :foreground "#ce5c00"))))
+ '(font-lock-keyword-face ((t (:foreground "#a40000"))))
+ '(font-lock-string-face ((t (:foreground "#5c3566"))))
+ '(font-lock-type-face ((t (:weight bold :foreground "#4e9a06"))))
+ '(font-lock-variable-name-face ((t (:weight bold :foreground "#c17d11"))))
+ '(font-lock-warning-face ((t (:foreground "#cc0000"))))
+ '(button ((t (:underline t :foreground "#204a87"))))
+ '(link ((t (:underline t :foreground "#204a87"))))
+ '(link-visited ((t (:underline t :foreground "#3465a4"))))
+ '(mode-line ((t (:box (:line-width -1 :style released-button)
+		       :background "#d3d7cf" :foreground "black"))))
+ '(mode-line-inactive ((t (:box (:line-width -1 :style released-button)
+				:background "#babdb6" :foreground "black"))))
+ '(isearch ((t (:foreground "#ffffff" :background "#ce5c00"))))
+ '(lazy-highlight ((t (:background "#e9b96e"))))
+ '(gnus-group-news-1 ((t (:weight bold :foreground "#5c3566"))))
+ '(gnus-group-news-1-low ((t (:foreground "#5c3566"))))
+ '(gnus-group-news-2 ((t (:weight bold :foreground "#204a87"))))
+ '(gnus-group-news-2-low ((t (:foreground "#204a87"))))
+ '(gnus-group-news-3 ((t (:weight bold :foreground "#4e0a06"))))
+ '(gnus-group-news-3-low ((t (:foreground "#4e0a06"))))
+ '(gnus-group-news-4 ((t (:weight bold :foreground "#7a4c02"))))
+ '(gnus-group-news-4-low ((t (:foreground "#7a4c02"))))
+ '(gnus-group-news-5 ((t (:weight bold :foreground "#ce5c00"))))
+ '(gnus-group-news-5-low ((t (:foreground "#ce5c00"))))
+ '(gnus-group-news-low ((t (:foreground "#888a85"))))
+ '(gnus-group-mail-1 ((t (:weight bold :foreground "#5c3566"))))
+ '(gnus-group-mail-1-low ((t (:foreground "#5c3566"))))
+ '(gnus-group-mail-2 ((t (:weight bold :foreground "#204a87"))))
+ '(gnus-group-mail-2-low ((t (:foreground "#204a87"))))
+ '(gnus-group-mail-3 ((t (:weight bold :foreground "#4e0a06"))))
+ '(gnus-group-mail-3-low ((t (:foreground "#4e0a06"))))
+ '(gnus-group-mail-low ((t (:foreground "#888a85"))))
+ '(gnus-header-content ((t (:foreground "#4e9a06"))))
+ '(gnus-header-from ((t (:weight bold :foreground "#c4a000"))))
+ '(gnus-header-subject ((t (:foreground "#4e0a06"))))
+ '(gnus-header-name ((t (:foreground "#204a87"))))
+ '(gnus-header-newsgroups ((t (:foreground "#888a85"))))
+ '(message-header-name ((t (:foreground "#204a87"))))
+ '(message-header-cc ((t (:foreground "#c4a000"))))
+ '(message-header-other ((t (:foreground "#c17d11"))))
+ '(message-header-subject ((t (:foreground "#4e0a06"))))
+ '(message-header-to ((t (:weight bold :foreground "#c4a000"))))
+ '(message-cited-text ((t (:foreground "#888a85"))))
+ '(message-separator ((t (:weight bold :foreground "#4e9a06")))))
+
+(provide-theme 'tango)
+
+;; Local Variables:
+;; no-byte-compile: t
+;; End:
+
+;;; tango-theme.el ends here
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/etc/themes/wheatgrass-theme.el	Thu Oct 28 19:57:59 2010 +0900
@@ -0,0 +1,66 @@
+;;; wheatgrass-theme.el --- custom theme for faces
+
+;; Copyright (C) 2010 Free Software Foundation, Inc.
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Code:
+
+(deftheme wheatgrass
+  "Theme for basic, Font Lock, Isearch, Gnus, and Message faces.
+The default face is wheat on a black background.  Other faces
+are in shades of green, brown, and blue.")
+
+(custom-theme-set-faces
+ 'wheatgrass
+ '(default ((t (:foreground "wheat" :background "black"))))
+ '(cursor ((t (:foreground "black" :background "thistle"))))
+ '(highlight ((t (:foreground "white" :background "dark green"))))
+ '(region ((t (:foreground "white" :background "dark green"))))
+ '(font-lock-builtin-face ((t (:foreground "LightSteelBlue"))))
+ '(font-lock-comment-face ((t (:foreground "SpringGreen3"))))
+ '(font-lock-constant-face ((t (:foreground "turquoise"))))
+ '(font-lock-function-name-face ((t (:foreground "pale green"))))
+ '(font-lock-keyword-face ((t (:foreground "white"))))
+ '(font-lock-string-face ((t (:foreground "dark khaki"))))
+ '(font-lock-type-face ((t (:foreground "aquamarine"))))
+ '(font-lock-variable-name-face ((t (:foreground "yellow green"))))
+ '(font-lock-warning-face ((t (:foreground "salmon1"))))
+ '(button ((t (:underline t :foreground "cyan"))))
+ '(link ((t (:underline t :foreground "cyan"))))
+ '(link-visited ((t (:underline t :foreground "dark cyan"))))
+ '(isearch ((t (:foreground "white" :background "dark goldenrod"))))
+ '(lazy-highlight ((t (:background "gray25"))))
+ '(gnus-header-content ((t (:weight normal :foreground "yellow green"))))
+ '(gnus-header-from ((t (:foreground "pale green"))))
+ '(gnus-header-subject ((t (:foreground "pale turquoise"))))
+ '(gnus-header-name ((t (:foreground "dark sea green"))))
+ '(gnus-header-newsgroups ((t (:foreground "dark khaki"))))
+ '(message-header-name ((t (:foreground "dark turquoise"))))
+ '(message-header-cc ((t (:foreground "yellow green"))))
+ '(message-header-other ((t (:foreground "dark khaki"))))
+ '(message-header-subject ((t (:foreground "pale turquoise"))))
+ '(message-header-to ((t (:foreground "pale green"))))
+ '(message-cited-text ((t (:foreground "SpringGreen3"))))
+ '(message-separator ((t (:foreground "deep sky blue")))))
+
+(provide-theme 'wheatgrass)
+
+;; Local Variables:
+;; no-byte-compile: t
+;; End:
+
+;;; wheatgrass-theme.el ends here
--- a/etc/tutorials/TUTORIAL	Thu Oct 14 16:21:40 2010 +0900
+++ b/etc/tutorials/TUTORIAL	Thu Oct 28 19:57:59 2010 +0900
@@ -498,12 +498,12 @@
 you later decide that your changes were a mistake.
 
 If you look near the bottom of the screen you will see a line that
-begins and ends with dashes, and starts with "--:--- TUTORIAL" or
-something like that.  This part of the screen normally shows the name
-of the file that you are visiting.  Right now, you are visiting a file
-called "TUTORIAL" which is your personal scratch copy of the Emacs
-tutorial.  When you find a file with Emacs, that file's name will
-appear in that precise spot.
+begins with dashes, and starts with "--:--- TUTORIAL" or something
+like that.  This part of the screen normally shows the name of the
+file that you are visiting.  Right now, you are visiting a file called
+"TUTORIAL" which is your personal scratch copy of the Emacs tutorial.
+When you find a file with Emacs, that file's name will appear in that
+precise spot.
 
 One special thing about the command for finding a file is that you
 have to say what file name you want.  We say the command "reads an
--- a/etc/tutorials/TUTORIAL.es	Thu Oct 14 16:21:40 2010 +0900
+++ b/etc/tutorials/TUTORIAL.es	Thu Oct 28 19:57:59 2010 +0900
@@ -1,4 +1,4 @@
-Tutorial de Emacs. Vea al final las condiciones de copiado.
+Tutorial de Emacs.  Vea al final las condiciones de copiado.
 
 Generalmente los comandos de Emacs involucran la tecla CONTROL
 (algunas veces llamada CTRL O CTL) o la tecla meta (algunas veces
@@ -17,7 +17,7 @@
 caracteres).  Los caracteres ">>" en el margen izquierdo indican
 instrucciones para que usted trate de usar un comando.  Por ejemplo:
 <<Blank lines inserted around following line by help-with-tutorial>>
-[Mitad de página en blanco para propósitos didácticos. El texto continúa abajo]
+[Mitad de página en blanco para propósitos didácticos.  El texto continúa abajo]
 >> Ahora teclee C-v (ver la próxima pantalla) para desplazarse a la
 	siguiente pantalla (hágalo manteniendo la tecla control
 	oprimida mientras teclea v).  Desde ahora debería hacer esto
@@ -75,7 +75,7 @@
 			Línea siguiente, C-n
 
 >> Mueva el cursor a la línea en la mitad del diagrama
-   usando C-n o C-p. Luego teclee C-l para ver el
+   usando C-n o C-p.  Luego teclee C-l para ver el
    diagrama completo centrado en la pantalla.
 
 Le resultará fácil recordar estas letras por las palabras que
@@ -200,7 +200,7 @@
 C-u y luego los dígitos antes de introducir los comandos.  Si tiene
 una tecla META (o EDIT o ALT), hay una manera alternativa para
 ingresar un argumento numérico: teclear los dígitos mientras presiona
-la tecla META.  Recomendamos aprender el método C-u porque este
+la tecla META.  Recomendamos aprender el método C-u porque éste
 funciona en cualquier terminal.  El argumento numérico es también
 llamado un "argumento prefijo", porque usted teclea el argumento antes
 del comando al que se aplica.
@@ -321,13 +321,13 @@
 <Delback> es una tecla en el teclado--la misma que normalmente usa
 fuera de emacs para borrar el último carácter que escribió.
 Normalmente es una tecla una o dos filas arriba de la tecla <Return>,
-y que esta usualmente rotulada como "Backspace", "Del" o simplemente
+y que está usualmente rotulada como "Backspace", "Del" o simplemente
 con una flecha en dirección izquierda que no es parte de las teclas de
 flecha.
 
-Si la tecla larga esta rotulada "Backspace", entonces esa es la que
-debe de usar para <Delback>. Puede haber otra tecla llamada "Del" en
-otra parte, pero esa no es <Delback>.
+Si la tecla larga está rotulada "Backspace", entonces ésa es la que
+debe de usar para <Delback>.  Puede haber otra tecla llamada "Del" en
+otra parte, pero ésa no es <Delback>.
 
 Generalmente, <Delback> borra el carácter inmediatamente anterior a la
 posición actual del cursor.
@@ -393,7 +393,7 @@
 entre las dos posiciones.
 
 >> Mueva el cursor a la letra T del inicio del párrafo anterior.
->> Teclee C-SPC. Emacs debe mostrar el mensaje "Mark set" en la parte
+>> Teclee C-SPC.  Emacs debe mostrar el mensaje "Mark set" en la parte
    de abajo de la pantalla.
 >> Mueva el cursor a la x en "extremo", en la segunda línea del
    párrafo.
@@ -405,7 +405,7 @@
 reinsertadas.  La reinserción de texto eliminado se llama "yanking" o
 "pegar".  Generalmente, los comandos que pueden quitar mucho texto lo
 eliminan, mientras que los comandos que quitan solo un carácter, o
-solo lineas en blanco y espacios, borran (para que no pueda pegar ese
+solo líneas en blanco y espacios, borran (para que no pueda pegar ese
 texto).
 
 >> Mueva el cursor al comienzo de una línea que no esté vacía.
@@ -417,14 +417,14 @@
 y un segundo C-k elimina la línea misma, y hace que todas las otras
 líneas se muevan hacia arriba.  C-k trata un argumento numérico
 especialmente: Elimina ese número de líneas y TAMBIÉN sus
-contenidos. Esto no es una simple repetición.  C-u 2 C-k elimina dos
+contenidos.  Esto no es una simple repetición.  C-u 2 C-k elimina dos
 líneas y sus nuevas líneas, tecleando C-k dos veces no hace esto.
 
 Traer texto eliminado de regreso es llamado "yanking" o "pegar".
 (Piense en ello como pegar de nuevo, o traer de vuelta, algún texto
 que le fue quitado.)  Puede pegar el texto eliminado en, ya sea el
 lugar en que fue eliminado, o en otra parte del buffer, o hasta en un
-archivo diferente. Puede pegar el texto varias veces, lo que hace
+archivo diferente.  Puede pegar el texto varias veces, lo que hace
 varias copias de él.
 
 El comando para pegar es C-y.  Reinserta el último texto eliminado, en
@@ -460,7 +460,7 @@
    Luego teclee M-y y será reemplazado por la primera línea eliminada.
    Teclee más veces M-y y vea lo que obtiene.  Siga haciéndolo hasta
    que la segunda línea eliminada regrese, y entonces unas pocas
-   más. Si quiere, puede tratar de darle a M-y argumentos positivos y
+   más.  Si quiere, puede tratar de darle a M-y argumentos positivos y
    negativos.
 
 
@@ -477,7 +477,7 @@
 Pero hay dos excepciones: los comandos que no cambian el texto no
 cuentan (esto incluye los comandos de movimiento del cursor y el
 comando de desplazamiento), y los caracteres de autoinserción se
-manejan usualmente en grupos de hasta 20. (Esto es para reducir el
+manejan usualmente en grupos de hasta 20.  (Esto es para reducir el
 numero de C-x u que tenga que teclear para deshacer una inserción en
 el texto.)
 
@@ -504,7 +504,7 @@
 Para que pueda hacer permanente el texto que edite, lo debe colocar en
 un archivo.  De otra manera, éste se perderá cuando cierre Emacs.
 Para poder poner su texto en un archivo, debe "encontrar" el archivo
-antes de ingresar el texto. (Esto se llama también "visitar" el
+antes de ingresar el texto.  (Esto se llama también "visitar" el
 archivo.)
 
 Encontrar un archivo significa que puede ver su contenido dentro de
@@ -556,7 +556,7 @@
 
 Esto copia el texto dentro de Emacs al archivo.  La primera vez que
 haga esto, Emacs renombrará el archivo original con un nuevo nombre
-para que este no se pierda. El nuevo nombre se hace agregando "~" al
+para que éste no se pierda.  El nuevo nombre se hace agregando "~" al
 final del nombre del archivo original.
 
 Cuando guardar haya terminado, Emacs mostrará el nombre del archivo
@@ -595,13 +595,13 @@
 Emacs.  Para mirar la lista de los buffers que existen actualmente en
 su sesión de Emacs, teclee:
 
-	C-x C-b   Lista de Buffers
+	C-x C-b   Lista de buffers
 
 >> Pruebe C-x C-b ahora.
 
 Vea como cada buffer tiene un nombre, y además puede tener un nombre
-de archivo para el archivo que contiene. CUALQUIER texto que vea en
-una ventana de Emacs es siempre parte de algún Buffer.
+de archivo para el archivo que contiene.  CUALQUIER texto que vea en
+una ventana de Emacs es siempre parte de algún buffer.
 
 >> Teclee C-x 1 para deshacerse de la lista de buffers.
 
@@ -610,14 +610,14 @@
 otro buffer, necesita "cambiar" a él.  Si quiere cambiar a un buffer
 que corresponde a un archivo, puede hacerlo visitando el archivo de
 nuevo con C-x C-f.  Pero existe una manera más rápida: use el comando
-C-x b. En ese comando, necesita teclear el nombre de buffer.
+C-x b.  En ese comando, necesita teclear el nombre de buffer.
 
 >> Teclee C-x b foo <Return> para volver al buffer "foo" que contiene
    el texto del archivo "foo".  Después teclee C-x b TUTORIAL.es
    <Return> para regresar a este tutorial.
 
 La mayoría del tiempo el nombre del buffer es el mismo que el nombre
-del archivo (sin la parte del directorio del archivo). Sin embargo,
+del archivo (sin la parte del directorio del archivo).  Sin embargo,
 esto no es así siempre.  La lista de buffers que hace con C-x C-b
 siempre muestra el nombre de todos los buffers.
 
@@ -638,7 +638,7 @@
 segundo buffer de archivo no afecta al primero.  Esto es muy útil,
 pero también significa que necesita una forma conveniente para guardar
 el archivo del primer buffer.  Sería una molestia tener que volver a
-este con C-x C-f para guardarlo con C-x C-s. Así tenemos
+éste con C-x C-f para guardarlo con C-x C-s.  Así tenemos
 
 	C-x s 	Guardar algunos buffers
 
@@ -655,10 +655,10 @@
 
 Hay muchísimos más comandos de Emacs que los que podrían asignarse a
 todos los caracteres control y meta.  Emacs puede darle la vuelta a
-esto usando el comando X (eXtendido).  Este viene de dos formas:
+esto usando el comando X (eXtendido).  Éste viene de dos formas:
 
-	C-x 	Carácter eXtendido. Seguido por un carácter.
-        M-x 	Comando eXtendido por nombre. Seguido por un nombre
+	C-x 	Carácter eXtendido.  Seguido por un carácter.
+        M-x 	Comando eXtendido por nombre.  Seguido por un nombre
                 largo.
 
 Estos comandos son generalmente útiles pero menos usados que los
@@ -713,7 +713,7 @@
 caracteres a reemplazar, y la cadena de caracteres para reemplazarla.
 Debe terminar cada argumento con <Return>.
 
->> Mueva el cursor hacia la línea en blanco dos líneas abajo de esta.
+>> Mueva el cursor hacia la línea en blanco dos líneas abajo de ésta.
    A continuación escriba
    M-x repl s<Return>cambiado<Return>alterado<Return>.
 
@@ -762,7 +762,7 @@
 Ya sabe qué significa el nombre del archivo: es el archivo que usted
 ha encontrado.  -NN%-- indica su posición actual en el texto; esto
 significa que NN por ciento del texto está encima de la parte superior
-de la pantalla.  Si el principio del archivo está en la pantalla, este
+de la pantalla.  Si el principio del archivo está en la pantalla, éste
 dirá --Top-- en vez de --00%--.  Si el final del texto está en la
 pantalla, dirá --Bot--.  Si está mirando un texto tan pequeño que cabe
 en la pantalla, el modo de línea dirá --All--.
@@ -776,7 +776,7 @@
 
 La parte de la línea de modo dentro de los paréntesis es para
 indicarle en qué modo de edición está.  El modo por omisión es
-Fundamental, el cual está usando ahora.  Este es un ejemplo de un
+Fundamental, el cual está usando ahora.  Éste es un ejemplo de un
 "modo mayor".
 
 Emacs tiene diferentes modos mayores.  Algunos están hechos para
@@ -841,7 +841,7 @@
    Debe intercalar espacios porque Auto Fill sólo rompe líneas en los
    espacios.
 
-El margen esta normalmente puesto en 70 caracteres, pero puede
+El margen está normalmente puesto en 70 caracteres, pero puede
 cambiarlo con el comando C-x f.  Debe indicar el margen deseado como
 un argumento numérico.
 
@@ -1079,7 +1079,7 @@
 valores pueda poner para adecuar el comportamiento de Emacs.  Necesita
 teclear el nombre de la variable cuando Emacs pregunte por ella.
 
-   C-h a 	Comando Apropos. Teclee una palabra y Emacs hará una
+   C-h a 	Comando Apropos.  Teclee una palabra y Emacs hará una
 		lista de todos los comandos que contengan esa palabra.
 		Todos estos comandos pueden ser invocados con META-x.
 		Para algunos comandos, el Comando Apropos también
@@ -1113,7 +1113,7 @@
 ---------------------
 
 Puede aprender más de Emacs leyendo su manual, ya sea como libro o en
-línea en el Info (use el menú Ayuda--"Help"--o teclee F10 h r). Dos
+línea en el Info (use el menú Ayuda--"Help"--o teclee F10 h r).  Dos
 características que pueden gustarle son la completación, que ahorra
 teclear, y dired, que simplifica el manejo de archivos.
 
@@ -1126,7 +1126,7 @@
 
 Dired le permite listar los archivos en un directorio (y opcionalmente
 sus subdirectorios), moverse alrededor de esa lista, visitar,
-renombrar, borrar y aparte de eso operar en los archivos.  Dired esta
+renombrar, borrar y aparte de eso operar en los archivos.  Dired está
 descrito en el Info en el manual de Emacs en el nodo llamado "Dired".
 
 El manual también describe otras características de Emacs.
@@ -1189,7 +1189,7 @@
    posterior como lo permite esta nota.
 
    Se permite distribuir versiones modificadas de este documento, o
-   porciones de este, bajo las condiciones anteriores, siempre que
+   porciones de éste, bajo las condiciones anteriores, siempre que
    ellas tengan nota visible especificando quién fue el último en
    alterarlas.
 
--- a/lib-src/ChangeLog	Thu Oct 14 16:21:40 2010 +0900
+++ b/lib-src/ChangeLog	Thu Oct 28 19:57:59 2010 +0900
@@ -1,3 +1,17 @@
+2010-10-25  Glenn Morris  <rgm@gnu.org>
+
+	* makefile.w32-in (OTHER_PLATFORM_SUPPORT): Remove easymenu.elc.
+
+2010-10-23  Glenn Morris  <rgm@gnu.org>
+
+	* digest-doc.c, sorted-doc.c: Remove files.
+	* Makefile.in (UTILITIES): Remove digest-doc and sorted-doc.
+	(digest-doc${EXEEXT}, sorted-doc${EXEEXT}): Remove rules.
+	* makefile.w32-in (ALL): Remove digest-doc and sorted-doc.
+	($(BLD)/sorted-doc.exe, $(BLD)/digest-doc.exe, sorted-doc, digest-doc)
+	($(BLD)/digest-doc.$(O), $(BLD)/sorted-doc.$(O)): Remove rules.
+	(install): Don't install digest-doc.exe or sorted-doc.exe.
+
 2010-10-10  Dan Nicolaescu  <dann@ics.uci.edu>
 
 	* Makefile.in (PROFILING_LDFLAGS): Remove, not needed.
@@ -5376,10 +5390,10 @@
 	(main): Improve usage message.
 	(error): Write to stderr, not stdout.
 
-	* b2m.c cvtmail.c digest-doc.c emacsclient.c emacsserver.c etags.c
-	fakemail.c hexl.c make-docfile.c profile.c sorted-doc.c test-distrib.c
-	timer.c wakeup.c yow.c: Eliminate some -Wall warnings from unused
-	variables and implicitly declared functions.
+	* b2m.c, cvtmail.c, digest-doc.c, emacsclient.c, emacsserver.c:
+	* etags.c, fakemail.c, hexl.c, make-docfile.c, profile.c, sorted-doc.c:
+	* test-distrib.c, timer.c, wakeup.c, yow.c: Eliminate some -Wall
+	warnings from unused variables and implicitly declared functions.
 
 1994-10-11  Richard Stallman  <rms@mole.gnu.ai.mit.edu>
 
--- a/lib-src/Makefile.in	Thu Oct 14 16:21:40 2010 +0900
+++ b/lib-src/Makefile.in	Thu Oct 28 19:57:59 2010 +0900
@@ -118,8 +118,7 @@
 
 # Things that Emacs runs internally, or during the build process,
 #  which should not be installed in bindir.
-UTILITIES = profile${EXEEXT} digest-doc${EXEEXT} sorted-doc${EXEEXT} \
-            movemail${EXEEXT} fakemail${EXEEXT} \
+UTILITIES = profile${EXEEXT} movemail${EXEEXT} fakemail${EXEEXT} \
             hexl${EXEEXT} update-game-score${EXEEXT}
 
 DONT_INSTALL= test-distrib${EXEEXT} make-docfile${EXEEXT}
@@ -353,12 +352,6 @@
 	$(CC) ${ALL_CFLAGS} ${srcdir}/make-docfile.c $(LOADLIBES) \
 	  -o make-docfile
 
-digest-doc${EXEEXT}: ${srcdir}/digest-doc.c
-	$(CC) ${ALL_CFLAGS} ${srcdir}/digest-doc.c $(LOADLIBES) -o digest-doc
-
-sorted-doc${EXEEXT}: ${srcdir}/sorted-doc.c
-	$(CC) ${ALL_CFLAGS} ${srcdir}/sorted-doc.c $(LOADLIBES) -o sorted-doc
-
 movemail${EXEEXT}: movemail.o pop.o $(GETOPTDEPS)
 	$(CC) ${LINK_CFLAGS} ${MOVE_FLAGS} movemail.o pop.o \
 	  $(GETOPTOBJS) $(LOADLIBES) $(LIBS_MOVE) -o movemail
--- a/lib-src/digest-doc.c	Thu Oct 14 16:21:40 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +0,0 @@
-/* Give this program DOC-mm.nn.oo as standard input and it outputs to
-   standard output a file of nroff output containing the doc strings.
-
-Copyright (C) 1987, 1994, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
-  2008, 2009, 2010 Free Software Foundation, Inc.
-
-This file is part of GNU Emacs.
-
-GNU Emacs is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-GNU Emacs is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
-
-
-See also sorted-doc.c, which produces similar output
-but in texinfo format and sorted by function/variable name.  */
-
-#include <stdio.h>
-
-#ifdef DOS_NT
-#include <fcntl.h>		/* for O_BINARY */
-#include <io.h>			/* for setmode */
-#endif
-
-int
-main (void)
-{
-  register int ch;
-  register int notfirst = 0;
-
-#ifdef DOS_NT
-  /* DOC is a binary file.  */
-  if (!isatty (fileno (stdin)))
-    setmode (fileno (stdin), O_BINARY);
-#endif
-
-  printf (".TL\n");
-  printf ("Command Summary for GNU Emacs\n");
-  printf (".AU\nRichard M. Stallman\n");
-  while ((ch = getchar ()) != EOF)
-    {
-      if (ch == '\037')
-	{
-	  if (notfirst)
-	    printf ("\n.DE");
-	  else
-	    notfirst = 1;
-
-	  printf ("\n.SH\n");
-
-	  ch = getchar ();
-	  printf (ch == 'F' ? "Function " : "Variable ");
-
-	  while ((ch = getchar ()) != '\n')  /* Changed this line */
-	    {
-	      if (ch != EOF)
-		  putchar (ch);
-	      else
-		{
-		  ungetc (ch, stdin);
-		  break;
-		}
-	    }
-	  printf ("\n.DS L\n");
-	}
-      else
-	putchar (ch);
-    }
-  return 0;
-}
-
-/* arch-tag: 2ba2c9b0-4157-4eba-bd9f-967e3677e35f
-   (do not change this comment) */
--- a/lib-src/makefile.w32-in	Thu Oct 14 16:21:40 2010 +0900
+++ b/lib-src/makefile.w32-in	Thu Oct 28 19:57:59 2010 +0900
@@ -18,7 +18,7 @@
 # along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 
-ALL = make-docfile hexl ctags etags movemail ebrowse sorted-doc digest-doc emacsclient
+ALL = make-docfile hexl ctags etags movemail ebrowse emacsclient
 
 .PHONY: $(ALL)
 
@@ -36,10 +36,6 @@
 		$(LINK) $(LINK_OUT)$@ $(LINK_FLAGS) $(BLD)/hexl.$(O) $(LIBS)
 $(BLD)/fakemail.exe: 		$(BLD)/fakemail.$(O) $(BLD)/ntlib.$(O)
 		$(LINK) $(LINK_OUT)$@ $(LINK_FLAGS) $(BLD)/fakemail.$(O) $(BLD)/ntlib.$(O) $(LIBS)
-$(BLD)/sorted-doc.exe: 	$(BLD)/sorted-doc.$(O)
-		$(LINK) $(LINK_OUT)$@ $(LINK_FLAGS) $(BLD)/sorted-doc.$(O) $(LIBS)
-$(BLD)/digest-doc.exe: 	$(BLD)/digest-doc.$(O)
-		$(LINK) $(LINK_OUT)$@ $(LINK_FLAGS) $(BLD)/digest-doc.$(O) $(LIBS)
 $(BLD)/test-distrib.exe: $(BLD)/test-distrib.$(O)
 		$(LINK) $(LINK_OUT)$@ $(LINK_FLAGS) $(BLD)/test-distrib.$(O) $(LIBS)
 
@@ -50,8 +46,6 @@
 hexl:		stamp_BLD $(BLD)/hexl.exe
 movemail:	stamp_BLD $(BLD)/movemail.exe
 fakemail:	stamp_BLD $(BLD)/fakemail.exe
-sorted-doc:	stamp_BLD $(BLD)/sorted-doc.exe
-digest-doc:	stamp_BLD $(BLD)/digest-doc.exe
 emacsclient:	stamp_BLD $(BLD)/emacsclient.exe $(BLD)/emacsclientw.exe
 
 test-distrib:	stamp_BLD $(BLD)/test-distrib.exe
@@ -195,7 +189,6 @@
 	$(lispsource)term/pc-win.elc \
 	$(lispsource)x-dnd.elc \
 	$(lispsource)term/x-win.elc \
-	$(lispsource)emacs-lisp/easymenu.elc \
 	$(lispsource)term/ns-win.elc
 
 
@@ -335,8 +328,6 @@
 		$(CP) $(BLD)/ctags.exe $(INSTALL_DIR)/bin
 		$(CP) $(BLD)/hexl.exe $(INSTALL_DIR)/bin
 		$(CP) $(BLD)/movemail.exe $(INSTALL_DIR)/bin
-		$(CP) $(BLD)/sorted-doc.exe $(INSTALL_DIR)/bin
-		$(CP) $(BLD)/digest-doc.exe $(INSTALL_DIR)/bin
 		$(CP) $(BLD)/emacsclient.exe $(INSTALL_DIR)/bin
 		$(CP) $(BLD)/emacsclientw.exe $(INSTALL_DIR)/bin
 		- mkdir "$(INSTALL_DIR)/etc"
@@ -404,9 +395,6 @@
 	$(SRC)/ntlib.h \
 	$(SRC)/getopt.h
 
-$(BLD)/digest-doc.$(O) : \
-	$(SRC)/digest-doc.c
-
 $(BLD)/emacsclient.$(O) : \
 	$(SRC)/emacsclient.c \
 	$(EMACS_ROOT)/src/s/ms-w32.h \
@@ -496,12 +484,6 @@
 $(BLD)/qsort.$(O) : \
 	$(SRC)/qsort.c
 
-$(BLD)/sorted-doc.$(O) : \
-	$(SRC)/sorted-doc.c \
-	$(EMACS_ROOT)/src/s/ms-w32.h \
-	$(EMACS_ROOT)/src/m/intel386.h \
-	$(EMACS_ROOT)/src/config.h
-
 $(BLD)/tcp.$(O) : \
 	$(SRC)/tcp.c
 
@@ -519,8 +501,6 @@
 #
 $(BLD)/make-docfile.$(O) $(BLD)/hexl.$(O) $(BLD)/fakemail.$(O): stamp_BLD
 
-$(BLD)/sorted-doc.$(O) $(BLD)/digest-doc.$(O): stamp_BLD
-
 $(BLD)/test-distrib.$(O) $(GETOPTOBJS) $(MOVEMAILOBJS): stamp_BLD
 
 $(BLD)/emacsclient.$(O) $(BLD)/etags.$(O) $(BLD)/regex.$(O): stamp_BLD
--- a/lib-src/sorted-doc.c	Thu Oct 14 16:21:40 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,296 +0,0 @@
-/* Give this program DOC-mm.nn.oo as standard input and it outputs to
-   standard output a file of texinfo input containing the doc strings.
-
-Copyright (C) 1989, 1992, 1994, 1996, 1999, 2000, 2001, 2002, 2003,
-              2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
-
-This file is part of GNU Emacs.
-
-GNU Emacs is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-GNU Emacs is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
-
-
-/* This version sorts the output by function name.  */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <ctype.h>
-#ifdef DOS_NT
-#include <fcntl.h>		/* for O_BINARY */
-#include <io.h>			/* for setmode */
-#endif
-#ifndef HAVE_STDLIB_H		/* config.h includes stdlib.  */
-#ifndef WINDOWSNT		/* src/s/ms-w32.h includes stdlib.h */
-extern char *malloc ();
-#endif
-#endif
-
-#define NUL	'\0'
-#define MARKER '\037'
-
-#define DEBUG 0
-
-typedef struct line LINE;
-
-struct line
-{
-  LINE *next;			/* ptr to next or NULL */
-  char *line;			/* text of the line */
-};
-
-typedef struct docstr DOCSTR;
-
-struct docstr			/* Allocated thing for an entry. */
-{
-  DOCSTR *next;			/* next in the chain */
-  char *name;			/* name of the function or var */
-  LINE *first;			/* first line of doc text. */
-  char type;			/* 'F' for function, 'V' for variable */
-};
-
-
-/* Print error message.  `s1' is printf control string, `s2' is arg for it. */
-
-void
-error (const char *s1, const char *s2)
-{
-  fprintf (stderr, "sorted-doc: ");
-  fprintf (stderr, s1, s2);
-  fprintf (stderr, "\n");
-}
-
-/* Print error message and exit.  */
-
-void
-fatal (const char *s1, const char *s2)
-{
-  error (s1, s2);
-  exit (EXIT_FAILURE);
-}
-
-/* Like malloc but get fatal error if memory is exhausted.  */
-
-char *
-xmalloc (int size)
-{
-  char *result = malloc ((unsigned)size);
-  if (result == NULL)
-    fatal ("%s", "virtual memory exhausted");
-  return result;
-}
-
-char *
-xstrdup (const char *str)
-{
-  char *buf = xmalloc (strlen (str) + 1);
-  (void) strcpy (buf, str);
-  return (buf);
-}
-
-/* Comparison function for qsort to call.  */
-
-int
-cmpdoc (const void *va, const void *vb)
-{
-  DOCSTR *const *a = va;
-  DOCSTR *const *b = vb;
-  register int val = strcmp ((*a)->name, (*b)->name);
-  if (val) return val;
-  return (*a)->type - (*b)->type;
-}
-
-enum state
-{
-  WAITING, BEG_NAME, NAME_GET, BEG_DESC, DESC_GET
-};
-
-const char *states[] =
-{
-  "WAITING", "BEG_NAME", "NAME_GET", "BEG_DESC", "DESC_GET"
-};
-
-int
-main (void)
-{
-  register DOCSTR *dp = NULL;	/* allocated DOCSTR */
-  register LINE *lp = NULL;	/* allocated line */
-  register char *bp;		/* ptr inside line buffer */
-  register enum state state = WAITING; /* state at start */
-  int cnt = 0;			/* number of DOCSTRs read */
-
-  DOCSTR *docs = NULL;          /* chain of allocated DOCSTRS */
-  char buf[512];		/* line buffer */
-
-#ifdef DOS_NT
-  /* DOC is a binary file.  */
-  if (!isatty (fileno (stdin)))
-    setmode (fileno (stdin), O_BINARY);
-#endif
-
-  bp = buf;
-
-  while (1)			/* process one char at a time */
-    {
-      /* this char from the DOCSTR file */
-      register int ch = getchar ();
-
-      /* Beginnings */
-
-      if (state == WAITING)
-	{
-	  if (ch == MARKER)
-	    state = BEG_NAME;
-	}
-      else if (state == BEG_NAME)
-	{
-	  cnt++;
-	  if (dp == NULL)	/* first dp allocated */
-	    {
-	      docs = dp = (DOCSTR*) xmalloc (sizeof (DOCSTR));
-	    }
-	  else			/* all the rest */
-	    {
-	      dp->next = (DOCSTR*) xmalloc (sizeof (DOCSTR));
-	      dp = dp->next;
-	    }
-	  lp = NULL;
-	  dp->next = NULL;
-	  bp = buf;
-	  state = NAME_GET;
-	  /* Record whether function or variable.  */
-	  dp->type = ch;
-	  ch = getchar ();
-	}
-      else if (state == BEG_DESC)
-	{
-	  if (lp == NULL)	/* first line for dp */
-	    {
-	      dp->first = lp = (LINE*)xmalloc (sizeof (LINE));
-	    }
-	  else			/* continuing lines */
-	    {
-	      lp->next = (LINE*)xmalloc (sizeof (LINE));
-	      lp = lp->next;
-	    }
-	  lp->next = NULL;
-	  bp = buf;
-	  state = DESC_GET;
-	}
-
-      /* process gets */
-
-      if (state == NAME_GET || state == DESC_GET)
-	{
-	  if (ch != MARKER && ch != '\n' && ch != EOF)
-	    {
-	      *bp++ = ch;
-	    }
-	  else			/* saving and changing state */
-	    {
-	      *bp = NUL;
-	      bp = xstrdup (buf);
-
-	      if (state == NAME_GET)
-		dp->name = bp;
-	      else
-		lp->line = bp;
-
-	      bp = buf;
-	      state =  (ch == MARKER) ? BEG_NAME : BEG_DESC;
-	    }
-	}			/* NAME_GET || DESC_GET */
-      if (ch == EOF)
-	break;
-    }
-
-  {
-    DOCSTR **array;
-    register int i;		/* counter */
-
-    /* build array of ptrs to DOCSTRs */
-
-    array = (DOCSTR**)xmalloc (cnt * sizeof (*array));
-    for (dp = docs, i = 0; dp != NULL ; dp = dp->next)
-      array[i++] = dp;
-
-    /* sort the array by name; within each name, by type */
-
-    qsort ((char*)array, cnt, sizeof (DOCSTR*), cmpdoc);
-
-    /* write the output header */
-
-    printf ("\\input texinfo  @c -*-texinfo-*-\n");
-    printf ("@setfilename ../info/summary\n");
-    printf ("@settitle Command Summary for GNU Emacs\n");
-    printf ("@finalout\n");
-    printf ("@unnumbered Command Summary for GNU Emacs\n");
-    printf ("@table @asis\n");
-    printf ("\n");
-    printf ("@iftex\n");
-    printf ("@global@let@ITEM@item\n");
-    printf ("@def@item{@filbreak@vskip5pt@ITEM}\n");
-    printf ("@font@tensy cmsy10 scaled @magstephalf\n");
-    printf ("@font@teni cmmi10 scaled @magstephalf\n");
-    printf ("@def\\{{@tensy@char110}}\n"); /* this backslash goes with cmr10 */
-    printf ("@def|{{@tensy@char106}}\n");
-    printf ("@def@{{{@tensy@char102}}\n");
-    printf ("@def@}{{@tensy@char103}}\n");
-    printf ("@def<{{@teni@char62}}\n");
-    printf ("@def>{{@teni@char60}}\n");
-    printf ("@chardef@@64\n");
-    printf ("@catcode43=12\n");
-    printf ("@tableindent-0.2in\n");
-    printf ("@end iftex\n");
-
-    /* print each function from the array */
-
-    for (i = 0; i < cnt; i++)
-      {
-	printf ("\n@item %s @code{%s}\n@display\n",
-		array[i]->type == 'F' ? "Function" : "Variable",
-		array[i]->name);
-
-	for (lp = array[i]->first; lp != NULL ; lp = lp->next)
-	  {
-	    for (bp = lp->line; *bp; bp++)
-	      {
-		/* the characters "@{}" need special treatment */
-		if (*bp == '@' || *bp == '{' || *bp == '}')
-		  {
-		    putchar('@');
-		  }
-		putchar(*bp);
-	      }
-	    putchar ('\n');
-	  }
-	printf("@end display\n");
-	/* Try to avoid a save size overflow in the TeX output
-           routine.  */
-	if (i%100 == 0 && i > 0 && i != cnt)
-	  printf("\n@end table\n@table @asis\n");
-      }
-
-    printf ("@end table\n");
-    printf ("@bye\n");
-  }
-
-  return EXIT_SUCCESS;
-}
-
-/* arch-tag: ce28f204-1e70-4b34-8210-3d54a5662071
-   (do not change this comment) */
-
-/* sorted-doc.c ends here */
--- a/lisp/ChangeLog	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/ChangeLog	Thu Oct 28 19:57:59 2010 +0900
@@ -1,3 +1,673 @@
+2010-10-28  Glenn Morris  <rgm@gnu.org>
+
+	* term/ns-win.el (global-map, menu-bar-final-items, menu-bar-help-menu):
+	Move menu-bar related settings to ../menu-bar.el.
+	* menu-bar.el (global-map, menu-bar-final-items, menu-bar-help-menu):
+	Move ns-specific settings here from term/ns-win.el.
+
+	* simple.el (x-selection-owner-p): Remove unused declaration.
+
+2010-10-28  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* minibuffer.el (completion-cycling): New var (bug#7266).
+	(minibuffer-complete, completion--do-completion):
+	Use completion--flush-all-sorted-completions.
+	(minibuffer-complete): Only cycle if completion-cycling is set.
+	(completion--flush-all-sorted-completions): Unset completion-cycling.
+	(minibuffer-force-complete): Set completion-cycling.
+	(completion-all-sorted-completions): Move declaration before first use.
+
+2010-10-28  Leo  <sdl.web@gmail.com>
+
+	* iswitchb.el (iswitchb-kill-buffer): Avoid `iswitchb-make-buflist'
+	which changes the order of matches seen by users (bug#7231).
+
+2010-10-28  Jes Bodi Klinke  <jes@bodi-klinke.dk>  (tiny change)
+
+	* progmodes/compile.el (compilation-mode-font-lock-keywords):
+	Don't confuse -omega as "-o mega".
+
+2010-10-27  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* vc/log-edit.el (log-edit-rewrite-fixes): New var.
+	(log-edit-author): New dynamic var.
+	(log-edit-changelog-ours-p, log-edit-insert-changelog-entries): Use it
+	to return the author if different from committer.
+	(log-edit-insert-changelog): Use them to add Author: and Fixes headers.
+
+	* play/landmark.el: Adjust commenting convention.
+	(lm-nil-score): Rename from nil-score.
+	(Xscore, XXscore, XXXscore, XXXXscore, Oscore, OOscore, OOOscore)
+	(OOOOscore): Move into a let in lm-score-trans-table.
+	(lm-winning-threshold, lm-loosing-threshold): Use lm-score-trans-table.
+
+	* electric.el (electric-indent-chars): Autoload.
+	* progmodes/octave-mod.el (octave-mode):
+	* progmodes/ruby-mode.el (ruby-mode): Take advantage of it.
+	(ruby-mode-abbrev-table): Merge initialization and declaration.
+
+2010-10-27  Glenn Morris  <rgm@gnu.org>
+
+	* abbrev.el (abbrev-mode): Remove one of the three definitions of this
+	variable.
+
+	* server.el (server-host, server-port, server-auth-dir): Autoload risky.
+
+	* term/ns-win.el: Restore require of cl when compiling.
+	(menu-bar-final-items): Remove non-existent `windows' menu.
+	(ns-handle-nxopen): Optionally handle the temp-case.
+	(ns-handle-nxopentemp): Just call ns-handle-nxopen.
+	(ns-insert-file, ns-find-file): Use `pop'.
+
+2010-10-26  Glenn Morris  <rgm@gnu.org>
+
+	* term/common-win.el (xw-defined-colors): Simplify the 'ns case.
+
+2010-10-26  Adrian Robert  <Adrian.B.Robert@gmail.com>
+
+	* term/ns-win.el (ns-new-frame, ns-show-prefs): Don't add to
+	global map.
+	* term/common-win.el (x-setup-function-keys): Remove most of the
+	keymappings.  Comment on the remaining ones.
+
+2010-10-26  Peter Oliver  <p.d.oliver@mavit.org.uk>  (tiny change)
+
+	* server.el (server-port): New option.  (Bug#854)
+	(server-start): Use server-port.
+
+2010-10-26  Glenn Morris  <rgm@gnu.org>
+
+	* term/ns-win.el (ns-version-string): Remove unused declaration.
+	(ns-invocation-args): Change to x-invocation-args.
+	(ns-handle-switch, ns-handle-numeric-switch, ns-handle-iconic)
+	(ns-handle-name-switch, ns-ignore-2-arg): Remove.
+	(ns-handle-nxopen, ns-handle-nxopentemp, ns-ignore-1-arg):
+	Use x-invocation-args instead of ns-invocation-args.
+	(ns-initialize-window-system, handle-args-function-alist):
+	Use x-handle-args instead of ns-handle-args.
+	* term/common-win.el (x-handle-args): Also handle nextstep arguments.
+	* startup.el (command-line-ns-option-alist): Replace
+	ns-handle-name-switch, ns-handle-switch, ns-handle-numeric-switch,
+	ns-handle-iconic with the x- equivalents.
+
+	* term/common-win.el (x-select-enable-clipboard):
+	* term/pc-win.el (x-select-enable-clipboard): Doc fix.
+
+	* term/ns-win.el: No need to require cl when compiling.
+	(x-display-name, x-setup-function-keys, x-select-text, x-colors)
+	(xw-defined-colors): Use the common-win definitions.
+	(ns-alternatives-map): Make it an obsolete alias for x-alternatives-map.
+	(ns-handle-iconic): Make it an alias for x-handle-iconic.
+	* term/common-win.el (x-select-text, x-alternatives-map)
+	(x-setup-function-keys, x-colors, xw-defined-colors): Handle 'ns case.
+	* loadup.el [ns]: Load common-win.
+
+2010-10-26  Daiki Ueno  <ueno@unixuser.org>
+
+	* epa-mail.el (epa-mail-encrypt): Handle local-part only
+	recipients; expand mail aliases (Bug#7280).
+
+2010-10-25  Glenn Morris  <rgm@gnu.org>
+
+	* term/common-win.el (x-handle-switch): Simplify with pop.
+	Optionally handle numeric switches.
+	(x-handle-numeric-switch): Just call x-handle-switch.
+	(x-handle-initial-switch, x-handle-xrm-switch, x-handle-geometry)
+	(x-handle-name-switch, x-handle-display, x-handle-args):
+	Simplify with pop.
+
+	* term/ns-win.el: Do not require easymenu.
+	(menu-bar-edit-menu) <copy, paste, paste-from-menu, separator-undo>:
+	<spell>: Move adjustments to menu-bar.el.
+	* menu-bar.el (menu-bar-edit-menu) <copy, paste, paste-from-menu>:
+	<separator-undo, spell>: Move ns-win's adjustments here.
+	* loadup.el [ns]: Do not load easymenu.
+
+2010-10-24  Chong Yidong  <cyd@stupidchicken.com>
+
+	* image.el (image-checkbox-checked, image-checkbox-unchecked):
+	Delete (Bug#7222).
+
+	* startup.el (fancy-startup-tail): Instead of using inline images,
+	refer to image files from etc/.
+
+	* wid-edit.el (checkbox): Likewise.
+	(widget-image-find): Center image specs.
+
+2010-10-24  Glenn Morris  <rgm@gnu.org>
+
+	* term/ns-win.el (x-select-text): Doc fix.
+	* w32-fns.el (x-alternatives-map, x-setup-function-keys)
+	(x-select-text): Move to term/common-win.
+	* term/w32-win.el (xw-defined-colors): Move to common-win.
+	* term/x-win.el (xw-defined-colors, x-alternatives-map)
+	(x-setup-function-keys, x-select-text): Move to common-win.
+	* term/common-win.el (x-select-text, x-alternatives-map)
+	(x-setup-function-keys, xw-defined-colors): Merge x- and w32-
+	definitions here.
+
+2010-10-24  T.V. Raman  <tv.raman.tv@gmail.com>  (tiny change)
+
+	* net/mairix.el (mairix-searches-mode-map):
+	* mail/mspools.el (mspools-mode-map): Fix 2010-10-10 change.
+
+2010-10-24  Michael McNamara  <mac@mail.brushroad.com>
+
+	* verilog-mode.el (verilog-directive-re): Make this variable
+	auto-built for efficiency of execution and updating.
+	(verilog-extended-complete-re): Support 'pure' fucntion & task
+	declarations (these have no bodies).
+	(verilog-beg-of-statement): general cleanup to enable support of
+	'pure' fucntion & task declarations (these have no bodies).  These
+	efforts together fix Verilog bug210 from veripool; which was also
+	noticed by Steve Pearlmutter.
+	(verilog-directive-re, verilog-directive-begin, verilog-indent-re)
+	(verilog-directive-nest-re, verilog-set-auto-endcomments): Support
+	`elsif.  Reported by Shankar Giri.
+	(verilog-forward-ws&directives, verilog-in-attribute-p): Fixes for
+	attribute handling for lining up declarations and assignments.
+	(verilog-beg-of-statement-1): Fix issue where continued declaration
+	is indented differently if it is after a begin..end clock.
+	(verilog-in-attribute-p, verilog-skip-backward-comments)
+	(verilog-skip-forward-comment-p): Support proper treatment of
+	attributes by indent code. Reported by Jeff Steele.
+	(verilog-in-directive-p): Fix comment to correctly describe
+	function.
+	(verilog-backward-up-list, verilog-in-struct-region-p)
+	(verilog-backward-token, verilog-in-struct-p)
+	(verilog-in-coverage-p, verilog-do-indent)
+	(verilog-pretty-declarations): Use verilog-backward-up-list as
+	wrapper around backward-up-list inorder to properly skip comments.
+	Reported by David Rogoff.
+	(verilog-property-re, verilog-endcomment-reason-re)
+	(verilog-beg-of-statement, verilog-set-auto-endcomments)
+	(verilog-calc-1 ): Fix for assert a; else b; indentation (new form
+	of if). Reported by Max Bjurling and
+	(verilog-calc-1): Fix for clocking block in modport
+	declaration. Reported by Brian Hunter.
+
+2010-10-24  Wilson Snyder  <wsnyder@wsnyder.org>
+
+	* verilog-mode.el (verilog-auto-inst, verilog-gate-ios)
+	(verilog-gate-keywords, verilog-read-sub-decls)
+	(verilog-read-sub-decls-gate, verilog-read-sub-decls-gate-ios)
+	(verilog-read-sub-decls-line, verilog-read-sub-decls-sig): Support
+	AUTOINST for gate primitives, bug284.  Reported by Mark Johnson.
+	(verilog-read-decls): Fix spaces in V2K module parameters causing
+	mis-identification as interfaces, bug287.
+	(verilog-read-decls): Fix not treating "parameter string" as a
+	parameter in AUTOINSTPARAM.
+	(verilog-read-always-signals-recurse, verilog-read-decls): Fix not
+	treating `elsif similar to `endif inside AUTOSENSE.
+        (verilog-do-indent): Implement correct automatic or static task or
+	function end comment highlight. Reported by Steve Pearlmutter.
+	(verilog-font-lock-keywords-2): Fix highlighting of single
+	character pins, bug264.  Reported by Michael Laajanen.
+	(verilog-auto-inst, verilog-read-decls, verilog-read-sub-decls)
+	(verilog-read-sub-decls-in-interfaced, verilog-read-sub-decls-sig)
+	(verilog-subdecls-get-interfaced, verilog-subdecls-new): Support
+	interfaces with AUTOINST, bug270.  Reported by Luis Gutierrez.
+	(verilog-pretty-expr): Fix interactive arguments, bug272. Reported
+	by Mark Johnson.
+	(verilog-auto-tieoff, verilog-auto-tieoff-ignore-regexp): Add
+	'verilog-auto-tieoff-ignore-regexp' for AUTOTIEOFF,
+	bug269. Suggested by Gary Delp.
+	(verilog-mode-map, verilog-preprocess, verilog-preprocess-history)
+	(verilog-preprocessor, verilog-set-compile-command): Create
+	verilog-preprocess and verilog-preprocessor to show preprocessed
+	output.
+	(verilog-get-beg-of-line, verilog-get-end-of-line)
+	(verilog-modi-file-or-buffer, verilog-modi-name)
+	(verilog-modi-point, verilog-within-string): Move defmacro's
+	before first use to avoid warning. Reported by Steve Pearlmutter.
+	(verilog-colorize-buffer, verilog-colorize-include-files-buffer)
+	(verilog-colorize-region, verilog-highlight-buffer)
+	(verilog-highlight-includes, verilog-highlight-modules)
+	(verilog-highlight-region, verilog-mode): Rename colorize to
+	highlight to match other packages.  Disable module highlighting,
+	as received speed complaints, reenable for experimentation only
+	using new verilog-highlight-modules.
+	(verilog-read-decls): Fix regexp stack overflow in very large
+	AUTO_TEMPLATEs, bug250.
+	(verilog-auto, verilog-delete-auto, verilog-save-buffer-state)
+	(verilog-scan): Create verilog-save-buffer-state to standardize
+	making insignificant changes that shouldn't call hooks.
+	(verilog-save-no-change-functions, verilog-save-scan-cache)
+	(verilog-scan, verilog-scan-cache-ok-p, verilog-scan-region):
+	Create verilog-save-no-change-functions to wrap verilog-scan
+	preservation, and fix to work with nested preserved calls.
+	(verilog-auto-inst, verilog-auto-inst-dot-name): Support .name
+	port syntax for AUTOWIRE, and with new verilog-auto-inst-dot-name
+	generate .name with AUTOINST, bug245.  Suggested by David Rogoff.
+	(verilog-submit-bug-report): Update variable list to be complete.
+	(verilog-auto, verilog-colorize-region): Fix AUTO expansion
+	breaking on-the-fly font-locking.
+	(verilog-colorize-buffer, verilog-colorize-include-files)
+	(verilog-colorize-include-files-buffer, verilog-colorize-region)
+	(verilog-load-file-at-mouse, verilog-load-file-at-point)
+	(verilog-mode, verilog-read-inst-module-matcher): With point on a
+	AUTOINST cell instance name, middle mouse button now finds-file on
+	it.  Suggested by Brad Dobbie.
+	(verilog-alw-get-temps, verilog-auto-reset)
+	(verilog-auto-sense-sigs, verilog-read-always-signals)
+	(verilog-read-always-signals-recurse): Fix loop indexes being
+	AUTORESET. AUTORESET now assumes any variables in the
+	initialization section of a for() should be ignored.  Reported by
+	Dan Dever.
+	(verilog-error-font-lock-keywords)
+	(verilog-error-regexp-emacs-alist)
+	(verilog-error-regexp-xemacs-alist): Fix error detection of
+	Cadence HAL, reported by David Asher.  Repair drift between the
+	three similar error variables.
+	(verilog-modi-lookup, verilog-modi-lookup-cache)
+	(verilog-modi-lookup-last-current, verilog-modi-lookup-last-mod)
+	(verilog-modi-lookup-last-modi, verilog-modi-lookup-last-tick):
+	Fix slow verilog-auto expansion on very large files.
+	(verilog-read-sub-decls-expr, verilog-read-sub-decls-line): Fix
+	AUTOOUTPUT treating "1*2" as a signal name in submodule connection
+	"{1*2{...".  Broke in last revision.
+	(verilog-read-sub-decls-expr): Fix AUTOOUTPUT not detecting
+	submodule connections with replications "{#{a},#{b}}".
+
+2010-10-24  Juanma Barranquero  <lekktu@gmail.com>
+
+	* progmodes/dcl-mode.el (dcl-electric-reindent-regexps):
+	Fix typo in docstring.
+
+2010-10-24  Kenichi Handa  <handa@m17n.org>
+
+	* face-remap.el (text-scale-adjust): Call read-event with a proper
+	prompt.
+
+2010-10-24  Chong Yidong  <cyd@stupidchicken.com>
+
+	* emacs-lisp/unsafep.el: Don't mark functions that display
+	messages as safe.  Suggested by Johan Bockgård.
+
+2010-10-24  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* emacs-lisp/regexp-opt.el (regexp-opt-group, regexp-opt-charset):
+	Turn comments into docstrings.
+
+	* minibuffer.el (completion--replace): Move point where it belongs
+	when there's a common suffix (bug#7215).
+
+2010-10-24  Chong Yidong  <cyd@stupidchicken.com>
+
+	Merge read-color and facemenu-read-color (Bug#7242).
+
+	* faces.el (read-color): Use the completion code from
+	facemenu-read-color.  Require match in completion.  Doc fix.
+
+	* facemenu.el (facemenu-read-color): Alias for read-color.
+	(facemenu-set-foreground, facemenu-set-background): Use
+	read-color.
+
+	* frame.el (set-background-color, set-foreground-color)
+	(set-cursor-color, set-mouse-color, set-border-color): Use
+	read-color.
+
+2010-10-24  Leo  <sdl.web@gmail.com>
+
+	* eshell/em-unix.el (eshell-remove-entries): Use the TRASH
+	argument of delete-file and delete-directory (Bug#7011).
+
+2010-10-24  Chong Yidong  <cyd@stupidchicken.com>
+
+	* emacs-lisp/package.el (package-menu-mode-map): Inherit from
+	button-buffer-map.
+
+2010-10-24  Ralf Angeli  <angeli@caeruleus.net>
+
+	* emacs-lisp/package.el (package--generate-package-list): Make the
+	*Packages* buffer read-only.
+
+2010-10-24  Alan Mackenzie  <acm@muc.de>
+
+	* progmodes/cc-fonts.el (c-font-lock-declarations): Cache the
+	result of `c-beginning-of-decl-1' between invocations of a lambda
+	function (Bug #7265).
+
+2010-10-24  Daiki Ueno  <ueno@unixuser.org>
+
+	* epg-config.el (epg-gpg-program): Try to use "gpg2" if "gpg"
+	executable is not available on the system (Bug#7268).
+
+2010-10-24  Glenn Morris  <rgm@gnu.org>
+
+	* select.el (selection-coding-system, next-selection-coding-system):
+	Sync doc with C versions.
+
+	* w32-vars.el (x-select-enable-clipboard):
+	* term/x-win.el (x-select-enable-clipboard): Move to common-win.
+	* term/common-win.el (x-select-enable-clipboard): Move here.
+
+	* term/tty-colors.el (tty-defined-color-alist): Remove duplicate
+	definition of C variable.
+
+	* frame.el (show-trailing-whitespace, auto-hscroll-mode)
+	(display-hourglass, hourglass-delay, cursor-in-non-selected-windows):
+	Don't redefine things that are defined in C.
+	* cus-start.el: Also handle :risky, :safe, :set, and :tag.
+	(show-trailing-whitespace, auto-hscroll-mode)
+	(display-hourglass, hourglass-delay, cursor-in-non-selected-windows):
+	Set up the appropriate custom properties.
+
+2010-10-24  Chong Yidong  <cyd@stupidchicken.com>
+
+	Bind "C-c ]" to ...
+	* progmodes/f90.el (f90-mode-map): ... f90-insert-end.
+	* nxml/nxml-mode.el (nxml-mode-map): ... nxml-finish-element.
+	* textmodes/tex-mode.el (tex-mode-map): ... latex-close-block.
+	* textmodes/sgml-mode.el (sgml-mode-map): ... sgml-close-tag.
+
+2010-10-23  Glenn Morris  <rgm@gnu.org>
+
+	* textmodes/flyspell.el (flyspell-mode): If there was an error,
+	say what it was.
+
+	* frame.el (auto-hscroll-mode, cursor-in-non-selected-windows):
+	Sync docs with C version.
+
+	* term/ns-win.el (xw-defined-colors):
+	* term/x-win.el (xw-defined-colors): Make docs identical to w32-win.
+
+	* term/pc-win.el (x-select-enable-clipboard):
+	* term/x-win.el (x-select-enable-clipboard):
+	* w32-vars.el (x-select-enable-clipboard): Make doc-strings identical.
+
+	* comint.el (comint-password-prompt-regexp): Make it less vague.
+	Bump version.
+
+	* help-fns.el (doc-file-to-man, doc-file-to-info): New commands.
+
+	* help.el (finder-by-keyword): Remove unnecessary autoload.
+
+2010-10-22  Glenn Morris  <rgm@gnu.org>
+
+	* loadup.el: Unconditionally load float-sup.
+	* paren.el (show-paren-delay):
+	* emacs-lisp/float-sup.el:
+	* emulation/cua-base.el (cua-prefix-override-inhibit-delay):
+	* obsolete/lazy-lock.el (lazy-lock-defer-time, lazy-lock-stealth-nice)
+	(lazy-lock-stealth-verbose): Assume float support.
+	* ps-print.el: Assume float support on Emacs.
+	* emacs-lisp/timer.el (timer-next-integral-multiple-of-time):
+	Remove non-float branch.
+
+	* emacs-lisp/autoload.el (batch-update-autoloads): Update for
+	src/Makefile no longer being pre-processed.
+
+2010-10-22  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* emacs-lisp/find-func.el (find-library): Use test-completion.
+
+2010-10-21  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* newcomment.el (comment-dwim): Fix the intentation in the doc string.
+
+010-10-21  Michael Albinus  <michael.albinus@gmx.de>
+
+	* net/tramp-sh.el (tramp-do-file-attributes-with-stat): Do not use
+	space in stat format string.
+	(tramp-send-command): Unset $PS1 when using here documents, in
+	order not to get several prompts.
+	(tramp-get-inline-coding): Return `nil' in case of errors.
+
+2010-10-21  Daiki Ueno  <ueno@unixuser.org>
+
+	* hexl.el (hexl-mode, hexl-mode-exit):
+	Tweak revert-buffer-function to inhibit auto-mode-alist (Bug#7252).
+	(hexl-revert-buffer-function): New function.
+	(hexl-before-revert-hook, hexl-after-revert-hook): Abolish.
+
+2010-10-19  Alan Mackenzie  <acm@muc.de>
+
+	* progmodes/cc-langs.el (c-type-decl-prefix-key): C++ bit:
+	Move "\(const\|throw\|volatile\)\>" nearer the start of the regexp, so
+	that these keywords aren't wrongly matched as identifiers.
+
+	* progmodes/cc-mode.el (c-before-change, c-after-change): Move the
+	setting of c-new-BEG and c-new-END from c-before-change to
+	c-after-change.  (Bug#7181)
+
+2010-10-19  Chong Yidong  <cyd@stupidchicken.com>
+
+	* cus-face.el (custom-theme-set-faces): Revert 2010-10-18 change.
+	Don't mark as safe.
+
+	* custom.el (custom-theme-set-variables): Likewise.
+	(load-theme): Add custom-theme-set-faces and
+	custom-theme-set-variables to safe-functions while loading.
+	(custom-enabled-themes): Mark as risky.
+
+2010-10-18  Julien Danjou  <julien@danjou.info>
+
+	* bindings.el: Remove end dashes in default mode-line-format.
+
+2010-10-19  Chong Yidong  <cyd@stupidchicken.com>
+
+	* bindings.el (global-map): Bind C-d to delete-char and deletechar
+	to delete-forward-char.
+
+	* simple.el (normal-erase-is-backspace-mode): Remap delete to
+	deletechar, and hence delete-forward-char.
+
+2010-10-19  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* repeat.el (repeat): Use read-key (bug#6256).
+
+2010-10-19  Chong Yidong  <cyd@stupidchicken.com>
+
+	* emacs-lisp/unsafep.el: Don't mark functions that display
+	messages as safe.  Suggested by Johan Bockgård.
+
+2010-10-19  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* minibuffer.el (completion--replace): Move point where it belongs
+	when there's a common suffix (bug#7215).
+
+2010-10-19  Kenichi Handa  <handa@m17n.org>
+
+	* international/characters.el: Add category '|' (word breakable)
+	to fullwidth characters.
+
+2010-10-19  Michael Albinus  <michael.albinus@gmx.de>
+
+	* net/tramp-sh.el (tramp-do-file-attributes-with-stat)
+	(tramp-do-directory-files-and-attributes-with-stat): Use "e0" in
+	order to make stat results a float.  Patch by Andreas Schwab
+	<schwab@linux-m68k.org>.
+
+2010-10-18  Julien Danjou  <julien@danjou.info>
+
+	* avoid.el (mouse-avoidance-ignore-p): Ignore mouse when it is
+	hidden by `make-pointer-invisible'.
+
+2010-10-18  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* files.el (locate-file-completion-table): Strip non-matching elements
+	before checking length of list (bug#7238).
+
+2010-10-18  Chong Yidong  <cyd@stupidchicken.com>
+
+	* custom.el (custom-theme-set-variables): Mark as a safe function.
+	(load-theme): Check forms using unsafep.
+
+	* cus-face.el (custom-theme-set-faces): Mark as a safe function.
+
+2010-10-17  Agustín Martín  <agustin.martin@hispalinux.es>
+
+	* textmodes/ispell.el (ispell-aspell-find-dictionary):
+	Fix aspell data file searching (bug#7230).
+
+2010-10-16  Chong Yidong  <cyd@stupidchicken.com>
+
+	* cus-theme.el (custom-theme--migrate-settings): New var.
+	(customize-create-theme): Allow editing the `user' theme.
+	(custom-theme-add-variable, custom-theme-add-var-1)
+	(custom-theme-add-face, custom-theme-add-face-1): Add a checkbox
+	to the front of each variable or face widget.
+	(custom-theme-write): Save theme settings in the correct order.
+	Optionally, remove saved settings from user customizations.
+	(custom-theme-write-variables, custom-theme-write-faces):
+	Save only the checked widgets.
+	(customize-themes): Add a link for migrating custom settings.
+
+	* custom.el (custom-declare-theme, provide-theme):
+	Use custom-theme-name-valid-p.
+	(custom-theme-name-valid-p): Remove checks that are now
+	unnecessary since themes no longer obey load-path.
+
+	* cus-edit.el (custom-variable-value-create): For the simple
+	style, hide documentation string when hidden.
+
+2010-10-16  Chong Yidong  <cyd@stupidchicken.com>
+
+	* cus-edit.el (custom-variable, custom-face): Combine the
+	:inhibit-magic and :display-style properties into a single
+	:custom-style property.
+	(custom-toggle-hide-variable, custom-toggle-hide-face):
+	New functions.  If hiding an edited value, save it to :shown-value.
+	(custom-variable-value-create, custom-face-value-create): Use them.
+	(custom-magic-reset): Allow magic property to be unset.
+
+	* custom.el: Custom themes no longer use load-path.
+	(custom-theme-load-path): New option.  Change built-in theme
+	directory to etc/.
+	(custom-enabled-themes): Add custom-theme-load-path dependency.
+	(custom-theme--load-path): New function.
+	(load-theme, custom-available-themes): Use it.
+
+	* cus-theme.el (describe-theme-1): Use custom-theme--load-path.
+	(customize-themes): Link to custom-theme-load-path variable.
+	(custom-theme-add-var-1, custom-theme-add-face-1): Use the
+	:custom-style property.
+
+	* themes/*.el: Moved to etc/.
+
+2010-10-16  Ralf Angeli  <angeli@caeruleus.net>
+
+	* textmodes/reftex-cite.el
+	(reftex-extract-bib-entries-from-thebibliography): Do not move
+	point when searching for \bibitem entries.  Match entries with
+	spaces or tabs in front of arguments.
+
+2010-10-16  Chong Yidong  <cyd@stupidchicken.com>
+
+	* cus-theme.el (customize-create-theme): Delete overlays after
+	erasing.  If given a THEME arg, display only the faces of that arg
+	instead of custom-theme--listed-faces.
+	(custom-theme-variable-menu, custom-theme-variable-action)
+	(custom-variable-reset-theme, custom-theme-delete-variable): Delete.
+	(custom-theme-add-variable, custom-theme-add-face): Apply value
+	from the theme settings, instead of the current value.
+	(custom-theme-add-var-1, custom-theme-add-face-1): New functions.
+	(custom-theme-visit-theme): Allow calling outside theme buffers.
+	(custom-theme-merge-theme): Don't enable the theme when merging.
+	(custom-theme-write-variables, custom-theme-write-faces): Use the
+	:shown-value properties to save buffer values, not global ones.
+	(customize-themes): Display a warning about user customizations.
+
+	* cus-edit.el (custom-variable-value-create)
+	(custom-face-value-create): Obey new special properties
+	:shown-value and :inhibit-magic.
+
+2010-10-15  Michael Albinus  <michael.albinus@gmx.de>
+
+	* net/tramp-sh.el (tramp-open-connection-setup-interactive-shell):
+	Suppress expansion of tabs to spaces.  Reported by Dale Sedivec
+	<dale@codefu.org>.
+
+2010-10-14  Kenichi Handa  <handa@m17n.org>
+
+	* mail/rmail.el (rmail-show-message-1): Catch an error of
+	base64-decode-region and just show an error message (bug#7165).
+
+	* ps-mule.el (ps-mule-font-spec-list): Delete it.  Not used anymore.
+	(ps-mule-begin-job): Fix for the case that only ENCODING is set in
+	a font-spec (bug#7197).
+
+2010-10-14  Glenn Morris  <rgm@gnu.org>
+
+	* mail/emacsbug.el (report-emacs-bug): Mention debbugs.gnu.org.
+
+2010-10-14  Juanma Barranquero  <lekktu@gmail.com>
+
+	* international/mule.el (define-coding-system):
+	* international/titdic-cnv.el (quail-cxterm-package-ext-info):
+	* composite.el (compose-region): Fix typo in docstring.
+
+2010-10-14  Chong Yidong  <cyd@stupidchicken.com>
+
+	* cus-face.el (custom-theme-set-faces): Call custom-push-theme
+	only after checking the theme-face property.
+
+	* faces.el (face-spec-reset-face): Reset all attributes in one
+	single call to set-face-attribute.
+	(face-spec-match-p): Make it a defsubst.
+	(frame-set-background-mode): New arg KEEP-FACE-SPECS.
+	(x-create-frame-with-faces, tty-create-frame-with-faces)
+	(tty-set-up-initial-frame-faces): Don't recompute face specs in
+	frame-set-background-mode, since they are recomputed immediately
+	afterwards in face-set-after-frame-default.
+	(face-set-after-frame-default): Minor optimization.
+	(cursor): Provide non-trivial defface spec.
+
+	* custom.el (custom-theme-recalc-face): Simplify.
+
+2010-10-14  Jay Belanger  <jay.p.belanger@gmail.com>
+
+	* calc/calc-alg.el (math-var): Rename from `var'.
+	(math-is-polynomial, math-is-poly-rec): Replace `var'
+	with `math-var'.
+
+	* calc/calcalg2.el (math-var): Rename from `var'.
+	(calcFunc-table, math-scan-for-limits): Replace `var'
+	with `math-var'.
+
+2010-10-13  Glenn Morris  <rgm@gnu.org>
+
+	* subr.el (last): Deal with dotted lists (reported in bug#7174).
+
+2010-10-13  Stephen Berman  <stephen.berman@gmx.net>
+
+	* subr.el (last): Use `safe-length' instead of `length' (bug#7206).
+
+2010-10-13  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* net/tls.el (tls-program): Remove spurious %s from openssl.
+	(tls-starttls-switches): Remove starttls hack.
+	(open-tls-stream): Ditto.
+	(tls-find-starttls-argument): Ditto.
+
+2010-10-13  Juanma Barranquero  <lekktu@gmail.com>
+
+	* image.el (image-library-alist): Declare as obsolete alias.
+	(image-type-available-p): Use `dynamic-library-alist'.
+
+	* term/w32-win.el (dynamic-library-alist):
+	Use instead of `image-library-alist'.
+
+2010-10-13  IRIE Shinsuke  <irieshinsuke@yahoo.co.jp>  (tiny change)
+
+	* subr.el (last): Make it faster.  (Bug#7174)
+
+2010-10-13  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>  (tiny change)
+
+	* Makefile.in (compile-clean): Use `` instead of $().  (Bug#7178)
+
+2010-10-12  Chong Yidong  <cyd@stupidchicken.com>
+
+	* cus-theme.el (custom-theme--listed-faces): Add cursor face.
+	(describe-theme-1): Extract doc from unloaded themes.
+
+	* custom.el (custom-theme-name-valid-p): Don't list color-themes.
+
+	* themes/tango-theme.el:
+	* themes/tango-dark-theme.el:
+	* themes/wheatgrass-theme.el: New files.
+
 2010-10-12  Chong Yidong  <cyd@stupidchicken.com>
 
 	* cus-theme.el (describe-theme, customize-themes)
@@ -16,8 +686,8 @@
 	(custom-theme-allow-multiple-selections): New option.
 	(custom-theme-choose-mode): New major mode.
 
-	* custom.el (custom-theme-set-variables): Remove dead code.  Obey
-	custom--inhibit-theme-enable.
+	* custom.el (custom-theme-set-variables): Remove dead code.
+	Obey custom--inhibit-theme-enable.
 	(custom--inhibit-theme-enable): New var.
 	(provide-theme): Obey it.
 	(load-theme): Replace load with manual read/eval, in order to
@@ -28,8 +698,8 @@
 	* cus-edit.el (custom--initialize-widget-variables): New function.
 	(Custom-mode): Use it.
 
-	* cus-face.el (custom-theme-set-faces): Remove dead code.  Obey
-	custom--inhibit-theme-enable.
+	* cus-face.el (custom-theme-set-faces): Remove dead code.
+	Obey custom--inhibit-theme-enable.
 
 	* help-mode.el (help-theme-def, help-theme-edit): New buttons.
 
@@ -80,15 +750,14 @@
 	(custom-available-themes): New function.
 	(load-theme): Use it.
 
-	* cus-edit.el (custom-face-edit-fix-value): Use
-	custom-fix-face-spec.
+	* cus-edit.el (custom-face-edit-fix-value): Use custom-fix-face-spec.
 
 	* custom.el (custom-push-theme): Cleanup (use cond).
 	(disable-theme): Recompute the saved-face property.
 	(custom-theme-recalc-face): Follow face alias before setting prop.
 
-	* image.el (image-checkbox-checked, image-checkbox-unchecked): New
-	variables, containing checkbox images.
+	* image.el (image-checkbox-checked, image-checkbox-unchecked):
+	New variables, containing checkbox images.
 
 	* startup.el (fancy-startup-tail):
 	* wid-edit.el (checkbox): Use them.
@@ -123,8 +792,8 @@
 
 	* epa.el (epa-passphrase-callback-function): Display filename
 	passed as the 3rd arg.
-	* epa-file.el (epa-file-passphrase-callback-function): Pass
-	filename to epa-passphrase-callback-function.
+	* epa-file.el (epa-file-passphrase-callback-function):
+	Pass filename to epa-passphrase-callback-function.
 
 2010-10-09  Chong Yidong  <cyd@stupidchicken.com>
 
@@ -152,8 +821,7 @@
 	* cc-engine.el (c-forward-type): New &optional param
 	"brace-block-too".
 	(c-forward-decl-or-cast-1): cdr of return value now indicates the
-	presence of either or both of a "struct"-like keyword and
-	"typedef".
+	presence of either or both of a "struct"-like keyword and "typedef".
 
 	* cc-fonts.el (c-complex-decl-matchers): Remove the heuristic
 	fontification of declarators which follow a "}".
@@ -175,8 +843,7 @@
 	querying the password for.
 
 	* ibuffer.el (ibuffer-visit-buffer): To mimick list-buffers
-	behaviour, don't bury the ibuffer buffer when visiting other
-	buffers.
+	behaviour, don't bury the ibuffer buffer when visiting other buffers.
 
 2010-10-08  Chong Yidong  <cyd@stupidchicken.com>
 
@@ -184,12 +851,12 @@
 	(custom-magic-value-create): Pad button tags with spaces.
 	(custom-face-edit): New variable.
 	(custom-face-value-create): Determine whether to use the usual
-	face editor here, instead of using custom-face-selected.  Pass
-	face defaults to custom-face-edit widget.
+	face editor here, instead of using custom-face-selected.
+	Pass face defaults to custom-face-edit widget.
 	(custom-face-selected, custom-display-unselected): Delete widgets.
 	(custom-display-unselected-match): Function removed.
-	(custom-face-set, custom-face-mark-to-save): Accept
-	custom-face-edit widgets as the direct widget child.
+	(custom-face-set, custom-face-mark-to-save):
+	Accept custom-face-edit widgets as the direct widget child.
 
 	* wid-edit.el (widget--completing-widget): New var.
 	(widget-default-complete): Bind it when doing completion.
@@ -273,8 +940,8 @@
 	* cus-edit.el (custom-variable, custom-face): Doc fix.
 	(custom-face-edit): Add value-create attribute.
 	(custom-face-edit-value-create)
-	(custom-face-edit-value-visibility-action): New functions.  Hide
-	unused face attributes by default, and add a visibility toggle.
+	(custom-face-edit-value-visibility-action): New functions.
+	Hide unused face attributes by default, and add a visibility toggle.
 	(custom-face-edit-deactivate): Show empty values with shadow face.
 	(custom-face-selected): Only use this for face specs with default
 	attributes.
@@ -354,10 +1021,9 @@
 	(tramp-handle-file-exists-p, tramp-handle-file-newer-than-file-p):
 	New defuns, taken from tramp-smb.el.
 	(tramp-coding-system-change-eol-conversion)
-	(tramp-set-process-query-on-exit-flag): Removed.
-
-	* net/tramp-compat.el (top): Do not check for byte-compiler
-	objects.
+	(tramp-set-process-query-on-exit-flag): Remove.
+
+	* net/tramp-compat.el (top): Do not check for byte-compiler objects.
 	(tramp-compat-coding-system-change-eol-conversion)
 	(tramp-compat-set-process-query-on-exit-flag): New defuns, taken
 	from tramp.el.
@@ -366,30 +1032,30 @@
 	* net/tramp-gw.el: Replace `tramp-set-process-query-on-exit-flag'
 	by `tramp-compat-set-process-query-on-exit-flag'.
 
-	* net/tramp-imap.el (tramp-imap-file-name-handler-alist): Use
-	`tramp-handle-directory-files-and-attributes',
+	* net/tramp-imap.el (tramp-imap-file-name-handler-alist):
+	Use `tramp-handle-directory-files-and-attributes',
 	`tramp-handle-file-exists-p' and
 	`tramp-handle-file-newer-than-file-p'.
 	(tramp-imap-handle-file-exists-p)
 	(tramp-imap-handle-file-executable-p)
 	(tramp-imap-handle-file-readable-p)
 	(tramp-imap-handle-directory-files-and-attributes)
-	(tramp-imap-handle-file-newer-than-file-p): Removed.
+	(tramp-imap-handle-file-newer-than-file-p): Remove.
 
 	* net/tramp-sh.el: Replace `tramp-set-process-query-on-exit-flag'
 	by `tramp-compat-set-process-query-on-exit-flag' and
 	`tramp-coding-system-change-eol-conversion' by
 	`tramp-compat-coding-system-change-eol-conversion'.
 
-	* net/tramp-smb.el (tramp-smb-file-name-handler-alist): Use
-	`tramp-handle-directory-files-and-attributes',
+	* net/tramp-smb.el (tramp-smb-file-name-handler-alist):
+	Use `tramp-handle-directory-files-and-attributes',
 	`tramp-handle-file-exists-p' and
 	`tramp-handle-file-newer-than-file-p'.
 	(tramp-smb-handle-directory-files-and-attributes)
 	(tramp-smb-handle-file-exists-p)
-	(tramp-smb-handle-file-newer-than-file-p): Removed.
-	(tramp-smb-maybe-open-connection): Replace
-	`tramp-set-process-query-on-exit-flag' by
+	(tramp-smb-handle-file-newer-than-file-p): Remove.
+	(tramp-smb-maybe-open-connection):
+	Replace `tramp-set-process-query-on-exit-flag' by
 	`tramp-compat-set-process-query-on-exit-flag'.
 
 2010-10-05  Glenn Morris  <rgm@gnu.org>
@@ -416,7 +1082,7 @@
 	(tramp-handle-substitute-in-file-name)
 	(tramp-handle-unhandled-file-name-directory)
 	(tramp-mode-string-to-int, tramp-local-host-p)
-	(tramp-make-tramp-temp-file): Moved from tramp-sh.el.
+	(tramp-make-tramp-temp-file): Move from tramp-sh.el.
 
 	* net/tramp-gvfs.el (top):
 	* net/tramp-smb.el (top): Do not require 'tramp-sh.
@@ -433,8 +1099,8 @@
 
 	* net/gnutls.el: Improve docs.  Remove starttls and ssl emulation.
 	Provide only `open-gnutls-stream' (formerly `open-ssl-stream') and
-	`gnutls-negotiate' (formerly `starttls-negotiate').  Remove
-	trivial wrapper `starttls-open-stream'.
+	`gnutls-negotiate' (formerly `starttls-negotiate').
+	Remove trivial wrapper `starttls-open-stream'.
 
 2010-10-03  Dan Nicolaescu  <dann@ics.uci.edu>
 
@@ -448,8 +1114,8 @@
 2010-10-03  Teodor Zlatanov  <tzz@lifelogs.com>
 
 	* net/gnutls.el (starttls-negotiate): Use the plist interface to
-	`gnutls-boot'.  Make TYPE the only required parameter.  Allow
-	TRUSTFILES and KEYFILES to be lists.
+	`gnutls-boot'.  Make TYPE the only required parameter.
+	Allow TRUSTFILES and KEYFILES to be lists.
 	(open-ssl-stream): Use it.
 
 2010-10-03  Glenn Morris  <rgm@gnu.org>
@@ -470,8 +1136,8 @@
 
 2010-10-03  Chong Yidong  <cyd@stupidchicken.com>
 
-	* emacs-lisp/bytecomp.el (byte-compile-from-buffer): Remove
-	obsolete use of binary-overwrite-mode (Bug#7001).
+	* emacs-lisp/bytecomp.el (byte-compile-from-buffer):
+	Remove obsolete use of binary-overwrite-mode (Bug#7001).
 
 2010-10-03  Glenn Morris  <rgm@gnu.org>
 
@@ -506,18 +1172,18 @@
 
 2010-10-03  Chong Yidong  <cyd@stupidchicken.com>
 
-	* server.el (server-process-filter, server-return-error): Give
-	emacsclient time to shut down after receiving an error string.
+	* server.el (server-process-filter, server-return-error):
+	Give emacsclient time to shut down after receiving an error string.
 
 2010-10-02  Michael Albinus  <michael.albinus@gmx.de>
 
 	* files.el (remote-file-name-inhibit-cache): New defcustom.
 
-	* time.el (display-time-file-nonempty-p): Use
-	`remote-file-name-inhibit-cache'.
-
-	* net/tramp.el (tramp-completion-reread-directory-timeout): Fix
-	docstring.
+	* time.el (display-time-file-nonempty-p):
+	Use `remote-file-name-inhibit-cache'.
+
+	* net/tramp.el (tramp-completion-reread-directory-timeout):
+	Fix docstring.
 
 	* net/tramp-cache.el (tramp-cache-inhibit-cache): Remove.
 	(tramp-get-file-property): Replace `tramp-cache-inhibit-cache' by
@@ -538,10 +1204,9 @@
 
 	* net/tramp-sh.el (tramp-handle-verify-visited-file-modtime)
 	(tramp-handle-file-name-all-completions)
-	(tramp-handle-vc-registered): Use
-	`remote-file-name-inhibit-cache'.
-	(tramp-open-connection-setup-interactive-shell): Call
-	`tramp-cleanup-connection' directly.
+	(tramp-handle-vc-registered): Use `remote-file-name-inhibit-cache'.
+	(tramp-open-connection-setup-interactive-shell):
+	Call `tramp-cleanup-connection' directly.
 
 2010-10-02  Glenn Morris  <rgm@gnu.org>
 
--- a/lisp/ChangeLog.1	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/ChangeLog.1	Thu Oct 28 19:57:59 2010 +0900
@@ -574,7 +574,7 @@
 
 1986-01-10  Richard Mlynarik  (mly@prep)
 
-	* mail-utils.el (mail-fetch-field)
+	* mail-utils.el (mail-fetch-field):
 	regexp-quote the argument.
 
 1986-01-10  Richard M. Stallman  (rms@prep)
--- a/lisp/ChangeLog.12	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/ChangeLog.12	Thu Oct 28 19:57:59 2010 +0900
@@ -12997,8 +12997,8 @@
 
 2006-02-13  Mathias Dahl  <mathias.dahl@gmail.com>
 
-	* tumme.el: Remove history section.  If someone needs the it, it
-	can always be found in CVS.
+	* tumme.el: Remove history section.  If someone needs it, it can
+	always be found in CVS.
 
 2006-02-12  Mathias Dahl  <mathias.dahl@gmail.com>
 
--- a/lisp/ChangeLog.7	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/ChangeLog.7	Thu Oct 28 19:57:59 2010 +0900
@@ -1043,10 +1043,10 @@
 	(quail-prev-translation-block): Likewise.
 	(quail-conversion-backward-char): Call quail-error instead of
 	error.  Set quail-translating to nil.
-	(quail-conversion-forward-char): Likewize.
+	(quail-conversion-forward-char): Likewise.
 	(quail-conversion-delete-char): Call quail-error instead of error.
 	If conversion region gets vacant, set quail-converting to nil.
-	(quail-conversion-backward-delete-char): Likewize.
+	(quail-conversion-backward-delete-char): Likewise.
 	(quail-no-conversion): Just set quail-converting to nil.
 	(quail-mouse-choose-completion): Call quai-error instead of error.
 	(quail-choose-completion-string): Likewise.
--- a/lisp/ChangeLog.8	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/ChangeLog.8	Thu Oct 28 19:57:59 2010 +0900
@@ -4926,7 +4926,7 @@
 
 	* language/ethio-util.el (setup-ethiopic-environment-internal):
 	Use quail-activate-hook instead of obsolete hook quail-mode-hook.
-	(exit-ethiopic-environment): Likewize.
+	(exit-ethiopic-environment): Likewise.
 
 1999-06-12  Richard M. Stallman  <rms@gnu.org>
 
--- a/lisp/ChangeLog.9	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/ChangeLog.9	Thu Oct 28 19:57:59 2010 +0900
@@ -1034,8 +1034,8 @@
 2001-09-18  Eli Zaretskii  <eliz@is.elta.co.il>
 
 	* dired.el (dired-move-to-filename-regexp): Allow one digit in the
-	numeric month value, and allow the Kanji character after the it to
-	be missing (happens with ls-lisp's output on Japanese versions of
+	numeric month value, and allow the Kanji character after it to be
+	missing (happens with ls-lisp's output on Japanese versions of
 	MS-Windows).
 
 2001-09-18  Miles Bader  <miles@gnu.org>
@@ -16606,7 +16606,7 @@
 	0.  Give correct argument to set-auto-coding-function.
 	(tar-expunge): For goto-char, use (point-min), not 0.
 	(tar-clear-modification-flags): For goto-char, use (point-min), not 1.
-	(tar-subfile-save-buffer): Likewize.
+	(tar-subfile-save-buffer): Likewise.
 
 	* international/mule.el
 	(after-insert-file-set-buffer-file-coding-system): Call
@@ -16910,7 +16910,7 @@
 	(ccl-decode-viscii): Use translate-character.
 	(ccl-encode-viscii, ccl-encode-viscii-font)
 	(ccl-decode-vscii, ccl-encode-vscii, ccl-encode-vscii-font):
-	Likewize.
+	Likewise.
 
 	* language/cyrillic.el: Remove eval-when-compile.
 	(cyrillic-koi8-r-nonascii-translation-table): Define it as a
@@ -16925,7 +16925,7 @@
 	table made from the reverse map of above.
 	(ccl-decode-alternativnyj): Use translate-character.
 	(ccl-encode-alternativnyj, ccl-encode-alternativnyj-font):
-	Likewize
+	Likewise.
 
 	* international/mule-diag.el (non-iso-charset-alist): Specify
 	translation table symbol instead of translation table itself.
@@ -18071,8 +18071,8 @@
 
 	* emacs-lisp/cl-macs.el: Doc fixes; mainly avoid duplicating arg
 	list in doc string.  Don't quote keyword symbols.
-	* emacs-lisp/cl.el: Likewise
-	* emacs-lisp/cl-seq.el: Likewise
+	* emacs-lisp/cl.el: Likewise.
+	* emacs-lisp/cl-seq.el: Likewise.
 
 2000-05-05  Gerd Moellmann  <gerd@gnu.org>
 
--- a/lisp/Makefile.in	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/Makefile.in	Thu Oct 28 19:57:59 2010 +0900
@@ -249,7 +249,7 @@
 compile-clean:
 	@cd $(lisp); $(setwins); \
 	elcs=`echo "$$wins " | sed -e 's|/\./|/|g' -e 's|/\. | |g' -e 's| |/*.elc |g'`; \
-	for el in $$(echo $$elcs | sed -e 's/\.elc/\.el/g'); do \
+	for el in `echo $$elcs | sed -e 's/\.elc/\.el/g'`; do \
 	  if test -f "$$el" -o \! -f "$${el}c"; then :; else \
 	    echo rm "$${el}c"; \
 	    rm "$${el}c"; \
--- a/lisp/abbrev.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/abbrev.el	Thu Oct 28 19:57:59 2010 +0900
@@ -1,7 +1,7 @@
 ;;; abbrev.el --- abbrev mode commands for Emacs
 
-;; Copyright (C) 1985, 1986, 1987, 1992, 2001, 2002, 2003, 2004,
-;;   2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1986, 1987, 1992, 2001, 2002, 2003, 2004, 2005,
+;;   2006, 2007, 2008, 2009, 2010  Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 ;; Keywords: abbrev convenience
@@ -59,16 +59,6 @@
 positive, otherwise turn it off.  In Abbrev mode, inserting an
 abbreviation causes it to expand and be replaced by its expansion.")
 
-(defcustom abbrev-mode nil
-  "Enable or disable Abbrev mode.
-Non-nil means automatically expand abbrevs as they are inserted.
-
-Setting this variable with `setq' changes it for the current buffer.
-Changing it with \\[customize] sets the default value.
-Interactively, use the command `abbrev-mode'
-to enable or disable Abbrev mode in the current buffer."
-  :type 'boolean
-  :group 'abbrev-mode)
 (put 'abbrev-mode 'safe-local-variable 'booleanp)
 
 
@@ -927,5 +917,4 @@
 
 (provide 'abbrev)
 
-;; arch-tag: dbd6f3ae-dfe3-40ba-b00f-f9e3ff960df5
 ;;; abbrev.el ends here
--- a/lisp/avoid.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/avoid.el	Thu Oct 28 19:57:59 2010 +0900
@@ -278,7 +278,8 @@
 
 (defun mouse-avoidance-ignore-p ()
   (let ((mp (mouse-position)))
-    (or executing-kbd-macro	       ; don't check inside macro
+    (or (not (frame-pointer-visible-p)) ; The pointer is hidden
+        executing-kbd-macro	       ; don't check inside macro
 	(null (cadr mp))	       ; don't move unless in an Emacs frame
 	(not (eq (car mp) (selected-frame)))
 	;; Don't do anything if last event was a mouse event.
--- a/lisp/bindings.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/bindings.el	Thu Oct 28 19:57:59 2010 +0900
@@ -318,7 +318,7 @@
 mouse-2: Make current window occupy the whole frame\n\
 mouse-3: Remove current window from display")
        (recursive-edit-help-echo "Recursive edit, type C-M-c to get out")
-       (dashes (propertize "--" 'help-echo help-echo))
+       (spaces (propertize " " 'help-echo help-echo))
        (standard-mode-line-format
 	(list
 	 "%e"
@@ -334,9 +334,10 @@
 	 '(vc-mode vc-mode)
 	 (propertize "  " 'help-echo help-echo)
 	 'mode-line-modes
-	 `(which-func-mode ("" which-func-format ,dashes))
-	 `(global-mode-string ("" global-mode-string ,dashes))
-	 (propertize "-%-" 'help-echo help-echo)))
+	 `(which-func-mode ("" which-func-format ,spaces))
+	 `(global-mode-string ("" global-mode-string ,spaces))
+	 `(:eval (unless (display-graphic-p)
+		   ,(propertize "-%-" 'help-echo help-echo)))))
        (standard-mode-line-modes
 	(list
 	 (propertize "%[" 'help-echo recursive-edit-help-echo)
@@ -362,7 +363,7 @@
 				 'mouse-2 #'mode-line-widen))
 	 (propertize ")" 'help-echo help-echo)
 	 (propertize "%]" 'help-echo recursive-edit-help-echo)
-	 (propertize "--" 'help-echo help-echo)))
+	 spaces))
 
        (standard-mode-line-position
 	`((-3 ,(propertize
@@ -824,7 +825,7 @@
 (define-key global-map [?\C-\M--] 'negative-argument)
 
 (define-key global-map "\177" 'delete-backward-char)
-(define-key global-map "\C-d" 'delete-forward-char)
+(define-key global-map "\C-d" 'delete-char)
 
 (define-key global-map "\C-k" 'kill-line)
 (define-key global-map "\C-w" 'kill-region)
@@ -933,7 +934,7 @@
 ;; (define-key global-map [clearline]	'function-key-error)
 (define-key global-map [insertline]	'open-line)
 (define-key global-map [deleteline]	'kill-line)
-(define-key global-map [deletechar]	'delete-char)
+(define-key global-map [deletechar]	'delete-forward-char)
 ;; (define-key global-map [backtab]	'function-key-error)
 ;; (define-key global-map [f1]		'function-key-error)
 ;; (define-key global-map [f2]		'function-key-error)
--- a/lisp/calc/calc-alg.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/calc/calc-alg.el	Thu Oct 28 19:57:59 2010 +0900
@@ -1659,11 +1659,11 @@
 ;; math-is-poly-rec.
 (defvar math-is-poly-degree)
 (defvar math-is-poly-loose)
-(defvar var)
+(defvar math-var)
 
-(defun math-is-polynomial (expr var &optional math-is-poly-degree math-is-poly-loose)
+(defun math-is-polynomial (expr math-var &optional math-is-poly-degree math-is-poly-loose)
   (let* ((math-poly-base-variable (if math-is-poly-loose
-				      (if (eq math-is-poly-loose 'gen) var '(var XXX XXX))
+				      (if (eq math-is-poly-loose 'gen) math-var '(var XXX XXX))
 				    math-poly-base-variable))
 	 (poly (math-is-poly-rec expr math-poly-neg-powers)))
     (and (or (null math-is-poly-degree)
@@ -1672,11 +1672,11 @@
 
 (defun math-is-poly-rec (expr negpow)
   (math-poly-simplify
-   (or (cond ((or (equal expr var)
+   (or (cond ((or (equal expr math-var)
 		  (eq (car-safe expr) '^))
 	      (let ((pow 1)
 		    (expr expr))
-		(or (equal expr var)
+		(or (equal expr math-var)
 		    (setq pow (nth 2 expr)
 			  expr (nth 1 expr)))
 		(or (eq math-poly-mult-powers 1)
@@ -1690,7 +1690,7 @@
 					 (equal math-poly-mult-powers
 						(nth 1 m))
 				       (setq math-poly-mult-powers (nth 1 m)))
-				     (or (equal expr var)
+				     (or (equal expr math-var)
 					 (eq math-poly-mult-powers 1))
 				     (car m)))))
 		(if (consp pow)
@@ -1698,7 +1698,7 @@
 		      (setq pow (math-to-simple-fraction pow))
 		      (and (eq (car-safe pow) 'frac)
 			   math-poly-frac-powers
-			   (equal expr var)
+			   (equal expr math-var)
 			   (setq math-poly-frac-powers
 				 (calcFunc-lcm math-poly-frac-powers
 					       (nth 2 pow))))))
@@ -1706,10 +1706,10 @@
 		    (setq pow (math-mul pow math-poly-frac-powers)))
 		(if (integerp pow)
 		    (if (and (= pow 1)
-			     (equal expr var))
+			     (equal expr math-var))
 			(list 0 1)
 		      (if (natnump pow)
-			  (let ((p1 (if (equal expr var)
+			  (let ((p1 (if (equal expr math-var)
 					(list 0 1)
 				      (math-is-poly-rec expr nil)))
 				(n pow)
@@ -1749,7 +1749,7 @@
                                     math-is-poly-degree))
 			    (math-poly-mul p1 p2))))))
 	     ((eq (car expr) '/)
-	      (and (or (not (math-poly-depends (nth 2 expr) var))
+	      (and (or (not (math-poly-depends (nth 2 expr) math-var))
 		       (and negpow
 			    (math-is-poly-rec (nth 2 expr) nil)
 			    (setq math-poly-neg-powers
@@ -1759,13 +1759,13 @@
 		     (mapcar (function (lambda (x) (math-div x (nth 2 expr))))
 			     p1))))
 	     ((and (eq (car expr) 'calcFunc-exp)
-		   (equal var '(var e var-e)))
-	      (math-is-poly-rec (list '^ var (nth 1 expr)) negpow))
+		   (equal math-var '(var e var-e)))
+	      (math-is-poly-rec (list '^ math-var (nth 1 expr)) negpow))
 	     ((and (eq (car expr) 'calcFunc-sqrt)
 		   math-poly-frac-powers)
 	      (math-is-poly-rec (list '^ (nth 1 expr) '(frac 1 2)) negpow))
 	     (t nil))
-       (and (or (not (math-poly-depends expr var))
+       (and (or (not (math-poly-depends expr math-var))
 		math-is-poly-loose)
 	    (not (eq (car expr) 'vec))
 	    (list expr)))))
--- a/lisp/calc/calcalg2.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/calc/calcalg2.el	Thu Oct 28 19:57:59 2010 +0900
@@ -1886,9 +1886,9 @@
 ;; math-scan-for-limits.
 (defvar calc-low)
 (defvar calc-high)
-(defvar var)
+(defvar math-var)
 
-(defun calcFunc-table (expr var &optional calc-low calc-high step)
+(defun calcFunc-table (expr math-var &optional calc-low calc-high step)
   (or calc-low
       (setq calc-low '(neg (var inf var-inf)) calc-high '(var inf var-inf)))
   (or calc-high (setq calc-high calc-low calc-low 1))
@@ -1917,7 +1917,7 @@
 	      (math-working-step-2 (1+ count))
 	      (math-working-step 0))
 	  (setq expr (math-evaluate-expr
-		      (math-expr-subst expr var '(var DUMMY var-DUMMY))))
+		      (math-expr-subst expr math-var '(var DUMMY var-DUMMY))))
 	  (while (>= count 0)
 	    (setq math-working-step (1+ math-working-step)
 		  var-DUMMY calc-low
@@ -1940,7 +1940,7 @@
 	      (calc-record-why 'integerp calc-high))
 	  (calc-record-why 'integerp calc-low)))
       (append (list (or math-tabulate-function 'calcFunc-table)
-		    expr var)
+		    expr math-var)
 	      (and (not (and (equal calc-low '(neg (var inf var-inf)))
 			     (equal calc-high '(var inf var-inf))))
 		   (list calc-low calc-high))
@@ -1950,11 +1950,11 @@
   (cond ((Math-primp x))
 	((and (eq (car x) 'calcFunc-subscr)
 	      (Math-vectorp (nth 1 x))
-	      (math-expr-contains (nth 2 x) var))
+	      (math-expr-contains (nth 2 x) math-var))
 	 (let* ((calc-next-why nil)
-		(low-val (math-solve-for (nth 2 x) 1 var nil))
+		(low-val (math-solve-for (nth 2 x) 1 math-var nil))
 		(high-val (math-solve-for (nth 2 x) (1- (length (nth 1 x)))
-					  var nil))
+					  math-var nil))
 		temp)
 	   (and low-val (math-realp low-val)
 		high-val (math-realp high-val))
--- a/lisp/cedet/ede/base.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/cedet/ede/base.el	Thu Oct 28 19:57:59 2010 +0900
@@ -452,7 +452,7 @@
 ;; Targets and projects are often associated with other files, such as
 ;; header files, documentation files and the like.  Have strong
 ;; associations can make useful user commands to quickly navigate
-;; between the files base on their associations.
+;; between the files based on their associations.
 ;;
 (defun ede-header-file ()
   "Return the header file for the current buffer.
--- a/lisp/comint.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/comint.el	Thu Oct 28 19:57:59 2010 +0900
@@ -339,13 +339,15 @@
 ;; Ubuntu's sudo prompts like `[sudo] password for user:'
 ;; Some implementations of passwd use "Password (again)" as the 2nd prompt.
 ;; Something called "perforce" uses "Enter password:".
+;; See M-x comint-testsuite--test-comint-password-prompt-regexp.
 (defcustom comint-password-prompt-regexp
   (concat
-   "\\("
+   "\\(^ *\\|"
    (regexp-opt
-    '("Enter" "Enter same" "Old" "old" "New" "new" "'s" "login"
-      "Kerberos" "CVS" "UNIX" " SMB" "LDAP" "[sudo]" "Repeat" "Bad"))
-   " +\\)?"
+    '("Enter" "enter" "Enter same" "enter same" "Enter the" "enter the"
+      "Old" "old" "New" "new" "'s" "login"
+      "Kerberos" "CVS" "UNIX" " SMB" "LDAP" "[sudo]" "Repeat" "Bad") t)
+   " +\\)"
    (regexp-opt
     '("password" "Password" "passphrase" "Passphrase"
       "pass phrase" "Pass phrase"))
@@ -353,6 +355,7 @@
 \\(?: for [^:]+\\)?:\\s *\\'")
   "Regexp matching prompts for passwords in the inferior process.
 This is used by `comint-watch-for-password-prompt'."
+  :version "24.1"
   :type 'regexp
   :group 'comint)
 
@@ -3748,5 +3751,4 @@
 
 (provide 'comint)
 
-;; arch-tag: 1793314c-09db-40be-9549-9aeae3e75164
 ;;; comint.el ends here
--- a/lisp/composite.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/composite.el	Thu Oct 28 19:57:59 2010 +0900
@@ -213,7 +213,7 @@
 
 If it is a string, the elements are alternate characters.  In
 this case, TAB element has a special meaning.  If the first
-characer is TAB, the glyphs are displayed with left padding space
+character is TAB, the glyphs are displayed with left padding space
 so that no pixel overlaps with the previous column.  If the last
 character is TAB, the glyphs are displayed with right padding
 space so that no pixel overlaps with the following column.
--- a/lisp/cus-edit.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/cus-edit.el	Thu Oct 28 19:57:59 2010 +0900
@@ -2077,7 +2077,8 @@
 (defun custom-magic-reset (widget)
   "Redraw the :custom-magic property of WIDGET."
   (let ((magic (widget-get widget :custom-magic)))
-    (widget-value-set magic (widget-value magic))))
+    (when magic
+      (widget-value-set magic (widget-value magic)))))
 
 ;;; The `custom' Widget.
 
@@ -2460,7 +2461,14 @@
 :custom-form should be a symbol describing how to display and
   edit the variable---either `edit' (using edit widgets),
   `lisp' (as a Lisp sexp), or `mismatch' (should not happen);
-  if nil, use the return value of `custom-variable-default-form'."
+  if nil, use the return value of `custom-variable-default-form'.
+
+:shown-value, if non-nil, should be a list whose `car' is the
+  variable value to display in place of the current value.
+
+:custom-style describes the widget interface style; nil is the
+  default style, while `simple' means a simpler interface that
+  inhibits the magic custom-state widget."
   :format "%v"
   :help-echo "Set or reset this variable."
   :documentation-property #'custom-variable-documentation
@@ -2512,9 +2520,13 @@
 	 (get (or (get symbol 'custom-get) 'default-value))
 	 (prefix (widget-get widget :custom-prefix))
 	 (last (widget-get widget :custom-last))
-	 (value (if (default-boundp symbol)
-		    (funcall get symbol)
-		  (widget-get conv :value)))
+	 (style (widget-get widget :custom-style))
+	 (value (let ((shown-value (widget-get widget :shown-value)))
+		  (cond (shown-value
+			 (car shown-value))
+			((default-boundp symbol)
+			 (funcall get symbol))
+			(t (widget-get conv :value)))))
 	 (state (or (widget-get widget :custom-state)
 		    (if (memq (custom-variable-state symbol value)
 			      (widget-get widget :hidden-states))
@@ -2543,7 +2555,7 @@
 		  :on "Hide"
 		  :off-image "right"
 		  :off "Show Value"
-		  :action 'custom-toggle-parent
+		  :action 'custom-toggle-hide-variable
 		  nil)
 		 buttons)
 	   (insert " ")
@@ -2563,7 +2575,7 @@
 		  :off "Show"
 		  :on-image "down"
 		  :off-image "right"
-		  :action 'custom-toggle-parent
+		  :action 'custom-toggle-hide-variable
 		  t)
 		 buttons)
 	   (insert " ")
@@ -2593,7 +2605,7 @@
 		  :off "Show"
 		  :on-image "down"
 		  :off-image "right"
-		  :action 'custom-toggle-parent
+		  :action 'custom-toggle-hide-variable
 		  t)
 		 buttons)
 	   (insert " ")
@@ -2622,15 +2634,18 @@
       (unless (eq (preceding-char) ?\n)
 	(widget-insert "\n"))
       ;; Create the magic button.
-      (let ((magic (widget-create-child-and-convert
-		    widget 'custom-magic nil)))
-	(widget-put widget :custom-magic magic)
-	(push magic buttons))
+      (unless (eq style 'simple)
+	(let ((magic (widget-create-child-and-convert
+		      widget 'custom-magic nil)))
+	  (widget-put widget :custom-magic magic)
+	  (push magic buttons)))
       (widget-put widget :buttons buttons)
       ;; Insert documentation.
       (widget-put widget :documentation-indent 3)
-      (widget-add-documentation-string-button
-       widget :visibility-widget 'custom-visibility)
+      (unless (and (eq style 'simple)
+		   (eq state 'hidden))
+	(widget-add-documentation-string-button
+	 widget :visibility-widget 'custom-visibility))
 
       ;; The comment field
       (unless (eq state 'hidden)
@@ -2657,6 +2672,31 @@
 	  (custom-add-parent-links widget))
 	(custom-add-see-also widget)))))
 
+(defun custom-toggle-hide-variable (visibility-widget &rest ignore)
+  "Toggle the visibility of a `custom-variable' parent widget.
+By default, this signals an error if the parent has unsaved
+changes.  If the parent has a `simple' :custom-style property,
+the present value is saved to its :shown-value property instead."
+  (let ((widget (widget-get visibility-widget :parent)))
+    (unless (eq (widget-type widget) 'custom-variable)
+      (error "Invalid widget type"))
+    (custom-load-widget widget)
+    (let ((state (widget-get widget :custom-state)))
+      (if (eq state 'hidden)
+	  (widget-put widget :custom-state 'unknown)
+	;; In normal interface, widget can't be hidden if modified.
+	(when (memq state '(invalid modified set))
+	  (if (eq (widget-get widget :custom-style) 'simple)
+	      (widget-put widget :shown-value
+			  (list (widget-value
+				 (car-safe
+				  (widget-get widget :children)))))
+	    (error "There are unsaved changes")))
+	(widget-put widget :documentation-shown nil)
+	(widget-put widget :custom-state 'hidden))
+      (custom-redraw widget)
+      (widget-setup))))
+
 (defun custom-tag-action (widget &rest args)
   "Pass :action to first child of WIDGET's parent."
   (apply 'widget-apply (car (widget-get (widget-get widget :parent) :children))
@@ -3281,12 +3321,15 @@
   Lisp sexp), or `mismatch' (should not happen); if nil, use
   the return value of `custom-face-default-form'.
 
-:display-style, if non-nil, should be a symbol describing the
-  style of display to use.  If the value is `concise', a more
-  concise interface is shown.
-
-:sample-indent, if non-nil, should be an integer; this is the
-number of columns to which to indent the face sample."
+:custom-style describes the widget interface style; nil is the
+  default style, while `simple' means a simpler interface that
+  inhibits the magic custom-state widget.
+
+:sample-indent, if non-nil, is the number of columns to which to
+  indent the face sample (an integer).
+
+:shown-value, if non-nil, is the face spec to display as the value
+  of the widget, instead of the current face spec."
   :sample-face 'custom-face-tag
   :help-echo "Set or reset this face."
   :documentation-property #'face-doc-string
@@ -3380,6 +3423,29 @@
 	(setq spec `((t ,(face-attr-construct face (selected-frame))))))
     (custom-pre-filter-face-spec spec)))
 
+(defun custom-toggle-hide-face (visibility-widget &rest ignore)
+  "Toggle the visibility of a `custom-face' parent widget.
+By default, this signals an error if the parent has unsaved
+changes.  If the parent has a `simple' :custom-style property,
+the present value is saved to its :shown-value property instead."
+  (let ((widget (widget-get visibility-widget :parent)))
+    (unless (eq (widget-type widget) 'custom-face)
+      (error "Invalid widget type"))
+    (custom-load-widget widget)
+    (let ((state (widget-get widget :custom-state)))
+      (if (eq state 'hidden)
+	  (widget-put widget :custom-state 'unknown)
+	;; In normal interface, widget can't be hidden if modified.
+	(when (memq state '(invalid modified set))
+	  (if (eq (widget-get widget :custom-style) 'simple)
+	      (widget-put widget :shown-value
+			  (custom-face-widget-to-spec widget))
+	    (error "There are unsaved changes")))
+	(widget-put widget :documentation-shown nil)
+	(widget-put widget :custom-state 'hidden))
+      (custom-redraw widget)
+      (widget-setup))))
+
 (defun custom-face-value-create (widget)
   "Create a list of the display specifications for WIDGET."
   (let* ((buttons (widget-get widget :buttons))
@@ -3387,7 +3453,7 @@
 	 (tag (or (widget-get widget :tag)
 		  (prin1-to-string symbol)))
 	 (hiddenp (eq (widget-get widget :custom-state) 'hidden))
-	 (style   (widget-get widget :display-style))
+	 (style   (widget-get widget :custom-style))
 	 children)
 
     (if (eq custom-buffer-style 'tree)
@@ -3410,7 +3476,7 @@
 	       :help-echo "Hide or show this face."
 	       :on "Hide" :off "Show"
 	       :on-image "down" :off-image "right"
-	       :action 'custom-toggle-parent
+	       :action 'custom-toggle-hide-face
 	       (not hiddenp))
 	      buttons)
 	;; Face name (tag).
@@ -3429,20 +3495,25 @@
 	     (indent-to-column sample-indent)))
       (push (widget-create-child-and-convert
 	     widget 'item
-	     :format "[%{%t%}]" :sample-face symbol :tag "sample")
+	     :format "[%{%t%}]"
+	     :sample-face (let ((spec (widget-get widget :shown-value)))
+			    (if spec (face-spec-choose spec) symbol))
+	     :tag "sample")
 	    buttons)
-      ;; Magic.
       (insert "\n")
-      (let ((magic (widget-create-child-and-convert
-		    widget 'custom-magic nil)))
-	(widget-put widget :custom-magic magic)
-	(push magic buttons))
+
+      ;; Magic.
+      (unless (eq (widget-get widget :custom-style) 'simple)
+	(let ((magic (widget-create-child-and-convert
+		      widget 'custom-magic nil)))
+	  (widget-put widget :custom-magic magic)
+	  (push magic buttons)))
 
       ;; Update buttons.
       (widget-put widget :buttons buttons)
 
       ;; Insert documentation.
-      (unless (and hiddenp (eq style 'concise))
+      (unless (and hiddenp (eq style 'simple))
 	(widget-put widget :documentation-indent 3)
 	(widget-add-documentation-string-button
 	 widget :visibility-widget 'custom-visibility)
@@ -3465,7 +3536,8 @@
 	(unless (widget-get widget :custom-form)
 	  (widget-put widget :custom-form custom-face-default-form))
 
-	(let* ((spec (custom-face-get-current-spec symbol))
+	(let* ((spec (or (widget-get widget :shown-value)
+			 (custom-face-get-current-spec symbol)))
 	       (form (widget-get widget :custom-form))
 	       (indent (widget-get widget :indent))
 	       face-alist face-entry spec-default spec-match editor)
--- a/lisp/cus-face.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/cus-face.el	Thu Oct 28 19:57:59 2010 +0900
@@ -328,15 +328,18 @@
 	;; is aliased to.
 	(if (get face 'face-alias)
 	    (setq face (get face 'face-alias)))
-	(custom-push-theme 'theme-face face theme 'set spec)
-	(unless custom--inhibit-theme-enable
-	  ;; Now set the face spec.
+	(if custom--inhibit-theme-enable
+	    ;; Just update theme settings.
+	    (custom-push-theme 'theme-face face theme 'set spec)
+	  ;; Update theme settings and set the face spec.
 	  (let ((now (nth 2 entry))
 		(comment (nth 3 entry))
 		(oldspec (get face 'theme-face)))
 	    (when (not (and oldspec (eq 'user (caar oldspec))))
 	      (put face 'saved-face spec)
 	      (put face 'saved-face-comment comment))
+	    ;; Do this AFTER checking the `theme-face' property.
+	    (custom-push-theme 'theme-face face theme 'set spec)
 	    (when (or now immediate)
 	      (put face 'force-face (if now 'rogue 'immediate)))
 	    (when (or now immediate (facep face))
--- a/lisp/cus-start.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/cus-start.el	Thu Oct 28 19:57:59 2010 +0900
@@ -96,6 +96,11 @@
 				       "21.1")
 	     (line-spacing display (choice (const :tag "none" nil) integer)
 			   "22.1")
+	     (cursor-in-non-selected-windows
+	      cursor boolean nil t :tag "Cursor In Non-selected Windows"
+	      :set #'(lambda (symbol value)
+		       (set-default symbol value)
+		       (force-mode-line-update t)))
 	     ;; callint.c
 	     (mark-even-if-inactive editing-basics boolean)
 	     ;; callproc.c
@@ -327,6 +332,8 @@
 				  (other :tag "Always" t))
 				 "23.1")
 	     ;; xdisp.c
+	     (show-trailing-whitespace whitespace-faces boolean nil nil
+				       :safe booleanp)
 	     (scroll-step windows integer)
 	     (scroll-conservatively windows integer)
 	     (scroll-margin windows integer)
@@ -362,6 +369,9 @@
 		      (const :tag "Text-image-horiz" :value text-image-horiz)
 		      (const :tag "System default" :value nil)) "23.3")
              (tool-bar-max-label-size frames integer "23.3")
+	     (auto-hscroll-mode scrolling boolean "21.1")
+	     (display-hourglass cursor boolean)
+	     (hourglass-delay cursor number)
 
 	     ;; xfaces.c
 	     (scalable-fonts-allowed display boolean "22.1")
@@ -379,7 +389,7 @@
 	     (x-stretch-cursor display boolean "21.1")
 	     ;; xsettings.c
 	     (font-use-system-font font-selection boolean "23.2")))
-      this symbol group type standard version native-p
+      this symbol group type standard version native-p rest prop propval
       ;; This function turns a value
       ;; into an expression which produces that value.
       (quoter (lambda (sexp)
@@ -404,6 +414,7 @@
 		       (nth 4 this)
 		     (when (default-boundp symbol)
 		       (funcall quoter (default-value symbol))))
+	  rest (nthcdr 5 this)
 	  ;; Don't complain about missing variables which are
 	  ;; irrelevant to this platform.
 	  native-p (save-match-data
@@ -436,6 +447,11 @@
       ;; Save the standard value, unless we already did.
       (or (get symbol 'standard-value)
 	  (put symbol 'standard-value (list standard)))
+      ;; We need these properties independent of whether cus-start is loaded.
+      (if (setq prop (memq :safe rest))
+	  (put symbol 'safe-local-variable (cadr prop)))
+      (if (setq prop (memq :risky rest))
+	  (put symbol 'risky-local-variable (cadr prop)))
       ;; If this is NOT while dumping Emacs,
       ;; set up the rest of the customization info.
       (unless purify-flag
@@ -443,18 +459,25 @@
 	(custom-add-to-group group symbol 'custom-variable)
 	;; Set the type.
 	(put symbol 'custom-type type)
-	(put symbol 'custom-version version)))))
+	(put symbol 'custom-version version)
+	(while rest
+	  (setq prop (car rest)
+		propval (cadr rest)
+		rest (nthcdr 2 rest))
+	  (cond ((memq prop '(:risky :safe))) ; handled above
+		((eq prop :set)
+		 (put symbol 'custom-set propval))
+		((eq prop :tag)
+		 (put symbol 'custom-tag propval))))))))
 
 (custom-add-to-group 'iswitchb 'read-buffer-function 'custom-variable)
 (custom-add-to-group 'font-lock 'open-paren-in-column-0-is-defun-start
 		     'custom-variable)
 
-;; Record cus-start as loaded
-;; if we have set up all the info that we can set up.
-;; Don't record cus-start as loaded
-;; if we have set up only the standard values.
+;; Record cus-start as loaded if we have set up all the info that we can.
+;; Don't record it as loaded if we have only set up the standard values
+;; and safe/risky properties.
 (unless purify-flag
   (provide 'cus-start))
 
-;; arch-tag: 4502730d-bcb3-4f5e-99a3-a86f2d54af60
 ;;; cus-start.el ends here
--- a/lisp/cus-theme.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/cus-theme.el	Thu Oct 28 19:57:59 2010 +0900
@@ -41,7 +41,7 @@
     map)
   "Keymap for `custom-new-theme-mode'.")
 
-(define-derived-mode custom-new-theme-mode nil "Cus-Theme"
+(define-derived-mode custom-new-theme-mode nil "Custom-Theme"
   "Major mode for editing Custom themes.
 Do not call this mode function yourself.  It is meant for internal use."
   (use-local-map custom-new-theme-mode-map)
@@ -50,13 +50,16 @@
 (put 'custom-new-theme-mode 'mode-class 'special)
 
 (defvar custom-theme-name nil)
+;; Each element has the form (VAR CHECKBOX-WIDGET VAR-WIDGET)
 (defvar custom-theme-variables nil)
+;; Each element has the form (FACE CHECKBOX-WIDGET FACE-WIDGET)
 (defvar custom-theme-faces nil)
 (defvar custom-theme-description nil)
+(defvar custom-theme--migrate-settings nil)
 (defvar custom-theme-insert-variable-marker nil)
 (defvar custom-theme-insert-face-marker nil)
 
-(defvar custom-theme--listed-faces '(default fixed-pitch
+(defvar custom-theme--listed-faces '(default cursor fixed-pitch
   variable-pitch escape-glyph minibuffer-prompt highlight region
   shadow secondary-selection trailing-whitespace
   font-lock-builtin-face font-lock-comment-delimiter-face
@@ -78,23 +81,32 @@
 ;;;###autoload
 (defun customize-create-theme (&optional theme buffer)
   "Create or edit a custom theme.
-THEME, if non-nil, should be an existing theme to edit.
-BUFFER, if non-nil, should be a buffer to use."
+THEME, if non-nil, should be an existing theme to edit.  If THEME
+is `user', provide an option to remove these as custom settings.
+BUFFER, if non-nil, should be a buffer to use; the default is
+named *Custom Theme*."
   (interactive)
   (switch-to-buffer (get-buffer-create (or buffer "*Custom Theme*")))
-  ;; Save current faces
   (let ((inhibit-read-only t))
-    (erase-buffer))
+    (erase-buffer)
+    (dolist (ov (overlays-in (point-min) (point-max)))
+      (delete-overlay ov)))
   (custom-new-theme-mode)
   (make-local-variable 'custom-theme-name)
   (set (make-local-variable 'custom-theme--save-name) theme)
   (set (make-local-variable 'custom-theme-faces) nil)
   (set (make-local-variable 'custom-theme-variables) nil)
   (set (make-local-variable 'custom-theme-description) "")
+  (set (make-local-variable 'custom-theme--migrate-settings) nil)
   (make-local-variable 'custom-theme-insert-face-marker)
   (make-local-variable 'custom-theme-insert-variable-marker)
   (make-local-variable 'custom-theme--listed-faces)
 
+  (if (eq theme 'user)
+      (widget-insert "This buffer contains all the Custom settings you have made.
+You can convert them into a new custom theme, and optionally
+remove them from your saved Custom file.\n\n"))
+
   (widget-create 'push-button
 		 :tag " Visit Theme "
 		 :help-echo "Insert the settings of a pre-defined theme."
@@ -107,64 +119,92 @@
 		 :action (lambda (widget &optional event)
 			   (call-interactively 'custom-theme-merge-theme)))
   (widget-insert "  ")
-  (widget-create 'push-button :notify 'revert-buffer " Revert ")
+  (widget-create 'push-button
+		 :tag " Revert "
+		 :help-echo "Revert this buffer to its original state."
+		 :action (lambda (&rest ignored) (revert-buffer)))
 
   (widget-insert "\n\nTheme name : ")
   (setq custom-theme-name
 	(widget-create 'editable-field
-		       :value (if theme (symbol-name theme) "")))
+		       :value (if (and theme (not (eq theme 'user)))
+				  (symbol-name theme)
+				"")))
   (widget-insert "Description: ")
   (setq custom-theme-description
 	(widget-create 'text
 		       :value (format-time-string "Created %Y-%m-%d.")))
-  (widget-insert "             ")
   (widget-create 'push-button
      		 :notify (function custom-theme-write)
      		 " Save Theme ")
-  ;; Face widgets
-  (widget-insert "\n\n  Theme faces:\n")
-  (let (widget)
-    (dolist (face custom-theme--listed-faces)
-      (widget-insert "  ")
-      (setq widget (widget-create 'custom-face
-				  :documentation-shown t
-				  :tag (custom-unlispify-tag-name face)
-				  :value face
-				  :display-style 'concise
-				  :custom-state 'hidden
-				  :sample-indent 34))
-      (custom-magic-reset widget)
-      (push (cons face widget) custom-theme-faces)))
-  (insert " ")
-  (setq custom-theme-insert-face-marker (point-marker))
-  (insert " ")
-  (widget-create 'push-button
-		 :tag "Insert Additional Face"
-		 :help-echo "Add another face to this theme."
-		 :follow-link 'mouse-face
-		 :button-face 'custom-link
-		 :mouse-face 'highlight
-		 :pressed-face 'highlight
-		 :action (lambda (widget &optional event)
-			   (call-interactively 'custom-theme-add-face)))
-  (widget-insert "\n\n  Theme variables:\n ")
-  (setq custom-theme-insert-variable-marker (point-marker))
-  (widget-insert ?\s)
-  (widget-create 'push-button
-		 :tag "Insert Variable"
-		 :help-echo "Add another variable to this theme."
-		 :follow-link 'mouse-face
-		 :button-face 'custom-link
-		 :mouse-face 'highlight
-		 :pressed-face 'highlight
-		 :action (lambda (widget &optional event)
-			   (call-interactively 'custom-theme-add-variable)))
-  (widget-insert ?\n)
-  (if theme
-      (custom-theme-merge-theme theme))
-  (widget-setup)
-  (goto-char (point-min))
-  (message ""))
+  (when (eq theme 'user)
+    (setq custom-theme--migrate-settings t)
+    (widget-insert "  ")
+    (widget-create 'checkbox
+		   :value custom-theme--migrate-settings
+		   :action (lambda (widget &optional event)
+			     (when (widget-value widget)
+			       (widget-toggle-action widget event)
+			       (setq custom-theme--migrate-settings
+				     (widget-value widget)))))
+    (widget-insert (propertize " Remove saved theme settings from Custom save file."
+			       'face '(variable-pitch (:height 0.9)))))
+
+  (let (vars values faces face-specs)
+
+    ;; Load the theme settings.
+    (when theme
+      (unless (eq theme 'user)
+	(load-theme theme t))
+      (dolist (setting (get theme 'theme-settings))
+	(if (eq (car setting) 'theme-value)
+	    (progn (push (nth 1 setting) vars)
+	    	   (push (nth 3 setting) values))
+	  (push (nth 1 setting) faces)
+	  (push (nth 3 setting) face-specs))))
+
+    ;; If THEME is non-nil, insert all of that theme's faces.
+    ;; Otherwise, insert those in `custom-theme--listed-faces'.
+    (widget-insert "\n\n  Theme faces:\n ")
+    (if theme
+	(while faces
+	  (custom-theme-add-face-1 (pop faces) (pop face-specs)))
+      (dolist (face custom-theme--listed-faces)
+	(custom-theme-add-face-1 face nil)))
+    (setq custom-theme-insert-face-marker (point-marker))
+    (widget-insert " ")
+    (widget-create 'push-button
+		   :tag "Insert Additional Face"
+		   :help-echo "Add another face to this theme."
+		   :follow-link 'mouse-face
+		   :button-face 'custom-link
+		   :mouse-face 'highlight
+		   :pressed-face 'highlight
+		   :action (lambda (widget &optional event)
+			     (call-interactively 'custom-theme-add-face)))
+
+    ;; If THEME is non-nil, insert all of that theme's variables.
+    (widget-insert "\n\n  Theme variables:\n ")
+    (if theme
+	(while vars
+	  (if (eq (car vars) 'custom-enabled-themes)
+	      (progn (pop vars) (pop values))
+	    (custom-theme-add-var-1 (pop vars) (pop values)))))
+    (setq custom-theme-insert-variable-marker (point-marker))
+    (widget-insert " ")
+    (widget-create 'push-button
+		   :tag "Insert Variable"
+		   :help-echo "Add another variable to this theme."
+		   :follow-link 'mouse-face
+		   :button-face 'custom-link
+		   :mouse-face 'highlight
+		   :pressed-face 'highlight
+		   :action (lambda (widget &optional event)
+			     (call-interactively 'custom-theme-add-variable)))
+    (widget-insert ?\n)
+    (widget-setup)
+    (goto-char (point-min))
+    (message "")))
 
 (defun custom-theme-revert (ignore-auto noconfirm)
   (when (or noconfirm (y-or-n-p "Discard current changes? "))
@@ -172,181 +212,133 @@
 
 ;;; Theme variables
 
-(defun custom-theme-add-variable (symbol)
-  (interactive "vVariable name: ")
-  (cond ((assq symbol custom-theme-variables)
-	 (message "%s is already in the theme" (symbol-name symbol)))
-	((not (boundp symbol))
-	 (message "%s is not defined as a variable" (symbol-name symbol)))
-	((eq symbol 'custom-enabled-themes)
-	 (message "Custom theme cannot contain `custom-enabled-themes'"))
-	(t
-	 (save-excursion
-	   (goto-char custom-theme-insert-variable-marker)
-	   (widget-insert " ")
-	   (let ((widget (widget-create 'custom-variable
-					:tag (custom-unlispify-tag-name symbol)
-					:custom-level 0
-					:action 'custom-theme-variable-action
-					:custom-state 'unknown
-					:value symbol)))
-	     (push (cons symbol widget) custom-theme-variables)
-	     (custom-magic-reset widget))
-	   (widget-insert " ")
-	   (move-marker custom-theme-insert-variable-marker (point))
-	   (widget-setup)))))
+(defun custom-theme-add-variable (var value)
+  "Add a widget for VAR (a symbol) to the *New Custom Theme* buffer.
+VALUE should be a value to which to set the widget; when called
+interactively, this defaults to the current value of VAR."
+  (interactive
+   (let ((v (read-variable "Variable name: ")))
+     (list v (symbol-value v))))
+  (let ((entry (assq var custom-theme-variables)))
+    (cond ((null entry)
+	   ;; If VAR is not yet in the buffer, add it.
+	   (save-excursion
+	     (goto-char custom-theme-insert-variable-marker)
+	     (custom-theme-add-var-1 var value)
+	     (move-marker custom-theme-insert-variable-marker (point))
+	     (widget-setup)))
+	  ;; Otherwise, alter that var widget.
+	  (t
+	   (widget-value-set (nth 1 entry) t)
+	   (let ((widget (nth 2 entry)))
+	     (widget-put widget :shown-value (list value))
+	     (custom-redraw widget))))))
 
-(defvar custom-theme-variable-menu
-  `(("Reset to Current" custom-redraw
-     (lambda (widget)
-       (and (boundp (widget-value widget))
-	    (memq (widget-get widget :custom-state)
-		  '(themed modified changed)))))
-    ("Reset to Theme Value" custom-variable-reset-theme
-     (lambda (widget)
-       (let ((theme  (intern (widget-value custom-theme-name)))
-	     (symbol (widget-value widget))
-	     found)
-	 (and (custom-theme-p theme)
-	      (dolist (setting (get theme 'theme-settings) found)
-	 	(if (and (eq (cadr setting) symbol)
-	 		 (eq (car  setting) 'theme-value))
-	 	    (setq found t)))))))
-    ("---" ignore ignore)
-    ("Delete" custom-theme-delete-variable nil))
-  "Alist of actions for the `custom-variable' widget in Custom Theme Mode.
-See the documentation for `custom-variable'.")
-
-(defun custom-theme-variable-action (widget &optional event)
-  "Show the Custom Theme Mode menu for a `custom-variable' widget.
-Optional EVENT is the location for the menu."
-  (let ((custom-variable-menu custom-theme-variable-menu))
-    (custom-variable-action widget event)))
-
-(defun custom-variable-reset-theme (widget)
-  "Reset WIDGET to its value for the currently edited theme."
-  (let ((theme  (intern (widget-value custom-theme-name)))
-	(symbol (widget-value widget))
-	found)
-    (dolist (setting (get theme 'theme-settings))
-      (if (and (eq (cadr setting) symbol)
-	       (eq (car  setting) 'theme-value))
-	  (setq found setting)))
-    (widget-value-set (car (widget-get widget :children))
-		      (nth 3 found)))
-  (widget-put widget :custom-state 'themed)
-  (custom-redraw-magic widget)
-  (widget-setup))
-
-(defun custom-theme-delete-variable (widget)
-  (setq custom-theme-variables
-	(assq-delete-all (widget-value widget) custom-theme-variables))
-  (widget-delete widget))
+(defun custom-theme-add-var-1 (symbol val)
+  (widget-insert " ")
+  (push (list symbol
+	      (prog1 (widget-create 'checkbox
+				    :value t
+				    :help-echo "Enable/disable this variable.")
+		(widget-insert " "))
+	      (widget-create 'custom-variable
+			     :tag (custom-unlispify-tag-name symbol)
+			     :value symbol
+			     :shown-value (list val)
+			     :notify 'ignore
+			     :custom-level 0
+			     :custom-state 'hidden
+			     :custom-style 'simple))
+	custom-theme-variables)
+  (widget-insert " "))
 
 ;;; Theme faces
 
-(defun custom-theme-add-face (symbol)
-  (interactive (list (read-face-name "Face name" nil nil)))
-  (cond ((assq symbol custom-theme-faces)
-	 (message "%s is already in the theme" (symbol-name symbol)))
-	((not (facep symbol))
-	 (message "%s is not defined as a face" (symbol-name symbol)))
-	(t
-	 (save-excursion
-	   (goto-char custom-theme-insert-face-marker)
-	   (widget-insert " ")
-	   (let ((widget (widget-create 'custom-face
-					:tag (custom-unlispify-tag-name symbol)
-					:custom-level 0
-					:action 'custom-theme-face-action
-					:custom-state 'unknown
-					:display-style 'concise
-					:sample-indent 34
-					:value symbol)))
-	     (push (cons symbol widget) custom-theme-faces)
-	     (custom-magic-reset widget)
-	     (widget-insert " ")
+(defun custom-theme-add-face (face &optional spec)
+  "Add a widget for FACE (a symbol) to the *New Custom Theme* buffer.
+SPEC, if non-nil, should be a face spec to which to set the widget."
+  (interactive (list (read-face-name "Face name" nil nil) nil))
+  (unless (or (facep face) spec)
+    (error "`%s' has no face definition" face))
+  (let ((entry (assq face custom-theme-faces)))
+    (cond ((null entry)
+	   ;; If FACE is not yet in the buffer, add it.
+	   (save-excursion
+	     (goto-char custom-theme-insert-face-marker)
+	     (custom-theme-add-face-1 face spec)
 	     (move-marker custom-theme-insert-face-marker (point))
-	     (widget-setup))))))
+	     (widget-setup)))
+	  ;; Otherwise, if SPEC is supplied, alter that face widget.
+	  (spec
+	   (widget-value-set (nth 1 entry) t)
+	   (let ((widget (nth 2 entry)))
+	     (widget-put widget :shown-value spec)
+	     (custom-redraw widget)))
+	  ((called-interactively-p 'interactive)
+	   (error "`%s' is already present" face)))))
 
-(defvar custom-theme-face-menu
-  `(("Reset to Theme Value" custom-face-reset-theme
-     (lambda (widget)
-       (let ((theme  (intern (widget-value custom-theme-name)))
-	     (symbol (widget-value widget))
-	     found)
-	 (and (custom-theme-p theme)
-	      (dolist (setting (get theme 'theme-settings) found)
-	 	(if (and (eq (cadr setting) symbol)
-	 		 (eq (car  setting) 'theme-face))
-	 	    (setq found t)))))))
-    ("---" ignore ignore)
-    ("Delete" custom-theme-delete-face nil))
-  "Alist of actions for the `custom-variable' widget in Custom Theme Mode.
-See the documentation for `custom-variable'.")
-
-(defun custom-theme-face-action (widget &optional event)
-  "Show the Custom Theme Mode menu for a `custom-face' widget.
-Optional EVENT is the location for the menu."
-  (let ((custom-face-menu custom-theme-face-menu))
-    (custom-face-action widget event)))
-
-(defun custom-face-reset-theme (widget)
-  "Reset WIDGET to its value for the currently edited theme."
-  (let ((theme  (intern (widget-value custom-theme-name)))
-	(symbol (widget-value widget))
-	found)
-    (dolist (setting (get theme 'theme-settings))
-      (if (and (eq (cadr setting) symbol)
-	       (eq (car  setting) 'theme-face))
-	  (setq found setting)))
-    (widget-value-set (car (widget-get widget :children))
-		      (nth 3 found)))
-  (widget-put widget :custom-state 'themed)
-  (custom-redraw-magic widget)
-  (widget-setup))
-
-(defun custom-theme-delete-face (widget)
-  (setq custom-theme-faces
-	(assq-delete-all (widget-value widget) custom-theme-faces))
-  (widget-delete widget))
+(defun custom-theme-add-face-1 (symbol spec)
+  (widget-insert " ")
+  (push (list symbol
+	      (prog1
+		  (widget-create 'checkbox
+				 :value t
+				 :help-echo "Enable/disable this face.")
+		(widget-insert " "))
+	      (widget-create 'custom-face
+			     :tag (custom-unlispify-tag-name symbol)
+			     :documentation-shown t
+			     :value symbol
+			     :custom-state 'hidden
+			     :custom-style 'simple
+			     :shown-value spec
+			     :sample-indent 34))
+	custom-theme-faces)
+  (widget-insert " "))
 
 ;;; Reading and writing
 
-(defun custom-theme-visit-theme ()
-  (interactive)
-  (when (and (y-or-n-p "Discard current changes? ")
-	     (progn (revert-buffer) t))
-    (let ((theme (call-interactively 'custom-theme-merge-theme)))
-      (unless (eq theme 'user)
-	(widget-value-set custom-theme-name (symbol-name theme)))
-      (widget-value-set custom-theme-description
-			(or (get theme 'theme-documentation)
-			    (format-time-string "Created %Y-%m-%d.")))
-      (widget-setup))))
+(defun custom-theme-visit-theme (theme)
+  "Load the custom theme THEME's settings into the current buffer."
+  (interactive
+   (list
+    (intern (completing-read "Find custom theme: "
+			     (mapcar 'symbol-name
+				     (custom-available-themes))))))
+  (unless (custom-theme-name-valid-p theme)
+    (error "No valid theme named `%s'" theme))
+  (cond ((not (eq major-mode 'custom-new-theme-mode))
+	 (customize-create-theme theme))
+	((y-or-n-p "Discard current changes? ")
+	 (setq custom-theme--save-name theme)
+	 (custom-theme-revert nil t))))
 
 (defun custom-theme-merge-theme (theme)
+  "Merge the custom theme THEME's settings into the current buffer."
   (interactive
    (list
     (intern (completing-read "Merge custom theme: "
 			     (mapcar 'symbol-name
 				     (custom-available-themes))))))
-  (unless (custom-theme-name-valid-p theme)
-    (error "Invalid theme name `%s'" theme))
-  (load-theme theme)
-  (let ((settings (get theme 'theme-settings)))
+  (unless (eq theme 'user)
+    (unless (custom-theme-name-valid-p theme)
+      (error "Invalid theme name `%s'" theme))
+    (load-theme theme t))
+  (let ((settings (reverse (get theme 'theme-settings))))
     (dolist (setting settings)
-      (if (eq (car setting) 'theme-value)
-	  (custom-theme-add-variable (cadr setting))
-	(custom-theme-add-face (cadr setting)))))
-  (disable-theme theme)
+      (funcall (if (eq (car setting) 'theme-value)
+		   'custom-theme-add-variable
+		 'custom-theme-add-face)
+	       (nth 1 setting)
+	       (nth 3 setting))))
   theme)
 
 (defun custom-theme-write (&rest ignore)
+  "Write the current custom theme to its theme file."
   (interactive)
   (let* ((name (widget-value custom-theme-name))
-	 (doc (widget-value custom-theme-description))
-	 (vars  custom-theme-variables)
+	 (doc  (widget-value custom-theme-description))
+	 (vars custom-theme-variables)
 	 (faces custom-theme-faces)
 	 filename)
     (when (string-equal name "")
@@ -363,26 +355,33 @@
 
     (with-temp-buffer
       (emacs-lisp-mode)
-      (unless (file-exists-p custom-theme-directory)
+      (unless (file-directory-p custom-theme-directory)
 	(make-directory (file-name-as-directory custom-theme-directory) t))
       (setq buffer-file-name filename)
       (erase-buffer)
       (insert "(deftheme " name)
       (if doc (insert "\n  \"" doc "\""))
       (insert  ")\n")
-      (custom-theme-write-variables name vars)
-      (custom-theme-write-faces name faces)
+      (custom-theme-write-variables name (reverse vars))
+      (custom-theme-write-faces name (reverse faces))
       (insert "\n(provide-theme '" name ")\n")
       (save-buffer))
-    (dolist (var vars)
-      (when (widget-get (cdr var) :children)
-	(widget-put (cdr var) :custom-state 'saved)
-	(custom-redraw-magic (cdr var))))
-    (dolist (face custom-theme-faces)
-      (when (widget-get (cdr face) :children)
-	(widget-put (cdr face) :custom-state 'saved)
-	(custom-redraw-magic (cdr face))))
-    (message "Theme written to %s" filename)))
+    (message "Theme written to %s" filename)
+
+    (when custom-theme--migrate-settings
+      ;; Remove these settings from the Custom file.
+      (let ((custom-reset-standard-variables-list '(t))
+	    (custom-reset-standard-faces-list '(t)))
+	(dolist (var vars)
+	  (when (and (not (eq (car var) 'custom-enabled-themes))
+		     (widget-get (nth 1 var) :value))
+	    (widget-apply (nth 2 var) :custom-mark-to-reset-standard)))
+	(dolist (face faces)
+	  (when (widget-get (nth 1 face) :value)
+	    (widget-apply (nth 2 face) :custom-mark-to-reset-standard)))
+	(custom-save-all))
+      (let ((custom-theme-load-path (list 'custom-theme-directory)))
+	(load-theme (intern name))))))
 
 (defun custom-theme-write-variables (theme vars)
   "Write a `custom-theme-set-variables' command for THEME.
@@ -394,20 +393,22 @@
       (princ theme)
       (princ "\n")
       (dolist (spec vars)
-	(let* ((symbol (car spec))
-	       (child (car-safe (widget-get (cdr spec) :children)))
-	       (value (if child
-			  (widget-value child)
-			;; For hidden widgets, use the standard value
-			(get symbol 'standard-value))))
-	  (when (boundp symbol)
-	    (unless (bolp)
-	      (princ "\n"))
-	    (princ " '(")
-	    (prin1 symbol)
-	    (princ " ")
-	    (prin1 (custom-quote value))
-	    (princ ")"))))
+	(when (widget-get (nth 1 spec) :value)
+	  (let* ((symbol (nth 0 spec))
+		 (widget (nth 2 spec))
+		 (child (car-safe (widget-get widget :children)))
+		 (value (if child
+			    (widget-value child)
+			  ;; Child is null if the widget is closed (hidden).
+			  (car (widget-get widget :shown-value)))))
+	    (when (boundp symbol)
+	      (unless (bolp)
+		(princ "\n"))
+	      (princ " '(")
+	      (prin1 symbol)
+	      (princ " ")
+	      (prin1 (custom-quote value))
+	      (princ ")")))))
       (if (bolp)
 	  (princ " "))
       (princ ")")
@@ -424,32 +425,21 @@
       (princ theme)
       (princ "\n")
       (dolist (spec faces)
-	(let* ((symbol (car spec))
-	       (widget (cdr spec))
-	       (child  (car-safe (widget-get widget :children)))
-	       (state  (if child
-			   (widget-get widget :custom-state)
-			 (custom-face-state symbol)))
-	       (value
-		(cond ((eq state 'standard)
-		       nil) ; do nothing
-		      (child
-		       (custom-face-widget-to-spec widget))
-		      (t
-		       ;; Widget is closed (hidden), but the face has
-		       ;; a non-standard value.  Try to extract that
-		       ;; value and save it.
-		       (custom-face-get-current-spec symbol)))))
-	  (when (and (facep symbol) value)
-	    (if (bolp)
-		(princ " '(")
-	      (princ "\n '("))
-	    (prin1 symbol)
-	    (princ " ")
-	    (prin1 value)
-	    (princ ")"))))
-      (if (bolp)
-	  (princ " "))
+	(when (widget-get (nth 1 spec) :value)
+	  (let* ((symbol (nth 0 spec))
+		 (widget (nth 2 spec))
+		 (value
+		  (if (car-safe (widget-get widget :children))
+		      (custom-face-widget-to-spec widget)
+		    ;; Child is null if the widget is closed (hidden).
+		    (widget-get widget :shown-value))))
+	    (when (and (facep symbol) value)
+	      (princ (if (bolp) " '(" "\n '("))
+	      (prin1 symbol)
+	      (princ " ")
+	      (prin1 value)
+	      (princ ")")))))
+      (if (bolp) (princ " "))
       (princ ")")
       (unless (looking-at "\n")
 	(princ "\n")))))
@@ -477,22 +467,38 @@
   (prin1 theme)
   (princ " is a custom theme")
   (let ((fn (locate-file (concat (symbol-name theme) "-theme.el")
-			 (cons custom-theme-directory load-path)
-			 '("" "c"))))
+			 (custom-theme--load-path)
+			 '("" "c")))
+	doc)
     (when fn
       (princ " in `")
       (help-insert-xref-button (file-name-nondirectory fn)
 			       'help-theme-def fn)
       (princ "'"))
-    (princ ".\n"))
-  (if (not (memq theme custom-known-themes))
-      (princ "It is not loaded.")
-    (if (custom-theme-enabled-p theme)
-	(princ "It is loaded and enabled.\n")
-      (princ "It is loaded but disabled.\n"))
-    (princ "\nDocumentation:\n")
-    (princ (or (get theme 'theme-documentation)
-	       "No documentation available.")))
+    (princ ".\n")
+    (if (not (memq theme custom-known-themes))
+	(progn
+	  (princ "It is not loaded.")
+	  ;; Attempt to grab the theme documentation
+	  (when fn
+	    (with-temp-buffer
+	      (insert-file-contents fn)
+	      (let ((sexp (let ((read-circle nil))
+			    (condition-case nil
+				(read (current-buffer))
+			      (end-of-file nil)))))
+		(and sexp (listp sexp)
+		     (eq (car sexp) 'deftheme)
+		     (setq doc (nth 2 sexp)))))))
+      (if (custom-theme-enabled-p theme)
+	  (princ "It is loaded and enabled.")
+	(princ "It is loaded but disabled."))
+      (setq doc (get theme 'theme-documentation)))
+
+    (princ "\n\nDocumentation:\n")
+    (princ (if (stringp doc)
+	       doc
+	     "No documentation available.")))
   (princ "\n\nYou can ")
   (help-insert-xref-button "customize" 'help-theme-edit theme)
   (princ " this theme."))
@@ -518,7 +524,7 @@
     map)
   "Keymap for `custom-theme-choose-mode'.")
 
-(define-derived-mode custom-theme-choose-mode nil "Cus-Theme"
+(define-derived-mode custom-theme-choose-mode nil "Themes"
   "Major mode for selecting Custom themes.
 Do not call this mode function yourself.  It is meant for internal use."
   (use-local-map custom-theme-choose-mode-map)
@@ -550,27 +556,40 @@
     "Type RET or click to enable/disable listed custom themes.
 Type \\[custom-describe-theme] to describe the theme at point.
 Theme files are named *-theme.el in `"))
-  (when (stringp custom-theme-directory)
-    (widget-create 'link :value custom-theme-directory
-		   :button-face 'custom-link
-		   :mouse-face 'highlight
-		   :pressed-face 'highlight
-		   :help-echo "Describe `custom-theme-directory'."
-		   :keymap custom-mode-link-map
-		   :follow-link 'mouse-face
-		   :action (lambda (widget &rest ignore)
-			     (describe-variable 'custom-theme-directory)))
-    (widget-insert "' or `"))
-  (widget-create 'link :value "load-path"
+  (widget-create 'link :value "custom-theme-load-path"
 		 :button-face 'custom-link
 		 :mouse-face 'highlight
 		 :pressed-face 'highlight
-		 :help-echo "Describe `load-path'."
+		 :help-echo "Describe `custom-theme-load-path'."
 		 :keymap custom-mode-link-map
 		 :follow-link 'mouse-face
 		 :action (lambda (widget &rest ignore)
-			   (describe-variable 'load-path)))
+			   (describe-variable 'custom-theme-load-path)))
   (widget-insert "'.\n\n")
+
+  ;; If the user has made customizations, display a warning and
+  ;; provide buttons to disable or convert them.
+  (let ((user-settings (get 'user 'theme-settings)))
+    (unless (or (null user-settings)
+		(and (null (cdr user-settings))
+		     (eq (caar user-settings) 'theme-value)
+		     (eq (cadr (car user-settings)) 'custom-enabled-themes)))
+      (widget-insert
+       (propertize
+	" Note: Your custom settings take precedence over theme settings.
+       To migrate your settings into a theme, click "
+	'face 'font-lock-warning-face))
+      (widget-create 'link :value "here"
+		     :button-face 'custom-link
+		     :mouse-face 'highlight
+		     :pressed-face 'highlight
+		     :help-echo "Migrate."
+		     :keymap custom-mode-link-map
+		     :follow-link 'mouse-face
+		     :action (lambda (widget &rest ignore)
+			       (customize-create-theme 'user)))
+      (widget-insert ".\n\n")))
+
   (widget-create 'push-button
 		 :tag " Save Theme Settings "
 		 :help-echo "Save the selected themes for future sessions."
@@ -638,9 +657,8 @@
 (defun custom-theme-selections-toggle (widget &optional event)
   (when (widget-value widget)
     ;; Deactivate multiple-selections.
-    (if (> (length (delq nil (mapcar (lambda (x) (widget-value (cdr x)))
-				     custom--listed-themes)))
-	   1)
+    (if (< 1 (length (delq nil (mapcar (lambda (x) (widget-value (cdr x)))
+				       custom--listed-themes))))
 	(error "More than one theme is currently selected")))
   (widget-toggle-action widget event)
   (setq custom-theme-allow-multiple-selections (widget-value widget)))
--- a/lisp/custom.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/custom.el	Thu Oct 28 19:57:59 2010 +0900
@@ -996,9 +996,8 @@
 
 ;;; Defining themes.
 
-;; A theme file should be named `THEME-theme.el' (where THEME is the theme
-;; name), and found in either `custom-theme-directory' or the load path.
-;; It has the following format:
+;; A theme file is named `THEME-theme.el' (where THEME is the theme
+;; name) found in `custom-theme-load-path'.  It has this format:
 ;;
 ;;   (deftheme THEME
 ;;     DOCSTRING)
@@ -1034,8 +1033,8 @@
   "Like `deftheme', but THEME is evaluated as a normal argument.
 FEATURE is the feature this theme provides.  Normally, this is a symbol
 created from THEME by `custom-make-theme-feature'."
-  (if (memq theme '(user changed))
-      (error "Custom theme cannot be named %S" theme))
+  (unless (custom-theme-name-valid-p theme)
+    (error "Custom theme cannot be named %S" theme))
   (add-to-list 'custom-known-themes theme)
   (put theme 'theme-feature feature)
   (when doc (put theme 'theme-documentation doc)))
@@ -1053,16 +1052,35 @@
 
 ;;; Loading themes.
 
-(defcustom custom-theme-directory
-  user-emacs-directory
-  "Directory in which Custom theme files should be written.
-`load-theme' searches this directory in addition to load-path.
-The command `customize-create-theme' writes the files it produces
-into this directory."
+(defcustom custom-theme-directory user-emacs-directory
+  "Default user directory for storing custom theme files.
+The command `customize-create-theme' writes theme files into this
+directory.  By default, Emacs searches for custom themes in this
+directory first---see `custom-theme-load-path'."
   :type 'string
   :group 'customize
   :version "22.1")
 
+(defcustom custom-theme-load-path (list 'custom-theme-directory t)
+  "List of directories to search for custom theme files.
+When loading custom themes (e.g. in `customize-themes' and
+`load-theme'), Emacs searches for theme files in the specified
+order.  Each element in the list should be one of the following:
+- the symbol `custom-theme-directory', meaning the value of
+  `custom-theme-directory'.
+- the symbol t, meaning the built-in theme directory (a directory
+  named \"themes\" in `data-directory').
+- a directory name (a string).
+
+Each theme file is named NAME-theme.el, where THEME is the theme
+name."
+  :type '(repeat (choice (const :tag "custom-theme-directory"
+				custom-theme-directory)
+			 (const :tag "Built-in theme directory" t)
+			 directory))
+  :group 'customize
+  :version "24.1")
+
 (defvar custom--inhibit-theme-enable nil
   "If non-nil, loading a theme does not enable it.
 This internal variable is set by `load-theme' when its NO-ENABLE
@@ -1074,19 +1092,21 @@
 This calls `provide' to provide the feature name stored in THEME's
 property `theme-feature' (which is usually a symbol created by
 `custom-make-theme-feature')."
-  (if (memq theme '(user changed))
-      (error "Custom theme cannot be named %S" theme))
+  (unless (custom-theme-name-valid-p theme)
+    (error "Custom theme cannot be named %S" theme))
   (custom-check-theme theme)
   (provide (get theme 'theme-feature))
   (unless custom--inhibit-theme-enable
-    ;; Loading a theme also enables it.
+    ;; By default, loading a theme also enables it.
     (push theme custom-enabled-themes)
     ;; `user' must always be the highest-precedence enabled theme.
-    ;; Make that remain true.  (This has the effect of making user settings
-    ;; override the ones just loaded, too.)
+    ;; Make that remain true.  (This has the effect of making user
+    ;; settings override the ones just loaded, too.)
     (let ((custom-enabling-themes t))
       (enable-theme 'user))))
 
+(defvar safe-functions) ; From unsafep.el
+
 (defun load-theme (theme &optional no-enable)
   "Load a theme's settings from its file.
 Normally, this also enables the theme; use `disable-theme' to
@@ -1108,40 +1128,39 @@
     (put theme 'theme-feature nil)
     (put theme 'theme-documentation nil))
   (let ((fn (locate-file (concat (symbol-name theme) "-theme.el")
-			 (cons custom-theme-directory load-path)
+			 (custom-theme--load-path)
 			 '("" "c"))))
     (unless fn
       (error "Unable to find theme file for `%s'." theme))
     ;; Instead of simply loading the theme file, read it manually.
     (with-temp-buffer
       (insert-file-contents fn)
+      (require 'unsafep)
       (let ((custom--inhibit-theme-enable no-enable)
-	    sexp scar)
-	(while (setq sexp (let ((read-circle nil))
+	    (safe-functions (append '(custom-theme-set-variables
+				      custom-theme-set-faces)
+				    safe-functions))
+	    form scar)
+	(while (setq form (let ((read-circle nil))
 			    (condition-case nil
 				(read (current-buffer))
 			      (end-of-file nil))))
-	  ;; Perform some checks on each sexp before evaluating it.
 	  (cond
-	   ((not (listp sexp)))
-	   ((eq (setq scar (car sexp)) 'deftheme)
-	    (unless (eq (cadr sexp) theme)
+	   ;; Check `deftheme' expressions.
+	   ((eq (setq scar (car form)) 'deftheme)
+	    (unless (eq (cadr form) theme)
 	      (error "Incorrect theme name in `deftheme'"))
-	    (and (symbolp (nth 1 sexp))
-		 (stringp (nth 2 sexp))
-		 (eval (list scar (nth 1 sexp) (nth 2 sexp)))))
-	   ((or (eq scar 'custom-theme-set-variables)
-		(eq scar 'custom-theme-set-faces))
-	    (unless (equal (nth 1 sexp) `(quote ,theme))
-	      (error "Incorrect theme name in theme settings"))
-	    (dolist (entry (cddr sexp))
-	      (unless (eq (car-safe entry) 'quote)
-		(error "Unsafe expression in theme settings")))
-	    (eval sexp))
+	    (and (symbolp (nth 1 form))
+		 (stringp (nth 2 form))
+		 (eval (list scar (nth 1 form) (nth 2 form)))))
+	   ;; Check `provide-theme' expressions.
 	   ((and (eq scar 'provide-theme)
-		 (equal (cadr sexp) `(quote ,theme))
-		 (= (length sexp) 2))
-	    (eval sexp))))))))
+		 (equal (cadr form) `(quote ,theme))
+		 (= (length form) 2))
+	    (eval form))
+	   ;; All other expressions need to be safe.
+	   ((not (unsafep form))
+	    (eval form))))))))
 
 (defun custom-theme-name-valid-p (name)
   "Return t if NAME is a valid name for a Custom theme, nil otherwise.
@@ -1149,25 +1168,34 @@
   (and (symbolp name)
        name
        (not (or (zerop (length (symbol-name name)))
-		(eq name 'cus)
 		(eq name 'user)
 		(eq name 'changed)))))
 
 (defun custom-available-themes ()
   "Return a list of available Custom themes (symbols)."
-  (let* ((load-path (if (file-directory-p custom-theme-directory)
-			(cons custom-theme-directory load-path)
-		      load-path))
-	 sym themes)
-    (dolist (dir load-path)
-      (dolist (file (file-expand-wildcards
-		     (expand-file-name "*-theme.el" dir) t))
-	(setq file (file-name-nondirectory file))
-	(and (string-match "\\`\\(.+\\)-theme.el\\'" file)
-	     (setq sym (intern (match-string 1 file)))
-	     (custom-theme-name-valid-p sym)
-	     (push sym themes))))
+  (let* (sym themes)
+    (dolist (dir (custom-theme--load-path))
+      (when (file-directory-p dir)
+	(dolist (file (file-expand-wildcards
+		       (expand-file-name "*-theme.el" dir) t))
+	  (setq file (file-name-nondirectory file))
+	  (and (string-match "\\`\\(.+\\)-theme.el\\'" file)
+	       (setq sym (intern (match-string 1 file)))
+	       (custom-theme-name-valid-p sym)
+	       (push sym themes)))))
     (delete-dups themes)))
+
+(defun custom-theme--load-path ()
+  (let (lpath)
+    (dolist (f custom-theme-load-path)
+      (cond ((eq f 'custom-theme-directory)
+	     (setq f custom-theme-directory))
+	    ((eq f t)
+	     (setq f (expand-file-name "themes" data-directory))))
+      (if (file-directory-p f)
+	  (push f lpath)))
+    (nreverse lpath)))
+
 
 ;;; Enabling and disabling loaded themes.
 
@@ -1209,7 +1237,8 @@
 and always takes precedence over other Custom Themes."
   :group 'customize
   :type  '(repeat symbol)
-  :set-after '(custom-theme-directory)  ; so we can find the themes
+  :set-after '(custom-theme-directory custom-theme-load-path)
+  :risky t
   :set (lambda (symbol themes)
 	 ;; Avoid an infinite loop when custom-enabled-themes is
 	 ;; defined in a theme (e.g. `user').  Enabling the theme sets
@@ -1258,8 +1287,7 @@
 	    ;; If the face spec specified by this theme is in the
 	    ;; saved-face property, reset that property.
 	    (when (equal (nth 3 s) (get symbol 'saved-face))
-	      (put symbol 'saved-face
-		   (and val (cadr (car val)))))
+	      (put symbol 'saved-face (and val (cadr (car val)))))
 	    (custom-theme-recalc-face symbol)))))
       (setq custom-enabled-themes
 	    (delq theme custom-enabled-themes)))))
@@ -1290,7 +1318,9 @@
   "Set FACE according to currently enabled custom themes."
   (if (get face 'face-alias)
       (setq face (get face 'face-alias)))
-  (face-spec-set face (get face 'face-override-spec)))
+  ;; Reset the faces for each frame.
+  (dolist (frame (frame-list))
+    (face-spec-recalc face frame)))
 
 
 ;;; XEmacs compability functions
--- a/lisp/electric.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/electric.el	Thu Oct 28 19:57:59 2010 +0900
@@ -178,6 +178,10 @@
 
 ;; Electric indentation.
 
+;; Autoloading variables is generally undesirable, but major modes
+;; should usually set this variable by adding elements to the default
+;; value, which only works well if the variable is preloaded.
+;;;###autoload
 (defvar electric-indent-chars '(?\n)
   "Characters that should cause automatic reindentation.")
 
--- a/lisp/emacs-lisp/autoload.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/emacs-lisp/autoload.el	Thu Oct 28 19:57:59 2010 +0900
@@ -778,16 +778,17 @@
 	  (with-temp-buffer
 	    (insert-file-contents mfile)
 	    (when (re-search-forward "^shortlisp= " nil t)
-	      (setq lim (line-end-position))
-	      (while (re-search-forward "\\.\\./lisp/\\([^ ]+\\.el\\)c?\\>"
-					lim t)
+	      (while (and (not lim)
+			  (re-search-forward "\\.\\./lisp/\\([^ ]+\\.el\\)c?\\>"
+					     nil t))
 		(push (expand-file-name (match-string 1) ldir)
-		      autoload-excludes))))))))
+		      autoload-excludes)
+		(skip-chars-forward " \t")
+		(if (eolp) (setq lim t)))))))))
   (let ((args command-line-args-left))
     (setq command-line-args-left nil)
     (apply 'update-directory-autoloads args)))
 
 (provide 'autoload)
 
-;; arch-tag: 00244766-98f4-4767-bf42-8a22103441c6
 ;;; autoload.el ends here
--- a/lisp/emacs-lisp/byte-opt.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/emacs-lisp/byte-opt.el	Thu Oct 28 19:57:59 2010 +0900
@@ -384,7 +384,7 @@
 	       (eq 'lambda (car-safe fn)))
 	   (let ((newform (byte-compile-unfold-lambda form)))
 	     (if (eq newform form)
-		 ;; Some error occured, avoid infinite recursion
+		 ;; Some error occurred, avoid infinite recursion
 		 form
 	       (byte-optimize-form-code-walker newform for-effect))))
 	  ((memq fn '(let let*))
--- a/lisp/emacs-lisp/find-func.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/emacs-lisp/find-func.el	Thu Oct 28 19:57:59 2010 +0900
@@ -213,6 +213,8 @@
   (interactive
    (let* ((dirs (or find-function-source-path load-path))
           (suffixes (find-library-suffixes))
+          (table (apply-partially 'locate-file-completion-table
+                                  dirs suffixes))
 	  (def (if (eq (function-called-at-point) 'require)
 		   ;; `function-called-at-point' may return 'require
 		   ;; with `point' anywhere on this line.  So wrap the
@@ -226,16 +228,12 @@
 			 (thing-at-point 'symbol))
 		     (error nil))
 		 (thing-at-point 'symbol))))
-     (when def
-       (setq def (and (locate-file-completion-table
-                       dirs suffixes def nil 'lambda)
-                      def)))
+     (when (and def (not (test-completion def table)))
+       (setq def nil))
      (list
       (completing-read (if def (format "Library name (default %s): " def)
 			 "Library name: ")
-		       (apply-partially 'locate-file-completion-table
-                                        dirs suffixes)
-                       nil nil nil nil def))))
+		       table nil nil nil nil def))))
   (let ((buf (find-file-noselect (find-library-name library))))
     (condition-case nil (switch-to-buffer buf) (error (pop-to-buffer buf)))))
 
--- a/lisp/emacs-lisp/float-sup.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/emacs-lisp/float-sup.el	Thu Oct 28 19:57:59 2010 +0900
@@ -1,7 +1,7 @@
 ;;; float-sup.el --- define some constants useful for floating point numbers.
 
-;; Copyright (C) 1985, 1986, 1987, 2001, 2002, 2003, 2004,
-;;   2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1986, 1987, 2001, 2002, 2003, 2004, 2005, 2006,
+;;   2007, 2008, 2009, 2010  Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 ;; Keywords: internal
@@ -26,15 +26,8 @@
 
 ;;; Code:
 
-;; Provide a meaningful error message if we are running on
-;; bare (non-float) emacs.
-
-(if (fboundp 'atan)
-    nil
-  (error "Floating point was disabled at compile time"))
-
-;; provide an easy hook to tell if we are running with floats or not.
-;; define pi and e via math-lib calls. (much less prone to killer typos.)
+;; Provide an easy hook to tell if we are running with floats or not.
+;; Define pi and e via math-lib calls (much less prone to killer typos).
 (defconst float-pi (* 4 (atan 1)) "The value of Pi (3.1415926...).")
 (defconst pi float-pi "Obsolete since Emacs-23.3.  Use `float-pi' instead.")
 
@@ -45,7 +38,7 @@
 (defconst radians-to-degrees (/ 180.0 float-pi)
   "Radian to degree conversion constant.")
 
-;; these expand to a single multiply by a float when byte compiled
+;; These expand to a single multiply by a float when byte compiled.
 
 (defmacro degrees-to-radians (x)
   "Convert X from degrees to radians."
@@ -56,5 +49,4 @@
 
 (provide 'lisp-float-type)
 
-;; arch-tag: e7837072-a4af-4d08-9953-8a3e755abf9d
 ;;; float-sup.el ends here
--- a/lisp/emacs-lisp/package.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/emacs-lisp/package.el	Thu Oct 28 19:57:59 2010 +0900
@@ -1187,7 +1187,7 @@
 (defvar package-menu-mode-map
   (let ((map (make-keymap))
 	(menu-map (make-sparse-keymap "Package")))
-    (suppress-keymap map)
+    (set-keymap-parent map button-buffer-map)
     (define-key map "\C-m" 'package-menu-describe-package)
     (define-key map "q" 'quit-window)
     (define-key map "n" 'next-line)
@@ -1474,7 +1474,6 @@
   (package-initialize)
   (let ((inhibit-read-only t)
 	info-list name desc hold builtin)
-    (setq buffer-read-only nil)
     (erase-buffer)
     ;; List installed packages
     (dolist (elt package-alist)
--- a/lisp/emacs-lisp/regexp-opt.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/emacs-lisp/regexp-opt.el	Thu Oct 28 19:57:59 2010 +0900
@@ -141,11 +141,10 @@
   (require 'cl))
 
 (defun regexp-opt-group (strings &optional paren lax)
-  ;; Return a regexp to match a string in the sorted list STRINGS.
-  ;; If PAREN non-nil, output regexp parentheses around returned regexp.
-  ;; If LAX non-nil, don't output parentheses if it doesn't require them.
-  ;; Merges keywords to avoid backtracking in Emacs' regexp matcher.
-
+  "Return a regexp to match a string in the sorted list STRINGS.
+If PAREN non-nil, output regexp parentheses around returned regexp.
+If LAX non-nil, don't output parentheses if it doesn't require them.
+Merges keywords to avoid backtracking in Emacs' regexp matcher."
   ;; The basic idea is to find the shortest common prefix or suffix, remove it
   ;; and recurse.  If there is no prefix, we divide the list into two so that
   ;; \(at least) one half will have at least a one-character common prefix.
@@ -239,9 +238,7 @@
 
 
 (defun regexp-opt-charset (chars)
-  ;;
-  ;; Return a regexp to match a character in CHARS.
-  ;;
+  "Return a regexp to match a character in CHARS."
   ;; The basic idea is to find character ranges.  Also we take care in the
   ;; position of character set meta characters in the character set regexp.
   ;;
--- a/lisp/emacs-lisp/timer.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/emacs-lisp/timer.el	Thu Oct 28 19:57:59 2010 +0900
@@ -93,31 +93,20 @@
 More precisely, the next value, after TIME, that is an integral multiple
 of SECS seconds since the epoch.  SECS may be a fraction."
   (let ((time-base (ash 1 16)))
-    (if (fboundp 'atan)
-	;; Use floating point, taking care to not lose precision.
-	(let* ((float-time-base (float time-base))
-	       (million 1000000.0)
-	       (time-usec (+ (* million
-				(+ (* float-time-base (nth 0 time))
-				   (nth 1 time)))
-			     (nth 2 time)))
-	       (secs-usec (* million secs))
-	       (mod-usec (mod time-usec secs-usec))
-	       (next-usec (+ (- time-usec mod-usec) secs-usec))
-	       (time-base-million (* float-time-base million)))
-	  (list (floor next-usec time-base-million)
-		(floor (mod next-usec time-base-million) million)
-		(floor (mod next-usec million))))
-      ;; Floating point is not supported.
-      ;; Use integer arithmetic, avoiding overflow if possible.
-      (let* ((mod-sec (mod (+ (* (mod time-base secs)
-				 (mod (nth 0 time) secs))
-			      (nth 1 time))
-			   secs))
-	     (next-1-sec (+ (- (nth 1 time) mod-sec) secs)))
-	(list (+ (nth 0 time) (floor next-1-sec time-base))
-	      (mod next-1-sec time-base)
-	      0)))))
+    ;; Use floating point, taking care to not lose precision.
+    (let* ((float-time-base (float time-base))
+	   (million 1000000.0)
+	   (time-usec (+ (* million
+			    (+ (* float-time-base (nth 0 time))
+			       (nth 1 time)))
+			 (nth 2 time)))
+	   (secs-usec (* million secs))
+	   (mod-usec (mod time-usec secs-usec))
+	   (next-usec (+ (- time-usec mod-usec) secs-usec))
+	   (time-base-million (* float-time-base million)))
+      (list (floor next-usec time-base-million)
+	    (floor (mod next-usec time-base-million) million)
+	    (floor (mod next-usec million))))))
 
 (defun timer-relative-time (time secs &optional usecs)
   "Advance TIME by SECS seconds and optionally USECS microseconds.
@@ -543,5 +532,4 @@
 
 (provide 'timer)
 
-;; arch-tag: b1a9237b-7787-4382-9e46-8f2c3b3273e0
 ;;; timer.el ends here
--- a/lisp/emacs-lisp/unsafep.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/emacs-lisp/unsafep.el	Thu Oct 28 19:57:59 2010 +0900
@@ -101,15 +101,13 @@
 (dolist (x '(;;Special forms
 	     and catch if or prog1 prog2 progn while unwind-protect
 	     ;;Safe subrs that have some side-effects
-	     ding error message minibuffer-message random read-minibuffer
-	     signal sleep-for string-match throw y-or-n-p yes-or-no-p
+	     ding error random signal sleep-for string-match throw
 	     ;;Defsubst functions from subr.el
 	     caar cadr cdar cddr
 	     ;;Macros from subr.el
-	     save-match-data unless when with-temp-message
+	     save-match-data unless when
 	     ;;Functions from subr.el that have side effects
-	     read-passwd split-string replace-regexp-in-string
-	     play-sound-file))
+	     split-string replace-regexp-in-string play-sound-file))
   (put x 'safe-function t))
 
 ;;;###autoload
--- a/lisp/emulation/cua-base.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/emulation/cua-base.el	Thu Oct 28 19:57:59 2010 +0900
@@ -1,7 +1,7 @@
 ;;; cua-base.el --- emulate CUA key bindings
 
-;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-;;   2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
+;;   2006, 2007, 2008, 2009, 2010  Free Software Foundation, Inc.
 
 ;; Author: Kim F. Storm <storm@cua.dk>
 ;; Keywords: keyboard emulations convenience cua
@@ -300,8 +300,7 @@
   :type 'boolean
   :group 'cua)
 
-(defcustom cua-prefix-override-inhibit-delay
-  (if (featurep 'lisp-float-type) (/ (float 1) (float 5)) nil)
+(defcustom cua-prefix-override-inhibit-delay 0.2
   "If non-nil, time in seconds to delay before overriding prefix key.
 If there is additional input within this time, the prefix key is
 used as a normal prefix key.  So typing a key sequence quickly will
@@ -1637,5 +1636,4 @@
 
 (provide 'cua-base)
 
-;; arch-tag: 21fb6289-ba25-4fee-bfdc-f9fb351acf05
 ;;; cua-base.el ends here
--- a/lisp/epa-mail.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/epa-mail.el	Thu Oct 28 19:57:59 2010 +0900
@@ -117,23 +117,29 @@
    (save-excursion
      (let ((verbose current-prefix-arg)
 	   (context (epg-make-context epa-protocol))
-	   recipients recipient-key)
+	   recipients-string recipients recipient-key)
        (goto-char (point-min))
        (save-restriction
 	 (narrow-to-region (point)
 			   (if (search-forward mail-header-separator nil 0)
 			       (match-beginning 0)
 			     (point)))
+	 (setq recipients-string
+	       (mapconcat #'identity
+			  (nconc (mail-fetch-field "to" nil nil t)
+				 (mail-fetch-field "cc" nil nil t)
+				 (mail-fetch-field "bcc" nil nil t))
+			  ","))
 	 (setq recipients
 	       (mail-strip-quoted-names
-		(mapconcat #'identity
-			   (nconc (mail-fetch-field "to" nil nil t)
-				  (mail-fetch-field "cc" nil nil t)
-				  (mail-fetch-field "bcc" nil nil t))
-			   ","))))
+		(with-temp-buffer
+		  (insert "to: " recipients-string "\n")
+		  (expand-mail-aliases (point-min) (point-max))
+		  (car (mail-fetch-field "to" nil nil t))))))
        (if recipients
 	   (setq recipients (delete ""
-				    (split-string recipients "[ \t\n]+"))))
+				    (split-string recipients
+						  "[ \t\n]*,[ \t\n]*"))))
        (goto-char (point-min))
        (if (search-forward mail-header-separator nil t)
 	   (forward-line))
@@ -154,7 +160,9 @@
 			    (epa-mail--find-usable-key
 			     (epg-list-keys
 			      (epg-make-context epa-protocol)
-			      (concat "<" recipient ">"))
+			      (if (string-match "@" recipient)
+				  (concat "<" recipient ">")
+				recipient))
 			     'encrypt))
 		      (unless (or recipient-key
 				  (y-or-n-p
--- a/lisp/epg-config.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/epg-config.el	Thu Oct 28 19:57:59 2010 +0900
@@ -37,7 +37,9 @@
   :version "23.1"
   :group 'data)
 
-(defcustom epg-gpg-program "gpg"
+(defcustom epg-gpg-program (or (executable-find "gpg")
+			       (executable-find "gpg2")
+			       "gpg")
   "The `gpg' executable."
   :group 'epg
   :type 'string)
--- a/lisp/erc/ChangeLog	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/erc/ChangeLog	Thu Oct 28 19:57:59 2010 +0900
@@ -1,3 +1,14 @@
+2010-10-24  Julien Danjou  <julien@danjou.info>
+
+	* erc-backend.el (erc-server-JOIN): Set the correct target list on join.
+
+	* erc-backend.el (erc-process-sentinel): Check that buffer is alive
+	before setting it as current buffer.
+
+2010-10-14  Juanma Barranquero  <lekktu@gmail.com>
+
+	* erc-xdcc.el (erc-xdcc-help-text): Fix typo in docstring.
+
 2010-10-10  Dan Nicolaescu  <dann@ics.uci.edu>
 
 	* erc-list.el (erc-list-menu-mode-map): Declare and define in one step.
--- a/lisp/erc/erc-backend.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/erc/erc-backend.el	Thu Oct 28 19:57:59 2010 +0900
@@ -653,30 +653,31 @@
 
 (defun erc-process-sentinel (cproc event)
   "Sentinel function for ERC process."
-  (with-current-buffer (process-buffer cproc)
-    (erc-log (format
-              "SENTINEL: proc: %S	 status: %S  event: %S (quitting: %S)"
-              cproc (process-status cproc) event erc-server-quitting))
-    (if (string-match "^open" event)
-        ;; newly opened connection (no wait)
-        (erc-login)
-      ;; assume event is 'failed
-      (let ((buf (process-buffer cproc)))
-        (erc-with-all-buffers-of-server cproc nil
-                                        (setq erc-server-connected nil))
-        (when erc-server-ping-handler
-          (progn (erc-cancel-timer erc-server-ping-handler)
-                 (setq erc-server-ping-handler nil)))
-        (run-hook-with-args 'erc-disconnected-hook
-                            (erc-current-nick) (system-name) "")
-        ;; Remove the prompt
-        (goto-char (or (marker-position erc-input-marker) (point-max)))
-        (forward-line 0)
-        (erc-remove-text-properties-region (point) (point-max))
-        (delete-region (point) (point-max))
-        ;; Decide what to do with the buffer
-        ;; Restart if disconnected
-        (erc-process-sentinel-1 event buf)))))
+  (let ((buf (process-buffer cproc)))
+    (when (buffer-live-p buf)
+      (with-current-buffer buf
+        (erc-log (format
+                  "SENTINEL: proc: %S	 status: %S  event: %S (quitting: %S)"
+                  cproc (process-status cproc) event erc-server-quitting))
+        (if (string-match "^open" event)
+            ;; newly opened connection (no wait)
+            (erc-login)
+          ;; assume event is 'failed
+          (erc-with-all-buffers-of-server cproc nil
+                                          (setq erc-server-connected nil))
+          (when erc-server-ping-handler
+            (progn (erc-cancel-timer erc-server-ping-handler)
+                   (setq erc-server-ping-handler nil)))
+          (run-hook-with-args 'erc-disconnected-hook
+                              (erc-current-nick) (system-name) "")
+          ;; Remove the prompt
+          (goto-char (or (marker-position erc-input-marker) (point-max)))
+          (forward-line 0)
+          (erc-remove-text-properties-region (point) (point-max))
+          (delete-region (point) (point-max))
+          ;; Decide what to do with the buffer
+          ;; Restart if disconnected
+          (erc-process-sentinel-1 event buf))))))
 
 ;;;; Sending messages
 
@@ -1195,7 +1196,7 @@
                       (setq buffer (erc-open erc-session-server erc-session-port
                                              nick erc-session-user-full-name
                                              nil nil
-                                             erc-default-recipients chnl
+                                             (list chnl) chnl
                                              erc-server-process))
                       (when buffer
                         (set-buffer buffer)
--- a/lisp/erc/erc-xdcc.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/erc/erc-xdcc.el	Thu Oct 28 19:57:59 2010 +0900
@@ -56,7 +56,7 @@
      (erc-current-nick) " XDCC send #\" to get a particular file number."))
   "*Help text sent in response to XDCC help command.
 A list of messages, each consisting of strings and expressions, expressions
-being evaluated and should return stings."
+being evaluated and should return strings."
   :group 'erc-dcc
   :type '(repeat (repeat :tag "Message" (choice string sexp))))
 
--- a/lisp/eshell/em-unix.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/eshell/em-unix.el	Thu Oct 28 19:57:59 2010 +0900
@@ -203,13 +203,7 @@
 	    (eshell-error "rm: cannot remove `.' or `..'\n"))
       (if (and (file-directory-p (car files))
 	       (not (file-symlink-p (car files))))
-	  (let ((dir (file-name-as-directory (car files))))
-	    (eshell-remove-entries dir
-				   (mapcar
-				    (function
-				     (lambda (file)
-				       (concat dir file)))
-				    (directory-files dir)))
+	  (progn
 	    (if verbose
 		(eshell-printn (format "rm: removing directory `%s'"
 				       (car files))))
@@ -219,7 +213,7 @@
 			 (not (y-or-n-p
 			       (format "rm: remove directory `%s'? "
 				       (car files))))))
-	      (eshell-funcalln 'delete-directory (car files))))
+	      (eshell-funcalln 'delete-directory (car files) t t)))
 	(if verbose
 	    (eshell-printn (format "rm: removing file `%s'"
 				   (car files))))
@@ -228,7 +222,7 @@
 			 (not (y-or-n-p
 			       (format "rm: remove `%s'? "
 				       (car files))))))
-	  (eshell-funcalln 'delete-file (car files)))))
+	  (eshell-funcalln 'delete-file (car files) t))))
     (setq files (cdr files))))
 
 (defun eshell/rm (&rest args)
--- a/lisp/face-remap.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/face-remap.el	Thu Oct 28 19:57:59 2010 +0900
@@ -312,7 +312,7 @@
       (when step
 	(text-scale-increase step)
 	(setq inc 1 first nil)
-	(setq ev (read-event))))
+	(setq ev (read-event "+,-,0 for further adjustment: "))))
     (push ev unread-command-events)))
 
 
--- a/lisp/facemenu.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/facemenu.el	Thu Oct 28 19:57:59 2010 +0900
@@ -358,7 +358,7 @@
 typing a character to insert cancels the specification."
   (interactive (list (progn
 		       (barf-if-buffer-read-only)
-		       (facemenu-read-color "Foreground color: "))
+		       (read-color "Foreground color: "))
 		     (if (and mark-active (not current-prefix-arg))
 			 (region-beginning))
 		     (if (and mark-active (not current-prefix-arg))
@@ -380,7 +380,7 @@
 typing a character to insert cancels the specification."
   (interactive (list (progn
 		       (barf-if-buffer-read-only)
-		       (facemenu-read-color "Background color: "))
+		       (read-color "Background color: "))
 		     (if (and mark-active (not current-prefix-arg))
 			 (region-beginning))
 		     (if (and mark-active (not current-prefix-arg))
@@ -462,23 +462,7 @@
     (remove-text-properties
      start end '(invisible nil intangible nil read-only nil))))
 
-(defun facemenu-read-color (&optional prompt)
-  "Read a color using the minibuffer."
-  (let* ((completion-ignore-case t)
-	 (color-list (or facemenu-color-alist (defined-colors)))
-	 (completer
-	  (lambda (string pred all-completions)
-	    (if all-completions
-		(or (all-completions string color-list pred)
-		    (if (color-defined-p string)
-			(list string)))
-	      (or (try-completion string color-list pred)
-		  (if (color-defined-p string)
-		      string)))))
-	 (col (completing-read (or prompt "Color: ") completer nil t)))
-    (if (equal "" col)
-	nil
-      col)))
+(defalias 'facemenu-read-color 'read-color)
 
 (defun color-rgb-to-hsv (r g b)
   "For R, G, B color components return a list of hue, saturation, value.
--- a/lisp/faces.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/faces.el	Thu Oct 28 19:57:59 2010 +0900
@@ -1507,12 +1507,11 @@
 
 (defun face-spec-reset-face (face &optional frame)
   "Reset all attributes of FACE on FRAME to unspecified."
-  (let ((attrs face-attribute-name-alist))
-    (while attrs
-      (let ((attr-and-name (car attrs)))
-	(set-face-attribute face frame (car attr-and-name) 'unspecified))
-      (setq attrs (cdr attrs)))))
-
+  (let (reset-args)
+    (dolist (attr-and-name face-attribute-name-alist)
+      (push 'unspecified reset-args)
+      (push (car attr-and-name) reset-args))
+    (apply 'set-face-attribute face frame reset-args)))
 
 (defun face-spec-set (face spec &optional for-defface)
   "Set FACE's face spec, which controls its appearance, to SPEC.
@@ -1578,8 +1577,8 @@
     (setq frame (selected-frame)))
   (let ((list face-attribute-name-alist)
 	(match t))
-    (while (and match (not (null list)))
-      (let* ((attr (car (car list)))
+    (while (and match list)
+      (let* ((attr (caar list))
 	     (specified-value
 	      (if (plist-member attrs attr)
 		  (plist-get attrs attr)
@@ -1589,7 +1588,7 @@
 	(setq list (cdr list))))
     match))
 
-(defun face-spec-match-p (face spec &optional frame)
+(defsubst face-spec-match-p (face spec &optional frame)
   "Return t if FACE, on FRAME, matches what SPEC says it should look like."
   (face-attr-match-p face (face-spec-choose spec frame) frame))
 
@@ -1677,89 +1676,76 @@
      (t
       (> (tty-color-gray-shades display) 2)))))
 
-(defun read-color (&optional prompt convert-to-RGB-p allow-empty-name-p msg-p)
-  "Read a color name or RGB hex value: #RRRRGGGGBBBB.
-Completion is available for color names, but not for RGB hex strings.
-If the user inputs an RGB hex string, it must have the form
-#XXXXXXXXXXXX or XXXXXXXXXXXX, where each X is a hex digit.  The
-number of Xs must be a multiple of 3, with the same number of Xs for
-each of red, green, and blue.  The order is red, green, blue.
+(defun read-color (&optional prompt convert-to-RGB allow-empty-name msg)
+  "Read a color name or RGB triplet of the form \"#RRRRGGGGBBBB\".
+Completion is available for color names, but not for RGB triplets.
 
-In addition to standard color names and RGB hex values, the following
-are available as color candidates.  In each case, the corresponding
-color is used.
+RGB triplets have the form #XXXXXXXXXXXX, where each X is a hex
+digit.  The number of Xs must be a multiple of 3, with the same
+number of Xs for each of red, green, and blue.  The order is red,
+green, blue.
+
+In addition to standard color names and RGB hex values, the
+following are available as color candidates.  In each case, the
+corresponding color is used.
 
  * `foreground at point'   - foreground under the cursor
  * `background at point'   - background under the cursor
 
-Checks input to be sure it represents a valid color.  If not, raises
-an error (but see exception for empty input with non-nil
-ALLOW-EMPTY-NAME-P).
+Optional arg PROMPT is the prompt; if nil, use a default prompt.
 
-Optional arg PROMPT is the prompt; if nil, uses a default prompt.
-
-Interactively, or with optional arg CONVERT-TO-RGB-P non-nil, converts
-an input color name to an RGB hex string.  Returns the RGB hex string.
+Interactively, or with optional arg CONVERT-TO-RGB-P non-nil,
+convert an input color name to an RGB hex string.  Return the RGB
+hex string.
 
-Optional arg ALLOW-EMPTY-NAME-P controls what happens if the user
-enters an empty color name (that is, just hits `RET').  If non-nil,
-then returns an empty color name, \"\".  If nil, then raises an error.
-Programs must test for \"\" if ALLOW-EMPTY-NAME-P is non-nil.  They
-can then perform an appropriate action in case of empty input.
+If optional arg ALLOW-EMPTY-NAME is non-nil, the user is allowed
+to enter an empty color name (the empty string).
 
-Interactively, or with optional arg MSG-P non-nil, echoes the color in
-a message."
+Interactively, or with optional arg MSG non-nil, print the
+resulting color name in the echo area."
   (interactive "i\np\ni\np")    ; Always convert to RGB interactively.
   (let* ((completion-ignore-case t)
-         (colors (append '("foreground at point" "background at point")
-			 (defined-colors)))
-         (color (completing-read (or prompt "Color (name or #R+G+B+): ")
-				 colors))
-         hex-string)
-    (cond ((string= "foreground at point" color)
-	   (setq color (foreground-color-at-point)))
-	  ((string= "background at point" color)
-	   (setq color (background-color-at-point))))
-    (unless color
-      (setq color ""))
-    (setq hex-string
-	  (string-match "^#?\\([a-fA-F0-9][a-fA-F0-9][a-fA-F0-9]\\)+$" color))
-    (if (and allow-empty-name-p (string= "" color))
-        ""
-      (when (and hex-string (not (eq (aref color 0) ?#)))
-        (setq color (concat "#" color))) ; No #; add it.
-      (unless hex-string
-        (when (or (string= "" color) (not (test-completion color colors)))
-          (error "No such color: %S" color))
-        (when convert-to-RGB-p
-          (let ((components (x-color-values color)))
-            (unless components (error "No such color: %S" color))
-            (unless (string-match "^#\\([a-fA-F0-9][a-fA-F0-9][a-fA-F0-9]\\)+$" color)
-              (setq color (format "#%04X%04X%04X"
-                                  (logand 65535 (nth 0 components))
-                                  (logand 65535 (nth 1 components))
-                                  (logand 65535 (nth 2 components))))))))
-      (when msg-p (message "Color: `%s'" color))
-      color)))
+	 (colors (or facemenu-color-alist
+		     (append '("foreground at point" "background at point")
+			     (if allow-empty-name '(""))
+			     (defined-colors))))
+	 (color (completing-read
+		 (or prompt "Color (name or #RGB triplet): ")
+		 ;; Completing function for reading colors, accepting
+		 ;; both color names and RGB triplets.
+		 (lambda (string pred flag)
+		   (cond
+		    ((null flag) ; Try completion.
+		     (or (try-completion string colors pred)
+			 (if (color-defined-p string)
+			     string)))
+		    ((eq flag t) ; List all completions.
+		     (or (all-completions string colors pred)
+			 (if (color-defined-p string)
+			     (list string))))
+		    ((eq flag 'lambda) ; Test completion.
+		     (or (memq string colors)
+			 (color-defined-p string)))))
+		 nil t))
+	 hex-string)
 
-;; Commented out because I decided it is better to include the
-;; duplicates in read-color's completion list.
+    ;; Process named colors.
+    (when (member color colors)
+      (cond ((string-equal color "foreground at point")
+	     (setq color (foreground-color-at-point)))
+	    ((string-equal color "background at point")
+	     (setq color (background-color-at-point))))
+      (when (and convert-to-RGB
+		 (not (string-equal color "")))
+	(let ((components (x-color-values color)))
+	  (unless (string-match "^#\\([a-fA-F0-9][a-fA-F0-9][a-fA-F0-9]\\)+$" color)
+	    (setq color (format "#%04X%04X%04X"
+				(logand 65535 (nth 0 components))
+				(logand 65535 (nth 1 components))
+				(logand 65535 (nth 2 components))))))))
+    (when msg (message "Color: `%s'" color))
+    color))
 
-;; (defun defined-colors-without-duplicates ()
-;;   "Return the list of defined colors, without the no-space versions.
-;; For each color name, we keep the variant that DOES have spaces."
-;;   (let ((result (copy-sequence (defined-colors)))
-;; 	   to-be-rejected)
-;;     (save-match-data
-;;       (dolist (this result)
-;; 	   (if (string-match " " this)
-;; 	       (push (replace-regexp-in-string " " ""
-;; 					       this)
-;; 		     to-be-rejected)))
-;;       (dolist (elt to-be-rejected)
-;; 	   (let ((as-found (car (member-ignore-case elt result))))
-;; 	     (setq result (delete as-found result)))))
-;;     result))
 
 (defun face-at-point ()
   "Return the face of the character after point.
@@ -1837,10 +1823,13 @@
 
 (defvar inhibit-frame-set-background-mode nil)
 
-(defun frame-set-background-mode (frame)
+(defun frame-set-background-mode (frame &optional keep-face-specs)
   "Set up display-dependent faces on FRAME.
 Display-dependent faces are those which have different definitions
-according to the `background-mode' and `display-type' frame parameters."
+according to the `background-mode' and `display-type' frame parameters.
+
+If optional arg KEEP-FACE-SPECS is non-nil, don't recalculate
+face specs for the new background mode."
   (unless inhibit-frame-set-background-mode
     (let* ((bg-resource
 	    (and (window-system frame)
@@ -1888,29 +1877,29 @@
 	(let ((locally-modified-faces nil)
 	      ;; Prevent face-spec-recalc from calling this function
 	      ;; again, resulting in a loop (bug#911).
-	      (inhibit-frame-set-background-mode t))
-	  ;; Before modifying the frame parameters, collect a list of
-	  ;; faces that don't match what their face-spec says they
-	  ;; should look like.  We then avoid changing these faces
-	  ;; below.  These are the faces whose attributes were
-	  ;; modified on FRAME.  We use a negative list on the
-	  ;; assumption that most faces will be unmodified, so we can
-	  ;; avoid consing in the common case.
-	  (dolist (face (face-list))
-	    (and (not (get face 'face-override-spec))
-		 (not (face-spec-match-p face
-					 (face-user-default-spec face)
-					 (selected-frame)))
-		 (push face locally-modified-faces)))
-	  ;; Now change to the new frame parameters
-	  (modify-frame-parameters frame
-				   (list (cons 'background-mode bg-mode)
-					 (cons 'display-type display-type)))
-	  ;; For all named faces, choose face specs matching the new frame
-	  ;; parameters, unless they have been locally modified.
-	  (dolist (face (face-list))
-	    (unless (memq face locally-modified-faces)
-	      (face-spec-recalc face frame))))))))
+	      (inhibit-frame-set-background-mode t)
+	      (params (list (cons 'background-mode bg-mode)
+			    (cons 'display-type display-type))))
+	  (if keep-face-specs
+	      (modify-frame-parameters frame params)
+	    ;; If we are recomputing face specs, first collect a list
+	    ;; of faces that don't match their face-specs.  These are
+	    ;; the faces modified on FRAME, and we avoid changing them
+	    ;; below.  Use a negative list to avoid consing (we assume
+	    ;; most faces are unmodified).
+	    (dolist (face (face-list))
+	      (and (not (get face 'face-override-spec))
+		   (not (face-spec-match-p face
+					   (face-user-default-spec face)
+					   (selected-frame)))
+		   (push face locally-modified-faces)))
+	    ;; Now change to the new frame parameters
+	    (modify-frame-parameters frame params)
+	    ;; For all unmodified named faces, choose face specs
+	    ;; matching the new frame parameters.
+	    (dolist (face (face-list))
+	      (unless (memq face locally-modified-faces)
+		(face-spec-recalc face frame)))))))))
 
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -1990,7 +1979,7 @@
 	(progn
 	  (x-setup-function-keys frame)
 	  (x-handle-reverse-video frame parameters)
-	  (frame-set-background-mode frame)
+	  (frame-set-background-mode frame t)
 	  (face-set-after-frame-default frame parameters)
 	  (if (null visibility-spec)
 	      (make-frame-visible frame)
@@ -2006,20 +1995,21 @@
 settings, X resources, and `face-new-frame-defaults'.
 Finally, apply any relevant face attributes found amongst the
 frame parameters in PARAMETERS."
-  (dolist (face (nreverse (face-list))) ;Why reverse?  --Stef
-    (condition-case ()
-	(progn
-	  ;; Initialize faces from face spec and custom theme.
-	  (face-spec-recalc face frame)
-	  ;; X resouces for the default face are applied during
-	  ;; x-create-frame.
-	  (and (not (eq face 'default))
-	       (memq (window-system frame) '(x w32))
-	       (make-face-x-resource-internal face frame))
-	  ;; Apply attributes specified by face-new-frame-defaults
-	  (internal-merge-in-global-face face frame))
-      ;; Don't let invalid specs prevent frame creation.
-      (error nil)))
+  (let ((window-system-p (memq (window-system frame) '(x w32))))
+    (dolist (face (nreverse (face-list))) ;Why reverse?  --Stef
+      (condition-case ()
+	  (progn
+	    ;; Initialize faces from face spec and custom theme.
+	    (face-spec-recalc face frame)
+	    ;; X resouces for the default face are applied during
+	    ;; `x-create-frame'.
+	    (and (not (eq face 'default)) window-system-p
+		 (make-face-x-resource-internal face frame))
+	    ;; Apply attributes specified by face-new-frame-defaults
+	    (internal-merge-in-global-face face frame))
+	;; Don't let invalid specs prevent frame creation.
+	(error nil))))
+
   ;; Apply attributes specified by frame parameters.
   (let ((face-params '((foreground-color default :foreground)
   		       (background-color default :background)
@@ -2066,7 +2056,7 @@
             (set-terminal-parameter frame 'terminal-initted t)
             (set-locale-environment nil frame)
             (tty-run-terminal-initialization frame))
-	  (frame-set-background-mode frame)
+	  (frame-set-background-mode frame t)
 	  (face-set-after-frame-default frame parameters)
 	  (setq success t))
       (unless success
@@ -2122,7 +2112,7 @@
 
 (defun tty-set-up-initial-frame-faces ()
   (let ((frame (selected-frame)))
-    (frame-set-background-mode frame)
+    (frame-set-background-mode frame t)
     (face-set-after-frame-default frame)))
 
 
@@ -2448,7 +2438,9 @@
   :group 'frames
   :group 'basic-faces)
 
-(defface cursor '((t nil))
+(defface cursor
+  '((((background light)) :background "black")
+    (((background dark))  :background "white"))
   "Basic face for the cursor color under X.
 Note: Other faces cannot inherit from the cursor face."
   :version "21.1"
--- a/lisp/files.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/files.el	Thu Oct 28 19:57:59 2010 +0900
@@ -801,9 +801,10 @@
       ;; Switching from names to names+fullnames creates a non-monotonicity
       ;; which can cause problems with things like partial-completion.
       ;; To minimize the problem, filter out completion-regexp-list, so that
-      ;; M-x load-library RET t/x.e TAB finds some files.
-      (if completion-regexp-list
-          (setq names (all-completions "" names)))
+      ;; M-x load-library RET t/x.e TAB finds some files.  Also remove elements
+      ;; from `names' which only matched `string' when they still had
+      ;; their suffix.
+      (setq names (all-completions string names))
       ;; Remove duplicates of the first element, so that we can easily check
       ;; if `names' really only contains a single element.
       (when (cdr names) (setcdr names (delete (car names) (cdr names))))
--- a/lisp/frame.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/frame.el	Thu Oct 28 19:57:59 2010 +0900
@@ -1,7 +1,8 @@
 ;;; frame.el --- multi-frame management independent of window systems
 
 ;; Copyright (C) 1993, 1994, 1996, 1997, 2000, 2001, 2002, 2003,
-;;   2004, 2005, 2006, 2007, 2008, 2009, 2010  Free Software Foundation, Inc.
+;;   2004, 2005, 2006, 2007, 2008, 2009, 2010
+;;   Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 ;; Keywords: internal
@@ -1066,7 +1067,7 @@
   "Set the background color of the selected frame to COLOR-NAME.
 When called interactively, prompt for the name of the color to use.
 To get the frame's current background color, use `frame-parameters'."
-  (interactive (list (facemenu-read-color "Background color: ")))
+  (interactive (list (read-color "Background color: ")))
   (modify-frame-parameters (selected-frame)
 			   (list (cons 'background-color color-name)))
   (or window-system
@@ -1076,7 +1077,7 @@
   "Set the foreground color of the selected frame to COLOR-NAME.
 When called interactively, prompt for the name of the color to use.
 To get the frame's current foreground color, use `frame-parameters'."
-  (interactive (list (facemenu-read-color "Foreground color: ")))
+  (interactive (list (read-color "Foreground color: ")))
   (modify-frame-parameters (selected-frame)
 			   (list (cons 'foreground-color color-name)))
   (or window-system
@@ -1086,7 +1087,7 @@
   "Set the text cursor color of the selected frame to COLOR-NAME.
 When called interactively, prompt for the name of the color to use.
 To get the frame's current cursor color, use `frame-parameters'."
-  (interactive (list (facemenu-read-color "Cursor color: ")))
+  (interactive (list (read-color "Cursor color: ")))
   (modify-frame-parameters (selected-frame)
 			   (list (cons 'cursor-color color-name))))
 
@@ -1094,7 +1095,7 @@
   "Set the color of the mouse pointer of the selected frame to COLOR-NAME.
 When called interactively, prompt for the name of the color to use.
 To get the frame's current mouse color, use `frame-parameters'."
-  (interactive (list (facemenu-read-color "Mouse color: ")))
+  (interactive (list (read-color "Mouse color: ")))
   (modify-frame-parameters (selected-frame)
 			   (list (cons 'mouse-color
 				       (or color-name
@@ -1105,7 +1106,7 @@
   "Set the color of the border of the selected frame to COLOR-NAME.
 When called interactively, prompt for the name of the color to use.
 To get the frame's current border color, use `frame-parameters'."
-  (interactive (list (facemenu-read-color "Border color: ")))
+  (interactive (list (read-color "Border color: ")))
   (modify-frame-parameters (selected-frame)
 			   (list (cons 'border-color color-name))))
 
@@ -1466,14 +1467,6 @@
 
 (make-variable-buffer-local 'show-trailing-whitespace)
 
-(defcustom show-trailing-whitespace nil
-  "Non-nil means highlight trailing whitespace.
-This is done in the face `trailing-whitespace'."
-  :type 'boolean
-  :safe 'booleanp
-  :group 'whitespace-faces)
-
-
 
 ;; Scrolling
 
@@ -1482,13 +1475,6 @@
   :version "21.1"
   :group 'frames)
 
-(defcustom auto-hscroll-mode t
-  "Allow or disallow automatic scrolling windows horizontally.
-If non-nil, windows are automatically scrolled horizontally to make
-point visible."
-  :version "21.1"
-  :type 'boolean
-  :group 'scrolling)
 (defvaralias 'automatic-hscrolling 'auto-hscroll-mode)
 
 
@@ -1575,35 +1561,6 @@
                                'blink-cursor-start))))
 
 (define-obsolete-variable-alias 'blink-cursor 'blink-cursor-mode "22.1")
-
-;; Hourglass pointer
-
-(defcustom display-hourglass t
-  "Non-nil means show an hourglass pointer, when Emacs is busy.
-This feature only works when on a window system that can change
-cursor shapes."
-  :type 'boolean
-  :group 'cursor)
-
-(defcustom hourglass-delay 1
-  "Seconds to wait before displaying an hourglass pointer when Emacs is busy."
-  :type 'number
-  :group 'cursor)
-
-
-(defcustom cursor-in-non-selected-windows t
-  "Non-nil means show a hollow box cursor in non-selected windows.
-If nil, don't show a cursor except in the selected window.
-If t, display a cursor related to the usual cursor type
- \(a solid box becomes hollow, a bar becomes a narrower bar).
-You can also specify the cursor type as in the `cursor-type' variable.
-Use Custom to set this variable to get the display updated."
-  :tag "Cursor In Non-selected Windows"
-  :type 'boolean
-  :group 'cursor
-  :set #'(lambda (symbol value)
-	   (set-default symbol value)
-	   (force-mode-line-update t)))
 
 
 ;;;; Key bindings
@@ -1615,5 +1572,4 @@
 
 (provide 'frame)
 
-;; arch-tag: 82979c70-b8f2-4306-b2ad-ddbd6b328b56
 ;;; frame.el ends here
--- a/lisp/gnus/ChangeLog	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/gnus/ChangeLog	Thu Oct 28 19:57:59 2010 +0900
@@ -1,3 +1,430 @@
+2010-10-28  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+	* gnus-art.el (gnus-article-jump-to-part): Error on no part; fix prompt.
+	(gnus-mime-copy-part): Check coding system, not charset.
+	(gnus-mime-view-part-externally): Never remove part.
+	(gnus-mime-view-part-internally): Don't remove part here.
+	(gnus-article-part-wrapper): Make sure MIME tag is visible.
+	(gnus-article-goto-part): Go to displayed or preferred subpart if it is
+	multipart/alternative.
+
+	* mm-decode.el (mm-display-part): Take optional arg `force'.
+
+2010-10-26  Julien Danjou  <julien@danjou.info>
+
+	* gnus-group.el (gnus-group-default-list-level): Add this function to
+	compute the default list level.
+	(gnus-group-default-list-level): Add possibility to use a function.
+
+2010-10-27  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+	* mm-decode.el (mm-shr): Add undisplayer to MIME handle.
+
+	* gnus-group.el (gnus-group-completing-read)
+	(gnus-read-ephemeral-bug-group): Replace replace-regexp-in-string with
+	gnus-replace-in-string.
+
+2010-10-26  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+	* shr.el (shr-tag-div): Added.
+
+2010-10-25  Julien Danjou  <julien@danjou.info>
+
+	* gnus-util.el: Remove `gnus-with-local-quit'.
+
+	* gnus-demon.el (gnus-demon-init): Use run-with-idle-timer function.
+
+2010-10-25  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* gnus-sum.el (gnus-summary-select-article): Fix type error in checking
+	the original article buffer.
+
+2010-10-24  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* nnimap.el (nnimap-request-head): New function.
+	(nnimap-request-move-article): Try to be slighly faster by not
+	requesting the entire message when moving.
+	(nnimap-transform-headers): Don't bug out on bodiless articles.
+	(nnimap-send-command): Have no outstanding messages if the IMAP server
+	doesn't support streaming.
+	(nnimap-transform-headers): Fold {quoted} strings more sloppily.
+
+2010-10-24  Julien Danjou  <julien@danjou.info>
+
+	* message.el (message-default-headers): Fix type.
+
+2010-10-24  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* gnus-html.el (gnus-html-prefetch-images): Decode entities before
+	prefetching images.
+
+	* gnus-sum.el (gnus-group-make-articles-read): Propagate marks to the
+	backend for unknown groups.  This is mainly useful for nnimap groups.
+
+	* gnus-agent.el (gnus-agent-fetch-group): Don't download stuff if the
+	group isn't covered by the agent.
+
+2010-10-22  Andrew Cohen  <cohen@andy.bu.edu>
+
+	* nnir.el (nnir-method-default-engines): new variable.
+	(nnir-run-query): use it.
+	(nnir-group-mode-hook): remove key binding and move to gnus-group.el.
+	(gnus-summary-nnir-goto-thread): change group if needed.
+
+	* gnus-group.el (gnus-group-group-map): add key binding for
+	gnus-group-make-nnir-group.
+
+2010-10-24  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* shr.el (shr-tag-object): Added.
+
+	* gnus-sum.el (gnus-summary-select-article): Make sure we have the
+	original article buffer live.
+	(gnus-summary-select-article-buffer): Mention
+	gnus-widen-article-buffer.
+
+2010-10-23  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* shr.el (shr-tag-strong): Added.
+
+2010-10-22  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* gnus-group.el (gnus-group-completing-read): Remove all newlines from
+	group names.  They mess up the group buffer badly.
+
+	* shr.el (shr-tag-img): Don't bug out on images that don't have a SRC.
+
+	* gnus-group.el (gnus-group-mark-group): Use gnus-group-position-point
+	instead of the summary one.
+
+2010-10-22  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+	* mml.el (mml-preview): Work properly when editing article.
+
+	* gnus-start.el (gnus-read-active-file-1): Don't add method to
+	gnus-have-read-active-file if it's already been in.
+
+2010-10-22  Tom Tromey  <tromey@redhat.com>
+
+	* gnus-group.el (gnus-group-unsubscribe-group): Fix args passed to
+	gnus-group-completing-read.
+
+2010-10-21  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* message.el (message-mode-map): Don't bind M-; to comment region, to
+	allow the global comment-dwim to work.
+
+2010-10-21  Julien Danjou  <julien@danjou.info>
+
+	* message.el (message-setup-1): Allow message-default-headers to be a
+	function.
+
+2010-10-21  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+	* shr.el (shr-tag-table): Simplify.
+
+2010-10-21  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* gnus-html.el (gnus-html-prefetch-images): Only prefetch http images
+	to avoid trying to snarf invalid stuff.
+
+	* gnus-sum.el (gnus-summary-edit-article-done): Bind free variable.
+
+	* gnus.el (gnus-message-archive-group): Quote value.
+	(gnus-message-archive-group): Mark as changed.
+
+	* shr.el (shr-add-font): Don't put the font properties on the newline
+	or the indentation.
+
+	* message.el (message-fix-before-sending): Change options when sending
+	non-printable characters.
+
+	* gnus.el (gnus-message-archive-method): Change the default to
+	monthly outgoing groups.
+
+	* gnus-sum.el (gnus-summary-edit-article-done): Try to replace articles
+	that have gotten new numbers.
+
+	* nnimap.el (nnimap-request-replace-article): New function.
+
+2010-10-21  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+	* nnrss.el (nnrss-wash-html-in-text-plain-parts): Remove.
+	(nnrss-request-article): Don't use special html washing code.
+
+2010-10-20  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+	* shr.el (shr-tag-table): Remove useless nconc.
+
+2010-10-20  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* gnus-art.el (article-wash-html): Simplify and remove the charset
+	stuff.  Use the normal html rendering code instead of the special html
+	washing code.
+
+	* mm-view.el (mm-text-html-renderer-alist): Add the `shr' and
+	`gnus-w3m' symbols.
+	(mm-text-html-washer-alist): Removed.
+
+	* mm-decode.el (mm-inline-text-html-renderer): Removed.
+	(mm-inline-media-tests): Removed use.
+	(mm-text-html-renderer): Change default to the `shr' symbol.
+
+	* mm-view.el (mm-inline-text-html): Removed use.
+
+	* gnus-art.el (gnus-blocked-images): New function.  Allow the
+	`gnus-blocked-images' to be a function.
+	(gnus-article-wash-function): Removed.
+
+2010-10-20  Julien Danjou  <julien@danjou.info>
+
+	* spam.el (spam-list-of-processors): Mark as obsolete.
+
+	* nnimap.el (nnimap-request-article): Fix BODYSTRUCTURE retrieval.
+	(nnimap-insert-partial-structure): Fix boundary detection.
+
+2010-10-20  Andreas Seltenreich  <seltenreich@gmx.de>
+
+	* gnus-draft.el (gnus-draft-check-draft-articles): Don't unnecessarily
+	run file-truename on remote files.  This can be expensive and even
+	prevent one from editing drafts if some unrelated buffer has a stale
+	connection.
+
+2010-10-20  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+	* shr.el (shr-find-fill-point): Shorten line if the preceding char is
+	kinsoku-eol regardless of shr-kinsoku-shorten.
+	(shr-tag-table-1): Rename from shr-tag-table; make it a subroutine.
+	(shr-tag-table): Support caption, thead, and tfoot.
+
+2010-10-19  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* shr.el (shr-find-fill-point): Don't leave blanks at the start of some
+	lines.
+	(shr-save-contents): New command and keystroke.
+
+	* nndoc.el (nndoc-type-alist): Add git support.
+	(nndoc-git-type-p): New function.
+	(nndoc-transform-git-article): Ditto.
+	(nndoc-transform-git-headers): Ditto.
+	(nndoc-transform-git-headers): Generate Subject headers.
+
+	* shr.el (shr-parse-style): New function.
+	(shr-tag-span): Ditto.
+
+	* nnmairix.el (nnmairix-summary-mode-hook): Move nnmairix's `$' command
+	to `G G' to avoid collisions.
+
+2010-10-19  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+	* shr.el: Load kinsoku if necessary.
+	(shr-kinsoku-shorten): New internal variable.
+	(shr-find-fill-point): Make kinsoku shorten text line if
+	shr-kinsoku-shorten is bound to non-nil.
+	(shr-tag-table): Bild shr-kinsoku-shorten to t; refer to
+	shr-indentation too when testing if table is wider than frame width.
+	(shr-insert-table): Use `string-width' instead of `length' to measure
+	text width.
+	(shr-insert-table-ruler): Make sure indentation is done at bol.
+
+2010-10-19  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* nnimap.el (nnimap-request-move-article, nnimap-parse-line)
+	(nnimap-process-expiry-targets): Use unibyte for buffers that hold
+	undecoded network data.
+
+2010-10-18  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* gnus-agent.el (gnus-agent-toggle-plugged): Use the right minor mode
+	name in the mode line spec so that the mode line menu works
+	(bug #2431).
+
+	* message.el (message-get-reply-headers): If we're fed `to-address',
+	then always use that.
+
+	* gnus-art.el (gnus-article-make-menu-bar): The article/group menus
+	aren't so wide as to need to switch off the edit menu.
+
+	* gnus-delay.el (gnus-delay-article): Remove superfluous `group'
+	binding.  Suggested by Leo <sdl.web@gmail.com> (bug #6613).
+
+	* nnimap.el (nnimap-request-group): Don't SELECT the group twice on
+	`M-g'.
+	(nnimap-update-info): Update flags/read marks even if \* isn't part of
+	the permanent marks.
+
+2010-10-18  Andrew Cohen  <cohen@andy.bu.edu>
+
+	* gnus-registry.el (gnus-registry-split-fancy-with-parent):
+	Splitting according to references/in-reply-to obeys the ignore-groups
+	variable, while splitting by sender and subject do not.
+
+2010-10-18  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* gnus-art.el (gnus-article-dumbquotes-map): Make into a char/string
+	alist, so that we can look for non-Unicode chars.
+	(article-translate-strings): Allow both character and string maps.
+
+2010-10-18  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+	* shr.el (shr-insert): Don't insert space behind a wide character
+	categorized as kinsoku-bol, or between characters both categorized as
+	nospace.
+
+2010-10-16  Andrew Cohen  <cohen@andy.bu.edu>
+
+	* gnus-sum.el (gnus-summary-refer-thread): Bug fix. Add the thread
+	headers to gnus-newsgroup-headers.
+
+2010-10-16  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* shr.el (shr-tag-img): Don't align images -- since we're not
+	rescaling, this often leads to ugly displays.
+
+2010-10-15  Andrew Cohen  <cohen@andy.bu.edu>
+
+	* gnus-sum.el (gnus-summary-refer-thread): Unconditionally ignore
+	duplicates.
+
+2010-10-15  Kan-Ru Chen  <kanru@kanru.info>  (tiny change)
+
+	* gnus-diary.el (gnus-diary-check-message): Fix gnus-completing-read
+	call.
+
+2010-10-15  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* gnus.el: Autoload gnus-html-show-images.
+
+	* nnimap.el: Use nnheader-message throughout.
+
+	* shr.el (shr-tag-img): Ignore images with no data.
+
+2010-10-15  Julien Danjou  <julien@danjou.info>
+
+	* mml.el (mml-generate-mime-1): Add `mml-enable-flowed' variable to add
+	a possibility to disable format=flow encoding when using hard newlines.
+
+2010-10-15  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+	* shr.el (shr-insert): Remove space inserted before or after a
+	breakable character or at the beginning or the end of a line.
+	(shr-find-fill-point): Do kinsoku; find the second best point or give
+	it up if there's no breakable point.
+
+2010-10-14  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* nnimap.el (nnimap-open-connection): Message when opening connection
+	for debugging purposes.
+
+	* gnus-art.el (gnus-article-setup-buffer): Set article mode truncation
+	on every setup buffer call to allow this to change from article to
+	article.
+
+	* shr.el (shr-tag-table): Experimental feature: Truncate lines in
+	buffers where we have a wide table.
+
+2010-10-14  Andrew Cohen  <cohen@andy.bu.edu>
+
+	* gnus-sum.el (gnus-summary-refer-thread): Implement a version that
+	uses *-request-thread.
+
+2010-10-14  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* nnimap.el (nnimap-open-connection): Remove %s from openssl
+	incantation, which is no longer valid.
+
+2010-10-14  Julien Danjou  <julien@danjou.info>
+
+	* shr.el: Fix defcustom type (char -> character).
+
+2010-10-14  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* nnimap.el (nnimap-open-connection): tls-program should be a list of
+	programs.
+
+2010-10-14  Julien Danjou  <julien@danjou.info>
+
+	* shr.el (shr-tag-a): Use url-link as widget type.
+
+	* gnus-group.el (gnus-group-insert-group-line): Fix group argument to
+	`gnus-group-get-icon'.
+
+2010-10-13  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* nnimap.el (nnimap-close-server): Forget the nnimap data on close.
+	This should make server editing work better.
+
+	* shr.el (shr-find-fill-point): Don't inloop on indented text.
+
+	* nnimap.el (nnimap-open-connection): Fix open-tls-stream call.
+	(nnimap-parse-flags): Fix regexp.
+
+	* shr.el (shr-find-fill-point): Use a filling algorithm that should
+	probably work for CJVK text, too.
+
+	* nnimap.el (nnimap-extend-tls-programs): Removed.
+	(nnimap-open-connection): Bind STARTTLS to openssl explicitly.
+
+2010-10-13  Julien Danjou  <julien@danjou.info>
+
+	* nnimap.el (nnimap-parse-flags): Be more strict when looking for FETCH
+	responses.
+
+2010-10-13  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* mm-decode.el (mm-shr): Allow use from non-Gnus users.
+
+	* gnus-spec.el (gnus-parse-simple-format): princ doesn't really insert
+	anything in Emacs.
+
+	* shr.el (shr-current-column): Remove buggy and unnecessary function.
+
+2010-10-13  Julien Danjou  <julien@danjou.info>
+
+	* shr.el (shr-width): Make shr-width a defcustom with default to
+	fill-column.
+	(shr-tag-img): Use shr-width rather than fill-column.
+
+2010-10-13  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+	* gnus-dired.el (gnus-dired-attach): Silence XEmacs 21.5 when compiling.
+
+	* gnus-gravatar.el (gnus-gravatar-transform-address): Adjust avatars'
+	position when (X-)Faces exist.
+	(gnus-treat-from-gravatar, gnus-treat-mail-gravatar): Force displaying
+	avatars when called interactively.
+
+2010-10-12  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+	* gnus-gravatar.el (gnus-gravatar-too-ugly): Don't test if
+	gnus-article-x-face-too-ugly is bound.
+
+2010-10-12  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* rfc2231.el (rfc2231-parse-string): Ignore repeated parts.
+
+	* nnimap.el (nnimap-request-rename-group): Unselect by selecting a
+	mailbox that doesn't exist.
+
+2010-10-12  Julien Danjou  <julien@danjou.info>
+
+	* shr.el (shr-tag-img): Encode URL properly when retrieving.
+	(shr-get-image-data): Encode URL properly when fetching from cache.
+	(shr-tag-img): Use aligned-to spaces to align correctly images.
+
+	* gnus-gravatar.el (gnus-gravatar-insert): Check if buffer is alive
+	before inserting the Gravatar.
+
+	* shr.el (shr-tag-img): Add align attribute support for <img>.
+
+2010-10-12  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* gnus-gravatar.el (gnus-art): Required.
+
+	* gnus-sum.el (gnus-summary-mark-as-unread-forward)
+	(gnus-summary-mark-as-unread-backward, gnus-summary-mark-as-unread):
+	Remove long obsoleted functions.
+
 2010-10-11  Katsumi Yamaoka  <yamaoka@jpl.org>
 
 	* nnimap.el (gnutls-negotiate): Silence the byte compiler.
--- a/lisp/gnus/ChangeLog.2	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/gnus/ChangeLog.2	Thu Oct 28 19:57:59 2010 +0900
@@ -3828,8 +3828,7 @@
 	that Gnus will render it as html if the user wants that.
 
 	Implemented the ability to save nnrss-group-alist so that any new
-	feeds the you subscribe to will be found the next time you start
-	up.
+	feeds you subscribe to will be found the next time you start up.
 
 	Implemented support for RSS 2.0 elements (author, pubDate).
 
@@ -5550,7 +5549,7 @@
 
 	* gnus-audio.el (gnus-audio-au-player): Use executable-find.
 
-2003-01-13  Jhair Tocancipa Triana  <jhair_tocancipa@@gmx.net>
+2003-01-13  Jhair Tocancipa Triana  <jhair_tocancipa@gmx.net>
 
 	* gnus-audio.el (gnus-audio-au-player, gnus-audio-wav-player): Use
 	/usr/bin/play as default player.
@@ -12167,7 +12166,7 @@
 2001-12-05 12:00:00  ShengHuo ZHU  <zsh@cs.rochester.edu>
 
 	* gnus-group.el (gnus-group-find-new-groups): Fix doc.
-	From:  Stefan Monnier  <monnier@cs.yale.edu>
+	From: Stefan Monnier  <monnier@cs.yale.edu>
 
 2001-12-05  Katsumi Yamaoka  <yamaoka@jpl.org>
 
@@ -14682,7 +14681,7 @@
 	* gnus-eform.el (gnus-edit-form-done): Return nil if end-of-file.
 
 2001-07-16 12:00:00  ShengHuo ZHU  <zsh@cs.rochester.edu>
-	From:  Stefan Monnier  <monnier@cs.yale.edu>
+	From: Stefan Monnier  <monnier@cs.yale.edu>
 
 	* message.el (message-mode): Use define-derived-mode.
 	(message-tab): message-completion-alist.
--- a/lisp/gnus/ecomplete.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/gnus/ecomplete.el	Thu Oct 28 19:57:59 2010 +0900
@@ -147,7 +147,7 @@
     (save-restriction
       (narrow-to-region (point) (point-at-eol))
       (while (not (eobp))
-	;; Put the 'region face on any charactes on this line that
+	;; Put the 'region face on any characters on this line that
 	;; aren't already highlighted.
 	(unless (get-text-property (point) 'face)
 	  (put-text-property (point) (1+ (point)) 'face 'highlight))
--- a/lisp/gnus/gnus-agent.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/gnus/gnus-agent.el	Thu Oct 28 19:57:59 2010 +0900
@@ -513,8 +513,8 @@
     ;; Set up the menu.
     (when (gnus-visual-p 'agent-menu 'menu)
       (funcall (intern (format "gnus-agent-%s-make-menu-bar" buffer))))
-    (unless (assq 'gnus-agent-mode minor-mode-alist)
-      (push gnus-agent-mode-status minor-mode-alist))
+    (unless (assq mode minor-mode-alist)
+      (push (cons mode (cdr gnus-agent-mode-status)) minor-mode-alist))
     (unless (assq mode minor-mode-map-alist)
       (push (cons mode (symbol-value (intern (format "gnus-agent-%s-mode-map"
 						     buffer))))
@@ -801,12 +801,13 @@
   (setq group (or group gnus-newsgroup-name))
   (unless group
     (error "No group on the current line"))
-
-  (gnus-agent-while-plugged
-    (let ((gnus-command-method (gnus-find-method-for-group group)))
-      (gnus-agent-with-fetch
-        (gnus-agent-fetch-group-1 group gnus-command-method)
-        (gnus-message 5 "Fetching %s...done" group)))))
+  (if (not (gnus-agent-group-covered-p group))
+      (message "%s isn't covered by the agent" group)
+    (gnus-agent-while-plugged
+      (let ((gnus-command-method (gnus-find-method-for-group group)))
+	(gnus-agent-with-fetch
+	  (gnus-agent-fetch-group-1 group gnus-command-method)
+	  (gnus-message 5 "Fetching %s...done" group))))))
 
 (defun gnus-agent-add-group (category arg)
   "Add the current group to an agent category."
--- a/lisp/gnus/gnus-art.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/gnus/gnus-art.el	Thu Oct 28 19:57:59 2010 +0900
@@ -916,25 +916,25 @@
   "Function used to decode addresses.")
 
 (defvar gnus-article-dumbquotes-map
-  '(("\200" "EUR")
-    ("\202" ",")
-    ("\203" "f")
-    ("\204" ",,")
-    ("\205" "...")
-    ("\213" "<")
-    ("\214" "OE")
-    ("\221" "`")
-    ("\222" "'")
-    ("\223" "``")
-    ("\224" "\"")
-    ("\225" "*")
-    ("\226" "-")
-    ("\227" "--")
-    ("\230" "~")
-    ("\231" "(TM)")
-    ("\233" ">")
-    ("\234" "oe")
-    ("\264" "'"))
+  '((?\200 "EUR")
+    (?\202 ",")
+    (?\203 "f")
+    (?\204 ",,")
+    (?\205 "...")
+    (?\213 "<")
+    (?\214 "OE")
+    (?\221 "`")
+    (?\222 "'")
+    (?\223 "``")
+    (?\224 "\"")
+    (?\225 "*")
+    (?\226 "-")
+    (?\227 "--")
+    (?\230 "~")
+    (?\231 "(TM)")
+    (?\233 ">")
+    (?\234 "oe")
+    (?\264 "'"))
   "Table for MS-to-Latin1 translation.")
 
 (defcustom gnus-ignored-mime-types nil
@@ -1621,9 +1621,6 @@
   :type 'string
   :group 'mime-security)
 
-(defvar gnus-article-wash-function nil
-  "Function used for converting HTML into text.")
-
 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
 			      (mm-coding-system-p 'utf-8)
 			      (executable-find idna-program))
@@ -1639,8 +1636,11 @@
   :group 'gnus-article
   :type 'boolean)
 
-(defcustom gnus-blocked-images "."
-  "Images that have URLs matching this regexp will be blocked."
+(defcustom gnus-blocked-images 'gnus-block-private-groups
+  "Images that have URLs matching this regexp will be blocked.
+This can also be a function to be evaluated.  If so, it will be
+called with the group name as the parameter, and should return a
+regexp."
   :version "24.1"
   :group 'gnus-art
   :type 'regexp)
@@ -2138,9 +2138,18 @@
     (when (article-goto-body)
       (let ((inhibit-read-only t))
 	(dolist (elem map)
-	  (save-excursion
-	    (while (search-forward (car elem) nil t)
-	      (replace-match (cadr elem)))))))))
+	  (let ((from (car elem))
+		(to (cadr elem)))
+	    (save-excursion
+	      (if (stringp from)
+		  (while (search-forward from nil t)
+		    (replace-match to))
+		(while (not (eobp))
+		  (if (eq (following-char) from)
+		      (progn
+			(delete-char 1)
+			(insert to))
+		    (forward-char 1)))))))))))
 
 (defun article-treat-overstrike ()
   "Translate overstrikes into bold text."
@@ -2685,118 +2694,16 @@
     (when (interactive-p)
       (gnus-treat-article nil))))
 
-
-(defun article-wash-html (&optional read-charset)
-  "Format an HTML article.
-If READ-CHARSET, ask for a coding system.  If it is a number, the
-charset defined in `gnus-summary-show-article-charset-alist' is used."
-  (interactive "P")
-  (save-excursion
-    (let ((inhibit-read-only t)
-	  charset)
-      (if read-charset
-	  (if (or (and (numberp read-charset)
-		       (setq charset
-			     (cdr
-			      (assq read-charset
-				    gnus-summary-show-article-charset-alist))))
-		  (setq charset (mm-read-coding-system "Charset: ")))
-	      (let ((gnus-summary-show-article-charset-alist
-		     (list (cons 1 charset))))
-		(with-current-buffer gnus-summary-buffer
-		  (gnus-summary-show-article 1)))
-	    (error "No charset is given"))
-	(when (gnus-buffer-live-p gnus-original-article-buffer)
-	  (with-current-buffer gnus-original-article-buffer
-	    (let* ((ct (gnus-fetch-field "content-type"))
-		   (ctl (and ct (mail-header-parse-content-type ct))))
-	      (setq charset (and ctl
-				 (mail-content-type-get ctl 'charset)))
-	      (when (stringp charset)
-		(setq charset (intern (downcase charset)))))))
-	(unless charset
-	  (setq charset gnus-newsgroup-charset)))
-      (article-goto-body)
-      (save-window-excursion
-	(save-restriction
-	  (narrow-to-region (point) (point-max))
-	  (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
-		 (entry (assq func mm-text-html-washer-alist)))
-	    (when entry
-	      (setq func (cdr entry)))
-	    (cond
-	     ((functionp func)
-	      (funcall func))
-	     (t
-	      (apply (car func) (cdr func))))))))))
-
-;; External.
-(declare-function w3-region "ext:w3-display" (st nd))
-
-(defun gnus-article-wash-html-with-w3 ()
-  "Wash the current buffer with w3."
-  (mm-setup-w3)
-  (let ((w3-strict-width (window-width))
-	(url-standalone-mode t)
-	(url-gateway-unplugged t)
-	(w3-honor-stylesheets nil))
-    (condition-case ()
-	(w3-region (point-min) (point-max))
-      (error))))
-
-;; External.
-(declare-function w3m-region "ext:w3m" (start end &optional url charset))
-
-(defun gnus-article-wash-html-with-w3m ()
-  "Wash the current buffer with emacs-w3m."
-  (mm-setup-w3m)
-  (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp)
-	w3m-force-redisplay)
-    (w3m-region (point-min) (point-max)))
-  ;; Put the mark meaning this part was rendered by emacs-w3m.
-  (put-text-property (point-min) (point-max) 'mm-inline-text-html-with-w3m t)
-  (when (and mm-inline-text-html-with-w3m-keymap
-	     (boundp 'w3m-minor-mode-map)
-	     w3m-minor-mode-map)
-    (if (and (boundp 'w3m-link-map)
-	     w3m-link-map)
-	(let* ((start (point-min))
-	       (end (point-max))
-	       (on (get-text-property start 'w3m-href-anchor))
-	       (map (copy-keymap w3m-link-map))
-	       next)
-	  (set-keymap-parent map w3m-minor-mode-map)
-	  (while (< start end)
-	    (if on
-		(progn
-		  (setq next (or (text-property-any start end
-						    'w3m-href-anchor nil)
-				 end))
-		  (put-text-property start next 'keymap map))
-	      (setq next (or (text-property-not-all start end
-						    'w3m-href-anchor nil)
-			     end))
-	      (put-text-property start next 'keymap w3m-minor-mode-map))
-	    (setq start next
-		  on (not on))))
-      (put-text-property (point-min) (point-max) 'keymap w3m-minor-mode-map))))
-
-(defvar charset) ;; Bound by `article-wash-html'.
-
-(defun gnus-article-wash-html-with-w3m-standalone ()
-  "Wash the current buffer with w3m."
-  (if (mm-w3m-standalone-supports-m17n-p)
-      (progn
-	(unless (mm-coding-system-p charset) ;; Bound by `article-wash-html'.
-	  ;; The default.
-	  (setq charset 'iso-8859-1))
-	(let ((coding-system-for-write charset)
-	      (coding-system-for-read charset))
-	  (call-process-region
-	   (point-min) (point-max)
-	   "w3m" t t nil "-dump" "-T" "text/html"
-	   "-I" (symbol-name charset) "-O" (symbol-name charset))))
-    (mm-inline-wash-with-stdin nil "w3m" "-dump" "-T" "text/html")))
+(defun article-wash-html ()
+  "Format an HTML article."
+  (interactive)
+  (let ((handles nil)
+	(buffer-read-only nil))
+    (when (gnus-buffer-live-p gnus-original-article-buffer)
+      (setq handles (mm-dissect-buffer t t)))
+    (article-goto-body)
+    (delete-region (point) (point-max))
+    (mm-inline-text-html handles)))
 
 (defvar gnus-article-browse-html-temp-list nil
   "List of temporary files created by `gnus-article-browse-html-parts'.
@@ -4393,7 +4300,6 @@
 (defun gnus-article-make-menu-bar ()
   (unless (boundp 'gnus-article-commands-menu)
     (gnus-summary-make-menu-bar))
-  (gnus-turn-off-edit-menu 'article)
   (unless (boundp 'gnus-article-article-menu)
     (easy-menu-define
      gnus-article-article-menu gnus-article-mode-map ""
@@ -4474,7 +4380,6 @@
   ;; face.
   (set (make-local-variable 'nobreak-char-display) nil)
   (setq cursor-in-non-selected-windows nil)
-  (setq truncate-lines gnus-article-truncate-lines)
   (gnus-set-default-directory)
   (buffer-disable-undo)
   (setq buffer-read-only t
@@ -4534,9 +4439,11 @@
 	  (setq gnus-button-marker-list nil)
 	  (unless (eq major-mode 'gnus-article-mode)
 	    (gnus-article-mode))
+	  (setq truncate-lines gnus-article-truncate-lines)
 	  (current-buffer))
       (with-current-buffer (gnus-get-buffer-create name)
 	(gnus-article-mode)
+	(setq truncate-lines gnus-article-truncate-lines)
 	(make-local-variable 'gnus-summary-buffer)
 	(setq gnus-summary-buffer
 	      (gnus-summary-buffer-name gnus-newsgroup-name))
@@ -4904,11 +4811,17 @@
 (defun gnus-article-jump-to-part (n)
   "Jump to MIME part N."
   (interactive "P")
-  (pop-to-buffer gnus-article-buffer)
-  ;; FIXME: why is it necessary?
-  (sit-for 0)
-  (let ((parts (length gnus-article-mime-handle-alist)))
-    (or n (setq n (read-number (format "Jump to part (2..%s): " parts))))
+  (let ((parts (with-current-buffer gnus-article-buffer
+		 (length gnus-article-mime-handle-alist))))
+    (when (zerop parts)
+      (error "No such part"))
+    (pop-to-buffer gnus-article-buffer)
+    ;; FIXME: why is it necessary?
+    (sit-for 0)
+    (or n
+	(setq n (if (= parts 1)
+		    1
+		  (read-number (format "Jump to part (1..%s): " parts)))))
     (unless (and (integerp n) (<= n parts) (>= n 1))
       (setq n
 	    (progn
@@ -5208,7 +5121,7 @@
       (if (or coding-system
 	      (and charset
 		   (setq coding-system (mm-charset-to-coding-system charset))
-		   (not (eq charset 'ascii))))
+		   (not (eq coding-system 'ascii))))
 	  (progn
 	    (mm-enable-multibyte)
 	    (insert (mm-decode-coding-string contents coding-system))
@@ -5383,9 +5296,7 @@
 	(gnus-mime-view-part-as-type
 	 nil (lambda (type) (stringp (mailcap-mime-info type))))
       (when handle
-	(if (mm-handle-undisplayer handle)
-	    (mm-remove-part handle)
-	  (mm-display-part handle))))))
+	(mm-display-part handle nil t)))))
 
 (defun gnus-mime-view-part-internally (&optional handle)
   "View the MIME part under point with an internal viewer.
@@ -5404,9 +5315,7 @@
         (gnus-mime-view-part-as-type
          nil (lambda (type) (mm-inlinable-p handle type)))
       (when handle
-	(if (mm-handle-undisplayer handle)
-	    (mm-remove-part handle)
-	  (gnus-bind-safe-url-regexp (mm-display-part handle)))))))
+	(gnus-bind-safe-url-regexp (mm-display-part handle))))))
 
 (defun gnus-mime-action-on-part (&optional action)
   "Do something with the MIME attachment at \(point\)."
@@ -5469,6 +5378,10 @@
 	  (when (gnus-article-goto-part n)
 	    ;; We point the cursor and the arrow at the MIME button
 	    ;; when the `function' prompt the user for something.
+	    (unless (and (pos-visible-in-window-p)
+			 (> (count-lines (point) (window-end))
+			    (/ (1- (window-height)) 3)))
+	      (recenter (/ (1- (window-height)) 3)))
 	    (let ((cursor-in-non-selected-windows t)
 		  (overlay-arrow-string "=>")
 		  (overlay-arrow-position (point-marker)))
@@ -5480,11 +5393,10 @@
 		    (funcall function))
 		   (interactive
 		    (call-interactively
-		     function
-		     (cdr (assq n gnus-article-mime-handle-alist))))
+		     function (get-text-property (point) 'gnus-data)))
 		   (t
 		    (funcall function
-			     (cdr (assq n gnus-article-mime-handle-alist)))))
+			     (get-text-property (point) 'gnus-data))))
 		(set-marker overlay-arrow-position nil)
 		(unless gnus-auto-select-part
 		  (gnus-select-frame-set-input-focus frame)
@@ -5649,7 +5561,35 @@
 
 (defun gnus-article-goto-part (n)
   "Go to MIME part N."
-  (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
+  (let ((start (text-property-any (point-min) (point-max) 'gnus-part n))
+	part handle end next handles)
+    (when start
+      (goto-char start)
+      (if (setq handle (get-text-property start 'gnus-data))
+	  start
+	;; Go to the displayed subpart, assuming this is multipart/alternative.
+	(setq part start
+	      end (point-at-eol))
+	(while (and (not handle)
+		    part
+		    (< part end)
+		    (setq next (text-property-not-all part end
+						      'gnus-data nil)))
+	  (setq part next
+		handle (get-text-property part 'gnus-data))
+	  (push (cons handle part) handles)
+	  (unless (mm-handle-displayed-p handle)
+	    (setq handle nil
+		  part (text-property-any part end 'gnus-data nil))))
+	(unless handle
+	  ;; No subpart is displayed, so we find preferred one.
+	  (setq part
+		(cdr (assq (mm-preferred-alternative
+			    (nreverse (mapcar 'car handles)))
+			   handles))))
+	(if part
+	    (goto-char (1+ part))
+	  start)))))
 
 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
   (let ((gnus-tmp-name
@@ -6887,6 +6827,18 @@
 			    (point))
 	  (set-buffer buf))))))
 
+(defun gnus-block-private-groups (group)
+  (if (gnus-news-group-p group)
+      ;; Block nothing in news groups.
+      nil
+    ;; Block everything anywhere else.
+    "."))
+
+(defun gnus-blocked-images ()
+  (if (functionp gnus-blocked-images)
+      (funcall gnus-blocked-images gnus-newsgroup-name)
+    gnus-blocked-images))
+
 ;;;
 ;;; Article editing
 ;;;
--- a/lisp/gnus/gnus-delay.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/gnus/gnus-delay.el	Thu Oct 28 19:57:59 2010 +0900
@@ -133,8 +133,7 @@
     (message-add-header (format "%s: %s" gnus-delay-header deadline)))
   (set-buffer-modified-p t)
   ;; If group does not exist, create it.
-  (let ((group (format "nndraft:%s" gnus-delay-group)))
-    (gnus-agent-queue-setup gnus-delay-group))
+  (gnus-agent-queue-setup gnus-delay-group)
   (message-disassociate-draft)
   (nndraft-request-associate-buffer gnus-delay-group)
   (save-buffer 0)
--- a/lisp/gnus/gnus-demon.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/gnus/gnus-demon.el	Thu Oct 28 19:57:59 2010 +0900
@@ -32,9 +32,6 @@
 (require 'nnheader)
 (require 'nntp)
 (require 'nnmail)
-(require 'gnus-util)
-
-(autoload 'parse-time-string "parse-time" nil nil)
 
 (defgroup gnus-demon nil
   "Demonic behavior."
@@ -46,14 +43,16 @@
 
 \(FUNCTION TIME IDLE)
 
-FUNCTION is the function to be called.
-TIME is the number of `gnus-demon-timestep's between each call.
-If nil, never call.  If t, call each `gnus-demon-timestep'.
-If IDLE is t, only call if Emacs has been idle for a while.  If IDLE
-is a number, only call when Emacs has been idle more than this number
-of `gnus-demon-timestep's.  If IDLE is nil, don't care about
-idleness.  If IDLE is a number and TIME is nil, then call once each
-time Emacs has been idle for IDLE `gnus-demon-timestep's."
+FUNCTION is the function to be called.  TIME is the number of
+`gnus-demon-timestep's between each call.
+If nil, never call. If t, call each `gnus-demon-timestep'.
+
+If IDLE is t, only call each time Emacs has been idle for TIME.
+If IDLE is a number, only call when Emacs has been idle more than
+this number of `gnus-demon-timestep's.
+If IDLE is nil, don't care about idleness.
+If IDLE is a number and TIME is nil, then call once each time
+Emacs has been idle for IDLE `gnus-demon-timestep's."
   :group 'gnus-demon
   :type '(repeat (list function
 		       (choice :tag "Time"
@@ -66,19 +65,16 @@
 			       (integer :tag "steps" 1)))))
 
 (defcustom gnus-demon-timestep 60
-  "*Number of seconds in each demon timestep."
+  "Number of seconds in each demon timestep."
   :group 'gnus-demon
   :type 'integer)
 
 ;;; Internal variables.
 
-(defvar gnus-demon-timer nil)
-(defvar gnus-demon-idle-has-been-called nil)
-(defvar gnus-demon-idle-time 0)
-(defvar gnus-demon-handler-state nil)
-(defvar gnus-demon-last-keys nil)
+(defvar gnus-demon-timers nil
+  "List of idle timers which are running.")
 (defvar gnus-inhibit-demon nil
-  "*If non-nil, no daemonic function will be run.")
+  "If non-nil, no daemonic function will be run.")
 
 ;;; Functions.
 
@@ -96,149 +92,67 @@
   (unless no-init
     (gnus-demon-init)))
 
+(defun gnus-demon-idle-since ()
+  "Return the number of seconds since when Emacs is idle."
+  (if (featurep 'xemacs)
+      (itimer-time-difference (current-time) last-command-event-time)
+    (float-time (or (current-idle-time)
+                    '(0 0 0)))))
+
+(defun gnus-demon-run-callback (func &optional idle)
+  "Run FUNC if Emacs has been idle for longer than IDLE seconds."
+  (unless gnus-inhibit-demon
+    (when (or (not idle)
+              (<= idle (gnus-demon-idle-since)))
+      (with-local-quit
+       (ignore-errors
+         (funcall func))))))
+
 (defun gnus-demon-init ()
   "Initialize the Gnus daemon."
   (interactive)
   (gnus-demon-cancel)
-  (when gnus-demon-handlers
+  (dolist (handler gnus-demon-handlers)
     ;; Set up the timer.
-    (setq gnus-demon-timer
-	  (run-at-time
-	   gnus-demon-timestep gnus-demon-timestep 'gnus-demon))
-    ;; Reset control variables.
-    (setq gnus-demon-handler-state
-	  (mapcar
-	   (lambda (handler)
-	     (list (car handler) (gnus-demon-time-to-step (nth 1 handler))
-		   (nth 2 handler)))
-	   gnus-demon-handlers))
-    (setq gnus-demon-idle-time 0)
-    (setq gnus-demon-idle-has-been-called nil)))
+    (let* ((func (nth 0 handler))
+           (time (nth 1 handler))
+           (idle (nth 2 handler))
+           ;; Compute time according with timestep.
+           ;; If t, replace by 1
+           (time (cond ((eq time t)
+                        gnus-demon-timestep)
+                       ((null time))
+                       (t (* time gnus-demon-timestep))))
+           (timer
+            (cond
+             ;; (func number t)
+             ;; Call when Emacs has been idle for `time'
+             ((and (numberp time) (eq idle t))
+              (run-with-timer t time 'gnus-demon-run-callback func time))
+             ;; (func number number)
+             ;; Call every `time' when Emacs has been idle for `idle'
+             ((and (numberp time) (numberp idle))
+              (run-with-timer t time 'gnus-demon-run-callback func idle))
+             ;; (func nil number)
+             ;; Only call when Emacs has been idle for `idle'
+             ((and (null time) (numberp idle))
+              (run-with-idle-timer (* idle gnus-demon-timestep) t
+                                   'gnus-demon-run-callback func))
+             ;; (func number nil)
+             ;; Call every `time'
+             ((and (numberp time) (null idle))
+              (run-with-timer t time 'gnus-demon-run-callback func)))))
+      (when timer
+        (add-to-list 'gnus-demon-timers timer)))))
 
 (gnus-add-shutdown 'gnus-demon-cancel 'gnus)
 
 (defun gnus-demon-cancel ()
   "Cancel any Gnus daemons."
   (interactive)
-  (when gnus-demon-timer
-    (nnheader-cancel-timer gnus-demon-timer))
-  (setq gnus-demon-timer nil
-	gnus-demon-idle-has-been-called nil)
-  (condition-case ()
-      (nnheader-cancel-function-timers 'gnus-demon)
-    (error t)))
-
-(defun gnus-demon-is-idle-p ()
-  "Whether Emacs is idle or not."
-  ;; We do this simply by comparing the 100 most recent keystrokes
-  ;; with the ones we had last time.  If they are the same, one might
-  ;; guess that Emacs is indeed idle.  This only makes sense if one
-  ;; calls this function seldom -- like once a minute, which is what
-  ;; we do here.
-  (let ((keys (recent-keys)))
-    (or (equal keys gnus-demon-last-keys)
-	(progn
-	  (setq gnus-demon-last-keys keys)
-	  nil))))
-
-(defun gnus-demon-time-to-step (time)
-  "Find out how many seconds to TIME, which is on the form \"17:43\"."
-  (if (not (stringp time))
-      time
-    (let* ((now (current-time))
-	   ;; obtain NOW as discrete components -- make a vector for speed
-	   (nowParts (decode-time now))
-	   ;; obtain THEN as discrete components
-	   (thenParts (parse-time-string time))
-	   (thenHour (elt thenParts 2))
-	   (thenMin (elt thenParts 1))
-	   ;; convert time as elements into number of seconds since EPOCH.
-	   (then (encode-time 0
-			      thenMin
-			      thenHour
-			      ;; If THEN is earlier than NOW, make it
-			      ;; same time tomorrow.  Doc for encode-time
-			      ;; says that this is OK.
-			      (+ (elt nowParts 3)
-				 (if (or (< thenHour (elt nowParts 2))
-					 (and (= thenHour (elt nowParts 2))
-					      (<= thenMin (elt nowParts 1))))
-				     1 0))
-			      (elt nowParts 4)
-			      (elt nowParts 5)
-			      (elt nowParts 6)
-			      (elt nowParts 7)
-			      (elt nowParts 8)))
-	   ;; calculate number of seconds between NOW and THEN
-	   (diff (+ (* 65536 (- (car then) (car now)))
-		    (- (cadr then) (cadr now)))))
-      ;; return number of timesteps in the number of seconds
-      (round (/ diff gnus-demon-timestep)))))
-
-(defun gnus-demon ()
-  "The Gnus daemon that takes care of running all Gnus handlers."
-  ;; Increase or reset the time Emacs has been idle.
-  (if (gnus-demon-is-idle-p)
-      (incf gnus-demon-idle-time)
-    (setq gnus-demon-idle-time 0)
-    (setq gnus-demon-idle-has-been-called nil))
-  ;; Disable all daemonic stuff if we're in the minibuffer
-  (when (and (not (window-minibuffer-p (selected-window)))
-	     (not gnus-inhibit-demon))
-    ;; Then we go through all the handler and call those that are
-    ;; sufficiently ripe.
-    (let ((handlers gnus-demon-handler-state)
-	  (gnus-inhibit-demon t)
-	  ;; Try to avoid dialog boxes, e.g. by Mailcrypt.
-	  ;; Unfortunately, Emacs 20's `message-or-box...' doesn't
-	  ;; obey `use-dialog-box'.
-	  use-dialog-box (last-nonmenu-event 10)
-	  handler time idle)
-      (while handlers
-	(setq handler (pop handlers))
-	(cond
-	 ((numberp (setq time (nth 1 handler)))
-	  ;; These handlers use a regular timeout mechanism.  We decrease
-	  ;; the timer if it hasn't reached zero yet.
-	  (unless (zerop time)
-	    (setcar (nthcdr 1 handler) (decf time)))
-	  (and (zerop time)		; If the timer now is zero...
-	       ;; Test for appropriate idleness
-	       (progn
-		 (setq idle (nth 2 handler))
-		 (cond
-		  ((null idle) t)	; Don't care about idle.
-		  ((numberp idle)	; Numerical idle...
-		   (< idle gnus-demon-idle-time)) ; Idle timed out.
-		  (t (< 0 gnus-demon-idle-time)))) ; Or just need to be idle.
-	       ;; So we call the handler.
-	       (gnus-with-local-quit
-		 (ignore-errors (funcall (car handler)))
-		 ;; And reset the timer.
-		 (setcar (nthcdr 1 handler)
-			 (gnus-demon-time-to-step
-			  (nth 1 (assq (car handler) gnus-demon-handlers)))))))
-	 ;; These are only supposed to be called when Emacs is idle.
-	 ((null (setq idle (nth 2 handler)))
-	  ;; We do nothing.
-	  )
-	 ((and (not (numberp idle))
-	       (gnus-demon-is-idle-p))
-	  ;; We want to call this handler each and every time that
-	  ;; Emacs is idle.
-	  (gnus-with-local-quit
-	    (ignore-errors (funcall (car handler)))))
-	 (t
-	  ;; We want to call this handler only if Emacs has been idle
-	  ;; for a specified number of timesteps.
-	  (and (not (memq (car handler) gnus-demon-idle-has-been-called))
-	       (< idle gnus-demon-idle-time)
-	       (gnus-demon-is-idle-p)
-	       (gnus-with-local-quit
-		 (ignore-errors (funcall (car handler)))
-		 ;; Make sure the handler won't be called once more in
-		 ;; this idle-cycle.
-		 (push (car handler) gnus-demon-idle-has-been-called)))))))))
+  (dolist (timer gnus-demon-timers)
+    (nnheader-cancel-timer timer))
+  (setq gnus-demon-timers nil))
 
 (defun gnus-demon-add-disconnection ()
   "Add daemonic server disconnection to Gnus."
--- a/lisp/gnus/gnus-diary.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/gnus/gnus-diary.el	Thu Oct 28 19:57:59 2010 +0900
@@ -368,7 +368,7 @@
 				 header ": ")))
 	     (setq value
 		   (if (listp (nth 1 head))
-		       (gnus-completing-read prompt (cons '("*" nil) (nth 1 head))
+		       (gnus-completing-read prompt (cons "*" (mapcar 'car (nth 1 head)))
                                              t value
                                              'gnus-diary-header-value-history)
 		     (read-string prompt value
--- a/lisp/gnus/gnus-dired.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/gnus/gnus-dired.el	Thu Oct 28 19:57:59 2010 +0900
@@ -133,7 +133,9 @@
 	  (mapcar
 	   ;; don't attach directories
 	   (lambda (f) (if (file-directory-p f) nil f))
-	   (nreverse (dired-map-over-marks (dired-get-filename) nil))))))
+	   (nreverse
+	    (let ((arg nil)) ;; Silence XEmacs 21.5 when compiling.
+	      (dired-map-over-marks (dired-get-filename) arg)))))))
   (let ((destination nil)
 	(files-str nil)
 	(bufs nil))
--- a/lisp/gnus/gnus-draft.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/gnus/gnus-draft.el	Thu Oct 28 19:57:59 2010 +0900
@@ -310,6 +310,8 @@
 	  (while buffs
 	    (set-buffer (setq buff (pop buffs)))
 	    (if (and buffer-file-name
+		     (equal (file-remote-p file)
+			    (file-remote-p buffer-file-name))
 		     (string-equal (file-truename buffer-file-name)
 				   (file-truename file))
 		     (buffer-modified-p))
--- a/lisp/gnus/gnus-gravatar.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/gnus/gnus-gravatar.el	Thu Oct 28 19:57:59 2010 +0900
@@ -25,6 +25,7 @@
 ;;; Code:
 
 (require 'gravatar)
+(require 'gnus-art)
 
 (defgroup gnus-gravatar nil
   "Gnus Gravatar."
@@ -42,14 +43,13 @@
   :version "24.1"
   :group 'gnus-gravatar)
 
-(defcustom gnus-gravatar-too-ugly (if (boundp 'gnus-article-x-face-too-ugly)
-				      gnus-article-x-face-too-ugly)
+(defcustom gnus-gravatar-too-ugly gnus-article-x-face-too-ugly
   "Regexp matching posters whose avatar shouldn't be shown automatically."
   :type '(choice regexp (const nil))
   :version "24.1"
   :group 'gnus-gravatar)
 
-(defun gnus-gravatar-transform-address (header category)
+(defun gnus-gravatar-transform-address (header category &optional force)
   (gnus-with-article-headers
     (let ((addresses
            (mail-header-parse-addresses
@@ -59,79 +59,80 @@
              (ignore-errors
                (mail-encode-encoded-word-string
                 (or (mail-fetch-field header) "")))
-             (mail-fetch-field header)))))
-      (let ((gravatar-size gnus-gravatar-size))
-        (dolist (address addresses)
-	  (unless (and gnus-gravatar-too-ugly
-		       (or (string-match gnus-gravatar-too-ugly
-					 (car address))
-			   (and (cdr address)
-				(string-match gnus-gravatar-too-ugly
-					      (cdr address)))))
-	    (ignore-errors
-              (gravatar-retrieve
-               (car address)
-               'gnus-gravatar-insert
-               (list header address category)))))))))
+             (mail-fetch-field header))))
+	  (gravatar-size gnus-gravatar-size)
+	  name)
+      (dolist (address addresses)
+	(when (and (setq name (cdr address))
+		   (string-match "\\`\\*+ " name)) ;; (X-)Faces exist.
+	  (setcdr address (setq name (substring name (match-end 0)))))
+	(when (or force
+		  (not (and gnus-gravatar-too-ugly
+			    (or (string-match gnus-gravatar-too-ugly
+					      (car address))
+				(and name
+				     (string-match gnus-gravatar-too-ugly
+						   name))))))
+	  (ignore-errors
+	    (gravatar-retrieve
+	     (car address)
+	     'gnus-gravatar-insert
+	     (list header address category))))))))
 
 (defun gnus-gravatar-insert (gravatar header address category)
   "Insert GRAVATAR for ADDRESS in HEADER in current article buffer.
 Set image category to CATEGORY."
   (unless (eq gravatar 'error)
     (gnus-with-article-headers
-      (gnus-article-goto-header header)
-      (mail-header-narrow-to-field)
-      (let ((real-name (cdr address))
-            (mail-address (car address)))
-        (when (if real-name             ; have a realname, go for it!
-                  (and (search-forward real-name nil t)
-                       (search-backward real-name nil t))
-                (and (search-forward mail-address nil t)
-                     (search-backward mail-address nil t)))
-          (goto-char (1- (point)))
-          ;; If we're on the " quoting the name, go backward
-          (when (looking-at "[\"<]")
-            (goto-char (1- (point))))
-          ;; Do not do anything if there's already a gravatar. This can
-          ;; happens if the buffer has been regenerated in the mean time, for
-          ;; example we were fetching someaddress, and then we change to
-          ;; another mail with the same someaddress.
-          (unless (memq 'gnus-gravatar (text-properties-at (point)))
-            (let ((inhibit-read-only t)
-                  (point (point)))
-	      (unless (featurep 'xemacs)
-		(setq gravatar (append gravatar gnus-gravatar-properties)))
-              (gnus-put-image gravatar nil category)
-              (put-text-property point (point) 'gnus-gravatar address)
-              (gnus-add-wash-type category)
-              (gnus-add-image category gravatar))))))))
+      ;; The buffer can be gone at this time
+      (when (buffer-live-p (current-buffer))
+        (gnus-article-goto-header header)
+        (mail-header-narrow-to-field)
+        (let ((real-name (cdr address))
+              (mail-address (car address)))
+          (when (if real-name             ; have a realname, go for it!
+                    (and (search-forward real-name nil t)
+                         (search-backward real-name nil t))
+                  (and (search-forward mail-address nil t)
+                       (search-backward mail-address nil t)))
+            (goto-char (1- (point)))
+            ;; If we're on the " quoting the name, go backward
+            (when (looking-at "[\"<]")
+              (goto-char (1- (point))))
+            ;; Do not do anything if there's already a gravatar. This can
+            ;; happens if the buffer has been regenerated in the mean time, for
+            ;; example we were fetching someaddress, and then we change to
+            ;; another mail with the same someaddress.
+            (unless (memq 'gnus-gravatar (text-properties-at (point)))
+              (let ((inhibit-read-only t)
+                    (point (point)))
+                (unless (featurep 'xemacs)
+                  (setq gravatar (append gravatar gnus-gravatar-properties)))
+                (gnus-put-image gravatar nil category)
+                (put-text-property point (point) 'gnus-gravatar address)
+                (gnus-add-wash-type category)
+                (gnus-add-image category gravatar)))))))))
 
 ;;;###autoload
-(defun gnus-treat-from-gravatar ()
+(defun gnus-treat-from-gravatar (&optional force)
   "Display gravatar in the From header.
 If gravatar is already displayed, remove it."
-  (interactive)
+  (interactive (list t)) ;; When type `W D g'
   (gnus-with-article-buffer
     (if (memq 'from-gravatar gnus-article-wash-types)
-        (gnus-delete-images 'from-gravatar)
-      (let ((gnus-gravatar-too-ugly
-	     (unless buffer-read-only ;; When type `W D g'
-	       gnus-gravatar-too-ugly)))
-	(gnus-gravatar-transform-address "from" 'from-gravatar)))))
+	(gnus-delete-images 'from-gravatar)
+      (gnus-gravatar-transform-address "from" 'from-gravatar force))))
 
 ;;;###autoload
-(defun gnus-treat-mail-gravatar ()
+(defun gnus-treat-mail-gravatar (&optional force)
   "Display gravatars in the Cc and To headers.
 If gravatars are already displayed, remove them."
-  (interactive)
+  (interactive (list t)) ;; When type `W D h'
     (gnus-with-article-buffer
       (if (memq 'mail-gravatar gnus-article-wash-types)
           (gnus-delete-images 'mail-gravatar)
-	(let ((gnus-gravatar-too-ugly
-	       (unless buffer-read-only ;; When type `W D h'
-		 gnus-gravatar-too-ugly)))
-	  (gnus-gravatar-transform-address "cc" 'mail-gravatar)
-	  (gnus-gravatar-transform-address "to" 'mail-gravatar)))))
+	(gnus-gravatar-transform-address "cc" 'mail-gravatar force)
+	(gnus-gravatar-transform-address "to" 'mail-gravatar force))))
 
 (provide 'gnus-gravatar)
 
--- a/lisp/gnus/gnus-group.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/gnus/gnus-group.el	Thu Oct 28 19:57:59 2010 +0900
@@ -55,6 +55,8 @@
 (autoload 'gnus-agent-total-fetched-for "gnus-agent")
 (autoload 'gnus-cache-total-fetched-for "gnus-cache")
 
+(autoload 'gnus-group-make-nnir-group "nnir")
+
 (defcustom gnus-no-groups-message "No Gnus is good news"
   "*Message displayed by Gnus when no groups are available."
   :group 'gnus-start
@@ -117,10 +119,11 @@
   :type 'boolean)
 
 (defcustom gnus-group-default-list-level gnus-level-subscribed
-  "*Default listing level.
+  "Default listing level.
 Ignored if `gnus-group-use-permanent-levels' is non-nil."
   :group 'gnus-group-listing
-  :type 'integer)
+  :type '(choice (integer :tag "Level")
+                 (function :tag "Function returning level")))
 
 (defcustom gnus-group-list-inactive-groups t
   "*If non-nil, inactive groups will be listed."
@@ -653,6 +656,7 @@
   "D" gnus-group-enter-directory
   "f" gnus-group-make-doc-group
   "w" gnus-group-make-web-group
+  "G" gnus-group-make-nnir-group
   "M" gnus-group-read-ephemeral-group
   "r" gnus-group-rename-group
   "R" gnus-group-make-rss-group
@@ -757,7 +761,6 @@
        (symbol-value 'gnus-topic-mode)))
 
 (defun gnus-group-make-menu-bar ()
-  (gnus-turn-off-edit-menu 'group)
   (unless (boundp 'gnus-group-reading-menu)
 
     (easy-menu-define
@@ -905,6 +908,7 @@
 	["Add the help group" gnus-group-make-help-group t]
 	["Make a doc group..." gnus-group-make-doc-group t]
 	["Make a web group..." gnus-group-make-web-group t]
+	["Make a search group..." gnus-group-make-nnir-group t]
 	["Make a virtual group..." gnus-group-make-empty-virtual t]
 	["Add a group to a virtual..." gnus-group-add-to-virtual t]
 	["Make an ephemeral group..." gnus-group-read-ephemeral-group t]
@@ -1166,6 +1170,12 @@
   (mouse-set-point e)
   (gnus-group-read-group nil))
 
+(defun gnus-group-default-list-level ()
+  "Return the real value for `gnus-group-default-list-level'."
+  (if (functionp gnus-group-default-list-level)
+      (funcall gnus-group-default-list-level)
+    gnus-group-default-list-level))
+
 ;; Look at LEVEL and find out what the level is really supposed to be.
 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
@@ -1175,13 +1185,13 @@
     (or (setq gnus-group-use-permanent-levels
 	      (or level (if (numberp gnus-group-use-permanent-levels)
 			    gnus-group-use-permanent-levels
-			  (or gnus-group-default-list-level
+			  (or (gnus-group-default-list-level)
 			      gnus-level-subscribed))))
-	gnus-group-default-list-level gnus-level-subscribed))
+	(gnus-group-default-list-level) gnus-level-subscribed))
    (number-or-nil
     level)
    (t
-    (or level gnus-group-default-list-level gnus-level-subscribed))))
+    (or level (gnus-group-default-list-level) gnus-level-subscribed))))
 
 (defun gnus-group-setup-buffer ()
   (set-buffer (gnus-get-buffer-create gnus-group-buffer))
@@ -1227,7 +1237,7 @@
 	     (prefix-numeric-value current-prefix-arg)
 	   (or
 	    (gnus-group-default-level nil t)
-	    gnus-group-default-list-level
+	    (gnus-group-default-list-level)
 	    gnus-level-subscribed))))
   (unless level
     (setq level (car gnus-group-list-mode)
@@ -1548,7 +1558,7 @@
 	      ?m ? ))
 	 (gnus-tmp-moderated-string
 	  (if (eq gnus-tmp-moderated ?m) "(m)" ""))
-         (gnus-tmp-group-icon (gnus-group-get-icon gnus-tmp-qualified-group))
+         (gnus-tmp-group-icon (gnus-group-get-icon gnus-tmp-group))
 	 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
 	 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
 	 (gnus-tmp-news-method-string
@@ -1888,7 +1898,7 @@
       (unless no-advance
 	(gnus-group-next-group 1))
       (decf n))
-    (gnus-summary-position-point)
+    (gnus-group-position-point)
     n))
 
 (defun gnus-group-unmark-group (n)
@@ -2190,11 +2200,13 @@
 				      require-match initial-input
 				      (or hist 'gnus-group-history)
 				      def))
-    (if (if (listp collection)
-	    (member group (mapcar 'symbol-name collection))
-	  (symbol-value (intern-soft group collection)))
-	group
-      (mm-encode-coding-string group (gnus-group-name-charset nil group)))))
+    (unless (if (listp collection)
+		(member group (mapcar 'symbol-name collection))
+	      (symbol-value (intern-soft group collection)))
+      (setq group
+	    (mm-encode-coding-string
+	     group (gnus-group-name-charset nil group))))
+    (gnus-replace-in-string group "\n" "")))
 
 ;;;###autoload
 (defun gnus-fetch-group (group &optional articles)
@@ -2424,9 +2436,9 @@
       (while (re-search-forward "^To: " nil t)
 	(end-of-line)
 	(insert (format ", %s@%s" number
-			(replace-regexp-in-string
-			 "/.*$" ""
-			 (replace-regexp-in-string "^http://" "" mbox-url)))))
+			(gnus-replace-in-string
+			 (gnus-replace-in-string mbox-url "^http://" "")
+			 "/.*$" ""))))
       (write-region (point-min) (point-max) tmpfile)
       (gnus-group-read-ephemeral-group
        "gnus-read-ephemeral-bug"
@@ -3677,7 +3689,7 @@
 Killed newsgroups are subscribed.  If SILENT, don't try to update the
 group line."
   (interactive (list (gnus-group-completing-read
-		      nil (gnus-read-active-file-p))))
+		      nil nil (gnus-read-active-file-p))))
   (let ((newsrc (gnus-group-entry group)))
     (cond
      ((string-match "^[ \t]*$" group)
@@ -4010,7 +4022,7 @@
       (goto-char beg))
     (when gnus-goto-next-group-when-activating
       (gnus-group-next-unread-group 1 t))
-    (gnus-summary-position-point)
+    (gnus-group-position-point)
     ret))
 
 (defun gnus-group-fetch-control (group)
--- a/lisp/gnus/gnus-html.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/gnus/gnus-html.el	Thu Oct 28 19:57:59 2010 +0900
@@ -205,8 +205,8 @@
                  url
                  (if (buffer-live-p gnus-summary-buffer)
                      (with-current-buffer gnus-summary-buffer
-                       gnus-blocked-images)
-                   gnus-blocked-images))
+                       (gnus-blocked-images))
+                   (gnus-blocked-images)))
                 (progn
                   (widget-convert-button
                    'link start end
@@ -491,10 +491,11 @@
 (defun gnus-html-prefetch-images (summary)
   (when (buffer-live-p summary)
     (let ((blocked-images (with-current-buffer summary
-                            gnus-blocked-images)))
+                            (gnus-blocked-images))))
       (save-match-data
-	(while (re-search-forward "<img[^>]+src=[\"']\\([^\"']+\\)" nil t)
-	  (let ((url (gnus-html-encode-url (match-string 1))))
+	(while (re-search-forward "<img[^>]+src=[\"']\\(http[^\"']+\\)" nil t)
+	  (let ((url (gnus-html-encode-url
+		      (mm-url-decode-entities-string (match-string 1)))))
 	    (unless (gnus-html-image-url-blocked-p url blocked-images)
               (when (gnus-html-cache-expired url gnus-html-image-cache-ttl)
                 (gnus-html-schedule-image-fetching nil
--- a/lisp/gnus/gnus-int.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/gnus/gnus-int.el	Thu Oct 28 19:57:59 2010 +0900
@@ -504,6 +504,12 @@
 	     article (gnus-group-real-name group)
 	     (nth 1 gnus-command-method) buffer)))
 
+(defun gnus-request-thread (id)
+  "Request the thread containing the article specified by Message-ID id."
+  (let ((gnus-command-method (gnus-find-method-for-group gnus-newsgroup-name)))
+    (funcall (gnus-get-function gnus-command-method 'request-thread)
+	     id)))
+
 (defun gnus-request-head (article group)
   "Request the head of ARTICLE in GROUP."
   (let* ((gnus-command-method (gnus-find-method-for-group group))
@@ -649,7 +655,8 @@
 	 (result (funcall (gnus-get-function gnus-command-method
 					     'request-move-article)
 			  article (gnus-group-real-name group)
-			  (nth 1 gnus-command-method) accept-function last move-is-internal)))
+			  (nth 1 gnus-command-method) accept-function
+			  last move-is-internal)))
     (when (and result gnus-agent
 	       (gnus-agent-method-p gnus-command-method))
       (gnus-agent-unfetch-articles group (list article)))
--- a/lisp/gnus/gnus-kill.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/gnus/gnus-kill.el	Thu Oct 28 19:57:59 2010 +0900
@@ -480,7 +480,7 @@
 	 (or (cdr (assq modifier mod-to-header)) "subject")
 	 pattern
 	 (if (string-match "m" commands)
-	     '(gnus-summary-mark-as-unread nil " ")
+	     '(gnus-summary-tick-article nil " ")
 	   '(gnus-summary-mark-as-read nil "X"))
 	 nil t))
       (forward-line 1))))
--- a/lisp/gnus/gnus-registry.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/gnus/gnus-registry.el	Thu Oct 28 19:57:59 2010 +0900
@@ -551,8 +551,9 @@
 			    key
 			    gnus-registry-max-track-groups)))
 	       (dolist (group groups)
-		 (push group found-full)
-		 (setq found (append (list group) (delete group found)))))
+		 (when (and group (gnus-registry-follow-group-p group))
+		   (push group found-full)
+		   (setq found (append (list group) (delete group found))))))
 	     (push key matches)
 	     (gnus-message
 	      ;; raise level of messaging if gnus-registry-track-extra
@@ -580,8 +581,9 @@
 			    key
 			    gnus-registry-max-track-groups)))
 	       (dolist (group groups)
-		 (push group found-full)
-		 (setq found (append (list group) (delete group found)))))
+		 (when (and group (gnus-registry-follow-group-p group))
+		   (push group found-full)
+		   (setq found (append (list group) (delete group found))))))
 	     (push key matches)
 	     (gnus-message
 	      ;; raise level of messaging if gnus-registry-track-extra
--- a/lisp/gnus/gnus-spec.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/gnus/gnus-spec.el	Thu Oct 28 19:57:59 2010 +0900
@@ -680,7 +680,7 @@
       ((string= fstring "%d")
        (setq dontinsert t)
        (if insert
-	   (list `(princ ,(car flist)))
+	   `(insert (int-to-string ,(car flist)))
 	 (list `(int-to-string ,(car flist)))))
       ;; Just lots of chars and strings.
       ((string-match "\\`\\(%[cs]\\)+\\'" fstring)
--- a/lisp/gnus/gnus-start.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/gnus/gnus-start.el	Thu Oct 28 19:57:59 2010 +0900
@@ -2090,7 +2090,7 @@
 	  (gnus-message 5 "%s" mesg)
 	  (gnus-active-to-gnus-format method gnus-active-hashtb nil t)
 	  ;; We mark this active file as read.
-	  (push method gnus-have-read-active-file)
+	  (add-to-list 'gnus-have-read-active-file method)
 	  (gnus-message 5 "%sdone" mesg)))))))
 
 (defun gnus-read-active-file-2 (groups method)
--- a/lisp/gnus/gnus-sum.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/gnus/gnus-sum.el	Thu Oct 28 19:57:59 2010 +0900
@@ -6190,7 +6190,13 @@
 	 (info (nth 2 entry))
 	 (active (gnus-active group))
 	 range)
-    (when entry
+    (if (not entry)
+	;; Group that Gnus doesn't know exists, but still allow the
+	;; backend to set marks.
+	(gnus-request-set-mark
+	 group (list (list (gnus-compress-sequence (sort articles #'<))
+			   'add '(read))))
+      ;; Normal, subscribed groups.
       (setq range (gnus-compute-read-articles group articles))
       (with-current-buffer gnus-group-buffer
 	(gnus-undo-register
@@ -6942,7 +6948,9 @@
 ;; Various summary commands
 
 (defun gnus-summary-select-article-buffer ()
-  "Reconfigure windows to show the article buffer."
+  "Reconfigure windows to show the article buffer.
+If `gnus-widen-article-buffer' is set, show only the article
+buffer."
   (interactive)
   (if (not (gnus-buffer-live-p gnus-article-buffer))
       (error "There is no article buffer for this summary buffer")
@@ -7584,7 +7592,8 @@
 		       (null (get-buffer gnus-article-buffer))
 		       (not (eq article (cdr gnus-article-current)))
 		       (not (equal (car gnus-article-current)
-				   gnus-newsgroup-name))))
+				   gnus-newsgroup-name))
+		       (not (get-buffer gnus-original-article-buffer))))
 	      (and (not gnus-single-article-buffer)
 		   (or (null gnus-current-article)
 		       (not (eq gnus-current-article article))))
@@ -8824,31 +8833,40 @@
 
 (defun gnus-summary-refer-thread (&optional limit)
   "Fetch all articles in the current thread.
-If LIMIT (the numerical prefix), fetch that many old headers instead
-of what's specified by the `gnus-refer-thread-limit' variable."
+If no backend-specific 'request-thread function is available
+fetch LIMIT (the numerical prefix) old headers. If LIMIT is nil
+fetch what's specified by the `gnus-refer-thread-limit'
+variable."
   (interactive "P")
   (let ((id (mail-header-id (gnus-summary-article-header)))
+	(gnus-summary-ignore-duplicates t)
 	(limit (if limit (prefix-numeric-value limit)
 		 gnus-refer-thread-limit)))
-    (unless (eq gnus-fetch-old-headers 'invisible)
-      (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
-      ;; Retrieve the headers and read them in.
-      (if (eq (if (numberp limit)
-		  (gnus-retrieve-headers
-		   (list (min
-			  (+ (mail-header-number
-			      (gnus-summary-article-header))
-			     limit)
-			  gnus-newsgroup-end))
-		   gnus-newsgroup-name (* limit 2))
-		;; gnus-refer-thread-limit is t, i.e. fetch _all_
-		;; headers.
-		(gnus-retrieve-headers (list gnus-newsgroup-end)
-				       gnus-newsgroup-name limit))
-	      'nov)
-	  (gnus-build-all-threads)
-	(error "Can't fetch thread from back ends that don't support NOV"))
-      (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
+    (if  (gnus-check-backend-function 'request-thread gnus-newsgroup-name)
+	(setq gnus-newsgroup-headers
+	      (gnus-merge 'list
+			  gnus-newsgroup-headers
+			  (gnus-request-thread id)
+			  'gnus-article-sort-by-number))
+      (unless (eq gnus-fetch-old-headers 'invisible)
+	(gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
+	;;	Retrieve the headers and read them in.
+	(if (numberp limit)
+	    (gnus-retrieve-headers
+	     (list (min
+		    (+ (mail-header-number
+			(gnus-summary-article-header))
+		       limit)
+		    gnus-newsgroup-end))
+	     gnus-newsgroup-name (* limit 2))
+	  ;; gnus-refer-thread-limit is t, i.e. fetch _all_
+	  ;; headers.
+	  (gnus-retrieve-headers (list gnus-newsgroup-end)
+				 gnus-newsgroup-name limit)
+	  (gnus-message 5 "Fetching headers for %s...done"
+			gnus-newsgroup-name))))
+    (when (eq gnus-headers-retrieved-by 'nov)
+      (gnus-build-all-threads))
     (gnus-summary-limit-include-thread id)))
 
 (defun gnus-summary-refer-article (message-id)
@@ -10248,7 +10266,7 @@
   "Make edits to the current article permanent."
   (interactive)
   (save-excursion
-   ;; The buffer restriction contains the entire article if it exists.
+    ;; The buffer restriction contains the entire article if it exists.
     (when (article-goto-body)
       (let ((lines (count-lines (point) (point-max)))
 	    (length (- (point-max) (point)))
@@ -10268,15 +10286,25 @@
 	  (delete-region (match-beginning 1) (match-end 1))
 	  (insert (number-to-string lines))))))
   ;; Replace the article.
-  (let ((buf (current-buffer)))
+  (let ((buf (current-buffer))
+	(article (cdr gnus-article-current))
+	replace-result)
     (with-temp-buffer
       (insert-buffer-substring buf)
-
       (if (and (not read-only)
-	       (not (gnus-request-replace-article
-		     (cdr gnus-article-current) (car gnus-article-current)
-		     (current-buffer) t)))
+	       (not (setq replace-result
+			  (gnus-request-replace-article
+			   article (car gnus-article-current)
+			   (current-buffer) t))))
 	  (error "Couldn't replace article")
+	;; If we got a number back, then that's the new article number
+	;; for this article.  Otherwise, the article number didn't change.
+	(when (numberp replace-result)
+	  (with-current-buffer gnus-summary-buffer
+	    (setq gnus-newsgroup-limit (delq article gnus-newsgroup-limit))
+	    (gnus-summary-limit gnus-newsgroup-limit)
+	    (setq article replace-result)
+	    (gnus-summary-goto-subject article t)))
 	;; Update the summary buffer.
 	(if (and references
 		 (equal (message-tokenize-header references " ")
@@ -10290,38 +10318,29 @@
 			     (point-min) (point-max)))
 		      header)
 		  (with-temp-buffer
-		    (insert (format "211 %d Article retrieved.\n"
-				    (cdr gnus-article-current)))
+		    (insert (format "211 %d Article retrieved.\n" article))
 		    (insert head)
 		    (insert ".\n")
 		    (let ((nntp-server-buffer (current-buffer)))
-		      (setq header (car (gnus-get-newsgroup-headers
-					 nil t))))
+		      (setq header (car (gnus-get-newsgroup-headers nil t))))
 		    (with-current-buffer gnus-summary-buffer
-		      (gnus-data-set-header
-		       (gnus-data-find (cdr gnus-article-current))
-		       header)
-		      (gnus-summary-update-article-line
-		       (cdr gnus-article-current) header)
-		      (if (gnus-summary-goto-subject
-			   (cdr gnus-article-current) nil t)
-			  (gnus-summary-update-secondary-mark
-			   (cdr gnus-article-current))))))))
+		      (gnus-data-set-header (gnus-data-find article) header)
+		      (gnus-summary-update-article-line article header)
+		      (if (gnus-summary-goto-subject article nil t)
+			  (gnus-summary-update-secondary-mark article)))))))
 	  ;; Update threads.
 	  (set-buffer (or buffer gnus-summary-buffer))
-	  (gnus-summary-update-article (cdr gnus-article-current))
-	  (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
-	      (gnus-summary-update-secondary-mark
-	       (cdr gnus-article-current))))
+	  (gnus-summary-update-article article)
+	  (if (gnus-summary-goto-subject article nil t)
+	      (gnus-summary-update-secondary-mark article)))
 	;; Prettify the article buffer again.
 	(unless no-highlight
 	  (with-current-buffer gnus-article-buffer
-	    ;;;!!! Fix this -- article should be rehighlighted.
-	    ;;;(gnus-run-hooks 'gnus-article-display-hook)
+	    ;;!!! Fix this -- article should be rehighlighted.
+	    ;;(gnus-run-hooks 'gnus-article-display-hook)
 	    (set-buffer gnus-original-article-buffer)
 	    (gnus-request-article
-	     (cdr gnus-article-current)
-	     (car gnus-article-current) (current-buffer))))
+	     article (car gnus-article-current) (current-buffer))))
 	;; Prettify the summary buffer line.
 	(when (gnus-visual-p 'summary-highlight 'highlight)
 	  (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
@@ -10853,10 +10872,6 @@
       (gnus-alist-pull article gnus-newsgroup-reads)
       t)))
 
-(defalias 'gnus-summary-mark-as-unread-forward
-  'gnus-summary-tick-article-forward)
-(make-obsolete 'gnus-summary-mark-as-unread-forward
-	       'gnus-summary-tick-article-forward "Emacs 20.4")
 (defun gnus-summary-tick-article-forward (n)
   "Tick N articles forwards.
 If N is negative, tick backwards instead.
@@ -10864,18 +10879,12 @@
   (interactive "p")
   (gnus-summary-mark-forward n gnus-ticked-mark))
 
-(defalias 'gnus-summary-mark-as-unread-backward
-  'gnus-summary-tick-article-backward)
-(make-obsolete 'gnus-summary-mark-as-unread-backward
-	       'gnus-summary-tick-article-backward "Emacs 20.4")
 (defun gnus-summary-tick-article-backward (n)
   "Tick N articles backwards.
 The difference between N and the number of articles ticked is returned."
   (interactive "p")
   (gnus-summary-mark-forward (- n) gnus-ticked-mark))
 
-(defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
-(make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article "Emacs 20.4")
 (defun gnus-summary-tick-article (&optional article clear-mark)
   "Mark current article as unread.
 Optional 1st argument ARTICLE specifies article number to be marked as unread.
--- a/lisp/gnus/gnus-util.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/gnus/gnus-util.el	Thu Oct 28 19:57:59 2010 +0900
@@ -1930,25 +1930,6 @@
   (defalias 'gnus-set-process-query-on-exit-flag
     'process-kill-without-query))
 
-(if (fboundp 'with-local-quit)
-    (defalias 'gnus-with-local-quit 'with-local-quit)
-  (defmacro gnus-with-local-quit (&rest body)
-    "Execute BODY, allowing quits to terminate BODY but not escape further.
-When a quit terminates BODY, `gnus-with-local-quit' returns nil but
-requests another quit.  That quit will be processed as soon as quitting
-is allowed once again.  (Immediately, if `inhibit-quit' is nil.)"
-    ;;(declare (debug t) (indent 0))
-    `(condition-case nil
-	 (let ((inhibit-quit nil))
-	   ,@body)
-       (quit (setq quit-flag t)
-	     ;; This call is to give a chance to handle quit-flag
-	     ;; in case inhibit-quit is nil.
-	     ;; Without this, it will not be handled until the next function
-	     ;; call, and that might allow it to exit thru a condition-case
-	     ;; that intends to handle the quit signal next time.
-	     (eval '(ignore nil))))))
-
 (defalias 'gnus-read-shell-command
   (if (fboundp 'read-shell-command) 'read-shell-command 'read-string))
 
--- a/lisp/gnus/gnus.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/gnus/gnus.el	Thu Oct 28 19:57:59 2010 +0900
@@ -1356,12 +1356,12 @@
 value of `gnus-message-archive-method' afterward.  If you want the
 saved \"archive\" method to be updated whenever you change the value of
 `gnus-message-archive-method', set this variable to a non-nil value."
-  :version "23.1" ;; No Gnus
+  :version "23.1"
   :group 'gnus-server
   :group 'gnus-message
   :type 'boolean)
 
-(defcustom gnus-message-archive-group nil
+(defcustom gnus-message-archive-group '((format-time-string "sent.%Y-%m"))
   "*Name of the group in which to save the messages you've written.
 This can either be a string; a list of strings; or an alist
 of regexps/functions/forms to be evaluated to return a string (or a list
@@ -1381,8 +1381,12 @@
 However, you may wish to store the message on some other server.  In
 that case, just return a fully prefixed name of the group --
 \"nnml+private:mail.misc\", for instance."
+  :version "24.1"
   :group 'gnus-message
   :type '(choice (const :tag "none" nil)
+		 (const :tag "Weekly" ((format-time-string "sent.%Yw%U")))
+		 (const :tag "Monthly" ((format-time-string "sent.%Y-%m")))
+		 (const :tag "Yearly" ((format-time-string "sent.%Y")))
 		 function
 		 sexp
 		 string))
@@ -2911,6 +2915,7 @@
       gnus-start-date-timer gnus-stop-date-timer
       gnus-mime-view-all-parts)
      ("gnus-int" gnus-request-type)
+     ("gnus-html" gnus-html-show-images)
      ("gnus-start" gnus-newsrc-parse-options gnus-1 gnus-no-server-1
       gnus-dribble-enter gnus-read-init-file gnus-dribble-touch
       gnus-check-reasonable-setup)
@@ -3937,7 +3942,9 @@
 		    (not (eq (caar old-params) name)))
 	    (setq new-params (append new-params (list (car old-params)))))
 	  (setq old-params (cdr old-params)))
-	(gnus-group-set-info new-params (gnus-info-group info) 'params)))))
+	(if (listp group)
+	    (gnus-info-set-params info new-params t)
+	  (gnus-group-set-info new-params (gnus-info-group info) 'params))))))
 
 (defun gnus-group-remove-parameter (group name)
   "Remove parameter NAME from GROUP.
--- a/lisp/gnus/message.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/gnus/message.el	Thu Oct 28 19:57:59 2010 +0900
@@ -1139,13 +1139,17 @@
   :error "All header lines must be newline terminated")
 
 (defcustom message-default-headers ""
-  "*A string containing header lines to be inserted in outgoing messages.
-It is inserted before you edit the message, so you can edit or delete
-these lines."
+  "Header lines to be inserted in outgoing messages.
+This can be set to a string containing or a function returning
+header lines to be inserted before you edit the message, so you
+can edit or delete these lines.  If set to a function, it is
+called and its result is inserted."
   :version "23.2"
   :group 'message-headers
   :link '(custom-manual "(message)Message Headers")
-  :type 'message-header-lines)
+  :type '(choice
+          (message-header-lines :tag "String")
+          (function :tag "Function")))
 
 (defcustom message-default-mail-headers
   ;; Ease the transition from mail-mode to message-mode.  See bugs#4431, 5555.
@@ -2639,7 +2643,6 @@
 
   (define-key message-mode-map "\C-a" 'message-beginning-of-line)
   (define-key message-mode-map "\t" 'message-tab)
-  (define-key message-mode-map "\M-;" 'comment-region)
 
   (define-key message-mode-map "\M-n" 'message-display-abbrev))
 
@@ -4206,7 +4209,7 @@
 		 (?r ,(format
 		       "Replace non-printable characters with \"%s\" and send"
 		       message-replacement-char))
-		 (?i "Ignore non-printable characters and send")
+		 (?s "Send as is without removing anything")
 		 (?e "Continue editing"))))
 	(if (eq choice ?e)
 	  (error "Non-printable characters"))
@@ -6363,7 +6366,10 @@
    headers)
   (delete-region (point) (progn (forward-line -1) (point)))
   (when message-default-headers
-    (insert message-default-headers)
+    (insert
+     (if (functionp message-default-headers)
+         (funcall message-default-headers)
+       message-default-headers))
     (or (bolp) (insert ?\n)))
   (insert mail-header-separator "\n")
   (forward-line -1)
@@ -6568,6 +6574,10 @@
     (save-match-data
       ;; Build (textual) list of new recipient addresses.
       (cond
+       (to-address
+	(setq recipients (concat ", " to-address))
+	;; If the author explicitly asked for a copy, we don't deny it to them.
+	(if mct (setq recipients (concat recipients ", " mct))))
        ((not wide)
 	(setq recipients (concat ", " author)))
        (address-headers
@@ -6603,10 +6613,6 @@
 You may customize the variable `message-use-mail-followup-to', if you
 want to get rid of this query permanently.")))
 	(setq recipients (concat ", " mft)))
-       (to-address
-	(setq recipients (concat ", " to-address))
-	;; If the author explicitly asked for a copy, we don't deny it to them.
-	(if mct (setq recipients (concat recipients ", " mct))))
        (t
 	(setq recipients (if never-mct "" (concat ", " author)))
 	(if to (setq recipients (concat recipients ", " to)))
--- a/lisp/gnus/mm-decode.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/gnus/mm-decode.el	Thu Oct 28 19:57:59 2010 +0900
@@ -105,8 +105,8 @@
 	 ,disposition ,description ,cache ,id))
 
 (defcustom mm-text-html-renderer
-  (cond ((fboundp 'libxml-parse-html-region) 'mm-shr)
-	((executable-find "w3m") 'gnus-article-html)
+  (cond ((fboundp 'libxml-parse-html-region) 'shr)
+	((executable-find "w3m") 'gnus-w3m)
 	((executable-find "links") 'links)
 	((executable-find "lynx") 'lynx)
 	((locate-library "w3") 'w3)
@@ -115,8 +115,8 @@
   "Render of HTML contents.
 It is one of defined renderer types, or a rendering function.
 The defined renderer types are:
-`mm-shr': use Gnus simple HTML renderer;
-`gnus-article-html' : use Gnus renderer based on w3m;
+`shr': use Gnus simple HTML renderer;
+`gnus-w3m' : use Gnus renderer based on w3m;
 `w3m'  : use emacs-w3m;
 `w3m-standalone': use w3m;
 `links': use links;
@@ -125,8 +125,8 @@
 `html2text' : use html2text;
 nil    : use external viewer (default web browser)."
   :version "24.1"
-  :type '(choice (const mm-shr)
-                 (const gnus-article-html)
+  :type '(choice (const shr)
+                 (const gnus-w3m)
                  (const w3)
                  (const w3m :tag "emacs-w3m")
 		 (const w3m-standalone :tag "standalone w3m" )
@@ -137,10 +137,6 @@
 		 (function))
   :group 'mime-display)
 
-(defvar mm-inline-text-html-renderer nil
-  "Function used for rendering inline HTML contents.
-It is suggested to customize `mm-text-html-renderer' instead.")
-
 (defcustom mm-inline-text-html-with-images nil
   "If non-nil, Gnus will allow retrieving images in HTML contents with
 the <img> tags.  It has no effect on Emacs/w3.  See also the
@@ -245,8 +241,7 @@
     ("text/html"
      mm-inline-text-html
      (lambda (handle)
-       (or mm-inline-text-html-renderer
-	   mm-text-html-renderer)))
+       mm-text-html-renderer))
     ("text/x-vcard"
      mm-inline-text-vcard
      (lambda (handle)
@@ -701,13 +696,14 @@
 (autoload 'mailcap-parse-mailcaps "mailcap")
 (autoload 'mailcap-mime-info "mailcap")
 
-(defun mm-display-part (handle &optional no-default)
+(defun mm-display-part (handle &optional no-default force)
   "Display the MIME part represented by HANDLE.
 Returns nil if the part is removed; inline if displayed inline;
 external if displayed external."
   (save-excursion
     (mailcap-parse-mailcaps)
-    (if (mm-handle-displayed-p handle)
+    (if (and (not force)
+	     (mm-handle-displayed-p handle))
 	(mm-remove-part handle)
       (let* ((ehandle (if (equal (mm-handle-media-type handle)
 				 "message/external-body")
@@ -1686,13 +1682,17 @@
 (declare-function libxml-parse-html-region "xml.c"
 		  (start end &optional base-url))
 (declare-function shr-insert-document "shr" (dom))
+(defvar shr-blocked-images)
 
 (defun mm-shr (handle)
   ;; Require since we bind its variables.
   (require 'shr)
   (let ((article-buffer (current-buffer))
-	(shr-blocked-images (with-current-buffer gnus-summary-buffer
-			      gnus-blocked-images))
+	(shr-blocked-images (if (and (boundp 'gnus-summary-buffer)
+				     (buffer-name gnus-summary-buffer))
+				(with-current-buffer gnus-summary-buffer
+				  (gnus-blocked-images))
+			      shr-blocked-images))
 	(shr-content-function (lambda (id)
 				(let ((handle (mm-get-content-id id)))
 				  (when handle
@@ -1713,7 +1713,13 @@
 		       (mm-decode-coding-string (buffer-string) charset)
 		     (erase-buffer)
 		     (mm-enable-multibyte))))
-	 (libxml-parse-html-region (point-min) (point-max)))))))
+	 (libxml-parse-html-region (point-min) (point-max))))
+      (mm-handle-set-undisplayer
+       handle
+       `(lambda ()
+	  (let ((inhibit-read-only t))
+	    (delete-region ,(point-min-marker)
+			   ,(point-max-marker))))))))
 
 (provide 'mm-decode)
 
--- a/lisp/gnus/mm-view.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/gnus/mm-view.el	Thu Oct 28 19:57:59 2010 +0900
@@ -50,29 +50,19 @@
 (defvar w3m-minor-mode-map)
 
 (defvar mm-text-html-renderer-alist
-  '((w3  . mm-inline-text-html-render-with-w3)
+  '((shr . mm-shr)
+    (w3 . mm-inline-text-html-render-with-w3)
     (w3m . mm-inline-text-html-render-with-w3m)
     (w3m-standalone . mm-inline-text-html-render-with-w3m-standalone)
+    (gnus-w3m . gnus-article-html)
     (links mm-inline-render-with-file
 	   mm-links-remove-leading-blank
 	   "links" "-dump" file)
-    (lynx  mm-inline-render-with-stdin nil
-	   "lynx" "-dump" "-force_html" "-stdin" "-nolist")
-    (html2text  mm-inline-render-with-function html2text))
+    (lynx mm-inline-render-with-stdin nil
+	  "lynx" "-dump" "-force_html" "-stdin" "-nolist")
+    (html2text mm-inline-render-with-function html2text))
   "The attributes of renderer types for text/html.")
 
-(defvar mm-text-html-washer-alist
-  '((w3  . gnus-article-wash-html-with-w3)
-    (w3m . gnus-article-wash-html-with-w3m)
-    (w3m-standalone . gnus-article-wash-html-with-w3m-standalone)
-    (links mm-inline-wash-with-file
-	   mm-links-remove-leading-blank
-	   "links" "-dump" file)
-    (lynx  mm-inline-wash-with-stdin nil
-	   "lynx" "-dump" "-force_html" "-stdin" "-nolist")
-    (html2text  html2text))
-  "The attributes of washer types for text/html.")
-
 (defcustom mm-fill-flowed t
   "If non-nil a format=flowed article will be displayed flowed."
   :type 'boolean
@@ -426,7 +416,7 @@
        (buffer-string)))))
 
 (defun mm-inline-text-html (handle)
-  (let* ((func (or mm-inline-text-html-renderer mm-text-html-renderer))
+  (let* ((func mm-text-html-renderer)
 	 (entry (assq func mm-text-html-renderer-alist))
 	 (inhibit-read-only t))
     (if entry
--- a/lisp/gnus/mml.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/gnus/mml.el	Thu Oct 28 19:57:59 2010 +0900
@@ -128,6 +128,14 @@
   :type 'boolean
   :group 'message)
 
+(defcustom mml-enable-flowed t
+  "If non-nil, enable format=flowed usage when encoding a message.
+This is only performed when filling on text/plain with hard
+newlines in the text."
+  :version "24.1"
+  :type 'boolean
+  :group 'message)
+
 (defvar mml-tweak-type-alist nil
   "A list of (TYPE . FUNCTION) for tweaking MML parts.
 TYPE is a string containing a regexp to match the MIME type.  FUNCTION
@@ -546,7 +554,8 @@
 		    ;; in the mml tag or it says "flowed" and there
 		    ;; actually are hard newlines in the text.
 		    (let (use-hard-newlines)
-		      (when (and (string= type "text/plain")
+		      (when (and mml-enable-flowed
+                                 (string= type "text/plain")
 				 (not (string= (cdr (assq 'sign cont)) "pgp"))
 				 (or (null (assq 'format cont))
 				     (string= (cdr (assq 'format cont))
@@ -1457,6 +1466,7 @@
   (require 'gnus-msg)		      ; for gnus-setup-posting-charset
   (save-excursion
     (let* ((buf (current-buffer))
+	   (article-editing (eq major-mode 'gnus-article-edit-mode))
 	   (message-options message-options)
 	   (message-this-is-mail (message-mail-p))
 	   (message-this-is-news (message-news-p))
@@ -1476,15 +1486,19 @@
       (mml-preview-insert-mail-followup-to)
       (let ((message-deletable-headers (if (message-news-p)
 					   nil
-					 message-deletable-headers)))
+					 message-deletable-headers))
+	    (mail-header-separator (if article-editing
+				       ""
+				     mail-header-separator)))
 	(message-generate-headers
 	 (copy-sequence (if (message-news-p)
 			    message-required-news-headers
-			  message-required-mail-headers))))
-      (if (re-search-forward
-	   (concat "^" (regexp-quote mail-header-separator) "\n") nil t)
-	  (replace-match "\n"))
-      (let ((mail-header-separator ""));; mail-header-separator is removed.
+			  message-required-mail-headers)))
+	(unless article-editing
+	  (if (re-search-forward
+	       (concat "^" (regexp-quote mail-header-separator) "\n") nil t)
+	      (replace-match "\n"))
+	  (setq mail-header-separator ""))
 	(message-sort-headers)
 	(mml-to-mime))
       (if raw
--- a/lisp/gnus/nndoc.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/gnus/nndoc.el	Thu Oct 28 19:57:59 2010 +0900
@@ -138,6 +138,14 @@
      (generate-head-function . nndoc-generate-lanl-gov-head)
      (article-transform-function . nndoc-transform-lanl-gov-announce)
      (subtype preprints guess))
+    (git
+     (file-begin . "\n- Log ---.*")
+     (article-begin . "^commit ")
+     (head-begin . "^Author: ")
+     (body-begin . "^$")
+     (file-end . "\n-----------------------------------------------------------------------")
+     (article-transform-function . nndoc-transform-git-article)
+     (header-transform-function . nndoc-transform-git-headers))
     (rfc822-forward
      (article-begin . "^\n+")
      (body-end-function . nndoc-rfc822-forward-body-end-function)
@@ -193,6 +201,7 @@
 (defvoo nndoc-prepare-body-function nil)
 (defvoo nndoc-generate-head-function nil)
 (defvoo nndoc-article-transform-function nil)
+(defvoo nndoc-header-transform-function nil)
 (defvoo nndoc-article-begin-function nil)
 (defvoo nndoc-generate-article-function nil)
 (defvoo nndoc-dissection-function nil)
@@ -223,17 +232,22 @@
 	  (while articles
 	    (when (setq entry (cdr (assq (setq article (pop articles))
 					 nndoc-dissection-alist)))
-	      (insert (format "221 %d Article retrieved.\n" article))
-	      (if nndoc-generate-head-function
-		  (funcall nndoc-generate-head-function article)
-		(insert-buffer-substring
-		 nndoc-current-buffer (car entry) (nth 1 entry)))
-	      (goto-char (point-max))
-	      (unless (eq (char-after (1- (point))) ?\n)
-		(insert "\n"))
-	      (insert (format "Lines: %d\n" (nth 4 entry)))
-	      (insert ".\n")))
-
+	      (let ((start (point)))
+		(insert (format "221 %d Article retrieved.\n" article))
+		(if nndoc-generate-head-function
+		    (funcall nndoc-generate-head-function article)
+		  (insert-buffer-substring
+		   nndoc-current-buffer (car entry) (nth 1 entry)))
+		(goto-char (point-max))
+		(unless (eq (char-after (1- (point))) ?\n)
+		  (insert "\n"))
+		(insert (format "Lines: %d\n" (nth 4 entry)))
+		(insert ".\n")
+		(when nndoc-header-transform-function
+		  (save-excursion
+		    (save-restriction
+		      (narrow-to-region start (point))
+		      (funcall nndoc-header-transform-function entry)))))))
 	  (nnheader-fold-continuation-lines)
 	  'headers)))))
 
@@ -373,6 +387,7 @@
 		nndoc-file-end nndoc-article-begin
 		nndoc-body-begin nndoc-body-end-function nndoc-body-end
 		nndoc-prepare-body-function nndoc-article-transform-function
+		nndoc-header-transform-function
 		nndoc-generate-head-function nndoc-body-begin-function
 		nndoc-head-begin-function
 		nndoc-generate-article-function
@@ -649,6 +664,30 @@
 (defun nndoc-slack-digest-type-p ()
   0)
 
+(defun nndoc-git-type-p ()
+  (and (search-forward "\n- Log ---" nil t)
+       (search-forward "\ncommit " nil t)
+       (search-forward "\nAuthor: " nil t)))
+
+(defun nndoc-transform-git-article (article)
+  (goto-char (point-min))
+  (when (re-search-forward "^Author: " nil t)
+    (replace-match "From: " t t)))
+
+(defun nndoc-transform-git-headers (entry)
+  (goto-char (point-min))
+  (when (re-search-forward "^Author: " nil t)
+    (replace-match "From: " t t))
+  (let (subject)
+    (with-current-buffer nndoc-current-buffer
+      (goto-char (car entry))
+      (when (search-forward "\n\n" nil t)
+	(setq subject (buffer-substring (point) (line-end-position)))))
+    (when subject
+      (goto-char (point-min))
+      (forward-line 1)
+      (insert (format "Subject: %s\n" subject)))))
+
 (defun nndoc-lanl-gov-announce-type-p ()
   (when (let ((case-fold-search nil))
 	  (re-search-forward "^\\\\\\\\\n\\(Paper\\( (\\*cross-listing\\*)\\)?: [a-zA-Z-\\.]+/[0-9]+\\|arXiv:\\)" nil t))
--- a/lisp/gnus/nnimap.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/gnus/nnimap.el	Thu Oct 28 19:57:59 2010 +0900
@@ -136,6 +136,16 @@
 (defun nnimap-buffer ()
   (nnimap-find-process-buffer nntp-server-buffer))
 
+(defun nnimap-header-parameters ()
+  (format "(UID RFC822.SIZE BODYSTRUCTURE %s)"
+	  (format
+	   (if (nnimap-ver4-p)
+	       "BODY.PEEK[HEADER.FIELDS %s]"
+	     "RFC822.HEADER.LINES %s")
+	   (append '(Subject From Date Message-Id
+			     References In-Reply-To Xref)
+		   nnmail-extra-headers))))
+
 (deffoo nnimap-retrieve-headers (articles &optional group server fetch-old)
   (with-current-buffer nntp-server-buffer
     (erase-buffer)
@@ -146,14 +156,7 @@
 	 (nnimap-send-command
 	  "UID FETCH %s %s"
 	  (nnimap-article-ranges (gnus-compress-sequence articles))
-	  (format "(UID RFC822.SIZE BODYSTRUCTURE %s)"
-		  (format
-		   (if (nnimap-ver4-p)
-		       "BODY.PEEK[HEADER.FIELDS %s]"
-		     "RFC822.HEADER.LINES %s")
-		   (append '(Subject From Date Message-Id
-				     References In-Reply-To Xref)
-			   nnmail-extra-headers))))
+	  (nnimap-header-parameters))
 	 t)
 	(nnimap-transform-headers))
       (insert-buffer-substring
@@ -171,7 +174,7 @@
 	    (return)))
 	(setq article (match-string 1))
 	;; Unfold quoted {number} strings.
-	(while (re-search-forward "[^]] {\\([0-9]+\\)}\r\n"
+	(while (re-search-forward "[^]][ (]{\\([0-9]+\\)}\r\n"
 				  (1+ (line-end-position)) t)
 	  (setq size (string-to-number (match-string 1)))
 	  (delete-region (+ (match-beginning 0) 2) (point))
@@ -200,7 +203,8 @@
 	  (insert (format "Chars: %s\n" size)))
 	(when lines
 	  (insert (format "Lines: %s\n" lines)))
-	(re-search-forward "^\r$")
+	(unless (re-search-forward "^\r$" nil t)
+	  (goto-char (point-max)))
 	(delete-region (line-beginning-position) (line-end-position))
 	(insert ".")
 	(forward-line 1)))))
@@ -304,6 +308,8 @@
 	       ((or (eq nnimap-stream 'network)
 		    (and (eq nnimap-stream 'starttls)
 			 (fboundp 'open-gnutls-stream)))
+		(nnheader-message 7 "Opening connection to %s..."
+				  nnimap-address)
 		(open-network-stream
 		 "*nnimap*" (current-buffer) nnimap-address
 		 (setq port
@@ -313,18 +319,24 @@
 			     "143"))))
 		'("143" "imap"))
 	       ((eq nnimap-stream 'shell)
+		(nnheader-message 7 "Opening connection to %s via shell..."
+				  nnimap-address)
 		(nnimap-open-shell-stream
 		 "*nnimap*" (current-buffer) nnimap-address
 		 (setq port (or nnimap-server-port "imap")))
 		'("imap"))
 	       ((eq nnimap-stream 'starttls)
-		(let ((tls-program (nnimap-extend-tls-programs)))
+		(nnheader-message 7 "Opening connection to %s via starttls..."
+			 nnimap-address)
+		(let ((tls-program
+		       '("openssl s_client -connect %h:%p -no_ssl2 -ign_eof -starttls imap")))
 		  (open-tls-stream
 		   "*nnimap*" (current-buffer) nnimap-address
-		   (setq port (or nnimap-server-port "imap"))
-		   'starttls))
+		   (setq port (or nnimap-server-port "imap"))))
 		'("imap"))
 	       ((memq nnimap-stream '(ssl tls))
+		(nnheader-message 7 "Opening connection to %s via tls..."
+				  nnimap-address)
 		(funcall (if (fboundp 'open-gnutls-stream)
 			     'open-gnutls-stream
 			   'open-tls-stream)
@@ -419,19 +431,6 @@
 		(nnimap-command "ENABLE QRESYNC"))
 	      (nnimap-process nnimap-object))))))))
 
-(defun nnimap-extend-tls-programs ()
-  (let ((programs tls-program)
-	result)
-    (unless (consp programs)
-      (setq programs (list programs)))
-    (dolist (program programs)
-      (when (assoc (car (split-string program)) tls-starttls-switches)
-	(push (if (not (string-match "%s" program))
-		  (concat program " " "%s")
-		program)
-	      result)))
-    (nreverse result)))
-
 (defun nnimap-find-parameter (parameter elems)
   (let (result)
     (dolist (elem elems)
@@ -448,6 +447,7 @@
   (when (nnoo-change-server 'nnimap server nil)
     (ignore-errors
       (delete-process (get-buffer-process (nnimap-buffer))))
+    (nnoo-close-server 'nnimap server)
     t))
 
 (deffoo nnimap-request-close ()
@@ -481,7 +481,7 @@
 				(let ((start (point)))
 				  (forward-sexp 1)
 				  (downcase-region start (point))
-				  (goto-char (point))
+				  (goto-char start)
 				  (read (current-buffer))))
 		    parts (nnimap-find-wanted-parts structure))))
 	  (when (if parts
@@ -494,12 +494,28 @@
 		(nnheader-ms-strip-cr)
 		(cons group article)))))))))
 
-(defun nnimap-get-whole-article (article)
+(deffoo nnimap-request-head (article &optional group server to-buffer)
+  (when (nnimap-possibly-change-group group server)
+    (with-current-buffer (nnimap-buffer)
+      (when (stringp article)
+	(setq article (nnimap-find-article-by-message-id group article)))
+      (nnimap-get-whole-article
+       article (format "UID FETCH %%d %s"
+		       (nnimap-header-parameters)))
+      (let ((buffer (current-buffer)))
+	(with-current-buffer (or to-buffer nntp-server-buffer)
+	  (erase-buffer)
+	  (insert-buffer-substring buffer)
+	  (nnheader-ms-strip-cr)
+	  (cons group article))))))
+
+(defun nnimap-get-whole-article (article &optional command)
   (let ((result
 	 (nnimap-command
-	  (if (nnimap-ver4-p)
-	      "UID FETCH %d BODY.PEEK[]"
-	    "UID FETCH %d RFC822.PEEK")
+	  (or command
+	      (if (nnimap-ver4-p)
+		  "UID FETCH %d BODY.PEEK[]"
+		"UID FETCH %d RFC822.PEEK"))
 	  article)))
     ;; Check that we really got an article.
     (goto-char (point-min))
@@ -569,9 +585,9 @@
 	(pop bstruc))
       (setq type (car bstruc))
       (setq bstruc (car (cdr bstruc)))
-      (when (and (stringp (car bstruc))
-		 (string= (downcase (car bstruc)) "boundary"))
-	(setq boundary (cadr bstruc))))
+      (let ((has-boundary (member "boundary" bstruc)))
+        (when has-boundary
+          (setq boundary (cadr has-boundary)))))
     (when subp
       (insert (format "Content-type: multipart/%s; boundary=%S\n\n"
 		      (downcase type) boundary)))
@@ -621,7 +637,13 @@
     (nreverse parts)))
 
 (deffoo nnimap-request-group (group &optional server dont-check info)
-  (let ((result (nnimap-possibly-change-group group server))
+  (let ((result (nnimap-possibly-change-group
+		 ;; Don't SELECT the group if we're going to select it
+		 ;; later, anyway.
+		 (if dont-check
+		     nil
+		   group)
+		 server))
 	articles active marks high low)
     (with-current-buffer nntp-server-buffer
       (when result
@@ -638,6 +660,7 @@
 		   (nnimap-send-command "SELECT %S" (utf7-encode group t)))
 		  (flag-sequence
 		   (nnimap-send-command "UID FETCH 1:* FLAGS")))
+	      (setf (nnimap-group nnimap-object) group)
 	      (nnimap-wait-for-response flag-sequence)
 	      (setq marks
 		    (nnimap-flags-to-marks
@@ -673,8 +696,11 @@
 (deffoo nnimap-request-rename-group (group new-name &optional server)
   (when (nnimap-possibly-change-group nil server)
     (with-current-buffer (nnimap-buffer)
-      ;; Make sure we don't have this group open read/write.
-      (nnimap-command "EXAMINE %S" (utf7-encode group 7))
+      ;; Make sure we don't have this group open read/write by asking
+      ;; to examine a mailbox that doesn't exist.  This seems to be
+      ;; the only way that allows us to reliably go back to unselected
+      ;; state on Courier.
+      (nnimap-command "EXAMINE DOES.NOT.EXIST")
       (setf (nnimap-group nnimap-object) nil)
       (car (nnimap-command "RENAME %S %S"
 			   (utf7-encode group t) (utf7-encode new-name t))))))
@@ -708,7 +734,11 @@
 (deffoo nnimap-request-move-article (article group server accept-form
 					     &optional last internal-move-group)
   (with-temp-buffer
-    (when (nnimap-request-article article group server (current-buffer))
+    (mm-disable-multibyte)
+    (when (funcall (if internal-move-group
+		       'nnimap-request-head
+		     'nnimap-request-article)
+		   article group server (current-buffer))
       ;; If the move is internal (on the same server), just do it the easy
       ;; way.
       (let ((message-id (message-field-value "message-id")))
@@ -738,7 +768,7 @@
    ((and force
 	 (eq nnmail-expiry-target 'delete))
     (unless (nnimap-delete-article (gnus-compress-sequence articles))
-      (message "Article marked for deletion, but not expunged."))
+      (nnheader-message 7 "Article marked for deletion, but not expunged."))
     nil)
    (t
     (let ((deletable-articles
@@ -763,8 +793,9 @@
     (dolist (article articles)
       (let ((target nnmail-expiry-target))
 	(with-temp-buffer
+          (mm-disable-multibyte)
 	  (when (nnimap-request-article article group server (current-buffer))
-	    (message "Expiring article %s:%d" group article)
+	    (nnheader-message 7 "Expiring article %s:%d" group article)
 	    (when (functionp target)
 	      (setq target (funcall target group)))
 	    (when (and target
@@ -834,7 +865,7 @@
   (when (and (nnimap-possibly-change-group nil server)
 	     nnimap-inbox
 	     nnimap-split-methods)
-    (message "nnimap %s splitting mail..." server)
+    (nnheader-message 7 "nnimap %s splitting mail..." server)
     (nnimap-split-incoming-mail)))
 
 (defun nnimap-marks-to-flags (marks)
@@ -873,7 +904,7 @@
     (let ((message-id (message-field-value "message-id"))
 	  sequence message)
       (nnimap-add-cr)
-      (setq message (buffer-string))
+      (setq message (buffer-substring-no-properties (point-min) (point-max)))
       (with-current-buffer (nnimap-buffer)
 	(setq sequence (nnimap-send-command
 			"APPEND %S {%d}" (utf7-encode group t)
@@ -886,11 +917,22 @@
 	(let ((result (nnimap-get-response sequence)))
 	  (if (not (car result))
 	      (progn
-		(message "%s" (nnheader-get-report-string 'nnimap))
+		(nnheader-message 7 "%s" (nnheader-get-report-string 'nnimap))
 		nil)
 	    (cons group
 		  (nnimap-find-article-by-message-id group message-id))))))))
 
+(deffoo nnimap-request-replace-article (article group buffer)
+  (let (group-art)
+    (when (and (nnimap-possibly-change-group group nil)
+	       ;; Put the article into the group.
+	       (with-current-buffer buffer
+		 (setq group-art
+		       (nnimap-request-accept-article group nil t))))
+      (nnimap-delete-article (list article))
+      ;; Return the new article number.
+      (cdr group-art))))
+
 (defun nnimap-add-cr ()
   (goto-char (point-min))
   (while (re-search-forward "\r?\n" nil t)
@@ -967,7 +1009,6 @@
     (with-current-buffer (nnimap-buffer)
       (erase-buffer)
       (setf (nnimap-group nnimap-object) nil)
-      ;; QRESYNC handling isn't implemented.
       (let ((qresyncp (member "QRESYNC" (nnimap-capabilities nnimap-object)))
 	    params groups sequences active uidvalidity modseq group)
 	;; Go through the infos and gather the data needed to know
@@ -1006,12 +1047,7 @@
 					       (utf7-encode group t))
 			  (nnimap-send-command "UID FETCH %d:* FLAGS" start)
 			  start group command)
-		    sequences)))
-	  ;; Some servers apparently can't have many outstanding
-	  ;; commands, so throttle them.
-	  (when (and (not nnimap-streaming)
-		     (car sequences))
-	    (nnimap-wait-for-response (caar sequences))))
+		    sequences))))
 	sequences))))
 
 (deffoo nnimap-finish-retrieve-group-infos (server infos sequences)
@@ -1106,12 +1142,13 @@
 	(unless (eq permanent-flags 'not-scanned)
 	  (gnus-group-set-parameter
 	   info 'permanent-flags
-	   (if (memq '%* permanent-flags)
-	       t
-	     nil)))
+	   (and (or (memq '%* permanent-flags)
+		    (memq '%Seen permanent-flags))
+		permanent-flags)))
 	;; Update marks and read articles if this isn't a
 	;; read-only IMAP group.
-	(when (cdr (assq 'permanent-flags (gnus-info-params info)))
+	(when (setq permanent-flags
+		    (cdr (assq 'permanent-flags (gnus-info-params info))))
 	  (if (and highestmodseq
 		   (not start-article))
 	      ;; We've gotten the data by QRESYNCing.
@@ -1137,27 +1174,32 @@
 			    (gnus-info-read info))
 			 (gnus-info-read info))
 		       read)))
-	      (gnus-info-set-read info read)
+	      (when (or (not (listp permanent-flags))
+			(memq '%Seen permanent-flags))
+		(gnus-info-set-read info read))
 	      ;; Update the marks.
 	      (setq marks (gnus-info-marks info))
 	      (dolist (type (cdr nnimap-mark-alist))
-		(let ((old-marks (assoc (car type) marks))
-		      (new-marks
-		       (gnus-compress-sequence
-			(cdr (or (assoc (caddr type) flags) ; %Flagged
-				 (assoc (intern (cadr type) obarray) flags)
-				 (assoc (cadr type) flags)))))) ; "\Flagged"
-		  (setq marks (delq old-marks marks))
-		  (pop old-marks)
-		  (when (and old-marks
-			     (> start-article 1))
-		    (setq old-marks (gnus-range-difference
-				     old-marks
-				     (cons start-article high)))
-		    (setq new-marks (gnus-range-nconcat old-marks new-marks)))
-		  (when new-marks
-		    (push (cons (car type) new-marks) marks)))
-		(gnus-info-set-marks info marks t)))))
+		(when (or (not (listp permanent-flags))
+			  (memq (assoc (caddr type) flags) permanent-flags)
+			  (memq '%* permanent-flags))
+		  (let ((old-marks (assoc (car type) marks))
+			(new-marks
+			 (gnus-compress-sequence
+			  (cdr (or (assoc (caddr type) flags) ; %Flagged
+				   (assoc (intern (cadr type) obarray) flags)
+				   (assoc (cadr type) flags)))))) ; "\Flagged"
+		    (setq marks (delq old-marks marks))
+		    (pop old-marks)
+		    (when (and old-marks
+			       (> start-article 1))
+		      (setq old-marks (gnus-range-difference
+				       old-marks
+				       (cons start-article high)))
+		      (setq new-marks (gnus-range-nconcat old-marks new-marks)))
+		    (when new-marks
+		      (push (cons (car type) new-marks) marks)))))
+	      (gnus-info-set-marks info marks t))))
 	;; Note the active level for the next run-through.
 	(gnus-group-set-parameter info 'active (gnus-active group))
 	(gnus-group-set-parameter info 'uidvalidity uidvalidity)
@@ -1300,7 +1342,7 @@
 		(setq start end))
 	    (setq start (point))
 	    (goto-char end))
-	  (while (search-forward " FETCH " start t)
+	  (while (re-search-forward "^\\* [0-9]+ FETCH " start t)
 	    (setq elems (read (current-buffer)))
 	    (push (cons (cadr (memq 'UID elems))
 			(cadr (memq 'FLAGS elems)))
@@ -1320,6 +1362,25 @@
   (setq nnimap-status-string "Read-only server")
   nil)
 
+(deffoo nnimap-request-thread (id)
+    (let* ((refs (split-string
+	       (or (mail-header-references (gnus-summary-article-header))
+		   "")))
+	   (cmd (let ((value
+		       (format
+			"(OR HEADER REFERENCES %s HEADER Message-Id %s)"
+			id id)))
+		  (dolist (refid refs value)
+		    (setq value (format
+				 "(OR (OR HEADER Message-Id %s HEADER REFERENCES %s) %s)"
+				 refid refid value)))))
+	   (result
+	    (with-current-buffer (nnimap-buffer)
+	      (nnimap-command  "UID SEARCH %s" cmd))))
+      (gnus-fetch-headers (and (car result)
+	   (delete 0 (mapcar #'string-to-number
+			     (cdr (assoc "SEARCH" (cdr result)))))))))
+
 (defun nnimap-possibly-change-group (group server)
   (let ((open-result t))
     (when (and server
@@ -1364,6 +1425,10 @@
 	    (if (nnimap-newlinep nnimap-object)
 		""
 	      "\r"))))
+  ;; Some servers apparently can't have many outstanding
+  ;; commands, so throttle them.
+  (unless nnimap-streaming
+    (nnimap-wait-for-response nnimap-sequence))
   nnimap-sequence)
 
 (defun nnimap-log-command (command)
@@ -1416,7 +1481,7 @@
 			      (point-min))
 			    t)))
 	    (when messagep
-	      (message "nnimap read %dk" (/ (buffer-size) 1000)))
+	      (nnheader-message 7 "nnimap read %dk" (/ (buffer-size) 1000)))
 	    (nnheader-accept-process-output process)
 	    (goto-char (point-max)))
           openp)
@@ -1443,6 +1508,7 @@
 (defun nnimap-parse-line (line)
   (let (char result)
     (with-temp-buffer
+      (mm-disable-multibyte)
       (insert line)
       (goto-char (point-min))
       (while (not (eobp))
--- a/lisp/gnus/nnir.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/gnus/nnir.el	Thu Oct 28 19:57:59 2010 +0900
@@ -378,6 +378,10 @@
 If this variable is nil, or if the provided function returns nil for a search
 result, `gnus-retrieve-headers' will be called instead.")
 
+(defvar nnir-method-default-engines
+  '((nnimap . imap)
+    (nntp . nil))
+  "Alist of default search engines by server method")
 
 ;;; Developer Extension Variable:
 
@@ -401,8 +405,8 @@
              ())
     (hyrex   nnir-run-hyrex
 	     ((group . "Group spec: ")))
-  (find-grep nnir-run-find-grep
-	     ((grep-options . "Grep options: "))))
+    (find-grep nnir-run-find-grep
+	       ((grep-options . "Grep options: "))))
   "Alist of supported search engines.
 Each element in the alist is a three-element list (ENGINE FUNCTION ARGS).
 ENGINE is a symbol designating the searching engine.  FUNCTION is also
@@ -677,16 +681,6 @@
            gnus-current-window-configuration)
      nil)))
 
-(eval-when-compile
-  (when (featurep 'xemacs)
-    ;; The `kbd' macro requires that the `read-kbd-macro' macro is available.
-    (require 'edmacro)))
-
-(defun nnir-group-mode-hook ()
-  (define-key gnus-group-mode-map (kbd "G G")
-    'gnus-group-make-nnir-group))
-(add-hook 'gnus-group-mode-hook 'nnir-group-mode-hook)
-
 ;; Why is this needed? Is this for compatibility with old/new gnusae? Using
 ;; gnus-group-server instead works for me.  -- Justus Piater
 (defmacro nnir-group-server (group)
@@ -716,22 +710,22 @@
 	 (id (mail-header-id (gnus-summary-article-header)))
 	 (refs (split-string
 		(mail-header-references (gnus-summary-article-header)))))
-    (if (string= (car (gnus-group-method group)) "nnimap")
-	(with-current-buffer (nnimap-buffer)
-	  (let* ((cmd (let ((value
-			     (format
-			      "(OR HEADER REFERENCES %s HEADER Message-Id %s)"
-			      id id)))
-			(dolist (refid refs value)
-			  (setq value (format
-				       "(OR (OR HEADER Message-Id %s HEADER REFERENCES %s) %s)"
-				       refid refid value)))))
-		 (result (nnimap-command
-			  "UID SEARCH %s" cmd)))
-	    (gnus-summary-read-group-1 group t t gnus-summary-buffer nil
-				       (and (car result)
-					    (delete 0 (mapcar #'string-to-number
-							      (cdr (assoc "SEARCH" (cdr result)))))))))
+    (if (eq (car (gnus-group-method group)) 'nnimap)
+	(progn (nnimap-possibly-change-group (gnus-group-short-name group) nil)
+	       (with-current-buffer (nnimap-buffer)
+		 (let* ((cmd (let ((value (format
+					   "(OR HEADER REFERENCES %s HEADER Message-Id %s)"
+					   id id)))
+			       (dolist (refid refs value)
+				 (setq value (format
+					      "(OR (OR HEADER Message-Id %s HEADER REFERENCES %s) %s)"
+					      refid refid value)))))
+			(result (nnimap-command
+				 "UID SEARCH %s" cmd)))
+		   (gnus-summary-read-group-1 group t t gnus-summary-buffer nil
+					      (and (car result)
+						   (delete 0 (mapcar #'string-to-number
+								     (cdr (assoc "SEARCH" (cdr result))))))))))
       (gnus-summary-read-group-1 group t t gnus-summary-buffer
 				 nil (list backend-number))
       (gnus-summary-limit (list backend-number))
@@ -1602,24 +1596,37 @@
     (if gnus-group-marked
 	(apply 'vconcat
 	       (mapcar (lambda (x)
-			 (let ((server (nnir-group-server x))
-			       search-func)
+			 (let* ((server (nnir-group-server x))
+				(engine
+				 (or (nnir-read-server-parm 'nnir-search-engine
+							    server)
+				     (cdr
+				      (assoc (car (gnus-server-to-method server))
+					     nnir-method-default-engines))))
+				search-func)
 			   (setq search-func (cadr
 					      (assoc
-					       (nnir-read-server-parm 'nnir-search-engine server) nnir-engines)))
+					       engine
+					       nnir-engines)))
 			   (if search-func
 			       (funcall search-func q server x)
 			     nil)))
-		       gnus-group-marked)
-	       )
+		       gnus-group-marked))
       (apply 'vconcat
 	     (mapcar (lambda (x)
 		       (if (and (equal (cadr x) 'ok) (not (equal (cadar x) "-ephemeral")))
-			   (let ((server (format "%s:%s" (caar x) (cadar x)))
-				 search-func)
+			   (let* ((server (format "%s:%s" (caar x) (cadar x)))
+				  (engine
+				   (or (nnir-read-server-parm 'nnir-search-engine
+							      server)
+				       (cdr
+					(assoc (car (gnus-server-to-method server))
+					       nnir-method-default-engines))))
+				  search-func)
 			     (setq search-func (cadr
 						(assoc
-						 (nnir-read-server-parm 'nnir-search-engine server) nnir-engines)))
+						 engine
+						 nnir-engines)))
 			     (if search-func
 				 (funcall search-func q server nil)
 			       nil))
--- a/lisp/gnus/nnmairix.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/gnus/nnmairix.el	Thu Oct 28 19:57:59 2010 +0900
@@ -188,17 +188,17 @@
 (defun nnmairix-summary-mode-hook ()
   "Nnmairix summary mode keymap."
   (define-key gnus-summary-mode-map
-    (kbd "$ t") 'nnmairix-search-thread-this-article)
+    (kbd "G G t") 'nnmairix-search-thread-this-article)
   (define-key gnus-summary-mode-map
-    (kbd "$ f") 'nnmairix-search-from-this-article)
+    (kbd "G G f") 'nnmairix-search-from-this-article)
   (define-key gnus-summary-mode-map
-    (kbd "$ m") 'nnmairix-widget-search-from-this-article)
+    (kbd "G G m") 'nnmairix-widget-search-from-this-article)
   (define-key gnus-summary-mode-map
-    (kbd "$ g") 'nnmairix-create-search-group-from-message)
+    (kbd "G G g") 'nnmairix-create-search-group-from-message)
   (define-key gnus-summary-mode-map
-    (kbd "$ o") 'nnmairix-goto-original-article)
+    (kbd "G G o") 'nnmairix-goto-original-article)
   (define-key gnus-summary-mode-map
-    (kbd "$ u") 'nnmairix-remove-tick-mark-original-article))
+    (kbd "G G u") 'nnmairix-remove-tick-mark-original-article))
 
 (add-hook 'gnus-group-mode-hook 'nnmairix-group-mode-hook)
 (add-hook 'gnus-summary-mode-hook 'nnmairix-summary-mode-hook)
--- a/lisp/gnus/nnrss.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/gnus/nnrss.el	Thu Oct 28 19:57:59 2010 +0900
@@ -114,11 +114,6 @@
 the car is what the data specify as the encoding.  Or, the car is used
 for decoding when the cdr that the data specify is not available.")
 
-(defvar nnrss-wash-html-in-text-plain-parts nil
-  "*Non-nil means render text in text/plain parts as HTML.
-The function specified by the `mm-text-html-renderer' variable will be
-used to render text.  If it is nil, text will simply be folded.")
-
 (nnoo-define-basics nnrss)
 
 ;;; Interface functions
@@ -197,9 +192,6 @@
 (deffoo nnrss-close-group (group &optional server)
   t)
 
-(defvar mm-text-html-renderer)
-(defvar mm-text-html-washer-alist)
-
 (deffoo nnrss-request-article (article &optional group server buffer)
   (setq group (nnrss-decode-group-name group))
   (when (stringp article)
@@ -240,46 +232,25 @@
 	    (when text
 	      (insert text)
 	      (goto-char body)
-	      (if (and nnrss-wash-html-in-text-plain-parts
-		       (progn
-			 (require 'mm-view)
-			 (setq fn (or (cdr (assq mm-text-html-renderer
-						 mm-text-html-washer-alist))
-				      mm-text-html-renderer))))
-		  (progn
-		    (narrow-to-region body (point-max))
-		    (if (functionp fn)
-			(funcall fn)
-		      (apply (car fn) (cdr fn)))
-		    (widen)
-		    (goto-char body)
-		    (re-search-forward "[^\t\n ]" nil t)
-		    (beginning-of-line)
-		    (delete-region body (point))
-		    (goto-char (point-max))
-		    (skip-chars-backward "\t\n ")
-		    (end-of-line)
-		    (delete-region (point) (point-max))
-		    (insert "\n"))
-		(while (re-search-forward "\n+" nil t)
-		  (replace-match " "))
-		(goto-char body)
-		;; See `nnrss-check-group', which inserts "<br /><br />".
-		(when (search-forward "<br /><br />" nil t)
-		  (if (eobp)
-		      (replace-match "\n")
-		    (replace-match "\n\n")))
-		(unless (eobp)
-		  (let ((fill-column (default-value 'fill-column))
-			(window (get-buffer-window nntp-server-buffer)))
-		    (when window
-		      (setq fill-column
-			    (max 1 (/ (* (window-width window) 7) 8))))
-		    (fill-region (point) (point-max))
-		    (goto-char (point-max))
-		    ;; XEmacs version of `fill-region' inserts newline.
-		    (unless (bolp)
-		      (insert "\n")))))
+	      (while (re-search-forward "\n+" nil t)
+		(replace-match " "))
+	      (goto-char body)
+	      ;; See `nnrss-check-group', which inserts "<br /><br />".
+	      (when (search-forward "<br /><br />" nil t)
+		(if (eobp)
+		    (replace-match "\n")
+		  (replace-match "\n\n")))
+	      (unless (eobp)
+		(let ((fill-column (default-value 'fill-column))
+		      (window (get-buffer-window nntp-server-buffer)))
+		  (when window
+		    (setq fill-column
+			  (max 1 (/ (* (window-width window) 7) 8))))
+		  (fill-region (point) (point-max))
+		  (goto-char (point-max))
+		  ;; XEmacs version of `fill-region' inserts newline.
+		  (unless (bolp)
+		    (insert "\n"))))
 	      (when (or link enclosure)
 		(insert "\n")))
 	    (when link
--- a/lisp/gnus/rfc2231.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/gnus/rfc2231.el	Thu Oct 28 19:57:59 2010 +0900
@@ -185,11 +185,19 @@
 		in (sort parameters (lambda (e1 e2)
 				      (< (or (caddr e1) 0)
 					 (or (caddr e2) 0))))
-		do (if (or (not (setq elem (assq attribute cparams)))
-			   (and (numberp part)
-				(zerop part)))
-		       (push (list attribute value encoded) cparams)
-		     (setcar (cdr elem) (concat (cadr elem) value))))
+		do (cond
+		    ;; First part.
+		    ((or (not (setq elem (assq attribute cparams)))
+			 (and (numberp part)
+			      (zerop part)))
+		     (push (list attribute value encoded) cparams))
+		    ;; Repetition of a part; do nothing.
+		    ((and elem
+			  (null number))
+		     )
+		    ;; Concatenate continuation parts.
+		    (t
+		     (setcar (cdr elem) (concat (cadr elem) value)))))
 	  ;; Finally decode encoded values.
 	  (cons type (mapcar
 		      (lambda (elem)
--- a/lisp/gnus/shr.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/gnus/shr.el	Thu Oct 28 19:57:59 2010 +0900
@@ -32,6 +32,8 @@
 
 (eval-when-compile (require 'cl))
 (require 'browse-url)
+(unless (aref (char-category-set (make-char 'japanese-jisx0208 33 35)) ?>)
+  (load "kinsoku" nil t))
 
 (defgroup shr nil
   "Simple HTML Renderer"
@@ -56,26 +58,28 @@
 (defcustom shr-table-line ?-
   "Character used to draw table line."
   :group 'shr
-  :type 'char)
+  :type 'character)
 
 (defcustom shr-table-corner ?+
   "Character used to draw table corner."
   :group 'shr
-  :type 'char)
+  :type 'character)
 
 (defcustom shr-hr-line ?-
   "Character used to draw hr line."
   :group 'shr
-  :type 'char)
+  :type 'character)
+
+(defcustom shr-width fill-column
+  "Frame width to use for rendering."
+  :type 'integer
+  :group 'shr)
 
 (defvar shr-content-function nil
   "If bound, this should be a function that will return the content.
 This is used for cid: URLs, and the function is called with the
 cid: URL as the argument.")
 
-(defvar shr-width 70
-  "Frame width to use for rendering.")
-
 ;;; Internal variables.
 
 (defvar shr-folding-mode nil)
@@ -85,6 +89,7 @@
 (defvar shr-inhibit-images nil)
 (defvar shr-list-mode nil)
 (defvar shr-content-cache nil)
+(defvar shr-kinsoku-shorten nil)
 
 (defvar shr-map
   (let ((map (make-sparse-keymap)))
@@ -93,6 +98,7 @@
     (define-key map "I" 'shr-insert-image)
     (define-key map "u" 'shr-copy-url)
     (define-key map "v" 'shr-browse-url)
+    (define-key map "o" 'shr-save-contents)
     (define-key map "\r" 'shr-browse-url)
     map))
 
@@ -201,54 +207,89 @@
    ((eq shr-folding-mode 'none)
     (insert text))
    (t
-    (let ((first t)
-	  column)
-      (when (and (string-match "\\`[ \t\n]" text)
-		 (not (bolp))
-		 (not (eq (char-after (1- (point))) ? )))
-	(insert " "))
-      (dolist (elem (split-string text))
-	(when (and (bolp)
-		   (> shr-indentation 0))
+    (when (and (string-match "\\`[ \t\n]" text)
+	       (not (bolp))
+	       (not (eq (char-after (1- (point))) ? )))
+      (insert " "))
+    (dolist (elem (split-string text))
+      (when (and (bolp)
+		 (> shr-indentation 0))
+	(shr-indent))
+      ;; The shr-start is a special variable that is used to pass
+      ;; upwards the first point in the buffer where the text really
+      ;; starts.
+      (unless shr-start
+	(setq shr-start (point)))
+      ;; No space is needed behind a wide character categorized as
+      ;; kinsoku-bol, between characters both categorized as nospace,
+      ;; or at the beginning of a line.
+      (let (prev)
+	(when (and (eq (preceding-char) ? )
+		   (or (= (line-beginning-position) (1- (point)))
+		       (and (aref fill-find-break-point-function-table
+				  (setq prev (char-after (- (point) 2))))
+			    (aref (char-category-set prev) ?>))
+		       (and (aref fill-nospace-between-words-table prev)
+			    (aref fill-nospace-between-words-table
+				  (aref elem 0)))))
+	  (delete-char -1)))
+      (insert elem)
+      (while (> (current-column) shr-width)
+	(unless (prog1
+		    (shr-find-fill-point)
+		  (when (eq (preceding-char) ? )
+		    (delete-char -1))
+		  (insert "\n"))
+	  (put-text-property (1- (point)) (point) 'shr-break t)
+	  ;; No space is needed at the beginning of a line.
+	  (when (eq (following-char) ? )
+	    (delete-char 1)))
+	(when (> shr-indentation 0)
 	  (shr-indent))
-	;; The shr-start is a special variable that is used to pass
-	;; upwards the first point in the buffer where the text really
-	;; starts.
-	(unless shr-start
-	  (setq shr-start (point)))
-	(insert elem)
-	(when (> (shr-current-column) shr-width)
-	  (if (not (search-backward " " (line-beginning-position) t))
-	      (insert "\n")
-	    (delete-char 1)
-	    (insert "\n")
-	    (put-text-property (1- (point)) (point) 'shr-break t)
-	    (when (> shr-indentation 0)
-	      (shr-indent))
-	    (end-of-line)))
-	(insert " "))
-      (unless (string-match "[ \t\n]\\'" text)
-	(delete-char -1))))))
+	(end-of-line))
+      (insert " "))
+    (unless (string-match "[ \t\n]\\'" text)
+      (delete-char -1)))))
 
 (defun shr-find-fill-point ()
-  (let ((found nil))
-    (while (and (not found)
-		(not (bolp)))
-      (when (or (eq (preceding-char) ? )
-		(aref fill-find-break-point-function-table (preceding-char)))
-	(setq found (point)))
+  (when (> (move-to-column shr-width) shr-width)
+    (backward-char 1))
+  (let (failed)
+    (while (not
+	    (or (setq failed (= (current-column) shr-indentation))
+		(eq (preceding-char) ? )
+		(eq (following-char) ? )
+		(aref fill-find-break-point-function-table (preceding-char))))
       (backward-char 1))
-    (or found
-	(end-of-line))))
-
-(defun shr-current-column ()
-  (let ((column 0))
-    (save-excursion
-      (beginning-of-line)
-      (while (not (eolp))
-	(incf column (char-width (following-char)))
-	(forward-char 1)))
-    column))
+    (if failed
+	;; There's no breakable point, so we give it up.
+	(progn
+	  (end-of-line)
+	  (while (aref fill-find-break-point-function-table (preceding-char))
+	    (backward-char 1))
+	  nil)
+      (or (eolp)
+	  ;; Don't put kinsoku-bol characters at the beginning of a line,
+	  ;; or kinsoku-eol characters at the end of a line,
+	  (let ((count 4))
+	    (if (or shr-kinsoku-shorten
+		    (and (aref (char-category-set (preceding-char)) ?<)
+			 (progn
+			   (setq count (1- count))
+			   (backward-char 1)
+			   t)))
+		(while (and
+			(>= (setq count (1- count)) 0)
+			(not (memq (preceding-char) (list ?\C-@ ?\n ? )))
+			(or (aref (char-category-set (preceding-char)) ?<)
+			    (aref (char-category-set (following-char)) ?>)))
+		  (backward-char 1))
+	      (while (and (>= (setq count (1- count)) 0)
+			  (aref (char-category-set (following-char)) ?>))
+		(forward-char 1)))
+	    (when (eq (following-char) ? )
+	      (forward-char 1))
+	    t)))))
 
 (defun shr-ensure-newline ()
   (unless (zerop (current-column))
@@ -277,9 +318,20 @@
     (dolist (type types)
       (shr-add-font (or shr-start (point)) (point) type))))
 
+;; Add an overlay in the region, but avoid putting the font properties
+;; on blank text at the start of the line, and the newline at the end,
+;; to avoid ugliness.
 (defun shr-add-font (start end type)
-  (let ((overlay (make-overlay start end)))
-    (overlay-put overlay 'face type)))
+  (save-excursion
+    (goto-char start)
+    (while (< (point) end)
+      (when (bolp)
+	(skip-chars-forward " "))
+      (let ((overlay (make-overlay (point) (min (line-end-position) end))))
+	(overlay-put overlay 'face type))
+      (if (< (line-end-position) end)
+	  (forward-line 1)
+	(goto-char end)))))
 
 (defun shr-browse-url ()
   "Browse the URL under point."
@@ -289,6 +341,23 @@
 	(message "No link under point")
       (browse-url url))))
 
+(defun shr-save-contents (directory)
+  "Save the contents from URL in a file."
+  (interactive "DSave contents of URL to directory: ")
+  (let ((url (get-text-property (point) 'shr-url)))
+    (if (not url)
+	(message "No link under point")
+      (url-retrieve (shr-encode-url url)
+		    'shr-store-contents (list url directory)))))
+
+(defun shr-store-contents (status url directory)
+  (unless (plist-get status :error)
+    (when (or (search-forward "\n\n" nil t)
+	      (search-forward "\r\n\r\n" nil t))
+      (write-region (point) (point-max)
+		    (expand-file-name (file-name-nondirectory url)
+				      directory)))))
+
 (defun shr-image-fetched (status buffer start end)
   (when (and (buffer-name buffer)
 	     (not (plist-get status :error)))
@@ -344,7 +413,7 @@
   (with-temp-buffer
     (mm-disable-multibyte)
     (when (ignore-errors
-	    (url-cache-extract (url-cache-create-filename url))
+	    (url-cache-extract (url-cache-create-filename (shr-encode-url url)))
 	    t)
       (when (or (search-forward "\n\n" nil t)
 		(search-forward "\r\n\r\n" nil t))
@@ -355,6 +424,18 @@
   (apply #'shr-fontize-cont cont types)
   (shr-ensure-paragraph))
 
+(defun shr-urlify (start url)
+  (widget-convert-button
+   'url-link start (point)
+   :help-echo url
+   :keymap shr-map
+   url)
+  (put-text-property start (point) 'shr-url url))
+
+(defun shr-encode-url (url)
+  "Encode URL."
+  (browse-url-url-encode-chars url "[)$ ]"))
+
 ;;; Tag-specific rendering rules.
 
 (defun shr-tag-p (cont)
@@ -363,6 +444,12 @@
   (shr-generic cont)
   (shr-ensure-paragraph))
 
+(defun shr-tag-div (cont)
+  (shr-ensure-newline)
+  (shr-indent)
+  (shr-generic cont)
+  (shr-ensure-newline))
+
 (defun shr-tag-b (cont)
   (shr-fontize-cont cont 'bold))
 
@@ -372,62 +459,93 @@
 (defun shr-tag-em (cont)
   (shr-fontize-cont cont 'bold))
 
+(defun shr-tag-strong (cont)
+  (shr-fontize-cont cont 'bold))
+
 (defun shr-tag-u (cont)
   (shr-fontize-cont cont 'underline))
 
 (defun shr-tag-s (cont)
   (shr-fontize-cont cont 'strike-through))
 
+(defun shr-tag-span (cont)
+  (let ((start (point))
+	(color (cdr (assq 'color (shr-parse-style (cdr (assq :style cont)))))))
+    (shr-generic cont)
+    (when color
+      (let ((overlay (make-overlay start (point))))
+	(overlay-put overlay 'face (cons 'foreground-color color))))))
+
+(defun shr-parse-style (style)
+  (when style
+    (let ((plist nil))
+      (dolist (elem (split-string style ";"))
+	(when elem
+	  (setq elem (split-string elem ":"))
+	  (when (and (car elem)
+		     (cadr elem))
+	    (let ((name (replace-regexp-in-string "^ +\\| +$" "" (car elem)))
+		  (value (replace-regexp-in-string "^ +\\| +$" "" (cadr elem))))
+	      (push (cons (intern name obarray)
+			  value)
+		    plist)))))
+      plist)))
+
 (defun shr-tag-a (cont)
   (let ((url (cdr (assq :href cont)))
 	(start (point))
 	shr-start)
     (shr-generic cont)
-    (widget-convert-button
-     'link (or shr-start start) (point)
-     :help-echo url)
-    (put-text-property (or shr-start start) (point) 'keymap shr-map)
-    (put-text-property (or shr-start start) (point) 'shr-url url)))
+    (shr-urlify (or shr-start start) url)))
+
+(defun shr-tag-object (cont)
+  (let ((url (cdr (assq :src (cdr (assq 'embed cont)))))
+	(start (point)))
+    (when url
+      (shr-insert " [multimedia] ")
+      (shr-urlify start url))))
 
 (defun shr-tag-img (cont)
-  (when (and (> (current-column) 0)
-	     (not (eq shr-state 'image)))
-    (insert "\n"))
-  (let ((start (point-marker)))
+  (when (and cont
+	     (cdr (assq :src cont)))
+    (when (and (> (current-column) 0)
+	       (not (eq shr-state 'image)))
+      (insert "\n"))
     (let ((alt (cdr (assq :alt cont)))
 	  (url (cdr (assq :src cont))))
-      (when (zerop (length alt))
-	(setq alt "[img]"))
-      (cond
-       ((and (not shr-inhibit-images)
-	     (string-match "\\`cid:" url))
-	(let ((url (substring url (match-end 0)))
-	      image)
-	  (if (or (not shr-content-function)
-		  (not (setq image (funcall shr-content-function url))))
-	      (insert alt)
-	    (shr-put-image image (point) alt))))
-       ((or shr-inhibit-images
-	    (and shr-blocked-images
-		 (string-match shr-blocked-images url)))
-	(setq shr-start (point))
-	(let ((shr-state 'space))
-	  (if (> (length alt) 8)
-	      (shr-insert (substring alt 0 8))
-	    (shr-insert alt))))
-       ((url-is-cached (browse-url-url-encode-chars url "[&)$ ]"))
-	(shr-put-image (shr-get-image-data url) (point) alt))
-       (t
-	(insert alt)
-	(ignore-errors
-	  (url-retrieve url 'shr-image-fetched
-			(list (current-buffer) start (point-marker))
-			t))))
-      (insert " ")
-      (put-text-property start (point) 'keymap shr-map)
-      (put-text-property start (point) 'shr-alt alt)
-      (put-text-property start (point) 'shr-image url)
-      (setq shr-state 'image))))
+      (let ((start (point-marker)))
+	(when (zerop (length alt))
+	  (setq alt "[img]"))
+	(cond
+	 ((and (not shr-inhibit-images)
+	       (string-match "\\`cid:" url))
+	  (let ((url (substring url (match-end 0)))
+		image)
+	    (if (or (not shr-content-function)
+		    (not (setq image (funcall shr-content-function url))))
+		(insert alt)
+	      (shr-put-image image (point) alt))))
+	 ((or shr-inhibit-images
+	      (and shr-blocked-images
+		   (string-match shr-blocked-images url)))
+	  (setq shr-start (point))
+	  (let ((shr-state 'space))
+	    (if (> (length alt) 8)
+		(shr-insert (substring alt 0 8))
+	      (shr-insert alt))))
+	 ((url-is-cached (shr-encode-url url))
+	  (shr-put-image (shr-get-image-data url) (point) alt))
+	 (t
+	  (insert alt)
+	  (ignore-errors
+	    (url-retrieve (shr-encode-url url) 'shr-image-fetched
+			  (list (current-buffer) start (point-marker))
+			  t))))
+	(insert " ")
+	(put-text-property start (point) 'keymap shr-map)
+	(put-text-property start (point) 'shr-alt alt)
+	(put-text-property start (point) 'shr-image url)
+	(setq shr-state 'image)))))
 
 (defun shr-tag-pre (cont)
   (let ((shr-folding-mode 'none))
@@ -506,11 +624,11 @@
 ;; main buffer).  Now we know how much space each TD really takes, so
 ;; we then render everything again with the new widths, and finally
 ;; insert all these boxes into the main buffer.
-(defun shr-tag-table (cont)
-  (shr-ensure-paragraph)
+(defun shr-tag-table-1 (cont)
   (setq cont (or (cdr (assq 'tbody cont))
 		 cont))
   (let* ((shr-inhibit-images t)
+	 (shr-kinsoku-shorten t)
 	 ;; Find all suggested widths.
 	 (columns (shr-column-specs cont))
 	 ;; Compute how many characters wide each TD should be.
@@ -520,6 +638,12 @@
 	 ;; unbreakable text).
 	 (sketch (shr-make-table cont suggested-widths))
 	 (sketch-widths (shr-table-widths sketch suggested-widths)))
+    ;; This probably won't work very well.
+    (when (> (+ (loop for width across sketch-widths
+		      summing (1+ width))
+		shr-indentation 1)
+	     (frame-width))
+      (setq truncate-lines t))
     ;; Then render the table again with these new "hard" widths.
     (shr-insert-table (shr-make-table cont sketch-widths t) sketch-widths))
   ;; Finally, insert all the images after the table.  The Emacs buffer
@@ -528,6 +652,54 @@
   (dolist (elem (shr-find-elements cont 'img))
     (shr-tag-img (cdr elem))))
 
+(defun shr-tag-table (cont)
+  (shr-ensure-paragraph)
+  (let* ((caption (cdr (assq 'caption cont)))
+	 (header (cdr (assq 'thead cont)))
+	 (body (or (cdr (assq 'tbody cont)) cont))
+	 (footer (cdr (assq 'tfoot cont)))
+	 (nheader (if header (shr-max-columns header)))
+	 (nbody (if body (shr-max-columns body)))
+	 (nfooter (if footer (shr-max-columns footer))))
+    (shr-tag-table-1
+     (nconc
+      (if caption `((tr (td ,@caption))))
+      (if header
+	  (if footer
+	      ;; hader + body + footer
+	      (if (= nheader nbody)
+		  (if (= nbody nfooter)
+		      `((tr (td (table (tbody ,@header ,@body ,@footer)))))
+		    (nconc `((tr (td (table (tbody ,@header ,@body)))))
+			   (if (= nfooter 1)
+			       footer
+			     `((tr (td (table (tbody ,@footer))))))))
+		(nconc `((tr (td (table (tbody ,@header)))))
+		       (if (= nbody nfooter)
+			   `((tr (td (table (tbody ,@body ,@footer)))))
+			 (nconc `((tr (td (table (tbody ,@body)))))
+				(if (= nfooter 1)
+				    footer
+				  `((tr (td (table (tbody ,@footer))))))))))
+	    ;; header + body
+	    (if (= nheader nbody)
+		`((tr (td (table (tbody ,@header ,@body)))))
+	      (if (= nheader 1)
+		  `(,@header (tr (td (table (tbody ,@body)))))
+		`((tr (td (table (tbody ,@header))))
+		  (tr (td (table (tbody ,@body))))))))
+	(if footer
+	    ;; body + footer
+	    (if (= nbody nfooter)
+		`((tr (td (table (tbody ,@body ,@footer)))))
+	      (nconc `((tr (td (table (tbody ,@body)))))
+		     (if (= nfooter 1)
+			 footer
+		       `((tr (td (table (tbody ,@footer))))))))
+	  (if caption
+	      `((tr (td (table (tbody ,@body)))))
+	    body)))))))
+
 (defun shr-find-elements (cont type)
   (let (result)
     (dolist (elem cont)
@@ -568,12 +740,14 @@
 	  ;; possibly.
 	  (dotimes (i (- height (length lines)))
 	    (end-of-line)
-	    (insert (make-string (length (car lines)) ? ) "|")
+	    (insert (make-string (string-width (car lines)) ? ) "|")
 	    (forward-line 1)))))
     (shr-insert-table-ruler widths)))
 
 (defun shr-insert-table-ruler (widths)
-  (shr-indent)
+  (when (and (bolp)
+	     (> shr-indentation 0))
+    (shr-indent))
   (insert shr-table-corner)
   (dotimes (i (length widths))
     (insert (make-string (aref widths i) shr-table-line) shr-table-corner))
--- a/lisp/gnus/spam.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/gnus/spam.el	Thu Oct 28 19:57:59 2010 +0900
@@ -1287,6 +1287,7 @@
 classification and spam-use-* check variable are used.  This is
 superseded by the new spam backend code, so it's only consulted
 for backwards compatibility.")
+(make-obsolete-variable 'spam-list-of-processors nil "22.1")
 
 (defun spam-group-processor-p (group backend &optional classification)
   "Checks if GROUP has a BACKEND with CLASSIFICATION registered.
--- a/lisp/help-fns.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/help-fns.el	Thu Oct 28 19:57:59 2010 +0900
@@ -887,7 +887,111 @@
 	  (insert "\nThe parent category table is:")
 	  (describe-vector table 'help-describe-category-set))))))
 
+
+;;; Replacements for old lib-src/ programs.  Don't seem especially useful.
+
+;; Replaces lib-src/digest-doc.c.
+;;;###autoload
+(defun doc-file-to-man (file)
+  "Produce an nroff buffer containing the doc-strings from the DOC file."
+  (interactive (list (read-file-name "Name of DOC file: " doc-directory
+                                     internal-doc-file-name t)))
+  (or (file-readable-p file)
+      (error "Cannot read file `%s'" file))
+  (pop-to-buffer (generate-new-buffer "*man-doc*"))
+  (setq buffer-undo-list t)
+  (insert ".TH \"Command Summary for GNU Emacs\"\n"
+          ".AU Richard M. Stallman\n")
+  (insert-file-contents file)
+  (let (notfirst)
+    (while (search-forward "" nil 'move)
+      (if (looking-at "S")
+          (delete-region (1- (point)) (line-end-position))
+        (delete-char -1)
+        (if notfirst
+            (insert "\n.DE\n")
+          (setq notfirst t))
+        (insert "\n.SH ")
+        (insert (if (looking-at "F") "Function " "Variable "))
+        (delete-char 1)
+        (forward-line 1)
+        (insert ".DS L\n"))))
+  (insert "\n.DE\n")
+  (setq buffer-undo-list nil)
+  (nroff-mode))
+
+;; Replaces lib-src/sorted-doc.c.
+;;;###autoload
+(defun doc-file-to-info (file)
+  "Produce a texinfo buffer with sorted doc-strings from the DOC file."
+  (interactive (list (read-file-name "Name of DOC file: " doc-directory
+                                     internal-doc-file-name t)))
+  (or (file-readable-p file)
+      (error "Cannot read file `%s'" file))
+  (let ((i 0) type name doc alist)
+    (with-temp-buffer
+      (insert-file-contents file)
+      ;; The characters "@{}" need special treatment.
+      (while (re-search-forward "[@{}]" nil t)
+        (backward-char)
+        (insert "@")
+        (forward-char 1))
+      (goto-char (point-min))
+      (while (search-forward "" nil t)
+        (unless (looking-at "S")
+          (setq type (char-after)
+                name (buffer-substring (1+ (point)) (line-end-position))
+                doc (buffer-substring (line-beginning-position 2)
+                                      (if (search-forward  "" nil 'move)
+                                          (1- (point))
+                                        (point)))
+                alist (cons (list name type doc) alist))
+          (backward-char 1))))
+    (pop-to-buffer (generate-new-buffer "*info-doc*"))
+    (setq buffer-undo-list t)
+    ;; Write the output header.
+    (insert "\\input texinfo  @c -*-texinfo-*-\n"
+            "@setfilename emacsdoc.info\n"
+            "@settitle Command Summary for GNU Emacs\n"
+            "@finalout\n"
+            "\n@node Top\n"
+            "@unnumbered Command Summary for GNU Emacs\n\n"
+            "@table @asis\n\n"
+            "@iftex\n"
+            "@global@let@ITEM@item\n"
+            "@def@item{@filbreak@vskip5pt@ITEM}\n"
+            "@font@tensy cmsy10 scaled @magstephalf\n"
+            "@font@teni cmmi10 scaled @magstephalf\n"
+            "@def\\{{@tensy@char110}}\n" ; this backslash goes with cmr10
+            "@def|{{@tensy@char106}}\n"
+            "@def@{{{@tensy@char102}}\n"
+            "@def@}{{@tensy@char103}}\n"
+            "@def<{{@teni@char62}}\n"
+            "@def>{{@teni@char60}}\n"
+            "@chardef@@64\n"
+            "@catcode43=12\n"
+            "@tableindent-0.2in\n"
+            "@end iftex\n")
+    ;; Sort the array by name; within each name, by type (functions first).
+    (setq alist (sort alist (lambda (e1 e2)
+                              (if (string-equal (car e1) (car e2))
+                                  (<= (cadr e1) (cadr e2))
+                                (string-lessp (car e1) (car e2))))))
+    ;; Print each function.
+    (dolist (e alist)
+      (insert "\n@item "
+              (if (char-equal (cadr e) ?\F) "Function" "Variable")
+              " @code{" (car e) "}\n@display\n"
+              (nth 2 e)
+              "\n@end display\n")
+      ;; Try to avoid a save size overflow in the TeX output routine.
+      (if (zerop (setq i (% (1+ i) 100)))
+          (insert "\n@end table\n@table @asis\n")))
+    (insert "@end table\n"
+            "@bye\n")
+    (setq buffer-undo-list nil)
+    (texinfo-mode)))
+
 (provide 'help-fns)
 
-;; arch-tag: 9e10331c-ae81-4d13-965d-c4819aaab0b3
 ;;; help-fns.el ends here
--- a/lisp/help.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/help.el	Thu Oct 28 19:57:59 2010 +0900
@@ -1,7 +1,8 @@
 ;;; help.el --- help commands for Emacs
 
 ;; Copyright (C) 1985, 1986, 1993, 1994, 1998, 1999, 2000, 2001, 2002,
-;;   2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+;;   2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+;;   Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 ;; Keywords: help, internal
@@ -119,9 +120,6 @@
 (define-key global-map [f1] 'help-command)
 (fset 'help-command help-map)
 
-(autoload 'finder-by-keyword "finder"
-  "Find packages matching a given keyword." t)
-
 ;; insert-button makes the action nil if it is not store somewhere
 (defvar help-button-cache nil)
 
@@ -1252,5 +1250,4 @@
 
 (provide 'help)
 
-;; arch-tag: cf427352-27e9-49b7-9a6f-741ebab02423
 ;;; help.el ends here
--- a/lisp/hexl.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/hexl.el	Thu Oct 28 19:57:59 2010 +0900
@@ -212,6 +212,7 @@
 (defvar hexl-mode-old-syntax-table)
 (defvar hexl-mode-old-font-lock-keywords)
 (defvar hexl-mode-old-eldoc-documentation-function)
+(defvar hexl-mode-old-revert-buffer-function)
 
 (defvar hexl-ascii-overlay nil
   "Overlay used to highlight ASCII element corresponding to current point.")
@@ -373,10 +374,9 @@
     (setq hexl-mode-old-font-lock-keywords font-lock-defaults)
     (setq font-lock-defaults '(hexl-font-lock-keywords t))
 
-    ;; Add hooks to rehexlify or dehexlify on various events.
-    (add-hook 'before-revert-hook 'hexl-before-revert-hook nil t)
-    (add-hook 'after-revert-hook 'hexl-after-revert-hook nil t)
-
+    (make-local-variable 'hexl-mode-old-revert-buffer-function)
+    (setq hexl-mode-old-revert-buffer-function revert-buffer-function)
+    (setq revert-buffer-function 'hexl-revert-buffer-function)
     (add-hook 'change-major-mode-hook 'hexl-maybe-dehexlify-buffer nil t)
 
     ;; Set a callback function for eldoc.
@@ -413,12 +413,6 @@
     (let ((isearch-search-fun-function nil))
       (isearch-search-fun))))
 
-(defun hexl-before-revert-hook ()
-  (remove-hook 'change-major-mode-hook 'hexl-maybe-dehexlify-buffer t))
-
-(defun hexl-after-revert-hook ()
-  (hexl-mode))
-
 (defvar hexl-in-save-buffer nil)
 
 (defun hexl-save-buffer ()
@@ -464,6 +458,23 @@
   (if (not (eq major-mode 'hexl-mode))
       (hexl-mode)))
 
+(defun hexl-revert-buffer-function (ignore-auto noconfirm)
+  (let ((coding-system-for-read 'no-conversion)
+	revert-buffer-function)
+    ;; Call the original `revert-buffer' without code conversion; also
+    ;; prevent it from changing the major mode to normal-mode, which
+    ;; calls `set-auto-mode'.
+    (revert-buffer nil nil t)
+    ;; A couple of hacks are necessary here:
+    ;; 1. change the major-mode to one other than hexl-mode since the
+    ;; function `hexl-mode' does nothing if the current major-mode is
+    ;; already hexl-mode.
+    ;; 2. reset change-major-mode-hook in case that `hexl-mode'
+    ;; previously added hexl-maybe-dehexlify-buffer to it.
+    (remove-hook 'change-major-mode-hook 'hexl-maybe-dehexlify-buffer t)
+    (setq major-mode 'fundamental-mode)
+    (hexl-mode)))
+
 (defun hexl-mode-exit (&optional arg)
   "Exit Hexl mode, returning to previous mode.
 With arg, don't unhexlify buffer."
@@ -483,8 +494,6 @@
 	  (or (bobp) (setq original-point (1+ original-point))))
 	(goto-char original-point)))
 
-  (remove-hook 'before-revert-hook 'hexl-before-revert-hook t)
-  (remove-hook 'after-revert-hook 'hexl-after-revert-hook t)
   (remove-hook 'change-major-mode-hook 'hexl-maybe-dehexlify-buffer t)
   (remove-hook 'post-command-hook 'hexl-follow-ascii-find t)
   (setq hexl-ascii-overlay nil)
@@ -512,6 +521,7 @@
   (set-syntax-table hexl-mode-old-syntax-table)
   (setq font-lock-defaults hexl-mode-old-font-lock-keywords)
   (setq major-mode hexl-mode-old-major-mode)
+  (setq revert-buffer-function hexl-mode-old-revert-buffer-function)
   (force-mode-line-update))
 
 (defun hexl-maybe-dehexlify-buffer ()
--- a/lisp/image.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/image.el	Thu Oct 28 19:57:59 2010 +0900
@@ -330,14 +330,16 @@
   type)
 
 
-(defvar image-library-alist)
+(define-obsolete-variable-alias
+    'image-library-alist
+    'dynamic-library-alist "24.1")
 
 ;;;###autoload
 (defun image-type-available-p (type)
   "Return non-nil if image type TYPE is available.
 Image types are symbols like `xbm' or `jpeg'."
   (and (fboundp 'init-image-library)
-       (init-image-library type image-library-alist)))
+       (init-image-library type dynamic-library-alist)))
 
 
 ;;;###autoload
@@ -721,21 +723,6 @@
 	 (cons (concat "\\." extension "\\'") 'imagemagick)
 	 image-type-file-name-regexps)))))
 
-
-;;; Inline stock images
-
-(defvar image-checkbox-checked
-  (create-image "\300\300\141\143\067\076\034\030"
-		'xbm t :width 8 :height 8 :background "grey75"
-		:foreground "black" :relief -2 :ascent 'center)
-  "Image of a checked checkbox.")
-
-(defvar image-checkbox-unchecked
-  (create-image (make-string 8 0)
-		'xbm t :width 8 :height 8 :background "grey75"
-		:foreground "black" :relief -2 :ascent 'center)
-  "Image of an unchecked checkbox.")
-
 (provide 'image)
 
 ;; arch-tag: 8e76a07b-eb48-4f3e-a7a0-1a7ba9f096b3
--- a/lisp/international/ccl.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/international/ccl.el	Thu Oct 28 19:57:59 2010 +0900
@@ -1437,7 +1437,7 @@
 	;; Normal arithmethic operators (same meaning as C code).
 	+ | - | * | / | %
 
-	;; Bitwize operators (same meaning as C code)
+	;; Bitwise operators (same meaning as C code)
 	| & | `|' | ^
 
 	;; Shifting operators (same meaning as C code)
--- a/lisp/international/characters.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/international/characters.el	Thu Oct 28 19:57:59 2010 +0900
@@ -188,6 +188,9 @@
 			       cp932-2-byte))
   (map-charset-chars #'modify-category-entry l ?j))
 
+;; Fullwidth characters
+(modify-category-entry '(#xff01 . #xff60) ?\|)
+
 ;; Unicode equivalents of JISX0201-kana
 (let ((range '(#xff61 . #xff9f)))
   (modify-category-entry range  ?k)
--- a/lisp/international/fontset.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/international/fontset.el	Thu Oct 28 19:57:59 2010 +0900
@@ -700,7 +700,7 @@
 ;; "HP-Hebrew8"                                    [36]
 ;;         HPHEBREW8 8-bit character set
 ;; "HP-Japanese15"                                 [36]
-;;         HPJAPAN15 15-bit characer set,
+;;         HPJAPAN15 15-bit character set,
 ;;         modified from industry defacto
 ;;         standard Shift-JIS
 ;; "HP-Kana8"                                      [36]
--- a/lisp/international/mule.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/international/mule.el	Thu Oct 28 19:57:59 2010 +0900
@@ -646,7 +646,7 @@
 `write-region-annotate-functions' and `buffer-file-format' are
 called, and before the text is encoded by the coding system
 itself.  This function should convert the whole text in the
-current buffer.  For backward compatibility, this funciton is
+current buffer.  For backward compatibility, this function is
 passed two arguments which can be ignored.
 
 `:default-char'
--- a/lisp/international/titdic-cnv.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/international/titdic-cnv.el	Thu Oct 28 19:57:59 2010 +0900
@@ -108,7 +108,7 @@
 input method `chinese-qj'.")
 
     ("chinese-ecdict" "$(05CKH(B"
-"In this input method, you enter a Chinese (Big5) charactere or word
+"In this input method, you enter a Chinese (Big5) character or word
 by typing the corresponding English word.  For example, if you type
 \"computer\", \"$(0IZH+(B\" is input.
 
--- a/lisp/iswitchb.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/iswitchb.el	Thu Oct 28 19:57:59 2010 +0900
@@ -1033,7 +1033,9 @@
     (setq buf (car iswitchb-matches))
     ;; check to see if buf is non-nil.
     (if buf
-	(progn
+	(let ((bufobjs (mapcar (lambda (name)
+				 (or (get-buffer name) name))
+			       iswitchb-buflist)))
 	  (kill-buffer buf)
 
 	  ;; Check if buffer exists.  XEmacs gnuserv.el makes alias
@@ -1044,8 +1046,13 @@
 	      (setq iswitchb-rescan t)
 	    ;; Else `kill-buffer' succeeds so re-make the buffer list
 	    ;; taking into account packages like uniquify may rename
-	    ;; buffers
-	    (iswitchb-make-buflist iswitchb-default))))))
+	    ;; buffers, and try to preserve the ordering of buffers.
+	    (setq iswitchb-buflist
+		  (delq nil (mapcar (lambda (b)
+				      (if (bufferp b)
+					  (buffer-name b)
+					b))
+				    bufobjs))))))))
 
 ;;; VISIT CHOSEN BUFFER
 (defun iswitchb-visit-buffer (buffer)
--- a/lisp/loadup.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/loadup.el	Thu Oct 28 19:57:59 2010 +0900
@@ -234,15 +234,14 @@
       (load "disp-table"))) ; needed to setup ibm-pc char set, see internal.el
 (if (featurep 'ns)
     (progn
-      (load "emacs-lisp/easymenu")  ;; for platform-related menu adjustments
+      (load "term/common-win")
       (load "term/ns-win")))
 (if (fboundp 'x-create-frame)
     ;; Do it after loading term/foo-win.el since the value of the
     ;; mouse-wheel-*-event vars depends on those files being loaded or not.
     (load "mwheel"))
-(if (fboundp 'atan)	; preload some constants and
-    (progn		; floating pt. functions if we have float support.
-      (load "emacs-lisp/float-sup")))
+;; Preload some constants and floating point functions.
+(load "emacs-lisp/float-sup")
 
 (load "vc/vc-hooks")
 (load "vc/ediff-hook")
@@ -403,5 +402,4 @@
 ;; no-update-autoloads: t
 ;; End:
 
-;; arch-tag: 121e1dd4-36e1-45ac-860e-239f577a6335
 ;;; loadup.el ends here
--- a/lisp/ls-lisp.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/ls-lisp.el	Thu Oct 28 19:57:59 2010 +0900
@@ -637,7 +637,7 @@
 	    ;; They tend to be bogus on non-UNIX platforms anyway so
 	    ;; optionally hide them.
 	    (if (memq 'uid ls-lisp-verbosity)
-		;; uid can be a sting or an integer
+		;; uid can be a string or an integer
 		(let ((uid (nth 2 file-attr)))
                   (format (if (stringp uid)
 			      ls-lisp-uid-s-fmt
--- a/lisp/mail/emacsbug.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/mail/emacsbug.el	Thu Oct 28 19:57:59 2010 +0900
@@ -173,9 +173,9 @@
         (overlay-put (make-overlay pos (point)) 'face 'highlight))
       (insert " if possible, because the Emacs maintainers
 usually do not have translators to read other languages for them.\n\n")
-      (insert (format "Your bug report will be posted to the %s mailing list"
+      (insert (format "Your report will be posted to the %s mailing list"
 		      report-emacs-bug-address))
-	(insert ",\nand to the gnu.emacs.bug news group.\n\n"))
+      (insert "\nand the gnu.emacs.bug news group, and at http://debbugs.gnu.org.\n\n"))
 
     (insert "Please describe exactly what actions triggered the bug\n"
 	    "and the precise symptoms of the bug.  If you can, give\n"
@@ -377,5 +377,4 @@
 
 (provide 'emacsbug)
 
-;; arch-tag: 248b6523-c3b5-4fec-9a3f-0411fafa7d49
 ;;; emacsbug.el ends here
--- a/lisp/mail/mspools.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/mail/mspools.el	Thu Oct 28 19:57:59 2010 +0900
@@ -181,7 +181,8 @@
     (define-key map "q" 'mspools-quit)
     (define-key map "n" 'next-line)
     (define-key map "p" 'previous-line)
-    (define-key map "g" 'revert-buffer))
+    (define-key map "g" 'revert-buffer)
+    map)
   "Keymap for the *spools* buffer.")
 
 ;;; Code
--- a/lisp/mail/rmail.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/mail/rmail.el	Thu Oct 28 19:57:59 2010 +0900
@@ -2742,7 +2742,9 @@
 						 nil t 'unibyte)
 		  (message "Malformed MIME quoted-printable message")))
 	     ((and (string= character-coding "base64") is-text-message)
-	      (base64-decode-region (point-min) (point-max)))
+	      (condition-case err
+		  (base64-decode-region (point-min) (point-max))
+		(error (message "%s" (cdr err)))))
 	     ((eq character-coding 'uuencode)
 	      (error "uuencoded messages are not supported yet"))
 	     (t))
--- a/lisp/menu-bar.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/menu-bar.el	Thu Oct 28 19:57:59 2010 +0900
@@ -35,14 +35,33 @@
     (define-key global-map [menu-bar] (make-sparse-keymap "menu-bar")))
 (defvar menu-bar-help-menu (make-sparse-keymap "Help"))
 
-;; Force Help item to come last, after the major mode's own items.
-;; The symbol used to be called `help', but that gets confused with the
-;; help key.
-(setq menu-bar-final-items '(help-menu))
+(if (not (featurep 'ns))
+    ;; Force Help item to come last, after the major mode's own items.
+    ;; The symbol used to be called `help', but that gets confused with the
+    ;; help key.
+    (setq menu-bar-final-items '(help-menu))
+  (if (eq system-type 'darwin)
+      (setq menu-bar-final-items '(buffer services help-menu))
+    (setq menu-bar-final-items '(buffer services hide-app quit))
+    ;; Add standard top-level items to GNUstep menu.
+    (define-key global-map [menu-bar quit]
+      `(menu-item ,(purecopy "Quit") save-buffers-kill-emacs
+                  :help ,(purecopy "Save unsaved buffers, then exit")))
+    (define-key global-map [menu-bar hide-app]
+      `(menu-item ,(purecopy "Hide") ns-do-hide-emacs
+                  :help ,(purecopy "Hide Emacs"))))
+  (define-key global-map [menu-bar services] ; set-up in ns-win
+    (cons (purecopy "Services") (make-sparse-keymap "Services"))))
 
-(define-key global-map [menu-bar help-menu] (cons (purecopy "Help") menu-bar-help-menu))
+;; If running under GNUstep, "Help" is moved and renamed "Info" (see below).
+(or (and (featurep 'ns)
+         (not (eq system-type 'darwin)))
+    (define-key global-map [menu-bar help-menu]
+      (cons (purecopy "Help") menu-bar-help-menu)))
+
 (defvar menu-bar-tools-menu (make-sparse-keymap "Tools"))
-(define-key global-map [menu-bar tools] (cons (purecopy "Tools") menu-bar-tools-menu))
+(define-key global-map [menu-bar tools]
+  (cons (purecopy "Tools") menu-bar-tools-menu))
 ;; This definition is just to show what this looks like.
 ;; It gets modified in place when menu-bar-update-buffers is called.
 (defvar global-buffers-menu-map (make-sparse-keymap "Buffers"))
@@ -52,9 +71,17 @@
 (define-key global-map [menu-bar options]
   (cons (purecopy "Options") menu-bar-options-menu))
 (defvar menu-bar-edit-menu (make-sparse-keymap "Edit"))
-(define-key global-map [menu-bar edit] (cons (purecopy "Edit") menu-bar-edit-menu))
+(define-key global-map [menu-bar edit]
+  (cons (purecopy "Edit") menu-bar-edit-menu))
 (defvar menu-bar-file-menu (make-sparse-keymap "File"))
-(define-key global-map [menu-bar file] (cons (purecopy "File") menu-bar-file-menu))
+(define-key global-map [menu-bar file]
+  (cons (purecopy "File") menu-bar-file-menu))
+
+;; Put "Help" menu at the front, called "Info".
+(and (featurep 'ns)
+     (not (eq system-type 'darwin))
+     (define-key global-map [menu-bar help-menu]
+       (cons (purecopy "Info") menu-bar-help-menu)))
 
 ;; This alias is for compatibility with 19.28 and before.
 (defvar menu-bar-files-menu menu-bar-file-menu)
@@ -361,6 +388,11 @@
 (define-key menu-bar-edit-menu [props]
   `(menu-item ,(purecopy "Text Properties") facemenu-menu))
 
+;; ns-win.el said: Add spell for platorm consistency.
+(if (featurep 'ns)
+    (define-key menu-bar-edit-menu [spell]
+      `(menu-item ,(purecopy "Spell") ispell-menu-map)))
+
 (define-key menu-bar-edit-menu [fill]
   `(menu-item ,(purecopy "Fill") fill-region
 	      :enable (and mark-active (not buffer-read-only))
@@ -453,30 +485,45 @@
 	      ,(purecopy "Delete the text in region between mark and current position")))
 (defvar yank-menu (cons (purecopy "Select Yank") nil))
 (fset 'yank-menu (cons 'keymap yank-menu))
-(define-key menu-bar-edit-menu [paste-from-menu]
-  `(menu-item ,(purecopy "Paste from Kill Menu") yank-menu
+(define-key menu-bar-edit-menu (if (featurep 'ns) [select-paste]
+                                 [paste-from-menu])
+  ;; ns-win.el said: Change text to be more consistent with
+  ;; surrounding menu items `paste', etc."
+  `(menu-item ,(purecopy (if (featurep 'ns) "Select and Paste"
+                           "Paste from Kill Menu")) yank-menu
 	      :enable (and (cdr yank-menu) (not buffer-read-only))
 	      :help ,(purecopy "Choose a string from the kill ring and paste it")))
 (define-key menu-bar-edit-menu [paste]
   `(menu-item ,(purecopy "Paste") yank
 	      :enable (and (or
-			    ;; Emacs compiled --without-x doesn't have
-			    ;; x-selection-exists-p.
+			    ;; Emacs compiled --without-x (or --with-ns)
+			    ;; doesn't have x-selection-exists-p.
 			    (and (fboundp 'x-selection-exists-p)
 				 (x-selection-exists-p 'CLIPBOARD))
-			    kill-ring)
+			    (if (featurep 'ns) ; like paste-from-menu
+				(cdr yank-menu)
+			      kill-ring))
 			   (not buffer-read-only))
 	      :help ,(purecopy "Paste (yank) text most recently cut/copied")))
 (define-key menu-bar-edit-menu [copy]
-  `(menu-item ,(purecopy "Copy") menu-bar-kill-ring-save
-	      :enable mark-active
-	      :help ,(purecopy "Copy text in region between mark and current position")
-	      :keys ,(purecopy "\\[kill-ring-save]")))
+  ;; ns-win.el said: Substitute a Copy function that works better
+  ;; under X (for GNUstep).
+  `(menu-item ,(purecopy "Copy") ,(if (featurep 'ns)
+                                      'ns-copy-including-secondary
+                                    'menu-bar-kill-ring-save)
+              :enable mark-active
+              :help ,(purecopy "Copy text in region between mark and current position")
+              :keys ,(purecopy (if (featurep 'ns)
+                                   "\\[ns-copy-including-secondary]"
+                                 "\\[kill-ring-save]"))))
 (define-key menu-bar-edit-menu [cut]
   `(menu-item ,(purecopy "Cut") kill-region
 	      :enable (and mark-active (not buffer-read-only))
 	      :help
 	      ,(purecopy "Cut (kill) text in region between mark and current position")))
+;; ns-win.el said: Separate undo from cut/paste section.
+(if (featurep 'ns)
+    (define-key menu-bar-edit-menu [separator-undo] `(,(purecopy "--"))))
 (define-key menu-bar-edit-menu [undo]
   `(menu-item ,(purecopy "Undo") undo
 	      :enable (and (not buffer-read-only)
@@ -486,7 +533,6 @@
 			     (consp buffer-undo-list)))
 	      :help ,(purecopy "Undo last operation")))
 
-
 (defun menu-bar-kill-ring-save (beg end)
   (interactive "r")
   (if (mouse-region-match)
@@ -1008,47 +1054,47 @@
       (defvar menu-bar-showhide-tool-bar-menu (make-sparse-keymap "Tool-bar"))
 
       (define-key menu-bar-showhide-tool-bar-menu [showhide-tool-bar-left]
-	`(menu-item ,(purecopy "On the left") 
+	`(menu-item ,(purecopy "On the left")
 		    menu-bar-showhide-tool-bar-menu-customize-enable-left
 		    :help ,(purecopy "Tool-bar at the left side")
 		    :visible (display-graphic-p)
-		    :button 
-		    (:radio . (and tool-bar-mode 
+		    :button
+		    (:radio . (and tool-bar-mode
 				   (eq (frame-parameter nil 'tool-bar-position)
 				       'left)))))
 
       (define-key menu-bar-showhide-tool-bar-menu [showhide-tool-bar-right]
-	`(menu-item ,(purecopy "On the right") 
+	`(menu-item ,(purecopy "On the right")
 		    menu-bar-showhide-tool-bar-menu-customize-enable-right
 		    :help ,(purecopy "Tool-bar at the right side")
 		    :visible (display-graphic-p)
 		    :button
-		    (:radio . (and tool-bar-mode 
+		    (:radio . (and tool-bar-mode
 				   (eq (frame-parameter nil 'tool-bar-position)
 				       'right)))))
 
       (define-key menu-bar-showhide-tool-bar-menu [showhide-tool-bar-bottom]
-	`(menu-item ,(purecopy "On the bottom") 
+	`(menu-item ,(purecopy "On the bottom")
 		    menu-bar-showhide-tool-bar-menu-customize-enable-bottom
 		    :help ,(purecopy "Tool-bar at the bottom")
 		    :visible (display-graphic-p)
 		    :button
-		    (:radio . (and tool-bar-mode 
+		    (:radio . (and tool-bar-mode
 				   (eq (frame-parameter nil 'tool-bar-position)
 				       'bottom)))))
 
       (define-key menu-bar-showhide-tool-bar-menu [showhide-tool-bar-top]
-	`(menu-item ,(purecopy "On the top") 
+	`(menu-item ,(purecopy "On the top")
 		    menu-bar-showhide-tool-bar-menu-customize-enable-top
 		    :help ,(purecopy "Tool-bar at the top")
 		    :visible (display-graphic-p)
 		    :button
-		    (:radio . (and tool-bar-mode 
+		    (:radio . (and tool-bar-mode
 				   (eq (frame-parameter nil 'tool-bar-position)
 				       'top)))))
 
       (define-key menu-bar-showhide-tool-bar-menu [showhide-tool-bar-none]
-	`(menu-item ,(purecopy "None") 
+	`(menu-item ,(purecopy "None")
 		    menu-bar-showhide-tool-bar-menu-customize-disable
 		    :help ,(purecopy "Turn tool-bar off")
 		    :visible (display-graphic-p)
@@ -1668,6 +1714,13 @@
   `(menu-item ,(purecopy "Emacs Tutorial") help-with-tutorial
 	      :help ,(purecopy "Learn how to use Emacs")))
 
+;; In OS X it's in the app menu already.
+;; FIXME? There already is an "About Emacs" (sans ...) entry in the Help menu.
+(and (featurep 'ns)
+     (not (eq system-type 'darwin))
+     (define-key menu-bar-help-menu [info-panel]
+       `(menu-item ,(purecopy "About Emacs...") ns-do-emacs-info-panel)))
+
 (defun menu-bar-menu-frame-live-and-visible-p ()
   "Return non-nil if the menu frame is alive and visible.
 The menu frame is the frame for which we are updating the menu."
@@ -2082,5 +2135,4 @@
 
 (provide 'menu-bar)
 
-;; arch-tag: 6e6a3c22-4ec4-4d3d-8190-583f8ef94ced
 ;;; menu-bar.el ends here
--- a/lisp/minibuffer.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/minibuffer.el	Thu Oct 28 19:57:59 2010 +0900
@@ -508,10 +508,11 @@
       (setq suffix-len (1+ suffix-len)))
     (unless (zerop suffix-len)
       (setq end (- end suffix-len))
-      (setq newtext (substring newtext 0 (- suffix-len)))))
-  (goto-char beg)
-  (insert newtext)
-  (delete-region (point) (+ (point) (- end beg))))
+      (setq newtext (substring newtext 0 (- suffix-len))))
+    (goto-char beg)
+    (insert newtext)
+    (delete-region (point) (+ (point) (- end beg)))
+    (forward-char suffix-len)))
 
 (defcustom completion-cycle-threshold nil
   "Number of completion candidates below which cycling is used.
@@ -525,6 +526,10 @@
           (const :tag "Always cycle" t)
           (integer :tag "Threshold")))
 
+(defvar completion-all-sorted-completions nil)
+(make-variable-buffer-local 'completion-all-sorted-completions)
+(defvar completion-cycling nil)
+
 (defun completion--do-completion (&optional try-completion-function)
   "Do the completion and return a summary of what happened.
 M = completion was performed, the text was Modified.
@@ -557,7 +562,7 @@
      ((eq t comp)
       (minibuffer-hide-completions)
       (goto-char (field-end))
-      (minibuffer--bitset nil nil t)) ;Exact and unique match.
+      (minibuffer--bitset nil nil t))   ;Exact and unique match.
      (t
       ;; `completed' should be t if some completion was done, which doesn't
       ;; include simply changing the case of the entered string.  However,
@@ -577,11 +582,11 @@
 	(forward-char (- comp-pos (length completion)))
 
         (if (not (or unchanged completed))
-	   ;; The case of the string changed, but that's all.  We're not sure
-	   ;; whether this is a unique completion or not, so try again using
-	   ;; the real case (this shouldn't recurse again, because the next
-	   ;; time try-completion will return either t or the exact string).
-           (completion--do-completion try-completion-function)
+            ;; The case of the string changed, but that's all.  We're not sure
+            ;; whether this is a unique completion or not, so try again using
+            ;; the real case (this shouldn't recurse again, because the next
+            ;; time try-completion will return either t or the exact string).
+            (completion--do-completion try-completion-function)
 
           ;; It did find a match.  Do we match some possibility exactly now?
           (let ((exact (test-completion completion
@@ -604,35 +609,34 @@
                                          ""))
                                    comp-pos)))
                    (completion-all-sorted-completions))))
-            (setq completion-all-sorted-completions nil)
+            (completion--flush-all-sorted-completions)
             (cond
-             ((and (not (ignore-errors
+             ((and (consp (cdr comps)) ;; There's something to cycle.
+                   (not (ignore-errors
                           ;; This signal an (intended) error if comps is too
                           ;; short or if completion-cycle-threshold is t.
-                          (consp (nthcdr completion-cycle-threshold comps))))
-                   ;; More than 1, so there's something to cycle.
-                   (consp (cdr comps)))
+                          (consp (nthcdr completion-cycle-threshold comps)))))
               ;; Fewer than completion-cycle-threshold remaining
               ;; completions: let's cycle.
               (setq completed t exact t)
               (setq completion-all-sorted-completions comps)
               (minibuffer-force-complete))
              (completed
-                ;; We could also decide to refresh the completions,
-                ;; if they're displayed (and assuming there are
-                ;; completions left).
+              ;; We could also decide to refresh the completions,
+              ;; if they're displayed (and assuming there are
+              ;; completions left).
               (minibuffer-hide-completions))
-              ;; Show the completion table, if requested.
-               ((not exact)
-                (if (case completion-auto-help
-                      (lazy (eq this-command last-command))
-                      (t completion-auto-help))
-                    (minibuffer-completion-help)
-                  (minibuffer-message "Next char not unique")))
-               ;; If the last exact completion and this one were the same, it
-               ;; means we've already given a "Next char not unique" message
-               ;; and the user's hit TAB again, so now we give him help.
-               ((eq this-command last-command)
+             ;; Show the completion table, if requested.
+             ((not exact)
+              (if (case completion-auto-help
+                    (lazy (eq this-command last-command))
+                    (t completion-auto-help))
+                  (minibuffer-completion-help)
+                (minibuffer-message "Next char not unique")))
+             ;; If the last exact completion and this one were the same, it
+             ;; means we've already given a "Next char not unique" message
+             ;; and the user's hit TAB again, so now we give him help.
+             ((eq this-command last-command)
               (if completion-auto-help (minibuffer-completion-help))))
 
             (minibuffer--bitset completed t exact))))))))
@@ -647,7 +651,7 @@
   ;; If the previous command was not this,
   ;; mark the completion buffer obsolete.
   (unless (eq this-command last-command)
-    (setq completion-all-sorted-completions nil)
+    (completion--flush-all-sorted-completions)
     (setq minibuffer-scroll-window nil))
 
   (cond
@@ -663,7 +667,7 @@
 	    (scroll-other-window))
         nil)))
    ;; If we're cycling, keep on cycling.
-   (completion-all-sorted-completions
+   ((and completion-cycling completion-all-sorted-completions)
     (minibuffer-force-complete)
     t)
    (t (case (completion--do-completion)
@@ -674,10 +678,8 @@
                t)
         (t     t)))))
 
-(defvar completion-all-sorted-completions nil)
-(make-variable-buffer-local 'completion-all-sorted-completions)
-
 (defun completion--flush-all-sorted-completions (&rest ignore)
+  (setq completion-cycling nil)
   (setq completion-all-sorted-completions nil))
 
 (defun completion-all-sorted-completions ()
@@ -719,6 +721,7 @@
          (all (completion-all-sorted-completions)))
     (if (not (consp all))
         (minibuffer-message (if all "No more completions" "No completions"))
+      (setq completion-cycling t)
       (goto-char end)
       (insert (car all))
       (delete-region (+ start (cdr (last all))) end)
--- a/lisp/net/mairix.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/net/mairix.el	Thu Oct 28 19:57:59 2010 +0900
@@ -748,7 +748,7 @@
     (define-key map [(e)] 'mairix-select-edit)
     (define-key map [(d)] 'mairix-select-delete)
     (define-key map [(s)] 'mairix-select-save)
-    (setq mairix-searches-mode-map map))
+    map)
   "'mairix-searches-mode' keymap.")
 
 (defvar mairix-searches-mode-font-lock-keywords)
--- a/lisp/net/tls.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/net/tls.el	Thu Oct 28 19:57:59 2010 +0900
@@ -75,13 +75,9 @@
   :type 'regexp
   :group 'tls)
 
-(defvar tls-starttls-switches
-  '(("openssl" "-starttls imap"))
-  "Alist of programs and the switches necessary to get starttls behaviour.")
-
 (defcustom tls-program '("gnutls-cli --insecure -p %p %h"
 			 "gnutls-cli --insecure -p %p %h --protocols ssl3"
-			 "openssl s_client %s -connect %h:%p -no_ssl2 -ign_eof")
+			 "openssl s_client -connect %h:%p -no_ssl2 -ign_eof")
   "List of strings containing commands to start TLS stream to a host.
 Each entry in the list is tried until a connection is successful.
 %h is replaced with server hostname, %p with port to connect to.
@@ -203,7 +199,7 @@
 	    (push (cons (match-string 1) (match-string 2)) vals))
 	  (nreverse vals))))))
 
-(defun open-tls-stream (name buffer host port &optional starttlsp)
+(defun open-tls-stream (name buffer host port)
   "Open a TLS connection for a port to a host.
 Returns a subprocess-object to represent the connection.
 Input and output work as for subprocesses; `delete-process' closes it.
@@ -233,9 +229,6 @@
 	       (format-spec
 		cmd
 		(format-spec-make
-		 ?s (if starttlsp
-			(tls-find-starttls-argument cmd)
-		      "")
 		 ?h host
 		 ?p (if (integerp port)
 			(int-to-string port)
@@ -307,11 +300,6 @@
       (kill-buffer buffer))
     done))
 
-(defun tls-find-starttls-argument (command)
-  (let ((command (car (split-string command))))
-    (or (cadr (assoc command tls-starttls-switches))
-	"")))
-
 (provide 'tls)
 
 ;;; tls.el ends here
--- a/lisp/net/tramp-sh.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/net/tramp-sh.el	Thu Oct 28 19:57:59 2010 +0900
@@ -67,7 +67,7 @@
   :group 'tramp
   :type 'string)
 
-;; ksh on OpenBSD 4.5 requires, that PS1 contains a `#' character for
+;; ksh on OpenBSD 4.5 requires, that $PS1 contains a `#' character for
 ;; root users.  It uses the `$' character for other users.  In order
 ;; to guarantee a proper prompt, we use "#$" for the prompt.
 
@@ -1241,7 +1241,7 @@
    (format
     ;; On Opsware, pdksh (which is the true name of ksh there) doesn't
     ;; parse correctly the sequence "((".  Therefore, we add a space.
-    "( (%s %s || %s -h %s) && %s -c '( (\"%%N\") %%h %s %s %%X.0 %%Y.0 %%Z.0 %%s.0 \"%%A\" t %%i.0 -1)' %s || echo nil)"
+    "( (%s %s || %s -h %s) && %s -c '((\"%%N\") %%h %s %s %%Xe0 %%Ye0 %%Ze0 %%se0 \"%%A\" t %%ie0 -1)' %s || echo nil)"
     (tramp-get-file-exists-command vec)
     (tramp-shell-quote-argument localname)
     (tramp-get-test-command vec)
@@ -1629,7 +1629,7 @@
      ;; but it does not work on all remote systems.  Therefore, we
      ;; quote the filenames via sed.
      "cd %s; echo \"(\"; (%s -a | sed -e s/\\$/\\\"/g -e s/^/\\\"/g | xargs "
-     "%s -c '(\"%%n\" (\"%%N\") %%h %s %s %%X.0 %%Y.0 %%Z.0 %%s.0 \"%%A\" t %%i.0 -1)'); "
+     "%s -c '(\"%%n\" (\"%%N\") %%h %s %s %%Xe0 %%Ye0 %%Ze0 %%se0 \"%%A\" t %%ie0 -1)'); "
      "echo \")\"")
     (tramp-shell-quote-argument localname)
     (tramp-get-ls-command vec)
@@ -3709,9 +3709,7 @@
 	;; because we're running on a non-MULE Emacs.  Let's try
 	;; stty, instead.
 	(tramp-send-command vec "stty -onlcr" t))))
-  ;; Dump stty settings in the traces.
-  (when (>= tramp-verbose 9)
-    (tramp-send-command vec "stty -a" t))
+
   (tramp-send-command vec "set +o vi +o emacs" t)
 
   ;; Check whether the output of "uname -sr" has been changed.  If
@@ -3782,12 +3780,21 @@
   (when (string-match "^IRIX64" (tramp-get-connection-property vec "uname" ""))
     (tramp-send-command vec "set +H" t))
 
+  ;; On BSD-like systems, ?\t is expanded to spaces.  Suppress this.
+  (when (string-match "BSD\\|Darwin"
+		      (tramp-get-connection-property vec "uname" ""))
+    (tramp-send-command vec "stty -oxtabs" t))
+
   ;; Set `remote-tty' process property.
   (ignore-errors
     (let ((tty (tramp-send-command-and-read vec "echo \\\"`tty`\\\"")))
       (unless (zerop (length tty))
 	(tramp-compat-process-put proc 'remote-tty tty))))
 
+  ;; Dump stty settings in the traces.
+  (when (>= tramp-verbose 9)
+    (tramp-send-command vec "stty -a" t))
+
   ;; Set the environment.
   (tramp-message vec 5 "Setting default environment")
 
@@ -4352,6 +4359,11 @@
       ;; We mark the command string that it can be erased in the output buffer.
       (tramp-set-connection-property p "check-remote-echo" t)
       (setq command (format "%s%s%s" tramp-echo-mark command tramp-echo-mark)))
+    (when (string-match "<<'EOF'" command)
+      ;; Unset $PS1 when using here documents, in order not to get
+      ;; several prompts.
+      (setq command (concat "(PS1= ; " command "\n)")))
+    ;; Send the command.
     (tramp-message vec 6 "%s" command)
     (tramp-send-string vec command)
     (unless nooutput (tramp-wait-for-output p))))
@@ -4890,54 +4902,57 @@
 Otherwise, either a string is returned which contains a `%s' mark
 to be used for the respective input or output file; or a Lisp
 function cell is returned to be applied on a buffer."
-  (let ((coding
-	 (with-connection-property vec prop
-	   (tramp-find-inline-encoding vec)
-	   (tramp-get-connection-property vec prop nil)))
-	(prop1 (if (string-match "encoding" prop)
-		   "inline-compress" "inline-decompress"))
-	compress)
-    ;; The connection property might have been cached.  So we must send
-    ;; the script to the remote side - maybe.
-    (when (and coding (symbolp coding) (string-match "remote" prop))
-      (let ((name (symbol-name coding)))
-	(while (string-match (regexp-quote "-") name)
-	  (setq name (replace-match "_" nil t name)))
-	(tramp-maybe-send-script vec (symbol-value coding) name)
-	(setq coding name)))
-    (when coding
-      ;; Check for the `compress' command.
-      (setq compress (tramp-get-inline-compress vec prop1 size))
-      ;; Return the value.
-      (cond
-       ((and compress (symbolp coding))
-	(if (string-match "decompress" prop1)
+  ;; We must catch the errors, because we want to return `nil', when
+  ;; no inline coding is found.
+  (ignore-errors
+    (let ((coding
+	   (with-connection-property vec prop
+	     (tramp-find-inline-encoding vec)
+	     (tramp-get-connection-property vec prop nil)))
+	  (prop1 (if (string-match "encoding" prop)
+		     "inline-compress" "inline-decompress"))
+	  compress)
+      ;; The connection property might have been cached.  So we must
+      ;; send the script to the remote side - maybe.
+      (when (and coding (symbolp coding) (string-match "remote" prop))
+	(let ((name (symbol-name coding)))
+	  (while (string-match (regexp-quote "-") name)
+	    (setq name (replace-match "_" nil t name)))
+	  (tramp-maybe-send-script vec (symbol-value coding) name)
+	  (setq coding name)))
+      (when coding
+	;; Check for the `compress' command.
+	(setq compress (tramp-get-inline-compress vec prop1 size))
+	;; Return the value.
+	(cond
+	 ((and compress (symbolp coding))
+	  (if (string-match "decompress" prop1)
+	      `(lambda (beg end)
+		 (,coding beg end)
+		 (let ((coding-system-for-write 'binary)
+		       (coding-system-for-read 'binary))
+		   (apply
+		    'call-process-region (point-min) (point-max)
+		    (car (split-string ,compress)) t t nil
+		    (cdr (split-string ,compress)))))
 	    `(lambda (beg end)
-	       (,coding beg end)
 	       (let ((coding-system-for-write 'binary)
 		     (coding-system-for-read 'binary))
 		 (apply
-		  'call-process-region (point-min) (point-max)
+		  'call-process-region beg end
 		  (car (split-string ,compress)) t t nil
-		  (cdr (split-string ,compress)))))
-	  `(lambda (beg end)
-	     (let ((coding-system-for-write 'binary)
-		   (coding-system-for-read 'binary))
-	       (apply
-		'call-process-region beg end
-		(car (split-string ,compress)) t t nil
-		(cdr (split-string ,compress))))
-	     (,coding (point-min) (point-max)))))
-       ((symbolp coding)
-	coding)
-       ((and compress (string-match "decoding" prop))
-	(format "(%s | %s >%%s)" coding compress))
-       (compress
-	(format "(%s <%%s | %s)" compress coding))
-       ((string-match "decoding" prop)
-	(format "%s >%%s" coding))
-       (t
-	(format "%s <%%s" coding))))))
+		  (cdr (split-string ,compress))))
+	       (,coding (point-min) (point-max)))))
+	 ((symbolp coding)
+	  coding)
+	 ((and compress (string-match "decoding" prop))
+	  (format "(%s | %s >%%s)" coding compress))
+	 (compress
+	  (format "(%s <%%s | %s)" compress coding))
+	 ((string-match "decoding" prop)
+	  (format "%s >%%s" coding))
+	 (t
+	  (format "%s <%%s" coding)))))))
 
 ;;; Integration of eshell.el:
 
--- a/lisp/newcomment.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/newcomment.el	Thu Oct 28 19:57:59 2010 +0900
@@ -1164,8 +1164,8 @@
 (defun comment-dwim (arg)
   "Call the comment command you want (Do What I Mean).
 If the region is active and `transient-mark-mode' is on, call
-  `comment-region' (unless it only consists of comments, in which
-  case it calls `uncomment-region').
+`comment-region' (unless it only consists of comments, in which
+case it calls `uncomment-region').
 Else, if the current line is empty, call `comment-insert-comment-function'
 if it is defined, otherwise insert a comment and indent it.
 Else if a prefix ARG is specified, call `comment-kill'.
--- a/lisp/nxml/nxml-mode.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/nxml/nxml-mode.el	Thu Oct 28 19:57:59 2010 +0900
@@ -404,6 +404,7 @@
     (define-key map "\M-}" 'nxml-forward-paragraph)
     (define-key map "\M-h" 'nxml-mark-paragraph)
     (define-key map "\C-c\C-f" 'nxml-finish-element)
+    (define-key map "\C-c]" 'nxml-finish-element)
     (define-key map "\C-c/" 'nxml-finish-element)
     (define-key map "\C-c\C-m" 'nxml-split-element)
     (define-key map "\C-c\C-b" 'nxml-balanced-close-start-tag-block)
--- a/lisp/obsolete/lazy-lock.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/obsolete/lazy-lock.el	Thu Oct 28 19:57:59 2010 +0900
@@ -310,7 +310,7 @@
 ;; User Variables:
 
 (defcustom lazy-lock-minimum-size 25600
-  "*Minimum size of a buffer for demand-driven fontification.
+  "Minimum size of a buffer for demand-driven fontification.
 On-demand fontification occurs if the buffer size is greater than this value.
 If nil, means demand-driven fontification is never performed.
 If a list, each element should be a cons pair of the form (MAJOR-MODE . SIZE),
@@ -334,7 +334,7 @@
   :group 'lazy-lock)
 
 (defcustom lazy-lock-defer-on-the-fly t
-  "*If non-nil, means fontification after a change should be deferred.
+  "If non-nil, means fontification after a change should be deferred.
 If nil, means on-the-fly fontification is performed.  This means when changes
 occur in the buffer, those areas are immediately fontified.
 If a list, it should be a list of `major-mode' symbol names for which deferred
@@ -354,7 +354,7 @@
   :group 'lazy-lock)
 
 (defcustom lazy-lock-defer-on-scrolling nil
-  "*If non-nil, means fontification after a scroll should be deferred.
+  "If non-nil, means fontification after a scroll should be deferred.
 If nil, means demand-driven fontification is performed.  This means when
 scrolling into unfontified areas of the buffer, those areas are immediately
 fontified.  Thus scrolling never presents unfontified areas.  However, since
@@ -379,7 +379,7 @@
   :group 'lazy-lock)
 
 (defcustom lazy-lock-defer-contextually 'syntax-driven
-  "*If non-nil, means deferred fontification should be syntactically true.
+  "If non-nil, means deferred fontification should be syntactically true.
 If nil, means deferred fontification occurs only on those lines modified.  This
 means where modification on a line causes syntactic change on subsequent lines,
 those subsequent lines are not refontified to reflect their new context.
@@ -396,9 +396,8 @@
 		 (other :tag "syntax-driven" syntax-driven))
   :group 'lazy-lock)
 
-(defcustom lazy-lock-defer-time
-  (if (featurep 'lisp-float-type) (/ (float 1) (float 4)) 1)
-  "*Time in seconds to delay before beginning deferred fontification.
+(defcustom lazy-lock-defer-time 0.25
+  "Time in seconds to delay before beginning deferred fontification.
 Deferred fontification occurs if there is no input within this time.
 If nil, means fontification is never deferred, regardless of the values of the
 variables `lazy-lock-defer-on-the-fly', `lazy-lock-defer-on-scrolling' and
@@ -410,7 +409,7 @@
   :group 'lazy-lock)
 
 (defcustom lazy-lock-stealth-time 30
-  "*Time in seconds to delay before beginning stealth fontification.
+  "Time in seconds to delay before beginning stealth fontification.
 Stealth fontification occurs if there is no input within this time.
 If nil, means stealth fontification is never performed.
 
@@ -420,7 +419,7 @@
   :group 'lazy-lock)
 
 (defcustom lazy-lock-stealth-lines (if font-lock-maximum-decoration 100 250)
-  "*Maximum size of a chunk of stealth fontification.
+  "Maximum size of a chunk of stealth fontification.
 Each iteration of stealth fontification can fontify this number of lines.
 To speed up input response during stealth fontification, at the cost of stealth
 taking longer to fontify, you could reduce the value of this variable."
@@ -429,7 +428,7 @@
 
 (defcustom lazy-lock-stealth-load
   (if (condition-case nil (load-average) (error)) 200)
-  "*Load in percentage above which stealth fontification is suspended.
+  "Load in percentage above which stealth fontification is suspended.
 Stealth fontification pauses when the system short-term load average (as
 returned by the function `load-average' if supported) goes above this level,
 thus reducing the demand that stealth fontification makes on the system.
@@ -443,9 +442,8 @@
 	  '(const :format "%t: unsupported\n" nil))
   :group 'lazy-lock)
 
-(defcustom lazy-lock-stealth-nice
-  (if (featurep 'lisp-float-type) (/ (float 1) (float 8)) 1)
-  "*Time in seconds to pause between chunks of stealth fontification.
+(defcustom lazy-lock-stealth-nice 0.125
+  "Time in seconds to pause between chunks of stealth fontification.
 Each iteration of stealth fontification is separated by this amount of time,
 thus reducing the demand that stealth fontification makes on the system.
 If nil, means stealth fontification is never paused.
@@ -457,9 +455,8 @@
   :group 'lazy-lock)
 
 (defcustom lazy-lock-stealth-verbose
-  (if (featurep 'lisp-float-type)
-      (and (not lazy-lock-defer-contextually) (not (null font-lock-verbose))))
-  "*If non-nil, means stealth fontification should show status messages."
+  (and (not lazy-lock-defer-contextually) (not (null font-lock-verbose)))
+  "If non-nil, means stealth fontification should show status messages."
   :type 'boolean
   :group 'lazy-lock)
 
@@ -1058,5 +1055,4 @@
 ;; byte-compile-warnings: (not obsolete)
 ;; End:
 
-;; arch-tag: c1776846-f046-4a45-9684-54b951b12fc9
 ;;; lazy-lock.el ends here
--- a/lisp/org/ChangeLog	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/org/ChangeLog	Thu Oct 28 19:57:59 2010 +0900
@@ -7798,7 +7798,7 @@
 
 2008-10-26  James TD Smith  <ahktenzero@mohorovi.cc>
 
-	* org.el (org-add-log-setup): Only skip drawers if the are
+	* org.el (org-add-log-setup): Only skip drawers if they are
 	immediately after the scheduling keywords.
 
 	* org-clock.el (org-clock-in-switch-to-state): Allow this to be a
--- a/lisp/paren.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/paren.el	Thu Oct 28 19:57:59 2010 +0900
@@ -52,8 +52,7 @@
   :type '(choice (const parenthesis) (const expression) (const mixed))
   :group 'paren-showing)
 
-(defcustom show-paren-delay
-  (if (featurep 'lisp-float-type) (/ (float 1) (float 8)) 1)
+(defcustom show-paren-delay 0.125
   "Time in seconds to delay before showing a matching paren."
   :type '(number :tag "seconds")
   :group 'paren-showing)
@@ -253,5 +252,4 @@
 
 (provide 'paren)
 
-;; arch-tag: d0969b88-7ac0-4bd0-bd53-e73b892b86a9
 ;;; paren.el ends here
--- a/lisp/play/landmark.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/play/landmark.el	Thu Oct 28 19:57:59 2010 +0900
@@ -30,31 +30,31 @@
 
 
 ;;; Commentary:
-;;; Lm is a relatively non-participatory game in which a robot
-;;; attempts to maneuver towards a tree at the center of the window
-;;; based on unique olfactory cues from each of the 4 directions. If
-;;; the smell of the tree increases, then the weights in the robot's
-;;; brain are adjusted to encourage this odor-driven behavior in the
-;;; future. If the smell of the tree decreases, the robots weights are
-;;; adjusted to discourage a correct move.
+;; Lm is a relatively non-participatory game in which a robot
+;; attempts to maneuver towards a tree at the center of the window
+;; based on unique olfactory cues from each of the 4 directions. If
+;; the smell of the tree increases, then the weights in the robot's
+;; brain are adjusted to encourage this odor-driven behavior in the
+;; future. If the smell of the tree decreases, the robots weights are
+;; adjusted to discourage a correct move.
 
-;;; In laymen's terms, the search space is initially flat. The point
-;;; of training is to "turn up the edges of the search space" so that
-;;; the robot rolls toward the center.
+;; In laymen's terms, the search space is initially flat. The point
+;; of training is to "turn up the edges of the search space" so that
+;; the robot rolls toward the center.
 
-;;; Further, do not become alarmed if the robot appears to oscillate
-;;; back and forth between two or a few positions. This simply means
-;;; it is currently caught in a local minimum and is doing its best to
-;;; work its way out.
+;; Further, do not become alarmed if the robot appears to oscillate
+;; back and forth between two or a few positions. This simply means
+;; it is currently caught in a local minimum and is doing its best to
+;; work its way out.
 
-;;; The version of this program as described has a small problem. a
-;;; move in a net direction can produce gross credit assignment. for
-;;; example, if moving south will produce positive payoff, then, if in
-;;; a single move, one moves east,west and south, then both east and
-;;; west will be improved when they shouldn't
+;; The version of this program as described has a small problem. a
+;; move in a net direction can produce gross credit assignment. for
+;; example, if moving south will produce positive payoff, then, if in
+;; a single move, one moves east,west and south, then both east and
+;; west will be improved when they shouldn't
 
-;;; Many thanks to Yuri Pryadkin (yuri@rana.usc.edu) for this
-;;; concise problem description.
+;; Many thanks to Yuri Pryadkin (yuri@rana.usc.edu) for this
+;; concise problem description.
 
 ;;;_* Require
 (eval-when-compile (require 'cl))
@@ -303,47 +303,47 @@
 ;; these values will change (hopefully improve) the strength of the program
 ;; and may change its style (rather aggressive here).
 
-(defconst nil-score	  7  "Score of an empty qtuple.")
-(defconst Xscore	 15  "Score of a qtuple containing one X.")
-(defconst XXscore	400  "Score of a qtuple containing two X's.")
-(defconst XXXscore     1800  "Score of a qtuple containing three X's.")
-(defconst XXXXscore  100000  "Score of a qtuple containing four X's.")
-(defconst Oscore	 35  "Score of a qtuple containing one O.")
-(defconst OOscore	800  "Score of a qtuple containing two O's.")
-(defconst OOOscore    15000  "Score of a qtuple containing three O's.")
-(defconst OOOOscore  800000  "Score of a qtuple containing four O's.")
+(defconst lm-nil-score	  7  "Score of an empty qtuple.")
+
+(defconst lm-score-trans-table
+  (let ((Xscore		15)  ; Score of a qtuple containing one X.
+        (XXscore       400)  ; Score of a qtuple containing two X's.
+        (XXXscore     1800)  ; Score of a qtuple containing three X's.
+        (XXXXscore  100000)  ; Score of a qtuple containing four X's.
+        (Oscore		35)  ; Score of a qtuple containing one O.
+        (OOscore       800)  ; Score of a qtuple containing two O's.
+        (OOOscore    15000)  ; Score of a qtuple containing three O's.
+        (OOOOscore  800000)) ; Score of a qtuple containing four O's.
 
-;; These values are not just random: if, given the following situation:
-;;
-;;			  . . . . . . . O .
-;;			  . X X a . . . X .
-;;			  . . . X . . . X .
-;;			  . . . X . . . X .
-;;			  . . . . . . . b .
-;;
-;; you want Emacs to play in "a" and not in "b", then the parameters must
-;; satisfy the inequality:
-;;
-;;		   6 * XXscore > XXXscore + XXscore
-;;
-;; because "a" mainly belongs to six "XX" qtuples (the others are less
-;; important) while "b" belongs to one "XXX" and one "XX" qtuples.  Other
-;; conditions are required to obtain sensible moves, but the previous example
-;; should illustrate the point. If you manage to improve on these values,
-;; please send me a note. Thanks.
+    ;; These values are not just random: if, given the following situation:
+    ;;
+    ;;			  . . . . . . . O .
+    ;;			  . X X a . . . X .
+    ;;			  . . . X . . . X .
+    ;;			  . . . X . . . X .
+    ;;			  . . . . . . . b .
+    ;;
+    ;; you want Emacs to play in "a" and not in "b", then the parameters must
+    ;; satisfy the inequality:
+    ;;
+    ;;		   6 * XXscore > XXXscore + XXscore
+    ;;
+    ;; because "a" mainly belongs to six "XX" qtuples (the others are less
+    ;; important) while "b" belongs to one "XXX" and one "XX" qtuples.
+    ;; Other conditions are required to obtain sensible moves, but the
+    ;; previous example should illustrate the point.  If you manage to
+    ;; improve on these values, please send me a note.  Thanks.
 
 
-;; As we chose values 0, 1 and 6 to denote empty, X and O squares, the
-;; contents of a qtuple are uniquely determined by the sum of its elements and
-;; we just have to set up a translation table.
-
-(defconst lm-score-trans-table
-  (vector nil-score Xscore XXscore XXXscore XXXXscore 0
-	  Oscore    0	   0	   0	    0	      0
-	  OOscore   0	   0	   0	    0	      0
-	  OOOscore  0	   0	   0	    0	      0
-	  OOOOscore 0	   0	   0	    0	      0
-	  0)
+    ;; As we chose values 0, 1 and 6 to denote empty, X and O squares,
+    ;; the contents of a qtuple are uniquely determined by the sum of
+    ;; its elements and we just have to set up a translation table.
+    (vector lm-nil-score Xscore XXscore XXXscore XXXXscore 0
+            Oscore       0	0	0	 0	   0
+            OOscore      0	0	0	 0	   0
+            OOOscore     0	0	0	 0	   0
+            OOOOscore    0	0	0	 0	   0
+            0))
   "Vector associating qtuple contents to their score.")
 
 
@@ -354,10 +354,12 @@
 ;; qtuple. We may use these considerations to detect when a given move is
 ;; winning or loosing.
 
-(defconst lm-winning-threshold OOOOscore
+(defconst lm-winning-threshold
+  (aref lm-score-trans-table (+ 6 6 6 6)) ;; OOOOscore
   "Threshold score beyond which an Emacs move is winning.")
 
-(defconst lm-loosing-threshold XXXXscore
+(defconst lm-loosing-threshold
+  (aref lm-score-trans-table (+ 1 1 1 1)) ;; XXXXscore
   "Threshold score beyond which a human move is winning.")
 
 
@@ -423,7 +425,7 @@
       (setq lm-score-table (copy-sequence lm-saved-score-table))
       ;; No, compute it:
       (setq lm-score-table
-	    (make-vector lm-vector-length (* 20 nil-score)))
+	    (make-vector lm-vector-length (* 20 lm-nil-score)))
       (let (i j maxi maxj maxi2 maxj2)
 	(setq maxi  (/ (1+ lm-board-width) 2)
 	      maxj  (/ (1+ lm-board-height) 2)
--- a/lisp/progmodes/cc-fonts.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/progmodes/cc-fonts.el	Thu Oct 28 19:57:59 2010 +0900
@@ -1045,6 +1045,9 @@
 	  ;; The position of the next token after the closing paren of
 	  ;; the last detected cast.
 	  last-cast-end
+	  ;; Start of containing declaration (if any); limit for searching
+	  ;; backwards for it.
+	  decl-start decl-search-lim
 	  ;; The result from `c-forward-decl-or-cast-1'.
 	  decl-or-cast
 	  ;; The maximum of the end positions of all the checked type
@@ -1184,20 +1187,29 @@
 				match-pos context last-cast-end))
 
 	    (if (not decl-or-cast)
-		;; Are we at a declarator?
-		;; Try to go back to the declaration to check this.
-		(let (paren-state bod-res lim encl-pos is-typedef)
+		;; Are we at a declarator?  Try to go back to the declaration
+		;; to check this.  Note that `c-beginning-of-decl-1' is slow,
+		;; so we cache its result between calls.
+		(let (paren-state bod-res encl-pos is-typedef)
 		  (goto-char start-pos)
 		  (save-excursion
-		    (setq lim (and (c-syntactic-skip-backward "^;" nil t)
-				   (point))))
+		    (unless (and decl-search-lim
+				 (eq decl-search-lim
+				     (save-excursion
+				       (c-syntactic-skip-backward "^;" nil t)
+				       (point))))
+		      (setq decl-search-lim
+			    (and (c-syntactic-skip-backward "^;" nil t) (point)))
+		      (setq bod-res (car (c-beginning-of-decl-1 decl-search-lim)))
+		      (if (and (eq bod-res 'same)
+			       (progn
+				 (c-backward-syntactic-ws)
+				 (eq (char-before) ?\})))
+			  (c-beginning-of-decl-1 decl-search-lim))
+		      (setq decl-start (point))))
+
 		  (save-excursion
-		    (setq bod-res (car (c-beginning-of-decl-1 lim)))
-		    (if (and (eq bod-res 'same)
-			     (progn
-			       (c-backward-syntactic-ws)
-			       (eq (char-before) ?\})))
-			(c-beginning-of-decl-1 lim))
+		    (goto-char decl-start)
 		    ;; We're now putatively at the declaration.
 		    (setq paren-state (c-parse-state))
 		    ;; At top level or inside a "{"?
--- a/lisp/progmodes/cc-langs.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/progmodes/cc-langs.el	Thu Oct 28 19:57:59 2010 +0900
@@ -2676,15 +2676,15 @@
   c++  (concat "\\("
 	       "[*\(&]"
 	       "\\|"
-	       (concat "\\("	; 2
+	       (c-lang-const c-type-decl-prefix-key)
+	       "\\|"
+	       (concat "\\("   ; 3
 		       ;; If this matches there's special treatment in
 		       ;; `c-font-lock-declarators' and
 		       ;; `c-font-lock-declarations' that check for a
 		       ;; complete name followed by ":: *".
 		       (c-lang-const c-identifier-start)
 		       "\\)")
-	       "\\|"
-	       (c-lang-const c-type-decl-prefix-key)
 	       "\\)"
 	       "\\([^=]\\|$\\)")
   pike "\\(\\*\\)\\([^=]\\|$\\)")
--- a/lisp/progmodes/cc-mode.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/progmodes/cc-mode.el	Thu Oct 28 19:57:59 2010 +0900
@@ -1029,10 +1029,6 @@
 			    (buffer-substring-no-properties type-pos term-pos)
 			    (buffer-substring-no-properties beg end)))))))
 
-	;; (c-new-BEG c-new-END) will be the region to fontify.  It may become
-	;; larger than (beg end).
-	(setq c-new-BEG beg
-	      c-new-END end)
 	(if c-get-state-before-change-functions
 	    (mapc (lambda (fn)
 		    (funcall fn beg end))
@@ -1086,6 +1082,10 @@
 	(when c-recognize-<>-arglists
 	  (c-after-change-check-<>-operators beg end))
 
+	;; (c-new-BEG c-new-END) will be the region to fontify.  It may become
+	;; larger than (beg end).
+	(setq c-new-BEG beg
+	      c-new-END end)
 	(if c-before-font-lock-function
 	    (save-excursion
 	      (funcall c-before-font-lock-function beg end old-len)))))))
--- a/lisp/progmodes/compile.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/progmodes/compile.el	Thu Oct 28 19:57:59 2010 +0900
@@ -543,7 +543,7 @@
      ;; 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)
+     (" -\\(?:o[= ]?\\|-\\(?:outfile\\|output\\)[= ]\\)\\(\\S +\\)" . 1)
      ("^Compilation \\(finished\\).*"
       (0 '(face nil message nil help-echo nil mouse-face nil) t)
       (1 compilation-info-face))
--- a/lisp/progmodes/dcl-mode.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/progmodes/dcl-mode.el	Thu Oct 28 19:57:59 2010 +0900
@@ -409,7 +409,7 @@
 is defined as dcl-electric-character.
 
 E.g.: if this list contains `endif', the key `f' is defined as
-dcl-electric-character and the you have just typed the `f' in
+dcl-electric-character and you have just typed the `f' in
 `endif', the line will be reindented."
   :type '(repeat regexp)
   :group 'dcl)
--- a/lisp/progmodes/f90.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/progmodes/f90.el	Thu Oct 28 19:57:59 2010 +0900
@@ -657,6 +657,7 @@
     (define-key map "\C-c\C-f" 'f90-fill-region)
     (define-key map "\C-c\C-p" 'f90-previous-statement)
     (define-key map "\C-c\C-n" 'f90-next-statement)
+    (define-key map "\C-c]"    'f90-insert-end)
     (define-key map "\C-c\C-w" 'f90-insert-end)
     ;; Standard tab binding will call this, and also handle regions.
 ;;;    (define-key map "\t"       'f90-indent-line)
--- a/lisp/progmodes/octave-mod.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/progmodes/octave-mod.el	Thu Oct 28 19:57:59 2010 +0900
@@ -646,9 +646,8 @@
                                      (aref (cdr kw) (1- (length (cdr kw)))))
                                    smie-closer-alist))))))
 
-  ;; FIXME: maybe we should use (cons ?\; electric-indent-chars)
-  ;; since only ; is really octave-specific.
-  (set (make-local-variable 'electric-indent-chars) '(?\; ?\s ?\n))
+  (set (make-local-variable 'electric-indent-chars)
+       (cons ?\; electric-indent-chars))
 
   (set (make-local-variable 'comment-start) octave-comment-start)
   (set (make-local-variable 'comment-end) "")
--- a/lisp/progmodes/ruby-mode.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/progmodes/ruby-mode.el	Thu Oct 28 19:57:59 2010 +0900
@@ -135,11 +135,9 @@
 (defconst ruby-symbol-re (concat "[" ruby-symbol-chars "]")
   "Regexp to match symbols.")
 
-(defvar ruby-mode-abbrev-table nil
+(define-abbrev-table 'ruby-mode-abbrev-table ()
   "Abbrev table in use in Ruby mode buffers.")
 
-(define-abbrev-table 'ruby-mode-abbrev-table ())
-
 (defvar ruby-mode-map
   (let ((map (make-sparse-keymap)))
     (define-key map "{" 'ruby-electric-brace)
@@ -1430,8 +1428,6 @@
    )
   "Additional expressions to highlight in Ruby mode.")
 
-(defvar electric-indent-chars)
-
 ;;;###autoload
 (define-derived-mode ruby-mode prog-mode "Ruby"
   "Major mode for editing Ruby scripts.
@@ -1456,8 +1452,7 @@
    'ruby-mode-set-encoding nil 'local)
 
   (set (make-local-variable 'electric-indent-chars)
-       (append '(?\{ ?\}) (if (boundp 'electric-indent-chars)
-                              (default-value 'electric-indent-chars))))
+       (append '(?\{ ?\}) electric-indent-chars))
 
   (set (make-local-variable 'font-lock-defaults)
        '((ruby-font-lock-keywords) nil nil))
--- a/lisp/progmodes/verilog-mode.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/progmodes/verilog-mode.el	Thu Oct 28 19:57:59 2010 +0900
@@ -3,12 +3,12 @@
 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
 ;;   2005, 2006, 2007, 2008, 2009, 2010  Free Software Foundation, Inc.
 
-;; Author: Michael McNamara (mac@verilog.com)
-;;  http://www.verilog.com
+;; Author: Michael McNamara (mac@verilog.com),
+;;    Wilson Snyder (wsnyder@wsnyder.org)
+;; Please see our web sites:
+;;    http://www.verilog.com
+;;    http://www.veripool.org
 ;;
-;; AUTO features, signal, modsig; by: Wilson Snyder
-;;	(wsnyder@wsnyder.org)
-;;	http://www.veripool.org
 ;; Keywords: languages
 
 ;; Yoni Rabkin <yoni@rabkins.net> contacted the maintainer of this
@@ -81,15 +81,21 @@
 ; (autoload 'verilog-mode "verilog-mode" "Verilog mode" t )
 ; (add-to-list 'auto-mode-alist '("\\.[ds]?vh?\\'" . verilog-mode))
 
-;; If you want to customize Verilog mode to fit your needs better,
-;; you may add these lines (the values of the variables presented
-;; here are the defaults). Note also that if you use an Emacs that
-;; supports custom, it's probably better to use the custom menu to
-;; edit these.
-;;
 ;; Be sure to examine at the help for verilog-auto, and the other
 ;; verilog-auto-* functions for some major coding time savers.
 ;;
+;; If you want to customize Verilog mode to fit your needs better,
+;; you may add the below lines (the values of the variables presented
+;; here are the defaults). Note also that if you use an Emacs that
+;; supports custom, it's probably better to use the custom menu to
+;; edit these. If working as a member of a large team these settings
+;; should be common across all users (in a site-start file), or set
+;; in Local Variables in every file.  Otherwise, different people's
+;; AUTO expansion may result different whitespace changes.
+;;
+; ;; Enable syntax highlighting of **all** languages
+; (global-font-lock-mode t)
+;
 ; ;; User customization for Verilog mode
 ; (setq verilog-indent-level             3
 ;       verilog-indent-level-module      3
@@ -118,9 +124,9 @@
 ;;; Code:
 
 ;; This variable will always hold the version number of the mode
-(defconst verilog-mode-version "565"
+(defconst verilog-mode-version "647"
   "Version of this Verilog mode.")
-(defconst verilog-mode-release-date "2010-03-01-GNU"
+(defconst verilog-mode-release-date "2010-10-20-GNU"
   "Release date of this Verilog mode.")
 (defconst verilog-mode-release-emacs t
   "If non-nil, this version of Verilog mode was released with Emacs itself.")
@@ -213,7 +219,14 @@
       ;; We have an intermediate custom-library, hack around it!
       (defmacro customize-group (var &rest args)
         `(customize ,var))
-      ))
+      )
+
+    (unless (boundp 'inhibit-point-motion-hooks)
+      (defvar inhibit-point-motion-hooks nil))
+    (unless (boundp 'deactivate-mark)
+      (defvar deactivate-mark nil))
+    )
+  ;;
   ;; OK, do this stuff if we are NOT XEmacs:
   (unless (featurep 'xemacs)
     (unless (fboundp 'region-active-p)
@@ -260,10 +273,21 @@
     ;; Emacs.
     (defalias 'verilog-regexp-opt 'regexp-opt)))
 
+(eval-and-compile
+  ;; Both xemacs and emacs
+  (condition-case nil
+      (unless (fboundp 'buffer-chars-modified-tick)  ;; Emacs 22 added
+	(defmacro buffer-chars-modified-tick () (buffer-modified-tick)))
+    (error nil)))
+
 (eval-when-compile
   (defun verilog-regexp-words (a)
     "Call 'regexp-opt' with word delimiters for the words A."
     (concat "\\<" (verilog-regexp-opt a t) "\\>")))
+(defun verilog-regexp-words (a)
+  "Call 'regexp-opt' with word delimiters for the words A."
+  ;; The FAQ references this function, so user LISP sometimes calls it
+  (concat "\\<" (verilog-regexp-opt a t) "\\>"))
 
 (defun verilog-easy-menu-filter (menu)
   "Filter `easy-menu-define' MENU to support new features."
@@ -338,6 +362,9 @@
   "Customize AUTO actions when expanding Verilog source text."
   :group 'verilog-mode)
 
+(defvar verilog-debug nil
+  "If set, enable debug messages for `verilog-mode' internals.")
+
 (defcustom verilog-linter
   "echo 'No verilog-linter set, see \"M-x describe-variable verilog-linter\"'"
   "*Unix program and arguments to call to run a lint checker on Verilog source.
@@ -378,11 +405,27 @@
   :group 'verilog-mode-actions)
 ;; We don't mark it safe, as it's used as a shell command
 
+(defcustom verilog-preprocessor
+  ;; Very few tools give preprocessed output, so we'll default to Verilog-Perl
+  "vppreproc __FLAGS__ __FILE__"
+  "*Program and arguments to use to preprocess Verilog source.
+This is invoked with `verilog-preprocess', and depending on the
+`verilog-set-compile-command', may also be invoked when you type
+\\[compile].  When the compile completes, \\[next-error] will
+take you to the next lint error."
+  :type 'string
+  :group 'verilog-mode-actions)
+;; We don't mark it safe, as it's used as a shell command
+
+(defvar verilog-preprocess-history nil
+  "History for `verilog-preprocess'.")
+
 (defvar verilog-tool 'verilog-linter
   "Which tool to use for building compiler-command.
-Either nil, `verilog-linter, `verilog-coverage, `verilog-simulator, or
-`verilog-compiler.  Alternatively use the \"Choose Compilation Action\"
-menu.  See `verilog-set-compile-command' for more information.")
+Either nil, `verilog-linter, `verilog-compiler,
+`verilog-coverage, `verilog-preprocessor, or `verilog-simulator.
+Alternatively use the \"Choose Compilation Action\" menu.  See
+`verilog-set-compile-command' for more information.")
 
 (defcustom verilog-highlight-translate-off nil
   "*Non-nil means background-highlight code excluded from translation.
@@ -572,6 +615,23 @@
   :type 'boolean)
 (put 'verilog-highlight-grouping-keywords 'safe-local-variable 'verilog-booleanp)
 
+(defcustom verilog-highlight-modules nil
+  "*True means highlight module statements for `verilog-load-file-at-point'.
+When true, mousing over module names will allow jumping to the
+module definition.  If false, this is not supported.  Setting
+this is experimental, and may lead to bad performance."
+  :group 'verilog-mode-indent
+  :type 'boolean)
+(put 'verilog-highlight-modules 'safe-local-variable 'verilog-booleanp)
+
+(defcustom verilog-highlight-includes t
+  "*True means highlight module statements for `verilog-load-file-at-point'.
+When true, mousing over include file names will allow jumping to the
+file referenced.  If false, this is not supported."
+  :group 'verilog-mode-indent
+  :type 'boolean)
+(put 'verilog-highlight-includes 'safe-local-variable 'verilog-booleanp)
+
 (defcustom verilog-auto-endcomments t
   "*True means insert a comment /* ... */ after 'end's.
 The name of the function or case will be set between the braces."
@@ -640,9 +700,7 @@
 ;;; Compile support
 (require 'compile)
 (defvar verilog-error-regexp-added nil)
-; List of regexps for Verilog compilers, like verilint. See compilation-error-regexp-alist
-;   for the formatting.
-; Here is the version for Emacs 22:
+
 (defvar verilog-error-regexp-emacs-alist
   '(
     (verilog-xl-1
@@ -650,7 +708,7 @@
     (verilog-xl-2
      "([WE][0-9A-Z]+)[ \t]+\\([^ \t\n,]+\\)[, \t]+\\(line[ \t]+\\)?\\([0-9]+\\):.*$" 1 3)
     (verilog-IES
-     ".*\\*[WE],[0-9A-Z]+ (\\([^ \t,]+\\),\\([0-9]+\\)" 1 2)
+     ".*\\*[WE],[0-9A-Z]+\\(\[[0-9A-Z_,]+\]\\)? (\\([^ \t,]+\\),\\([0-9]+\\)" 2 3)
     (verilog-surefire-1
      "[^\n]*\\[\\([^:]+\\):\\([0-9]+\\)\\]" 1 2)
     (verilog-surefire-2
@@ -672,87 +730,64 @@
     (verilog-verilator
      "%?\\(Error\\|Warning\\)\\(-[^:]+\\|\\):[\n ]*\\([^ \t:]+\\):\\([0-9]+\\):" 3 4)
     (verilog-leda
-     "In file \\([^ \t]+\\)[ \t]+line[ \t]+\\([0-9]+\\):
-.*
-.*
-.*
-\\(Warning\\|Error\\|Failure\\)" 1 2)
-    ))
-;; And the version for XEmacs:
+     "^In file \\([^ \t]+\\)[ \t]+line[ \t]+\\([0-9]+\\):\n[^\n]*\n[^\n]*\n\\(Warning\\|Error\\|Failure\\)[^\n]*" 1 2)
+    )
+  "List of regexps for Verilog compilers.
+See `compilation-error-regexp-alist' for the formatting.  For Emacs 22+.")
+
 (defvar verilog-error-regexp-xemacs-alist
-  '(verilog
-    ("[^\n]*\\[\\([^:]+\\):\\([0-9]+\\)\\]" 1 2)
-    ("\\(WARNING\\|ERROR\\|INFO\\)[^:]*: \\([^,]+\\),\\s-+\\(line \\)?\\([0-9]+\\):" 2 4 )
-    ("\
-\\([a-zA-Z]?:?[^:( \t\n]+\\)[:(][ \t]*\\([0-9]+\\)\\([) \t]\\|\
-:\\([^0-9\n]\\|\\([0-9]+:\\)\\)\\)" 1 2 5)
-; xsim
-; Error! in file /homes/mac/Axis/Xsim/test.v at line 13		[OBJ_NOT_DECLARED]
-    ("\\(Error\\|Warning\\).*in file (\\([^ \t]+\\) at line *\\([0-9]+\\))" 2 3)
-; vcs
-    ("\\(Error\\|Warning\\):[^(]*(\\([^ \t]+\\) line *\\([0-9]+\\))" 2 3)
-    ("Warning:.*(port.*(\\([^ \t]+\\) line \\([0-9]+\\))" 1 2)
-    ("\\(Error\\|Warning\\):[\n.]*\\([^ \t]+\\) *\\([0-9]+\\):" 2 3)
-    ("syntax error:.*\n\\([^ \t]+\\) *\\([0-9]+\\):" 1 2)
-; Verilator
-    ("%?\\(Error\\|Warning\\)\\(-[^:]+\\|\\):[\n ]*\\([^ \t:]+\\):\\([0-9]+\\):" 3 4)
-; verilog-xl
-    ("\\(Error\\|Warning\\)!.*\n?.*\"\\([^\"]+\\)\", \\([0-9]+\\)" 2 3)
-    ("([WE][0-9A-Z]+)[ \t]+\\([^ \t\n,]+\\)[, \t]+\\([0-9]+\\):.*$" 1 2)	       ; vxl
-    ("([WE][0-9A-Z]+)[ \t]+\\([^ \t\n,]+\\)[, \t]+line[ \t]+\\([0-9]+\\):.*$" 1 2)
-; nc-verilog
-    (".*\\*[WE],[0-9A-Z]+ (\\([^ \t,]+\\),\\([0-9]+\\)|" 1 2)
-; Leda
-    ("In file \\([^ \t]+\\)[ \t]+line[ \t]+\\([0-9]+\\):\n[^\n]*\n[^\n]*\n\\[\\(Warning\\|Error\\|Failure\\)\\][^\n]*" 1 2)
-    )
-  )
+  ;; Emacs form is '((v-tool "re" 1 2) ...)
+  ;; XEmacs form is '(verilog ("re" 1 2) ...)
+  ;; So we can just map from Emacs to Xemacs
+  (cons 'verilog (mapcar 'cdr verilog-error-regexp-emacs-alist))
+  "List of regexps for Verilog compilers.
+See `compilation-error-regexp-alist-alist' for the formatting.  For XEmacs.")
 
 (defvar verilog-error-font-lock-keywords
   '(
+    ;; verilog-xl-1
+    ("\\(Error\\|Warning\\)!.*\n?.*\"\\([^\"]+\\)\", \\([0-9]+\\)" 2 bold t)
+    ("\\(Error\\|Warning\\)!.*\n?.*\"\\([^\"]+\\)\", \\([0-9]+\\)" 2 bold t)
+    ;; verilog-xl-2
+    ("([WE][0-9A-Z]+)[ \t]+\\([^ \t\n,]+\\)[, \t]+\\(line[ \t]+\\)?\\([0-9]+\\):.*$" 1 bold t)
+    ("([WE][0-9A-Z]+)[ \t]+\\([^ \t\n,]+\\)[, \t]+\\(line[ \t]+\\)?\\([0-9]+\\):.*$" 3 bold t)
+    ;; verilog-IES (nc-verilog)
+    (".*\\*[WE],[0-9A-Z]+\\(\[[0-9A-Z_,]+\]\\)? (\\([^ \t,]+\\),\\([0-9]+\\)|" 2 bold t)
+    (".*\\*[WE],[0-9A-Z]+\\(\[[0-9A-Z_,]+\]\\)? (\\([^ \t,]+\\),\\([0-9]+\\)|" 3 bold t)
+    ;; verilog-surefire-1
     ("[^\n]*\\[\\([^:]+\\):\\([0-9]+\\)\\]" 1 bold t)
     ("[^\n]*\\[\\([^:]+\\):\\([0-9]+\\)\\]" 2 bold t)
-
+    ;; verilog-surefire-2
     ("\\(WARNING\\|ERROR\\|INFO\\): \\([^,]+\\), line \\([0-9]+\\):" 2 bold t)
     ("\\(WARNING\\|ERROR\\|INFO\\): \\([^,]+\\), line \\([0-9]+\\):" 3 bold t)
-
+    ;; verilog-verbose
     ("\
 \\([a-zA-Z]?:?[^:( \t\n]+\\)[:(][ \t]*\\([0-9]+\\)\\([) \t]\\|\
 :\\([^0-9\n]\\|\\([0-9]+:\\)\\)\\)" 1 bold t)
     ("\
 \\([a-zA-Z]?:?[^:( \t\n]+\\)[:(][ \t]*\\([0-9]+\\)\\([) \t]\\|\
 :\\([^0-9\n]\\|\\([0-9]+:\\)\\)\\)" 1 bold t)
-
+    ;; verilog-vcs-1
     ("\\(Error\\|Warning\\):[^(]*(\\([^ \t]+\\) line *\\([0-9]+\\))" 2 bold t)
     ("\\(Error\\|Warning\\):[^(]*(\\([^ \t]+\\) line *\\([0-9]+\\))" 3 bold t)
-
-    ("%?\\(Error\\|Warning\\)\\(-[^:]+\\|\\):[\n ]*\\([^ \t:]+\\):\\([0-9]+\\):" 3 bold t)
-    ("%?\\(Error\\|Warning\\)\\(-[^:]+\\|\\):[\n ]*\\([^ \t:]+\\):\\([0-9]+\\):" 4 bold t)
-
+    ;; verilog-vcs-2
     ("Warning:.*(port.*(\\([^ \t]+\\) line \\([0-9]+\\))" 1 bold t)
     ("Warning:.*(port.*(\\([^ \t]+\\) line \\([0-9]+\\))" 1 bold t)
-
+    ;; verilog-vcs-3
     ("\\(Error\\|Warning\\):[\n.]*\\([^ \t]+\\) *\\([0-9]+\\):" 2 bold t)
     ("\\(Error\\|Warning\\):[\n.]*\\([^ \t]+\\) *\\([0-9]+\\):" 3 bold t)
-
+    ;; verilog-vcs-4
     ("syntax error:.*\n\\([^ \t]+\\) *\\([0-9]+\\):" 1 bold t)
     ("syntax error:.*\n\\([^ \t]+\\) *\\([0-9]+\\):" 2 bold t)
-       ; vxl
-    ("\\(Error\\|Warning\\)!.*\n?.*\"\\([^\"]+\\)\", \\([0-9]+\\)" 2 bold t)
-    ("\\(Error\\|Warning\\)!.*\n?.*\"\\([^\"]+\\)\", \\([0-9]+\\)" 2 bold t)
-
-    ("([WE][0-9A-Z]+)[ \t]+\\([^ \t\n,]+\\)[, \t]+\\([0-9]+\\):.*$" 1 bold t)
-    ("([WE][0-9A-Z]+)[ \t]+\\([^ \t\n,]+\\)[, \t]+\\([0-9]+\\):.*$" 2 bold t)
-
-    ("([WE][0-9A-Z]+)[ \t]+\\([^ \t\n,]+\\)[, \t]+line[ \t]+\\([0-9]+\\):.*$" 1 bold t)
-    ("([WE][0-9A-Z]+)[ \t]+\\([^ \t\n,]+\\)[, \t]+line[ \t]+\\([0-9]+\\):.*$" 2 bold t)
-        ; nc-verilog
-    (".*[WE],[0-9A-Z]+ (\\([^ \t,]+\\),\\([0-9]+\\)|" 1 bold t)
-    (".*[WE],[0-9A-Z]+ (\\([^ \t,]+\\),\\([0-9]+\\)|" 2 bold t)
-       ; Leda
-    ("In file \\([^ \t]+\\)[ \t]+line[ \t]+\\([0-9]+\\):\n[^\n]*\n[^\n]*\n\\[\\(Warning\\|Error\\|Failure\\)\\][^\n]*" 1 bold t)
-    ("In file \\([^ \t]+\\)[ \t]+line[ \t]+\\([0-9]+\\):\n[^\n]*\n[^\n]*\n\\[\\(Warning\\|Error\\|Failure\\)\\][^\n]*" 2 bold t)
+    ;; verilog-verilator
+    (".*%?\\(Error\\|Warning\\)\\(-[^:]+\\|\\):[\n ]*\\([^ \t:]+\\):\\([0-9]+\\):" 3 bold t)
+    (".*%?\\(Error\\|Warning\\)\\(-[^:]+\\|\\):[\n ]*\\([^ \t:]+\\):\\([0-9]+\\):" 4 bold t)
+    ;; verilog-leda
+    ("^In file \\([^ \t]+\\)[ \t]+line[ \t]+\\([0-9]+\\):\n[^\n]*\n[^\n]*\n\\(Warning\\|Error\\|Failure\\)[^\n]*" 1 bold t)
+    ("^In file \\([^ \t]+\\)[ \t]+line[ \t]+\\([0-9]+\\):\n[^\n]*\n[^\n]*\n\\(Warning\\|Error\\|Failure\\)[^\n]*" 2 bold t)
     )
-  "*Keywords to also highlight in Verilog *compilation* buffers.")
+  "*Keywords to also highlight in Verilog *compilation* buffers.
+Only used in XEmacs; GNU Emacs uses `verilog-error-regexp-emacs-alist'.")
 
 (defcustom verilog-library-flags '("")
   "*List of standard Verilog arguments to use for /*AUTOINST*/.
@@ -888,6 +923,16 @@
   :type 'boolean)
 (put 'verilog-auto-arg-sort 'safe-local-variable 'verilog-booleanp)
 
+(defcustom verilog-auto-inst-dot-name nil
+  "*If true, when creating ports with AUTOINST, use .name syntax.
+This will use \".port\" instead of \".port(port)\" when possible.
+This is only legal in SystemVerilog files, and will confuse older
+simulators.  Setting `verilog-auto-inst-vector' to nil may also
+be desirable to increase how often .name will be used."
+  :group 'verilog-mode-auto
+  :type 'boolean)
+(put 'verilog-auto-inst-dot-name 'safe-local-variable 'verilog-booleanp)
+
 (defcustom verilog-auto-inst-param-value nil
   "*If set, AUTOINST will replace parameters with the parameter value.
 If nil, leave parameters as symbolic names.
@@ -899,7 +944,7 @@
 For example, imagine a submodule uses parameters to declare the size of its
 inputs.  This is then used by a upper module:
 
-	module InstModule (o,i)
+	module InstModule (o,i);
 	   parameter WIDTH;
 	   input [WIDTH-1:0] i;
 	endmodule
@@ -971,6 +1016,13 @@
   :type 'string)
 (put 'verilog-auto-output-ignore-regexp 'safe-local-variable 'stringp)
 
+(defcustom verilog-auto-tieoff-ignore-regexp nil
+  "*If set, when creating AUTOTIEOFF list, ignore signals matching this regexp.
+See the \\[verilog-faq] for examples on using this."
+  :group 'verilog-mode-auto
+  :type 'string)
+(put 'verilog-auto-tieoff-ignore-regexp 'safe-local-variable 'stringp)
+
 (defcustom verilog-auto-unused-ignore-regexp nil
   "*If set, when creating AUTOUNUSED list, ignore signals matching this regexp.
 See the \\[verilog-faq] for examples on using this."
@@ -1080,6 +1132,7 @@
     (define-key map "\C-c\C-k" 'verilog-delete-auto)
     (define-key map "\C-c\C-a" 'verilog-auto)
     (define-key map "\C-c\C-s" 'verilog-auto-save-compile)
+    (define-key map "\C-c\C-p" 'verilog-preprocess)
     (define-key map "\C-c\C-z" 'verilog-inject-auto)
     (define-key map "\C-c\C-e" 'verilog-expand-vector)
     (define-key map "\C-c\C-h" 'verilog-header)
@@ -1127,6 +1180,13 @@
        :style radio
        :selected (equal verilog-tool `verilog-compiler)
        :help "When invoking compilation, compile Verilog source"]
+      ["Preprocessor"
+       (progn
+	 (setq verilog-tool 'verilog-preprocessor)
+	 (verilog-set-compile-command))
+       :style radio
+       :selected (equal verilog-tool `verilog-preprocessor)
+       :help "When invoking compilation, preprocess Verilog source, see also `verilog-preprocess'"]
       )
      ("Move"
       ["Beginning of function"		verilog-beg-of-defun
@@ -1318,6 +1378,20 @@
 ;;  Macros
 ;;
 
+(defsubst verilog-get-beg-of-line (&optional arg)
+  (save-excursion
+    (beginning-of-line arg)
+    (point)))
+
+(defsubst verilog-get-end-of-line (&optional arg)
+  (save-excursion
+    (end-of-line arg)
+    (point)))
+
+(defsubst verilog-within-string ()
+  (save-excursion
+    (nth 3 (parse-partial-sexp (verilog-get-beg-of-line) (point)))))
+
 (defsubst verilog-string-replace-matches (from-string to-string fixedcase literal string)
   "Replace occurrences of FROM-STRING with TO-STRING.
 FIXEDCASE and LITERAL as in `replace-match`.  STRING is what to replace.
@@ -1394,19 +1468,45 @@
 	  (setq pt (match-end 0))))
     pt))
 
-(defsubst verilog-get-beg-of-line (&optional arg)
-  (save-excursion
-    (beginning-of-line arg)
-    (point)))
-
-(defsubst verilog-get-end-of-line (&optional arg)
-  (save-excursion
-    (end-of-line arg)
-    (point)))
-
-(defsubst verilog-within-string ()
-  (save-excursion
-    (nth 3 (parse-partial-sexp (verilog-get-beg-of-line) (point)))))
+(defsubst verilog-re-search-forward-substr (substr regexp bound noerror)
+  "Like `re-search-forward', but first search for SUBSTR constant.
+Then searched for the normal REGEXP (which contains SUBSTR), with given
+BOUND and NOERROR.  The REGEXP must fit within a single line.
+This speeds up complicated regexp matches."
+  ;; Problem with overlap: search-forward BAR then FOOBARBAZ won't match.
+  ;; thus require matches to be on one line, and use beginning-of-line.
+  (let (done)
+    (while (and (not done)
+		(search-forward substr bound noerror))
+      (save-excursion
+	(beginning-of-line)
+	(setq done (re-search-forward regexp (verilog-get-end-of-line) noerror)))
+      (unless (and (<= (match-beginning 0) (point))
+		   (>= (match-end 0) (point)))
+	(setq done nil)))
+    (when done (goto-char done))
+    done))
+;;(verilog-re-search-forward-substr "-end" "get-end-of" nil t) ;;-end (test bait)
+
+(defsubst verilog-re-search-backward-substr (substr regexp bound noerror)
+  "Like `re-search-backward', but first search for SUBSTR constant.
+Then searched for the normal REGEXP (which contains SUBSTR), with given
+BOUND and NOERROR.  The REGEXP must fit within a single line.
+This speeds up complicated regexp matches."
+  ;; Problem with overlap: search-backward BAR then FOOBARBAZ won't match.
+  ;; thus require matches to be on one line, and use beginning-of-line.
+  (let (done)
+    (while (and (not done)
+		(search-backward substr bound noerror))
+      (save-excursion
+	(end-of-line)
+	(setq done (re-search-backward regexp (verilog-get-beg-of-line) noerror)))
+      (unless (and (<= (match-beginning 0) (point))
+		   (>= (match-end 0) (point)))
+	(setq done nil)))
+    (when done (goto-char done))
+    done))
+;;(verilog-re-search-backward-substr "-end" "get-end-of" nil t) ;;-end (test bait)
 
 (defvar compile-command)
 
@@ -1418,10 +1518,11 @@
 program that executes when you type \\[compile] or
 \\[verilog-auto-save-compile].
 
-By default `verilog-tool' uses a Makefile if one exists in the current
-directory.  If not, it is set to the `verilog-linter', `verilog-coverage',
-`verilog-simulator', or `verilog-compiler' variables, as selected with the
-Verilog -> \"Choose Compilation Action\" menu.
+By default `verilog-tool' uses a Makefile if one exists in the
+current directory.  If not, it is set to the `verilog-linter',
+`verilog-compiler', `verilog-coverage', `verilog-preprocessor',
+or `verilog-simulator' variables, as selected with the Verilog ->
+\"Choose Compilation Action\" menu.
 
 You should set `verilog-tool' or the other variables to the path and
 arguments for your Verilog simulator.  For example:
@@ -1433,8 +1534,12 @@
 value of `verilog-tool'; in the later, the path to the current buffer is
 substituted for the %s.
 
-Where __FILE__ appears in the string, the `buffer-file-name' of the
-current buffer, without the directory portion, will be substituted."
+Where __FLAGS__ appears in the string `verilog-current-flags'
+will be substituted.
+
+Where __FILE__ appears in the string, the variable
+`buffer-file-name' of the current buffer, without the directory
+portion, will be substituted."
   (interactive)
   (cond
    ((or (file-exists-p "makefile")	;If there is a makefile, use it
@@ -1451,18 +1556,29 @@
 	    ""))))
   (verilog-modify-compile-command))
 
+(defun verilog-expand-command (command)
+  "Replace meta-information in COMMAND and return it.
+Where __FLAGS__ appears in the string `verilog-current-flags'
+will be substituted.  Where __FILE__ appears in the string, the
+current buffer's file-name, without the directory portion, will
+be substituted."
+  (setq command	(verilog-string-replace-matches
+		 ;; Note \\b only works if under verilog syntax table
+		 "\\b__FLAGS__\\b" (verilog-current-flags)
+		 t t command))
+  (setq command	(verilog-string-replace-matches
+		 "\\b__FILE__\\b" (file-name-nondirectory
+				   (or (buffer-file-name) ""))
+		 t t command))
+  command)
+
 (defun verilog-modify-compile-command ()
-  "Replace meta-information in `compile-command'.
-Where __FILE__ appears in the string, the current buffer's file-name,
-without the directory portion, will be substituted."
+  "Update `compile-command' using `verilog-expand-command'."
   (when (and
 	 (stringp compile-command)
-	 (string-match "\\b__FILE__\\b" compile-command))
+	 (string-match "\\b\\(__FLAGS__\\|__FILE__\\)\\b" compile-command))
     (make-local-variable 'compile-command)
-    (setq compile-command
-	  (verilog-string-replace-matches
-	   "\\b__FILE__\\b" (file-name-nondirectory (buffer-file-name))
-	   t t compile-command))))
+    (setq compile-command (verilog-expand-command compile-command))))
 
 (if (featurep 'xemacs)
     ;; Following code only gets called from compilation-mode-hook on XEmacs to add error handling.
@@ -1511,11 +1627,13 @@
 (if (featurep 'emacs) (add-hook 'compilation-mode-hook 'verilog-error-regexp-add-emacs))
 
 (defconst verilog-directive-re
-  ;; "`case" "`default" "`define" "`define" "`else" "`endfor" "`endif"
-  ;; "`endprotect" "`endswitch" "`endwhile" "`for" "`format" "`if" "`ifdef"
-  ;; "`ifndef" "`include" "`let" "`protect" "`switch" "`timescale"
-  ;; "`time_scale" "`undef" "`while"
-  "\\<`\\(case\\|def\\(ault\\|ine\\(\\)?\\)\\|e\\(lse\\|nd\\(for\\|if\\|protect\\|switch\\|while\\)\\)\\|for\\(mat\\)?\\|i\\(f\\(def\\|ndef\\)?\\|nclude\\)\\|let\\|protect\\|switch\\|time\\(_scale\\|scale\\)\\|undef\\|while\\)\\>")
+  (eval-when-compile
+    (verilog-regexp-words
+     '(
+   "`case" "`default" "`define" "`else" "`elsif" "`endfor" "`endif"
+   "`endprotect" "`endswitch" "`endwhile" "`for" "`format" "`if" "`ifdef"
+   "`ifndef" "`include" "`let" "`protect" "`switch" "`timescale"
+   "`time_scale" "`undef" "`while" ))))
 
 (defconst verilog-directive-re-1
   (concat "[ \t]*"  verilog-directive-re))
@@ -1524,7 +1642,7 @@
   "\\<`\\(for\\|i\\(f\\|fdef\\|fndef\\)\\|switch\\|while\\)\\>")
 
 (defconst verilog-directive-middle
-  "\\<`\\(else\\|default\\|case\\)\\>")
+  "\\<`\\(else\\|elsif\\|default\\|case\\)\\>")
 
 (defconst verilog-directive-end
   "`\\(endfor\\|endif\\|endswitch\\|endwhile\\)\\>")
@@ -1703,6 +1821,11 @@
 ;;   b :
 
 (defconst verilog-label-re (concat verilog-symbol-re "\\s-*:\\s-*"))
+(defconst verilog-property-re
+  (concat "\\(" verilog-label-re "\\)?"
+	  "\\(\\(assert\\|assume\\|cover\\)\\>\\s-+\\<property\\>\\)\\|\\(assert\\)"))
+	  ;;  "\\(assert\\|assume\\|cover\\)\\s-+property\\>"
+
 (defconst verilog-no-indent-begin-re
   "\\<\\(if\\|else\\|while\\|for\\|repeat\\|always\\|always_comb\\|always_ff\\|always_latch\\)\\>")
 
@@ -1837,6 +1960,8 @@
    "\\(\\<fork\\>\\)\\|"			 ; 7
    "\\(\\<always\\>\\(\[ \t\]*@\\)?\\)\\|"
    "\\(\\<if\\>\\)\\|"
+   verilog-property-re "\\|"
+   "\\(\\(" verilog-label-re "\\)?\\<assert\\>\\)\\|"
    "\\(\\<clocking\\>\\)\\|"
    "\\(\\<task\\>\\)\\|"
    "\\(\\<function\\>\\)\\|"
@@ -2051,7 +2176,7 @@
        "`case"
        "`default"
        "`define" "`undef"
-       "`if" "`ifdef" "`ifndef" "`else" "`endif"
+       "`if" "`ifdef" "`ifndef" "`else" "`elsif" "`endif"
        "`while" "`endwhile"
        "`for" "`endfor"
        "`format"
@@ -2120,7 +2245,7 @@
 (defconst verilog-fork-wait-re "fork\\s-+wait\\>")
 (defconst verilog-extended-case-re "\\(unique\\s-+\\|priority\\s-+\\)?case[xz]?")
 (defconst verilog-extended-complete-re
-  (concat "\\(\\<extern\\s-+\\|\\<virtual\\s-+\\|\\<protected\\s-+\\)*\\(\\<function\\>\\|\\<task\\>\\)"
+  (concat "\\(\\<extern\\s-+\\|\\<\\(\\<pure\\>\\s-+\\)?virtual\\s-+\\|\\<protected\\s-+\\)*\\(\\<function\\>\\|\\<task\\>\\)"
 	  "\\|\\(\\<typedef\\>\\s-+\\)*\\(\\<struct\\>\\|\\<union\\>\\|\\<class\\>\\)"
 	  "\\|\\(\\<import\\>\\s-+\\)?\"DPI-C\"\\s-+\\(function\\>\\|task\\>\\)"
 	  "\\|" verilog-extended-case-re ))
@@ -2468,7 +2593,7 @@
 		 '("\\(@\\)\\|\\(#\\s-*\\(\\(\[0-9_.\]+\\('s?[hdxbo][0-9a-fA-F_xz]*\\)?\\)\\|\\(([^()]+)\\|\\sw+\\)\\)\\)"
 		   0 font-lock-type-face append)
 		 ;; Fontify instantiation names
-		 '("\\([A-Za-z][A-Za-z0-9_]+\\)\\s-*(" 1 font-lock-function-name-face)
+		 '("\\([A-Za-z][A-Za-z0-9_]*\\)\\s-*(" 1 font-lock-function-name-face)
 		 )))
 
   (setq verilog-font-lock-keywords-3
@@ -2480,22 +2605,145 @@
 		     (0 'verilog-font-lock-translate-off-face prepend))
 		   )))))
 
+;;
+;; Buffer state preservation
+
+(defmacro verilog-save-buffer-state (&rest body)
+  "Execute BODY forms, saving state around insignificant change.
+Changes in text properties like `face' or `syntax-table' are
+considered insignificant.  This macro allows text properties to
+be changed, even in a read-only buffer.
+
+A change is considered significant if it affects the buffer text
+in any way that isn't completely restored again.  Any
+user-visible changes to the buffer must not be within a
+`verilog-save-buffer-state'."
+  ;; From c-save-buffer-state
+  `(let* ((modified (buffer-modified-p))
+	  (buffer-undo-list t)
+	  (inhibit-read-only t)
+	  (inhibit-point-motion-hooks t)
+	  before-change-functions
+	  after-change-functions
+	  deactivate-mark
+	  buffer-file-name ; Prevent primitives checking
+	  buffer-file-truename)	; for file modification
+     (unwind-protect
+	 (progn ,@body)
+       (and (not modified)
+	    (buffer-modified-p)
+	    (set-buffer-modified-p nil)))))
+
+(defmacro verilog-save-no-change-functions (&rest body)
+  "Execute BODY forms, disabling all change hooks in BODY.
+For insigificant changes, see instead `verilog-save-buffer-state'."
+  `(let* ((inhibit-point-motion-hooks t)
+	  before-change-functions
+	  after-change-functions)
+     (progn ,@body)))
+
+;;
+;; Comment detection and caching
+
+(defvar verilog-scan-cache-preserving nil
+  "If set, the specified buffer's comment properties are static.
+Buffer changes will be ignored.  See `verilog-inside-comment-p'
+and `verilog-scan'.")
+
+(defvar verilog-scan-cache-tick nil
+  "Modification tick at which `verilog-scan' was last completed.")
+(make-variable-buffer-local 'verilog-scan-cache-tick)
+
+(defun verilog-scan-cache-ok-p ()
+  "Return t iff the scan cache is up to date."
+  (or (and verilog-scan-cache-preserving
+	   (eq verilog-scan-cache-preserving (current-buffer))
+	   verilog-scan-cache-tick)
+      (equal verilog-scan-cache-tick (buffer-chars-modified-tick))))
+
+(defmacro verilog-save-scan-cache (&rest body)
+  "Execute the BODY forms, allowing scan cache preservation within BODY.
+This requires that insertions must use `verilog-insert'."
+  ;; If the buffer is out of date, trash it, as we'll not check later the tick
+  ;; Note this must work properly if there's multiple layers of calls
+  ;; to verilog-save-scan-cache even with differing ticks.
+  `(progn
+     (unless (verilog-scan-cache-ok-p)  ;; Must be before let
+       (setq verilog-scan-cache-tick nil))
+     (let* ((verilog-scan-cache-preserving (current-buffer)))
+       (progn ,@body))))
+
+(defun verilog-scan-region (beg end)
+  "Parse comments between BEG and END for `verilog-inside-comment-p'.
+This creates v-cmt properties where comments are in force."
+  ;; Why properties and not overlays?  Overlays have much slower non O(1)
+  ;; lookup times.
+  ;; This function is warm - called on every verilog-insert
+  (save-excursion
+    (save-match-data
+      (verilog-save-buffer-state
+       (let (pt)
+	 (goto-char beg)
+	 (while (< (point) end)
+	   (cond ((looking-at "//")
+		  (setq pt (point))
+		  (or (search-forward "\n" end t)
+		      (goto-char end))
+		  ;; "1+": The leading // or /* itself isn't considered as
+		  ;; being "inside" the comment, so that a (search-backward)
+		  ;; that lands at the start of the // won't mis-indicate
+		  ;; it's inside a comment
+		  (put-text-property (1+ pt) (point) 'v-cmt t))
+		 ((looking-at "/\\*")
+		  (setq pt (point))
+		  (or (search-forward "*/" end t)
+		      ;; No error - let later code indicate it so we can
+		      ;; use inside functions on-the-fly
+		      ;;(error "%s: Unmatched /* */, at char %d"
+		      ;;       (verilog-point-text) (point))
+		      (goto-char end))
+		  (put-text-property (1+ pt) (point) 'v-cmt t))
+		 (t
+		  (forward-char 1)
+		  (if (re-search-forward "/[/*]" end t)
+		      (backward-char 2)
+		    (goto-char end))))))))))
+
+(defun verilog-scan ()
+  "Parse the buffer, marking all comments with properties.
+Also assumes any text inserted since `verilog-scan-cache-tick'
+either is ok to parse as a non-comment, or `verilog-insert' was used."
+  (unless (verilog-scan-cache-ok-p)
+    (save-excursion
+      (verilog-save-buffer-state
+	(when verilog-debug
+	  (message "Scanning %s cache=%s cachetick=%S tick=%S" (current-buffer)
+		   verilog-scan-cache-preserving verilog-scan-cache-tick
+		   (buffer-chars-modified-tick)))
+	(remove-text-properties (point-min) (point-max) '(v-cmt nil))
+	(verilog-scan-region (point-min) (point-max))
+	(setq verilog-scan-cache-tick (buffer-chars-modified-tick))
+	(when verilog-debug (message "Scaning... done"))))))
 
 (defun verilog-inside-comment-p ()
-  "Check if point inside a nested comment."
-  (save-excursion
-    (let ((st-point (point)) hitbeg)
-      (or (search-backward "//" (verilog-get-beg-of-line) t)
-	  (if (progn
-		;; This is for tricky case //*, we keep searching if /*
-		;; is proceeded by // on same line.
-		(while
-		    (and (setq hitbeg (search-backward "/*" nil t))
-			 (progn
-			   (forward-char 1)
-			   (search-backward "//" (verilog-get-beg-of-line) t))))
-		hitbeg)
-	      (not (search-forward "*/" st-point t)))))))
+  "Check if point inside a comment.
+This may require a slow pre-parse of the buffer with `verilog-scan'
+to establish comment properties on all text."
+  ;; This function is very hot
+  (verilog-scan)
+  (get-text-property (point) 'v-cmt))
+
+(defun verilog-insert (&rest stuff)
+  "Insert STUFF arguments, tracking comments for `verilog-inside-comment-p'.
+Any insert that includes a comment must have the entire commente
+inserted using a single call to `verilog-insert'."
+  (let ((pt (point)))
+    (while stuff
+      (insert (car stuff))
+      (setq stuff (cdr stuff)))
+    (verilog-scan-region pt (point))))
+
+;; More searching
 
 (defun verilog-declaration-end ()
   (search-forward ";"))
@@ -2917,15 +3165,16 @@
 	      nil
 	    'verilog-beg-of-defun)))
   ;;------------------------------------------------------------
-  ;; now hook in 'verilog-colorize-include-files (eldo-mode.el&spice-mode.el)
+  ;; now hook in 'verilog-highlight-include-files (eldo-mode.el&spice-mode.el)
   ;; all buffer local:
-  (when (featurep 'xemacs)
-    (make-local-hook 'font-lock-mode-hook)
-    (make-local-hook 'font-lock-after-fontify-buffer-hook); doesn't exist in Emacs
-    (make-local-hook 'after-change-functions))
-  (add-hook 'font-lock-mode-hook 'verilog-colorize-include-files-buffer t t)
-  (add-hook 'font-lock-after-fontify-buffer-hook 'verilog-colorize-include-files-buffer t t) ; not in Emacs
-  (add-hook 'after-change-functions 'verilog-colorize-include-files t t)
+  (unless noninteractive  ;; Else can't see the result, and change hooks are slow
+    (when (featurep 'xemacs)
+      (make-local-hook 'font-lock-mode-hook)
+      (make-local-hook 'font-lock-after-fontify-buffer-hook); doesn't exist in Emacs
+      (make-local-hook 'after-change-functions))
+    (add-hook 'font-lock-mode-hook 'verilog-highlight-buffer t t)
+    (add-hook 'font-lock-after-fontify-buffer-hook 'verilog-highlight-buffer t t) ; not in Emacs
+    (add-hook 'after-change-functions 'verilog-highlight-region t t))
 
   ;; Tell imenu how to handle Verilog.
   (make-local-variable 'imenu-generic-expression)
@@ -3355,34 +3604,53 @@
   (interactive)
   ;; Move back token by token until we see the end
   ;; of some ealier line.
-  (while
-      ;; If the current point does not begin a new
-      ;; statement, as in the character ahead of us is a ';', or SOF
-      ;; or the string after us unambiguously starts a statement,
-      ;; or the token before us unambiguously ends a statement,
-      ;; then move back a token and test again.
-      (not (or
-	    (bolp)
-	    (= (preceding-char) ?\;)
-	    (looking-at "\\w+\\W*:\\W*\\(coverpoint\\|cross\\|constraint\\)")
-	    (not (or
-		  (looking-at "\\<")
-		  (forward-word -1)))
-	    (and
-	     (looking-at verilog-complete-reg)
-	     (not (save-excursion
-		    (verilog-backward-token)
-		    (looking-at verilog-extended-complete-re))))
-	    (looking-at verilog-basic-complete-re)
-	    (save-excursion
-	      (verilog-backward-token)
-	      (or
-	       (looking-at verilog-end-block-re)
-	       (looking-at verilog-preprocessor-re)))))
+  (let (h)
+    (while
+	;; If the current point does not begin a new
+	;; statement, as in the character ahead of us is a ';', or SOF
+	;; or the string after us unambiguously starts a statement,
+	;; or the token before us unambiguously ends a statement,
+	;; then move back a token and test again.
+	(not (or
+          ;; stop if beginning of buffer
+	      (bolp)
+          ;; stop if we find a ;
+	      (= (preceding-char) ?\;)
+          ;; stop if we see a named coverpoint
+	      (looking-at "\\w+\\W*:\\W*\\(coverpoint\\|cross\\|constraint\\)")
+          ;; keep going if we are in the middle of a word
+	      (not (or (looking-at "\\<") (forward-word -1)))
+          ;; stop if we see an assertion (perhaps labled)
+	      (and
+	       (looking-at "\\(\\<\\(assert\\|assume\\|cover\\)\\>\\s-+\\<property\\>\\)\\|\\(\\<assert\\>\\)")
+	       (progn
+             (setq h (point))
+             (save-excursion
+               (verilog-backward-token)
+               (if (looking-at verilog-label-re)
+                   (setq h (point))))
+             (goto-char h)))
+          ;; stop if we see a complete reg, perhaps an extended one
+	      (and
+           (looking-at verilog-complete-reg)
+           (let* ((p (point)))
+             (while (and (looking-at verilog-extended-complete-re)
+                         (progn (setq p (point))
+                                (verilog-backward-token)
+                                (/= p (point)))))
+             (goto-char p)))
+          ;; stop if we see a complete reg (previous found extended ones)
+	      (looking-at verilog-basic-complete-re)
+          ;; stop if previous token is an ender
+	      (save-excursion
+            (verilog-backward-token)
+            (or
+             (looking-at verilog-end-block-re)
+             (looking-at verilog-preprocessor-re))))) ;; end of test
     (verilog-backward-syntactic-ws)
     (verilog-backward-token))
-  ;; Now point is where the previous line ended.
-  (verilog-forward-syntactic-ws))
+    ;; Now point is where the previous line ended.
+    (verilog-forward-syntactic-ws)))
 
 (defun verilog-beg-of-statement-1 ()
   "Move backward to beginning of statement."
@@ -3395,7 +3663,10 @@
         (setq pt (point))
         (verilog-backward-syntactic-ws)
         (if (or (bolp)
-                (= (preceding-char) ?\;))
+                (= (preceding-char) ?\;)
+		(save-excursion
+		  (verilog-backward-token)
+		  (looking-at verilog-ends-re)))
             (progn
               (goto-char pt)
               (throw 'done t))
@@ -3494,6 +3765,14 @@
 	       (t
 		(throw 'found (= nest 0)))))))
       nil)))
+(defun verilog-backward-up-list (arg)
+  "Like backward-up-list, but deal with comments."
+  (let (saved-psic parse-sexp-ignore-comments)
+    (setq parse-sexp-ignore-comments 1)
+    (backward-up-list arg)
+    (setq parse-sexp-ignore-comments saved-psic)
+    ))
+
 (defun verilog-in-struct-region-p ()
   "Return true if in a struct region.
 More specifically, in a list after a struct|union keyword."
@@ -3502,7 +3781,7 @@
     (let* ((state (verilog-syntax-ppss))
 	   (depth (nth 0 state)))
       (if depth
-	  (progn (backward-up-list depth)
+	  (progn (verilog-backward-up-list depth)
 		 (verilog-beg-of-statement)
 		 (looking-at "\\<typedef\\>?\\s-*\\<struct\\|union\\>"))))))
 
@@ -3628,7 +3907,8 @@
 	  "\\(`endif\\>\\)\\|"
 	  "\\(`if\\>\\)\\|"
 	  "\\(`ifdef\\>\\)\\|"
-	  "\\(`ifndef\\>\\)"))
+	  "\\(`ifndef\\>\\)\\|"
+	  "\\(`elsif\\>\\)"))
 (defun verilog-set-auto-endcomments (indent-str kill-existing-comment)
   "Add ending comment with given INDENT-STR.
 With KILL-EXISTING-COMMENT, remove what was there before.
@@ -3668,7 +3948,12 @@
 	     ((match-end 4) ; `ifdef
 	      (setq nest (1- nest)))
 	     ((match-end 5) ; `ifndef
-	      (setq nest (1- nest)))))
+	      (setq nest (1- nest)))
+	     ((match-end 6) ; `elsif
+	      (if (= nest 1)
+		  (progn
+		    (setq else "!")
+		    (setq nest 0))))))
 	  (if (match-end 0)
 	      (setq
 	       m (buffer-substring
@@ -3685,7 +3970,7 @@
 	    (if (> (count-lines (point) b) verilog-minimum-comment-distance)
 		(insert (concat " // " else m " " (buffer-substring b e))))
 	  (progn
-	    (insert " // unmatched `else or `endif")
+	    (insert " // unmatched `else, `elsif or `endif")
 	    (ding 't)))))
 
      (; Comment close case/class/function/task/module and named block
@@ -3764,8 +4049,8 @@
 			  (cond
 			   (;
 			    (eq here (progn
-				       (verilog-backward-token)
-				       (verilog-beg-of-statement-1)
+				    ;;   (verilog-backward-token)
+				       (verilog-beg-of-statement)
 				       (point)))
 			    (setq err nil)
 			    (setq str ""))
@@ -3789,7 +4074,7 @@
 			     (;- else
 			      (match-end 2)
 			      (let ((nest 0)
-				    ( reg "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)\\|\\(\\<if\\>\\)"))
+				    ( reg "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)\\|\\(\\<if\\>\\)\\|\\(assert\\)"))
 				(catch 'skip
 				  (while (verilog-re-search-backward reg nil 'move)
 				    (cond
@@ -3805,13 +4090,21 @@
 					    (setq err nil)
 					    (setq str (verilog-get-expr))
 					    (setq str (concat " // else: !if" str ))
+					    (throw 'skip 1))))
+				     ((match-end 4)
+				      (if (= 0 nest)
+					  (progn
+					    (goto-char (match-end 0))
+					    (setq there (point))
+					    (setq err nil)
+					    (setq str (verilog-get-expr))
+					    (setq str (concat " // else: !assert " str ))
 					    (throw 'skip 1)))))))))
-
 			     (;- end else
 			      (match-end 3)
 			      (goto-char there)
 			      (let ((nest 0)
-				    (reg "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)\\|\\(\\<if\\>\\)"))
+				    (reg "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)\\|\\(\\<if\\>\\)\\|\\(assert\\)"))
 				(catch 'skip
 				  (while (verilog-re-search-backward reg nil 'move)
 				    (cond
@@ -3827,7 +4120,17 @@
 					    (setq err nil)
 					    (setq str (verilog-get-expr))
 					    (setq str (concat " // else: !if" str ))
+					    (throw 'skip 1))))
+				     ((match-end 4)
+				      (if (= 0 nest)
+					  (progn
+					    (goto-char (match-end 0))
+					    (setq there (point))
+					    (setq err nil)
+					    (setq str (verilog-get-expr))
+					    (setq str (concat " // else: !assert " str ))
 					    (throw 'skip 1)))))))))
+
 			     (; always_comb, always_ff, always_latch
 			      (or (match-end 4) (match-end 5) (match-end 6))
 			      (goto-char (match-end 0))
@@ -3960,6 +4263,10 @@
 			(setq b (progn
 				  (skip-chars-forward "^ \t")
 				  (verilog-forward-ws&directives)
+				  (if (looking-at "static\\|automatic")
+				      (progn
+					(goto-char (match-end 0))
+					(verilog-forward-ws&directives)))
 				  (if (and name-re (verilog-re-search-forward name-re nil 'move))
 				      (progn
 					(goto-char (match-beginning 0))
@@ -4243,6 +4550,28 @@
   (save-buffer)
   (compile compile-command))
 
+(defun verilog-preprocess (&optional command filename)
+  "Preprocess the buffer, similar to `compile', but leave output in Verilog-Mode.
+Takes optional COMMAND or defaults to `verilog-preprocessor', and
+FILENAME or defaults to `buffer-file-name`."
+  (interactive
+   (list
+    (let ((default (verilog-expand-command verilog-preprocessor)))
+      (set (make-local-variable `verilog-preprocessor)
+	   (read-from-minibuffer "Run Preprocessor (like this): "
+				 default nil nil
+				 'verilog-preprocess-history default)))))
+  (unless command (setq command (verilog-expand-command verilog-preprocessor)))
+  (let* ((dir (file-name-directory (or filename buffer-file-name)))
+	 (file (file-name-nondirectory (or filename buffer-file-name)))
+	 (cmd (concat "cd " dir "; " command " " file)))
+    (with-output-to-temp-buffer "*Verilog-Preprocessed*"
+      (save-excursion
+	(set-buffer "*Verilog-Preprocessed*")
+	(insert (concat "// " cmd "\n"))
+	(shell-command cmd "*Verilog-Preprocessed*")
+	(verilog-mode)
+	(font-lock-mode)))))
 
 
 ;;
@@ -4385,7 +4714,7 @@
 		   ;; if we have a directive, done.
 		   (if (save-excursion (beginning-of-line)
 				       (and (looking-at verilog-directive-re-1)
-					    (not (or (looking-at "[ \t]*`ovm_") 
+					    (not (or (looking-at "[ \t]*`ovm_")
                                  (looking-at "[ \t]*`vmm_")))))
 		       (throw 'nesting 'directive))
            ;; indent structs as if there were module level
@@ -4449,8 +4778,7 @@
 			      ((match-end 3) ; assert block
 			       (setq elsec (1- elsec))
 			       (verilog-beg-of-statement) ;; doesn't get to beginning
-			       (if (looking-at (concat "\\(" verilog-label-re "\\)?"
-						       "\\(assert\\|assume\\|cover\\)\\s-+property\\>"))
+			       (if (looking-at verilog-property-re)
 				   (throw 'nesting 'statement) ; We don't need an endproperty for these
 				 (throw 'nesting 'block)	;We still need a endproperty
 				 ))
@@ -4584,6 +4912,13 @@
 		    (goto-char here)
 		    (throw 'nesting 'block)))))
 
+	     ((match-end 27)  ; *sigh* might be a clocking declaration
+	      (let ((here (point)))
+		(if (verilog-in-paren)
+		    t ; this is a normal statement
+		  (progn ; or is fork, starts a new block
+		    (goto-char here)
+		    (throw 'nesting 'block)))))
 
 	     ;; need to consider typedef struct here...
 	     ((looking-at "\\<class\\|struct\\|function\\|task\\>")
@@ -4607,8 +4942,7 @@
 					; but
                                         ;    property ID () ... needs end_property
 	      (verilog-beg-of-statement)
-	      (if (looking-at (concat "\\(" verilog-label-re "\\)?"
-				      "\\(assert\\|assume\\|cover\\)\\s-+property\\>"))
+	      (if (looking-at verilog-property-re)
 		  (throw 'continue 'statement) ; We don't need an endproperty for these
 		(throw 'nesting 'block)	;We still need a endproperty
 		))
@@ -4857,7 +5191,7 @@
     (= (preceding-char) ?\))
     (progn
       (backward-char)
-      (backward-up-list 1)
+      (verilog-backward-up-list 1)
       (verilog-backward-syntactic-ws)
       (let ((back (point)))
 	(forward-word -1)
@@ -4981,14 +5315,19 @@
 	    (let ((state (save-excursion (verilog-syntax-ppss))))
 	      (cond
 	       ((nth 7 state) ;; in // comment
-		(verilog-re-search-forward "//" nil 'move))
+		(end-of-line)
+		(forward-char 1)
+		(skip-chars-forward " \t\n\f")
+		)
 	       ((nth 4 state) ;; in /* */ comment
-		(verilog-re-search-forward "/\*" nil 'move))))
+		(verilog-re-search-forward "\*\/\\s-*" nil 'move))))
 	    (narrow-to-region (point) bound)
 	    (while (/= here (point))
 	      (setq here (point)
 		    jump nil)
 	      (forward-comment (buffer-size))
+	      (and (looking-at "\\s-*(\\*.*\\*)\\s-*") ;; Attribute
+		   (goto-char (match-end 0)))
 	      (save-excursion
 		(beginning-of-line)
 		(if (looking-at verilog-directive-re-1)
@@ -5020,6 +5359,12 @@
  (let ((state (save-excursion (verilog-syntax-ppss))))
    (or (nth 3 state) (nth 4 state) (nth 7 state)))) ; Inside string or comment)
 
+(defun verilog-in-attribute-p ()
+ "Return true if point is in an attribute (* [] attribute *)."
+ (save-excursion
+   (verilog-re-search-backward "\\((\\*\\)\\|\\(\\*)\\)" nil 'move)
+   (numberp (match-beginning 1))))
+
 (defun verilog-in-escaped-name-p ()
  "Return true if in an escaped name."
  (save-excursion
@@ -5029,7 +5374,7 @@
        t
      nil)))
 (defun verilog-in-directive-p ()
- "Return true if in a star or // comment."
+ "Return true if in a directive."
  (save-excursion
    (beginning-of-line)
    (looking-at verilog-directive-re-1)))
@@ -5045,7 +5390,7 @@
  (save-excursion
    (if (verilog-in-paren)
        (progn
-	 (backward-up-list 1)
+	 (verilog-backward-up-list 1)
 	 (verilog-at-struct-p)
 	 )
      nil)))
@@ -5056,7 +5401,7 @@
  (save-excursion
    (if (verilog-in-paren)
        (progn
-	 (backward-up-list 1)
+	 (verilog-backward-up-list 1)
 	 (verilog-at-constraint-p)
 	 )
      nil)))
@@ -5147,30 +5492,70 @@
 	       (search-backward "/*")
 	       (skip-chars-backward " \t\n\f")
 	       t)
-	      ((if (and (not (bobp))
-			(= (char-before) ?\/)
-			(= (char-before (1- (point))) ?\*))
-		   (goto-char (- (point) 2))
-		 (/= (skip-chars-backward " \t\n\f") 0)))))))))
+	      ((and (not (bobp))
+		    (= (char-before) ?\/)
+		    (= (char-before (1- (point))) ?\*))
+	       (goto-char (- (point) 2))
+	       t) ;; Let nth 4 state handle the rest
+	      ((and (not (bobp))
+		    (= (char-before) ?\))
+		    (= (char-before (1- (point))) ?\*))
+	       (goto-char (- (point) 2))
+	       (if (search-backward "(*" nil t)
+		   (progn
+		     (skip-chars-backward " \t\n\f")
+		     t)
+		 (progn
+		   (goto-char (+ (point) 2))
+		   nil)))
+	      (t
+	       (/= (skip-chars-backward " \t\n\f") 0))))))))
 
 (defun verilog-skip-forward-comment-p ()
   "If in comment, move to end and return true."
-  (let (state)
-    (progn
-      (setq state (save-excursion (verilog-syntax-ppss)))
-      (cond
-       ((nth 3 state)                   ;Inside string
-	t)
-       ((nth 7 state)			;Inside // comment
-	(end-of-line)
-	(forward-char 1)
-	t)
-       ((nth 4 state)			;Inside any comment
-	(search-forward "*/")
-	(skip-chars-forward " \t\n\f")
-	t)
-       (t
-	(skip-chars-forward " \t\n\f"))))))
+  (let* (h
+	 (state (save-excursion (verilog-syntax-ppss)))
+	 (skip (cond
+		((nth 3 state)		;Inside string
+		 t)
+		((nth 7 state)		;Inside // comment
+		 (end-of-line)
+		 (forward-char 1)
+		 t)
+		((nth 4 state)		;Inside /* comment
+		 (search-forward "*/")
+		 t)
+		((verilog-in-attribute-p)  ;Inside (* attribute
+		 (search-forward "*)" nil t)
+		 t)
+		(t nil))))
+    (skip-chars-forward " \t\n\f")
+    (while
+	(cond
+	 ((looking-at "\\/\\*")
+	  (progn
+	    (setq h (point))
+	    (goto-char (match-end 0))
+	    (if (search-forward "*/" nil t)
+		(progn
+		  (skip-chars-forward " \t\n\f")
+		  (setq skip 't))
+	      (progn
+		(goto-char h)
+		nil))))
+	 ((looking-at "(\\*")
+	  (progn
+	    (setq h (point))
+	    (goto-char (match-end 0))
+	    (if (search-forward "*)" nil t)
+		(progn
+		  (skip-chars-forward " \t\n\f")
+		  (setq skip 't))
+	      (progn
+		(goto-char h)
+		nil))))
+	 (t nil)))
+    skip))
 
 (defun verilog-indent-line-relative ()
   "Cheap version of indent line.
@@ -5237,7 +5622,7 @@
 			    ((= (following-char) ?\[)
 			     (progn
 			       (forward-char 1)
-			       (backward-up-list -1)
+			       (verilog-backward-up-list -1)
 			       (skip-chars-forward " \t"))))
 			   (current-column))
 		       (progn
@@ -5262,13 +5647,24 @@
 
      (; handle inside parenthetical expressions
       (eq type 'cparenexp)
-      (let ((val (save-excursion
-		   (backward-up-list 1)
-		   (forward-char 1)
-		   (skip-chars-forward " \t")
-		   (current-column))))
-	(indent-line-to val)
-      ))
+      (let* ( here
+	      (val (save-excursion
+		     (verilog-backward-up-list 1)
+		     (forward-char 1)
+             (if verilog-indent-lists
+                 (skip-chars-forward " \t")
+               (verilog-forward-syntactic-ws))
+             (setq here (point))
+             (current-column)))
+
+	      (decl (save-excursion
+		      (goto-char here)
+		      (verilog-forward-syntactic-ws)
+		      (setq here (point))
+		      (looking-at verilog-declaration-re))))
+        (indent-line-to val)
+        (if decl
+            (verilog-pretty-declarations))))
 
      (;-- Handle the ends
       (or
@@ -5419,16 +5815,16 @@
       (if (progn
 ;          (verilog-beg-of-statement-1)
           (beginning-of-line)
-          (verilog-forward-syntactic-ws)          
+          (verilog-forward-syntactic-ws)
           (and (not (verilog-in-directive-p))    ;; could have `define input foo
                (looking-at verilog-declaration-re)))
 	  (progn
-	    (if (verilog-parenthesis-depth)  
-		;; in an argument list or parameter block		
-		(setq el (backward-up-list -1)		      
+	    (if (verilog-parenthesis-depth)
+		;; in an argument list or parameter block
+		(setq el (verilog-backward-up-list -1)
 		      start (progn
 			      (goto-char e)
-			      (backward-up-list 1)
+			      (verilog-backward-up-list 1)
 			      (forward-line) ;; ignore ( input foo,
 			      (verilog-re-search-forward verilog-declaration-re el 'move)
 			      (goto-char (match-beginning 0))
@@ -5437,19 +5833,19 @@
 		      startpos (set-marker (make-marker) start)
 		      end (progn
 			    (goto-char start)
-			    (backward-up-list -1)
+			    (verilog-backward-up-list -1)
 			    (forward-char -1)
 			    (verilog-backward-syntactic-ws)
 			    (point))
 		      endpos (set-marker (make-marker) end)
 		      base-ind (progn
 				 (goto-char start)
-				 (verilog-do-indent (verilog-calculate-indent))
-				 (verilog-forward-ws&directives)
-				 (current-column))
+                 (forward-char 1)
+                 (skip-chars-forward " \t")
+                 (current-column))
 		      )
 	      ;; in a declaration block (not in argument list)
-	      (setq 
+	      (setq
 	       start (progn
 		       (verilog-beg-of-statement-1)
 		       (while (and (looking-at verilog-declaration-re)
@@ -5468,7 +5864,6 @@
 		     (setq e (point))	;Might be on last line
 		     (verilog-forward-syntactic-ws)
 		     (while (looking-at verilog-declaration-re)
-		       ;;(beginning-of-line)
 		       (verilog-end-of-statement)
 		       (setq e (point))
 		       (verilog-forward-syntactic-ws))
@@ -5488,7 +5883,7 @@
 	    (while (progn (setq e (marker-position endpos))
 			  (< (point) e))
 	      (cond
-	       ((save-excursion (skip-chars-backward " \t") 
+	       ((save-excursion (skip-chars-backward " \t")
 				(bolp))
 		 (verilog-forward-ws&directives)
 		 (indent-line-to base-ind)
@@ -5509,7 +5904,7 @@
 			  (> r 0))
 	      (setq e (point))
 	      (unless quiet (message "%d" r))
-	      (verilog-indent-line)
+          ;;(verilog-do-indent (verilog-calculate-indent)))
 	      (verilog-forward-ws&directives)
 	      (cond
 	       ((or (and verilog-indent-declaration-macros
@@ -5543,12 +5938,12 @@
 
 (defun verilog-pretty-expr (&optional quiet myre)
   "Line up expressions around point, optionally QUIET with regexp MYRE."
-  (interactive "sRegular Expression: ((<|:)?=) ")
+  (interactive "i\nsRegular Expression: ((<|:)?=) ")
   (save-excursion
     (if (or (eq myre nil)
 	    (string-equal myre ""))
 	(setq myre "\\(<\\|:\\)?="))
-    ;; want to match the first <= |  := | = 
+    ;; want to match the first <= |  := | =
     (setq myre (concat "\\(^.*?\\)\\(" myre "\\)"))
     (let ((rexp(concat "^\\s-*" verilog-complete-reg)))
       (beginning-of-line)
@@ -5873,6 +6268,39 @@
 Variables and function names defined within the Verilog program
 will be completed at runtime and should not be added to this list.")
 
+(defvar verilog-gate-ios
+  ;; All these have an implied {"input"...} at the end
+  '(("and"	"output")
+    ("buf"	"output")
+    ("bufif0"	"output")
+    ("bufif1"	"output")
+    ("cmos"	"output")
+    ("nand"	"output")
+    ("nmos"	"output")
+    ("nor"	"output")
+    ("not"	"output")
+    ("notif0"	"output")
+    ("notif1"	"output")
+    ("or"	"output")
+    ("pmos"	"output")
+    ("pulldown"	"output")
+    ("pullup"	"output")
+    ("rcmos"	"output")
+    ("rnmos"	"output")
+    ("rpmos"	"output")
+    ("rtran"	"inout" "inout")
+    ("rtranif0"	"inout" "inout")
+    ("rtranif1"	"inout" "inout")
+    ("tran"	"inout" "inout")
+    ("tranif0"	"inout" "inout")
+    ("tranif1"	"inout" "inout")
+    ("xnor"	"output")
+    ("xor"	"output"))
+  "*Map of direction for each positional argument to each gate primitive.")
+
+(defvar verilog-gate-keywords (mapcar `car verilog-gate-ios)
+  "*Keywords for gate primitives.")
+
 (defun verilog-string-diff (str1 str2)
   "Return index of first letter where STR1 and STR2 differs."
   (catch 'done
@@ -6203,7 +6631,7 @@
       (verilog-completion-response))))
 
 (defun verilog-goto-defun ()
-  "Move to specified Verilog module/task/function.
+  "Move to specified Verilog module/interface/task/function.
 The default is a name found in the buffer around point.
 If search fails, other files are checked based on
 `verilog-library-flags'."
@@ -6447,6 +6875,8 @@
 ;;
 
 ;; Elements of a signal list
+(defsubst verilog-sig-new (name bits comment mem enum signed type multidim modport)
+  (list name bits comment mem enum signed type multidim modport))
 (defsubst verilog-sig-name (sig)
   (car sig))
 (defsubst verilog-sig-bits (sig)
@@ -6475,37 +6905,96 @@
 (defsubst verilog-sig-width (sig)
   (verilog-make-width-expression (verilog-sig-bits sig)))
 
+(defsubst verilog-alw-new (outputs temps inputs delayed)
+  (list outputs temps inputs delayed))
+(defsubst verilog-alw-get-outputs (sigs)
+  (nth 0 sigs))
+(defsubst verilog-alw-get-temps (sigs)
+  (nth 1 sigs))
 (defsubst verilog-alw-get-inputs (sigs)
   (nth 2 sigs))
-(defsubst verilog-alw-get-outputs (sigs)
-  (nth 0 sigs))
 (defsubst verilog-alw-get-uses-delayed (sigs)
   (nth 3 sigs))
 
+(defsubst verilog-modi-new (name fob pt type)
+  (vector name fob pt type))
+(defsubst verilog-modi-name (modi)
+  (aref modi 0))
+(defsubst verilog-modi-file-or-buffer (modi)
+  (aref modi 1))
+(defsubst verilog-modi-get-point (modi)
+  (aref modi 2))
+(defsubst verilog-modi-get-type (modi) ;; "module" or "interface"
+  (aref modi 3))
+(defsubst verilog-modi-get-decls (modi)
+  (verilog-modi-cache-results modi 'verilog-read-decls))
+(defsubst verilog-modi-get-sub-decls (modi)
+  (verilog-modi-cache-results modi 'verilog-read-sub-decls))
+
+;; Signal reading for given module
+;; Note these all take modi's - as returned from verilog-modi-current
+(defsubst verilog-decls-new (out inout in wires regs assigns consts gparams interfaces)
+  (vector out inout in wires regs assigns consts gparams interfaces))
+(defsubst verilog-decls-get-outputs (decls)
+  (aref decls 0))
+(defsubst verilog-decls-get-inouts (decls)
+  (aref decls 1))
+(defsubst verilog-decls-get-inputs (decls)
+  (aref decls 2))
+(defsubst verilog-decls-get-wires (decls)
+  (aref decls 3))
+(defsubst verilog-decls-get-regs (decls)
+  (aref decls 4))
+(defsubst verilog-decls-get-assigns (decls)
+  (aref decls 5))
+(defsubst verilog-decls-get-consts (decls)
+  (aref decls 6))
+(defsubst verilog-decls-get-gparams (decls)
+  (aref decls 7))
+(defsubst verilog-decls-get-interfaces (decls)
+  (aref decls 8))
+
+(defsubst verilog-subdecls-new (out inout in intf intfd)
+  (vector out inout in intf intfd))
+(defsubst verilog-subdecls-get-outputs (subdecls)
+  (aref subdecls 0))
+(defsubst verilog-subdecls-get-inouts (subdecls)
+  (aref subdecls 1))
+(defsubst verilog-subdecls-get-inputs (subdecls)
+  (aref subdecls 2))
+(defsubst verilog-subdecls-get-interfaces (subdecls)
+  (aref subdecls 3))
+(defsubst verilog-subdecls-get-interfaced (subdecls)
+  (aref subdecls 4))
+
 (defun verilog-signals-not-in (in-list not-list)
   "Return list of signals in IN-LIST that aren't also in NOT-LIST.
 Also remove any duplicates in IN-LIST.
 Signals must be in standard (base vector) form."
-  (let (out-list)
-    (while in-list
-      (if (not (or (assoc (car (car in-list)) not-list)
-		   (assoc (car (car in-list)) out-list)))
-	  (setq out-list (cons (car in-list) out-list)))
-      (setq in-list (cdr in-list)))
-    (nreverse out-list)))
+  ;; This function is hot, so implemented as O(1)
+  (cond ((eval-when-compile (fboundp 'make-hash-table))
+	 (let ((ht (make-hash-table :test 'equal :rehash-size 4.0))
+	       out-list)
+	   (while not-list
+	     (puthash (car (car not-list)) t ht)
+	     (setq not-list (cdr not-list)))
+	   (while in-list
+	     (when (not (gethash (car (car in-list)) ht))
+	       (setq out-list (cons (car in-list) out-list))
+	       (puthash (car (car in-list)) t ht))
+	     (setq in-list (cdr in-list)))
+	   (nreverse out-list)))
+	;; Slower Fallback if no hash tables (pre Emacs 21.1/XEmacs 21.4)
+	(t
+	 (let (out-list)
+	   (while in-list
+	     (if (not (or (assoc (car (car in-list)) not-list)
+			  (assoc (car (car in-list)) out-list)))
+		 (setq out-list (cons (car in-list) out-list)))
+	     (setq in-list (cdr in-list)))
+	   (nreverse out-list)))))
 ;;(verilog-signals-not-in '(("A" "") ("B" "") ("DEL" "[2:3]")) '(("DEL" "") ("EXT" "")))
 
-(defun verilog-signals-in (in-list other-list)
-  "Return list of signals in IN-LIST that are also in OTHER-LIST.
-Signals must be in standard (base vector) form."
-  (let (out-list)
-    (while in-list
-      (if (assoc (car (car in-list)) other-list)
-	  (setq out-list (cons (car in-list) out-list)))
-      (setq in-list (cdr in-list)))
-    (nreverse out-list)))
-;;(verilog-signals-in '(("A" "") ("B" "") ("DEL" "[2:3]")) '(("DEL" "") ("EXT" "")))
-
 (defun verilog-signals-memory (in-list)
   "Return list of signals in IN-LIST that are memoried (multidimensional)."
   (let (out-list)
@@ -6599,15 +7088,15 @@
 	    ;; Note sig may also be nil for the last signal in the list
 	    (t
 	     (setq out-list
-		   (cons
-		    (list sv-name
+		   (cons (verilog-sig-new
+			  sv-name
 			  (or sv-busstring
 			      (if sv-highbit
 				  (concat "[" (int-to-string sv-highbit) ":"
 					  (int-to-string sv-lowbit) "]")))
 			  (concat sv-comment combo buswarn)
 			  sv-memory sv-enum sv-signed sv-type sv-multidim sv-modport)
-		    out-list)
+			 out-list)
 		   sv-name nil))))
     ;;
     out-list))
@@ -6645,20 +7134,26 @@
       (verilog-re-search-backward-quick "\\(\\b[a-zA-Z0-9`_\$]\\|\\]\\)" nil nil))
     (skip-chars-backward "a-zA-Z0-9`_$"))
 
+(defun verilog-read-inst-module-matcher ()
+  "Set match data 0 with module_name when point is inside instantiation."
+  (verilog-read-inst-backward-name)
+  ;; Skip over instantiation name
+  (verilog-re-search-backward-quick "\\(\\b[a-zA-Z0-9`_\$]\\|)\\)" nil nil)  ; ) isn't word boundary
+  ;; Check for parameterized instantiations
+  (when (looking-at ")")
+    (verilog-backward-open-paren)
+    (verilog-re-search-backward-quick "\\b[a-zA-Z0-9`_\$]" nil nil))
+  (skip-chars-backward "a-zA-Z0-9'_$")
+  (looking-at "[a-zA-Z0-9`_\$]+")
+  ;; Important: don't use match string, this must work with Emacs 19 font-lock on
+  (buffer-substring-no-properties (match-beginning 0) (match-end 0))
+  ;; Caller assumes match-beginning/match-end is still set
+  )
+
 (defun verilog-read-inst-module ()
   "Return module_name when point is inside instantiation."
   (save-excursion
-    (verilog-read-inst-backward-name)
-    ;; Skip over instantiation name
-    (verilog-re-search-backward-quick "\\(\\b[a-zA-Z0-9`_\$]\\|)\\)" nil nil)  ; ) isn't word boundary
-    ;; Check for parameterized instantiations
-    (when (looking-at ")")
-      (verilog-backward-open-paren)
-      (verilog-re-search-backward-quick "\\b[a-zA-Z0-9`_\$]" nil nil))
-    (skip-chars-backward "a-zA-Z0-9'_$")
-    (looking-at "[a-zA-Z0-9`_\$]+")
-    ;; Important: don't use match string, this must work with Emacs 19 font-lock on
-    (buffer-substring-no-properties (match-beginning 0) (match-end 0))))
+    (verilog-read-inst-module-matcher)))
 
 (defun verilog-read-inst-name ()
   "Return instance_name when point is inside instantiation."
@@ -6730,6 +7225,7 @@
 Return a array of [outputs inouts inputs wire reg assign const]."
   (let ((end-mod-point (or (verilog-get-end-of-defun t) (point-max)))
 	(functask 0) (paren 0) (sig-paren 0) (v2kargs-ok t)
+	in-modport
 	sigs-in sigs-out sigs-inout sigs-wire sigs-reg sigs-assign sigs-const
 	sigs-gparam sigs-intf
 	vec expect-signal keywd newsig rvalue enum io signed typedefed multidim
@@ -6738,7 +7234,7 @@
       (verilog-beg-of-defun)
       (setq sigs-const (verilog-read-auto-constants (point) end-mod-point))
       (while (< (point) end-mod-point)
-	;;(if dbg (setq dbg (cons (format "Pt %s  Vec %s   Kwd'%s'\n" (point) vec keywd) dbg)))
+	;;(if dbg (setq dbg (concat dbg (format "Pt %s  Vec %s   C%c Kwd'%s'\n" (point) vec (following-char) keywd))))
 	(cond
 	 ((looking-at "//")
 	  (if (looking-at "[^\n]*synopsys\\s +enum\\s +\\([a-zA-Z0-9_]+\\)")
@@ -6746,7 +7242,7 @@
 	  (search-forward "\n"))
 	 ((looking-at "/\\*")
 	  (forward-char 2)
-	  (if (looking-at "[^*]*synopsys\\s +enum\\s +\\([a-zA-Z0-9_]+\\)")
+	  (if (looking-at "[^\n]*synopsys\\s +enum\\s +\\([a-zA-Z0-9_]+\\)")
 	      (setq enum (match-string 1)))
 	  (or (search-forward "*/")
 	      (error "%s: Unmatched /* */, at char %d" (verilog-point-text) (point))))
@@ -6760,7 +7256,7 @@
 	      (error "%s: Unmatched quotes, at char %d" (verilog-point-text) (point))))
 	 ((eq ?\; (following-char))
 	  (setq vec nil  io nil  expect-signal nil  newsig nil  paren 0  rvalue nil
-		v2kargs-ok nil)
+		v2kargs-ok nil  in-modport nil)
 	  (forward-char 1))
 	 ((eq ?= (following-char))
 	  (setq rvalue t  newsig nil)
@@ -6818,7 +7314,9 @@
 				  expect-signal 'sigs-wire  modport nil)))
 		((member keywd '("reg" "trireg"
 				 "byte" "shortint" "int" "longint" "integer" "time"
-				 "bit" "logic"))
+				 "bit" "logic"
+				 "shortreal" "real" "realtime"
+				 "string" "event" "chandle"))
 		 (unless io (setq vec nil  enum nil  rvalue nil  signed nil  typedefed nil  multidim nil  sig-paren paren
 				  expect-signal 'sigs-reg  modport nil)))
 		((equal keywd "assign")
@@ -6836,8 +7334,10 @@
 		((member keywd '("endclass" "endclocking" "endgroup" "endfunction"
 				 "endproperty" "endsequence" "endtask"))
 		 (setq functask (1- functask)))
+		((equal keywd "modport")
+		 (setq in-modport t))
 		;; Ifdef?  Ignore name of define
-		((member keywd '("`ifdef" "`ifndef"))
+		((member keywd '("`ifdef" "`ifndef" "`elsif"))
 		 (setq rvalue t))
 		;; Type?
 		((verilog-typedef-name-p keywd)
@@ -6846,32 +7346,45 @@
 		;; Skip over parsing modport, and take the interface name as the type
 		((and v2kargs-ok
 		      (eq paren 1)
-		      (looking-at "\\s-*\\(\\.\\(\\s-*[a-zA-Z0-9`_$]+\\)\\|\\)\\s-*[a-zA-Z0-9`_$]+"))
+		      (not rvalue)
+		      (looking-at "\\s-*\\(\\.\\(\\s-*[a-zA-Z`_$][a-zA-Z0-9`_$]*\\)\\|\\)\\s-*[a-zA-Z`_$][a-zA-Z0-9`_$]*"))
 		 (when (match-end 2) (goto-char (match-end 2)))
 		 (setq vec nil enum nil  rvalue nil  newsig nil  signed nil  typedefed keywd  multidim nil  sig-paren paren
 		       expect-signal 'sigs-intf  io t  modport (match-string 2)))
+		;; Ignore dotted LHS assignments: "assign foo.bar = z;"
+		((looking-at "\\s-*\\.")
+		 (goto-char (match-end 0))
+		 (when (not rvalue)
+		   (setq expect-signal nil)))
 		;; New signal, maybe?
 		((and expect-signal
+		      (not rvalue)
 		      (eq functask 0)
-		      (not rvalue)
+		      (not in-modport)
 		      (not (member keywd verilog-keywords)))
 		 ;; Add new signal to expect-signal's variable
-		 (setq newsig (list keywd vec nil nil enum signed typedefed multidim modport))
+		 (setq newsig (verilog-sig-new keywd vec nil nil enum signed typedefed multidim modport))
 		 (set expect-signal (cons newsig
 					  (symbol-value expect-signal))))))
 	 (t
 	  (forward-char 1)))
 	(skip-syntax-forward " "))
       ;; Return arguments
-      (vector (nreverse sigs-out)
-	      (nreverse sigs-inout)
-	      (nreverse sigs-in)
-	      (nreverse sigs-wire)
-	      (nreverse sigs-reg)
-	      (nreverse sigs-assign)
-	      (nreverse sigs-const)
-	      (nreverse sigs-gparam)
-	      (nreverse sigs-intf)))))
+      (verilog-decls-new (nreverse sigs-out)
+			 (nreverse sigs-inout)
+			 (nreverse sigs-in)
+			 (nreverse sigs-wire)
+			 (nreverse sigs-reg)
+			 (nreverse sigs-assign)
+			 (nreverse sigs-const)
+			 (nreverse sigs-gparam)
+			 (nreverse sigs-intf)))))
+
+(defvar verilog-read-sub-decls-in-interfaced nil
+  "For `verilog-read-sub-decls', process next signal as under interfaced block.")
+
+(defvar verilog-read-sub-decls-gate-ios nil
+  "For `verilog-read-sub-decls', gate IO pins remaining, nil if non-primitive.")
 
 (eval-when-compile
   ;; Prevent compile warnings; these are let's, not globals
@@ -6880,82 +7393,77 @@
   (defvar sigs-in)
   (defvar sigs-inout)
   (defvar sigs-out)
-  (defvar sigs-intf))
-
-
-(defsubst verilog-modi-get-decls (modi)
-  (verilog-modi-cache-results modi 'verilog-read-decls))
-
-(defsubst verilog-modi-get-sub-decls (modi)
-  (verilog-modi-cache-results modi 'verilog-read-sub-decls))
-
-
-;; Signal reading for given module
-;; Note these all take modi's - as returned from the
-;; verilog-modi-current function.
-(defsubst verilog-decls-get-outputs (decls)
-  (aref decls 0))
-(defsubst verilog-decls-get-inouts (decls)
-  (aref decls 1))
-(defsubst verilog-decls-get-inputs (decls)
-  (aref decls 2))
-(defsubst verilog-decls-get-wires (decls)
-  (aref decls 3))
-(defsubst verilog-decls-get-regs (decls)
-  (aref decls 4))
-(defsubst verilog-decls-get-assigns (decls)
-  (aref decls 5))
-(defsubst verilog-decls-get-consts (decls)
-  (aref decls 6))
-(defsubst verilog-decls-get-gparams (decls)
-  (aref decls 7))
-(defsubst verilog-decls-get-interfaces (decls)
-  (aref decls 8))
-(defsubst verilog-subdecls-get-outputs (subdecls)
-  (aref subdecls 0))
-(defsubst verilog-subdecls-get-inouts (subdecls)
-  (aref subdecls 1))
-(defsubst verilog-subdecls-get-inputs (subdecls)
-  (aref subdecls 2))
-(defsubst verilog-subdecls-get-interfaces (subdecls)
-  (aref subdecls 3))
-
+  (defvar sigs-intf)
+  (defvar sigs-intfd))
 
 (defun verilog-read-sub-decls-sig (submoddecls comment port sig vec multidim)
   "For `verilog-read-sub-decls-line', add a signal."
-  (let (portdata)
+  ;; sig eq t to indicate .name syntax
+  ;;(message "vrsds: %s(%S)" port sig)
+  (let ((dotname (eq sig t))
+	portdata)
     (when sig
       (setq port (verilog-symbol-detick-denumber port))
-      (setq sig  (verilog-symbol-detick-denumber sig))
-      (if sig (setq sig  (verilog-string-replace-matches "^\\s-*[---+~!|&]+\\s-*" "" nil nil sig)))
+      (setq sig  (if dotname port (verilog-symbol-detick-denumber sig)))
       (if vec (setq vec  (verilog-symbol-detick-denumber vec)))
       (if multidim (setq multidim  (mapcar `verilog-symbol-detick-denumber multidim)))
       (unless (or (not sig)
 		  (equal sig ""))  ;; Ignore .foo(1'b1) assignments
-	(cond ((setq portdata (assoc port (verilog-decls-get-inouts submoddecls)))
-	       (setq sigs-inout (cons (list sig vec (concat "To/From " comment) nil nil
-					    (verilog-sig-signed portdata)
-					    (verilog-sig-type portdata)
-					    multidim)
-				      sigs-inout)))
-	      ((setq portdata (assoc port (verilog-decls-get-outputs submoddecls)))
-	       (setq sigs-out   (cons (list sig vec (concat "From " comment) nil nil
-					    (verilog-sig-signed portdata)
-					    (verilog-sig-type portdata)
-					    multidim)
-				      sigs-out)))
-	      ((setq portdata (assoc port (verilog-decls-get-inputs submoddecls)))
-	       (setq sigs-in    (cons (list sig vec (concat "To " comment) nil nil
-					    (verilog-sig-signed portdata)
-					    (verilog-sig-type portdata)
-					    multidim)
-				      sigs-in)))
+	(cond ((or (setq portdata (assoc port (verilog-decls-get-inouts submoddecls)))
+		   (equal "inout" verilog-read-sub-decls-gate-ios))
+	       (setq sigs-inout
+		     (cons (verilog-sig-new
+			    sig
+			    (if dotname (verilog-sig-bits portdata) vec)
+			    (concat "To/From " comment) nil nil
+			    (verilog-sig-signed portdata)
+			    (verilog-sig-type portdata)
+			    multidim nil)
+			   sigs-inout)))
+	      ((or (setq portdata (assoc port (verilog-decls-get-outputs submoddecls)))
+		   (equal "output" verilog-read-sub-decls-gate-ios))
+	       (setq sigs-out
+		     (cons (verilog-sig-new
+			    sig
+			    (if dotname (verilog-sig-bits portdata) vec)
+			    (concat "From " comment) nil nil
+			    (verilog-sig-signed portdata)
+			    (verilog-sig-type portdata)
+			    multidim nil)
+			   sigs-out)))
+	      ((or (setq portdata (assoc port (verilog-decls-get-inputs submoddecls)))
+		   (equal "input" verilog-read-sub-decls-gate-ios))
+	       (setq sigs-in
+		     (cons (verilog-sig-new
+			    sig
+			    (if dotname (verilog-sig-bits portdata) vec)
+			    (concat "To " comment) nil nil
+			    (verilog-sig-signed portdata)
+			    (verilog-sig-type portdata)
+			    multidim nil)
+			   sigs-in)))
 	      ((setq portdata (assoc port (verilog-decls-get-interfaces submoddecls)))
-	       (setq sigs-intf  (cons (list sig vec (concat "To/From " comment) nil nil
-					    (verilog-sig-signed portdata)
-					    (verilog-sig-type portdata)
-					    multidim)
-				      sigs-intf)))
+	       (setq sigs-intf
+		     (cons (verilog-sig-new
+			    sig
+			    (if dotname (verilog-sig-bits portdata) vec)
+			    (concat "To/From " comment) nil nil
+			    (verilog-sig-signed portdata)
+			    (verilog-sig-type portdata)
+			    multidim nil)
+			   sigs-intf)))
+	      ((setq portdata (and verilog-read-sub-decls-in-interfaced
+				   (or (assoc port (verilog-decls-get-regs submoddecls))
+				       (assoc port (verilog-decls-get-wires submoddecls)))))
+	       (setq sigs-intfd
+		     (cons (verilog-sig-new
+			    sig
+			    (if dotname (verilog-sig-bits portdata) vec)
+			    (concat "To/From " comment) nil nil
+			    (verilog-sig-signed portdata)
+			    (verilog-sig-type portdata)
+			    multidim nil)
+			   sigs-intf)))
 	      ;; (t  -- warning pin isn't defined.)   ; Leave for lint tool
 	      )))))
 
@@ -6969,21 +7477,25 @@
   ;;
   (cond
    ;; {..., a, b} requires us to recurse on a,b
-   ((string-match "^\\s-*{\\([^{}]*\\)}\\s-*$" expr)
+   ;; To support {#{},{#{a,b}} we'll just split everything on [{},]
+   ((string-match "^\\s-*{\\(.*\\)}\\s-*$" expr)
     (unless verilog-auto-ignore-concat
-      (let ((mlst (split-string (match-string 1 expr) ","))
+      (let ((mlst (split-string (match-string 1 expr) "[{},]"))
 	    mstr)
 	(while (setq mstr (pop mlst))
 	  (verilog-read-sub-decls-expr submoddecls comment port mstr)))))
    (t
     (let (sig vec multidim)
+      ;; Remove leading reduction operators, etc
+      (setq expr (verilog-string-replace-matches "^\\s-*[---+~!|&]+\\s-*" "" nil nil expr))
+      ;;(message "vrsde-ptop: '%s'" expr)
       (cond ;; Find \signal. Final space is part of escaped signal name
        ((string-match "^\\s-*\\(\\\\[^ \t\n\f]+\\s-\\)" expr)
 	;;(message "vrsde-s: '%s'" (match-string 1 expr))
 	(setq sig (match-string 1 expr)
 	      expr (substring expr (match-end 0))))
        ;; Find signal
-       ((string-match "^\\s-*\\([^[({).\\]+\\)" expr)
+       ((string-match "^\\s-*\\([a-zA-Z_][a-zA-Z_0-9]*\\)" expr)
 	;;(message "vrsde-s: '%s'" (match-string 1 expr))
 	(setq sig (verilog-string-remove-spaces (match-string 1 expr))
 	      expr (substring expr (match-end 0)))))
@@ -6999,8 +7511,8 @@
 	(verilog-read-sub-decls-sig submoddecls comment port sig vec multidim))))))
 
 (defun verilog-read-sub-decls-line (submoddecls comment)
-  "For `verilog-read-sub-decls', read lines of port defs until none match anymore.
-Return the list of signals found, using submodi to look up each port."
+  "For `verilog-read-sub-decls', read lines of port defs until none match.
+Inserts the list of signals found, using submodi to look up each port."
   (let (done port)
     (save-excursion
       (forward-line 1)
@@ -7009,9 +7521,23 @@
 	(cond ((looking-at "\\s-*\\.\\s-*\\([a-zA-Z0-9`_$]*\\)\\s-*(\\s-*")
 	       (setq port (match-string 1))
 	       (goto-char (match-end 0)))
+	      ;; .\escaped (
 	      ((looking-at "\\s-*\\.\\s-*\\(\\\\[^ \t\n\f]*\\)\\s-*(\\s-*")
 	       (setq port (concat (match-string 1) " ")) ;; escaped id's need trailing space
 	       (goto-char (match-end 0)))
+	      ;; .name
+	      ((looking-at "\\s-*\\.\\s-*\\([a-zA-Z0-9`_$]*\\)\\s-*[,)/]")
+	       (verilog-read-sub-decls-sig
+		submoddecls comment (match-string 1) t ; sig==t for .name
+		nil nil) ; vec multidim
+	       (setq port nil))
+	      ;; .\escaped_name
+	      ((looking-at "\\s-*\\.\\s-*\\(\\\\[^ \t\n\f]*\\)\\s-*[,)/]")
+	       (verilog-read-sub-decls-sig
+		submoddecls comment (concat (match-string 1) " ") t ; sig==t for .name
+		nil nil) ; vec multidim
+	       (setq port nil))
+	      ;; random
 	      ((looking-at "\\s-*\\.[^(]*(")
 	       (setq port nil) ;; skip this line
 	       (goto-char (match-end 0)))
@@ -7021,13 +7547,13 @@
 	;; We intentionally ignore (non-escaped) signals with .s in them
 	;; this prevents AUTOWIRE etc from noticing hierarchical sigs.
 	(when port
-	  (cond ((looking-at "\\([^[({).\\]*\\)\\s-*)")
+	  (cond ((looking-at "\\([a-zA-Z_][a-zA-Z_0-9]*\\)\\s-*)")
 		 (verilog-read-sub-decls-sig
 		  submoddecls comment port
 		  (verilog-string-remove-spaces (match-string 1)) ; sig
 		  nil nil)) ; vec multidim
 		;;
-		((looking-at "\\([^[({).\\]*\\)\\s-*\\(\\[[^]]+\\]\\)\\s-*)")
+		((looking-at "\\([a-zA-Z_][a-zA-Z_0-9]*\\)\\s-*\\(\\[[^]]+\\]\\)\\s-*)")
 		 (verilog-read-sub-decls-sig
 		  submoddecls comment port
 		  (verilog-string-remove-spaces (match-string 1)) ; sig
@@ -7043,6 +7569,35 @@
 	;;
 	(forward-line 1)))))
 
+(defun verilog-read-sub-decls-gate (submoddecls comment submod end-inst-point)
+  "For `verilog-read-sub-decls', read lines of UDP gate decl until none match.
+Inserts the list of signals found."
+  (save-excursion
+    (let ((iolist (cdr (assoc submod verilog-gate-ios))))
+      (while (< (point) end-inst-point)
+	;; Get primitive's signal name, as will never have port, and no trailing )
+	(cond ((looking-at "//")
+	       (search-forward "\n"))
+	      ((looking-at "/\\*")
+	       (or (search-forward "*/")
+		   (error "%s: Unmatched /* */, at char %d" (verilog-point-text) (point))))
+	      ((looking-at "(\\*")
+	       (or (looking-at "(\\*\\s-*)")   ; It's a "always @ (*)"
+		   (search-forward "*)")
+		   (error "%s: Unmatched (* *), at char %d" (verilog-point-text) (point))))
+	      ;; On pins, parse and advance to next pin
+	      ;; Looking at pin, but *not* an // Output comment, or ) to end the inst
+	      ((looking-at "\\s-*[a-zA-Z0-9`_$({}\\\\][^,]*")
+	       (goto-char (match-end 0))
+	       (setq verilog-read-sub-decls-gate-ios (or (car iolist) "input")
+		     iolist (cdr iolist))
+	       (verilog-read-sub-decls-expr
+		submoddecls comment "primitive_port"
+		(match-string 0)))
+	      (t
+	       (forward-char 1)
+	       (skip-syntax-forward " ")))))))
+
 (defun verilog-read-sub-decls ()
   "Internally parse signals going to modules under this module.
 Return a array of [ outputs inouts inputs ] signals for modules that are
@@ -7065,7 +7620,7 @@
     (let ((end-mod-point (verilog-get-end-of-defun t))
 	  st-point end-inst-point
 	  ;; below 3 modified by verilog-read-sub-decls-line
-	  sigs-out sigs-inout sigs-in sigs-intf)
+	  sigs-out sigs-inout sigs-in sigs-intf sigs-intfd)
       (verilog-beg-of-defun)
       (while (verilog-re-search-forward "\\(/\\*AUTOINST\\*/\\|\\.\\*\\)" end-mod-point t)
 	(save-excursion
@@ -7074,33 +7629,53 @@
 	    ;; Attempt to snarf a comment
 	    (let* ((submod (verilog-read-inst-module))
 		   (inst (verilog-read-inst-name))
+		   (subprim (member submod verilog-gate-keywords))
 		   (comment (concat inst " of " submod ".v"))
 		   submodi submoddecls)
-	      (when (setq submodi (verilog-modi-lookup submod t))
-		(setq submoddecls (verilog-modi-get-decls submodi))
-		;; This could have used a list created by verilog-auto-inst
-		;; However I want it to be runnable even on user's manually added signals
+    	      (cond
+	       (subprim
+		(setq submodi `primitive
+		      submoddecls (verilog-decls-new nil nil nil nil nil nil nil nil nil)
+		      comment (concat inst " of " submod))
 		(verilog-backward-open-paren)
 		(setq end-inst-point (save-excursion (forward-sexp 1) (point))
 		      st-point (point))
-		(while (re-search-forward "\\s *(?\\s *// Interfaces" end-inst-point t)
-		  (verilog-read-sub-decls-line submoddecls comment)) ;; Modifies sigs-out
-		(goto-char st-point)
-		(while (re-search-forward "\\s *(?\\s *// Outputs" end-inst-point t)
-		  (verilog-read-sub-decls-line submoddecls comment)) ;; Modifies sigs-out
-		(goto-char st-point)
-		(while (re-search-forward "\\s *(?\\s *// Inouts" end-inst-point t)
-		  (verilog-read-sub-decls-line submoddecls comment)) ;; Modifies sigs-inout
-		(goto-char st-point)
-		(while (re-search-forward "\\s *(?\\s *// Inputs" end-inst-point t)
-		  (verilog-read-sub-decls-line submoddecls comment)) ;; Modifies sigs-in
-		)))))
+		(forward-char 1)
+		(verilog-read-sub-decls-gate submoddecls comment submod end-inst-point))
+	       ;; Non-primitive
+	       (t
+		(when (setq submodi (verilog-modi-lookup submod t))
+		  (setq submoddecls (verilog-modi-get-decls submodi)
+			verilog-read-sub-decls-gate-ios nil)
+		  (verilog-backward-open-paren)
+		  (setq end-inst-point (save-excursion (forward-sexp 1) (point))
+			st-point (point))
+		  ;; This could have used a list created by verilog-auto-inst
+		  ;; However I want it to be runnable even on user's manually added signals
+		  (let ((verilog-read-sub-decls-in-interfaced t))
+		    (while (re-search-forward "\\s *(?\\s *// Interfaced" end-inst-point t)
+		      (verilog-read-sub-decls-line submoddecls comment))) ;; Modifies sigs-ifd
+		  (goto-char st-point)
+		  (while (re-search-forward "\\s *(?\\s *// Interfaces" end-inst-point t)
+		    (verilog-read-sub-decls-line submoddecls comment)) ;; Modifies sigs-out
+		  (goto-char st-point)
+		  (while (re-search-forward "\\s *(?\\s *// Outputs" end-inst-point t)
+		    (verilog-read-sub-decls-line submoddecls comment)) ;; Modifies sigs-out
+		  (goto-char st-point)
+		  (while (re-search-forward "\\s *(?\\s *// Inouts" end-inst-point t)
+		    (verilog-read-sub-decls-line submoddecls comment)) ;; Modifies sigs-inout
+		  (goto-char st-point)
+		  (while (re-search-forward "\\s *(?\\s *// Inputs" end-inst-point t)
+		    (verilog-read-sub-decls-line submoddecls comment)) ;; Modifies sigs-in
+		  )))))))
       ;; Combine duplicate bits
       ;;(setq rr (vector sigs-out sigs-inout sigs-in))
-      (vector (verilog-signals-combine-bus (nreverse sigs-out))
-	      (verilog-signals-combine-bus (nreverse sigs-inout))
-	      (verilog-signals-combine-bus (nreverse sigs-in))
-	      (verilog-signals-combine-bus (nreverse sigs-intf))))))
+      (verilog-subdecls-new
+       (verilog-signals-combine-bus (nreverse sigs-out))
+       (verilog-signals-combine-bus (nreverse sigs-inout))
+       (verilog-signals-combine-bus (nreverse sigs-in))
+       (verilog-signals-combine-bus (nreverse sigs-intf))
+       (verilog-signals-combine-bus (nreverse sigs-intfd))))))
 
 (defun verilog-read-inst-pins ()
   "Return an array of [ pins ] for the current instantiation at point.
@@ -7148,16 +7723,27 @@
 	  (setq sig-list (cons (list (match-string 1) nil nil) sig-list))))
       sig-list)))
 
-(defun verilog-read-auto-lisp (start end)
-  "Look for and evaluate a AUTO_LISP between START and END."
+(defvar verilog-cache-has-lisp nil "True if any AUTO_LISP in buffer.")
+(make-variable-buffer-local 'verilog-cache-has-lisp)
+
+(defun verilog-read-auto-lisp-present ()
+  "Set `verilog-cache-has-lisp' if any AUTO_LISP in this buffer."
   (save-excursion
-    (goto-char start)
-    (while (re-search-forward "\\<AUTO_LISP(" end t)
-      (backward-char)
-      (let* ((beg-pt (prog1 (point)
-		       (forward-sexp 1)))	;; Closing paren
-	     (end-pt (point)))
-	(eval-region beg-pt end-pt nil)))))
+    (setq verilog-cache-has-lisp (re-search-forward "\\<AUTO_LISP(" nil t))))
+
+(defun verilog-read-auto-lisp (start end)
+  "Look for and evaluate a AUTO_LISP between START and END.
+Must call `verilog-read-auto-lisp-present' before this function."
+  ;; This function is expensive for large buffers, so we cache if any AUTO_LISP exists
+  (when verilog-cache-has-lisp
+    (save-excursion
+      (goto-char start)
+      (while (re-search-forward "\\<AUTO_LISP(" end t)
+	(backward-char)
+	(let* ((beg-pt (prog1 (point)
+			 (forward-sexp 1)))	;; Closing paren
+	       (end-pt (point)))
+	  (eval-region beg-pt end-pt nil))))))
 
 (eval-when-compile
   ;; Prevent compile warnings; these are let's, not globals
@@ -7165,20 +7751,20 @@
   ;; - we want a error when we are debugging this code if they are refed.
   (defvar sigs-in)
   (defvar sigs-out)
-  (defvar got-sig)
-  (defvar got-rvalue)
+  (defvar sigs-temp)
   (defvar uses-delayed)
   (defvar vector-skip-list))
 
 (defun verilog-read-always-signals-recurse
-  (exit-keywd rvalue ignore-next)
+  (exit-keywd rvalue temp-next)
   "Recursive routine for parentheses/bracket matching.
 EXIT-KEYWD is expression to stop at, nil if top level.
 RVALUE is true if at right hand side of equal.
 IGNORE-NEXT is true to ignore next token, fake from inside case statement."
   (let* ((semi-rvalue (equal "endcase" exit-keywd)) ;; true if after a ; we are looking for rvalue
-	 keywd last-keywd sig-tolk sig-last-tolk gotend got-sig got-rvalue end-else-check)
-    ;;(if dbg (setq dbg (concat dbg (format "Recursion %S %S %S\n" exit-keywd rvalue ignore-next))))
+	 keywd last-keywd sig-tolk sig-last-tolk gotend got-sig got-list end-else-check
+	 ignore-next)
+    ;;(if dbg (setq dbg (concat dbg (format "Recursion %S %S %S\n" exit-keywd rvalue temp-next))))
     (while (not (or (eobp) gotend))
       (cond
        ((looking-at "//")
@@ -7256,7 +7842,9 @@
 	    (cond (sig-last-tolk	;; Function call; zap last signal
 		   (setq got-sig nil)))
 	    (cond ((equal last-keywd "for")
-		   (verilog-read-always-signals-recurse ";" nil nil)
+		   ;; temp-next: Variables on LHS are lvalues, but generally we want
+		   ;; to ignore them, assuming they are loop increments
+		   (verilog-read-always-signals-recurse ";" nil t)
 		   (verilog-read-always-signals-recurse ";" t nil)
 		   (verilog-read-always-signals-recurse ")" nil nil))
 		  (t (verilog-read-always-signals-recurse ")" t nil))))
@@ -7266,16 +7854,13 @@
 	    ;;(if dbg (setq dbg (concat dbg (format "\tgot-end %s\n" exit-keywd))))
 	    (setq ignore-next nil  rvalue semi-rvalue)
 	    (if (not exit-keywd) (setq end-else-check t)))
-	   ((or (equal keywd "case")
-		(equal keywd "casex")
-		(equal keywd "casez"))
+	   ((member keywd '("case" "casex" "casez"))
 	    (skip-syntax-forward "w_")
 	    (verilog-read-always-signals-recurse "endcase" t nil)
 	    (setq ignore-next nil  rvalue semi-rvalue)
 	    (if (not exit-keywd) (setq gotend t)))	;; top level begin/end
 	   ((string-match "^[$`a-zA-Z_]" keywd)	;; not exactly word constituent
-	    (cond ((or (equal keywd "`ifdef")
-		       (equal keywd "`ifndef"))
+	    (cond ((member keywd '("`ifdef" "`ifndef" "`elsif"))
 		   (setq ignore-next t))
 		  ((or ignore-next
 		       (member keywd verilog-keywords)
@@ -7284,14 +7869,16 @@
 		  (t
 		   (setq keywd (verilog-symbol-detick-denumber keywd))
 		   (when got-sig
-		     (if got-rvalue (setq sigs-in (cons got-sig sigs-in))
-		       (setq sigs-out (cons got-sig sigs-out)))
-		     ;;(if dbg (setq dbg (concat dbg (format "\t\tgot-sig=%S rv=%S\n" got-sig got-rvalue))))
+		     (set got-list (cons got-sig (symbol-value got-list)))
+		     ;;(if dbg (setq dbg (concat dbg (format "\t\tgot-sig=%S got-list=%S\n" got-sig got-list))))
 		     )
-		   (setq got-rvalue rvalue
+		   (setq got-list (cond (temp-next 'sigs-temp)
+					(rvalue 'sigs-in)
+					(t 'sigs-out))
 			 got-sig (if (or (not keywd)
-					 (assoc keywd (if got-rvalue sigs-in sigs-out)))
+					 (assoc keywd (symbol-value got-list)))
 				     nil (list keywd nil nil))
+			 temp-next nil
 			 sig-tolk t)))
 	    (skip-chars-forward "a-zA-Z0-9$_.%`"))
 	   (t
@@ -7301,25 +7888,23 @@
       (skip-syntax-forward " "))
     ;; Append the final pending signal
     (when got-sig
-      (if got-rvalue (setq sigs-in (cons got-sig sigs-in))
-	(setq sigs-out (cons got-sig sigs-out)))
-      ;;(if dbg (setq dbg (concat dbg (format "\t\tgot-sig=%S rv=%S\n" got-sig got-rvalue))))
+      ;;(if dbg (setq dbg (concat dbg (format "\t\tfinal got-sig=%S got-list=%s\n" got-sig got-list))))
+      (set got-list (cons got-sig (symbol-value got-list)))
       (setq got-sig nil))
     ;;(if dbg (setq dbg (concat dbg (format "ENDRecursion %s\n" exit-keywd))))
     ))
 
 (defun verilog-read-always-signals ()
   "Parse always block at point and return list of (outputs inout inputs)."
-  ;; Insert new
   (save-excursion
     (let* (;;(dbg "")
-	   sigs-in sigs-out
+	   sigs-out sigs-temp sigs-in
 	   uses-delayed)	;; Found signal/rvalue; push if not function
       (search-forward ")")
       (verilog-read-always-signals-recurse nil nil nil)
       ;;(if dbg (with-current-buffer (get-buffer-create "*vl-dbg*")) (delete-region (point-min) (point-max)) (insert dbg) (setq dbg ""))
       ;; Return what was found
-      (list sigs-out nil sigs-in uses-delayed))))
+      (verilog-alw-new sigs-out sigs-temp sigs-in uses-delayed))))
 
 (defun verilog-read-instants ()
   "Parse module at point and return list of ( ( file instance ) ... )."
@@ -7356,15 +7941,29 @@
     (let ((tpl-regexp "\\([0-9]+\\)")
 	  (lineno 0)
 	  (templateno 0)
+	  (pt (point))
 	  tpl-sig-list tpl-wild-list tpl-end-pt rep)
+      ;; Note this search is expensive, as we hunt from mod-begin to point
+      ;; for every instantiation.  Likewise in verilog-read-auto-lisp.
+      ;; So, we look first for an exact string rather than a slow regexp.
+      ;; Someday we may keep a cache of every template, but this would also
+      ;; need to record the relative position of each AUTOINST, as multiple
+      ;; templates exist for each module, and we're inserting lines.
       (cond ((or
-	       (re-search-backward (concat "^\\s-*/?\\*?\\s-*" module "\\s-+AUTO_TEMPLATE") nil t)
-	       (progn
-		 (goto-char (point-min))
-		 (re-search-forward (concat "^\\s-*/?\\*?\\s-*" module "\\s-+AUTO_TEMPLATE") nil t)))
+	      (verilog-re-search-backward-substr
+	       "AUTO_TEMPLATE"
+	       (concat "^\\s-*/?\\*?\\s-*" module "\\s-+AUTO_TEMPLATE") nil t)
+	      ;; Also try forward of this AUTOINST
+	      ;; This is for historical support; this isn't speced as working
+	      (progn
+		(goto-char pt)
+		(verilog-re-search-forward-substr
+		 "AUTO_TEMPLATE"
+		 (concat "^\\s-*/?\\*?\\s-*" module "\\s-+AUTO_TEMPLATE") nil t)))
 	     (goto-char (match-end 0))
 	     ;; Parse "REGEXP"
-	     ;; We reserve @"..." for future lisp expressions that evaluate once-per-AUTOINST
+	     ;; We reserve @"..." for future lisp expressions that evaluate
+	     ;; once-per-AUTOINST
 	     (when (looking-at "\\s-*\"\\([^\"]*\\)\"")
 	       (setq tpl-regexp (match-string 1))
 	       (goto-char (match-end 0)))
@@ -7495,7 +8094,8 @@
       (when recurse
 	(goto-char (point-min))
 	(while (re-search-forward "^\\s-*`include\\s-+\\([^ \t\n\f]+\\)" nil t)
-	  (let ((inc (verilog-string-replace-matches "\"" "" nil nil (match-string-no-properties 1))))
+	  (let ((inc (verilog-string-replace-matches
+		      "\"" "" nil nil (match-string-no-properties 1))))
 	    (unless (verilog-inside-comment-p)
 	      (verilog-read-defines inc recurse t)))))
       ;; Read `defines
@@ -7518,7 +8118,8 @@
 	      (setq enumname (match-string-no-properties 1)))
 	  (forward-comment 999)
 	  (while (looking-at "\\s-*,?\\s-*\\([a-zA-Z0-9_$]+\\)\\s-*=\\s-*\\([^;,]*\\),?\\s-*")
-	    (verilog-set-define (match-string-no-properties 1) (match-string-no-properties 2) origbuf enumname)
+	    (verilog-set-define (match-string-no-properties 1)
+				(match-string-no-properties 2) origbuf enumname)
 	    (goto-char (match-end 0))
 	    (forward-comment 999)))))))
 
@@ -7702,6 +8303,20 @@
   varref)
 ;;(progn (setq l '()) (verilog-add-list-unique `l "a") (verilog-add-list-unique `l "a") l)
 
+(defun verilog-current-flags ()
+  "Convert `verilog-library-flags' and similar variables to command line.
+Used for __FLAGS__ in `verilog-expand-command'."
+  (let ((cmd (mapconcat `concat verilog-library-flags " ")))
+    (when (equal cmd "")
+      (setq cmd (concat
+		 "+libext+" (mapconcat `concat verilog-library-extensions "+")
+		 (mapconcat (lambda (i) (concat " -y " i " +incdir+" i))
+			    verilog-library-directories "")
+		 (mapconcat (lambda (i) (concat " -v " i))
+			    verilog-library-files ""))))
+    cmd))
+;;(verilog-current-flags)
+
 
 ;;
 ;; Cached directory support
@@ -7721,7 +8336,7 @@
   "Execute the BODY forms, allowing directory cache preservation within BODY.
 This means that changes inside BODY made to the file system will not be
 seen by the `verilog-dir-files' and related functions."
-  `(let ((verilog-dir-cache-preserving t)
+  `(let ((verilog-dir-cache-preserving (current-buffer))
 	 verilog-dir-cache-list
 	 verilog-dir-cache-lib-filenames)
      (progn ,@body)))
@@ -7771,23 +8386,24 @@
 ;;
 
 (defun verilog-module-inside-filename-p (module filename)
-  "Return point if MODULE is specified inside FILENAME, else nil.
+  "Return modi if MODULE is specified inside FILENAME, else nil.
 Allows version control to check out the file if need be."
   (and (or (file-exists-p filename)
 	   (and (fboundp 'vc-backend)
 		(vc-backend filename)))
-       (let (pt)
+       (let (modi type)
 	 (with-current-buffer (find-file-noselect filename)
 	   (save-excursion
 	     (goto-char (point-min))
 	     (while (and
 		     ;; It may be tempting to look for verilog-defun-re,
 		     ;; don't, it slows things down a lot!
-		     (verilog-re-search-forward-quick "\\<module\\>" nil t)
+		     (verilog-re-search-forward-quick "\\<\\(module\\|interface\\)\\>" nil t)
+		     (setq type (match-string-no-properties 0))
 		     (verilog-re-search-forward-quick "[(;]" nil t))
 	       (if (equal module (verilog-read-module-name))
-		   (setq pt (point))))
-	     pt)))))
+		   (setq modi (verilog-modi-new module filename (point) type))))
+	     modi)))))
 
 (defun verilog-is-number (symbol)
   "Return true if SYMBOL is number-like."
@@ -7953,7 +8569,6 @@
   "Cache of ((Module Function) Buf-Tick Buf-Modtime Func-Returns)...
 For speeding up verilog-modi-get-* commands.
 Buffer-local.")
-
 (make-variable-buffer-local 'verilog-modi-cache-list)
 
 (defvar verilog-modi-cache-preserve-tick nil
@@ -7962,47 +8577,80 @@
 (defvar verilog-modi-cache-preserve-buffer nil
   "Modification tick after which the cache is still considered valid.
 Use `verilog-preserve-modi-cache' to set it.")
+(defvar verilog-modi-cache-current-enable nil
+  "If true, allow caching `verilog-modi-current', set by let().")
+(defvar verilog-modi-cache-current nil
+  "Currently active `verilog-modi-current', if any, set by let().")
+(defvar verilog-modi-cache-current-max nil
+  "Current endmodule point for `verilog-modi-cache-current', if any.")
 
 (defun verilog-modi-current ()
+  "Return the modi structure for the module currently at point, possibly cached."
+  (cond ((and verilog-modi-cache-current
+	      (>= (point) (verilog-modi-get-point verilog-modi-cache-current))
+	      (<= (point) verilog-modi-cache-current-max))
+	 ;; Slow assertion, for debugging the cache:
+	 ;;(or (equal verilog-modi-cache-current (verilog-modi-current-get)) (debug))
+	 verilog-modi-cache-current)
+	(verilog-modi-cache-current-enable
+	 (setq verilog-modi-cache-current (verilog-modi-current-get)
+	       verilog-modi-cache-current-max
+	       ;; The cache expires when we pass "endmodule" as then the
+	       ;; current modi may change to the next module
+	       ;; This relies on the AUTOs generally inserting, not deleting text
+	       (save-excursion
+		 (verilog-re-search-forward-quick verilog-end-defun-re nil nil)))
+	 verilog-modi-cache-current)
+	(t
+	 (verilog-modi-current-get))))
+
+(defun verilog-modi-current-get ()
   "Return the modi structure for the module currently at point."
-  (let* (name pt)
+  (let* (name type pt)
     ;; read current module's name
     (save-excursion
       (verilog-re-search-backward-quick verilog-defun-re nil nil)
+      (setq type (match-string-no-properties 0))
       (verilog-re-search-forward-quick "(" nil nil)
       (setq name (verilog-read-module-name))
       (setq pt (point)))
-    ;; return
-    (vector name (or (buffer-file-name) (current-buffer)) pt)))
-
-(defvar verilog-modi-lookup-last-mod nil "Cache of last module looked up.")
-(defvar verilog-modi-lookup-last-modi nil "Cache of last modi returned.")
-(defvar verilog-modi-lookup-last-current nil "Cache of last `current-buffer' looked up.")
-(defvar verilog-modi-lookup-last-tick nil "Cache of last `buffer-modified-tick' looked up.")
+    ;; return modi - note this vector built two places
+    (verilog-modi-new name (or (buffer-file-name) (current-buffer)) pt type)))
+
+(defvar verilog-modi-lookup-cache nil "Hash of (modulename modi).")
+(make-variable-buffer-local 'verilog-modi-lookup-cache)
+(defvar verilog-modi-lookup-last-current nil "Cache of `current-buffer' at last lookup.")
+(defvar verilog-modi-lookup-last-tick nil "Cache of `buffer-chars-modified-tick' at last lookup.")
 
 (defun verilog-modi-lookup (module allow-cache &optional ignore-error)
   "Find the file and point at which MODULE is defined.
 If ALLOW-CACHE is set, check and remember cache of previous lookups.
 Return modi if successful, else print message unless IGNORE-ERROR is true."
-  (let* ((current (or (buffer-file-name) (current-buffer))))
-    (cond ((and verilog-modi-lookup-last-modi
+  (let* ((current (or (buffer-file-name) (current-buffer)))
+	 modi)
+    ;; Check cache
+    ;;(message "verilog-modi-lookup: %s" module)
+    (cond ((and verilog-modi-lookup-cache
 		verilog-cache-enabled
 		allow-cache
-		(equal verilog-modi-lookup-last-mod module)
+		(setq modi (gethash module verilog-modi-lookup-cache))
 		(equal verilog-modi-lookup-last-current current)
-		(equal verilog-modi-lookup-last-tick (buffer-modified-tick)))
-	   ;; ok as is
-	   )
+		;; Iff hit is in current buffer, then tick must match
+		(or (equal verilog-modi-lookup-last-tick (buffer-chars-modified-tick))
+		    (not (equal current (verilog-modi-file-or-buffer modi)))))
+	   ;;(message "verilog-modi-lookup: HIT %S" modi)
+	   modi)
+	  ;; Miss
 	  (t (let* ((realmod (verilog-symbol-detick module t))
 		    (orig-filenames (verilog-module-filenames realmod current))
 		    (filenames orig-filenames)
-		    pt)
-	       (while (and filenames (not pt))
-		 (if (not (setq pt (verilog-module-inside-filename-p realmod (car filenames))))
+		    mif)
+	       (while (and filenames (not mif))
+		 (if (not (setq mif (verilog-module-inside-filename-p realmod (car filenames))))
 		     (setq filenames (cdr filenames))))
-	       (cond (pt (setq verilog-modi-lookup-last-modi
-			       (vector realmod (car filenames) pt)))
-		     (t (setq verilog-modi-lookup-last-modi nil)
+	       ;; mif has correct form to become later elements of modi
+	       (cond (mif (setq modi mif))
+		     (t (setq modi nil)
 			(or ignore-error
 			    (error (concat (verilog-point-text)
 					   ": Can't locate " module " module definition"
@@ -8012,17 +8660,14 @@
 					   "\n    Check the verilog-library-directories variable."
 					   "\n    I looked in (if not listed, doesn't exist):\n\t"
 					   (mapconcat 'concat orig-filenames "\n\t"))))))
-	       (setq verilog-modi-lookup-last-mod module
-		     verilog-modi-lookup-last-current current
-		     verilog-modi-lookup-last-tick (buffer-modified-tick)))))
-    verilog-modi-lookup-last-modi))
-
-(defsubst verilog-modi-name (modi)
-  (aref modi 0))
-(defsubst verilog-modi-file-or-buffer (modi)
-  (aref modi 1))
-(defsubst verilog-modi-point (modi)
-  (aref modi 2))
+	       (when (eval-when-compile (fboundp 'make-hash-table))
+		 (unless verilog-modi-lookup-cache
+		   (setq verilog-modi-lookup-cache
+			 (make-hash-table :test 'equal :rehash-size 4.0)))
+		 (puthash module modi verilog-modi-lookup-cache))
+	       (setq verilog-modi-lookup-last-current current
+		     verilog-modi-lookup-last-tick (buffer-chars-modified-tick)))))
+    modi))
 
 (defun verilog-modi-filename (modi)
   "Filename of MODI, or name of buffer if it's never been saved."
@@ -8039,7 +8684,7 @@
 		(find-file-noselect (verilog-modi-file-or-buffer modi))))
   (or (equal major-mode `verilog-mode)	;; Put into Verilog mode to get syntax
       (verilog-mode))
-  (goto-char (verilog-modi-point modi)))
+  (goto-char (verilog-modi-get-point modi)))
 
 (defun verilog-goto-defun-file (module)
   "Move point to the file at which a given MODULE is defined."
@@ -8059,7 +8704,7 @@
 				 verilog-modi-cache-list))
 	       ;; Destroy caching when incorrect; Modified or file changed
 	       (not (and verilog-cache-enabled
-			 (or (equal (buffer-modified-tick) (nth 1 fass))
+			 (or (equal (buffer-chars-modified-tick) (nth 1 fass))
 			     (and verilog-modi-cache-preserve-tick
 				  (<= verilog-modi-cache-preserve-tick  (nth 1 fass))
 				  (equal  verilog-modi-cache-preserve-buffer (current-buffer))))
@@ -8082,7 +8727,7 @@
 	       ;; Cache for next time
 	       (setq verilog-modi-cache-list
 		     (cons (list (list modi function)
-				 (buffer-modified-tick)
+				 (buffer-chars-modified-tick)
 				 (visited-file-modtime)
 				 func-returns)
 			   verilog-modi-cache-list))
@@ -8108,7 +8753,7 @@
 modsig-cache-add-* function, else the results of later calls may be
 incorrect.  Without this, changes are assumed to be adding/removing signals
 and invalidating the cache."
-  `(let ((verilog-modi-cache-preserve-tick (buffer-modified-tick))
+  `(let ((verilog-modi-cache-preserve-tick (buffer-chars-modified-tick))
 	 (verilog-modi-cache-preserve-buffer (current-buffer)))
      (progn ,@body)))
 
@@ -8254,7 +8899,7 @@
 	      (equal "" (verilog-sig-comment sig)))
 	  (insert "\n")
 	(indent-to (max 48 (+ indent-pt 40)))
-	(insert (concat "// " (verilog-sig-comment sig) "\n")))
+	(verilog-insert "// " (verilog-sig-comment sig) "\n"))
       (setq sigs (cdr sigs)))))
 
 (eval-when-compile
@@ -8268,7 +8913,7 @@
     (while stuff
       (if need-indent (indent-to indent-pt))
       (setq need-indent nil)
-      (insert (car stuff))
+      (verilog-insert (car stuff))
       (setq need-indent (string-match "\n$" (car stuff))
 	    stuff (cdr stuff)))))
 ;;(let ((indent-pt 10)) (verilog-insert-indent "hello\n" "addon" "there\n"))
@@ -8500,42 +9145,44 @@
   (save-excursion
     (if (buffer-file-name)
 	(find-file-noselect (buffer-file-name)))	;; To check we have latest version
-    ;; Allow user to customize
-    (run-hooks 'verilog-before-delete-auto-hook)
-
-    ;; Remove those that have multi-line insertions, possibly with parameters
-    (verilog-auto-re-search-do
-     (concat "/\\*"
-	     (eval-when-compile
-	       (verilog-regexp-words
-		`("AUTOASCIIENUM" "AUTOCONCATCOMMENT" "AUTODEFINEVALUE"
-		  "AUTOINOUT" "AUTOINOUTCOMP" "AUTOINOUTMODULE"
-		  "AUTOINPUT" "AUTOINSERTLISP" "AUTOOUTPUT" "AUTOOUTPUTEVERY"
-		  "AUTOREG" "AUTOREGINPUT" "AUTORESET" "AUTOTIEOFF"
-		  "AUTOUNUSED" "AUTOWIRE")))
-	     ;; Optional parens or quoted parameter or .* for (((...)))
-	     "\\(\\|([^)]*)\\|(\"[^\"]*\")\\).*?"
-	     "\\*/")
-     'verilog-delete-autos-lined)
-    ;; Remove those that are in parenthesis
-    (verilog-auto-re-search-do
-     (concat "/\\*"
-	     (eval-when-compile
-	       (verilog-regexp-words
-		`("AS" "AUTOARG" "AUTOCONCATWIDTH" "AUTOINST" "AUTOINSTPARAM"
-		  "AUTOSENSE")))
-	     "\\*/")
-     'verilog-delete-to-paren)
-    ;; Do .* instantiations, but avoid removing any user pins by looking for our magic comments
-    (verilog-auto-re-search-do "\\.\\*"
-			       'verilog-delete-auto-star-all)
-    ;; Remove template comments ... anywhere in case was pasted after AUTOINST removed
-    (goto-char (point-min))
-    (while (re-search-forward "\\s-*// \\(Templated\\|Implicit \\.\\*\\)[ \tLT0-9]*$" nil t)
-      (replace-match ""))
-
-    ;; Final customize
-    (run-hooks 'verilog-delete-auto-hook)))
+    (verilog-save-no-change-functions
+     (verilog-save-scan-cache
+      ;; Allow user to customize
+      (run-hooks 'verilog-before-delete-auto-hook)
+
+      ;; Remove those that have multi-line insertions, possibly with parameters
+      (verilog-auto-re-search-do
+       (concat "/\\*"
+	       (eval-when-compile
+		 (verilog-regexp-words
+		  `("AUTOASCIIENUM" "AUTOCONCATCOMMENT" "AUTODEFINEVALUE"
+		    "AUTOINOUT" "AUTOINOUTCOMP" "AUTOINOUTMODULE"
+		    "AUTOINPUT" "AUTOINSERTLISP" "AUTOOUTPUT" "AUTOOUTPUTEVERY"
+		    "AUTOREG" "AUTOREGINPUT" "AUTORESET" "AUTOTIEOFF"
+		    "AUTOUNUSED" "AUTOWIRE")))
+	       ;; Optional parens or quoted parameter or .* for (((...)))
+	       "\\(\\|([^)]*)\\|(\"[^\"]*\")\\).*?"
+	       "\\*/")
+       'verilog-delete-autos-lined)
+      ;; Remove those that are in parenthesis
+      (verilog-auto-re-search-do
+       (concat "/\\*"
+	       (eval-when-compile
+		 (verilog-regexp-words
+		  `("AS" "AUTOARG" "AUTOCONCATWIDTH" "AUTOINST" "AUTOINSTPARAM"
+		    "AUTOSENSE")))
+	       "\\*/")
+       'verilog-delete-to-paren)
+      ;; Do .* instantiations, but avoid removing any user pins by looking for our magic comments
+      (verilog-auto-re-search-do "\\.\\*"
+				 'verilog-delete-auto-star-all)
+      ;; Remove template comments ... anywhere in case was pasted after AUTOINST removed
+      (goto-char (point-min))
+      (while (re-search-forward "\\s-*// \\(Templated\\|Implicit \\.\\*\\)[ \tLT0-9]*$" nil t)
+	(replace-match ""))
+
+      ;; Final customize
+      (run-hooks 'verilog-delete-auto-hook)))))
 
 ;;
 ;; Auto inject
@@ -8600,7 +9247,7 @@
 	  (verilog-backward-syntactic-ws)
 	  (backward-char 1) ; Moves to paren that closes argdecl's
 	  (when (looking-at ")")
-	    (insert "/*AUTOARG*/")))))))
+	    (verilog-insert "/*AUTOARG*/")))))))
 
 (defun verilog-inject-sense ()
   "Inject AUTOSENSE into new code.  See `verilog-inject-auto'."
@@ -8622,7 +9269,7 @@
 	  (when (not (or (verilog-signals-not-in pre-sigs got-sigs)  ; Both are equal?
 			 (verilog-signals-not-in got-sigs pre-sigs)))
 	    (delete-region start-pt (point))
-	    (insert "/*AS*/")))))))
+	    (verilog-insert "/*AS*/")))))))
 
 (defun verilog-inject-inst ()
   "Inject AUTOINST into new code.  See `verilog-inject-auto'."
@@ -8656,9 +9303,8 @@
 		 ;; Not verilog-re-search, as we don't want to strip comments
 		 (while (re-search-backward "[ \t\n\f]+" (- (point) 1) t)
 		   (delete-region (match-beginning 0) (match-end 0)))
-		 (insert "\n")
-		 (indent-to indent-pt)
-		 (insert "/*AUTOINST*/")))))))))
+		 (verilog-insert "\n")
+		 (verilog-insert-indent "/*AUTOINST*/")))))))))
 
 ;;
 ;; Auto save
@@ -8675,14 +9321,14 @@
 	((eq verilog-auto-save-policy 'force)
 	 (verilog-auto))
 	((not (buffer-modified-p)))
-	((eq verilog-auto-update-tick (buffer-modified-tick))) ; up-to-date
+	((eq verilog-auto-update-tick (buffer-chars-modified-tick))) ; up-to-date
 	((eq verilog-auto-save-policy 'detect)
 	 (verilog-auto))
 	(t
 	 (when (yes-or-no-p "AUTO statements not recomputed, do it now? ")
 	   (verilog-auto))
 	 ;; Don't ask again if didn't update
-	 (set (make-local-variable 'verilog-auto-update-tick) (buffer-modified-tick))))
+	 (set (make-local-variable 'verilog-auto-update-tick) (buffer-chars-modified-tick))))
   (when (not verilog-auto-star-save)
     (verilog-delete-auto-star-implicit))
   nil)	;; Always return nil -- we don't write the file ourselves
@@ -8828,7 +9474,7 @@
 	 (vl-name (verilog-sig-name port-st))
 	 (vl-width (verilog-sig-width port-st))
 	 (vl-modport (verilog-sig-modport port-st))
-	 (vl-mbits (if (verilog-sig-multidim port-st) 
+	 (vl-mbits (if (verilog-sig-multidim port-st)
                        (verilog-sig-multidim-string port-st) ""))
 	 (vl-bits (if (or verilog-auto-inst-vector
 			  (not (assoc port vector-skip-list))
@@ -8892,19 +9538,23 @@
     ;; Insert it
     (indent-to indent-pt)
     (insert "." port)
-    (indent-to verilog-auto-inst-column)
-    (insert "(" tpl-net "),")
+    (unless (and verilog-auto-inst-dot-name
+		 (equal port tpl-net))
+      (indent-to verilog-auto-inst-column)
+      (insert "(" tpl-net ")"))
+    (insert ",")
     (cond (tpl-ass
 	   (indent-to (+ (if (< verilog-auto-inst-column 48) 24 16)
 			 verilog-auto-inst-column))
-	   (insert " // Templated")
-	   (when verilog-auto-inst-template-numbers
-	     (insert " T" (int-to-string (nth 2 tpl-ass))
-		     " L" (int-to-string (nth 3 tpl-ass)))))
+	   (if verilog-auto-inst-template-numbers
+	       (verilog-insert " // Templated"
+			       " T" (int-to-string (nth 2 tpl-ass))
+			       " L" (int-to-string (nth 3 tpl-ass)))
+	     (verilog-insert " // Templated")))
 	  (for-star
 	   (indent-to (+ (if (< verilog-auto-inst-column 48) 24 16)
 			 verilog-auto-inst-column))
-	   (insert " // Implicit .\*"))) ;For some reason the . or * must be escaped...
+	   (verilog-insert " // Implicit .\*"))) ;For some reason the . or * must be escaped...
     (insert "\n")))
 ;;(verilog-auto-inst-port (list "foo" "[5:0]") 10 (list (list "foo" "a@\"(% (+ @ 1) 4)\"a")) "3")
 ;;(x "incom[@\"(+ (* 8 @) 7)\":@\"(* 8 @)\"]")
@@ -8944,8 +9594,9 @@
 
 (defun verilog-auto-inst ()
   "Expand AUTOINST statements, as part of \\[verilog-auto].
-Replace the pin connections to an instantiation with ones
-automatically derived from the module header of the instantiated netlist.
+Replace the pin connections to an instantiation or interface
+declaration with ones automatically derived from the module or
+interface header of the instantiated item.
 
 If `verilog-auto-star-expand' is set, also expand SystemVerilog .* ports,
 and delete them before saving unless `verilog-auto-star-save' is set.
@@ -8965,12 +9616,18 @@
 
   SystemVerilog multidimensional input/output has only experimental support.
 
+  SystemVerilog .name syntax is used if `verilog-auto-inst-dot-name' is set.
+
   Parameters referenced by the instantiation will remain symbolic, unless
   `verilog-auto-inst-param-value' is set.
 
+  Gate primitives (and/or) may have AUTOINST for the purpose of
+  AUTOWIRE declarations, etc.  Gates are the only case when
+  position based connections are passed.
+
 For example, first take the submodule InstModule.v:
 
-	module InstModule (o,i)
+	module InstModule (o,i);
 	   output [31:0] o;
 	   input i;
 	   wire [31:0] o = {32{i}};
@@ -8978,7 +9635,7 @@
 
 This is then used in a upper level module:
 
-	module ExampInst (o,i)
+	module ExampInst (o,i);
 	   output o;
 	   input i;
 	   InstModule instName
@@ -8987,7 +9644,7 @@
 
 Typing \\[verilog-auto] will make this into:
 
-	module ExampInst (o,i)
+	module ExampInst (o,i);
 	   output o;
 	   input i;
 	   InstModule instName
@@ -9238,7 +9895,8 @@
 
       ;; Lookup position, etc of submodule
       ;; Note this may raise an error
-      (when (setq submodi (verilog-modi-lookup submod t))
+      (when (and (not (member submod verilog-gate-keywords))
+		 (setq submodi (verilog-modi-lookup submod t)))
 	(setq submoddecls (verilog-modi-get-decls submodi))
 	;; If there's a number in the instantiation, it may be a argument to the
 	;; automatic variable instantiation program.
@@ -9249,15 +9907,28 @@
 			  "")
 		tpl-list (aref tpl-info 1)))
 	;; Find submodule's signals and dump
+	(let ((sig-list (and (equal (verilog-modi-get-type submodi) "interface")
+			     (verilog-signals-not-in
+			      (append (verilog-decls-get-wires submoddecls)
+				      (verilog-decls-get-regs submoddecls))
+			      skip-pins)))
+	      (vl-dir "interfaced"))
+	  (when sig-list
+	    (when (not did-first) (verilog-auto-inst-first) (setq did-first t))
+            ;; Note these are searched for in verilog-read-sub-decls.
+	    (verilog-insert-indent "// Interfaced\n")
+	    (mapc (lambda (port)
+                    (verilog-auto-inst-port port indent-pt
+                                            tpl-list tpl-num for-star par-values))
+                  sig-list)))
 	(let ((sig-list (verilog-signals-not-in
 			 (verilog-decls-get-interfaces submoddecls)
 			 skip-pins))
 	      (vl-dir "interface"))
 	  (when sig-list
 	    (when (not did-first) (verilog-auto-inst-first) (setq did-first t))
-	    (indent-to indent-pt)
             ;; Note these are searched for in verilog-read-sub-decls.
-	    (insert "// Interfaces\n")
+	    (verilog-insert-indent "// Interfaces\n")
 	    (mapc (lambda (port)
                     (verilog-auto-inst-port port indent-pt
                                             tpl-list tpl-num for-star par-values))
@@ -9268,8 +9939,7 @@
 	      (vl-dir "output"))
 	  (when sig-list
 	    (when (not did-first) (verilog-auto-inst-first) (setq did-first t))
-	    (indent-to indent-pt)
-	    (insert "// Outputs\n")
+	    (verilog-insert-indent "// Outputs\n")
 	    (mapc (lambda (port)
                     (verilog-auto-inst-port port indent-pt
                                             tpl-list tpl-num for-star par-values))
@@ -9280,8 +9950,7 @@
 	      (vl-dir "inout"))
 	  (when sig-list
 	    (when (not did-first) (verilog-auto-inst-first) (setq did-first t))
-	    (indent-to indent-pt)
-	    (insert "// Inouts\n")
+	    (verilog-insert-indent "// Inouts\n")
 	    (mapc (lambda (port)
                     (verilog-auto-inst-port port indent-pt
                                             tpl-list tpl-num for-star par-values))
@@ -9292,8 +9961,7 @@
 	      (vl-dir "input"))
 	  (when sig-list
 	    (when (not did-first) (verilog-auto-inst-first) (setq did-first t))
-	    (indent-to indent-pt)
-	    (insert "// Inputs\n")
+	    (verilog-insert-indent "// Inputs\n")
 	    (mapc (lambda (port)
                     (verilog-auto-inst-port port indent-pt
                                             tpl-list tpl-num for-star par-values))
@@ -9321,13 +9989,13 @@
 
 For example, first take the submodule InstModule.v:
 
-	module InstModule (o,i)
+	module InstModule (o,i);
 	   parameter PAR;
 	endmodule
 
 This is then used in a upper level module:
 
-	module ExampInst (o,i)
+	module ExampInst (o,i);
 	   parameter PAR;
 	   InstModule #(/*AUTOINSTPARAM*/)
 		instName (/*AUTOINST*/);
@@ -9335,7 +10003,7 @@
 
 Typing \\[verilog-auto] will make this into:
 
-	module ExampInst (o,i)
+	module ExampInst (o,i);
 	   output o;
 	   input i;
 	   InstModule #(/*AUTOINSTPARAM*/
@@ -9398,9 +10066,8 @@
 	      (vl-dir "parameter"))
 	  (when sig-list
 	    (when (not did-first) (verilog-auto-inst-first) (setq did-first t))
-	    (indent-to indent-pt)
             ;; Note these are searched for in verilog-read-sub-decls.
-	    (insert "// Parameters\n")
+	    (verilog-insert-indent "// Parameters\n")
 	    (mapc (lambda (port)
                     (verilog-auto-inst-port port indent-pt
                                             tpl-list tpl-num nil nil))
@@ -9428,7 +10095,7 @@
 
 An example:
 
-	module ExampReg (o,i)
+	module ExampReg (o,i);
 	   output o;
 	   input i;
 	   /*AUTOREG*/
@@ -9437,7 +10104,7 @@
 
 Typing \\[verilog-auto] will make this into:
 
-	module ExampReg (o,i)
+	module ExampReg (o,i);
 	   output o;
 	   input i;
 	   /*AUTOREG*/
@@ -9459,6 +10126,7 @@
 			      (verilog-decls-get-assigns moddecls)
 			      (verilog-decls-get-consts moddecls)
 			      (verilog-decls-get-gparams moddecls)
+			      (verilog-subdecls-get-interfaced modsubdecls)
 			      (verilog-subdecls-get-outputs modsubdecls)
 			      (verilog-subdecls-get-inouts modsubdecls)))))
       (forward-line 1)
@@ -9481,7 +10149,7 @@
 
 An example (see `verilog-auto-inst' for what else is going on here):
 
-	module ExampRegInput (o,i)
+	module ExampRegInput (o,i);
 	   output o;
 	   input i;
 	   /*AUTOREGINPUT*/
@@ -9491,7 +10159,7 @@
 
 Typing \\[verilog-auto] will make this into:
 
-	module ExampRegInput (o,i)
+	module ExampRegInput (o,i);
 	   output o;
 	   input i;
 	   /*AUTOREGINPUT*/
@@ -9543,7 +10211,7 @@
 
 An example (see `verilog-auto-inst' for what else is going on here):
 
-	module ExampWire (o,i)
+	module ExampWire (o,i);
 	   output o;
 	   input i;
 	   /*AUTOWIRE*/
@@ -9553,7 +10221,7 @@
 
 Typing \\[verilog-auto] will make this into:
 
-	module ExampWire (o,i)
+	module ExampWire (o,i);
 	   output o;
 	   input i;
 	   /*AUTOWIRE*/
@@ -9613,7 +10281,7 @@
 
 An example (see `verilog-auto-inst' for what else is going on here):
 
-	module ExampOutput (ov,i)
+	module ExampOutput (ov,i);
 	   input i;
 	   /*AUTOOUTPUT*/
 	   InstModule instName
@@ -9622,7 +10290,7 @@
 
 Typing \\[verilog-auto] will make this into:
 
-	module ExampOutput (ov,i)
+	module ExampOutput (ov,i);
 	   input i;
 	   /*AUTOOUTPUT*/
 	   // Beginning of automatic outputs (from unused autoinst outputs)
@@ -9679,7 +10347,7 @@
 
 An example:
 
-	module ExampOutputEvery (o,i,tempa,tempb)
+	module ExampOutputEvery (o,i,tempa,tempb);
 	   output o;
 	   input i;
 	   /*AUTOOUTPUTEVERY*/
@@ -9690,7 +10358,7 @@
 
 Typing \\[verilog-auto] will make this into:
 
-	module ExampOutputEvery (o,i,tempa,tempb)
+	module ExampOutputEvery (o,i,tempa,tempb);
 	   output o;
 	   input i;
 	   /*AUTOOUTPUTEVERY*/
@@ -9742,7 +10410,7 @@
 
 An example (see `verilog-auto-inst' for what else is going on here):
 
-	module ExampInput (ov,i)
+	module ExampInput (ov,i);
 	   output [31:0] ov;
 	   /*AUTOINPUT*/
 	   InstModule instName
@@ -9751,7 +10419,7 @@
 
 Typing \\[verilog-auto] will make this into:
 
-	module ExampInput (ov,i)
+	module ExampInput (ov,i);
 	   output [31:0] ov;
 	   /*AUTOINPUT*/
 	   // Beginning of automatic inputs (from unused autoinst inputs)
@@ -9786,6 +10454,7 @@
 			      (verilog-decls-get-regs moddecls)
 			      (verilog-decls-get-consts moddecls)
 			      (verilog-decls-get-gparams moddecls)
+			      (verilog-subdecls-get-interfaced modsubdecls)
 			      (verilog-subdecls-get-outputs modsubdecls)
 			      (verilog-subdecls-get-inouts modsubdecls)))))
       (when regexp
@@ -9822,7 +10491,7 @@
 
 An example (see `verilog-auto-inst' for what else is going on here):
 
-	module ExampInout (ov,i)
+	module ExampInout (ov,i);
 	   input i;
 	   /*AUTOINOUT*/
 	   InstModule instName
@@ -9831,7 +10500,7 @@
 
 Typing \\[verilog-auto] will make this into:
 
-	module ExampInout (ov,i)
+	module ExampInout (ov,i);
 	   input i;
 	   /*AUTOINOUT*/
 	   // Beginning of automatic inouts (from unused autoinst inouts)
@@ -9886,6 +10555,7 @@
 into the current module.  This is useful for making null templates and
 shell modules which need to have identical I/O with another module.
 Any I/O which are already defined in this module will not be redefined.
+For the complement of this function, see `verilog-auto-inout-comp'.
 
 Limitations:
   If placed inside the parenthesis of a module declaration, it creates
@@ -9901,11 +10571,11 @@
 
 An example:
 
-	module ExampShell (/*AUTOARG*/)
+	module ExampShell (/*AUTOARG*/);
 	   /*AUTOINOUTMODULE(\"ExampMain\")*/
 	endmodule
 
-	module ExampMain (i,o,io)
+	module ExampMain (i,o,io);
           input i;
           output o;
           inout io;
@@ -9913,7 +10583,7 @@
 
 Typing \\[verilog-auto] will make this into:
 
-	module ExampShell (/*AUTOARG*/i,o,io)
+	module ExampShell (/*AUTOARG*/i,o,io);
 	   /*AUTOINOUTMODULE(\"ExampMain\")*/
            // Beginning of automatic in/out/inouts (from specific module)
            output o;
@@ -10004,7 +10674,8 @@
 and vice-versa.)  This is useful for making test and stimulus
 modules which need to have complementing I/O with another module.
 Any I/O which are already defined in this module will not be
-redefined.
+redefined.  For the complement of this function, see
+`verilog-auto-inout-module'.
 
 Limitations:
   If placed inside the parenthesis of a module declaration, it creates
@@ -10020,11 +10691,11 @@
 
 An example:
 
-	module ExampShell (/*AUTOARG*/)
+	module ExampShell (/*AUTOARG*/);
 	   /*AUTOINOUTCOMP(\"ExampMain\")*/
 	endmodule
 
-	module ExampMain (i,o,io)
+	module ExampMain (i,o,io);
           input i;
           output o;
           inout io;
@@ -10032,7 +10703,7 @@
 
 Typing \\[verilog-auto] will make this into:
 
-	module ExampShell (/*AUTOARG*/i,o,io)
+	module ExampShell (/*AUTOARG*/i,o,io);
 	   /*AUTOINOUTCOMP(\"ExampMain\")*/
            // Beginning of automatic in/out/inouts (from specific module)
            output i;
@@ -10106,6 +10777,7 @@
       (forward-line -1)
       (eval (read cmd))
       (forward-line -1)
+      (setq verilog-scan-cache-tick nil) ;; Clear cache; inserted unknown text
       (verilog-delete-empty-auto-pair))))
 
 (defun verilog-auto-sense-sigs (moddecls presense-sigs)
@@ -10115,6 +10787,7 @@
 		    (verilog-signals-not-in (verilog-alw-get-inputs sigss)
 					    (append (and (not verilog-auto-sense-include-inputs)
 							 (verilog-alw-get-outputs sigss))
+						    (verilog-alw-get-temps sigss)
 						    (verilog-decls-get-consts moddecls)
 						    (verilog-decls-get-gparams moddecls)
 						    presense-sigs)))))
@@ -10197,7 +10870,7 @@
       (when sig-memories
 	(let ((tlen (length sig-list)))
 	  (setq sig-list (verilog-signals-not-in sig-list sig-memories))
-	  (if (not (eq tlen (length sig-list))) (insert " /*memory or*/ "))))
+	  (if (not (eq tlen (length sig-list))) (verilog-insert " /*memory or*/ "))))
       (if (and presense-sigs  ;; Add a "or" if not "(.... or /*AUTOSENSE*/"
 	       (save-excursion (goto-char (point))
 			       (verilog-re-search-backward "[a-zA-Z0-9$_.%`]+" start-pt t)
@@ -10297,12 +10970,13 @@
 			       (concat " <= " verilog-assignment-delay)
 			     " = "))
       (setq sig-list (verilog-signals-not-in (verilog-alw-get-outputs sigss)
-					     prereset-sigs))
+					     (append
+					      (verilog-alw-get-temps sigss)
+					      prereset-sigs)))
       (setq sig-list (sort sig-list `verilog-signals-sort-compare))
       (when sig-list
 	(insert "\n");
-	(indent-to indent-pt)
-	(insert "// Beginning of autoreset for uninitialized flops\n");
+	(verilog-insert-indent "// Beginning of autoreset for uninitialized flops\n");
 	(indent-to indent-pt)
 	(while sig-list
 	  (let ((sig (or (assoc (verilog-sig-name (car sig-list)) all-list) ;; As sig-list has no widths
@@ -10313,7 +10987,7 @@
 		    ";\n")
 	    (indent-to indent-pt)
 	    (setq sig-list (cdr sig-list))))
-	(insert "// End of automatics")))))
+	(verilog-insert "// End of automatics")))))
 
 (defun verilog-auto-tieoff ()
   "Expand AUTOTIEOFF statements, as part of \\[verilog-auto].
@@ -10329,6 +11003,9 @@
 Signals that match `verilog-active-low-regexp' will be deasserted by tieing
 them to a one.
 
+You can add signals you do not want included in AUTOTIEOFF with
+`verilog-auto-tieoff-ignore-regexp'.
+
 An example of making a stub for another module:
 
     module ExampStub (/*AUTOINST*/);
@@ -10369,8 +11046,11 @@
 			      (verilog-decls-get-assigns moddecls)
 			      (verilog-decls-get-consts moddecls)
 			      (verilog-decls-get-gparams moddecls)
+			      (verilog-subdecls-get-interfaced modsubdecls)
 			      (verilog-subdecls-get-outputs modsubdecls)
 			      (verilog-subdecls-get-inouts modsubdecls)))))
+      (setq sig-list (verilog-signals-not-matching-regexp
+		      sig-list verilog-auto-tieoff-ignore-regexp))
       (when sig-list
 	(forward-line 1)
 	(verilog-insert-indent "// Beginning of automatic tieoffs (for this module's unterminated outputs)\n")
@@ -10622,13 +11302,16 @@
   "Replace Templated relative line numbers with absolute line numbers.
 Internal use only.  This hacks around the line numbers in AUTOINST Templates
 being different from the final output's line numbering."
-  (let ((templateno 0) (template-line (list 0)))
+  (let ((templateno 0) (template-line (list 0)) (buf-line 1))
     ;; Find line number each template is on
+    ;; Count lines as we go, as otherwise it's O(n^2) to use count-lines
     (goto-char (point-min))
-    (while (search-forward "AUTO_TEMPLATE" nil t)
-      (setq templateno (1+ templateno))
-      (setq template-line
-	    (cons (count-lines (point-min) (point)) template-line)))
+    (while (not (eobp))
+      (when (looking-at ".*AUTO_TEMPLATE")
+	(setq templateno (1+ templateno))
+	(setq template-line (cons buf-line template-line)))
+      (setq buf-line (1+ buf-line))
+      (forward-line 1))
     (setq template-line (nreverse template-line))
     ;; Replace T# L# with absolute line number
     (goto-char (point-min))
@@ -10661,7 +11344,7 @@
 called before and after this function, respectively.
 
 For example:
-	module ModuleName (/*AUTOARG*/)
+	module ModuleName (/*AUTOARG*/);
 	/*AUTOINPUT*/
 	/*AUTOOUTPUT*/
 	/*AUTOWIRE*/
@@ -10717,89 +11400,102 @@
 		      (font-lock-mode 0)
 		      t))
 	;; Cache directories; we don't write new files, so can't change
-	(verilog-dir-cache-preserving t))
-    (unwind-protect
-	(save-excursion
-	  ;; If we're not in verilog-mode, change syntax table so parsing works right
-	  (unless (eq major-mode `verilog-mode) (verilog-mode))
-	  ;; Allow user to customize
-	  (run-hooks 'verilog-before-auto-hook)
-	  ;; Try to save the user from needing to revert-file to reread file local-variables
-	  (verilog-auto-reeval-locals)
-	  (verilog-read-auto-lisp (point-min) (point-max))
-	  (verilog-getopt-flags)
-	  ;; From here on out, we can cache anything we read from disk
-	  (verilog-preserve-dir-cache
-	   ;; These two may seem obvious to do always, but on large includes it can be way too slow
-	   (when verilog-auto-read-includes
-	     (verilog-read-includes)
-	     (verilog-read-defines nil nil t))
-	   ;; This particular ordering is important
-	   ;; INST: Lower modules correct, no internal dependencies, FIRST
-	   (verilog-preserve-modi-cache
-	    ;; Clear existing autos else we'll be screwed by existing ones
-	    (verilog-delete-auto)
-	    ;; Injection if appropriate
-	    (when inject
-	      (verilog-inject-inst)
-	      (verilog-inject-sense)
-	      (verilog-inject-arg))
-	    ;;
-	    ;; Do user inserts first, so their code can insert AUTOs
-	    ;; We may provide a AUTOINSERTLISPLAST if another cleanup pass is needed
-	    (verilog-auto-re-search-do "/\\*AUTOINSERTLISP(.*?)\\*/"
-				       'verilog-auto-insert-lisp)
-	    ;; Expand instances before need the signals the instances input/output
-	    (verilog-auto-re-search-do "/\\*AUTOINSTPARAM\\*/" 'verilog-auto-inst-param)
-	    (verilog-auto-re-search-do "/\\*AUTOINST\\*/" 'verilog-auto-inst)
-	    (verilog-auto-re-search-do "\\.\\*" 'verilog-auto-star)
-	    ;; Doesn't matter when done, but combine it with a common changer
-	    (verilog-auto-re-search-do "/\\*\\(AUTOSENSE\\|AS\\)\\*/" 'verilog-auto-sense)
-	    (verilog-auto-re-search-do "/\\*AUTORESET\\*/" 'verilog-auto-reset)
-	    ;; Must be done before autoin/out as creates a reg
-	    (verilog-auto-re-search-do "/\\*AUTOASCIIENUM([^)]*)\\*/" 'verilog-auto-ascii-enum)
-	    ;;
-	    ;; first in/outs from other files
-	    (verilog-auto-re-search-do "/\\*AUTOINOUTMODULE([^)]*)\\*/" 'verilog-auto-inout-module)
-	    (verilog-auto-re-search-do "/\\*AUTOINOUTCOMP([^)]*)\\*/" 'verilog-auto-inout-comp)
-	    ;; next in/outs which need previous sucked inputs first
-	    (verilog-auto-re-search-do "/\\*AUTOOUTPUT\\((\"[^\"]*\")\\)\\*/"
-				       '(lambda () (verilog-auto-output t)))
-	    (verilog-auto-re-search-do "/\\*AUTOOUTPUT\\*/" 'verilog-auto-output)
-	    (verilog-auto-re-search-do "/\\*AUTOINPUT\\((\"[^\"]*\")\\)\\*/"
-				       '(lambda () (verilog-auto-input t)))
-	    (verilog-auto-re-search-do "/\\*AUTOINPUT\\*/"  'verilog-auto-input)
-	    (verilog-auto-re-search-do "/\\*AUTOINOUT\\((\"[^\"]*\")\\)\\*/"
-				       '(lambda () (verilog-auto-inout t)))
-	    (verilog-auto-re-search-do "/\\*AUTOINOUT\\*/" 'verilog-auto-inout)
-	    ;; Then tie off those in/outs
-	    (verilog-auto-re-search-do "/\\*AUTOTIEOFF\\*/" 'verilog-auto-tieoff)
-	    ;; Wires/regs must be after inputs/outputs
-	    (verilog-auto-re-search-do "/\\*AUTOWIRE\\*/" 'verilog-auto-wire)
-	    (verilog-auto-re-search-do "/\\*AUTOREG\\*/" 'verilog-auto-reg)
-	    (verilog-auto-re-search-do "/\\*AUTOREGINPUT\\*/" 'verilog-auto-reg-input)
-	    ;; outputevery needs AUTOOUTPUTs done first
-	    (verilog-auto-re-search-do "/\\*AUTOOUTPUTEVERY\\*/" 'verilog-auto-output-every)
-	    ;; After we've created all new variables
-	    (verilog-auto-re-search-do "/\\*AUTOUNUSED\\*/" 'verilog-auto-unused)
-	    ;; Must be after all inputs outputs are generated
-	    (verilog-auto-re-search-do "/\\*AUTOARG\\*/" 'verilog-auto-arg)
-	    ;; Fix line numbers (comments only)
-	    (verilog-auto-templated-rel)))
-	  ;;
-	  (run-hooks 'verilog-auto-hook)
-	  ;;
-	  (set (make-local-variable 'verilog-auto-update-tick) (buffer-modified-tick))
-	  ;;
-	  ;; If end result is same as when started, clear modified flag
-	  (cond ((and oldbuf (equal oldbuf (buffer-string)))
-		 (set-buffer-modified-p nil)
-		 (unless noninteractive (message "Updating AUTOs...done (no changes)")))
-		(t (unless noninteractive (message "Updating AUTOs...done")))))
-      ;; Unwind forms
-      (progn
-	;; Restore font-lock
-	(when fontlocked (font-lock-mode t))))))
+	(verilog-dir-cache-preserving t)
+	;; Cache current module
+	(verilog-modi-cache-current-enable t)
+	(verilog-modi-cache-current-max (point-min)) ; IE it's invalid
+	verilog-modi-cache-current)
+     (unwind-protect
+	 ;; Disable change hooks for speed
+	 ;; This let can't be part of above let; must restore
+	 ;; after-change-functions before font-lock resumes
+	 (verilog-save-no-change-functions
+	  (verilog-save-scan-cache
+	   (save-excursion
+	     ;; If we're not in verilog-mode, change syntax table so parsing works right
+	     (unless (eq major-mode `verilog-mode) (verilog-mode))
+	     ;; Allow user to customize
+	     (run-hooks 'verilog-before-auto-hook)
+	     ;; Try to save the user from needing to revert-file to reread file local-variables
+	     (verilog-auto-reeval-locals)
+	     (verilog-read-auto-lisp-present)
+	     (verilog-read-auto-lisp (point-min) (point-max))
+	     (verilog-getopt-flags)
+	     ;; From here on out, we can cache anything we read from disk
+	     (verilog-preserve-dir-cache
+	      ;; These two may seem obvious to do always, but on large includes it can be way too slow
+	      (when verilog-auto-read-includes
+		(verilog-read-includes)
+		(verilog-read-defines nil nil t))
+	      ;; This particular ordering is important
+	      ;; INST: Lower modules correct, no internal dependencies, FIRST
+	      (verilog-preserve-modi-cache
+	       ;; Clear existing autos else we'll be screwed by existing ones
+	       (verilog-delete-auto)
+	       ;; Injection if appropriate
+	       (when inject
+		 (verilog-inject-inst)
+		 (verilog-inject-sense)
+		 (verilog-inject-arg))
+	       ;;
+	       ;; Do user inserts first, so their code can insert AUTOs
+	       ;; We may provide a AUTOINSERTLISPLAST if another cleanup pass is needed
+	       (verilog-auto-re-search-do "/\\*AUTOINSERTLISP(.*?)\\*/"
+					  'verilog-auto-insert-lisp)
+	       ;; Expand instances before need the signals the instances input/output
+	       (verilog-auto-re-search-do "/\\*AUTOINSTPARAM\\*/" 'verilog-auto-inst-param)
+	       (verilog-auto-re-search-do "/\\*AUTOINST\\*/" 'verilog-auto-inst)
+	       (verilog-auto-re-search-do "\\.\\*" 'verilog-auto-star)
+	       ;; Doesn't matter when done, but combine it with a common changer
+	       (verilog-auto-re-search-do "/\\*\\(AUTOSENSE\\|AS\\)\\*/" 'verilog-auto-sense)
+	       (verilog-auto-re-search-do "/\\*AUTORESET\\*/" 'verilog-auto-reset)
+	       ;; Must be done before autoin/out as creates a reg
+	       (verilog-auto-re-search-do "/\\*AUTOASCIIENUM([^)]*)\\*/" 'verilog-auto-ascii-enum)
+	       ;;
+	       ;; first in/outs from other files
+	       (verilog-auto-re-search-do "/\\*AUTOINOUTMODULE([^)]*)\\*/" 'verilog-auto-inout-module)
+	       (verilog-auto-re-search-do "/\\*AUTOINOUTCOMP([^)]*)\\*/" 'verilog-auto-inout-comp)
+	       ;; next in/outs which need previous sucked inputs first
+	       (verilog-auto-re-search-do "/\\*AUTOOUTPUT\\((\"[^\"]*\")\\)\\*/"
+					  '(lambda () (verilog-auto-output t)))
+	       (verilog-auto-re-search-do "/\\*AUTOOUTPUT\\*/" 'verilog-auto-output)
+	       (verilog-auto-re-search-do "/\\*AUTOINPUT\\((\"[^\"]*\")\\)\\*/"
+					  '(lambda () (verilog-auto-input t)))
+	       (verilog-auto-re-search-do "/\\*AUTOINPUT\\*/"  'verilog-auto-input)
+	       (verilog-auto-re-search-do "/\\*AUTOINOUT\\((\"[^\"]*\")\\)\\*/"
+					  '(lambda () (verilog-auto-inout t)))
+	       (verilog-auto-re-search-do "/\\*AUTOINOUT\\*/" 'verilog-auto-inout)
+	       ;; Then tie off those in/outs
+	       (verilog-auto-re-search-do "/\\*AUTOTIEOFF\\*/" 'verilog-auto-tieoff)
+	       ;; Wires/regs must be after inputs/outputs
+	       (verilog-auto-re-search-do "/\\*AUTOWIRE\\*/" 'verilog-auto-wire)
+	       (verilog-auto-re-search-do "/\\*AUTOREG\\*/" 'verilog-auto-reg)
+	       (verilog-auto-re-search-do "/\\*AUTOREGINPUT\\*/" 'verilog-auto-reg-input)
+	       ;; outputevery needs AUTOOUTPUTs done first
+	       (verilog-auto-re-search-do "/\\*AUTOOUTPUTEVERY\\*/" 'verilog-auto-output-every)
+	       ;; After we've created all new variables
+	       (verilog-auto-re-search-do "/\\*AUTOUNUSED\\*/" 'verilog-auto-unused)
+	       ;; Must be after all inputs outputs are generated
+	       (verilog-auto-re-search-do "/\\*AUTOARG\\*/" 'verilog-auto-arg)
+	       ;; Fix line numbers (comments only)
+	       (when verilog-auto-inst-template-numbers
+		 (verilog-auto-templated-rel))))
+	     ;;
+	     (run-hooks 'verilog-auto-hook)
+	     ;;
+	     (set (make-local-variable 'verilog-auto-update-tick) (buffer-chars-modified-tick))
+	     ;;
+	     ;; If end result is same as when started, clear modified flag
+	     (cond ((and oldbuf (equal oldbuf (buffer-string)))
+		    (set-buffer-modified-p nil)
+		    (unless noninteractive (message "Updating AUTOs...done (no changes)")))
+		   (t (unless noninteractive (message "Updating AUTOs...done"))))
+	     ;; End of after-change protection
+	     )))
+       ;; Unwind forms
+       (progn
+	 ;; Restore font-lock
+	 (when fontlocked (font-lock-mode t))))))
 
 
 ;;
@@ -11191,91 +11887,119 @@
   "Map containing mouse bindings for `verilog-mode'.")
 
 
-(defun verilog-colorize-include-files (beg end old-len)
-  "This function colorizes included files when the mouse passes over them.
+(defun verilog-highlight-region (beg end old-len)
+  "Colorize included files and modules in the (changed?) region.
 Clicking on the middle-mouse button loads them in a buffer (as in dired)."
-  (save-excursion
-    (save-match-data
-      (let (end-point)
-	(goto-char end)
-	(setq end-point (verilog-get-end-of-line))
-	(goto-char beg)
-	(beginning-of-line)  ; scan entire line !
-	;; delete overlays existing on this line
-	(let ((overlays (overlays-in (point) end-point)))
-	  (while overlays
-	    (if (and
-		 (overlay-get (car overlays) 'detachable)
-		 (overlay-get (car overlays) 'verilog-include-file))
-		(delete-overlay (car overlays)))
-	    (setq overlays (cdr overlays)))) ; let
-	;; make new ones, could reuse deleted one ?
-	(while (search-forward-regexp verilog-include-file-regexp end-point t)
-	  (let (ov)
-	    (goto-char (match-beginning 1))
-	    (setq ov (make-overlay (match-beginning 1) (match-end 1)))
-	    (overlay-put ov 'start-closed 't)
-	    (overlay-put ov 'end-closed 't)
-	    (overlay-put ov 'evaporate 't)
-	    (overlay-put ov 'verilog-include-file 't)
-	    (overlay-put ov 'mouse-face 'highlight)
-	    (overlay-put ov 'local-map verilog-mode-mouse-map)))))))
-
-
-(defun verilog-colorize-include-files-buffer ()
-  "Colorize an include file."
+  (when (or verilog-highlight-includes
+	    verilog-highlight-modules)
+    (save-excursion
+      (save-match-data  ;; A query-replace may call this function - do not disturb
+	(verilog-save-buffer-state
+	 (verilog-save-scan-cache
+	  (let (end-point)
+	    (goto-char end)
+	    (setq end-point (verilog-get-end-of-line))
+	    (goto-char beg)
+	    (beginning-of-line)  ; scan entire line
+	    ;; delete overlays existing on this line
+	    (let ((overlays (overlays-in (point) end-point)))
+	      (while overlays
+		(if (and
+		     (overlay-get (car overlays) 'detachable)
+		     (or (overlay-get (car overlays) 'verilog-include-file)
+			 (overlay-get (car overlays) 'verilog-inst-module)))
+		    (delete-overlay (car overlays)))
+		(setq overlays (cdr overlays))))
+	    ;;
+	    ;; make new include overlays
+	    (when verilog-highlight-includes
+	      (while (search-forward-regexp verilog-include-file-regexp end-point t)
+		(goto-char (match-beginning 1))
+		(let ((ov (make-overlay (match-beginning 1) (match-end 1))))
+		  (overlay-put ov 'start-closed 't)
+		  (overlay-put ov 'end-closed 't)
+		  (overlay-put ov 'evaporate 't)
+		  (overlay-put ov 'verilog-include-file 't)
+		  (overlay-put ov 'mouse-face 'highlight)
+		  (overlay-put ov 'local-map verilog-mode-mouse-map))))
+	    ;;
+	    ;; make new module overlays
+	    (goto-char beg)
+	    ;; This scanner is syntax-fragile, so don't get bent
+	    (when verilog-highlight-modules
+	      (condition-case nil
+		  (while (verilog-re-search-forward "\\(/\\*AUTOINST\\*/\\|\\.\\*\\)" end-point t)
+		    (save-excursion
+		      (goto-char (match-beginning 0))
+		      (unless (verilog-inside-comment-p)
+			(verilog-read-inst-module-matcher)   ;; sets match 0
+			(let* ((ov (make-overlay (match-beginning 0) (match-end 0))))
+			  (overlay-put ov 'start-closed 't)
+			  (overlay-put ov 'end-closed 't)
+			  (overlay-put ov 'evaporate 't)
+			  (overlay-put ov 'verilog-inst-module 't)
+			  (overlay-put ov 'mouse-face 'highlight)
+			  (overlay-put ov 'local-map verilog-mode-mouse-map)))))
+		(error nil)))
+	    ;;
+	    ;; Future highlights:
+	    ;;  variables - make an Occur buffer of where referenced
+	    ;;  pins - make an Occur buffer of the sig in the declaration module
+	    )))))))
+
+(defun verilog-highlight-buffer ()
+  "Colorize included files and modules across the whole buffer."
+  ;; Invoked via verilog-mode calling font-lock then `font-lock-mode-hook'
   (interactive)
-  ;; delete overlays
-  (let ((overlays (overlays-in (point-min) (point-max))))
-    (while overlays
-      (if (and
-	   (overlay-get (car overlays) 'detachable)
-	   (overlay-get (car overlays) 'verilog-include-file))
-	  (delete-overlay (car overlays)))
-      (setq overlays (cdr overlays)))) ; let
-  ;; remake overlays
-  (verilog-colorize-include-files (point-min) (point-max) nil))
+  ;; delete and remake overlays
+  (verilog-highlight-region (point-min) (point-max) nil))
+
+;; Deprecated, but was interactive, so we'll keep it around
+(defalias 'verilog-colorize-include-files-buffer 'verilog-highlight-buffer)
 
 ;; ffap-at-mouse isn't useful for Verilog mode. It uses library paths.
 ;; so define this function to do more or less the same as ffap-at-mouse
 ;; but first resolve filename...
 (defun verilog-load-file-at-mouse (event)
   "Load file under button 2 click's EVENT.
-Files are checked based on `verilog-library-directories'."
+Files are checked based on `verilog-library-flags'."
   (interactive "@e")
   (save-excursion ;; implement a Verilog specific ffap-at-mouse
     (mouse-set-point event)
-    (beginning-of-line)
-    (if (looking-at verilog-include-file-regexp)
+    (verilog-load-file-at-point t)))
+
+;; ffap isn't useable for Verilog mode. It uses library paths.
+;; so define this function to do more or less the same as ffap
+;; but first resolve filename...
+(defun verilog-load-file-at-point (&optional warn)
+  "Load file under point.
+If WARN, throw warning if not found.
+Files are checked based on `verilog-library-flags'."
+  (interactive)
+  (save-excursion ;; implement a Verilog specific ffap
+    (let ((overlays (overlays-in (point) (point)))
+	  hit)
+      (while (and overlays (not hit))
+	(when (overlay-get (car overlays) 'verilog-inst-module)
+	  (verilog-goto-defun-file (buffer-substring
+				    (overlay-start (car overlays))
+				    (overlay-end (car overlays))))
+	  (setq hit t))
+	(setq overlays (cdr overlays)))
+      ;; Include?
+      (beginning-of-line)
+      (when (and (not hit)
+		 (looking-at verilog-include-file-regexp))
 	(if (and (car (verilog-library-filenames
 		       (match-string 1) (buffer-file-name)))
 		 (file-readable-p (car (verilog-library-filenames
 					(match-string 1) (buffer-file-name)))))
 	    (find-file (car (verilog-library-filenames
 			     (match-string 1) (buffer-file-name))))
-	  (progn
+	  (when warn
 	    (message
 	     "File '%s' isn't readable, use shift-mouse2 to paste in this field"
-	     (match-string 1)))))))
-
-;; ffap isn't useable for Verilog mode. It uses library paths.
-;; so define this function to do more or less the same as ffap
-;; but first resolve filename...
-(defun verilog-load-file-at-point ()
-  "Load file under point.
-Files are checked based on `verilog-library-directories'."
-  (interactive)
-  (save-excursion ;; implement a Verilog specific ffap
-    (beginning-of-line)
-    (if (looking-at verilog-include-file-regexp)
-	(if (and
-	     (car (verilog-library-filenames
-		   (match-string 1) (buffer-file-name)))
-	     (file-readable-p (car (verilog-library-filenames
-				    (match-string 1) (buffer-file-name)))))
-	    (find-file (car (verilog-library-filenames
-			     (match-string 1) (buffer-file-name))))))))
-
+	     (match-string 1))))))))
 
 ;;
 ;; Bug reporting
@@ -11305,22 +12029,43 @@
      "mac@verilog.com, wsnyder@wsnyder.org"
      (concat "verilog-mode v" verilog-mode-version)
      '(
+       verilog-active-low-regexp
        verilog-align-ifelse
+       verilog-assignment-delay
+       verilog-auto-arg-sort
        verilog-auto-endcomments
        verilog-auto-hook
+       verilog-auto-ignore-concat
        verilog-auto-indent-on-newline
+       verilog-auto-inout-ignore-regexp
+       verilog-auto-input-ignore-regexp
+       verilog-auto-inst-column
+       verilog-auto-inst-dot-name
+       verilog-auto-inst-param-value
+       verilog-auto-inst-template-numbers
        verilog-auto-inst-vector
-       verilog-auto-inst-template-numbers
        verilog-auto-lineup
        verilog-auto-newline
+       verilog-auto-output-ignore-regexp
+       verilog-auto-read-includes
+       verilog-auto-reset-widths
        verilog-auto-save-policy
        verilog-auto-sense-defines-constant
        verilog-auto-sense-include-inputs
+       verilog-auto-star-expand
+       verilog-auto-star-save
+       verilog-auto-unused-ignore-regexp
        verilog-before-auto-hook
+       verilog-before-delete-auto-hook
+       verilog-before-getopt-flags-hook
        verilog-case-indent
        verilog-cexp-indent
        verilog-compiler
        verilog-coverage
+       verilog-delete-auto-hook
+       verilog-getopt-flags-hook
+       verilog-highlight-grouping-keywords
+       verilog-highlight-p1800-keywords
        verilog-highlight-translate-off
        verilog-indent-begin-after-if
        verilog-indent-declaration-macros
@@ -11330,16 +12075,18 @@
        verilog-indent-level-directive
        verilog-indent-level-module
        verilog-indent-lists
-       verilog-library-flags
        verilog-library-directories
        verilog-library-extensions
        verilog-library-files
+       verilog-library-flags
        verilog-linter
        verilog-minimum-comment-distance
        verilog-mode-hook
+       verilog-preprocessor
        verilog-simulator
        verilog-tab-always-indent
        verilog-tab-to-comment
+       verilog-typedef-regexp
        )
      nil nil
      (concat "Hi Mac,
--- a/lisp/ps-mule.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/ps-mule.el	Thu Oct 28 19:57:59 2010 +0900
@@ -320,31 +320,19 @@
 
 See also `ps-mule-font-info-database-bdf'.")
 
-(defvar ps-mule-font-spec-list nil
-  "Array of FONT-SPEC lists for each font type.
-
-Elements are for `normal' font, `bold' font, `italic' font, and
-`bold-italic' font in this order.
-
-Each element is a list of FONT-SPEC which has this form:
-
-	(ID CHARSET (FONT-SRC FONT-NAME ENCODING) EXTRA-DATA)
-
-Where
+;; Functions to access each element of FONT-SPEC.
+;;
+;; FONT-SPEC is a vector of this form:
+;; 	[ID CHARSET FONT-ID FONT-SRC FONT-NAME ENCODING BYTES EXTRA-DATA]
+;; Where
+;;
+;; ID is an identification number for this FONT-SPEC and is unique in the list.
+;;
+;; CHARSET, FONT-SRC, FONT-NAME, ENCODING, and BYTES are the same as those in
+;; `ps-mule-font-info-database' (which see).
+;;
+;; EXTRA-DATA is a data attached by external libraries.
 
-ID is a number for this FONT-SPEC and is unique in the list.
-
-CHARSET, FONT-SRC, FONT-NAME, ENCODING are the same as those in
-`ps-mule-font-info-database' (which see).
-
-EXTRA-DATA is a data attached by external libraries.
-
-Each list is ordered by the current charset priorities.
-
-This variable is setup by `ps-mule-begin-job' from
-`ps-mule-font-info-database'.")
-
-;; Functions to access each element of FONT-SPEC.
 (defsubst ps-mule-font-spec-id (font-spec) (aref font-spec 0))
 (defsubst ps-mule-font-spec-charset (font-spec) (aref font-spec 1))
 (defsubst ps-mule-font-spec-font-id (font-spec) (aref font-spec 2))
@@ -1044,7 +1032,7 @@
   (if (and (not (find-composition from to))
 	   (save-excursion
 	     (goto-char from)
-	     (= (skip-chars-forward "\x00-\xFF" to) to)))
+	     (= (skip-chars-forward "\x00-\x7F" to) to)))
       ;; All characters can be printed by normal PostScript fonts.
       (setq ps-basic-plot-string-function 'ps-basic-plot-string
 	    ps-encode-header-string-function 'identity)
@@ -1086,17 +1074,19 @@
 	      (setq font-info-list (cons font-info font-info-list))))
 	(setq font-info-list (nreverse font-info-list)))
 
+      ;; Now font-info-list is an alist ordered by charset priority.
       ;; Store FONT-SPECs in each element of font-spec-alist.
       (dolist (font-info font-info-list)
 	(let ((font-spec-vec (make-vector 4 nil))
 	      (charset (car font-info))
-	      encoding font-spec)
+	      encoding bytes font-spec)
 	  (dolist (e (cdr font-info))
-	    (setq encoding (or (nth 3 e) charset)
-		  font-spec (vector id-max charset font-id
+	    (setq encoding (nth 3 e) bytes (nth 4 e))
+	    (unless encoding
+	      (setq encoding charset bytes (charset-dimension charset)))
+	    (setq font-spec (vector id-max charset font-id
 				    (nth 1 e) (nth 2 e) encoding
-				    (or (nth 4 e) (charset-dimension encoding))
-				    nil)
+				    (or bytes 1) nil)
 		  id-max (1+ id-max))
 	    (if (ps-mule-check-font font-spec)
 		(aset font-spec-vec
--- a/lisp/ps-print.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/ps-print.el	Thu Oct 28 19:57:59 2010 +0900
@@ -1466,12 +1466,9 @@
 (require 'lpr)
 
 
-(or (featurep 'lisp-float-type)
-    (error "`ps-print' requires floating point support"))
-
-
 (if (featurep 'xemacs)
-    ()
+    (or (featurep 'lisp-float-type)
+	(error "`ps-print' requires floating point support"))
   (unless (and (boundp 'emacs-major-version)
 	       (>= emacs-major-version 23))
     (error "`ps-print' only supports Emacs 23 and higher")))
@@ -6656,7 +6653,7 @@
 ;; But autoload them here to make the separation invisible.
 
 ;;;### (autoloads (ps-mule-end-job ps-mule-begin-job ps-mule-initialize
-;;;;;;  ps-multibyte-buffer) "ps-mule" "ps-mule.el" "d2fcad95db7404989362657faf744796")
+;;;;;;  ps-multibyte-buffer) "ps-mule" "ps-mule.el" "26f1d5db9476d0e84ab55627fbb72b1b")
 ;;; Generated autoloads from ps-mule.el
 
 (defvar ps-multibyte-buffer nil "\
@@ -6726,5 +6723,4 @@
 
 (provide 'ps-print)
 
-;; arch-tag: fb06a585-1112-4206-885d-a57d95d50579
 ;;; ps-print.el ends here
--- a/lisp/repeat.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/repeat.el	Thu Oct 28 19:57:59 2010 +0900
@@ -335,7 +335,7 @@
 	(setq real-last-command 'repeat)
 	(setq repeat-undo-count 1)
 	(unwind-protect
-	    (while (let ((evt (read-event))) ;FIXME: read-key maybe?
+	    (while (let ((evt (read-key)))
                      ;; For clicks, we need to strip the meta-data to
                      ;; check the underlying event name.
                      (eq (or (car-safe evt) evt)
--- a/lisp/select.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/select.el	Thu Oct 28 19:57:59 2010 +0900
@@ -1,12 +1,11 @@
 ;;; select.el --- lisp portion of standard selection support
 
+;; Copyright (C) 1993, 1994, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
+;;   2008, 2009, 2010  Free Software Foundation, Inc.
+
 ;; Maintainer: FSF
 ;; Keywords: internal
 
-;; Copyright (C) 1993, 1994, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
-;;   2008, 2009, 2010 Free Software Foundation, Inc.
-;; Based partially on earlier release by Lucid.
-
 ;; This file is part of GNU Emacs.
 
 ;; GNU Emacs is free software: you can redistribute it and/or modify
@@ -24,11 +23,20 @@
 
 ;;; Commentary:
 
+;; Based partially on earlier release by Lucid.
+
 ;;; Code:
 
 (defcustom selection-coding-system nil
-  "Coding system for communicating with other X clients.
+  "Coding system for communicating with other programs.
 
+For MS-Windows and MS-DOS:
+When sending or receiving text via selection and clipboard, the text
+is encoded or decoded by this coding system.  The default value is
+the current system default encoding on 9x/Me, `utf-16le-dos'
+\(Unicode) on NT/W2K/XP, and `iso-latin-1-dos' on MS-DOS.
+
+For X Windows:
 When sending text via selection and clipboard, if the target
 data-type matches with the type of this coding system, it is used
 for encoding the text.  Otherwise (including the case that this
@@ -58,11 +66,11 @@
          (set symbol value)))
 
 (defvar next-selection-coding-system nil
-  "Coding system for the next communication with other X clients.
+  "Coding system for the next communication with other programs.
 Usually, `selection-coding-system' is used for communicating with
-other X clients.  But, if this variable is set, it is used for
-the next communication only.  After the communication, this
-variable is set to nil.")
+other programs (X Windows clients or MS Windows programs).  But, if this
+variable is set, it is used for the next communication only.
+After the communication, this variable is set to nil.")
 
 (declare-function x-get-selection-internal "xselect.c"
 		  (selection-symbol target-type &optional time-stamp))
@@ -380,5 +388,4 @@
 
 (provide 'select)
 
-;; arch-tag: bb634f97-8a3b-4b0a-b940-f6e09982328c
 ;;; select.el ends here
--- a/lisp/server.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/server.el	Thu Oct 28 19:57:59 2010 +0900
@@ -110,8 +110,19 @@
           (string :tag "Name or IP address")
           (const :tag "Local" nil))
   :version "22.1")
+;;;###autoload
 (put 'server-host 'risky-local-variable t)
 
+(defcustom server-port nil
+  "The port number that the server process should listen on."
+  :group 'server
+  :type '(choice
+          (string :tag "Port number")
+          (const :tag "Random" nil))
+  :version "24.1")
+;;;###autoload
+(put 'server-port 'risky-local-variable t)
+
 (defcustom server-auth-dir (locate-user-emacs-file "server/")
   "Directory for server authentication files.
 
@@ -122,6 +133,7 @@
   :group 'server
   :type 'directory
   :version "22.1")
+;;;###autoload
 (put 'server-auth-dir 'risky-local-variable t)
 
 (defcustom server-raise-frame t
@@ -564,7 +576,7 @@
 		       ;; The other args depend on the kind of socket used.
 		       (if server-use-tcp
 			   (list :family 'ipv4  ;; We're not ready for IPv6 yet
-				 :service t
+				 :service (or server-port t)
 				 :host (or server-host 'local)
 				 :plist '(:authenticated nil))
 			 (list :family 'local
@@ -1473,5 +1485,4 @@
 
 (provide 'server)
 
-;; arch-tag: 1f7ecb42-f00a-49f8-906d-61995d84c8d6
 ;;; server.el ends here
--- a/lisp/simple.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/simple.el	Thu Oct 28 19:57:59 2010 +0900
@@ -3685,8 +3685,6 @@
       (marker-position (mark-marker))
     (signal 'mark-inactive nil)))
 
-(declare-function x-selection-owner-p "xselect.c" (&optional selection))
-
 (defsubst deactivate-mark (&optional force)
   "Deactivate the mark by setting `mark-active' to nil.
 Unless FORCE is non-nil, this function does nothing if Transient
@@ -6628,7 +6626,7 @@
 
 	     (if enabled
 		 (progn
-		   (define-key local-function-key-map [delete] [?\C-d])
+		   (define-key local-function-key-map [delete] [deletechar])
 		   (define-key local-function-key-map [kp-delete] [?\C-d])
 		   (define-key local-function-key-map [backspace] [?\C-?])
                    (dolist (b bindings)
@@ -6764,5 +6762,4 @@
 
 (provide 'simple)
 
-;; arch-tag: 24af67c0-2a49-44f6-b3b1-312d8b570dfd
 ;;; simple.el ends here
--- a/lisp/startup.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/startup.el	Thu Oct 28 19:57:59 2010 +0900
@@ -200,47 +200,47 @@
     ;;("-bw" .              x-handle-numeric-switch)
     ;;("-d" .               x-handle-display)
     ;;("-display" .         x-handle-display)
-    ("-name" 1 ns-handle-name-switch)
-    ("-title" 1 ns-handle-switch title)
-    ("-T" 1 ns-handle-switch title)
-    ("-r" 0 ns-handle-switch reverse t)
-    ("-rv" 0 ns-handle-switch reverse t)
-    ("-reverse" 0 ns-handle-switch reverse t)
-    ("-fn" 1 ns-handle-switch font)
-    ("-font" 1 ns-handle-switch font)
-    ("-ib" 1 ns-handle-numeric-switch internal-border-width)
+    ("-name" 1 x-handle-name-switch)
+    ("-title" 1 x-handle-switch title)
+    ("-T" 1 x-handle-switch title)
+    ("-r" 0 x-handle-switch reverse t)
+    ("-rv" 0 x-handle-switch reverse t)
+    ("-reverse" 0 x-handle-switch reverse t)
+    ("-fn" 1 x-handle-switch font)
+    ("-font" 1 x-handle-switch font)
+    ("-ib" 1 x-handle-numeric-switch internal-border-width)
     ;;("-g" .               x-handle-geometry)
     ;;("-geometry" .        x-handle-geometry)
-    ("-fg" 1 ns-handle-switch foreground-color)
-    ("-foreground" 1 ns-handle-switch foreground-color)
-    ("-bg" 1 ns-handle-switch background-color)
-    ("-background" 1 ns-handle-switch background-color)
-;    ("-ms" 1 ns-handle-switch mouse-color)
-    ("-itype" 0 ns-handle-switch icon-type t)
-    ("-i" 0 ns-handle-switch icon-type t)
-    ("-iconic" 0 ns-handle-iconic icon-type t)
+    ("-fg" 1 x-handle-switch foreground-color)
+    ("-foreground" 1 x-handle-switch foreground-color)
+    ("-bg" 1 x-handle-switch background-color)
+    ("-background" 1 x-handle-switch background-color)
+;    ("-ms" 1 x-handle-switch mouse-color)
+    ("-itype" 0 x-handle-switch icon-type t)
+    ("-i" 0 x-handle-switch icon-type t)
+    ("-iconic" 0 x-handle-iconic icon-type t)
     ;;("-xrm" .             x-handle-xrm-switch)
-    ("-cr" 1 ns-handle-switch cursor-color)
-    ("-vb" 0 ns-handle-switch vertical-scroll-bars t)
-    ("-hb" 0 ns-handle-switch horizontal-scroll-bars t)
-    ("-bd" 1 ns-handle-switch)
-    ;; ("--border-width" 1 ns-handle-numeric-switch border-width)
+    ("-cr" 1 x-handle-switch cursor-color)
+    ("-vb" 0 x-handle-switch vertical-scroll-bars t)
+    ("-hb" 0 x-handle-switch horizontal-scroll-bars t)
+    ("-bd" 1 x-handle-switch)
+    ;; ("--border-width" 1 x-handle-numeric-switch border-width)
     ;; ("--display" 1 ns-handle-display)
-    ("--name" 1 ns-handle-name-switch)
-    ("--title" 1 ns-handle-switch title)
-    ("--reverse-video" 0 ns-handle-switch reverse t)
-    ("--font" 1 ns-handle-switch font)
-    ("--internal-border" 1 ns-handle-numeric-switch internal-border-width)
+    ("--name" 1 x-handle-name-switch)
+    ("--title" 1 x-handle-switch title)
+    ("--reverse-video" 0 x-handle-switch reverse t)
+    ("--font" 1 x-handle-switch font)
+    ("--internal-border" 1 x-handle-numeric-switch internal-border-width)
     ;; ("--geometry" 1 ns-handle-geometry)
-    ("--foreground-color" 1 ns-handle-switch foreground-color)
-    ("--background-color" 1 ns-handle-switch background-color)
-    ("--mouse-color" 1 ns-handle-switch mouse-color)
-    ("--icon-type" 0 ns-handle-switch icon-type t)
-    ("--iconic" 0 ns-handle-iconic)
+    ("--foreground-color" 1 x-handle-switch foreground-color)
+    ("--background-color" 1 x-handle-switch background-color)
+    ("--mouse-color" 1 x-handle-switch mouse-color)
+    ("--icon-type" 0 x-handle-switch icon-type t)
+    ("--iconic" 0 x-handle-iconic)
     ;; ("--xrm" 1 ns-handle-xrm-switch)
-    ("--cursor-color" 1 ns-handle-switch cursor-color)
-    ("--vertical-scroll-bars" 0 ns-handle-switch vertical-scroll-bars t)
-    ("--border-color" 1 ns-handle-switch border-width))
+    ("--cursor-color" 1 x-handle-switch cursor-color)
+    ("--vertical-scroll-bars" 0 x-handle-switch vertical-scroll-bars t)
+    ("--border-color" 1 x-handle-switch border-width))
   "Alist of NS options.
 Each element has the form
   (NAME NUMARGS HANDLER FRAME-PARAM VALUE)
@@ -1563,21 +1563,26 @@
 		 (kill-buffer "*GNU Emacs*")))
        "  ")
       (when (or user-init-file custom-file)
-	(insert-button
-	 " "
-	 :on-glyph image-checkbox-checked
-	 :off-glyph image-checkbox-unchecked
-	 'checked nil 'display image-checkbox-unchecked 'follow-link t
-	 'action (lambda (button)
-		   (if (overlay-get button 'checked)
-		       (progn (overlay-put button 'checked nil)
-			      (overlay-put button 'display
-					   (overlay-get button :off-glyph))
-			      (setq startup-screen-inhibit-startup-screen nil))
-		     (overlay-put button 'checked t)
-		     (overlay-put button 'display
-				  (overlay-get button :on-glyph))
-		     (setq startup-screen-inhibit-startup-screen t))))
+	(let ((checked (create-image "checked.xpm"
+				     nil nil :ascent 'center))
+	      (unchecked (create-image "unchecked.xpm"
+				       nil nil :ascent 'center)))
+	  (insert-button
+	   " "
+	   :on-glyph checked
+	   :off-glyph unchecked
+	   'checked nil 'display unchecked 'follow-link t
+	   'action (lambda (button)
+		     (if (overlay-get button 'checked)
+			 (progn (overlay-put button 'checked nil)
+				(overlay-put button 'display
+					     (overlay-get button :off-glyph))
+				(setq startup-screen-inhibit-startup-screen
+				      nil))
+		       (overlay-put button 'checked t)
+		       (overlay-put button 'display
+				    (overlay-get button :on-glyph))
+		       (setq startup-screen-inhibit-startup-screen t)))))
 	(fancy-splash-insert :face '(variable-pitch (:height 0.9))
 			     " Never show it again.")))))
 
--- a/lisp/subr.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/subr.el	Thu Oct 28 19:57:59 2010 +0900
@@ -289,14 +289,11 @@
 If N is non-nil, return the Nth-to-last link of LIST.
 If N is bigger than the length of LIST, return LIST."
   (if n
-      (let ((m 0) (p list))
-	(while (consp p)
-	  (setq m (1+ m) p (cdr p)))
-	(if (<= n 0) p
-	  (if (< n m) (nthcdr (- m n) list) list)))
-    (while (consp (cdr list))
-      (setq list (cdr list)))
-    list))
+      (and (>= n 0)
+           (let ((m (safe-length list)))
+             (if (< n m) (nthcdr (- m n) list) list)))
+    (and list
+         (nthcdr (1- (safe-length list)) list))))
 
 (defun butlast (list &optional n)
   "Return a copy of LIST with the last N elements removed."
--- a/lisp/term/common-win.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/term/common-win.el	Thu Oct 28 19:57:59 2010 +0900
@@ -1,7 +1,7 @@
 ;;; common-win.el --- common part of handling window systems
 
 ;; Copyright (C) 1993, 1994, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
-;;   2008, 2009, 2010 Free Software Foundation, Inc.
+;;   2008, 2009, 2010  Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 ;; Keywords: terminals
@@ -25,54 +25,139 @@
 
 ;;; Code:
 
+(defcustom x-select-enable-clipboard t
+  "Non-nil means cutting and pasting uses the clipboard.
+This is in addition to, but in preference to, the primary selection.
+
+Note that MS-Windows does not support selection types other than the
+clipboard.  (The primary selection that is set by Emacs is not
+accessible to other programs on MS-Windows.)
+
+This variable is not used by the Nextstep port."
+  :type 'boolean
+  :group 'killing
+  ;; The GNU/Linux version changed in 24.1, the MS-Windows version did not.
+  :version "24.1")
+
+(defvar x-last-selected-text)		; w32-fns.el
+(declare-function w32-set-clipboard-data "w32select.c"
+		  (string &optional ignored))
+(defvar ns-last-selected-text)		; ns-win.el
+(declare-function ns-set-pasteboard "ns-win" (string))
+
+(defun x-select-text (text)
+  "Select TEXT, a string, according to the window system.
+
+On X, if `x-select-enable-clipboard' is non-nil, copy TEXT to the
+clipboard.  If `x-select-enable-primary' is non-nil, put TEXT in
+the primary selection.
+
+On MS-Windows, make TEXT the current selection.  If
+`x-select-enable-clipboard' is non-nil, copy the text to the
+clipboard as well.
+
+On Nextstep, put TEXT in the pasteboard (`x-select-enable-clipboard'
+is not used)."
+  (cond ((eq system-type 'windows-nt)
+	 (if x-select-enable-clipboard
+	     (w32-set-clipboard-data text))
+	 (setq x-last-selected-text text))
+	((featurep 'ns)
+	 ;; Don't send the pasteboard too much text.
+	 ;; It becomes slow, and if really big it causes errors.
+	 (ns-set-pasteboard text)
+	 (setq ns-last-selected-text text))
+	(t
+	 ;; With multi-tty, this function may be called from a tty frame.
+	 (when (eq (framep (selected-frame)) 'x)
+	   (when x-select-enable-primary
+	     (x-set-selection 'PRIMARY text)
+	     (setq x-last-selected-text-primary text))
+	   (when x-select-enable-clipboard
+	     (x-set-selection 'CLIPBOARD text)
+	     (setq x-last-selected-text-clipboard text))))))
+
+;;;; Function keys
+
+(defvar x-alternatives-map
+  (let ((map (make-sparse-keymap)))
+    ;; Map certain keypad keys into ASCII characters that people usually expect.
+    (define-key map [M-backspace] [?\M-\d])
+    (define-key map [M-delete] [?\M-\d])
+    (define-key map [M-tab] [?\M-\t])
+    (define-key map [M-linefeed] [?\M-\n])
+    (define-key map [M-clear] [?\M-\C-l])
+    (define-key map [M-return] [?\M-\C-m])
+    (define-key map [M-escape] [?\M-\e])
+    (unless (featurep 'ns)
+      (define-key map [iso-lefttab] [backtab])
+      (define-key map [S-iso-lefttab] [backtab]))
+    (and (or (eq system-type 'windows-nt)
+	     (featurep 'ns))
+	 (define-key map [S-tab] [backtab]))
+    map)
+  "Keymap of possible alternative meanings for some keys.")
+
+(defun x-setup-function-keys (frame)
+  "Set up `function-key-map' on the graphical frame FRAME."
+  ;; Don't do this twice on the same display, or it would break
+  ;; normal-erase-is-backspace-mode.
+  (unless (terminal-parameter frame 'x-setup-function-keys)
+    ;; Map certain keypad keys into ASCII characters that people usually expect.
+    (with-selected-frame frame
+      (let ((map (copy-keymap x-alternatives-map)))
+        (set-keymap-parent map (keymap-parent local-function-key-map))
+        (set-keymap-parent local-function-key-map map))
+      (when (featurep 'ns)
+	(setq interprogram-cut-function 'x-select-text
+	      interprogram-paste-function 'x-selection-value
+	      system-key-alist
+	      (list
+	       ;; These are special "keys" used to pass events from C to lisp.
+	       (cons (logior (lsh 0 16)   1) 'ns-power-off)
+	       (cons (logior (lsh 0 16)   2) 'ns-open-file)
+	       (cons (logior (lsh 0 16)   3) 'ns-open-temp-file)
+	       (cons (logior (lsh 0 16)   4) 'ns-drag-file)
+	       (cons (logior (lsh 0 16)   5) 'ns-drag-color)
+	       (cons (logior (lsh 0 16)   6) 'ns-drag-text)
+	       (cons (logior (lsh 0 16)   7) 'ns-change-font)
+	       (cons (logior (lsh 0 16)   8) 'ns-open-file-line)
+;;;	       (cons (logior (lsh 0 16)   9) 'ns-insert-working-text)
+;;;	       (cons (logior (lsh 0 16)  10) 'ns-delete-working-text)
+	       (cons (logior (lsh 0 16)  11) 'ns-spi-service-call)
+;;;	       (cons (logior (lsh 0 16)  12) 'ns-new-frame)
+	       (cons (logior (lsh 0 16)  13) 'ns-toggle-toolbar)
+;;;	       (cons (logior (lsh 0 16)  14) 'ns-show-prefs)
+	       ))))
+    (set-terminal-parameter frame 'x-setup-function-keys t)))
 
 (defvar x-invocation-args)
 
 (defvar x-command-line-resources nil)
 
 ;; Handler for switches of the form "-switch value" or "-switch".
-(defun x-handle-switch (switch)
+(defun x-handle-switch (switch &optional numeric)
   (let ((aelt (assoc switch command-line-x-option-alist)))
     (if aelt
-	(let ((param (nth 3 aelt))
-	      (value (nth 4 aelt)))
-	  (if value
-	      (setq default-frame-alist
-		    (cons (cons param value)
-			  default-frame-alist))
-	    (setq default-frame-alist
-		  (cons (cons param
-			      (car x-invocation-args))
-			default-frame-alist)
-		  x-invocation-args (cdr x-invocation-args)))))))
+	(setq default-frame-alist
+	      (cons (cons (nth 3 aelt)
+			  (if numeric
+			      (string-to-number (pop x-invocation-args))
+			    (or (nth 4 aelt) (pop x-invocation-args))))
+		    default-frame-alist)))))
 
 ;; Handler for switches of the form "-switch n"
 (defun x-handle-numeric-switch (switch)
-  (let ((aelt (assoc switch command-line-x-option-alist)))
-    (if aelt
-	(let ((param (nth 3 aelt)))
-	  (setq default-frame-alist
-		(cons (cons param
-			    (string-to-number (car x-invocation-args)))
-		      default-frame-alist)
-		x-invocation-args
-		(cdr x-invocation-args))))))
+  (x-handle-switch switch t))
 
 ;; Handle options that apply to initial frame only
 (defun x-handle-initial-switch (switch)
   (let ((aelt (assoc switch command-line-x-option-alist)))
     (if aelt
-	(let ((param (nth 3 aelt))
-	      (value (nth 4 aelt)))
-	  (if value
-	      (setq initial-frame-alist
-		    (cons (cons param value)
-			  initial-frame-alist))
-	    (setq initial-frame-alist
-		  (cons (cons param
-			      (car x-invocation-args))
-			initial-frame-alist)
-		  x-invocation-args (cdr x-invocation-args)))))))
+	(setq initial-frame-alist
+	      (cons (cons (nth 3 aelt)
+			  (or (nth 4 aelt) (pop x-invocation-args)))
+		    initial-frame-alist)))))
 
 ;; Make -iconic apply only to the initial frame!
 (defun x-handle-iconic (switch)
@@ -85,15 +170,14 @@
     (error "%s: missing argument to `%s' option" (invocation-name) switch))
   (setq x-command-line-resources
 	(if (null x-command-line-resources)
-	    (car x-invocation-args)
-	  (concat x-command-line-resources "\n" (car x-invocation-args))))
-  (setq x-invocation-args (cdr x-invocation-args)))
+	    (pop x-invocation-args)
+	  (concat x-command-line-resources "\n" (pop x-invocation-args)))))
 
 (declare-function x-parse-geometry "frame.c" (string))
 
 ;; Handle the geometry option
 (defun x-handle-geometry (switch)
-  (let* ((geo (x-parse-geometry (car x-invocation-args)))
+  (let* ((geo (x-parse-geometry (pop x-invocation-args)))
 	 (left (assq 'left geo))
 	 (top (assq 'top geo))
 	 (height (assq 'height geo))
@@ -114,8 +198,7 @@
 	      (append initial-frame-alist
 		      '((user-position . t))
 		      (if left (list left))
-		      (if top (list top)))))
-    (setq x-invocation-args (cdr x-invocation-args))))
+		      (if top (list top)))))))
 
 (defvar x-resource-name)
 
@@ -125,9 +208,8 @@
 (defun x-handle-name-switch (switch)
   (or (consp x-invocation-args)
       (error "%s: missing argument to `%s' option" (invocation-name) switch))
-  (setq x-resource-name (car x-invocation-args)
-	x-invocation-args (cdr x-invocation-args))
-  (setq initial-frame-alist (cons (cons 'name x-resource-name)
+  (setq x-resource-name (pop x-invocation-args)
+	initial-frame-alist (cons (cons 'name x-resource-name)
 				  initial-frame-alist)))
 
 (defvar x-display-name nil
@@ -137,8 +219,7 @@
 
 (defun x-handle-display (switch)
   "Handle -display DISPLAY option."
-  (setq x-display-name (car x-invocation-args)
-	x-invocation-args (cdr x-invocation-args))
+  (setq x-display-name (pop x-invocation-args))
   ;; Make subshell programs see the same DISPLAY value Emacs really uses.
   ;; Note that this isn't completely correct, since Emacs can use
   ;; multiple displays.  However, there is no way to tell an already
@@ -146,21 +227,25 @@
   (setenv "DISPLAY" x-display-name))
 
 (defun x-handle-args (args)
-  "Process the X-related command line options in ARGS.
-This is done before the user's startup file is loaded.  They are copied to
-`x-invocation-args', from which the X-related things are extracted, first
-the switch (e.g., \"-fg\") in the following code, and possible values
-\(e.g., \"black\") in the option handler code (e.g., x-handle-switch).
-This function returns ARGS minus the arguments that have been processed."
+  "Process the X (or Nextstep) related command line options in ARGS.
+This is done before the user's startup file is loaded.
+Copies the options in ARGS to `x-invocation-args'.  It then extracts
+the X (or Nextstep) options according to the handlers defined in
+`command-line-x-option-alist' (or `command-line-ns-option-alist').
+For example, `x-handle-switch' handles a switch like \"-fg\" and its
+value \"black\".  This function returns ARGS minus the arguments that
+have been processed."
   ;; We use ARGS to accumulate the args that we don't handle here, to return.
-  (setq x-invocation-args args
+  (setq x-invocation-args args		; FIXME let-bind?
 	args nil)
   (while (and x-invocation-args
 	      (not (equal (car x-invocation-args) "--")))
-    (let* ((this-switch (car x-invocation-args))
+    (let* ((this-switch (pop x-invocation-args))
 	   (orig-this-switch this-switch)
+	   (option-alist (if (featurep 'ns)
+			     command-line-ns-option-alist
+			   command-line-x-option-alist))
 	   completion argval aelt handler)
-      (setq x-invocation-args (cdr x-invocation-args))
       ;; Check for long options with attached arguments
       ;; and separate out the attached option argument into argval.
       (if (string-match "^--[^=]*=" this-switch)
@@ -169,17 +254,17 @@
       ;; Complete names of long options.
       (if (string-match "^--" this-switch)
 	  (progn
-	    (setq completion (try-completion this-switch command-line-x-option-alist))
+	    (setq completion (try-completion this-switch option-alist))
 	    (if (eq completion t)
 		;; Exact match for long option.
 		nil
 	      (if (stringp completion)
-		  (let ((elt (assoc completion command-line-x-option-alist)))
+		  (let ((elt (assoc completion option-alist)))
 		    ;; Check for abbreviated long option.
 		    (or elt
 			(error "Option `%s' is ambiguous" this-switch))
 		    (setq this-switch completion))))))
-      (setq aelt (assoc this-switch command-line-x-option-alist))
+      (setq aelt (assoc this-switch option-alist))
       (if aelt (setq handler (nth 2 aelt)))
       (if handler
 	  (if argval
@@ -203,173 +288,190 @@
 ;; white, (v) numbered colors sorted by hue, and (vi) numbered shades
 ;; of grey.
 
+(declare-function ns-list-colors "nsfns.m" (&optional frame))
+
 (defvar x-colors
-  (purecopy
-   '("gray100" "grey100" "gray99" "grey99" "gray98" "grey98" "gray97"
-     "grey97" "gray96" "grey96" "gray95" "grey95" "gray94" "grey94"
-     "gray93" "grey93" "gray92" "grey92" "gray91" "grey91" "gray90"
-     "grey90" "gray89" "grey89" "gray88" "grey88" "gray87" "grey87"
-     "gray86" "grey86" "gray85" "grey85" "gray84" "grey84" "gray83"
-     "grey83" "gray82" "grey82" "gray81" "grey81" "gray80" "grey80"
-     "gray79" "grey79" "gray78" "grey78" "gray77" "grey77" "gray76"
-     "grey76" "gray75" "grey75" "gray74" "grey74" "gray73" "grey73"
-     "gray72" "grey72" "gray71" "grey71" "gray70" "grey70" "gray69"
-     "grey69" "gray68" "grey68" "gray67" "grey67" "gray66" "grey66"
-     "gray65" "grey65" "gray64" "grey64" "gray63" "grey63" "gray62"
-     "grey62" "gray61" "grey61" "gray60" "grey60" "gray59" "grey59"
-     "gray58" "grey58" "gray57" "grey57" "gray56" "grey56" "gray55"
-     "grey55" "gray54" "grey54" "gray53" "grey53" "gray52" "grey52"
-     "gray51" "grey51" "gray50" "grey50" "gray49" "grey49" "gray48"
-     "grey48" "gray47" "grey47" "gray46" "grey46" "gray45" "grey45"
-     "gray44" "grey44" "gray43" "grey43" "gray42" "grey42" "gray41"
-     "grey41" "gray40" "grey40" "gray39" "grey39" "gray38" "grey38"
-     "gray37" "grey37" "gray36" "grey36" "gray35" "grey35" "gray34"
-     "grey34" "gray33" "grey33" "gray32" "grey32" "gray31" "grey31"
-     "gray30" "grey30" "gray29" "grey29" "gray28" "grey28" "gray27"
-     "grey27" "gray26" "grey26" "gray25" "grey25" "gray24" "grey24"
-     "gray23" "grey23" "gray22" "grey22" "gray21" "grey21" "gray20"
-     "grey20" "gray19" "grey19" "gray18" "grey18" "gray17" "grey17"
-     "gray16" "grey16" "gray15" "grey15" "gray14" "grey14" "gray13"
-     "grey13" "gray12" "grey12" "gray11" "grey11" "gray10" "grey10"
-     "gray9" "grey9" "gray8" "grey8" "gray7" "grey7" "gray6" "grey6"
-     "gray5" "grey5" "gray4" "grey4" "gray3" "grey3" "gray2" "grey2"
-     "gray1" "grey1" "gray0" "grey0"
-     "LightPink1" "LightPink2" "LightPink3" "LightPink4"
-     "pink1" "pink2" "pink3" "pink4"
-     "PaleVioletRed1" "PaleVioletRed2" "PaleVioletRed3" "PaleVioletRed4"
-     "LavenderBlush1" "LavenderBlush2" "LavenderBlush3" "LavenderBlush4"
-     "VioletRed1" "VioletRed2" "VioletRed3" "VioletRed4"
-     "HotPink1" "HotPink2" "HotPink3" "HotPink4"
-     "DeepPink1" "DeepPink2" "DeepPink3" "DeepPink4"
-     "maroon1" "maroon2" "maroon3" "maroon4"
-     "orchid1" "orchid2" "orchid3" "orchid4"
-     "plum1" "plum2" "plum3" "plum4"
-     "thistle1" "thistle2" "thistle3" "thistle4"
-     "MediumOrchid1" "MediumOrchid2" "MediumOrchid3" "MediumOrchid4"
-     "DarkOrchid1" "DarkOrchid2" "DarkOrchid3" "DarkOrchid4"
-     "purple1" "purple2" "purple3" "purple4"
-     "MediumPurple1" "MediumPurple2" "MediumPurple3" "MediumPurple4"
-     "SlateBlue1" "SlateBlue2" "SlateBlue3" "SlateBlue4"
-     "RoyalBlue1" "RoyalBlue2" "RoyalBlue3" "RoyalBlue4"
-     "LightSteelBlue1" "LightSteelBlue2" "LightSteelBlue3" "LightSteelBlue4"
-     "SlateGray1" "SlateGray2" "SlateGray3" "SlateGray4"
-     "DodgerBlue1" "DodgerBlue2" "DodgerBlue3" "DodgerBlue4"
-     "SteelBlue1" "SteelBlue2" "SteelBlue3" "SteelBlue4"
-     "SkyBlue1" "SkyBlue2" "SkyBlue3" "SkyBlue4"
-     "LightSkyBlue1" "LightSkyBlue2" "LightSkyBlue3" "LightSkyBlue4"
-     "LightBlue1" "LightBlue2" "LightBlue3" "LightBlue4"
-     "CadetBlue1" "CadetBlue2" "CadetBlue3" "CadetBlue4"
-     "azure1" "azure2" "azure3" "azure4"
-     "LightCyan1" "LightCyan2" "LightCyan3" "LightCyan4"
-     "PaleTurquoise1" "PaleTurquoise2" "PaleTurquoise3" "PaleTurquoise4"
-     "DarkSlateGray1" "DarkSlateGray2" "DarkSlateGray3" "DarkSlateGray4"
-     "aquamarine1" "aquamarine2" "aquamarine3" "aquamarine4"
-     "SeaGreen1" "SeaGreen2" "SeaGreen3" "SeaGreen4"
-     "honeydew1" "honeydew2" "honeydew3" "honeydew4"
-     "DarkSeaGreen1" "DarkSeaGreen2" "DarkSeaGreen3" "DarkSeaGreen4"
-     "PaleGreen1" "PaleGreen2" "PaleGreen3" "PaleGreen4"
-     "DarkOliveGreen1" "DarkOliveGreen2" "DarkOliveGreen3" "DarkOliveGreen4"
-     "OliveDrab1" "OliveDrab2" "OliveDrab3" "OliveDrab4"
-     "ivory1" "ivory2" "ivory3" "ivory4"
-     "LightYellow1" "LightYellow2" "LightYellow3" "LightYellow4"
-     "khaki1" "khaki2" "khaki3" "khaki4"
-     "LemonChiffon1" "LemonChiffon2" "LemonChiffon3" "LemonChiffon4"
-     "LightGoldenrod1" "LightGoldenrod2" "LightGoldenrod3" "LightGoldenrod4"
-     "cornsilk1" "cornsilk2" "cornsilk3" "cornsilk4"
-     "goldenrod1" "goldenrod2" "goldenrod3" "goldenrod4"
-     "DarkGoldenrod1" "DarkGoldenrod2" "DarkGoldenrod3" "DarkGoldenrod4"
-     "wheat1" "wheat2" "wheat3" "wheat4"
-     "NavajoWhite1" "NavajoWhite2" "NavajoWhite3" "NavajoWhite4"
-     "burlywood1" "burlywood2" "burlywood3" "burlywood4"
-     "AntiqueWhite1" "AntiqueWhite2" "AntiqueWhite3" "AntiqueWhite4"
-     "bisque1" "bisque2" "bisque3" "bisque4"
-     "tan1" "tan2" "tan3" "tan4"
-     "PeachPuff1" "PeachPuff2" "PeachPuff3" "PeachPuff4"
-     "seashell1" "seashell2" "seashell3" "seashell4"
-     "chocolate1" "chocolate2" "chocolate3" "chocolate4"
-     "sienna1" "sienna2" "sienna3" "sienna4"
-     "LightSalmon1" "LightSalmon2" "LightSalmon3" "LightSalmon4"
-     "salmon1" "salmon2" "salmon3" "salmon4"
-     "coral1" "coral2" "coral3" "coral4"
-     "tomato1" "tomato2" "tomato3" "tomato4"
-     "MistyRose1" "MistyRose2" "MistyRose3" "MistyRose4"
-     "snow1" "snow2" "snow3" "snow4"
-     "RosyBrown1" "RosyBrown2" "RosyBrown3" "RosyBrown4"
-     "IndianRed1" "IndianRed2" "IndianRed3" "IndianRed4"
-     "firebrick1" "firebrick2" "firebrick3" "firebrick4"
-     "brown1" "brown2" "brown3" "brown4"
-     "magenta1" "magenta2" "magenta3" "magenta4"
-     "blue1" "blue2" "blue3" "blue4"
-     "DeepSkyBlue1" "DeepSkyBlue2" "DeepSkyBlue3" "DeepSkyBlue4"
-     "turquoise1" "turquoise2" "turquoise3" "turquoise4"
-     "cyan1" "cyan2" "cyan3" "cyan4"
-     "SpringGreen1" "SpringGreen2" "SpringGreen3" "SpringGreen4"
-     "green1" "green2" "green3" "green4"
-     "chartreuse1" "chartreuse2" "chartreuse3" "chartreuse4"
-     "yellow1" "yellow2" "yellow3" "yellow4"
-     "gold1" "gold2" "gold3" "gold4"
-     "orange1" "orange2" "orange3" "orange4"
-     "DarkOrange1" "DarkOrange2" "DarkOrange3" "DarkOrange4"
-     "OrangeRed1" "OrangeRed2" "OrangeRed3" "OrangeRed4"
-     "red1" "red2" "red3" "red4"
-     "lavender blush" "LavenderBlush" "ghost white" "GhostWhite"
-     "lavender" "alice blue" "AliceBlue" "azure" "light cyan"
-     "LightCyan" "mint cream" "MintCream" "honeydew" "ivory"
-     "light goldenrod yellow" "LightGoldenrodYellow" "light yellow"
-     "LightYellow" "beige" "floral white" "FloralWhite" "old lace"
-     "OldLace" "blanched almond" "BlanchedAlmond" "moccasin"
-     "papaya whip" "PapayaWhip" "bisque" "antique white"
-     "AntiqueWhite" "linen" "peach puff" "PeachPuff" "seashell"
-     "misty rose" "MistyRose" "snow" "light pink" "LightPink" "pink"
-     "hot pink" "HotPink" "deep pink" "DeepPink" "maroon"
-     "pale violet red" "PaleVioletRed" "violet red" "VioletRed"
-     "medium violet red" "MediumVioletRed" "violet" "plum" "thistle"
-     "orchid" "medium orchid" "MediumOrchid" "dark orchid"
-     "DarkOrchid" "purple" "blue violet" "BlueViolet" "medium purple"
-     "MediumPurple" "light slate blue" "LightSlateBlue"
-     "medium slate blue" "MediumSlateBlue" "slate blue" "SlateBlue"
-     "dark slate blue" "DarkSlateBlue" "midnight blue" "MidnightBlue"
-     "navy" "navy blue" "NavyBlue" "dark blue" "DarkBlue"
-     "light steel blue" "LightSteelBlue" "cornflower blue"
-     "CornflowerBlue" "dodger blue" "DodgerBlue" "royal blue"
-     "RoyalBlue" "light slate gray" "light slate grey"
-     "LightSlateGray" "LightSlateGrey" "slate gray" "slate grey"
-     "SlateGray" "SlateGrey" "dark slate gray" "dark slate grey"
-     "DarkSlateGray" "DarkSlateGrey" "steel blue" "SteelBlue"
-     "cadet blue" "CadetBlue" "light sky blue" "LightSkyBlue"
-     "sky blue" "SkyBlue" "light blue" "LightBlue" "powder blue"
-     "PowderBlue" "pale turquoise" "PaleTurquoise" "turquoise"
-     "medium turquoise" "MediumTurquoise" "dark turquoise"
-     "DarkTurquoise"  "dark cyan" "DarkCyan" "aquamarine"
-     "medium aquamarine" "MediumAquamarine" "light sea green"
-     "LightSeaGreen" "medium sea green" "MediumSeaGreen" "sea green"
-     "SeaGreen" "dark sea green" "DarkSeaGreen" "pale green"
-     "PaleGreen" "lime green" "LimeGreen" "dark green" "DarkGreen"
-     "forest green" "ForestGreen" "light green" "LightGreen"
-     "green yellow" "GreenYellow" "yellow green" "YellowGreen"
-     "olive drab" "OliveDrab" "dark olive green" "DarkOliveGreen"
-     "lemon chiffon" "LemonChiffon" "khaki" "dark khaki" "DarkKhaki"
-     "cornsilk" "pale goldenrod" "PaleGoldenrod" "light goldenrod"
-     "LightGoldenrod" "goldenrod" "dark goldenrod" "DarkGoldenrod"
-     "wheat" "navajo white" "NavajoWhite" "tan" "burlywood"
-     "sandy brown" "SandyBrown" "peru" "chocolate" "saddle brown"
-     "SaddleBrown" "sienna" "rosy brown" "RosyBrown" "dark salmon"
-     "DarkSalmon" "coral" "tomato" "light salmon" "LightSalmon"
-     "salmon" "light coral" "LightCoral" "indian red" "IndianRed"
-     "firebrick" "brown" "dark red" "DarkRed" "magenta"
-     "dark magenta" "DarkMagenta" "dark violet" "DarkViolet"
-     "medium blue" "MediumBlue" "blue" "deep sky blue" "DeepSkyBlue"
-     "cyan" "medium spring green" "MediumSpringGreen" "spring green"
-     "SpringGreen" "green" "lawn green" "LawnGreen" "chartreuse"
-     "yellow" "gold" "orange" "dark orange" "DarkOrange" "orange red"
-     "OrangeRed" "red" "white" "white smoke" "WhiteSmoke" "gainsboro"
-     "light gray" "light grey" "LightGray" "LightGrey" "gray" "grey"
-     "dark gray" "dark grey" "DarkGray" "DarkGrey" "dim gray"
-     "dim grey" "DimGray" "DimGrey" "black"))
+  (if (featurep 'ns) (ns-list-colors)
+    (purecopy
+     '("gray100" "grey100" "gray99" "grey99" "gray98" "grey98" "gray97"
+       "grey97" "gray96" "grey96" "gray95" "grey95" "gray94" "grey94"
+       "gray93" "grey93" "gray92" "grey92" "gray91" "grey91" "gray90"
+       "grey90" "gray89" "grey89" "gray88" "grey88" "gray87" "grey87"
+       "gray86" "grey86" "gray85" "grey85" "gray84" "grey84" "gray83"
+       "grey83" "gray82" "grey82" "gray81" "grey81" "gray80" "grey80"
+       "gray79" "grey79" "gray78" "grey78" "gray77" "grey77" "gray76"
+       "grey76" "gray75" "grey75" "gray74" "grey74" "gray73" "grey73"
+       "gray72" "grey72" "gray71" "grey71" "gray70" "grey70" "gray69"
+       "grey69" "gray68" "grey68" "gray67" "grey67" "gray66" "grey66"
+       "gray65" "grey65" "gray64" "grey64" "gray63" "grey63" "gray62"
+       "grey62" "gray61" "grey61" "gray60" "grey60" "gray59" "grey59"
+       "gray58" "grey58" "gray57" "grey57" "gray56" "grey56" "gray55"
+       "grey55" "gray54" "grey54" "gray53" "grey53" "gray52" "grey52"
+       "gray51" "grey51" "gray50" "grey50" "gray49" "grey49" "gray48"
+       "grey48" "gray47" "grey47" "gray46" "grey46" "gray45" "grey45"
+       "gray44" "grey44" "gray43" "grey43" "gray42" "grey42" "gray41"
+       "grey41" "gray40" "grey40" "gray39" "grey39" "gray38" "grey38"
+       "gray37" "grey37" "gray36" "grey36" "gray35" "grey35" "gray34"
+       "grey34" "gray33" "grey33" "gray32" "grey32" "gray31" "grey31"
+       "gray30" "grey30" "gray29" "grey29" "gray28" "grey28" "gray27"
+       "grey27" "gray26" "grey26" "gray25" "grey25" "gray24" "grey24"
+       "gray23" "grey23" "gray22" "grey22" "gray21" "grey21" "gray20"
+       "grey20" "gray19" "grey19" "gray18" "grey18" "gray17" "grey17"
+       "gray16" "grey16" "gray15" "grey15" "gray14" "grey14" "gray13"
+       "grey13" "gray12" "grey12" "gray11" "grey11" "gray10" "grey10"
+       "gray9" "grey9" "gray8" "grey8" "gray7" "grey7" "gray6" "grey6"
+       "gray5" "grey5" "gray4" "grey4" "gray3" "grey3" "gray2" "grey2"
+       "gray1" "grey1" "gray0" "grey0"
+       "LightPink1" "LightPink2" "LightPink3" "LightPink4"
+       "pink1" "pink2" "pink3" "pink4"
+       "PaleVioletRed1" "PaleVioletRed2" "PaleVioletRed3" "PaleVioletRed4"
+       "LavenderBlush1" "LavenderBlush2" "LavenderBlush3" "LavenderBlush4"
+       "VioletRed1" "VioletRed2" "VioletRed3" "VioletRed4"
+       "HotPink1" "HotPink2" "HotPink3" "HotPink4"
+       "DeepPink1" "DeepPink2" "DeepPink3" "DeepPink4"
+       "maroon1" "maroon2" "maroon3" "maroon4"
+       "orchid1" "orchid2" "orchid3" "orchid4"
+       "plum1" "plum2" "plum3" "plum4"
+       "thistle1" "thistle2" "thistle3" "thistle4"
+       "MediumOrchid1" "MediumOrchid2" "MediumOrchid3" "MediumOrchid4"
+       "DarkOrchid1" "DarkOrchid2" "DarkOrchid3" "DarkOrchid4"
+       "purple1" "purple2" "purple3" "purple4"
+       "MediumPurple1" "MediumPurple2" "MediumPurple3" "MediumPurple4"
+       "SlateBlue1" "SlateBlue2" "SlateBlue3" "SlateBlue4"
+       "RoyalBlue1" "RoyalBlue2" "RoyalBlue3" "RoyalBlue4"
+       "LightSteelBlue1" "LightSteelBlue2" "LightSteelBlue3" "LightSteelBlue4"
+       "SlateGray1" "SlateGray2" "SlateGray3" "SlateGray4"
+       "DodgerBlue1" "DodgerBlue2" "DodgerBlue3" "DodgerBlue4"
+       "SteelBlue1" "SteelBlue2" "SteelBlue3" "SteelBlue4"
+       "SkyBlue1" "SkyBlue2" "SkyBlue3" "SkyBlue4"
+       "LightSkyBlue1" "LightSkyBlue2" "LightSkyBlue3" "LightSkyBlue4"
+       "LightBlue1" "LightBlue2" "LightBlue3" "LightBlue4"
+       "CadetBlue1" "CadetBlue2" "CadetBlue3" "CadetBlue4"
+       "azure1" "azure2" "azure3" "azure4"
+       "LightCyan1" "LightCyan2" "LightCyan3" "LightCyan4"
+       "PaleTurquoise1" "PaleTurquoise2" "PaleTurquoise3" "PaleTurquoise4"
+       "DarkSlateGray1" "DarkSlateGray2" "DarkSlateGray3" "DarkSlateGray4"
+       "aquamarine1" "aquamarine2" "aquamarine3" "aquamarine4"
+       "SeaGreen1" "SeaGreen2" "SeaGreen3" "SeaGreen4"
+       "honeydew1" "honeydew2" "honeydew3" "honeydew4"
+       "DarkSeaGreen1" "DarkSeaGreen2" "DarkSeaGreen3" "DarkSeaGreen4"
+       "PaleGreen1" "PaleGreen2" "PaleGreen3" "PaleGreen4"
+       "DarkOliveGreen1" "DarkOliveGreen2" "DarkOliveGreen3" "DarkOliveGreen4"
+       "OliveDrab1" "OliveDrab2" "OliveDrab3" "OliveDrab4"
+       "ivory1" "ivory2" "ivory3" "ivory4"
+       "LightYellow1" "LightYellow2" "LightYellow3" "LightYellow4"
+       "khaki1" "khaki2" "khaki3" "khaki4"
+       "LemonChiffon1" "LemonChiffon2" "LemonChiffon3" "LemonChiffon4"
+       "LightGoldenrod1" "LightGoldenrod2" "LightGoldenrod3" "LightGoldenrod4"
+       "cornsilk1" "cornsilk2" "cornsilk3" "cornsilk4"
+       "goldenrod1" "goldenrod2" "goldenrod3" "goldenrod4"
+       "DarkGoldenrod1" "DarkGoldenrod2" "DarkGoldenrod3" "DarkGoldenrod4"
+       "wheat1" "wheat2" "wheat3" "wheat4"
+       "NavajoWhite1" "NavajoWhite2" "NavajoWhite3" "NavajoWhite4"
+       "burlywood1" "burlywood2" "burlywood3" "burlywood4"
+       "AntiqueWhite1" "AntiqueWhite2" "AntiqueWhite3" "AntiqueWhite4"
+       "bisque1" "bisque2" "bisque3" "bisque4"
+       "tan1" "tan2" "tan3" "tan4"
+       "PeachPuff1" "PeachPuff2" "PeachPuff3" "PeachPuff4"
+       "seashell1" "seashell2" "seashell3" "seashell4"
+       "chocolate1" "chocolate2" "chocolate3" "chocolate4"
+       "sienna1" "sienna2" "sienna3" "sienna4"
+       "LightSalmon1" "LightSalmon2" "LightSalmon3" "LightSalmon4"
+       "salmon1" "salmon2" "salmon3" "salmon4"
+       "coral1" "coral2" "coral3" "coral4"
+       "tomato1" "tomato2" "tomato3" "tomato4"
+       "MistyRose1" "MistyRose2" "MistyRose3" "MistyRose4"
+       "snow1" "snow2" "snow3" "snow4"
+       "RosyBrown1" "RosyBrown2" "RosyBrown3" "RosyBrown4"
+       "IndianRed1" "IndianRed2" "IndianRed3" "IndianRed4"
+       "firebrick1" "firebrick2" "firebrick3" "firebrick4"
+       "brown1" "brown2" "brown3" "brown4"
+       "magenta1" "magenta2" "magenta3" "magenta4"
+       "blue1" "blue2" "blue3" "blue4"
+       "DeepSkyBlue1" "DeepSkyBlue2" "DeepSkyBlue3" "DeepSkyBlue4"
+       "turquoise1" "turquoise2" "turquoise3" "turquoise4"
+       "cyan1" "cyan2" "cyan3" "cyan4"
+       "SpringGreen1" "SpringGreen2" "SpringGreen3" "SpringGreen4"
+       "green1" "green2" "green3" "green4"
+       "chartreuse1" "chartreuse2" "chartreuse3" "chartreuse4"
+       "yellow1" "yellow2" "yellow3" "yellow4"
+       "gold1" "gold2" "gold3" "gold4"
+       "orange1" "orange2" "orange3" "orange4"
+       "DarkOrange1" "DarkOrange2" "DarkOrange3" "DarkOrange4"
+       "OrangeRed1" "OrangeRed2" "OrangeRed3" "OrangeRed4"
+       "red1" "red2" "red3" "red4"
+       "lavender blush" "LavenderBlush" "ghost white" "GhostWhite"
+       "lavender" "alice blue" "AliceBlue" "azure" "light cyan"
+       "LightCyan" "mint cream" "MintCream" "honeydew" "ivory"
+       "light goldenrod yellow" "LightGoldenrodYellow" "light yellow"
+       "LightYellow" "beige" "floral white" "FloralWhite" "old lace"
+       "OldLace" "blanched almond" "BlanchedAlmond" "moccasin"
+       "papaya whip" "PapayaWhip" "bisque" "antique white"
+       "AntiqueWhite" "linen" "peach puff" "PeachPuff" "seashell"
+       "misty rose" "MistyRose" "snow" "light pink" "LightPink" "pink"
+       "hot pink" "HotPink" "deep pink" "DeepPink" "maroon"
+       "pale violet red" "PaleVioletRed" "violet red" "VioletRed"
+       "medium violet red" "MediumVioletRed" "violet" "plum" "thistle"
+       "orchid" "medium orchid" "MediumOrchid" "dark orchid"
+       "DarkOrchid" "purple" "blue violet" "BlueViolet" "medium purple"
+       "MediumPurple" "light slate blue" "LightSlateBlue"
+       "medium slate blue" "MediumSlateBlue" "slate blue" "SlateBlue"
+       "dark slate blue" "DarkSlateBlue" "midnight blue" "MidnightBlue"
+       "navy" "navy blue" "NavyBlue" "dark blue" "DarkBlue"
+       "light steel blue" "LightSteelBlue" "cornflower blue"
+       "CornflowerBlue" "dodger blue" "DodgerBlue" "royal blue"
+       "RoyalBlue" "light slate gray" "light slate grey"
+       "LightSlateGray" "LightSlateGrey" "slate gray" "slate grey"
+       "SlateGray" "SlateGrey" "dark slate gray" "dark slate grey"
+       "DarkSlateGray" "DarkSlateGrey" "steel blue" "SteelBlue"
+       "cadet blue" "CadetBlue" "light sky blue" "LightSkyBlue"
+       "sky blue" "SkyBlue" "light blue" "LightBlue" "powder blue"
+       "PowderBlue" "pale turquoise" "PaleTurquoise" "turquoise"
+       "medium turquoise" "MediumTurquoise" "dark turquoise"
+       "DarkTurquoise"  "dark cyan" "DarkCyan" "aquamarine"
+       "medium aquamarine" "MediumAquamarine" "light sea green"
+       "LightSeaGreen" "medium sea green" "MediumSeaGreen" "sea green"
+       "SeaGreen" "dark sea green" "DarkSeaGreen" "pale green"
+       "PaleGreen" "lime green" "LimeGreen" "dark green" "DarkGreen"
+       "forest green" "ForestGreen" "light green" "LightGreen"
+       "green yellow" "GreenYellow" "yellow green" "YellowGreen"
+       "olive drab" "OliveDrab" "dark olive green" "DarkOliveGreen"
+       "lemon chiffon" "LemonChiffon" "khaki" "dark khaki" "DarkKhaki"
+       "cornsilk" "pale goldenrod" "PaleGoldenrod" "light goldenrod"
+       "LightGoldenrod" "goldenrod" "dark goldenrod" "DarkGoldenrod"
+       "wheat" "navajo white" "NavajoWhite" "tan" "burlywood"
+       "sandy brown" "SandyBrown" "peru" "chocolate" "saddle brown"
+       "SaddleBrown" "sienna" "rosy brown" "RosyBrown" "dark salmon"
+       "DarkSalmon" "coral" "tomato" "light salmon" "LightSalmon"
+       "salmon" "light coral" "LightCoral" "indian red" "IndianRed"
+       "firebrick" "brown" "dark red" "DarkRed" "magenta"
+       "dark magenta" "DarkMagenta" "dark violet" "DarkViolet"
+       "medium blue" "MediumBlue" "blue" "deep sky blue" "DeepSkyBlue"
+       "cyan" "medium spring green" "MediumSpringGreen" "spring green"
+       "SpringGreen" "green" "lawn green" "LawnGreen" "chartreuse"
+       "yellow" "gold" "orange" "dark orange" "DarkOrange" "orange red"
+       "OrangeRed" "red" "white" "white smoke" "WhiteSmoke" "gainsboro"
+       "light gray" "light grey" "LightGray" "LightGrey" "gray" "grey"
+       "dark gray" "dark grey" "DarkGray" "DarkGrey" "dim gray"
+       "dim grey" "DimGray" "DimGrey" "black")))
   "List of basic colors available on color displays.
 For X, the list comes from the `rgb.txt' file,v 10.41 94/02/20.
 For Nextstep, this is a list of non-PANTONE colors returned by
 the operating system.")
 
-;; arch-tag: 2a128601-99cc-401e-9dff-0ee6a36102ef
+(defvar w32-color-map)
+
+(defun xw-defined-colors (&optional frame)
+  "Internal function called by `defined-colors', which see."
+  (if (featurep 'ns)
+      x-colors
+    (or frame (setq frame (selected-frame)))
+    (let (defined-colors)
+      (dolist (this-color (if (eq system-type 'windows-nt)
+			      (or (mapcar 'car w32-color-map) x-colors)
+			    x-colors))
+	(and (color-supported-p this-color frame t)
+	     (setq defined-colors (cons this-color defined-colors))))
+      defined-colors)))
+
 ;;; common-win.el ends here
--- a/lisp/term/ns-win.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/term/ns-win.el	Thu Oct 28 19:57:59 2010 +0900
@@ -41,131 +41,42 @@
 
 ;;; Code:
 
-
-(if (not (featurep 'ns))
+(or (featurep 'ns)
     (error "%s: Loading ns-win.el but not compiled for GNUstep/MacOS"
-	   (invocation-name)))
+           (invocation-name)))
 
-(eval-when-compile (require 'cl))
+(eval-when-compile (require 'cl))       ; lexical-let
 
-;; Documentation-purposes only: actually loaded in loadup.el
+;; Documentation-purposes only: actually loaded in loadup.el.
 (require 'frame)
 (require 'mouse)
 (require 'faces)
-(require 'easymenu)
 (require 'menu-bar)
 (require 'fontset)
 
-;; Not needed?
-;;(require 'ispell)
-
 (defgroup ns nil
   "GNUstep/Mac OS X specific features."
   :group 'environment)
 
-;; nsterm.m
-(defvar ns-version-string)
-(defvar ns-alternate-modifier)
-(defvar ns-right-alternate-modifier)
-
 ;;;; Command line argument handling.
 
-(defvar ns-invocation-args nil)
-(defvar ns-command-line-resources nil)
-
-;; Handler for switches of the form "-switch value" or "-switch".
-(defun ns-handle-switch (switch &optional numeric)
-  (let ((aelt (assoc switch command-line-ns-option-alist)))
-    (if aelt
-	(setq default-frame-alist
-	      (cons (cons (nth 3 aelt)
-			  (if numeric
-			      (string-to-number (pop ns-invocation-args))
-			    (or (nth 4 aelt) (pop ns-invocation-args))))
-		    default-frame-alist)))))
-
-;; Handler for switches of the form "-switch n"
-(defun ns-handle-numeric-switch (switch)
-  (ns-handle-switch switch t))
-
-;; Make -iconic apply only to the initial frame!
-(defun ns-handle-iconic (switch)
-  (setq initial-frame-alist
-        (cons '(visibility . icon) initial-frame-alist)))
-
-;; Handle the -name option, set the name of the initial frame.
-(defun ns-handle-name-switch (switch)
-  (or (consp ns-invocation-args)
-      (error "%s: missing argument to `%s' option" (invocation-name) switch))
-  (setq initial-frame-alist (cons (cons 'name (pop ns-invocation-args))
-                                  initial-frame-alist)))
-
-;; Set (but not used?) in frame.el.
-(defvar x-display-name nil
-  "The name of the window display on which Emacs was started.
-On X, the display name of individual X frames is recorded in the
-`display' frame parameter.")
+(defvar x-invocation-args)
+(defvar ns-command-line-resources nil)  ; FIXME unused?
 
 ;; nsterm.m.
 (defvar ns-input-file)
 
-(defun ns-handle-nxopen (switch)
-  (setq unread-command-events (append unread-command-events '(ns-open-file))
-        ns-input-file (append ns-input-file (list (pop ns-invocation-args)))))
+(defun ns-handle-nxopen (switch &optional temp)
+  (setq unread-command-events (append unread-command-events
+                                      (if temp '(ns-open-temp-file)
+                                        '(ns-open-file)))
+        ns-input-file (append ns-input-file (list (pop x-invocation-args)))))
 
 (defun ns-handle-nxopentemp (switch)
-  (setq unread-command-events (append unread-command-events
-				      '(ns-open-temp-file))
-        ns-input-file (append ns-input-file (list (pop ns-invocation-args)))))
+  (ns-handle-nxopen switch t))
 
 (defun ns-ignore-1-arg (switch)
-  (setq ns-invocation-args (cdr ns-invocation-args)))
-(defun ns-ignore-2-arg (switch)
-  (setq ns-invocation-args (cddr ns-invocation-args)))
-
-(defun ns-handle-args (args)
-  "Process Nextstep-related command line options.
-This is run before the user's startup file is loaded.
-The options in ARGS are copied to `ns-invocation-args'.
-The Nextstep-related settings are then applied using the handlers
-defined in `command-line-ns-option-alist'.
-The return value is ARGS minus the number of arguments processed."
-  ;; We use ARGS to accumulate the args that we don't handle here, to return.
-  (setq ns-invocation-args args
-        args nil)
-  (while ns-invocation-args
-    (let* ((this-switch (pop ns-invocation-args))
-	   (orig-this-switch this-switch)
-	   completion argval aelt handler)
-      ;; Check for long options with attached arguments
-      ;; and separate out the attached option argument into argval.
-      (if (string-match "^--[^=]*=" this-switch)
-	  (setq argval (substring this-switch (match-end 0))
-		this-switch (substring this-switch 0 (1- (match-end 0)))))
-      ;; Complete names of long options.
-      (if (string-match "^--" this-switch)
-	  (progn
-	    (setq completion (try-completion this-switch
-                                             command-line-ns-option-alist))
-	    (if (eq completion t)
-		;; Exact match for long option.
-		nil
-	      (if (stringp completion)
-		  (let ((elt (assoc completion command-line-ns-option-alist)))
-		    ;; Check for abbreviated long option.
-		    (or elt
-			(error "Option `%s' is ambiguous" this-switch))
-		    (setq this-switch completion))))))
-      (setq aelt (assoc this-switch command-line-ns-option-alist))
-      (if aelt (setq handler (nth 2 aelt)))
-      (if handler
-	  (if argval
-	      (let ((ns-invocation-args
-		     (cons argval ns-invocation-args)))
-		(funcall handler this-switch))
-	    (funcall handler this-switch))
-	(setq args (cons orig-this-switch args)))))
-  (nreverse args))
+  (setq x-invocation-args (cdr x-invocation-args)))
 
 (defun ns-parse-geometry (geom)
   "Parse a Nextstep-style geometry string GEOM.
@@ -187,20 +98,7 @@
 
 ;;;; Keyboard mapping.
 
-(defvar ns-alternatives-map
-  (let ((map (make-sparse-keymap)))
-    ;; Map certain keypad keys into ASCII characters
-    ;; that people usually expect.
-    (define-key map [S-tab] [backtab])
-    (define-key map [M-backspace] [?\M-\d])
-    (define-key map [M-delete] [?\M-\d])
-    (define-key map [M-tab] [?\M-\t])
-    (define-key map [M-linefeed] [?\M-\n])
-    (define-key map [M-clear] [?\M-\C-l])
-    (define-key map [M-return] [?\M-\C-m])
-    (define-key map [M-escape] [?\M-\e])
-    map)
-  "Keymap of alternative meanings for some keys under Nextstep.")
+(define-obsolete-variable-alias 'ns-alternatives-map 'x-alternatives-map "24.1")
 
 ;; Here are some Nextstep-like bindings for command key sequences.
 (define-key global-map [?\s-,] 'customize)
@@ -256,13 +154,13 @@
 (define-key global-map [kp-prior] 'scroll-down)
 (define-key global-map [kp-next] 'scroll-up)
 
-;;; Allow shift-clicks to work similarly to under Nextstep
+;; Allow shift-clicks to work similarly to under Nextstep.
 (define-key global-map [S-mouse-1] 'mouse-save-then-kill)
 (global-unset-key [S-down-mouse-1])
 
-
 ;; Special Nextstep-generated events are converted to function keys.  Here
-;; are the bindings for them.
+;; are the bindings for them.  Note, these keys are actually declared in
+;; x-setup-function-keys in common-win.
 (define-key global-map [ns-power-off] 'save-buffers-kill-emacs)
 (define-key global-map [ns-open-file] 'ns-find-file)
 (define-key global-map [ns-open-temp-file] [ns-open-file])
@@ -273,9 +171,7 @@
 (define-key global-map [ns-change-font] 'ns-respond-to-change-font)
 (define-key global-map [ns-open-file-line] 'ns-open-file-select-line)
 (define-key global-map [ns-spi-service-call] 'ns-spi-service-call)
-(define-key global-map [ns-new-frame] 'make-frame)
 (define-key global-map [ns-toggle-toolbar] 'ns-toggle-toolbar)
-(define-key global-map [ns-show-prefs] 'customize)
 
 
 ;; Set up a number of aliases and other layers to pretend we're using
@@ -290,189 +186,6 @@
 (declare-function ns-do-applescript "nsfns.m" (script))
 (defalias 'do-applescript 'ns-do-applescript)
 
-(defun x-setup-function-keys (frame)
-  "Set up `function-key-map' on the graphical frame FRAME."
-  (unless (terminal-parameter frame 'x-setup-function-keys)
-    (with-selected-frame frame
-      (setq interprogram-cut-function 'x-select-text
-	    interprogram-paste-function 'x-selection-value)
-      (let ((map (copy-keymap ns-alternatives-map)))
-	(set-keymap-parent map (keymap-parent local-function-key-map))
-	(set-keymap-parent local-function-key-map map))
-      (setq system-key-alist
-            (list
-             (cons (logior (lsh 0 16)   1) 'ns-power-off)
-             (cons (logior (lsh 0 16)   2) 'ns-open-file)
-             (cons (logior (lsh 0 16)   3) 'ns-open-temp-file)
-             (cons (logior (lsh 0 16)   4) 'ns-drag-file)
-             (cons (logior (lsh 0 16)   5) 'ns-drag-color)
-             (cons (logior (lsh 0 16)   6) 'ns-drag-text)
-             (cons (logior (lsh 0 16)   7) 'ns-change-font)
-             (cons (logior (lsh 0 16)   8) 'ns-open-file-line)
-;             (cons (logior (lsh 0 16)   9) 'ns-insert-working-text)
-;             (cons (logior (lsh 0 16)  10) 'ns-delete-working-text)
-             (cons (logior (lsh 0 16)  11) 'ns-spi-service-call)
-	     (cons (logior (lsh 0 16)  12) 'ns-new-frame)
-	     (cons (logior (lsh 0 16)  13) 'ns-toggle-toolbar)
-	     (cons (logior (lsh 0 16)  14) 'ns-show-prefs)
-	     (cons (logior (lsh 1 16)  32) 'f1)
-             (cons (logior (lsh 1 16)  33) 'f2)
-             (cons (logior (lsh 1 16)  34) 'f3)
-             (cons (logior (lsh 1 16)  35) 'f4)
-             (cons (logior (lsh 1 16)  36) 'f5)
-             (cons (logior (lsh 1 16)  37) 'f6)
-             (cons (logior (lsh 1 16)  38) 'f7)
-             (cons (logior (lsh 1 16)  39) 'f8)
-             (cons (logior (lsh 1 16)  40) 'f9)
-             (cons (logior (lsh 1 16)  41) 'f10)
-             (cons (logior (lsh 1 16)  42) 'f11)
-             (cons (logior (lsh 1 16)  43) 'f12)
-             (cons (logior (lsh 1 16)  44) 'kp-insert)
-             (cons (logior (lsh 1 16)  45) 'kp-delete)
-             (cons (logior (lsh 1 16)  46) 'kp-home)
-             (cons (logior (lsh 1 16)  47) 'kp-end)
-             (cons (logior (lsh 1 16)  48) 'kp-prior)
-             (cons (logior (lsh 1 16)  49) 'kp-next)
-             (cons (logior (lsh 1 16)  50) 'print-screen)
-             (cons (logior (lsh 1 16)  51) 'scroll-lock)
-             (cons (logior (lsh 1 16)  52) 'pause)
-             (cons (logior (lsh 1 16)  53) 'system)
-             (cons (logior (lsh 1 16)  54) 'break)
-             (cons (logior (lsh 1 16)  56) 'please-tell-carl-what-this-key-is-called-56)
-             (cons (logior (lsh 1 16)  61) 'please-tell-carl-what-this-key-is-called-61)
-             (cons (logior (lsh 1 16)  62) 'please-tell-carl-what-this-key-is-called-62)
-             (cons (logior (lsh 1 16)  63) 'please-tell-carl-what-this-key-is-called-63)
-             (cons (logior (lsh 1 16)  64) 'please-tell-carl-what-this-key-is-called-64)
-             (cons (logior (lsh 1 16)  69) 'please-tell-carl-what-this-key-is-called-69)
-             (cons (logior (lsh 1 16)  70) 'please-tell-carl-what-this-key-is-called-70)
-             (cons (logior (lsh 1 16)  71) 'please-tell-carl-what-this-key-is-called-71)
-             (cons (logior (lsh 1 16)  72) 'please-tell-carl-what-this-key-is-called-72)
-             (cons (logior (lsh 1 16)  73) 'please-tell-carl-what-this-key-is-called-73)
-             (cons (logior (lsh 2 16)   3) 'kp-enter)
-             (cons (logior (lsh 2 16)   9) 'kp-tab)
-             (cons (logior (lsh 2 16)  28) 'kp-quit)
-             (cons (logior (lsh 2 16)  35) 'kp-hash)
-             (cons (logior (lsh 2 16)  42) 'kp-multiply)
-             (cons (logior (lsh 2 16)  43) 'kp-add)
-             (cons (logior (lsh 2 16)  44) 'kp-separator)
-             (cons (logior (lsh 2 16)  45) 'kp-subtract)
-             (cons (logior (lsh 2 16)  46) 'kp-decimal)
-             (cons (logior (lsh 2 16)  47) 'kp-divide)
-             (cons (logior (lsh 2 16)  48) 'kp-0)
-             (cons (logior (lsh 2 16)  49) 'kp-1)
-             (cons (logior (lsh 2 16)  50) 'kp-2)
-             (cons (logior (lsh 2 16)  51) 'kp-3)
-             (cons (logior (lsh 2 16)  52) 'kp-4)
-             (cons (logior (lsh 2 16)  53) 'kp-5)
-             (cons (logior (lsh 2 16)  54) 'kp-6)
-             (cons (logior (lsh 2 16)  55) 'kp-7)
-             (cons (logior (lsh 2 16)  56) 'kp-8)
-             (cons (logior (lsh 2 16)  57) 'kp-9)
-             (cons (logior (lsh 2 16)  60) 'kp-less)
-             (cons (logior (lsh 2 16)  61) 'kp-equal)
-             (cons (logior (lsh 2 16)  62) 'kp-more)
-             (cons (logior (lsh 2 16)  64) 'kp-at)
-             (cons (logior (lsh 2 16)  92) 'kp-backslash)
-             (cons (logior (lsh 2 16)  96) 'kp-backtick)
-             (cons (logior (lsh 2 16) 124) 'kp-bar)
-             (cons (logior (lsh 2 16) 126) 'kp-tilde)
-             (cons (logior (lsh 2 16) 157) 'kp-mu)
-             (cons (logior (lsh 2 16) 165) 'kp-yen)
-             (cons (logior (lsh 2 16) 167) 'kp-paragraph)
-             (cons (logior (lsh 2 16) 172) 'left)
-             (cons (logior (lsh 2 16) 173) 'up)
-             (cons (logior (lsh 2 16) 174) 'right)
-             (cons (logior (lsh 2 16) 175) 'down)
-             (cons (logior (lsh 2 16) 176) 'kp-ring)
-             (cons (logior (lsh 2 16) 201) 'kp-square)
-             (cons (logior (lsh 2 16) 204) 'kp-cube)
-             (cons (logior (lsh 3 16)   8) 'backspace)
-             (cons (logior (lsh 3 16)   9) 'tab)
-             (cons (logior (lsh 3 16)  10) 'linefeed)
-             (cons (logior (lsh 3 16)  11) 'clear)
-             (cons (logior (lsh 3 16)  13) 'return)
-             (cons (logior (lsh 3 16)  18) 'pause)
-             (cons (logior (lsh 3 16)  25) 'S-tab)
-             (cons (logior (lsh 3 16)  27) 'escape)
-             (cons (logior (lsh 3 16) 127) 'delete)
-             )))
-    (set-terminal-parameter frame 'x-setup-function-keys t)))
-
-
-;; Add a couple of menus and rearrange some others; easiest just to redo toplvl
-;; Note keymap defns must be given last-to-first
-(define-key global-map [menu-bar] (make-sparse-keymap "menu-bar"))
-
-(setq menu-bar-final-items
-      (cond ((eq system-type 'darwin)
-             '(buffer windows services help-menu))
-            ;; Otherwise, GNUstep.
-            (t
-             '(buffer windows services hide-app quit))))
-
-;; Add standard top-level items to GNUstep menu.
-(unless (eq system-type 'darwin)
-  (define-key global-map [menu-bar quit] '("Quit" . save-buffers-kill-emacs))
-  (define-key global-map [menu-bar hide-app] '("Hide" . ns-do-hide-emacs)))
-
-(define-key global-map [menu-bar services]
-  (cons "Services" (make-sparse-keymap "Services")))
-(define-key global-map [menu-bar buffer]
-  (cons "Buffers" global-buffers-menu-map))
-;;  (cons "Buffers" (make-sparse-keymap "Buffers")))
-(define-key global-map [menu-bar tools] (cons "Tools" menu-bar-tools-menu))
-(define-key global-map [menu-bar options] (cons "Options" menu-bar-options-menu))
-(define-key global-map [menu-bar edit] (cons "Edit" menu-bar-edit-menu))
-(define-key global-map [menu-bar file] (cons "File" menu-bar-file-menu))
-
-;; If running under GNUstep, rename "Help" to "Info"
-(cond ((eq system-type 'darwin)
-       (define-key global-map [menu-bar help-menu]
-	 (cons "Help" menu-bar-help-menu)))
-      (t
-       (let ((contents (reverse (cdr menu-bar-help-menu))))
-	 (setq menu-bar-help-menu
-	       (append (list 'keymap) (cdr contents) (list "Info"))))
-       (define-key global-map [menu-bar help-menu]
-	 (cons "Info" menu-bar-help-menu))))
-
-(if (not (eq system-type 'darwin))
-    ;; in OS X it's in the app menu already
-    (define-key menu-bar-help-menu [info-panel]
-      '("About Emacs..." . ns-do-emacs-info-panel)))
-
-;;;; Edit menu: Modify slightly
-
-;; Substitute a Copy function that works better under X (for GNUstep).
-(easy-menu-remove-item global-map '("menu-bar" "edit") 'copy)
-(define-key-after menu-bar-edit-menu [copy]
-  '(menu-item "Copy" ns-copy-including-secondary
-    :enable mark-active
-    :help "Copy text in region between mark and current position")
-  'cut)
-
-;; Change to same precondition as select-and-paste, as we don't have
-;; `x-selection-exists-p'.
-(easy-menu-remove-item global-map '("menu-bar" "edit") 'paste)
-(define-key-after menu-bar-edit-menu [paste]
-  '(menu-item "Paste" yank
-    :enable (and (cdr yank-menu) (not buffer-read-only))
-    :help "Paste (yank) text most recently cut/copied")
-  'copy)
-
-;; Change text to be more consistent with surrounding menu items `paste', etc.
-(easy-menu-remove-item global-map '("menu-bar" "edit") 'paste-from-menu)
-(define-key-after menu-bar-edit-menu [select-paste]
-  '(menu-item "Select and Paste" yank-menu
-    :enable (and (cdr yank-menu) (not buffer-read-only))
-    :help "Choose a string from the kill ring and paste it")
-  'paste)
-
-;; Separate undo from cut/paste section, add spell for platform consistency.
-(define-key-after menu-bar-edit-menu [separator-undo] '("--") 'undo)
-(define-key-after menu-bar-edit-menu [spell] '("Spell" . ispell-menu-map) 'fill)
-
-
 ;;;; Services
 (declare-function ns-perform-service "nsfns.m" (service send))
 
@@ -536,10 +249,6 @@
 	(t (error (concat "Service " ns-input-spi-name " not recognized")))))
 
 
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-
-
 ;; Composed key sequence handling for Nextstep system input methods.
 ;; (On Nextstep systems, input methods are provided for CJK
 ;; characters, etc. which require multiple keystrokes, and during
@@ -636,29 +345,24 @@
 ;;;; OS X file system Unicode UTF-8 NFD (decomposed form) support
 ;; Lisp code based on utf-8m.el, by Seiji Zenitani, Eiji Honjoh, and
 ;; Carsten Bormann.
-(if (eq system-type 'darwin)
-    (progn
+(when (eq system-type 'darwin)
+  (defun ns-utf8-nfd-post-read-conversion (length)
+    "Calls `ns-convert-utf8-nfd-to-nfc' to compose char sequences."
+    (save-excursion
+      (save-restriction
+        (narrow-to-region (point) (+ (point) length))
+        (let ((str (buffer-string)))
+          (delete-region (point-min) (point-max))
+          (insert (ns-convert-utf8-nfd-to-nfc str))
+          (- (point-max) (point-min))))))
 
-      (defun ns-utf8-nfd-post-read-conversion (length)
-	"Calls `ns-convert-utf8-nfd-to-nfc' to compose char sequences."
-	(save-excursion
-	  (save-restriction
-	    (narrow-to-region (point) (+ (point) length))
-	    (let ((str (buffer-string)))
-	      (delete-region (point-min) (point-max))
-	      (insert (ns-convert-utf8-nfd-to-nfc str))
-	      (- (point-max) (point-min))
-	      ))))
-
-      (define-coding-system 'utf-8-nfd
-	"UTF-8 NFD (decomposed) encoding."
-	:coding-type 'utf-8
-	:mnemonic ?U
-	:charset-list '(unicode)
-	:post-read-conversion 'ns-utf8-nfd-post-read-conversion)
-      (set-file-name-coding-system 'utf-8-nfd)))
-
-
+  (define-coding-system 'utf-8-nfd
+    "UTF-8 NFD (decomposed) encoding."
+    :coding-type 'utf-8
+    :mnemonic ?U
+    :charset-list '(unicode)
+    :post-read-conversion 'ns-utf8-nfd-post-read-conversion)
+  (set-file-name-coding-system 'utf-8-nfd))
 
 ;;;; Inter-app communications support.
 
@@ -674,12 +378,10 @@
   "Insert contents of file `ns-input-file' like insert-file but with less
 prompting.  If file is a directory perform a `find-file' on it."
   (interactive)
-  (let ((f))
-    (setq f (car ns-input-file))
-    (setq ns-input-file (cdr ns-input-file))
+  (let ((f (pop ns-input-file)))
     (if (file-directory-p f)
         (find-file f)
-      (push-mark (+ (point) (car (cdr (insert-file-contents f))))))))
+      (push-mark (+ (point) (cadr (insert-file-contents f)))))))
 
 (defvar ns-select-overlay nil
   "Overlay used to highlight areas in files requested by Nextstep apps.")
@@ -732,8 +434,6 @@
 
 (add-hook 'first-change-hook 'ns-unselect-line)
 
-
-
 ;;;; Preferences handling.
 (declare-function ns-get-resource "nsfns.m" (owner name))
 
@@ -784,12 +484,10 @@
 (defun ns-find-file ()
   "Do a `find-file' with the `ns-input-file' as argument."
   (interactive)
-  (let ((f) (file) (bufwin1) (bufwin2))
-    (setq f (file-truename (car ns-input-file)))
-    (setq ns-input-file (cdr ns-input-file))
-    (setq file (find-file-noselect f))
-    (setq bufwin1 (get-buffer-window file 'visible))
-    (setq bufwin2 (get-buffer-window "*scratch*" 'visibile))
+  (let* ((f (file-truename (pop ns-input-file)))
+         (file (find-file-noselect f))
+         (bufwin1 (get-buffer-window file 'visible))
+         (bufwin2 (get-buffer-window "*scratch*" 'visibile)))
     (cond
      (bufwin1
       (select-frame (window-frame bufwin1))
@@ -808,13 +506,15 @@
       (ns-hide-emacs 'activate)
       (find-file f)))))
 
-
-
 ;;;; Frame-related functions.
 
 ;; Don't show the frame name; that's redundant with Nextstep.
 (setq-default mode-line-frame-identification '("  "))
 
+;; nsterm.m
+(defvar ns-alternate-modifier)
+(defvar ns-right-alternate-modifier)
+
 ;; You say tomAYto, I say tomAHto..
 (defvaralias 'ns-option-modifier 'ns-alternate-modifier)
 (defvaralias 'ns-right-option-modifier 'ns-right-alternate-modifier)
@@ -881,10 +581,8 @@
   (if (not tool-bar-mode) (tool-bar-mode t)))
 
 
-
 ;;;; Dialog-related functions.
 
-
 ;; Ask user for confirm before printing.  Due to Kevin Rodgers.
 (defun ns-print-buffer ()
   "Interactive front-end to `print-buffer': asks for user confirmation first."
@@ -902,7 +600,6 @@
 	  (error "Cancelled")))
     (print-buffer)))
 
-
 ;;;; Font support.
 
 ;; Needed for font listing functions under both backend and normal
@@ -947,17 +644,16 @@
 See the documentation of `create-fontset-from-fontset-spec' for the format.")
 
 ;; Conditional on new-fontset so bootstrapping works on non-GUI compiles.
-(if (fboundp 'new-fontset)
-    (progn
-      ;; Setup the default fontset.
-      (create-default-fontset)
-      ;; Create the standard fontset.
-      (condition-case err
-	  (create-fontset-from-fontset-spec ns-standard-fontset-spec t)
-	(error (display-warning
-		'initialization
-		(format "Creation of the standard fontset failed: %s" err)
-		:error)))))
+(when (fboundp 'new-fontset)
+  ;; Setup the default fontset.
+  (create-default-fontset)
+  ;; Create the standard fontset.
+  (condition-case err
+      (create-fontset-from-fontset-spec ns-standard-fontset-spec t)
+    (error (display-warning
+            'initialization
+            (format "Creation of the standard fontset failed: %s" err)
+            :error))))
 
 (defvar ns-reg-to-script)               ; nsfont.m
 
@@ -1021,33 +717,14 @@
 ;; from x-selection-value.
 (defvar ns-last-selected-text nil)
 
-(defun x-select-text (text)
-  "Select TEXT, a string, according to the window system.
-
-On X, if `x-select-enable-clipboard' is non-nil, copy TEXT to the
-clipboard.  If `x-select-enable-primary' is non-nil, put TEXT in
-the primary selection.
-
-On Windows, make TEXT the current selection.  If
-`x-select-enable-clipboard' is non-nil, copy the text to the
-clipboard as well.
-
-On Nextstep, put TEXT in the pasteboard."
-  ;; Don't send the pasteboard too much text.
-  ;; It becomes slow, and if really big it causes errors.
-  (ns-set-pasteboard text)
-  (setq ns-last-selected-text text))
-
 ;; Return the value of the current Nextstep selection.  For
 ;; compatibility with older Nextstep applications, this checks cut
 ;; buffer 0 before retrieving the value of the primary selection.
 (defun x-selection-value ()
   (let (text)
-
     ;; Consult the selection.  Treat empty strings as if they were unset.
     (or text (setq text (ns-get-pasteboard)))
     (if (string= text "") (setq text nil))
-
     (cond
      ((not text) nil)
      ((eq text ns-last-selected-text) nil)
@@ -1068,7 +745,6 @@
   (insert (ns-get-cut-buffer-internal 'SECONDARY)))
 
 
-
 ;;;; Scrollbar handling.
 
 (global-set-key [vertical-scroll-bar down-mouse-1] 'ns-handle-scroll-bar-event)
@@ -1129,27 +805,6 @@
 
 ;;;; Color support.
 
-(declare-function ns-list-colors "nsfns.m" (&optional frame))
-
-(defvar x-colors (ns-list-colors)
-  "List of basic colors available on color displays.
-For X, the list comes from the `rgb.txt' file,v 10.41 94/02/20.
-For Nextstep, this is a list of non-PANTONE colors returned by
-the operating system.")
-
-(defun xw-defined-colors (&optional frame)
-  "Internal function called by `defined-colors'."
-  (or frame (setq frame (selected-frame)))
-  (let ((all-colors x-colors)
-	(this-color nil)
-	(defined-colors nil))
-    (while all-colors
-      (setq this-color (car all-colors)
-	    all-colors (cdr all-colors))
-      ;; (and (face-color-supported-p frame this-color t)
-      (setq defined-colors (cons this-color defined-colors))) ;;)
-    defined-colors))
-
 ;; Functions for color panel + drag
 (defun ns-face-at-pos (pos)
   (let* ((frame (car pos))
@@ -1237,7 +892,7 @@
   "Initialize Emacs for Nextstep (Cocoa / GNUstep) windowing."
 
   ;; PENDING: not needed?
-  (setq command-line-args (ns-handle-args command-line-args))
+  (setq command-line-args (x-handle-args command-line-args))
 
   (x-open-connection (system-name) nil t)
 
@@ -1256,12 +911,11 @@
 
   (setq ns-initialized t))
 
-(add-to-list 'handle-args-function-alist '(ns . ns-handle-args))
+(add-to-list 'handle-args-function-alist '(ns . x-handle-args))
 (add-to-list 'frame-creation-function-alist '(ns . x-create-frame-with-faces))
 (add-to-list 'window-system-initialization-alist '(ns . ns-initialize-window-system))
 
 
 (provide 'ns-win)
 
-;; arch-tag: eb138a45-4e2e-4d68-b1c9-a39665731644
 ;;; ns-win.el ends here
--- a/lisp/term/pc-win.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/term/pc-win.el	Thu Oct 28 19:57:59 2010 +0900
@@ -1,7 +1,7 @@
 ;;; pc-win.el --- setup support for `PC windows' (whatever that is)
 
-;; Copyright (C) 1994, 1996, 1997, 1999, 2001, 2002, 2003, 2004,
-;;   2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 1994, 1996, 1997, 1999, 2001, 2002, 2003, 2004, 2005,
+;;   2006, 2007, 2008, 2009, 2010  Free Software Foundation, Inc.
 
 ;; Author: Morten Welinder <terra@diku.dk>
 ;; Maintainer: FSF
@@ -203,9 +203,11 @@
   "Non-nil means cutting and pasting uses the clipboard.
 This is in addition to, but in preference to, the primary selection.
 
-On MS-Windows, this is non-nil by default, since Windows does not
-support other types of selections.  \(The primary selection that is
-set by Emacs is not accessible to other programs on Windows.\)"
+Note that MS-Windows does not support selection types other than the
+clipboard.  (The primary selection that is set by Emacs is not
+accessible to other programs on MS-Windows.)
+
+This variable is not used by the Nextstep port."
   :type 'boolean
   :group 'killing)
 
@@ -408,5 +410,4 @@
 
 (provide 'pc-win)
 
-;; arch-tag: 5cbdb455-b495-427b-95d0-e417d77d00b4
 ;;; pc-win.el ends here
--- a/lisp/term/tty-colors.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/term/tty-colors.el	Thu Oct 28 19:57:59 2010 +0900
@@ -1,7 +1,7 @@
 ;;; tty-colors.el --- color support for character terminals
 
-;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004,
-;;   2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
+;;   2008, 2009, 2010  Free Software Foundation, Inc.
 
 ;; Author: Eli Zaretskii
 ;; Maintainer: FSF
@@ -768,11 +768,6 @@
     (yes . 8))
   "An alist of supported standard tty color modes and their aliases.")
 
-(defvar tty-defined-color-alist nil
-  "An alist of defined terminal colors and their RGB values.
-
-See the docstring of `tty-color-alist' for the details.")
-
 (defun tty-color-alist (&optional frame)
   "Return an alist of colors supported by FRAME's terminal.
 FRAME defaults to the selected frame.
@@ -1039,5 +1034,4 @@
       (setq colors (cdr colors)))
     count))
 
-;; arch-tag: 84d5c3ef-ae22-4754-99ac-e6350c0967ae
 ;;; tty-colors.el ends here
--- a/lisp/term/w32-win.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/term/w32-win.el	Thu Oct 28 19:57:59 2010 +0900
@@ -148,18 +148,8 @@
 (global-set-key [language-change] 'ignore)
 
 (defvar x-resource-name)
-(defvar x-colors)
 
 
-(defun xw-defined-colors (&optional frame)
-  "Internal function called by `defined-colors', which see."
-  (or frame (setq frame (selected-frame)))
-  (let ((defined-colors nil))
-    (dolist (this-color (or (mapcar 'car w32-color-map) x-colors))
-      (and (color-supported-p this-color frame t)
-	   (setq defined-colors (cons this-color defined-colors))))
-    defined-colors))
-
 ;;;; Function keys
 
  ;;; make f10 activate the real menubar rather than the mini-buffer menu
@@ -196,10 +186,10 @@
   "Report an error when a suspend is attempted."
   (error "Suspending an Emacs running under W32 makes no sense"))
 
-(defvar image-library-alist)
+(defvar dynamic-library-alist)
 
-;;; Set default known names for image libraries
-(setq image-library-alist
+;;; Set default known names for external libraries
+(setq dynamic-library-alist
       '((xpm "libxpm.dll" "xpm4.dll" "libXpm-nox4.dll")
         (png "libpng12d.dll" "libpng12.dll" "libpng.dll"
 	 ;; these are libpng 1.2.8 from GTK+
@@ -316,5 +306,4 @@
 
 (provide 'w32-win)
 
-;; arch-tag: 69fb1701-28c2-4890-b351-3d1fe4b4f166
 ;;; w32-win.el ends here
--- a/lisp/term/x-win.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/term/x-win.el	Thu Oct 28 19:57:59 2010 +0900
@@ -1,7 +1,7 @@
 ;;; x-win.el --- parse relevant switches and set up for X  -*-coding: iso-2022-7bit;-*-
 
 ;; Copyright (C) 1993, 1994, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
-;;   2008, 2009, 2010 Free Software Foundation, Inc.
+;;   2008, 2009, 2010  Free Software Foundation, Inc.
 
 ;; Author: FSF
 ;; Keywords: terminals, i18n
@@ -252,50 +252,6 @@
 (defconst x-pointer-invisible 255)
 
 
-(defvar x-colors)
-
-(defun xw-defined-colors (&optional frame)
-  "Internal function called by `defined-colors'."
-  (or frame (setq frame (selected-frame)))
-  (let ((all-colors x-colors)
-	(this-color nil)
-	(defined-colors nil))
-    (while all-colors
-      (setq this-color (car all-colors)
-	    all-colors (cdr all-colors))
-      (and (color-supported-p this-color frame t)
-	   (setq defined-colors (cons this-color defined-colors))))
-    defined-colors))
-
-;;;; Function keys
-
-(defvar x-alternatives-map
-  (let ((map (make-sparse-keymap)))
-    ;; Map certain keypad keys into ASCII characters that people usually expect.
-    (define-key map [M-backspace] [?\M-\d])
-    (define-key map [M-delete] [?\M-\d])
-    (define-key map [M-tab] [?\M-\t])
-    (define-key map [M-linefeed] [?\M-\n])
-    (define-key map [M-clear] [?\M-\C-l])
-    (define-key map [M-return] [?\M-\C-m])
-    (define-key map [M-escape] [?\M-\e])
-    (define-key map [iso-lefttab] [backtab])
-    (define-key map [S-iso-lefttab] [backtab])
-    map)
-  "Keymap of possible alternative meanings for some keys.")
-
-(defun x-setup-function-keys (frame)
-  "Set up `function-key-map' on the graphical frame FRAME."
-  ;; Don't do this twice on the same display, or it would break
-  ;; normal-erase-is-backspace-mode.
-  (unless (terminal-parameter frame 'x-setup-function-keys)
-    ;; Map certain keypad keys into ASCII characters that people usually expect.
-    (with-selected-frame frame
-      (let ((map (copy-keymap x-alternatives-map)))
-        (set-keymap-parent map (keymap-parent local-function-key-map))
-        (set-keymap-parent local-function-key-map map)))
-    (set-terminal-parameter frame 'x-setup-function-keys t)))
-
 ;;;; Keysyms
 
 (defun vendor-specific-keysyms (vendor)
@@ -1206,40 +1162,12 @@
   "The value of the PRIMARY X selection last time we selected or
 pasted text.")
 
-(defcustom x-select-enable-clipboard t
-  "Non-nil means cutting and pasting uses the clipboard.
-This is in addition to, but in preference to, the primary selection."
-  :type 'boolean
-  :group 'killing
-  :version "24.1")
-
 (defcustom x-select-enable-primary nil
   "Non-nil means cutting and pasting uses the primary selection."
   :type 'boolean
   :group 'killing
   :version "24.1")
 
-(defun x-select-text (text)
-  "Select TEXT, a string, according to the window system.
-
-On X, if `x-select-enable-clipboard' is non-nil, copy TEXT to the
-clipboard.  If `x-select-enable-primary' is non-nil, put TEXT in
-the primary selection.
-
-On Windows, make TEXT the current selection.  If
-`x-select-enable-clipboard' is non-nil, copy the text to the
-clipboard as well.
-
-On Nextstep, put TEXT in the pasteboard."
-  ;; With multi-tty, this function may be called from a tty frame.
-  (when (eq (framep (selected-frame)) 'x)
-    (when x-select-enable-primary
-      (x-set-selection 'PRIMARY text)
-      (setq x-last-selected-text-primary text))
-    (when x-select-enable-clipboard
-      (x-set-selection 'CLIPBOARD text)
-      (setq x-last-selected-text-clipboard text))))
-
 (defvar x-select-request-type nil
   "*Data type request for X selection.
 The value is one of the following data types, a list of them, or nil:
@@ -1640,5 +1568,4 @@
 
 (provide 'x-win)
 
-;; arch-tag: f1501302-db8b-4d95-88e3-116697d89f78
 ;;; x-win.el ends here
--- a/lisp/textmodes/flyspell.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/textmodes/flyspell.el	Thu Oct 28 19:57:59 2010 +0900
@@ -494,9 +494,9 @@
   :keymap flyspell-mode-map
   :group 'flyspell
   (if flyspell-mode
-      (condition-case ()
+      (condition-case err
 	  (flyspell-mode-on)
-	(error (message "Enabling Flyspell mode gave an error")
+	(error (message "Error enabling Flyspell mode:\n%s" (cdr err))
 	       (flyspell-mode -1)))
     (flyspell-mode-off)))
 
@@ -2354,5 +2354,4 @@
 
 (provide 'flyspell)
 
-;; arch-tag: 05d915b9-e9cf-44fb-9137-fc28f5eaab2a
 ;;; flyspell.el ends here
--- a/lisp/textmodes/ispell.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/textmodes/ispell.el	Thu Oct 28 19:57:59 2010 +0900
@@ -983,19 +983,32 @@
     (car (split-string (buffer-string)))))
 
 (defun ispell-aspell-find-dictionary (dict-name)
-  ;; This returns nil if the data file does not exist.
-  ;; Can someone please explain the return value format when the
-  ;; file does exist -- rms?
-  (let* ((lang ;; Strip out variant, etc.
-	  (and (string-match "^[[:alpha:]_]+" dict-name)
-	       (match-string 0 dict-name)))
+  "For aspell dictionary DICT-NAME, return a list of parameters if an
+  associated data file is found or nil otherwise.  List format is
+  that of `ispell-dictionary-base-alist' elements."
+  ;; Make sure `ispell-aspell-data-dir' is defined
+  (or ispell-aspell-data-dir
+      (setq ispell-aspell-data-dir
+	    (ispell-get-aspell-config-value "data-dir")))
+  ;; Try finding associated datafile
+  (let* ((datafile1
+	  (concat ispell-aspell-data-dir "/"
+		  ;; Strip out variant, country code, etc.
+		  (and (string-match "^[[:alpha:]]+" dict-name)
+		       (match-string 0 dict-name)) ".dat"))
+	 (datafile2
+	  (concat ispell-aspell-data-dir "/"
+		  ;; Strip out anything but xx_YY.
+		  (and (string-match "^[[:alpha:]_]+" dict-name)
+		       (match-string 0 dict-name)) ".dat"))
 	 (data-file
-	  (concat (or ispell-aspell-data-dir
-		      (setq ispell-aspell-data-dir
-			    (ispell-get-aspell-config-value "data-dir")))
-		  "/" lang ".dat"))
+	  (if (file-readable-p datafile1)
+	      datafile1
+	    (if (file-readable-p datafile2)
+		datafile2)))
 	 otherchars)
-    (condition-case ()
+
+    (if data-file
 	(with-temp-buffer
 	  (insert-file-contents data-file)
 	  ;; There is zero or one line with special characters declarations.
@@ -1023,9 +1036,7 @@
 		;; Here we specify the encoding to use while communicating with
 		;; aspell.  This doesn't apply to command line arguments, so
 		;; just don't pass words to spellcheck as arguments...
-		'utf-8))
-      (file-error
-       nil))))
+		'utf-8)))))
 
 (defun ispell-aspell-add-aliases (alist)
   "Find aspell's dictionary aliases and add them to dictionary ALIST.
--- a/lisp/textmodes/reftex-cite.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/textmodes/reftex-cite.el	Thu Oct 28 19:57:59 2010 +0900
@@ -358,27 +358,30 @@
       (message "Scanning thebibliography environment in %s" file)
 
       (with-current-buffer buf
-        (save-restriction
-          (widen)
-          (goto-char (point-min))
-          (while (re-search-forward 
-                  "\\(\\`\\|[\n\r]\\)[ \t]*\\\\begin{thebibliography}" nil t)
-            (beginning-of-line 2)
-            (setq start (point))
-            (if (re-search-forward 
-                 "\\(\\`\\|[\n\r]\\)[ \t]*\\\\end{thebibliography}" nil t)
-                (progn
-                  (beginning-of-line 1)
-                  (setq end (point))))
-            (when (and start end)
-              (setq entries 
-                    (append entries
-                      (mapcar 'reftex-parse-bibitem
-                        (delete ""
-                                (split-string 
-                                 (buffer-substring-no-properties start end)
-                                 "[ \t\n\r]*\\\\bibitem\\(\\[[^]]*]\\)*"))))))
-            (goto-char end)))))
+	(save-excursion
+	  (save-restriction
+	    (widen)
+	    (goto-char (point-min))
+	    (while (re-search-forward
+		    "\\(\\`\\|[\n\r]\\)[ \t]*\\\\begin{thebibliography}" nil t)
+	      (beginning-of-line 2)
+	      (setq start (point))
+	      (if (re-search-forward
+		   "\\(\\`\\|[\n\r]\\)[ \t]*\\\\end{thebibliography}" nil t)
+		  (progn
+		    (beginning-of-line 1)
+		    (setq end (point))))
+	      (when (and start end)
+		(setq entries
+		      (append entries
+			      (mapcar 'reftex-parse-bibitem
+				      (delete ""
+					      (split-string
+					       (buffer-substring-no-properties
+						start end)
+					       "[ \t\n\r]*\\\\bibitem\
+\\(\\[[^]]*]\\)*\[ \t]*"))))))
+	      (goto-char end))))))
     (unless entries
       (error "No bibitems found"))
 
--- a/lisp/textmodes/sgml-mode.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/textmodes/sgml-mode.el	Thu Oct 28 19:57:59 2010 +0900
@@ -100,6 +100,7 @@
     (define-key map "\C-c\C-d" 'sgml-delete-tag)
     (define-key map "\C-c\^?" 'sgml-delete-tag)
     (define-key map "\C-c?" 'sgml-tag-help)
+    (define-key map "\C-c]" 'sgml-close-tag)
     (define-key map "\C-c/" 'sgml-close-tag)
 
     ;; Redundant keybindings, for consistency with TeX mode.
--- a/lisp/textmodes/tex-mode.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/textmodes/tex-mode.el	Thu Oct 28 19:57:59 2010 +0900
@@ -864,6 +864,7 @@
 
     ;; Redundant keybindings, for consistency with SGML mode.
     (define-key map "\C-c\C-t" 'latex-insert-block)
+    (define-key map "\C-c]" 'latex-close-block)
     (define-key map "\C-c/" 'latex-close-block)
 
     (define-key map "\C-c\C-e" 'latex-close-block)
--- a/lisp/url/ChangeLog	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/url/ChangeLog	Thu Oct 28 19:57:59 2010 +0900
@@ -1,3 +1,7 @@
+2010-10-14  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* url-gw.el (url-open-stream): Use open-gnutls-stream if it exists.
+
 2010-10-07  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
 	* url-http.el (url-http-end-of-document-sentinel): Protect against
--- a/lisp/url/url-gw.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/url/url-gw.el	Thu Oct 28 19:57:59 2010 +0900
@@ -245,7 +245,10 @@
 		(coding-system-for-write 'binary))
 	    (setq conn (case gw-method
 			 (tls
-			  (open-tls-stream name buffer host service))
+			  (funcall (if (fboundp 'open-gnutls-stream)
+				       'open-gnutls-stream
+				     'open-tls-stream)
+				   name buffer host service))
 			 (ssl
 			  (open-ssl-stream name buffer host service))
 			 ((native)
--- a/lisp/vc/log-edit.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/vc/log-edit.el	Thu Oct 28 19:57:59 2010 +0900
@@ -572,6 +572,14 @@
 	(log-edit-comment-to-change-log)))))
 
 (defvar log-edit-changelog-use-first nil)
+
+(defvar log-edit-rewrite-fixes nil
+  "Rule to rewrite bug numbers into Fixes: headers.
+The value should be of the form (REGEXP . REPLACEMENT)
+where REGEXP should match the expression referring to a bug number
+in the text, and REPLACEMENT is an expression to pass to `replace-match'
+to build the Fixes: header.")
+
 (defun log-edit-insert-changelog (&optional use-first)
   "Insert a log message by looking at the ChangeLog.
 The idea is to write your ChangeLog entries first, and then use this
@@ -593,18 +601,34 @@
     (when (<= (point) eoh)
       (goto-char eoh)
       (if (looking-at "\n") (forward-char 1))))
-  (let ((log-edit-changelog-use-first
-	 (or use-first (eq last-command 'log-edit-insert-changelog))))
-    (log-edit-insert-changelog-entries (log-edit-files)))
-  (log-edit-set-common-indentation)
-  (goto-char (point-min))
-  (when (and log-edit-strip-single-file-name (looking-at "\\*\\s-+"))
-    (forward-line 1)
-    (when (not (re-search-forward "^\\*\\s-+" nil t))
-      (goto-char (point-min))
-      (skip-chars-forward "^():")
-      (skip-chars-forward ": ")
-      (delete-region (point-min) (point)))))
+  (let ((author
+         (let ((log-edit-changelog-use-first
+                (or use-first (eq last-command 'log-edit-insert-changelog))))
+           (log-edit-insert-changelog-entries (log-edit-files)))))
+    (log-edit-set-common-indentation)
+    ;; Add an Author: field if appropriate.
+    (when author
+      (rfc822-goto-eoh)
+      (insert "Author: " author "\n" (if (looking-at "\n") "" "\n")))
+    ;; Add a Fixes: field if applicable.
+    (when (consp log-edit-rewrite-fixes)
+      (rfc822-goto-eoh)
+      (when (re-search-forward (car log-edit-rewrite-fixes) nil t)
+        (let ((start (match-beginning 0))
+              (end (match-end 0))
+              (fixes (match-substitute-replacement
+                      (cdr log-edit-rewrite-fixes))))
+          (delete-region start end)
+          (rfc822-goto-eoh)
+          (insert "Fixes: " fixes "\n" (if (looking-at "\n") "" "\n")))))
+    (goto-char (point-min))
+    (when (and log-edit-strip-single-file-name (looking-at "\\*\\s-+"))
+      (forward-line 1)
+      (when (not (re-search-forward "^\\*\\s-+" nil t))
+        (goto-char (point-min))
+        (skip-chars-forward "^():")
+        (skip-chars-forward ": ")
+        (delete-region (point-min) (point))))))
 
 ;;;;
 ;;;; functions for getting commit message from ChangeLog a file...
@@ -670,6 +694,9 @@
 
 (defvar user-full-name)
 (defvar user-mail-address)
+
+(defvar log-edit-author)                ;Dynamically scoped.
+
 (defun log-edit-changelog-ours-p ()
   "See if ChangeLog entry at point is for the current user, today.
 Return non-nil if it is."
@@ -684,9 +711,23 @@
 		       (functionp add-log-time-format)
 		       (funcall add-log-time-format))
 		  (format-time-string "%Y-%m-%d"))))
-    (looking-at (if log-edit-changelog-use-first
-                    "[^ \t]"
-                  (regexp-quote (format "%s  %s  <%s>" time name mail))))))
+    (if (null log-edit-changelog-use-first)
+        (looking-at (regexp-quote (format "%s  %s  <%s>" time name mail)))
+      ;; Check the author, to potentially add it as a "Author: " header.
+      (when (looking-at "[^ \t]")
+        (when (and (boundp 'log-edit-author)
+                   (not (looking-at (format ".+  .+  <%s>"
+                                            (regexp-quote mail))))
+                   (looking-at ".+  \\(.+  <.+>\\)"))
+          (let ((author (replace-regexp-in-string "  " " "
+                                                  (match-string 1))))
+            (unless (and log-edit-author
+                         (string-match (regexp-quote author) log-edit-author))
+              (setq log-edit-author
+                    (if log-edit-author
+                        (concat log-edit-author ", " author)
+                      author)))))
+        t))))
 
 (defun log-edit-changelog-entries (file)
   "Return the ChangeLog entries for FILE, and the ChangeLog they came from.
@@ -776,7 +817,8 @@
 
 (defun log-edit-insert-changelog-entries (files)
   "Given a list of files FILES, insert the ChangeLog entries for them."
-  (let ((log-entries nil))
+  (let ((log-entries nil)
+        (log-edit-author nil))
     ;; Note that any ChangeLog entry can apply to more than one file.
     ;; Here we construct a log-entries list with elements of the form
     ;;   ((LOGBUFFER ENTRYSTART ENTRYEND) FILE1 FILE2...)
@@ -793,7 +835,8 @@
     (dolist (log-entry (nreverse log-entries))
       (apply 'log-edit-changelog-insert-entries
 	     (append (car log-entry) (cdr log-entry)))
-      (insert "\n"))))
+      (insert "\n"))
+    log-edit-author))
 
 (defun log-edit-extract-headers (headers comment)
   "Extract headers from COMMENT to form command line arguments.
--- a/lisp/w32-fns.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/w32-fns.el	Thu Oct 28 19:57:59 2010 +0900
@@ -32,34 +32,6 @@
 
 ;;;; Function keys
 
-(defvar x-alternatives-map
-  (let ((map (make-sparse-keymap)))
-    ;; Map certain keypad keys into ASCII characters that people usually expect.
-    (define-key map [M-backspace] [?\M-\d])
-    (define-key map [M-delete] [?\M-\d])
-    (define-key map [M-tab] [?\M-\t])
-    (define-key map [M-linefeed] [?\M-\n])
-    (define-key map [M-clear] [?\M-\C-l])
-    (define-key map [M-return] [?\M-\C-m])
-    (define-key map [M-escape] [?\M-\e])
-    (define-key map [iso-lefttab] [backtab])
-    (define-key map [S-iso-lefttab] [backtab])
-    (define-key map [S-tab] [backtab])
-    map)
-  "Keymap of possible alternative meanings for some keys.")
-
-(defun x-setup-function-keys (frame)
-  "Set up `function-key-map' on the graphical frame FRAME."
-  ;; Don't do this twice on the same display, or it would break
-  ;; normal-erase-is-backspace-mode.
-  (unless (terminal-parameter frame 'x-setup-function-keys)
-    ;; Map certain keypad keys into ASCII characters that people usually expect.
-    (with-selected-frame frame
-      (let ((map (copy-keymap x-alternatives-map)))
-        (set-keymap-parent map (keymap-parent local-function-key-map))
-        (set-keymap-parent local-function-key-map map)))
-    (set-terminal-parameter frame 'x-setup-function-keys t)))
-
 (declare-function set-message-beep "w32console.c")
 (declare-function w32-get-clipboard-data "w32select.c")
 (declare-function w32-get-locale-info "w32proc.c")
@@ -432,22 +404,6 @@
 ;; from x-selection-value.
 (defvar x-last-selected-text nil)
 
-(defun x-select-text (text)
-  "Select TEXT, a string, according to the window system.
-
-On X, if `x-select-enable-clipboard' is non-nil, copy TEXT to the
-clipboard.  If `x-select-enable-primary' is non-nil, put TEXT in
-the primary selection.
-
-On Windows, make TEXT the current selection.  If
-`x-select-enable-clipboard' is non-nil, copy the text to the
-clipboard as well.
-
-On Nextstep, put TEXT in the pasteboard."
-  (if x-select-enable-clipboard
-      (w32-set-clipboard-data text))
-  (setq x-last-selected-text text))
-
 (defun x-get-selection-value ()
   "Return the value of the current selection.
 Consult the selection.  Treat empty strings as if they were unset."
@@ -503,5 +459,4 @@
   (delete-matching-lines "^$\\|^;")
   (save-buffers-kill-emacs t))
 
-;; arch-tag: c49b48cc-0f4f-454f-a274-c2dc34815e14
 ;;; w32-fns.el ends here
--- a/lisp/w32-vars.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/w32-vars.el	Thu Oct 28 19:57:59 2010 +0900
@@ -148,17 +148,6 @@
 		      (string :tag "Font")))))))
     :group 'w32)
 
-(defcustom x-select-enable-clipboard t
-  "Non-nil means cutting and pasting uses the clipboard.
-This is in addition to, but in preference to, the primary selection.
-
-On MS-Windows, this is non-nil by default, since Windows does not
-support other types of selections.  \(The primary selection that is
-set by Emacs is not accessible to other programs on Windows.\)"
-  :type 'boolean
-  :group 'killing)
-
 (provide 'w32-vars)
 
-;; arch-tag: ee2394fb-9db7-4c15-a8f0-66b47f4a2bb1
 ;;; w32-vars.el ends here
--- a/lisp/wid-edit.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/wid-edit.el	Thu Oct 28 19:57:59 2010 +0900
@@ -638,7 +638,8 @@
 		specs)
 	   (dolist (elt widget-image-conversion)
 	     (dolist (ext (cdr elt))
-	       (push (list :type (car elt) :file (concat image ext)) specs)))
+	       (push (list :type (car elt) :file (concat image ext)
+			   :ascent 'center) specs)))
  	   (find-image (nreverse specs))))
 	(t
 	 ;; Oh well.
@@ -2195,9 +2196,9 @@
   ;; We could probably do the same job as the images using single
   ;; space characters in a boxed face with a stretch specification to
   ;; make them square.
-  :on-glyph image-checkbox-checked
+  :on-glyph "checked"
   :off "[ ]"
-  :off-glyph image-checkbox-unchecked
+  :off-glyph "unchecked"
   :help-echo "Toggle this item."
   :action 'widget-checkbox-action)
 
--- a/lisp/woman.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/lisp/woman.el	Thu Oct 28 19:57:59 2010 +0900
@@ -1508,7 +1508,7 @@
   ;;   (topic)
   ;;   (topic (path-index) (path-index) ... )
   ;;   (topic (path-index filename) (path-index filename) ... )
-  ;; where the are no duplicates in the value lists.
+  ;; where there are no duplicates in the value lists.
   ;; Topic must match first `word' of filename, so ...
   (let ((topic-regexp
 	 (concat
--- a/make-dist	Thu Oct 14 16:21:40 2010 +0900
+++ b/make-dist	Thu Oct 28 19:57:59 2010 +0900
@@ -49,6 +49,7 @@
 check=yes
 clean_up=no
 make_tar=no
+default_gzip=gzip
 newer=""
 
 while [ $# -gt 0 ]; do
@@ -78,12 +79,7 @@
       new_extension=".new"
       shift
     ;;
-    ## This option tells make-dist to use `compress' instead of gzip.
-    ## Normally, make-dist uses gzip whenever it is present.
-    "--compress")
-      default_gzip="compress"
-    ;;
-    ## Same with bzip2.
+    ## This option tells make-dist to use `bzip2' instead of gzip.
     "--bzip2")
       default_gzip="bzip2"
     ;;
@@ -104,7 +100,6 @@
       echo ""
       echo "  --bzip2	use bzip2 instead of gzip"
       echo "  --clean-up	delete staging directories when done"
-      echo "  --compress	use compress instead of gzip"
       echo "  --lzma	use lzma instead of gzip"
       echo "  --newer=TIME	don't include files older than TIME"
       echo "  --no-check	don't check for bad file names etc."
@@ -161,12 +156,11 @@
 
 echo Version number is $version
 
-if [ $update = yes ];
-then
-  if grep -s "@set EMACSVER  *${version}" ./doc/emacs/emacsver.texi > /dev/null; then
-    true
-  else
-    echo "You must update the version number in \`./doc/emacs/emacsver.texi'"
+if [ $update = yes ]; then
+  if ! grep -q "@set EMACSVER  *${version}" doc/emacs/emacsver.texi || \
+     ! grep -q "tree holds version  *${version}" README; then
+    echo "WARNING: README and/or emacsver.texi have the wrong version number"
+    echo "Consider running M-x set-version from admin/admin.el"
     sleep 5
   fi
 fi
@@ -192,72 +186,66 @@
   exit 1
 fi
 
-### Find where to run Emacs.
-if [ $check = yes ];
-then
-  ### Check for .elc files with no corresponding .el file.
+if [ $check = yes ]; then
   ls -1 lisp/[a-zA-Z]*.el lisp/[a-z]*/[a-zA-Z0-9]*.el \
 	lisp/[a-z]*/[a-z]*/[a-zA-Z0-9]*.el \
 	lisp/[a-z]*/[a-z]*/[a-z]*/[a-zA-Z0-9]*.el \
-	leim/[a-z]*/[a-z]*.el | sed 's/\.el$/.elc/' > /tmp/el
+	leim/[a-z]*/[a-z]*.el > /tmp/el
+
   ls -1 lisp/[a-zA-Z]*.elc lisp/[a-z]*/[a-zA-Z0-9]*.elc \
 	lisp/[a-z]*/[a-z]*/[a-zA-Z0-9]*.elc \
 	lisp/[a-z]*/[a-z]*/[a-z]*/[a-zA-Z0-9]*.elc \
 	leim/[a-z]*/[a-z]*.elc > /tmp/elc
-  bogosities="`comm -13 /tmp/el /tmp/elc`"
-  if [ "${bogosities}" != "" ]; then
+
+  ## Check for .elc files with no corresponding .el file.
+  sed 's/\.el$/.elc/' /tmp/el > /tmp/elelc
+
+  bogosities="`comm -13 /tmp/elelc /tmp/elc`"
+  if [ x"${bogosities}" != x"" ]; then
     echo "The following .elc files have no corresponding .el files:"
     echo "${bogosities}"
   fi
-  rm -f /tmp/el /tmp/elc
 
   ### Check for .el files with no corresponding .elc file.
-  ls -1 lisp/[a-zA-Z]*.el lisp/[a-z]*/[a-zA-Z0-9]*.el \
-	lisp/[a-z]*/[a-z]*/[a-zA-Z0-9]*.el \
-	lisp/[a-z]*/[a-z]*/[a-z]*/[a-zA-Z0-9]*.el \
-	leim/[a-z]*/[a-z]*.el > /tmp/el
-  ls -1 lisp/[a-zA-Z]*.elc lisp/[a-z]*/[a-zA-Z0-9]*.elc \
-	lisp/[a-z]*/[a-z]*/[a-zA-Z0-9]*.el \
-	lisp/[a-z]*/[a-z]*/[a-z]*/[a-zA-Z0-9]*.el \
-	leim/[a-z]*/[a-z]*.elc | sed 's/\.elc$/.el/' > /tmp/elc
-  losers="`comm -23 /tmp/el /tmp/elc`"
+  sed 's/\.elc$/.el/' /tmp/elc > /tmp/elcel
+  losers="`comm -23 /tmp/el /tmp/elcel`"
+
+  rm -f /tmp/el /tmp/elc /tmp/elcel /tmp/elelc
+
   bogosities=
   for file in $losers; do
-    if ! grep -q "no-byte-compile: t" $file; then
-      case $file in
-	site-init.el | site-load.el | site-start.el | default.el)
-	  ;;
-	*)
-	  bogosities="$file $bogosities"
-	  ;;
-      esac
-    fi
+    grep -q "no-byte-compile: t" $file && continue
+    case $file in
+      site-init.el | site-load.el | site-start.el | default.el) continue ;;
+    esac
+
+    bogosities="$file $bogosities"
+
   done
   if [ x"${bogosities}" != x"" ]; then
     echo "The following .el files have no corresponding .elc files:"
     echo "${bogosities}"
   fi
-  rm -f /tmp/el /tmp/elc
-fi
-
-### Make sure configure is newer than configure.in.
-if [ "x`ls -t configure configure.in | sed q`" != "xconfigure" ]; then
-  echo "\`./configure.in' is newer than \`./configure'" >&2
-  echo "Running autoconf" >&2
-  autoconf || { x=$?; echo Autoconf FAILED! >&2; exit $x; }
 fi
 
-### Make sure src/stamp-h.in is newer than configure.in.
-if [ "x`ls -t src/stamp-h.in configure.in | sed q`" != "xsrc/stamp-h.in" ]; then
-  echo "\`./configure.in' is newer than \`./src/stamp-h.in'" >&2
-  echo "Running autoheader" >&2
-  autoheader || { x=$?; echo Autoheader FAILED! >&2; exit $x; }
-  rm -f src/stamp-h.in
-  echo timestamp > src/stamp-h.in
-fi
+if [ $update = yes ]; then
+
+  ## Make sure configure is newer than configure.in.
+  if [ "x`ls -t configure configure.in | sed q`" != "xconfigure" ]; then
+    echo "\`./configure.in' is newer than \`./configure'" >&2
+    echo "Running autoconf" >&2
+    autoconf || { x=$?; echo Autoconf FAILED! >&2; exit $x; }
+  fi
 
-if [ $update = yes ];
-then
+  ## Make sure src/stamp-h.in is newer than configure.in.
+  if [ "x`ls -t src/stamp-h.in configure.in | sed q`" != "xsrc/stamp-h.in" ]; then
+    echo "\`./configure.in' is newer than \`./src/stamp-h.in'" >&2
+    echo "Running autoheader" >&2
+    autoheader || { x=$?; echo Autoheader FAILED! >&2; exit $x; }
+    rm -f src/stamp-h.in
+    echo timestamp > src/stamp-h.in
+  fi
+
   echo "Updating Info files"
   (cd doc/emacs; make info)
   (cd doc/misc; make info)
@@ -274,19 +262,7 @@
 
   echo "Recompiling Lisp files"
   $EMACS -batch -f batch-byte-recompile-directory lisp leim
-fi
-
-## What is this file for?  It goes in srcdir, not the tarfile.
-## Why does it exclude term/ ?
-echo "Making lisp/MANIFEST"
-
-files=`find lisp -type f -name '*.el'`
-for file in $files; do
-   case "$file" in
-     */subdirs.el|*/default.el|*/loaddefs.el|*/term/*) continue ;;
-   esac
-   sed -n 's/^;;; //p; q' $file
-done | sort > lisp/MANIFEST
+fi                              # $update = yes
 
 echo "Creating staging directory: \`${tempparent}'"
 
@@ -312,17 +288,6 @@
 ln config.bat make-dist update-subdirs vpath.sed .dir-locals.el ${tempdir}
 ln mkinstalldirs config.sub config.guess install-sh ${tempdir}
 
-## FIXME why do we bother doing this? set-version in admin/admin.el
-## does this, and more besides.
-echo "Updating version number in README"
-(cd ${tempdir}
- awk \
-   '$1 " " $2 " " $3 " " $4 " " $5 == "This directory tree holds version" { $6 = version; print $0 }
-    $1 " " $2 " " $3 " " $4 " " $5 != "This directory tree holds version"' \
-   version=${version} README > tmp.README
- mv -f tmp.README README)
-
-
 echo "Creating subdirectories"
 for subdir in site-lisp \
 	      leim leim/CXTERM-DIC leim/MISC-DIC \
@@ -417,28 +382,18 @@
 (cd m4
  ln *.m4 ../${tempdir}/m4)
 
+## Exclude README.W32 because it is specific to pre-built binaries(?).
 echo "Making links to \`nt'"
 (cd nt
  ln emacs.manifest emacs.rc emacsclient.rc config.nt ../${tempdir}/nt
  ln emacs-src.tags nmake.defs gmake.defs subdirs.el ../${tempdir}/nt
  ln [a-z]*.bat [a-z]*.[ch] ../${tempdir}/nt
- ln ChangeLog INSTALL README README.W32 makefile.w32-in ../${tempdir}/nt)
-
-echo "Making links to \`nt/inc'"
-(cd nt/inc
- ln [a-z]*.h ../../${tempdir}/nt/inc)
+ ln ChangeLog INSTALL README makefile.w32-in ../${tempdir}/nt)
 
-echo "Making links to \`nt/inc/sys'"
-(cd nt/inc/sys
- ln [a-z]*.h ../../../${tempdir}/nt/inc/sys)
-
-echo "Making links to \`nt/inc/arpa'"
-(cd nt/inc/arpa
- ln [a-z]*.h ../../../${tempdir}/nt/inc/arpa)
-
-echo "Making links to \`nt/inc/netinet'"
-(cd nt/inc/netinet
- ln [a-z]*.h ../../../${tempdir}/nt/inc/netinet)
+echo "Making links to \`nt/inc' and its subdirectories"
+for f in `find nt/inc -type f -name '[a-z]*.h'`; do
+  ln $f $tempdir/$f
+done
 
 echo "Making links to \`nt/icons'"
 (cd nt/icons
@@ -452,7 +407,7 @@
 
 echo "Making links to \`nextstep'"
 (cd nextstep
- ln AUTHORS ChangeLog README INSTALL ../${tempdir}/nextstep)
+ ln ChangeLog README INSTALL ../${tempdir}/nextstep)
 
 echo "Making links to \`nextstep/Cocoa/Emacs.base/Contents'"
 (cd nextstep/Cocoa/Emacs.base/Contents
@@ -493,8 +448,7 @@
 done
 
 echo "Making links to \`info'"
-(cd info
- ln `find . -type f -print` ../${tempdir}/info)
+ln `find info -type f -print` ${tempdir}/info
 
 echo "Making links to \`doc/emacs'"
 (cd doc/emacs
@@ -542,24 +496,23 @@
 find ${tempparent} \( -name '*~' -o -name '#*#' -o -name '.*ignore' -o -name '=*' -o -name 'TAGS' \) -exec rm -f {} \;
 
 if [ "${make_tar}" = yes ]; then
-  if [ "${default_gzip}" = "" ]; then
-    echo "Looking for gzip"
-    temppath=`echo $PATH | sed 's/^:/.:/
-				s/::/:.:/g
-				s/:$/:./
-				s/:/ /g'`
-    default_gzip=`(
-      for dir in ${temppath}; do
-	if [ -f ${dir}/gzip ]; then echo 'gzip --best'; exit 0; fi
-      done
-      echo compress
-    )`
+  echo "Looking for $default_gzip"
+  found=0
+  temppath=`echo $PATH | sed -e 's/^:/.:/' -e 's/::/:.:/g' -e 's/:$/:./' \
+     -e 's/:/ /g'`
+  for dir in ${temppath}; do
+    [ -x ${dir}/$default_gzip ] || continue
+    found=1; break
+  done
+  if [ "$found" = "0" ]; then
+    echo "WARNING: \`$default_gzip' not found, will not compress" >&2
+    default_gzip=cat
   fi
   case "${default_gzip}" in
-    bzip2)      gzip_extension=.bz2 ;;
-    compress* ) gzip_extension=.Z ;;
-    lzma)       gzip_extension=.lzma ;;
-    * )         gzip_extension=.gz ;;
+    bzip2) gzip_extension=.bz2 ;;
+    lzma)  gzip_extension=.lzma ;;
+    gzip)  gzip_extension=.gz ; default_gzip="gzip --best";;
+       *)  gzip_extension= ;;
   esac
   echo "Creating tar file"
   (cd ${tempparent} ; tar cvf - ${emacsname} ) \
--- a/msdos/ChangeLog	Thu Oct 14 16:21:40 2010 +0900
+++ b/msdos/ChangeLog	Thu Oct 28 19:57:59 2010 +0900
@@ -1,3 +1,11 @@
+2010-10-15  Eli Zaretskii  <eliz@gnu.org>
+
+	* sed1v2.inp: Use $(..) instead of ${..} in all edit commands.
+	Needed because of changes in revno 101897.
+
+	* sed6.inp (mkinfodir): Edit to avoid Unix shell-isms.  Needed
+	because of changes in revno 101876.
+
 2010-10-10  Dan Nicolaescu  <dann@ics.uci.edu>
 
 	* sed1v2.inp (PROFILING_LDFLAGS):
--- a/msdos/sed1v2.inp	Thu Oct 14 16:21:40 2010 +0900
+++ b/msdos/sed1v2.inp	Thu Oct 28 19:57:59 2010 +0900
@@ -131,12 +131,12 @@
 /^M_FILE *=/s!@[^@\n]*@!m/intel386.h!
 /^S_FILE *=/s!@[^@\n]*@!s/msdos.h!
 /^@SET_MAKE@$/s/@SET_MAKE@//
-/^.\${libsrc}make-docfile.*>/s!make-docfile!make-docfile -o ../etc/DOC!
-/^.\${libsrc}make-doc/s!>.*$!!
+/^.\$(libsrc)\/make-docfile.*>/s!make-docfile!make-docfile -o ../etc/DOC!
+/^.\$(libsrc)\/make-doc/s!>.*$!!
 /^[ 	]*$/d
 /^	if test -f/,/^	fi$/c\
 	command.com /c if exist .gdbinit rm -f _gdbinit
-/^	if test "\${CANNOT_DUMP}" =/,/^	else /d
+/^	if test "\$(CANNOT_DUMP)" =/,/^	else /d
 /^	fi/d
 /^	LC_ALL=C \$(RUN_TEMACS)/i\
 	stubedit temacs.exe minstack=1024k
@@ -152,7 +152,7 @@
 /^	if test -f/,/^	fi$/c\
 	command.com /c if exist .gdbinit rm -f _gdbinit
 /^	#/d
-/^	cd.*make-docfile/s!$!; cd ${dot}${dot}/src!
+/^	cd.*make-docfile/s!$!; cd ../src!
 /^	@: /d
 /^	-\{0,1\} *ln -/s/ln -f/cp -pf/
 /^[ 	]touch /s/touch/djecho $@ >/
--- a/msdos/sed6.inp	Thu Oct 14 16:21:40 2010 +0900
+++ b/msdos/sed6.inp	Thu Oct 28 19:57:59 2010 +0900
@@ -43,4 +43,6 @@
   s/^	for file in $(INFO_TARGETS)\; do rm -f.*$/	rm -f $(INFO_TARGETS)/
 }
 
+/^mkinfodir *=/s| @.*$|@command.com /c if not exist ..\\..\\info\\emacs mkdir ..\\..\\info|
+
 # arch-tag: defe1001-f35a-47f7-9635-3f5d33ee5e97
--- a/nextstep/AUTHORS	Thu Oct 14 16:21:40 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,59 +0,0 @@
-In addition to the folks listed in ../AUTHORS responsible for GNU Emacs itself,
-the NeXTstep port owes to the following people:
-
-Carl Edman
-    original author and maintainer, mainly UI
-Michael Brouwer
-    heavy contributor, input handling and other areas
-Christian Limpach
-    help / maintenance on NeXTstep
-Scott Bender
-    OpenStep, Rhapsody ports
-Christophe de Dinechin
-    MacOS X port
-Adrian Robert
-    GNUstep port, update Emacs 20 -> 21+
-
-Joe Reiss
-    popup menu, dialog boxes; icons
-Andrew Athan
-    font panel integration
-Scott Byer
-    improved rendering code
-Scott Hess
-    keyboard handling suggestions
-
-Rahul Abrol
-    "hide others" patch
-Adam Ratcliffe
-    preferences panel documentation
-Peter Dyballa
-    assistance with non-ASCII rendering and keyboard handling
-David M. Cooke
-    fix to XPM crash bug
-Carsten Bormann
-    initial patch and assistance getting dired working for non-ASCII filenames
-Andrew Moore
-    assistance on ns-mark-nav extension
-
-The GNUstep port was made possible through the assistance of Adam
-Fedor, Fred Kiefer, M. Uli Klusterer, Alexander Malmberg, Jonas
-Matton, and Riccardo Mottola.  Leigh Smith maintained the SourceForge
-project for a period.
-
-Suggestions from Darcy Brockbank, Timothy Bissell, Scott Byer, David
-Griffiths, Scott Hess, Eberhard Mandler, John C. Randolph, and Bradley
-Taylor all helped things along at one point or another.  Axel Seibert
-<seiberta@@informatik.tu-muenchen.de> and Paul J. Sanchez
-<paul@@whimsy.umsl.edu> offered their time and machines to make a
-binary release possible.
-
-We would also like to thank a number of people who kept up the
-constant supply of bug reports, suggested features and praise: Hardy
-Mayer, Gisli Ottarsson, Anthony Heading, David Bau, Jamie Zawinski,
-Martin Moncrieffe, Simson L. Garfinkel, Richard Stallman, Stephen
-Anderson, Ivo Welch, Magnus Nordborg, Tom Epperly, Andreas Koenig,
-Yves Arrouye, Anil Somayaji, Gregor Hoffleit; and the few hundred
-other people on the mailing list from whom we didn't hear much, but
-the presence of which assured us that maybe this project was actually
-worth doing.
--- a/nextstep/ChangeLog	Thu Oct 14 16:21:40 2010 +0900
+++ b/nextstep/ChangeLog	Thu Oct 28 19:57:59 2010 +0900
@@ -1,3 +1,9 @@
+2010-10-13  Glenn Morris  <rgm@gnu.org>
+
+	* README: Remove information duplicated in AUTHORS.
+	Move historical information to new file ../etc/NEXTSTEP.
+	* AUTHORS: Merge into ./etc/NEXTSTEP and remove file.
+
 2010-10-12  Glenn Morris  <rgm@gnu.org>
 
 	* FOR-RELEASE: Merge into ../etc/TODO.
@@ -182,10 +188,9 @@
 
 ;; Local Variables:
 ;; coding: utf-8
-;; add-log-time-zone-rule: t
 ;; End:
 
-    Copyright (C) 2008, 2009, 2010  Free Software Foundation, Inc.
+  Copyright (C) 2008, 2009, 2010  Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
@@ -201,5 +206,3 @@
 
   You should have received a copy of the GNU General Public License
   along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
-
-;; arch-tag: 963ee08e-8e76-485f-9cfb-65a4333a073c
--- a/nextstep/README	Thu Oct 14 16:21:40 2010 +0900
+++ b/nextstep/README	Thu Oct 28 19:57:59 2010 +0900
@@ -10,19 +10,6 @@
 
 See the INSTALL file in this directory for compilation instructions.
 
-Those primarily responsible for the port were, in chronological order:
-Michael Brouwer, Carl Edman, Christian Limpach, Scott Bender,
-Christophe de Dinechin, and Adrian Robert.
-
-Peter Dyballa assisted in a variety of ways to improve text rendering
-and keyboard handling, Adam Ratcliffe documented the Preferences
-panel, David M. Cooke contributed fixes to XPM handling, and Carsten
-Bormann helped get dired working for non-ASCII filenames.  People who
-provided additional assistance include Adam Fedor, Fred Kiefer, M. Uli
-Klusterer, Alexander Malmberg, Jonas Matton, and Riccardo Mottola.
-See AUTHORS file and "Release History" below for more information.
-
-
 Requirements
 ------------
 MacOS X 10.4 or later
@@ -33,233 +20,6 @@
 Tested on GNU/Linux, should work on other systems, perhaps with minor
 build tweaking.
 
-
-Background
-----------
-Within Emacs, the port and its code are referred to using the term
-"Nextstep", despite the fact that no system or API has been released
-under this name in more than 10 years.  Here's some background on why:
-
-NeXT, Inc. introduced the NeXTstep API with its computer and operating
-system in the late 1980's.  Later on, in collaboration with Sun, this
-API was published as a specification called OpenStep.  The GNUstep
-project started in the early 1990's to provide a free implementation
-of this API.  Later on, Apple bought NeXT (some would say "NeXT bought
-Apple") and made OpenStep the basis of OS X, calling the API "Cocoa".
-Since then, Cocoa has evolved beyond the OpenStep specification, and
-GNUstep has followed it.
-
-Thus, calling this port "OpenStep" is not technically accurate, and in
-the absence of any other determinant, we are using the term
-"Nextstep", both because it signifies the original inspiration that
-created these APIs, and because all of the classes and functions still
-begin with the letters "NS".
-
-(See http://en.wikipedia.org/wiki/Nextstep)
-
-This Emacs port was first released in the early 1990's on the NeXT
-computer, and was successively updated to OpenStep, Rhapsody, OS X,
-and then finally GNUstep, tracking GNU emacs core releases in the
-meantime.
-
-
-Release History
----------------
-
-1990-1992	1.0-3.0 (?)	Michael Brouwer's socket/terminal communication 
-				based version (GUI ran as a separate process.)
-
-1993/10/25	3.0.1		Last (?) release of Brouwer version.  Supports
-				NeXTstep 3.x and below.
-
-1994/04/24	4.0		Carl Edman's version using direct API following
-				the X-Windows port.  NeXTstep 3.x only.
-
-1995/06/15	4.1        	Second (and last) Carl Edman release, based on
-				Emacs 19.28.
-
-1996/07/28	4.2		First Christian Limpach release, based on
-				Emacs 19.29.
-
-??		5.0		??
-
-1997/12/??	6.0b1		Ported to OpenStep by Scott Bender.  Updated
-				to Emacs 20.2.
-
-??		6.0b2		(?) Scott Bender: ported to Rhapsody.
-
-1999/05/??	6.0b3		Scott Bender: "OS X Server", Emacs 20.3.
-
-2001/06/25	7.0		Ported to MacOS X (10.1) by Christophe de
-				Dinechin. Release based on Emacs 20.7. Hosting
-				moved to SourceForge.
-
-2002/01/03	7.0.1		Bug fixes.
-
-2002/08/27	7.0.2		Jaguar (OS X 10.2) support. Added an autoconf
-				option for sys_nerr being in stdio. Added
-				libncurses to the build libraries. Fixed a
-				problem with ns-alternate-is-meta. Changed the
-				icon color to blue, since Jaguar is yellow.
-
-2004/10/07	8.0-pre1	Ported to GNUstep by Adrian Robert.
-
-2004/11/04	8.0-pre2	Restored functionality on OS X (menu code
-				cleanup).  Improved scrollbar handling and
-				paste from other applications.  File icons
-				obtained properly from NSWorkspace.  Dropped
-				Gorm and Nib files.  Background refresh bug
-				fixed (in GNUstep).  Various small fixes and
-				code cleanups.  Now starts up under Art.
-
-2005/01/27	8.0-pre3	Bold and italic faces supported.  Cursor and
-				mouse highlighting rendering bugs
-				fixed. Drag/drop and cut/paste interaction
-				w/external apps fixed.  File load/save panels
-				available.  Stability and rendering speed
-				improvements. Some ObjC and VC mode bugs fixed.
-
-2005/02/27	8.0-rc1		Dynamic path detection at startup so Emacs.app
-				can be moved anywhere.  Added binary packages
-				and simplified source installation to running
-				two scripts.  Thorough cleanup of menu code;
-				now fully functional.  Fixed all detected
-				memory leaks.  Minor frame focus and title
-				bugs fixed.
-
-2005/03/30	8.0-rc2		"Configure" info directory now uses dynamic
-				path setting, so info files can go under .app.
-				Improved select() handling and PTY fixes so
-				shell mode and tramp run smoothly.
-				Significant rendering optimizations under
-				GNUstep, and now works under Art backend.
-				Non-Latin text rendering works (but not
-				fontsets), and LEIM is bundled.  UTF8 is used
-				for clipboard interaction.
-				Arrow cursor now used on scrollbar.
-				objc-mode and tramp now bundled in site-lisp.
-
-2005/05/30	8.0-rc3		Fixed bug with parsing of "easymenu" menus.
-       				Many problems with modes such as SLIME, MatLab,
-				and Planner go away.  Improved scrollbar
-				handling and rendering speed.  Color panel
-				and other bug fixes. mac-fix-env utility.
-				Font handling improvements (OS X 10.3, 10.4):
-				- heed 'GSFontAntiAlias' default
-				- heed system antialiasing threshold
-				- added 'UseQuickdrawSmoothing' default to
-				  invoke less heavy antialiasing
-
-2005/07/05	8.0-rc4		Added a Preferences panel.  Cleaned up
-				rendering for synthetic italic fonts.  Further
-				improved menu parsing.  Use system highlight
-				color.  Added previous- and next-mark history
-				navigation commmands bound to M-p,M-n.
-				Miscellaneous bug fixes.
-
-2005/08/04	8.0-rc5		All internal string handling changed to UTF-8.
-				This means menu items, color and color list
-				names, and a few other things will now display
-				properly.  It does NOT mean UTF-8 filenames
-				are displayed correctly in the minibuffer.
-				Also relating to UTF-8, contents of files
-				using this coding can now be displayed (though
-				not auto-recognized; add extensions to your
-				default coding alist).  Limited mac-roman
-				support was also added (also sans recognition).
-				Certain characters are not displayed properly
-				due to a translation problem.  (UTF-8 based on
-				work by Otfried Cheong; mac-roman from
-				emacs-21.)  Partial support for "dead-key"
-				handling now added.  Transparency (e.g., M-x
-				set-background-color ARGB88FFFFFF) improved:
-				only the background is made transparent.
-				Cursor drawing glitches fixed.  Preferences 
-				handling improved.  Fixed some portability
-				problems on Tiger and Puma.
-
-2005/09/12	8.0		Bundled ispell on OS X.  Minor bug fixes and
-				stability improvements.  Compiles under gcc-4.
-
-2005/09/26	8.0.1		Correct clipped rendering for synthetic
-				italics. Include the info directory.
-				Fix grabenv. Bundle whitespace package.
-
-2005/10/27	8.0.2		Correct rendering for wide characters during
-				cursor movement.  Fix bungled hack in ispell
-				bundling.
-
-2005/11/05	9.0-pre1	Updated to latest Emacs CVS code on unicode-2
-				branch (proposed to be released 2006/2007 as
-				Emacs 23).
-
-2005/11/11	9.0-pre2	Fix crashes for deiconifying and loading
-				certain images.  Improve vertical font metrics
-				(fixes inaccurate page up/down, window size,
-				and partial lines).  Support better remapping
-				of Alt/Opt and remapping of Command.  More
-				insistent defaulting of scrollbar to right.
-				Modest improvements to build process.
-
-2006/04/22	9.0-pre2a	Stopgap interim release to sync w/latest
-				unicode-2 CVS.  Includes XPM and partial
-				toolbar support.
-
-2006/06/08	9.0-pre3	Major upgrade to keyboard handling:
-				system-selected compositional input methods
-				should now work, as well as more keys /
-				keyboards.  XPM, toolbar, and tooltip support.
-				Some improvements to scrollbars, zoom, italic
-				rendering, pasting, Color panel.  Added function
-				ns-set-background-alpha to work around
-				inability to customize with numeric colors.
-				
-2006/12/24	9.0-rc1		Reworked font handling and text rendering to
-				use Kenichi Handa's new font back-end system.
-				Font sets are now supported and automatically
-				created when a font is selected.  Added recent
-				X11 colors to Emacs.clr (remove
-				~/Library/Colors/Emacs.clr to pick up).  Added
-				ns-option-modifier, ns-control-modifier,
-				ns-function-modifier customization variables.
-				Update menus to Emacs 21+ conventions.  Right
-				mouse button now generates mouse-3 events.
-				Various bug fixes and rendering improvements.
-
-2007/09/10	9.0-rc2		Improve menubar, popup menu, and scrollbar
-				behavior, let accented char entry work in
-				isearch, follow system keymap for shortcut
-				keys, fix border and box drawing, remove
-				glitches in modeline drawing, support
-				overstrike for unavailable bold fonts, fix XPM
-				related crasher bugs.  Incremental font
-				metrics caching and other performance
-				improvements.  Shared-lisp builds now possible.
-
-2007/09/20	9.0-rc2a	Interim release.  New features: composed
-				character display, colored fringe bitmaps,
-				colored relief drawing, dynamic resizing,
-				Bug fixes: popup menu position and selection,
-				font width calculation, face color adaptation
-				to background, submenu keyboard navigation.
-				NOT TESTED ON GNUSTEP.
-
-2007/11/19	9.0-rc3		Integrated the multi-TTY functionality from
-				emacs core (however, mixed TTY and GUI
-				sessions are not working yet).  Support 10.5.
-				Give site-lisp load precedence over lisp and
-				add a compile option to prefer an additional
-				directory, use miniaturized miniwindow images
-				in some cases, rename cursor types for
-				consistency w/other emacs terms, improved font
-				selection for symbol scripts.
-				Bug fixes: fringe and bitmap, frame deletion,
-				resizing, cursor blink, workspace open-file,
-				image backgrounds, toolbar item enablement,
-				context menu positioning.
-
-2008/07/15	(none)		Merge to GNU Emacs CVS trunk.
-
 
 This file is part of GNU Emacs.
 
--- a/nt/ChangeLog	Thu Oct 14 16:21:40 2010 +0900
+++ b/nt/ChangeLog	Thu Oct 28 19:57:59 2010 +0900
@@ -1,3 +1,7 @@
+2010-10-13  Juanma Barranquero  <lekktu@gmail.com>
+
+	* INSTALL: Refer to `dynamic-library-alist'.
+
 2010-10-06  Juanma Barranquero  <lekktu@gmail.com>
 
 	* INSTALL: Add note about problematic characters passed to configure.
--- a/nt/INSTALL	Thu Oct 14 16:21:40 2010 +0900
+++ b/nt/INSTALL	Thu Oct 28 19:57:59 2010 +0900
@@ -266,7 +266,7 @@
   library is not an error; the associated image format will simply be
   unavailable.  Note that once Emacs has determined that a library can
   not be found, there's no way to force it to try again, other than
-  restarting.  See the variable `image-library-alist' to configure the
+  restarting.  See the variable `dynamic-library-alist' to configure the
   expected names of the libraries.
 
   Some image libraries have dependencies on one another, or on zlib.
--- a/nt/README	Thu Oct 14 16:21:40 2010 +0900
+++ b/nt/README	Thu Oct 28 19:57:59 2010 +0900
@@ -1,7 +1,7 @@
 	     Emacs for Windows NT/2000 and Windows 95/98/ME
 
-  Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006,
-     2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+  Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
+    2010  Free Software Foundation, Inc.
   See the end of the file for license conditions.
 
   This directory contains support for compiling and running GNU Emacs on
@@ -61,9 +61,6 @@
     a mail spool or POP server to a local user mailbox.  See the
     `Movemail' node of the Emacs manual.
 
-  + digest-doc.exe, sorted-doc.exe - Tools for rebuilding the
-  built-in documentation.
-
 * Further information
 
   There is a web page that serves as a FAQ for the Windows port of
--- a/nt/README.W32	Thu Oct 14 16:21:40 2010 +0900
+++ b/nt/README.W32	Thu Oct 28 19:57:59 2010 +0900
@@ -1,5 +1,5 @@
-Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
-  Free Software Foundation, Inc.
+Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
+  2010  Free Software Foundation, Inc.
 See the end of the file for license conditions.
 
 			   Emacs for Windows
@@ -106,9 +106,6 @@
     a mail spool or POP server to a local user mailbox.  See the
     `Movemail' node of the Emacs manual.
 
-  + digest-doc.exe, sorted-doc.exe - Tools for rebuilding the
-    built-in documentation.
-
 * Image support
 
   Emacs has built in support for XBM and PPM/PGM/PBM images, and the
--- a/src/ChangeLog	Thu Oct 14 16:21:40 2010 +0900
+++ b/src/ChangeLog	Thu Oct 28 19:57:59 2010 +0900
@@ -1,3 +1,221 @@
+2010-10-26  Juanma Barranquero  <lekktu@gmail.com>
+
+	* eval.c (init_eval_once): Set max_lisp_eval_depth to 600;
+	otherwise, bootstrapping on Windows fails to compile macroexp.el.
+
+2010-10-26  Eli Zaretskii  <eliz@gnu.org>
+
+	* cmds.c (internal_self_insert): Don't insert if argument N is
+	zero or negative.  (Bug#7281)
+
+2010-10-26  Jan Djärv  <jan.h.d@swipnet.se>
+
+	* gtkutil.c (qttip_cb): Set title to empty for ATK (Bug#7278).
+
+2010-10-25  Glenn Morris  <rgm@gnu.org>
+
+	* Makefile.in (SOME_MACHINE_LISP): Remove easymenu.elc.
+
+2010-10-24  Glenn Morris  <rgm@gnu.org>
+
+	* w32fns.c (Fx_synchronize, Fx_change_window_property)
+	(Fx_window_property, Fx_file_dialog):
+	* xfns.c (Fx_synchronize, Fx_change_window_property)
+	(Fx_window_property, Fx_file_dialog): Sync docs between w32 and X.
+
+2010-10-24  Chong Yidong  <cyd@stupidchicken.com>
+
+	* xterm.c (x_connection_closed): Kill Emacs unconditionally.
+
+2010-10-24  Eli Zaretskii  <eliz@gnu.org>
+
+	* frame.c (Fframep, Fwindow_system): Deprecate use as a predicate.
+
+	* dispnew.c (syms_of_display) <initial-window-system, window-system>:
+	Deprecate use as a boolean flag.
+
+2010-10-24  Jim Meyering  <jim@meyering.net>
+
+	* emacs.c (argmatch): Don't treat "--" as "--chdir".
+
+2010-10-24  Glenn Morris  <rgm@gnu.org>
+
+	* w16select.c (syms_of_win16select) <selection-coding-system>:
+	<next-selection-coding-system>:
+	* w32select.c (syms_of_w32select) <selection-coding-system>:
+	<next-selection-coding-system>:
+	Sync docs with select.el.
+
+	* xfaces.c (syms_of_xfaces) <tty-defined-color-alist>: Sync doc with
+	Lisp version.
+
+	* w32term.c (syms_of_w32term) <x-use-underline-position-properties>:
+	Sync doc with the xterm.c version.
+
+	* w32term.c (syms_of_w32term) <x-toolkit-scroll-bars>:
+	* xterm.c (syms_of_xterm) <x-toolkit-scroll-bars>: Sync docs.
+
+2010-10-23  Glenn Morris  <rgm@gnu.org>
+
+	* buffer.c (syms_of_buffer) <cursor-in-non-selected-windows>:
+	* frame.c (syms_of_frame) <menu-bar-mode>:
+	* xdisp.c (syms_of_xdisp) <auto-hscroll-mode, display-hourglass>:
+	<hourglass-delay>: Sync docs with Lisp.
+
+2010-10-23  Eli Zaretskii  <eliz@gnu.org>
+
+	Implement mouse highlight for bidi-reordered lines.
+
+	* xdisp.c (fast_find_string_pos): #ifdef away, not used anymore.
+	(mouse_face_from_string_pos): New function, replaces
+	fast_find_string_pos.
+	(note_mouse_highlight): Call it instead of fast_find_string_pos.
+	(note_mode_line_or_margin_highlight): Support bidi-reordered
+	strings and R2L glyph rows.  Fix comments.
+	(note_mouse_highlight): When bidi reordering is turned on in a
+	buffer, call next-single-property-change and
+	previous-single-property-change with last argument nil.  Clear
+	mouse highlight when mouse pointer is in a R2L row on the stretch
+	glyph that stands for no text beyond the line end.
+	(row_containing_pos): Don't return too early when CHARPOS is in a
+	bidi-reordered continued line.  Return immediately when the first
+	hit is found in a line that is not continued, or when an exact
+	match for CHARPOS is found.
+	(rows_from_pos_range): New function.
+	(mouse_face_from_buffer_pos): Use it instead of calling
+	row_containing_pos for START_CHARPOS and END_CHARPOS.  Rewrite the
+	function to support mouse highlight in bidi-reordered lines and
+	not to assume that START_CHARPOS is always in mouse_face_beg_row.
+	If necessary, swap mouse_face_beg_row and mouse_face_end_row so
+	that the former is always above the latter or identical to it.
+	(show_mouse_face): Support drawing highlighted R2L lines.
+	(coords_in_mouse_face_p): New function, bidi-aware.
+	(cursor_in_mouse_face_p, note_mouse_highlight, erase_phys_cursor):
+	Call it instead of comparing with mouse-face members of dpyinfo.
+	(note_mode_line_or_margin_highlight): Fix confusingly swapped
+	usage of hpos and vpos.
+
+2010-10-22  Jan Djärv  <jan.h.d@swipnet.se>
+
+	* xrdb.c: Include keyboard.h for MOTIF.
+
+	* xmenu.c: Revert 2010-07-27 change: lwlib.h is needed for
+	MOTIF (Bug#7263).
+
+	* xfns.c: Include Xm/TextF and Xm/List.
+	(file_dialog_cb, file_dialog_unmap_cb, clean_up_file_dialog): Make
+	ANSI prototypes.
+
+2010-10-22  Glenn Morris  <rgm@gnu.org>
+
+	* Makefile.in (SOME_MACHINE_LISP): Add w32-vars.
+	Remove ccl and duplicate mouse.
+
+2010-10-21  Chong Yidong  <cyd@stupidchicken.com>
+
+	* insdel.c (prepare_to_modify_buffer): Don't set
+	saved-region-selection if modification hooks are disabled.
+
+2010-10-19  Chong Yidong  <cyd@stupidchicken.com>
+
+	* cmds.c (Fdelete_char): Doc fix.
+
+2010-10-19  Ken Brown  <kbrown@cornell.edu>
+
+	* s/cygwin.h (SIGNALS_VIA_CHARACTERS): New define (bug#7225).
+
+2010-10-19  Kenichi Handa  <handa@m17n.org>
+
+	Fix incorrect font metrics when the same font is opened with
+	different pixelsizes.
+
+	* xftfont.c: Include composite.h.
+	(xftfont_shape): New function.
+	(syms_of_xftfont): Set xftfont_driver.shape.
+
+2010-10-18  Julien Danjou  <julien@danjou.info>
+
+	* frame.c (Fframe_pointer_visible_p):
+	Add `frame-pointer-visible-p' to get the pointer visibility.
+
+2010-10-18  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* gnutls.c (emacs_gnutls_read): Return 0 if we get a
+	non-"EAGAIN"-like error to signal to Emacs that the socket should
+	be closed.
+
+2010-10-15  Eli Zaretskii  <eliz@gnu.org>
+
+	* unexcoff.c (make_hdr): Fix prototype according to changes in
+	revno 101757.
+
+	* image.c (tiff_load): Cast 3rd argument to avoid compiler warning.
+
+2010-10-15  Tassilo Horn  <tassilo@member.fsf.org>
+
+	* Makefile.in (really-oldXMenu): Fix typo in variable name that
+	made building the X menu fail.
+	(really-oldXMenu): Fix my previous fix.
+
+2010-10-14  Damyan Pepper  <damyanp@gmail.com>
+
+	Fix handling of font properties on Windows (bug#6303).
+	* font.c (font_filter_properties): New function, refactored from
+	ftfont_filter_properties.
+	* font.h (font_filter_properties): Declare.
+	* ftfont.c (ftfont_filter_properties): Use font_filter_properties.
+	* w32font.c (w32font_booleans, w32font_non_booleans): New variables.
+	(w32font_filter_properties): New function.
+	(w32font_driver): Add w32font_filter_properties.
+
+2010-10-14  Juanma Barranquero  <lekktu@gmail.com>
+
+	* font.c (Ffont_variation_glyphs):
+	* ccl.c (Fccl_execute_on_string): Fix typo in docstring.
+
+2010-10-14  Juanma Barranquero  <lekktu@gmail.com>
+
+	* w32fns.c (w32_wnd_proc, file_dialog_callback):
+	* w32font.c (w32_generic_family):
+	* w32inevt.c (key_event):
+	* w32menu.c (fill_in_menu):
+	* w32proc.c (reader_thread, w32_executable_type, compare_env)
+	(merge_and_sort_env, int_from_hex, enum_locale_fn, enum_codepage_fn):
+	* w32term.c (w32_read_socket): Make static.
+
+2010-10-13  Juanma Barranquero  <lekktu@gmail.com>
+
+	* image.c (DEF_IMGLIB_FN): Add argument to adapt to strict
+	prototypes; all callers changed.
+
+2010-10-13  Juanma Barranquero  <lekktu@gmail.com>
+
+	* makefile.w32-in (TLIB2): Rename from TLIBW32.
+	(OBJ2): New macro.
+	(WIN32OBJ, FONTOBJ): Remove.
+	(OBJ1): Redistribute object files with OBJ2.
+	(LIBS, $(TEMACS)): Use TLIB2.
+	(make-buildobj-CMD, make-buildobj-SH): Use OBJ2.
+	($(TLIB2), TAGS, TAGS-LISP, TAGS-gmake): Depend on OBJ2.
+
+2010-10-13  Juanma Barranquero  <lekktu@gmail.com>
+
+	* emacs.c (Vdynamic_library_alist)
+	(syms_of_emacs) <dynamic-library-alist>: Move from image.c and rename.
+	Doc fix.
+
+	* lisp.h (Vdynamic_library_alist): Declare extern.
+
+	* image.c (Vimage_library_alist)
+	(syms_of_image) <image-library-alist>: Move to emacs.c and rename.
+	(lookup_image_type): Use Vdynamic_library_alist.
+	(Finit_image_library): Doc fix.
+
+2010-10-12  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* Makefile.in (lispsource, libsrc, etc, oldxmenudir, lwlibdir)
+	(lispdir): Remove trailing /, update all uses.
+
 2010-10-12  Jan Djärv  <jan.h.d@swipnet.se>
 
 	* nsterm.m (Qleft): Declare.
@@ -28124,10 +28342,10 @@
 
 ;; Local Variables:
 ;; coding: utf-8
-;; add-log-time-zone-rule: t
 ;; End:
 
-    Copyright (C) 2007, 2008, 2009, 2010  Free Software Foundation, Inc.
+  Copyright (C) 2007, 2008, 2009, 2010
+    Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
@@ -28144,4 +28362,3 @@
   You should have received a copy of the GNU General Public License
   along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
-;; arch-tag: dfb6ad96-1550-4905-9e53-d2059ee84c40
--- a/src/ChangeLog.2	Thu Oct 14 16:21:40 2010 +0900
+++ b/src/ChangeLog.2	Thu Oct 28 19:57:59 2010 +0900
@@ -1563,10 +1563,10 @@
 1987-04-27  Richard Mlynarik  (mly@prep)
 
 	* fileio.c (APOLLO from lnz):
-	Fcopy_file, Fset_file_modes: Don't use un*x modes if
+	(Fcopy_file, Fset_file_modes): Don't use un*x modes if
 	env var USE_DOMAIN_ACLS is set.
-	Fset_file_modes: utimes fix.
-	Finsert_file_contents: Must do fstat after open for Apollo.
+	(Fset_file_modes): utimes fix.
+	(Finsert_file_contents): Must do fstat after open for Apollo.
 
 	* emacs.c (main): (APOLLO from lnz):
 	Don't use un*x modes if env var USE_DOMAIN_ACLS set.
@@ -2073,7 +2073,7 @@
 
 	* xfns.c (Fx_get_default): Add (unsigned char *) cast.
 
-	* window.c: typo.
+	* window.c: Typo.
 
 1987-02-09  Richard M. Stallman  (rms@prep)
 
--- a/src/ChangeLog.3	Thu Oct 14 16:21:40 2010 +0900
+++ b/src/ChangeLog.3	Thu Oct 28 19:57:59 2010 +0900
@@ -5146,7 +5146,7 @@
 	Change mouse movement events to be arranged like click events.
 	(format_modifiers): Note that the click modifier has no
 	written representation.
-	(modifier_names, modifer_symbols): New variables, used to
+	(modifier_names, modifier_symbols): New variables, used to
 	create the Qevent_symbol_elements property.
 	(modify_event_symbol): Change the format of the modified
 	symbol cache; there are too many modifier bits now to use a
@@ -5154,8 +5154,8 @@
 	Document the format of the cache.
 	Put the Qevent_symbol_elements property on each new symbol,
 	instead of a Qevent_unmodified property.
-	(symbols_of_keyboard): Put Qevent_symbol_elements properties on
-	the symbols specified in head_table, not Qevent_unmodifed properties.
+	(symbols_of_keyboard): Put Qevent_symbol_elements properties on the
+	symbols specified in head_table, not Qevent_unmodified properties.
 	Initialize and staticpro modifier_symbols, and staticpro the
 	window elements of button_down_location.
 
@@ -11207,7 +11207,7 @@
 	events to send the function key number instead of a symbol.
 	* keyboard.c (modify_event_symbol): Re-arranged to work well
 	with function key/mouse button numbers instead of symbols.
-	And if (MODIFIERS & up_modifer), prepend "U-" to the name of the
+	And if (MODIFIERS & up_modifier), prepend "U-" to the name of the
 	symbol being constructed.
 	(make_lispy_event): Use the new modify_event_symbol.
 
--- a/src/ChangeLog.7	Thu Oct 14 16:21:40 2010 +0900
+++ b/src/ChangeLog.7	Thu Oct 28 19:57:59 2010 +0900
@@ -491,7 +491,7 @@
 
 	* xselect.c (selection_data_to_lisp_data): Set
 	Vlast_coding_system_used.
-	(lisp_data_to_selection_data): Likewize.
+	(lisp_data_to_selection_data): Likesize.
 
 1998-07-07  Richard Stallman  <rms@psilocin.ai.mit.edu>
 
@@ -502,7 +502,7 @@
 	* editfns.c (Fformat): Replace explicit numeric constants with
 	proper macros.
 
-	* fns.c (concat): Likewize.
+	* fns.c (concat): Likewise.
 
 1998-07-06  Kenichi Handa  <handa@etl.go.jp>
 
--- a/src/ChangeLog.8	Thu Oct 14 16:21:40 2010 +0900
+++ b/src/ChangeLog.8	Thu Oct 28 19:57:59 2010 +0900
@@ -3686,7 +3686,7 @@
 	* lread.c (read_escape): For Control modifier, pay attention to
 	multibyte character.
 	(read1): Likewise.  Signal error or a multibyte character which
-	has a modifer bit.  Check validity of Shift modifer.
+	has a modifier bit.  Check validity of Shift modifier.
 
 	* charset.c (non_ascii_char_to_string): Handle modifier bits as
 	the same as Lisp reader.
--- a/src/ChangeLog.9	Thu Oct 14 16:21:40 2010 +0900
+++ b/src/ChangeLog.9	Thu Oct 28 19:57:59 2010 +0900
@@ -12476,9 +12476,9 @@
 	* atimer.c (stop_other_atimers): Don't call cancel_atimer because
 	that unblocks alarms.
 
-	* alloc.c, bytecode.c, data.c, dispnew.c, ecrt0.c, editfns.c,
-	emacs.c, floatfns.c, fns.c, lread.c, print.c, config.in, lisp.h,
-	Makefile.in: Remove `LISP_FLOAT_TYPE' and `standalone'.
+	* alloc.c, bytecode.c, data.c, dispnew.c, ecrt0.c, editfns.c:
+	* emacs.c, floatfns.c, fns.c, lread.c, print.c, config.in, lisp.h:
+	* Makefile.in: Remove `LISP_FLOAT_TYPE' and `standalone'.
 
 	* frame.c (make_frame): Set frame initially to `garbaged'.
 
@@ -13312,4 +13312,3 @@
   You should have received a copy of the GNU General Public License
   along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
-;;; arch-tag: 38875948-6e89-4f08-b0ca-ff328f1e8b72
--- a/src/Makefile.in	Thu Oct 14 16:21:40 2010 +0900
+++ b/src/Makefile.in	Thu Oct 28 19:57:59 2010 +0900
@@ -1,5 +1,5 @@
+# src/Makefile for GNU Emacs.
 
-# Makefile for GNU Emacs.
 # Copyright (C) 1985, 1987, 1988, 1993, 1994, 1995, 1999, 2000, 2001, 2002,
 #   2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
 #   Free Software Foundation, Inc.
@@ -46,12 +46,12 @@
 # LIBS = @LIBS@
 LIBOBJS = @LIBOBJS@
 
-lispsource = $(srcdir)/../lisp/
-libsrc = ../lib-src/
-etc = ../etc/
-oldXMenudir = ../oldXMenu/
-lwlibdir = ../lwlib/
-lispdir = ../lisp/
+lispsource = $(srcdir)/../lisp
+libsrc = ../lib-src
+etc = ../etc
+oldXMenudir = ../oldXMenu
+lwlibdir = ../lwlib
+lispdir = ../lisp
 
 # Configuration files for .o files to depend on.
 M_FILE = $(srcdir)/@machfile@
@@ -176,8 +176,8 @@
 OLDXMENU_TARGET=@OLDXMENU_TARGET@
 
 ## If !HAVE_X11 || USE_GTK, empty.
-## Else if USE_X_TOOLKIT, $(lwlibdir)liblw.a.
-## Else $(oldxmenudir)libXMenu11.a.
+## Else if USE_X_TOOLKIT, $(lwlibdir)/liblw.a.
+## Else $(oldXMenudir)/libXMenu11.a.
 ## (Actually, rather than being empty, it is set to "nothing".
 ## It is never actually used for anything in this case.
 ## This is done because there is a rule with target $(OLDXMENU) below,
@@ -237,9 +237,9 @@
 MSDOS_OBJ =
 ## w16select.o termcap.o if MSDOS && HAVE_X_WINDOWS.
 MSDOS_X_OBJ =
-MSDOS_SUPPORT_REAL = $(lispsource)ls-lisp.elc $(lispsource)disp-table.elc \
- $(lispsource)dos-fns.elc $(lispsource)dos-w32.elc $(lispsource)dos-vars.elc \
- $(lispsource)term/internal.elc $(lispsource)term/pc-win.elc
+MSDOS_SUPPORT_REAL = $(lispsource)/ls-lisp.elc $(lispsource)/disp-table.elc \
+ $(lispsource)/dos-fns.elc $(lispsource)/dos-w32.elc $(lispsource)/dos-vars.elc \
+ $(lispsource)/term/internal.elc $(lispsource)/term/pc-win.elc
 ## $MSDOS_SUPPORT_REAL if MSDOS.
 MSDOS_SUPPORT = 
 
@@ -258,23 +258,23 @@
 FONT_OBJ=@FONT_OBJ@
 
 ## Used if HAVE_MOUSE.
-REAL_MOUSE_SUPPORT=$(lispsource)mouse.elc $(lispsource)select.elc \
-  $(lispsource)scroll-bar.elc
+REAL_MOUSE_SUPPORT=$(lispsource)/mouse.elc $(lispsource)/select.elc \
+  $(lispsource)/scroll-bar.elc
 ## Used if HAVE_GPM && !HAVE_MOUSE
-GPM_MOUSE_SUPPORT=$(lispsource)mouse.elc
+GPM_MOUSE_SUPPORT=$(lispsource)/mouse.elc
 LIBGPM = @LIBGPM@
 ## Either of the two preceding options, or empty.
 MOUSE_SUPPORT=@MOUSE_SUPPORT@
 
-## $(lispsource)tooltip.elc if HAVE_WINDOW_SYSTEM, else empty.
+## $(lispsource)/tooltip.elc if HAVE_WINDOW_SYSTEM, else empty.
 TOOLTIP_SUPPORT=@TOOLTIP_SUPPORT@
 
-BASE_WINDOW_SUPPORT=$(lispsource)fringe.elc $(lispsource)image.elc \
-  $(lispsource)international/fontset.elc $(lispsource)dnd.elc \
-  $(lispsource)tool-bar.elc $(lispsource)mwheel.elc
+BASE_WINDOW_SUPPORT=$(lispsource)/fringe.elc $(lispsource)/image.elc \
+  $(lispsource)/international/fontset.elc $(lispsource)/dnd.elc \
+  $(lispsource)/tool-bar.elc $(lispsource)/mwheel.elc
 
-X_WINDOW_SUPPORT=$(lispsource)x-dnd.elc $(lispsource)term/common-win.elc \
-  $(lispsource)term/x-win.elc $(lispsource)dynamic-setting.elc
+X_WINDOW_SUPPORT=$(lispsource)/x-dnd.elc $(lispsource)/term/common-win.elc \
+  $(lispsource)/term/x-win.elc $(lispsource)/dynamic-setting.elc
 
 ## If HAVE_X_WINDOWS, both the above
 ## else if HAVE_WINDOW_SYSTEM (ie, HAVE_NS) just the former; else empty.
@@ -397,93 +397,93 @@
 ## Place loaddefs.el first, so it gets generated first, since it is on
 ## the critical path (relevant in parallel compilations).
 lisp= \
-	$(lispsource)loaddefs.el \
-	$(lispsource)abbrev.elc \
-	$(lispsource)buff-menu.elc \
-	$(lispsource)button.elc \
-	$(lispsource)emacs-lisp/byte-run.elc \
-	$(lispsource)composite.elc \
-	$(lispsource)cus-face.elc \
-	$(lispsource)cus-start.elc \
-	$(lispsource)custom.elc \
-	$(lispsource)emacs-lisp/backquote.elc \
-	$(lispsource)emacs-lisp/lisp-mode.elc \
-	$(lispsource)emacs-lisp/lisp.elc \
-	$(lispsource)env.elc \
-	$(lispsource)faces.elc \
-	$(lispsource)files.elc \
-	$(lispsource)format.elc \
-	$(lispsource)facemenu.elc \
+	$(lispsource)/loaddefs.el \
+	$(lispsource)/abbrev.elc \
+	$(lispsource)/buff-menu.elc \
+	$(lispsource)/button.elc \
+	$(lispsource)/emacs-lisp/byte-run.elc \
+	$(lispsource)/composite.elc \
+	$(lispsource)/cus-face.elc \
+	$(lispsource)/cus-start.elc \
+	$(lispsource)/custom.elc \
+	$(lispsource)/emacs-lisp/backquote.elc \
+	$(lispsource)/emacs-lisp/lisp-mode.elc \
+	$(lispsource)/emacs-lisp/lisp.elc \
+	$(lispsource)/env.elc \
+	$(lispsource)/faces.elc \
+	$(lispsource)/files.elc \
+	$(lispsource)/format.elc \
+	$(lispsource)/facemenu.elc \
 	$(MOUSE_SUPPORT) \
-	$(lispsource)emacs-lisp/float-sup.elc \
-	$(lispsource)frame.elc \
-	$(lispsource)help.elc \
-	$(lispsource)indent.elc \
-	$(lispsource)isearch.elc \
-	$(lispsource)rfn-eshadow.elc \
-	$(lispsource)loadup.el \
-	$(lispsource)bindings.elc \
-	$(lispsource)emacs-lisp/map-ynp.elc \
-	$(lispsource)menu-bar.elc \
-	$(lispsource)international/mule.elc \
-	$(lispsource)international/mule-conf.elc \
-	$(lispsource)international/mule-cmds.elc \
-	$(lispsource)international/characters.elc \
-	$(lispsource)international/charprop.el \
-	$(lispsource)case-table.elc \
-	$(lispsource)language/chinese.elc \
-	$(lispsource)language/cyrillic.elc \
-	$(lispsource)language/indian.elc \
-	$(lispsource)language/sinhala.el \
-	$(lispsource)language/english.el \
-	$(lispsource)language/ethiopic.elc \
-	$(lispsource)language/european.elc \
-	$(lispsource)language/czech.el \
-	$(lispsource)language/slovak.el \
-	$(lispsource)language/romanian.el \
-	$(lispsource)language/greek.el \
-	$(lispsource)language/hebrew.elc \
-	$(lispsource)language/japanese.el \
-	$(lispsource)language/korean.el \
-	$(lispsource)language/lao.el \
-	$(lispsource)language/cham.el \
-	$(lispsource)language/tai-viet.el \
-	$(lispsource)language/thai.el \
-	$(lispsource)language/tibetan.elc \
-	$(lispsource)language/vietnamese.elc \
-	$(lispsource)language/misc-lang.el \
-	$(lispsource)language/utf-8-lang.el \
-	$(lispsource)language/georgian.el \
-	$(lispsource)language/khmer.el \
-	$(lispsource)language/burmese.el \
-	$(lispsource)paths.el \
-	$(lispsource)register.elc \
-	$(lispsource)replace.elc \
-	$(lispsource)simple.elc \
-	$(lispsource)minibuffer.elc \
-	$(lispsource)startup.elc \
-	$(lispsource)subr.elc \
-	$(lispsource)term/tty-colors.elc \
-	$(lispsource)font-core.elc \
-	$(lispsource)emacs-lisp/syntax.elc \
-	$(lispsource)font-lock.elc \
-	$(lispsource)jit-lock.elc \
-	$(lispsource)textmodes/fill.elc \
-	$(lispsource)textmodes/page.elc \
-	$(lispsource)textmodes/paragraphs.elc \
-	$(lispsource)textmodes/text-mode.elc \
-	$(lispsource)emacs-lisp/timer.elc \
-	$(lispsource)jka-cmpr-hook.elc \
-	$(lispsource)vc/vc-hooks.elc \
-	$(lispsource)vc/ediff-hook.elc \
-	$(lispsource)epa-hook.elc \
+	$(lispsource)/emacs-lisp/float-sup.elc \
+	$(lispsource)/frame.elc \
+	$(lispsource)/help.elc \
+	$(lispsource)/indent.elc \
+	$(lispsource)/isearch.elc \
+	$(lispsource)/rfn-eshadow.elc \
+	$(lispsource)/loadup.el \
+	$(lispsource)/bindings.elc \
+	$(lispsource)/emacs-lisp/map-ynp.elc \
+	$(lispsource)/menu-bar.elc \
+	$(lispsource)/international/mule.elc \
+	$(lispsource)/international/mule-conf.elc \
+	$(lispsource)/international/mule-cmds.elc \
+	$(lispsource)/international/characters.elc \
+	$(lispsource)/international/charprop.el \
+	$(lispsource)/case-table.elc \
+	$(lispsource)/language/chinese.elc \
+	$(lispsource)/language/cyrillic.elc \
+	$(lispsource)/language/indian.elc \
+	$(lispsource)/language/sinhala.el \
+	$(lispsource)/language/english.el \
+	$(lispsource)/language/ethiopic.elc \
+	$(lispsource)/language/european.elc \
+	$(lispsource)/language/czech.el \
+	$(lispsource)/language/slovak.el \
+	$(lispsource)/language/romanian.el \
+	$(lispsource)/language/greek.el \
+	$(lispsource)/language/hebrew.elc \
+	$(lispsource)/language/japanese.el \
+	$(lispsource)/language/korean.el \
+	$(lispsource)/language/lao.el \
+	$(lispsource)/language/cham.el \
+	$(lispsource)/language/tai-viet.el \
+	$(lispsource)/language/thai.el \
+	$(lispsource)/language/tibetan.elc \
+	$(lispsource)/language/vietnamese.elc \
+	$(lispsource)/language/misc-lang.el \
+	$(lispsource)/language/utf-8-lang.el \
+	$(lispsource)/language/georgian.el \
+	$(lispsource)/language/khmer.el \
+	$(lispsource)/language/burmese.el \
+	$(lispsource)/paths.el \
+	$(lispsource)/register.elc \
+	$(lispsource)/replace.elc \
+	$(lispsource)/simple.elc \
+	$(lispsource)/minibuffer.elc \
+	$(lispsource)/startup.elc \
+	$(lispsource)/subr.elc \
+	$(lispsource)/term/tty-colors.elc \
+	$(lispsource)/font-core.elc \
+	$(lispsource)/emacs-lisp/syntax.elc \
+	$(lispsource)/font-lock.elc \
+	$(lispsource)/jit-lock.elc \
+	$(lispsource)/textmodes/fill.elc \
+	$(lispsource)/textmodes/page.elc \
+	$(lispsource)/textmodes/paragraphs.elc \
+	$(lispsource)/textmodes/text-mode.elc \
+	$(lispsource)/emacs-lisp/timer.elc \
+	$(lispsource)/jka-cmpr-hook.elc \
+	$(lispsource)/vc/vc-hooks.elc \
+	$(lispsource)/vc/ediff-hook.elc \
+	$(lispsource)/epa-hook.elc \
 	$(TOOLTIP_SUPPORT) \
 	$(MSDOS_SUPPORT) \
 	$(WINDOW_SUPPORT) \
 	$(NS_SUPPORT) \
-	$(lispsource)widget.elc \
-	$(lispsource)window.elc \
-	$(lispsource)version.el
+	$(lispsource)/widget.elc \
+	$(lispsource)/window.elc \
+	$(lispsource)/version.el
 
 ## List of relative names for those files from $lisp that are loaded
 ## unconditionally (i.e. on all platforms).  Files from $lisp that
@@ -575,23 +575,22 @@
 
 ## Like $shortlisp, but includes only those files from $lisp that are loaded
 ## conditionally (i.e., only on some platforms).
+## Confusingly, term/internal is not in loadup, but is unconditionally
+## loaded by pc-win, which is.
 SOME_MACHINE_LISP = ../lisp/mouse.elc \
   ../lisp/select.elc ../lisp/scroll-bar.elc \
   ../lisp/ls-lisp.elc ../lisp/dos-fns.elc \
   ../lisp/w32-fns.elc ../lisp/dos-w32.elc \
-  ../lisp/disp-table.elc ../lisp/dos-vars.elc \
+  ../lisp/disp-table.elc ../lisp/dos-vars.elc ../lisp/w32-vars.elc \
   ../lisp/tooltip.elc ../lisp/image.elc \
   ../lisp/fringe.elc ../lisp/dnd.elc \
   ../lisp/mwheel.elc ../lisp/tool-bar.elc \
   ../lisp/x-dnd.elc ../lisp/dynamic-setting.elc \
-  ../lisp/international/ccl.elc \
   ../lisp/international/fontset.elc \
-  ../lisp/mouse.elc \
   ../lisp/term/common-win.elc \
   ../lisp/term/x-win.elc \
   ../lisp/term/pc-win.elc ../lisp/term/internal.elc \
-  ../lisp/term/ns-win.elc ../lisp/term/w32-win.elc \
-  ../lisp/emacs-lisp/easymenu.elc
+  ../lisp/term/ns-win.elc ../lisp/term/w32-win.elc
 
 ## Construct full set of libraries to be linked.
 ## Note that SunOS needs -lm to come before -lc; otherwise, you get
@@ -610,7 +609,7 @@
 ## Does anyone ever pay attention to the load-path-shadows output here?
 ## The dumped Emacs is as functional and more efficient than
 ## bootstrap-emacs, so we replace the latter with the former.
-emacs$(EXEEXT): temacs$(EXEEXT) $(etc)DOC $(lisp)
+emacs$(EXEEXT): temacs$(EXEEXT) $(etc)/DOC $(lisp)
 	if test "$(CANNOT_DUMP)" = "yes"; then \
 	  ln -f temacs$(EXEEXT) emacs$(EXEEXT); \
 	  EMACSLOADPATH=$(lispsource) ./emacs -q -batch \
@@ -634,12 +633,12 @@
 ## the Makefile uses string equality to decide when we talk about identical
 ## files.  Apparently we pass $(shortlisp) rather than $(lisp) to make-docfile
 ## only in order to reduce the command line length.  --Stef
-$(etc)DOC: $(libsrc)make-docfile$(EXEEXT) $(obj) $(lisp) $(SOME_MACHINE_LISP)
-	-rm -f $(etc)DOC
-	$(libsrc)make-docfile -d $(srcdir) $(SOME_MACHINE_OBJECTS) $(obj) > $(etc)DOC
-	$(libsrc)make-docfile -a $(etc)DOC -d $(srcdir) $(SOME_MACHINE_LISP) $(shortlisp)
+$(etc)/DOC: $(libsrc)/make-docfile$(EXEEXT) $(obj) $(lisp) $(SOME_MACHINE_LISP)
+	-rm -f $(etc)/DOC
+	$(libsrc)/make-docfile -d $(srcdir) $(SOME_MACHINE_OBJECTS) $(obj) > $(etc)/DOC
+	$(libsrc)/make-docfile -a $(etc)/DOC -d $(srcdir) $(SOME_MACHINE_LISP) $(shortlisp)
 
-$(libsrc)make-docfile$(EXEEXT):
+$(libsrc)/make-docfile$(EXEEXT):
 	cd $(libsrc); $(MAKE) $(MFLAGS) make-docfile$(EXEEXT)
 
 buildobj.h: Makefile
@@ -660,7 +659,7 @@
 .PHONY: really-lwlib
 
 really-oldXMenu:
-	cd $(oldxmenudir); $(MAKE) $(MFLAGS) \
+	cd $(oldXMenudir); $(MAKE) $(MFLAGS) \
     CC='$(CC)' CFLAGS='$(CFLAGS)' MAKE='$(MAKE)'
 	@true  # make -t should not create really-oldXMenu.
 .PHONY: really-oldXMenu
@@ -737,12 +736,12 @@
 	  $(srcdir)/$(ctagsfiles1) $(srcdir)/$(ctagsfiles2)
 frc:
 TAGS-LISP: frc
-	$(MAKE) -f $(lispdir)Makefile TAGS-LISP ETAGS=../lib-src/etags
+	$(MAKE) -f $(lispdir)/Makefile TAGS-LISP ETAGS=../lib-src/etags
 
-$(lwlibdir)TAGS:
-	(cd $(lwlibdir); $(MAKE) -f $(lwlibdir)Makefile tags ETAGS=../lib-src/etags)
+$(lwlibdir)/TAGS:
+	(cd $(lwlibdir); $(MAKE) -f $(lwlibdir)/Makefile tags ETAGS=../lib-src/etags)
 
-tags: TAGS TAGS-LISP $(lwlibdir)TAGS
+tags: TAGS TAGS-LISP $(lwlibdir)/TAGS
 .PHONY: tags
 
 
@@ -784,7 +783,7 @@
 
 ## VCSWITNESS points to the file that holds info about the current checkout.
 ## We use it as a heuristic to decide when to rebuild loaddefs.el.
-$(lispsource)loaddefs.el: $(BOOTSTRAPEMACS) $(VCSWITNESS)
+$(lispsource)/loaddefs.el: $(BOOTSTRAPEMACS) $(VCSWITNESS)
 	cd ../lisp; $(MAKE) $(MFLAGS) autoloads EMACS=$(bootstrap_exe)
 
 ## Dump an Emacs executable named bootstrap-emacs containing the
--- a/src/atimer.c	Thu Oct 14 16:21:40 2010 +0900
+++ b/src/atimer.c	Thu Oct 28 19:57:59 2010 +0900
@@ -171,9 +171,9 @@
       for (t = *list, prev = NULL; t && t != timer; prev = t, t = t->next)
 	;
 
-      /* If it is, take it off the its list, and put in on the
-	 free-list.  We don't bother to arrange for setting a
-	 different alarm time, since a too early one doesn't hurt.  */
+      /* If it is, take it off its list, and put in on the free-list.
+	 We don't bother to arrange for setting a different alarm time,
+	 since a too early one doesn't hurt.  */
       if (t)
 	{
 	  if (prev)
--- a/src/buffer.c	Thu Oct 14 16:21:40 2010 +0900
+++ b/src/buffer.c	Thu Oct 28 19:57:59 2010 +0900
@@ -1,8 +1,8 @@
 /* Buffer manipulation primitives for GNU Emacs.
-   Copyright (C) 1985, 1986, 1987, 1988, 1989, 1993, 1994,
-                 1995, 1997, 1998, 1999, 2000, 2001, 2002,
-                 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
-                 Free Software Foundation, Inc.
+
+Copyright (C) 1985, 1986, 1987, 1988, 1989, 1993, 1994, 1995, 1997,
+  1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
+  2009, 2010  Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -6140,8 +6140,12 @@
 
   DEFVAR_PER_BUFFER ("cursor-in-non-selected-windows",
 		     &current_buffer->cursor_in_non_selected_windows, Qnil,
-		     doc: /* *Cursor type to display in non-selected windows.
-The value t means to use hollow box cursor.  See `cursor-type' for other values.  */);
+		     doc: /* *Non-nil means show a cursor in non-selected windows.
+If nil, only shows a cursor in the selected window.
+If t, displays a cursor related to the usual cursor type
+\(a solid box becomes hollow, a bar becomes a narrower bar).
+You can also specify the cursor type as in the `cursor-type' variable.
+Use Custom to set this variable and update the display."  */);
 
   DEFVAR_LISP ("kill-buffer-query-functions", &Vkill_buffer_query_functions,
 	       doc: /* List of functions called with no args to query before killing a buffer.
@@ -6218,5 +6222,3 @@
   Fput (intern_c_string ("erase-buffer"), Qdisabled, Qt);
 }
 
-/* arch-tag: e48569bf-69a9-4b65-a23b-8e68769436e1
-   (do not change this comment) */
--- a/src/ccl.c	Thu Oct 14 16:21:40 2010 +0900
+++ b/src/ccl.c	Thu Oct 28 19:57:59 2010 +0900
@@ -448,7 +448,7 @@
    Therefore, the instruction code range is 0..16384(0x3fff).
  */
 
-/* Read a multibyte characeter.
+/* Read a multibyte character.
    A code point is stored into reg[rrr].  A charset ID is stored into
    reg[RRR].  */
 
@@ -2044,7 +2044,7 @@
 If IC is nil, it is initialized to head of the CCL program.
 
 If optional 4th arg CONTINUE is non-nil, keep IC on read operation
-when read buffer is exausted, else, IC is always set to the end of
+when read buffer is exhausted, else, IC is always set to the end of
 CCL-PROGRAM on exit.
 
 It returns the contents of write buffer as a string,
--- a/src/cmds.c	Thu Oct 14 16:21:40 2010 +0900
+++ b/src/cmds.c	Thu Oct 28 19:57:59 2010 +0900
@@ -230,7 +230,7 @@
 Interactively, N is the prefix arg, and KILLFLAG is set if
 N was explicitly specified.
 
-The command `delete-forward' is preferable for interactive use.  */)
+The command `delete-forward-char' is preferable for interactive use.  */)
   (Lisp_Object n, Lisp_Object killflag)
 {
   EMACS_INT pos;
@@ -453,7 +453,7 @@
 		 && SINGLE_BYTE_CHAR_P (c))
 		? UNIBYTE_TO_CHAR (c) : c);
       Lisp_Object string = Fmake_string (make_number (n), make_number (mc));
-					  
+
       if (spaces_to_insert)
 	{
 	  tem = Fmake_string (make_number (spaces_to_insert),
@@ -474,7 +474,7 @@
       insert_and_inherit (strn, p - strn);
       SAFE_FREE ();
     }
-  else
+  else if (n > 0)
     insert_and_inherit (str, len);
 
   if ((CHAR_TABLE_P (Vauto_fill_chars)
--- a/src/coding.c	Thu Oct 14 16:21:40 2010 +0900
+++ b/src/coding.c	Thu Oct 28 19:57:59 2010 +0900
@@ -166,7 +166,7 @@
 
   while (1)
     {
-      /* Get one byte from the source.  If the souce is exausted, jump
+      /* Get one byte from the source.  If the source is exhausted, jump
 	 to no_more_source:.  */
       ONE_MORE_BYTE (c);
 
@@ -180,7 +180,7 @@
   return 0;
 
  no_more_source:
-  /* The source exausted successfully.  */
+  /* The source exhausted successfully.  */
   detect_info->found |= found;
   return 1;
 }
@@ -530,7 +530,7 @@
    on output.  */
 #define CODING_ISO_FLAG_DESIGNATE_AT_BOL 0x0400
 
-/* If set, do not encode unsafe charactes on output.  */
+/* If set, do not encode unsafe characters on output.  */
 #define CODING_ISO_FLAG_SAFE		0x0800
 
 /* If set, extra latin codes (128..159) are accepted as a valid code
@@ -686,7 +686,7 @@
 static Lisp_Object Vcoding_category_list;
 
 /* Table of coding categories (Lisp symbols).  This variable is for
-   internal use oly.  */
+   internal use only.  */
 static Lisp_Object Vcoding_category_table;
 
 /* Table of coding-categories ordered by priority.  */
@@ -818,7 +818,7 @@
   } while (0)
 
 
-/* Like EMIT_ONE_ASCII_BYTE byt store two bytes; C1 and C2.  */
+/* Like EMIT_ONE_ASCII_BYTE but store two bytes; C1 and C2.  */
 
 #define EMIT_TWO_ASCII_BYTES(c1, c2)	\
   do {					\
@@ -1227,7 +1227,7 @@
 
    METHOD is one of enum composition_method.
 
-   Optionnal COMPOSITION-COMPONENTS are characters and composition
+   Optional COMPOSITION-COMPONENTS are characters and composition
    rules.
 
    In the case of CODING_ANNOTATE_CHARSET_MASK, one element CHARSET-ID
@@ -1932,7 +1932,7 @@
 	CHARS is 0xA0 plus a number of characters composed by this
 	data,
 
-	COMPONENTs are characters of multibye form or composition
+	COMPONENTs are characters of multibyte form or composition
 	rules encoded by two-byte of ASCII codes.
 
    In addition, for backward compatibility, the following formats are
@@ -2428,8 +2428,8 @@
   const unsigned char *src_end = coding->source + coding->src_bytes;
   const unsigned char *src_base;
   int *charbuf = coding->charbuf + coding->charbuf_used;
-  /* We may produce two annocations (charset and composition) in one
-     loop and one more charset annocation at the end.  */
+  /* We may produce two annotations (charset and composition) in one
+     loop and one more charset annotation at the end.  */
   int *charbuf_end
     = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 3);
   int consumed_chars = 0, consumed_chars_base;
@@ -2505,7 +2505,7 @@
 	  /* emacs_mule_char can load a charset map from a file, which
 	     allocates a large structure and might cause buffer text
 	     to be relocated as result.  Thus, we need to remember the
-	     original pointer to buffer text, and fixup all related
+	     original pointer to buffer text, and fix up all related
 	     pointers after the call.  */
 	  const unsigned char *orig = coding->source;
 	  EMACS_INT offset;
@@ -2532,7 +2532,7 @@
 	    cmp_status->ncomps -= nchars;
 	}
 
-      /* Now if C >= 0, we found a normally encoded characer, if C <
+      /* Now if C >= 0, we found a normally encoded character, if C <
 	 0, we found an old-style composition component character or
 	 rule.  */
 
@@ -3043,7 +3043,7 @@
 
 
 /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions".
-   Check if a text is encoded in one of ISO-2022 based codig systems.
+   Check if a text is encoded in one of ISO-2022 based coding systems.
    If it is, return 1, else return 0.  */
 
 static int
@@ -3452,7 +3452,7 @@
   return new_chars;
 }
 
-/* If characers are under composition, finish the composition.  */
+/* If characters are under composition, finish the composition.  */
 #define MAYBE_FINISH_COMPOSITION()				\
   do {								\
     if (cmp_status->state != COMPOSING_NO)			\
@@ -3558,8 +3558,8 @@
   const unsigned char *src_end = coding->source + coding->src_bytes;
   const unsigned char *src_base;
   int *charbuf = coding->charbuf + coding->charbuf_used;
-  /* We may produce two annocations (charset and composition) in one
-     loop and one more charset annocation at the end.  */
+  /* We may produce two annotations (charset and composition) in one
+     loop and one more charset annotation at the end.  */
   int *charbuf_end
     = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 3);
   int consumed_chars = 0, consumed_chars_base;
@@ -3861,7 +3861,7 @@
 		goto invalid_code;
 	      /* For the moment, nested direction is not supported.
 		 So, `coding->mode & CODING_MODE_DIRECTION' zero means
-		 left-to-right, and nozero means right-to-left.  */
+		 left-to-right, and nonzero means right-to-left.  */
 	      ONE_MORE_BYTE (c1);
 	      switch (c1)
 		{
@@ -4766,7 +4766,7 @@
   const unsigned char *src_end = coding->source + coding->src_bytes;
   const unsigned char *src_base;
   int *charbuf = coding->charbuf + coding->charbuf_used;
-  /* We may produce one charset annocation in one loop and one more at
+  /* We may produce one charset annotation in one loop and one more at
      the end.  */
   int *charbuf_end
     = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2);
@@ -4884,7 +4884,7 @@
   const unsigned char *src_end = coding->source + coding->src_bytes;
   const unsigned char *src_base;
   int *charbuf = coding->charbuf + coding->charbuf_used;
-  /* We may produce one charset annocation in one loop and one more at
+  /* We may produce one charset annotation in one loop and one more at
      the end.  */
   int *charbuf_end
     = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2);
@@ -5541,7 +5541,7 @@
   const unsigned char *src_end = coding->source + coding->src_bytes;
   const unsigned char *src_base;
   int *charbuf = coding->charbuf + coding->charbuf_used;
-  /* We may produce one charset annocation in one loop and one more at
+  /* We may produce one charset annotation in one loop and one more at
      the end.  */
   int *charbuf_end
     = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2);
@@ -6144,14 +6144,14 @@
    o coding-category-iso-7-else
 
    	The category for a coding system which has the same code range
-	as ISO2022 of 7-bit environemnt but uses locking shift or
+	as ISO2022 of 7-bit environment but uses locking shift or
 	single shift functions.  Assigned the coding-system (Lisp
 	symbol) `iso-2022-7bit-lock' by default.
 
    o coding-category-iso-8-else
 
    	The category for a coding system which has the same code range
-	as ISO2022 of 8-bit environemnt but uses locking shift or
+	as ISO2022 of 8-bit environment but uses locking shift or
 	single shift functions.  Assigned the coding-system (Lisp
 	symbol) `iso-2022-8bit-ss2' by default.
 
@@ -7548,7 +7548,7 @@
 static int reused_workbuf_in_use;
 
 
-/* Return a working buffer of code convesion.  MULTIBYTE specifies the
+/* Return a working buffer of code conversion.  MULTIBYTE specifies the
    multibyteness of returning buffer.  */
 
 static Lisp_Object
@@ -8200,7 +8200,7 @@
 
 /* Detect how the bytes at SRC of length SRC_BYTES are encoded.  If
    HIGHEST is nonzero, return the coding system of the highest
-   priority among the detected coding systems.  Otherwize return a
+   priority among the detected coding systems.  Otherwise return a
    list of detected coding systems sorted by their priorities.  If
    MULTIBYTEP is nonzero, it is assumed that the bytes are in correct
    multibyte form but contains only ASCII and eight-bit chars.
@@ -9302,7 +9302,7 @@
   setup_coding_system (Fcheck_coding_system (coding_system), terminal_coding);
   /* We had better not send unsafe characters to terminal.  */
   terminal_coding->mode |= CODING_MODE_SAFE_ENCODING;
-  /* Characer composition should be disabled.  */
+  /* Character composition should be disabled.  */
   terminal_coding->common_flags &= ~CODING_ANNOTATE_COMPOSITION_MASK;
   terminal_coding->src_multibyte = 1;
   terminal_coding->dst_multibyte = 0;
@@ -9318,7 +9318,7 @@
   CHECK_SYMBOL (coding_system);
   setup_coding_system (Fcheck_coding_system (coding_system),
 		       &safe_terminal_coding);
-  /* Characer composition should be disabled.  */
+  /* Character composition should be disabled.  */
   safe_terminal_coding.common_flags &= ~CODING_ANNOTATE_COMPOSITION_MASK;
   safe_terminal_coding.src_multibyte = 1;
   safe_terminal_coding.dst_multibyte = 0;
@@ -9352,7 +9352,7 @@
   else
     Fcheck_coding_system (coding_system);
   setup_coding_system (coding_system, TERMINAL_KEYBOARD_CODING (t));
-  /* Characer composition should be disabled.  */
+  /* Character composition should be disabled.  */
   TERMINAL_KEYBOARD_CODING (t)->common_flags
     &= ~CODING_ANNOTATE_COMPOSITION_MASK;
   return Qnil;
@@ -9720,7 +9720,7 @@
 
 	 If Nth element is a list of charset IDs, N is the first byte
 	 of one of them.  The list is sorted by dimensions of the
-	 charsets.  A charset of smaller dimension comes firtst. */
+	 charsets.  A charset of smaller dimension comes first. */
       val = Fmake_vector (make_number (256), Qnil);
 
       for (tail = charset_list; CONSP (tail); tail = XCDR (tail))
--- a/src/dispnew.c	Thu Oct 14 16:21:40 2010 +0900
+++ b/src/dispnew.c	Thu Oct 28 19:57:59 2010 +0900
@@ -6583,13 +6583,29 @@
 
   DEFVAR_LISP ("initial-window-system", &Vinitial_window_system,
 	       doc: /* Name of the window system that Emacs uses for the first frame.
-The value is a symbol--for instance, `x' for X windows.
-The value is nil if Emacs is using a text-only terminal.  */);
+The value is a symbol:
+ nil for a termcap frame (a character-only terminal),
+ 'x' for an Emacs frame that is really an X window,
+ 'w32' for an Emacs frame that is a window on MS-Windows display,
+ 'ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
+ 'pc' for a direct-write MS-DOS frame.
+
+Use of this variable as a boolean is deprecated.  Instead,
+use `display-graphic-p' or any of the other `display-*-p'
+predicates which report frame's specific UI-related capabilities.  */);
 
   DEFVAR_KBOARD ("window-system", Vwindow_system,
 		 doc: /* Name of window system through which the selected frame is displayed.
-The value is a symbol--for instance, `x' for X windows.
-The value is nil if the selected frame is on a text-only-terminal.  */);
+The value is a symbol:
+ nil for a termcap frame (a character-only terminal),
+ 'x' for an Emacs frame that is really an X window,
+ 'w32' for an Emacs frame that is a window on MS-Windows display,
+ 'ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
+ 'pc' for a direct-write MS-DOS frame.
+
+Use of this variable as a boolean is deprecated.  Instead,
+use `display-graphic-p' or any of the other `display-*-p'
+predicates which report frame's specific UI-related capabilities.  */);
 
   DEFVAR_LISP ("window-system-version", &Vwindow_system_version,
 	       doc: /* The version number of the window system in use.
--- a/src/emacs.c	Thu Oct 14 16:21:40 2010 +0900
+++ b/src/emacs.c	Thu Oct 28 19:57:59 2010 +0900
@@ -187,6 +187,9 @@
    Lisp code.  */
 Lisp_Object Vemacs_copyright, Vemacs_version;
 
+/* Alist of external libraries and files implementing them.  */
+Lisp_Object Vdynamic_library_alist;
+
 /* If non-zero, emacs should not attempt to use a window-specific code,
    but instead should use the virtual terminal under which it was started.  */
 int inhibit_window_system;
@@ -826,13 +829,14 @@
       printf ("see the file named COPYING.\n");
       exit (0);
     }
-  if (argmatch (argv, argc, "-chdir", "--chdir", 2, &ch_to_dir, &skip_args))
-      if (chdir (ch_to_dir) == -1)
-        {
-          fprintf (stderr, "%s: Can't chdir to %s: %s\n",
-                   argv[0], ch_to_dir, strerror (errno));
-          exit (1);
-        }
+
+  if (argmatch (argv, argc, "-chdir", "--chdir", 4, &ch_to_dir, &skip_args))
+    if (chdir (ch_to_dir) == -1)
+      {
+	fprintf (stderr, "%s: Can't chdir to %s: %s\n",
+		 argv[0], ch_to_dir, strerror (errno));
+	exit (1);
+      }
 
 
 #ifdef HAVE_PERSONALITY_LINUX32
@@ -2507,6 +2511,24 @@
 	       doc: /* Version numbers of this version of Emacs.  */);
   Vemacs_version = build_string (emacs_version);
 
+  DEFVAR_LISP ("dynamic-library-alist", &Vdynamic_library_alist,
+    doc: /* Alist of dynamic libraries vs external files implementing them.
+Each element is a list (LIBRARY FILE...), where the car is a symbol
+representing a supported external library, and the rest are strings giving
+alternate filenames for that library.
+
+Emacs tries to load the library from the files in the order they appear on
+the list; if none is loaded, the running session of Emacs won't have access
+to that library.
+
+Note that image types `pbm' and `xbm' do not need entries in this variable
+because they do not depend on external libraries and are always available.
+
+Also note that this is not a generic facility for accessing external
+libraries; only those already known by Emacs will be loaded.  */);
+  Vdynamic_library_alist = Qnil;
+  Fput (intern_c_string ("dynamic-library-alist"), Qrisky_local_variable, Qt);
+
   /* Make sure IS_DAEMON starts up as false.  */
   daemon_pipe[1] = 0;
 }
--- a/src/eval.c	Thu Oct 14 16:21:40 2010 +0900
+++ b/src/eval.c	Thu Oct 28 19:57:59 2010 +0900
@@ -176,7 +176,7 @@
   specpdl_ptr = specpdl;
   /* Don't forget to update docs (lispref node "Local Variables").  */
   max_specpdl_size = 1000;
-  max_lisp_eval_depth = 500;
+  max_lisp_eval_depth = 600;
 
   Vrun_hooks = Qnil;
 }
--- a/src/font.c	Thu Oct 14 16:21:40 2010 +0900
+++ b/src/font.c	Thu Oct 28 19:57:59 2010 +0900
@@ -3723,6 +3723,58 @@
 }
 
 
+/* Sets attributes on a font.  Any properties that appear in ALIST and
+   BOOLEAN_PROPERTIES or NON_BOOLEAN_PROPERTIES are set on the font.
+   BOOLEAN_PROPERTIES and NON_BOOLEAN_PROPERTIES are NULL-terminated
+   arrays of strings.  This function is intended for use by the font
+   drivers to implement their specific font_filter_properties.  */
+void
+font_filter_properties (Lisp_Object font,
+			Lisp_Object alist,
+			const char *boolean_properties[],
+			const char *non_boolean_properties[])
+{
+  Lisp_Object it;
+  int i;
+
+  /* Set boolean values to Qt or Qnil */
+  for (i = 0; boolean_properties[i] != NULL; ++i)
+    for (it = alist; ! NILP (it); it = XCDR (it))
+      {
+        Lisp_Object key = XCAR (XCAR (it));
+        Lisp_Object val = XCDR (XCAR (it));
+        char *keystr = SDATA (SYMBOL_NAME (key));
+
+        if (strcmp (boolean_properties[i], keystr) == 0)
+          {
+            const char *str = INTEGERP (val) ? (XINT (val) ? "true" : "false")
+	      : SYMBOLP (val) ? (const char *) SDATA (SYMBOL_NAME (val))
+	      : "true";
+
+            if (strcmp ("false", str) == 0 || strcmp ("False", str) == 0
+                || strcmp ("FALSE", str) == 0 || strcmp ("FcFalse", str) == 0
+                || strcmp ("off", str) == 0 || strcmp ("OFF", str) == 0
+                || strcmp ("Off", str) == 0)
+              val = Qnil;
+	    else
+              val = Qt;
+
+            Ffont_put (font, key, val);
+          }
+      }
+
+  for (i = 0; non_boolean_properties[i] != NULL; ++i)
+    for (it = alist; ! NILP (it); it = XCDR (it))
+      {
+        Lisp_Object key = XCAR (XCAR (it));
+        Lisp_Object val = XCDR (XCAR (it));
+        char *keystr = SDATA (SYMBOL_NAME (key));
+        if (strcmp (non_boolean_properties[i], keystr) == 0)
+          Ffont_put (font, key, val);
+      }
+}
+
+
 /* Return the font used to draw character C by FACE at buffer position
    POS in window W.  If STRING is non-nil, it is a string containing C
    at index POS.  If C is negative, get C from the current buffer or
@@ -4486,7 +4538,7 @@
        doc: /* Return a list of variation glyphs for CHAR in FONT-OBJECT.
 Each element of the value is a cons (VARIATION-SELECTOR . GLYPH-ID),
 where
-  VARIATION-SELECTOR is a chracter code of variation selection
+  VARIATION-SELECTOR is a character code of variation selection
     (#xFE00..#xFE0F or #xE0100..#xE01EF)
   GLYPH-ID is a glyph code of the corresponding variation glyph.  */)
   (Lisp_Object font_object, Lisp_Object character)
--- a/src/font.h	Thu Oct 14 16:21:40 2010 +0900
+++ b/src/font.h	Thu Oct 28 19:57:59 2010 +0900
@@ -581,7 +581,7 @@
      FONT-ENTITY and it must be opened to check it, return -1.  */
   int (*has_char) (Lisp_Object font, int c);
 
-  /* Return a glyph code of FONT for characer C (Unicode code point).
+  /* Return a glyph code of FONT for character C (Unicode code point).
      If FONT doesn't have such a glyph, return FONT_INVALID_CODE.  */
   unsigned (*encode_char) (struct font *font, int c);
 
@@ -821,6 +821,11 @@
 extern void *font_get_frame_data (FRAME_PTR f,
                                   struct font_driver *driver);
 
+extern void font_filter_properties (Lisp_Object font,
+				    Lisp_Object alist,
+				    const char *boolean_properties[],
+				    const char *non_boolean_properties[]);
+
 #ifdef HAVE_FREETYPE
 extern struct font_driver ftfont_driver;
 extern void syms_of_ftfont (void);
--- a/src/frame.c	Thu Oct 14 16:21:40 2010 +0900
+++ b/src/frame.c	Thu Oct 28 19:57:59 2010 +0900
@@ -1,6 +1,8 @@
 /* Generic frame functions.
-   Copyright (C) 1993, 1994, 1995, 1997, 1999, 2000, 2001, 2002, 2003,
-     2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+
+Copyright (C) 1993, 1994, 1995, 1997, 1999, 2000, 2001, 2002, 2003,
+  2004, 2005, 2006, 2007, 2008, 2009, 2010
+  Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -201,11 +203,12 @@
 
 DEFUN ("framep", Fframep, Sframep, 1, 1, 0,
        doc: /* Return non-nil if OBJECT is a frame.
-Value is t for a termcap frame (a character-only terminal),
-`x' for an Emacs frame that is really an X window,
-`w32' for an Emacs frame that is a window on MS-Windows display,
-`ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
-`pc' for a direct-write MS-DOS frame.
+Value is:
+  t for a termcap frame (a character-only terminal),
+ 'x' for an Emacs frame that is really an X window,
+ 'w32' for an Emacs frame that is a window on MS-Windows display,
+ 'ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
+ 'pc' for a direct-write MS-DOS frame.
 See also `frame-live-p'.  */)
   (Lisp_Object object)
 {
@@ -247,10 +250,18 @@
 
 DEFUN ("window-system", Fwindow_system, Swindow_system, 0, 1, 0,
        doc: /* The name of the window system that FRAME is displaying through.
-The value is a symbol---for instance, 'x' for X windows.
-The value is nil if Emacs is using a text-only terminal.
-
-FRAME defaults to the currently selected frame.  */)
+The value is a symbol:
+ nil for a termcap frame (a character-only terminal),
+ 'x' for an Emacs frame that is really an X window,
+ 'w32' for an Emacs frame that is a window on MS-Windows display,
+ 'ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
+ 'pc' for a direct-write MS-DOS frame.
+
+FRAME defaults to the currently selected frame.
+
+Use of this function as a predicate is deprecated.  Instead,
+use `display-graphic-p' or any of the other `display-*-p'
+predicates which report frame's specific UI-related capabilities.  */)
   (Lisp_Object frame)
 {
   Lisp_Object type;
@@ -4314,6 +4325,20 @@
     }
 }
 
+DEFUN ("frame-pointer-visible-p", Fframe_pointer_visible_p,
+       Sframe_pointer_visible_p, 0, 1, 0,
+       doc: /* Return t if the mouse pointer displayed on FRAME is visible.
+Otherwise it returns nil.  FRAME omitted or nil means the
+selected frame.  This is useful when `make-pointer-invisible' is set.  */)
+  (Lisp_Object frame)
+{
+  if (NILP (frame))
+    frame = selected_frame;
+
+  CHECK_FRAME (frame);
+
+  return (XFRAME (frame)->pointer_invisible ? Qnil : Qt);
+}
 
 
 /***********************************************************************
@@ -4538,7 +4563,11 @@
   staticpro (&Qdelete_frame_functions);
 
   DEFVAR_LISP ("menu-bar-mode", &Vmenu_bar_mode,
-               doc: /* Non-nil if Menu-Bar mode is enabled.  */);
+               doc: /* Non-nil if Menu-Bar mode is enabled.
+See the command `menu-bar-mode' for a description of this minor mode.
+Setting this variable directly does not take effect;
+either customize it (see the info node `Easy Customization')
+or call the function `menu-bar-mode'.  */);
   Vmenu_bar_mode = Qt;
 
   DEFVAR_LISP ("tool-bar-mode", &Vtool_bar_mode,
@@ -4623,6 +4652,7 @@
   defsubr (&Sset_frame_width);
   defsubr (&Sset_frame_size);
   defsubr (&Sset_frame_position);
+  defsubr (&Sframe_pointer_visible_p);
 
 #ifdef HAVE_WINDOW_SYSTEM
   defsubr (&Sx_get_resource);
@@ -4631,5 +4661,3 @@
 
 }
 
-/* arch-tag: 7dbf2c69-9aad-45f8-8296-db893d6dd039
-   (do not change this comment) */
--- a/src/ftfont.c	Thu Oct 14 16:21:40 2010 +0900
+++ b/src/ftfont.c	Thu Oct 28 19:57:59 2010 +0900
@@ -88,7 +88,7 @@
                                         enum ftfont_cache_for);
 
 static void ftfont_filter_properties (Lisp_Object font, Lisp_Object alist);
-                                                
+
 Lisp_Object ftfont_font_format (FcPattern *, Lisp_Object);
 
 #define SYMBOL_FcChar8(SYM) (FcChar8 *) SDATA (SYMBOL_NAME (SYM))
@@ -260,7 +260,7 @@
   else
     {
       /* As this font is not scalable, parhaps this is a BDF or PCF
-	 font. */ 
+	 font. */
       FT_Face ft_face;
 
       ASET (entity, FONT_ADSTYLE_INDEX, get_adstyle_property (p));
@@ -2093,7 +2093,7 @@
   return to;
 }
 
-static int 
+static int
 ftfont_try_otf (MFLTFont *font, MFLTOtfSpec *spec,
 		MFLTGlyphString *in, int from, int to)
 {
@@ -2645,42 +2645,7 @@
 static void
 ftfont_filter_properties (Lisp_Object font, Lisp_Object alist)
 {
-  Lisp_Object it;
-  int i;
-
-  /* Set boolean values to Qt or Qnil */
-  for (i = 0; ftfont_booleans[i] != NULL; ++i)
-    for (it = alist; ! NILP (it); it = XCDR (it))
-      {
-        Lisp_Object key = XCAR (XCAR (it));
-        Lisp_Object val = XCDR (XCAR (it));
-        char *keystr = SDATA (SYMBOL_NAME (key));
-
-        if (strcmp (ftfont_booleans[i], keystr) == 0)
-          {
-            const char *str = SYMBOLP (val) ? SDATA (SYMBOL_NAME (val)) : NULL;
-            if (INTEGERP (val)) str = XINT (val) != 0 ? "true" : "false";
-            if (str == NULL) str = "true";
-
-            val = Qt;
-            if (strcmp ("false", str) == 0 || strcmp ("False", str) == 0
-                || strcmp ("FALSE", str) == 0 || strcmp ("FcFalse", str) == 0
-                || strcmp ("off", str) == 0 || strcmp ("OFF", str) == 0
-                || strcmp ("Off", str) == 0)
-              val = Qnil;
-            Ffont_put (font, key, val);
-          }
-      }
-
-  for (i = 0; ftfont_non_booleans[i] != NULL; ++i)
-    for (it = alist; ! NILP (it); it = XCDR (it))
-      {
-        Lisp_Object key = XCAR (XCAR (it));
-        Lisp_Object val = XCDR (XCAR (it));
-        char *keystr = SDATA (SYMBOL_NAME (key));
-        if (strcmp (ftfont_non_booleans[i], keystr) == 0)
-          Ffont_put (font, key, val);
-      }
+  font_filter_properties (font, alist, ftfont_booleans, ftfont_non_booleans);
 }
 
 
--- a/src/gnutls.c	Thu Oct 14 16:21:40 2010 +0900
+++ b/src/gnutls.c	Thu Oct 28 19:57:59 2010 +0900
@@ -125,8 +125,13 @@
   rtnval = gnutls_read (state, buf, nbyte);
   if (rtnval >= 0)
     return rtnval;
-  else
-    return -1;
+  else {
+    if (rtnval == GNUTLS_E_AGAIN ||
+	rtnval == GNUTLS_E_INTERRUPTED)
+      return -1;
+    else
+      return 0;
+  }
 }
 
 /* convert an integer error to a Lisp_Object; it will be either a
--- a/src/gtkutil.c	Thu Oct 14 16:21:40 2010 +0900
+++ b/src/gtkutil.c	Thu Oct 28 19:57:59 2010 +0900
@@ -589,6 +589,8 @@
       g_object_ref (G_OBJECT (x->ttip_lbl));
       gtk_tooltip_set_custom (tooltip, x->ttip_lbl);
       x->ttip_window = GTK_WINDOW (gtk_widget_get_toplevel (x->ttip_lbl));
+      /* ATK needs an empty title for some reason.  */
+      gtk_window_set_title (x->ttip_window, "");
       /* Realize so we can safely get screen later on.  */
       gtk_widget_realize (GTK_WIDGET (x->ttip_window));
       gtk_widget_realize (x->ttip_lbl);
--- a/src/image.c	Thu Oct 14 16:21:40 2010 +0900
+++ b/src/image.c	Thu Oct 28 19:57:59 2010 +0900
@@ -567,10 +567,6 @@
 
 Lisp_Object Vimage_types;
 
-/* An alist of image types and libraries that implement the type.  */
-
-Lisp_Object Vimage_library_alist;
-
 /* Cache for delayed-loading image types.  */
 
 static Lisp_Object Vimage_type_cache;
@@ -645,7 +641,7 @@
   struct image_type *type;
 
   /* We must initialize the image-type if it hasn't been already.  */
-  if (NILP (Finit_image_library (symbol, Vimage_library_alist)))
+  if (NILP (Finit_image_library (symbol, Vdynamic_library_alist)))
     return 0;			/* unimplemented */
 
   for (type = image_types; type; type = type->next)
@@ -1914,7 +1910,7 @@
 #ifdef HAVE_NTGUI
 
 /* Macro for defining functions that will be loaded from image DLLs.  */
-#define DEF_IMGLIB_FN(func) int (FAR CDECL *fn_##func)()
+#define DEF_IMGLIB_FN(func,args) int (FAR CDECL *fn_##func)args
 
 /* Macro for loading those image functions from the library.  */
 #define LOAD_IMGLIB_FN(lib,func) {					\
@@ -1923,10 +1919,11 @@
   }
 
 /* Load a DLL implementing an image type.
-   The `image-library-alist' variable associates a symbol,
-   identifying an image type, to a list of possible filenames.
+   The argument LIBRARIES is usually the variable
+   `dynamic-library-alist', which associates a symbol, identifying
+   an external DLL library, to a list of possible filenames.
    The function returns NULL if no library could be loaded for
-   the given image type, or if the library was previously loaded;
+   the given symbol, or if the library was previously loaded;
    else the handle of the DLL.  */
 static HMODULE
 w32_delayed_load (Lisp_Object libraries, Lisp_Object type)
@@ -3268,10 +3265,12 @@
 
 /* XPM library details.  */
 
-DEF_IMGLIB_FN (XpmFreeAttributes);
-DEF_IMGLIB_FN (XpmCreateImageFromBuffer);
-DEF_IMGLIB_FN (XpmReadFileToImage);
-DEF_IMGLIB_FN (XImageFree);
+DEF_IMGLIB_FN (XpmFreeAttributes, (XpmAttributes *));
+DEF_IMGLIB_FN (XpmCreateImageFromBuffer, (Display *, char *, xpm_XImage **,
+					  xpm_XImage **, XpmAttributes *));
+DEF_IMGLIB_FN (XpmReadFileToImage, (Display *, char *, xpm_XImage **,
+				    xpm_XImage **, XpmAttributes *));
+DEF_IMGLIB_FN (XImageFree, (xpm_XImage *));
 
 static int
 init_xpm_functions (Lisp_Object libraries)
@@ -5439,27 +5438,31 @@
 #ifdef HAVE_NTGUI
 /* PNG library details.  */
 
-DEF_IMGLIB_FN (png_get_io_ptr);
-DEF_IMGLIB_FN (png_sig_cmp);
-DEF_IMGLIB_FN (png_create_read_struct);
-DEF_IMGLIB_FN (png_create_info_struct);
-DEF_IMGLIB_FN (png_destroy_read_struct);
-DEF_IMGLIB_FN (png_set_read_fn);
-DEF_IMGLIB_FN (png_set_sig_bytes);
-DEF_IMGLIB_FN (png_read_info);
-DEF_IMGLIB_FN (png_get_IHDR);
-DEF_IMGLIB_FN (png_get_valid);
-DEF_IMGLIB_FN (png_set_strip_16);
-DEF_IMGLIB_FN (png_set_expand);
-DEF_IMGLIB_FN (png_set_gray_to_rgb);
-DEF_IMGLIB_FN (png_set_background);
-DEF_IMGLIB_FN (png_get_bKGD);
-DEF_IMGLIB_FN (png_read_update_info);
-DEF_IMGLIB_FN (png_get_channels);
-DEF_IMGLIB_FN (png_get_rowbytes);
-DEF_IMGLIB_FN (png_read_image);
-DEF_IMGLIB_FN (png_read_end);
-DEF_IMGLIB_FN (png_error);
+DEF_IMGLIB_FN (png_get_io_ptr, (png_structp));
+DEF_IMGLIB_FN (png_sig_cmp, (png_bytep, png_size_t, png_size_t));
+DEF_IMGLIB_FN (png_create_read_struct, (png_const_charp, png_voidp,
+					png_error_ptr, png_error_ptr));
+DEF_IMGLIB_FN (png_create_info_struct, (png_structp));
+DEF_IMGLIB_FN (png_destroy_read_struct, (png_structpp, png_infopp, png_infopp));
+DEF_IMGLIB_FN (png_set_read_fn, (png_structp, png_voidp, png_rw_ptr));
+DEF_IMGLIB_FN (png_set_sig_bytes, (png_structp, int));
+DEF_IMGLIB_FN (png_read_info, (png_structp, png_infop));
+DEF_IMGLIB_FN (png_get_IHDR, (png_structp, png_infop,
+			      png_uint_32 *, png_uint_32 *,
+			      int *, int *, int *, int *, int *));
+DEF_IMGLIB_FN (png_get_valid, (png_structp, png_infop, png_uint_32));
+DEF_IMGLIB_FN (png_set_strip_16, (png_structp));
+DEF_IMGLIB_FN (png_set_expand, (png_structp));
+DEF_IMGLIB_FN (png_set_gray_to_rgb, (png_structp));
+DEF_IMGLIB_FN (png_set_background, (png_structp, png_color_16p,
+				    int, int, double));
+DEF_IMGLIB_FN (png_get_bKGD, (png_structp, png_infop, png_color_16p *));
+DEF_IMGLIB_FN (png_read_update_info, (png_structp, png_infop));
+DEF_IMGLIB_FN (png_get_channels, (png_structp, png_infop));
+DEF_IMGLIB_FN (png_get_rowbytes, (png_structp, png_infop));
+DEF_IMGLIB_FN (png_read_image, (png_structp, png_bytepp));
+DEF_IMGLIB_FN (png_read_end, (png_structp, png_infop));
+DEF_IMGLIB_FN (png_error, (png_structp, png_const_charp));
 
 static int
 init_png_functions (Lisp_Object libraries)
@@ -6042,14 +6045,14 @@
 #ifdef HAVE_NTGUI
 
 /* JPEG library details.  */
-DEF_IMGLIB_FN (jpeg_CreateDecompress);
-DEF_IMGLIB_FN (jpeg_start_decompress);
-DEF_IMGLIB_FN (jpeg_finish_decompress);
-DEF_IMGLIB_FN (jpeg_destroy_decompress);
-DEF_IMGLIB_FN (jpeg_read_header);
-DEF_IMGLIB_FN (jpeg_read_scanlines);
-DEF_IMGLIB_FN (jpeg_std_error);
-DEF_IMGLIB_FN (jpeg_resync_to_restart);
+DEF_IMGLIB_FN (jpeg_CreateDecompress, (j_decompress_ptr, int, size_t));
+DEF_IMGLIB_FN (jpeg_start_decompress, (j_decompress_ptr));
+DEF_IMGLIB_FN (jpeg_finish_decompress, (j_decompress_ptr));
+DEF_IMGLIB_FN (jpeg_destroy_decompress, (j_decompress_ptr));
+DEF_IMGLIB_FN (jpeg_read_header, (j_decompress_ptr, boolean));
+DEF_IMGLIB_FN (jpeg_read_scanlines, (j_decompress_ptr, JSAMPARRAY, JDIMENSION));
+DEF_IMGLIB_FN (jpeg_std_error, (struct jpeg_error_mgr *));
+DEF_IMGLIB_FN (jpeg_resync_to_restart, (j_decompress_ptr, int));
 
 static int
 init_jpeg_functions (Lisp_Object libraries)
@@ -6575,14 +6578,17 @@
 #ifdef HAVE_NTGUI
 
 /* TIFF library details.  */
-DEF_IMGLIB_FN (TIFFSetErrorHandler);
-DEF_IMGLIB_FN (TIFFSetWarningHandler);
-DEF_IMGLIB_FN (TIFFOpen);
-DEF_IMGLIB_FN (TIFFClientOpen);
-DEF_IMGLIB_FN (TIFFGetField);
-DEF_IMGLIB_FN (TIFFReadRGBAImage);
-DEF_IMGLIB_FN (TIFFClose);
-DEF_IMGLIB_FN (TIFFSetDirectory);
+DEF_IMGLIB_FN (TIFFSetErrorHandler, (TIFFErrorHandler));
+DEF_IMGLIB_FN (TIFFSetWarningHandler, (TIFFErrorHandler));
+DEF_IMGLIB_FN (TIFFOpen, (const char *, const char *));
+DEF_IMGLIB_FN (TIFFClientOpen, (const char *, const char *, thandle_t,
+				TIFFReadWriteProc, TIFFReadWriteProc,
+				TIFFSeekProc, TIFFCloseProc, TIFFSizeProc,
+				TIFFMapFileProc, TIFFUnmapFileProc));
+DEF_IMGLIB_FN (TIFFGetField, (TIFF *, ttag_t, ...));
+DEF_IMGLIB_FN (TIFFReadRGBAImage, (TIFF *, uint32, uint32, uint32 *, int));
+DEF_IMGLIB_FN (TIFFClose, (TIFF *));
+DEF_IMGLIB_FN (TIFFSetDirectory, (TIFF *, tdir_t));
 
 static int
 init_tiff_functions (Lisp_Object libraries)
@@ -6787,8 +6793,9 @@
       memsrc.len = SBYTES (specified_data);
       memsrc.index = 0;
 
-      /* Casting return value avoids a GCC warning on W32.  */
-      tiff = (TIFF *)fn_TIFFClientOpen ("memory_source", "r", &memsrc,
+      /* Casting arguments return value avoids a GCC warning on W32.  */
+      tiff = (TIFF *)fn_TIFFClientOpen ("memory_source", "r",
+					(thandle_t) &memsrc,
 					(TIFFReadWriteProc) tiff_read_from_memory,
 					(TIFFReadWriteProc) tiff_write_from_memory,
 					tiff_seek_in_memory,
@@ -7024,10 +7031,10 @@
 #ifdef HAVE_NTGUI
 
 /* GIF library details.  */
-DEF_IMGLIB_FN (DGifCloseFile);
-DEF_IMGLIB_FN (DGifSlurp);
-DEF_IMGLIB_FN (DGifOpen);
-DEF_IMGLIB_FN (DGifOpenFileName);
+DEF_IMGLIB_FN (DGifCloseFile, (GifFileType *));
+DEF_IMGLIB_FN (DGifSlurp, (GifFileType *));
+DEF_IMGLIB_FN (DGifOpen, (void *, InputFunc));
+DEF_IMGLIB_FN (DGifOpenFileName, (const char *));
 
 static int
 init_gif_functions (Lisp_Object libraries)
@@ -8583,7 +8590,7 @@
 
 Image types pbm and xbm are prebuilt; other types are loaded here.
 Libraries to load are specified in alist LIBRARIES (usually, the value
-of `image-library-alist', which see).  */)
+of `dynamic-library-alist', which see).  */)
   (Lisp_Object type, Lisp_Object libraries)
 {
   Lisp_Object tested;
@@ -8659,20 +8666,6 @@
 To check whether it is really supported, use `image-type-available-p'.  */);
   Vimage_types = Qnil;
 
-  DEFVAR_LISP ("image-library-alist", &Vimage_library_alist,
-    doc: /* Alist of image types vs external libraries needed to display them.
-
-Each element is a list (IMAGE-TYPE LIBRARY...), where the car is a symbol
-representing a supported image type, and the rest are strings giving
-alternate filenames for the corresponding external libraries.
-
-Emacs tries to load the libraries in the order they appear on the
-list; if none is loaded, the running session of Emacs won't
-support the image type.  Types 'pbm and 'xbm don't need to be
-listed; they are always supported.  */);
-  Vimage_library_alist = Qnil;
-  Fput (intern_c_string ("image-library-alist"), Qrisky_local_variable, Qt);
-
   DEFVAR_LISP ("max-image-size", &Vmax_image_size,
     doc: /* Maximum size of images.
 Emacs will not load an image into memory if its pixel width or
--- a/src/insdel.c	Thu Oct 14 16:21:40 2010 +0900
+++ b/src/insdel.c	Thu Oct 28 19:57:59 2010 +0900
@@ -2051,6 +2051,7 @@
 
   /* If `select-active-regions' is non-nil, save the region text.  */
   if (!NILP (current_buffer->mark_active)
+      && !inhibit_modification_hooks
       && XMARKER (current_buffer->mark)->buffer
       && NILP (Vsaved_region_selection)
       && (EQ (Vselect_active_regions, Qonly)
--- a/src/lisp.h	Thu Oct 14 16:21:40 2010 +0900
+++ b/src/lisp.h	Thu Oct 28 19:57:59 2010 +0900
@@ -3300,6 +3300,7 @@
 extern Lisp_Object Vinstallation_directory;
 extern Lisp_Object empty_unibyte_string, empty_multibyte_string;
 extern Lisp_Object Qfile_name_handler_alist;
+extern Lisp_Object Vdynamic_library_alist;
 extern void (*fatal_error_signal_hook) (void);
 EXFUN (Fkill_emacs, 1) NO_RETURN;
 #if HAVE_SETLOCALE
--- a/src/lread.c	Thu Oct 14 16:21:40 2010 +0900
+++ b/src/lread.c	Thu Oct 28 19:57:59 2010 +0900
@@ -1,7 +1,8 @@
 /* Lisp parsing and input streams.
-   Copyright (C) 1985, 1986, 1987, 1988, 1989, 1993, 1994, 1995,
-                 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-                 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+
+Copyright (C) 1985, 1986, 1987, 1988, 1989, 1993, 1994, 1995, 1997,
+  1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
+  2009, 2010  Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -3889,9 +3890,9 @@
 }
 #endif /* NOTDEF */
 
-/* Define an "integer variable"; a symbol whose value is forwarded
-   to a C variable of type int.  Sample call:
-   DEFVAR_INT ("emacs-priority", &emacs_priority, "Documentation");  */
+/* Define an "integer variable"; a symbol whose value is forwarded to a
+   C variable of type int.  Sample call (munged w "xx" to fool make-docfile):
+   DEFxxVAR_INT ("emacs-priority", &emacs_priority, "Documentation");  */
 void
 defvar_int (struct Lisp_Intfwd *i_fwd,
 	    const char *namestring, EMACS_INT *address)
@@ -4474,5 +4475,3 @@
   staticpro (&Qrehash_threshold);
 }
 
-/* arch-tag: a0d02733-0f96-4844-a659-9fd53c4f414d
-   (do not change this comment) */
--- a/src/makefile.w32-in	Thu Oct 14 16:21:40 2010 +0900
+++ b/src/makefile.w32-in	Thu Oct 28 19:57:59 2010 +0900
@@ -37,7 +37,7 @@
 TEMACS_TMP      = $(BLD)/temacs.bin
 TLIB0           = $(BLD)/temacs0.$(A)
 TLIB1           = $(BLD)/temacs1.$(A)
-TLIBW32         = $(BLD)/temacw32.$(A)
+TLIB2           = $(BLD)/temacs2.$(A)
 TOBJ            = $(BLD)/firstfile.$(O)
 TRES		= $(BLD)/emacs.res
 TLASTLIB	= $(BLD)/lastfile.$(A)
@@ -94,8 +94,9 @@
 	$(BLD)/scroll.$(O)		\
 	$(BLD)/search.$(O)		\
 	$(BLD)/sound.$(O)		\
-	$(BLD)/syntax.$(O)		\
-	$(BLD)/sysdep.$(O)		\
+	$(BLD)/syntax.$(O)
+
+OBJ2 =  $(BLD)/sysdep.$(O)		\
 	$(BLD)/term.$(O)		\
 	$(BLD)/tparam.$(O)		\
 	$(BLD)/undo.$(O)		\
@@ -125,28 +126,27 @@
 	$(BLD)/fringe.$(O)		\
 	$(BLD)/image.$(O)		\
 	$(BLD)/terminal.$(O)            \
-        $(BLD)/menu.$(O)
-
-WIN32OBJ = $(BLD)/w32term.$(O)		\
-	   $(BLD)/w32xfns.$(O)		\
-	   $(BLD)/w32fns.$(O)		\
-	   $(BLD)/xfaces.$(O)		\
-	   $(BLD)/w32select.$(O)	\
-	   $(BLD)/w32menu.$(O)		\
-	   $(BLD)/w32reg.$(O)
-
-FONTOBJ = $(BLD)/w32font.$(O) $(BLD)/w32uniscribe.$(O)
+	$(BLD)/menu.$(O)		\
+	$(BLD)/w32term.$(O)		\
+	$(BLD)/w32xfns.$(O)		\
+	$(BLD)/w32fns.$(O)		\
+	$(BLD)/xfaces.$(O)		\
+	$(BLD)/w32select.$(O)		\
+	$(BLD)/w32menu.$(O)		\
+	$(BLD)/w32reg.$(O)		\
+	$(BLD)/w32font.$(O)		\
+	$(BLD)/w32uniscribe.$(O)
 
 LIBS =  $(TLIB0)	\
 	$(TLIB1)	\
-	$(TLIBW32)	\
+	$(TLIB2)	\
 	$(TLASTLIB)	\
 	$(WINMM)	\
 	$(ADVAPI32)	\
 	$(GDI32)	\
 	$(COMDLG32)	\
 	$(USER32)	\
-	$(MPR)	\
+	$(MPR)		\
 	$(SHELL32)	\
 	$(WINSPOOL)	\
 	$(OLE32)	\
@@ -174,7 +174,7 @@
 # (it is the preload heap size in MB).
 #
 temacs:         stamp_BLD $(TEMACS)
-$(TEMACS):      $(TLIB0) $(TLIB1) $(TLIBW32) $(TLASTLIB) $(TOBJ) $(TRES) \
+$(TEMACS):      $(TLIB0) $(TLIB1) $(TLIB2) $(TLASTLIB) $(TOBJ) $(TRES) \
 		  ../nt/$(BLD)/addsection.exe
 	$(LINK) $(LINK_OUT)$(TEMACS_TMP) $(FULL_LINK_FLAGS) $(TOBJ) $(TRES) $(LIBS)
 	"../nt/$(BLD)/addsection" "$(TEMACS_TMP)" "$(TEMACS)" EMHEAP 21
@@ -190,16 +190,14 @@
 	echo #define BUILDOBJ ^"\> buildobj.h
 	echo $(OBJ0)            \>> buildobj.h
 	echo $(OBJ1)            \>> buildobj.h
-	echo $(WIN32OBJ)        \>> buildobj.h
-	echo $(FONTOBJ)         \>> buildobj.h
+	echo $(OBJ2)            \>> buildobj.h
 	echo ^">> buildobj.h
 
 make-buildobj-SH:
 	echo '#define BUILDOBJ $(DQUOTE)\'  > buildobj.h
 	echo $(OBJ0)                   '\' >> buildobj.h
 	echo $(OBJ1)                   '\' >> buildobj.h
-	echo $(WIN32OBJ)               '\' >> buildobj.h
-	echo $(FONTOBJ)                '\' >> buildobj.h
+	echo $(OBJ2)                   '\' >> buildobj.h
 	echo '$(DQUOTE)'                   >> buildobj.h
 
 bootstrap: bootstrap-emacs
@@ -249,7 +247,7 @@
 $(TLIB1):       $(OBJ1)
 	- $(DEL) $@
 	$(AR) $(AR_OUT)$@ $(ALL_DEPS)
-$(TLIBW32):	$(WIN32OBJ) $(FONTOBJ)
+$(TLIB2):	$(OBJ2)
 	- $(DEL) $@
 	$(AR) $(AR_OUT)$@ $(ALL_DEPS)
 
@@ -298,10 +296,10 @@
 ##
 ## This works only with GNU Make.
 
-TAGS: $(OBJ0) $(OBJ1) $(WIN32OBJ) $(FONTOBJ)
+TAGS: $(OBJ0) $(OBJ1) $(OBJ2)
 	$(MAKE) $(MFLAGS) TAGS-$(MAKETYPE)
 
-TAGS-LISP: $(OBJ0) $(OBJ1) $(WIN32OBJ) $(FONTOBJ)
+TAGS-LISP: $(OBJ0) $(OBJ1) $(OBJ2)
 	$(MAKE) $(MFLAGS) TAGS-LISP-$(MAKETYPE)
 
 TAGS-gmake:
@@ -311,8 +309,7 @@
 	../lib-src/$(BLD)/etags.exe -a --regex=@../nt/emacs-src.tags \
 	  $(patsubst $(BLD)%.$(O),$(CURDIR)%.c,$(OBJ1))
 	../lib-src/$(BLD)/etags.exe -a --regex=@../nt/emacs-src.tags \
-	  $(patsubst $(BLD)%.$(O),$(CURDIR)%.c,$(WIN32OBJ)) \
-	  $(patsubst $(BLD)%.$(O),$(CURDIR)%.c,$(FONTOBJ)) \
+	  $(patsubst $(BLD)%.$(O),$(CURDIR)%.c,$(OBJ2)) \
 	  $(CURDIR)/*.h
 
 TAGS-nmake:
@@ -1752,4 +1749,4 @@
 # Each object file depends on stamp_BLD, because in parallel builds we must
 # make sure $(BLD) exists before starting compilations.
 #
-$(OBJ0) $(OBJ1) $(WIN32OBJ) $(FONTOBJ) $(BLD)/lastfile.$(O) $(BLD)/firstfile.$(O): stamp_BLD
+$(OBJ0) $(OBJ1) $(OBJ2) $(BLD)/lastfile.$(O) $(BLD)/firstfile.$(O): stamp_BLD
--- a/src/nsterm.m	Thu Oct 14 16:21:40 2010 +0900
+++ b/src/nsterm.m	Thu Oct 28 19:57:59 2010 +0900
@@ -145,24 +145,24 @@
 extern Lisp_Object Qcursor_color, Qcursor_type, Qns, Qleft;
 
 /* Specifies which emacs modifier should be generated when NS receives
-   the Alternate modifer.  May be Qnone or any of the modifier lisp symbols. */
+   the Alternate modifier.  May be Qnone or any of the modifier lisp symbols. */
 Lisp_Object ns_alternate_modifier;
 
 /* Specifies which emacs modifier should be generated when NS receives
-   the right Alternate modifer.  Has same values as ns_alternate_modifier plus
+   the right Alternate modifier.  Has same values as ns_alternate_modifier plus
    the value Qleft which means whatever value ns_alternate_modifier has.  */
 Lisp_Object ns_right_alternate_modifier;
 
 /* Specifies which emacs modifier should be generated when NS receives
-   the Command modifer.  May be any of the modifier lisp symbols. */
+   the Command modifier.  May be any of the modifier lisp symbols. */
 Lisp_Object ns_command_modifier;
 
 /* Specifies which emacs modifier should be generated when NS receives
-   the Control modifer.  May be any of the modifier lisp symbols. */
+   the Control modifier.  May be any of the modifier lisp symbols. */
 Lisp_Object ns_control_modifier;
 
 /* Specifies which emacs modifier should be generated when NS receives
-   the Function modifer (laptops).  May be any of the modifier lisp symbols. */
+   the Function modifier (laptops).  May be any of the modifier lisp symbols. */
 Lisp_Object ns_function_modifier;
 
 /* Control via default 'GSFontAntiAlias' on OS X and GNUstep. */
--- a/src/print.c	Thu Oct 14 16:21:40 2010 +0900
+++ b/src/print.c	Thu Oct 28 19:57:59 2010 +0900
@@ -1401,7 +1401,7 @@
 #define PRINT_STRING_NON_CHARSET_FOUND 1
 #define PRINT_STRING_UNSAFE_CHARSET_FOUND 2
 
-/* Bitwize or of the abobe macros. */
+/* Bitwise or of the above macros. */
 static int print_check_string_result;
 
 static void
--- a/src/regex.c	Thu Oct 14 16:21:40 2010 +0900
+++ b/src/regex.c	Thu Oct 28 19:57:59 2010 +0900
@@ -4089,7 +4089,7 @@
 		   && match_any_multibyte_characters == false)
 	    {
 	      /* Set fastmap[I] to 1 where I is a leading code of each
-		 multibyte characer in the range table. */
+		 multibyte character in the range table. */
 	      int c, count;
 	      unsigned char lc1, lc2;
 
--- a/src/s/cygwin.h	Thu Oct 14 16:21:40 2010 +0900
+++ b/src/s/cygwin.h	Thu Oct 28 19:57:59 2010 +0900
@@ -101,5 +101,8 @@
    returns ENOSYS.  A workaround is to set G_SLICE=always-malloc. */
 #define G_SLICE_ALWAYS_MALLOC
 
+/* Send signals to subprocesses by "typing" special chars at them.  */
+#define SIGNALS_VIA_CHARACTERS
+
 /* arch-tag: 5ae7ba00-83b0-4ab3-806a-3e845779191b
    (do not change this comment) */
--- a/src/unexcoff.c	Thu Oct 14 16:21:40 2010 +0900
+++ b/src/unexcoff.c	Thu Oct 28 19:57:59 2010 +0900
@@ -141,8 +141,7 @@
   error (msg, a1, a2);
 }
 
-static int make_hdr (int, int, unsigned, unsigned, unsigned,
-		     const char *, const char *);
+static int make_hdr (int, int, const char *, const char *);
 static int copy_text_and_data (int, int);
 static int copy_sym (int, int, const char *, const char *);
 static void mark_x (const char *);
--- a/src/w16select.c	Thu Oct 14 16:21:40 2010 +0900
+++ b/src/w16select.c	Thu Oct 28 19:57:59 2010 +0900
@@ -1,6 +1,7 @@
 /* 16-bit Windows Selection processing for emacs on MS-Windows
-   Copyright (C) 1996, 1997, 2001, 2002, 2003, 2004,
-                 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+
+Copyright (C) 1996, 1997, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
+ 2008, 2009, 2010  Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -693,18 +694,43 @@
   defsubr (&Sx_selection_exists_p);
 
   DEFVAR_LISP ("selection-coding-system", &Vselection_coding_system,
-	       doc: /* Coding system for communicating with other X clients.
-When sending or receiving text via cut_buffer, selection, and clipboard,
-the text is encoded or decoded by this coding system.
-The default value is `iso-latin-1-dos'.  */);
+	       doc: /* Coding system for communicating with other programs.
+
+For MS-Windows and MS-DOS:
+When sending or receiving text via selection and clipboard, the text
+is encoded or decoded by this coding system.  The default value is
+the current system default encoding on 9x/Me, `utf-16le-dos'
+\(Unicode) on NT/W2K/XP, and `iso-latin-1-dos' on MS-DOS.
+
+For X Windows:
+When sending text via selection and clipboard, if the target
+data-type matches with the type of this coding system, it is used
+for encoding the text.  Otherwise (including the case that this
+variable is nil), a proper coding system is used as below:
+
+data-type	coding system
+---------	-------------
+UTF8_STRING	utf-8
+COMPOUND_TEXT	compound-text-with-extensions
+STRING		iso-latin-1
+C_STRING	no-conversion
+
+When receiving text, if this coding system is non-nil, it is used
+for decoding regardless of the data-type.  If this is nil, a
+proper coding system is used according to the data-type as above.
+
+See also the documentation of the variable `x-select-request-type' how
+to control which data-type to request for receiving text.
+
+The default value is nil.  */);
   Vselection_coding_system = intern ("iso-latin-1-dos");
 
   DEFVAR_LISP ("next-selection-coding-system", &Vnext_selection_coding_system,
-	       doc: /* Coding system for the next communication with other X clients.
+	       doc: /* Coding system for the next communication with other programs.
 Usually, `selection-coding-system' is used for communicating with
-other X clients.  But, if this variable is set, it is used for the
-next communication only.  After the communication, this variable is
-set to nil.  */);
+other programs (X Windows clients or MS Windows programs).  But, if this
+variable is set, it is used for the next communication only.
+After the communication, this variable is set to nil.  */);
   Vnext_selection_coding_system = Qnil;
 
   QPRIMARY   = intern ("PRIMARY");	staticpro (&QPRIMARY);
@@ -713,5 +739,3 @@
 
 #endif /* MSDOS */
 
-/* arch-tag: 085a22c8-7324-436e-a6da-102464ce95d8
-   (do not change this comment) */
--- a/src/w32.c	Thu Oct 14 16:21:40 2010 +0900
+++ b/src/w32.c	Thu Oct 28 19:57:59 2010 +0900
@@ -2970,7 +2970,7 @@
 
   if (!init)
     {
-      initialize_utc_base();
+      initialize_utc_base ();
       init = 1;
     }
 
@@ -5037,7 +5037,7 @@
 	  unsigned long nblock = 1;
 	  int rc = pfn_ioctlsocket (SOCK_HANDLE (s), FIONBIO, &nblock);
 	  if (rc == SOCKET_ERROR)
-	    set_errno();
+	    set_errno ();
 	  /* Keep track of the fact that we set this to non-blocking.  */
 	  fd_info[s].flags |= FILE_NDELAY;
 	  return rc;
@@ -5935,8 +5935,7 @@
 
 /* For serial-process-configure  */
 void
-serial_configure (struct Lisp_Process *p,
-		  Lisp_Object contact)
+serial_configure (struct Lisp_Process *p, Lisp_Object contact)
 {
   Lisp_Object childp2 = Qnil;
   Lisp_Object tem = Qnil;
--- a/src/w32fns.c	Thu Oct 14 16:21:40 2010 +0900
+++ b/src/w32fns.c	Thu Oct 28 19:57:59 2010 +0900
@@ -1,7 +1,8 @@
 /* Graphical user interface functions for the Microsoft W32 API.
-   Copyright (C) 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-                 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
-                 Free Software Foundation, Inc.
+
+Copyright (C) 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
+  2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+  Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -245,7 +246,7 @@
 };
 
 /* Reportedly, VS 6 does not have this in its headers.  */
-#if defined(_MSC_VER) && _MSC_VER < 1300
+#if defined (_MSC_VER) && _MSC_VER < 1300
 DECLARE_HANDLE(HMONITOR);
 #endif
 
@@ -1870,7 +1871,6 @@
     }
 }
 
-
 void
 x_set_scroll_bar_default_width (struct frame *f)
 {
@@ -1900,7 +1900,7 @@
   return cursor;
 }
 
-extern LRESULT CALLBACK w32_wnd_proc (HWND, UINT, WPARAM, LPARAM);
+static LRESULT CALLBACK w32_wnd_proc (HWND, UINT, WPARAM, LPARAM);
 
 static BOOL
 w32_init_class (HINSTANCE hinst)
@@ -2672,7 +2672,7 @@
 
 /* Main window procedure */
 
-LRESULT CALLBACK
+static LRESULT CALLBACK
 w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
 {
   struct frame *f;
@@ -3918,7 +3918,6 @@
       return DefWindowProc (hwnd, msg, wParam, lParam);
     }
 
-
   /* The most common default return code for handled messages is 0.  */
   return 0;
 }
@@ -4359,7 +4358,6 @@
   x_default_parameter (f, parameters, Qright_fringe, Qnil,
 		       "rightFringe", "RightFringe", RES_TYPE_NUMBER);
 
-
   /* Init faces before x_default_parameter is called for scroll-bar
      parameters because that function calls x_set_scroll_bar_width,
      which calls change_frame_size, which calls Fset_window_buffer,
@@ -4977,7 +4975,17 @@
 }
 
 DEFUN ("x-synchronize", Fx_synchronize, Sx_synchronize, 1, 2, 0,
-       doc: /* This is a noop on W32 systems.  */)
+       doc: /* If ON is non-nil, report X errors as soon as the erring request is made.
+This function only has an effect on X Windows.  With MS Windows, it is
+defined but does nothing.
+
+If ON is nil, allow buffering of requests.
+Turning on synchronization prohibits the Xlib routines from buffering
+requests and seriously degrades performance, but makes debugging much
+easier.
+The optional second argument TERMINAL specifies which display to act on.
+TERMINAL should be a terminal object, a frame or a display name (a string).
+If TERMINAL is omitted or nil, that stands for the selected frame's display.  */)
   (Lisp_Object on, Lisp_Object display)
 {
   return Qnil;
@@ -4992,11 +5000,12 @@
 DEFUN ("x-change-window-property", Fx_change_window_property,
        Sx_change_window_property, 2, 6, 0,
        doc: /* Change window property PROP to VALUE on the X window of FRAME.
-VALUE may be a string or a list of conses, numbers and/or strings.
-If an element in the list is a string, it is converted to
-an Atom and the value of the Atom is used.  If an element is a cons,
-it is converted to a 32 bit number where the car is the 16 top bits and the
-cdr is the lower 16 bits.
+PROP must be a string.  VALUE may be a string or a list of conses,
+numbers and/or strings.  If an element in the list is a string, it is
+converted to an atom and the value of the Atom is used.  If an element
+is a cons, it is converted to a 32 bit number where the car is the 16
+top bits and the cdr is the lower 16 bits.
+
 FRAME nil or omitted means use the selected frame.
 If TYPE is given and non-nil, it is the name of the type of VALUE.
 If TYPE is not given or nil, the type is STRING.
@@ -5004,9 +5013,7 @@
 It must be one of 8, 16 or 32.
 If VALUE is a string or FORMAT is nil or not given, FORMAT defaults to 8.
 If OUTER_P is non-nil, the property is changed for the outer X window of
-FRAME.  Default is to change on the edit X window.
-
-Value is VALUE.  */)
+FRAME.  Default is to change on the edit X window.  */)
   (Lisp_Object prop, Lisp_Object value, Lisp_Object frame, Lisp_Object type, Lisp_Object format, Lisp_Object outer_p)
 {
 #if 0 /* TODO : port window properties to W32 */
@@ -5060,9 +5067,20 @@
 DEFUN ("x-window-property", Fx_window_property, Sx_window_property,
        1, 2, 0,
        doc: /* Value is the value of window property PROP on FRAME.
-If FRAME is nil or omitted, use the selected frame.  Value is nil
-if FRAME hasn't a property with name PROP or if PROP has no string
-value.  */)
+If FRAME is nil or omitted, use the selected frame.
+
+On MS Windows, this function only accepts the PROP and FRAME arguments.
+
+On X Windows, the following optional arguments are also accepted:
+If TYPE is nil or omitted, get the property as a string.
+Otherwise TYPE is the name of the atom that denotes the type expected.
+If SOURCE is non-nil, get the property on that window instead of from
+FRAME.  The number 0 denotes the root window.
+If DELETE_P is non-nil, delete the property after retreiving it.
+If VECTOR_RET_P is non-nil, don't return a string but a vector of values.
+
+Value is nil if FRAME hasn't a property with name PROP or if PROP has
+no value of TYPE (always string in the MS Windows case).  */)
   (Lisp_Object prop, Lisp_Object frame)
 {
 #if 0 /* TODO : port window properties to W32 */
@@ -5903,7 +5921,7 @@
    read-only when "Directories" is selected in the filter.  This
    allows us to work around the fact that the standard Open File
    dialog does not support directories.  */
-UINT CALLBACK
+static UINT CALLBACK
 file_dialog_callback (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
 {
   if (msg == WM_NOTIFY)
@@ -5951,10 +5969,13 @@
 
 DEFUN ("x-file-dialog", Fx_file_dialog, Sx_file_dialog, 2, 5, 0,
        doc: /* Read file name, prompting with PROMPT in directory DIR.
-Use a file selection dialog.
-Select DEFAULT-FILENAME in the dialog's file selection box, if
-specified.  Ensure that file exists if MUSTMATCH is non-nil.
-If ONLY-DIR-P is non-nil, the user can only select directories.  */)
+Use a file selection dialog.  Select DEFAULT-FILENAME in the dialog's file
+selection box, if specified.  If MUSTMATCH is non-nil, the returned file
+or directory must exist.
+
+This function is only defined on MS Windows, and X Windows with the
+Motif or Gtk toolkits.  With the Motif toolkit, ONLY-DIR-P is ignored.
+Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories.  */)
   (Lisp_Object prompt, Lisp_Object dir, Lisp_Object default_filename, Lisp_Object mustmatch, Lisp_Object only_dir_p)
 {
   struct frame *f = SELECTED_FRAME ();
--- a/src/w32font.c	Thu Oct 14 16:21:40 2010 +0900
+++ b/src/w32font.c	Thu Oct 28 19:57:59 2010 +0900
@@ -333,7 +333,7 @@
 }
 
 /* w32 implementation of encode_char for font backend.
-   Return a glyph code of FONT for characer C (Unicode code point).
+   Return a glyph code of FONT for character C (Unicode code point).
    If FONT doesn't have such a glyph, return FONT_INVALID_CODE.
 
    For speed, the gdi backend uses unicode (Emacs calls encode_char
@@ -1058,7 +1058,7 @@
 
 
 /* Convert generic families to the family portion of lfPitchAndFamily.  */
-BYTE
+static BYTE
 w32_generic_family (Lisp_Object name)
 {
   /* Generic families.  */
@@ -1798,7 +1798,7 @@
   if (fnweight >= FW_NORMAL)     return 100;
   if (fnweight >= FW_LIGHT)      return 50;
   if (fnweight >= FW_EXTRALIGHT) return 40;
-  if (fnweight > FW_THIN)        return 20;
+  if (fnweight >  FW_THIN)       return 20;
   return 0;
 }
 
@@ -1812,7 +1812,7 @@
   if (n >= 100) return FW_NORMAL;
   if (n >= 50)  return FW_LIGHT;
   if (n >= 40)  return FW_EXTRALIGHT;
-  if (n >= 20)  return  FW_THIN;
+  if (n >= 20)  return FW_THIN;
   return 0;
 }
 
@@ -1822,9 +1822,9 @@
 w32_to_fc_weight (int n)
 {
   if (n >= FW_EXTRABOLD) return intern ("black");
-  if (n >= FW_BOLD) return intern ("bold");
-  if (n >= FW_SEMIBOLD) return intern ("demibold");
-  if (n >= FW_NORMAL) return intern ("medium");
+  if (n >= FW_BOLD)      return intern ("bold");
+  if (n >= FW_SEMIBOLD)  return intern ("demibold");
+  if (n >= FW_NORMAL)    return intern ("medium");
   return intern ("light");
 }
 
@@ -1912,7 +1912,6 @@
         logfont->lfPitchAndFamily = family | DEFAULT_PITCH;
     }
 
-
   /* Set pitch based on the spacing property.  */
   tmp = AREF (font_spec, FONT_SPACING_INDEX);
   if (INTEGERP (tmp))
@@ -2378,6 +2377,23 @@
   return DECODE_SYSTEM (build_string (buf));
 }
 
+static const char *w32font_booleans [] = {
+  NULL,
+};
+
+static const char *w32font_non_booleans [] = {
+  ":script",
+  ":antialias",
+  ":style",
+  NULL,
+};
+
+static void
+w32font_filter_properties (Lisp_Object font, Lisp_Object alist)
+{
+  font_filter_properties (font, alist, w32font_booleans, w32font_non_booleans);
+}
+
 struct font_driver w32font_driver =
   {
     0, /* Qgdi */
@@ -2407,7 +2423,7 @@
     NULL, /* shape */
     NULL, /* check */
     NULL, /* get_variation_glyphs */
-    NULL, /* filter_properties */
+    w32font_filter_properties,
   };
 
 
--- a/src/w32heap.c	Thu Oct 14 16:21:40 2010 +0900
+++ b/src/w32heap.c	Thu Oct 28 19:57:59 2010 +0900
@@ -278,7 +278,7 @@
     sbrk (need_to_alloc);
 }
 
-#if (_MSC_VER >= 1000 && _MSC_VER < 1300 && !defined(USE_CRT_DLL))
+#if (_MSC_VER >= 1000 && _MSC_VER < 1300 && !defined (USE_CRT_DLL))
 
 /* MSVC 4.2 invokes these functions from mainCRTStartup to initialize
    a heap via HeapCreate.  They are normally defined by the runtime,
--- a/src/w32inevt.c	Thu Oct 14 16:21:40 2010 +0900
+++ b/src/w32inevt.c	Thu Oct 28 19:57:59 2010 +0900
@@ -288,7 +288,7 @@
 
 /* return code -1 means that event_queue_ptr won't be incremented.
    In other word, this event makes two key codes.   (by himi)       */
-int
+static int
 key_event (KEY_EVENT_RECORD *event, struct input_event *emacs_ev, int *isdead)
 {
   static int mod_key_state = 0;
--- a/src/w32menu.c	Thu Oct 14 16:21:40 2010 +0900
+++ b/src/w32menu.c	Thu Oct 28 19:57:59 2010 +0900
@@ -106,6 +106,7 @@
 #endif
 
 static void utf8to16 (unsigned char *, int, WCHAR *);
+static int fill_in_menu (HMENU, widget_value *);
 
 void w32_free_menu_strings (HWND);
 
@@ -996,7 +997,7 @@
 		 Lisp_Object title, Lisp_Object header,
 		 char **error)
 {
-  int i, nb_buttons=0;
+  int i, nb_buttons = 0;
   char dialog_name[6];
   int menu_item_selection;
 
@@ -1568,7 +1569,7 @@
 }
 
 /* Construct native Windows menu(bar) based on widget_value tree.  */
-int
+static int
 fill_in_menu (HMENU menu, widget_value *wv)
 {
   int items_added = 0;
@@ -1739,7 +1740,7 @@
 void
 globals_of_w32menu (void)
 {
-	/* See if Get/SetMenuItemInfo functions are available.  */
+  /* See if Get/SetMenuItemInfo functions are available.  */
   HMODULE user32 = GetModuleHandle ("user32.dll");
   get_menu_item_info = (GetMenuItemInfoA_Proc) GetProcAddress (user32, "GetMenuItemInfoA");
   set_menu_item_info = (SetMenuItemInfoA_Proc) GetProcAddress (user32, "SetMenuItemInfoA");
--- a/src/w32proc.c	Thu Oct 14 16:21:40 2010 +0900
+++ b/src/w32proc.c	Thu Oct 28 19:57:59 2010 +0900
@@ -159,7 +159,7 @@
 child_process child_procs[ MAX_CHILDREN ];
 child_process *dead_child = NULL;
 
-DWORD WINAPI reader_thread (void *arg);
+static DWORD WINAPI reader_thread (void *arg);
 
 /* Find an unused process slot.  */
 child_process *
@@ -168,7 +168,7 @@
   child_process *cp;
   DWORD id;
 
-  for (cp = child_procs+(child_proc_count-1); cp >= child_procs; cp--)
+  for (cp = child_procs + (child_proc_count-1); cp >= child_procs; cp--)
     if (!CHILD_ACTIVE (cp))
       goto Initialise;
   if (child_proc_count == MAX_CHILDREN)
@@ -268,7 +268,7 @@
 {
   child_process *cp;
 
-  for (cp = child_procs+(child_proc_count-1); cp >= child_procs; cp--)
+  for (cp = child_procs + (child_proc_count-1); cp >= child_procs; cp--)
     if (CHILD_ACTIVE (cp) && pid == cp->pid)
       return cp;
   return NULL;
@@ -279,7 +279,7 @@
    is normally blocked until woken by select() to check for input by
    reading one char.  When the read completes, char_avail is signaled
    to wake up the select emulator and the thread blocks itself again. */
-DWORD WINAPI
+static DWORD WINAPI
 reader_thread (void *arg)
 {
   child_process *cp;
@@ -495,7 +495,7 @@
     }
   else
     {
-      for (cp = child_procs+(child_proc_count-1); cp >= child_procs; cp--)
+      for (cp = child_procs + (child_proc_count-1); cp >= child_procs; cp--)
 	/* some child_procs might be sockets; ignore them */
 	if (CHILD_ACTIVE (cp) && cp->procinfo.hProcess
 	    && (cp->fd < 0 || (fd_info[cp->fd].flags & FILE_AT_EOF) != 0))
@@ -608,7 +608,7 @@
 # define IMAGE_OPTIONAL_HEADER32 IMAGE_OPTIONAL_HEADER
 #endif
 
-void
+static void
 w32_executable_type (char * filename,
 		     int * is_dos_app,
 		     int * is_cygnus_app,
@@ -726,7 +726,7 @@
   close_file_data (&executable);
 }
 
-int
+static int
 compare_env (const void *strp1, const void *strp2)
 {
   const char *str1 = *(const char **)strp1, *str2 = *(const char **)strp2;
@@ -750,7 +750,7 @@
     return 1;
 }
 
-void
+static void
 merge_and_sort_env (char **envp1, char **envp2, char **new_envp)
 {
   char **optr, **nptr;
@@ -895,7 +895,7 @@
 	escape_char = is_cygnus_app ? '"' : '\\';
     }
 
-  /* Cygwin apps needs quoting a bit more often */
+  /* Cygwin apps needs quoting a bit more often.  */
   if (escape_char == '"')
     sepchars = "\r\n\t\f '";
 
@@ -1245,7 +1245,7 @@
 count_children:
   /* Add handles of child processes.  */
   nc = 0;
-  for (cp = child_procs+(child_proc_count-1); cp >= child_procs; cp--)
+  for (cp = child_procs + (child_proc_count-1); cp >= child_procs; cp--)
     /* Some child_procs might be sockets; ignore them.  Also some
        children may have died already, but we haven't finished reading
        the process output; ignore them too.  */
@@ -1999,7 +1999,7 @@
   return make_number (GetThreadLocale ());
 }
 
-DWORD
+static DWORD
 int_from_hex (char * s)
 {
   DWORD val = 0;
@@ -2021,7 +2021,7 @@
    function isn't given a context pointer.  */
 Lisp_Object Vw32_valid_locale_ids;
 
-BOOL CALLBACK
+static BOOL CALLBACK
 enum_locale_fn (LPTSTR localeNum)
 {
   DWORD id = int_from_hex (localeNum);
@@ -2085,7 +2085,7 @@
    function isn't given a context pointer.  */
 Lisp_Object Vw32_valid_codepages;
 
-BOOL CALLBACK
+static BOOL CALLBACK
 enum_codepage_fn (LPTSTR codepageNum)
 {
   DWORD id = atoi (codepageNum);
--- a/src/w32select.c	Thu Oct 14 16:21:40 2010 +0900
+++ b/src/w32select.c	Thu Oct 28 19:57:59 2010 +0900
@@ -1,6 +1,7 @@
 /* Selection processing for Emacs on the Microsoft W32 API.
-   Copyright (C) 1993, 1994, 2001, 2002, 2003, 2004,
-                 2005, 2006, 2007, 2008, 2009, 2010  Free Software Foundation, Inc.
+
+Copyright (C) 1993, 1994, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
+  2008, 2009, 2010  Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -1069,10 +1070,34 @@
 
   DEFVAR_LISP ("selection-coding-system", &Vselection_coding_system,
 	       doc: /* Coding system for communicating with other programs.
-When sending or receiving text via cut_buffer, selection, and
-clipboard, the text is encoded or decoded by this coding system.
-The default value is the current system default encoding on 9x/Me and
-`utf-16le-dos' (Unicode) on NT/W2K/XP. */);
+
+For MS-Windows and MS-DOS:
+When sending or receiving text via selection and clipboard, the text
+is encoded or decoded by this coding system.  The default value is
+the current system default encoding on 9x/Me, `utf-16le-dos'
+\(Unicode) on NT/W2K/XP, and `iso-latin-1-dos' on MS-DOS.
+
+For X Windows:
+When sending text via selection and clipboard, if the target
+data-type matches with the type of this coding system, it is used
+for encoding the text.  Otherwise (including the case that this
+variable is nil), a proper coding system is used as below:
+
+data-type	coding system
+---------	-------------
+UTF8_STRING	utf-8
+COMPOUND_TEXT	compound-text-with-extensions
+STRING		iso-latin-1
+C_STRING	no-conversion
+
+When receiving text, if this coding system is non-nil, it is used
+for decoding regardless of the data-type.  If this is nil, a
+proper coding system is used according to the data-type as above.
+
+See also the documentation of the variable `x-select-request-type' how
+to control which data-type to request for receiving text.
+
+The default value is nil.  */);
   /* The actual value is set dynamically in the dumped Emacs, see
      below. */
   Vselection_coding_system = Qnil;
@@ -1080,9 +1105,9 @@
   DEFVAR_LISP ("next-selection-coding-system", &Vnext_selection_coding_system,
 	       doc: /* Coding system for the next communication with other programs.
 Usually, `selection-coding-system' is used for communicating with
-other programs.  But, if this variable is set, it is used for the
-next communication only.  After the communication, this variable is
-set to nil.  */);
+other programs (X Windows clients or MS Windows programs).  But, if this
+variable is set, it is used for the next communication only.
+After the communication, this variable is set to nil.  */);
   Vnext_selection_coding_system = Qnil;
 
   DEFSYM (QCLIPBOARD, "CLIPBOARD");
@@ -1123,5 +1148,3 @@
   clipboard_owner = create_owner ();
 }
 
-/* arch-tag: c96e9724-5eb1-4dad-be07-289f092fd2af
-   (do not change this comment) */
--- a/src/w32term.c	Thu Oct 14 16:21:40 2010 +0900
+++ b/src/w32term.c	Thu Oct 28 19:57:59 2010 +0900
@@ -1,7 +1,8 @@
 /* Implementation of GUI terminal on the Microsoft W32 API.
-   Copyright (C) 1989, 1993, 1994, 1995, 1996, 1997, 1998,
-                 1999, 2000, 2001, 2002, 2003, 2004, 2005,
-                 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+
+Copyright (C) 1989, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
+  2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+  Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -893,7 +894,7 @@
 {
 }
 
-/* This is called when exiting or suspending Emacs. Exiting will make
+/* This is called when exiting or suspending Emacs.  Exiting will make
    the W32 windows go away, and suspending requires no action. */
 
 static void
@@ -3954,7 +3955,7 @@
    recursively with different messages by the system.
 */
 
-int
+static int
 w32_read_socket (struct terminal *terminal, int expected,
 		 struct input_event *hold_quit)
 {
@@ -4239,7 +4240,7 @@
 		      inev.frame_or_window = window;
 		    }
 
-		  last_window=window;
+		  last_window = window;
 		}
 	      if (!note_mouse_movement (f, &msg.msg))
 		help_echo_string = previous_help_echo_string;
@@ -5601,7 +5602,7 @@
 	  /* Adjust vertical window position in order to avoid being
 	     covered by a task bar placed at the bottom of the desktop. */
 	  SystemParametersInfo (SPI_GETWORKAREA, 0, &workarea_rect, 0);
-	  GetWindowRect (FRAME_W32_WINDOW(f), &window_rect);
+	  GetWindowRect (FRAME_W32_WINDOW (f), &window_rect);
 	  if (window_rect.bottom > workarea_rect.bottom
 	      && window_rect.top > workarea_rect.top)
 	    f->top_pos = max (window_rect.top
@@ -6336,7 +6337,9 @@
      doc: /* *Non-nil means make use of UNDERLINE_POSITION font properties.
 A value of nil means ignore them.  If you encounter fonts with bogus
 UNDERLINE_POSITION font properties, for example 7x13 on XFree prior
-to 4.1, set this to nil.  */);
+to 4.1, set this to nil.  You can also use `underline-minimum-offset'
+to override the font's UNDERLINE_POSITION for small font display
+sizes.  */);
   x_use_underline_position_properties = 0;
 
   DEFVAR_BOOL ("x-underline-at-descent-line",
@@ -6348,12 +6351,14 @@
   x_underline_at_descent_line = 0;
 
   DEFVAR_LISP ("x-toolkit-scroll-bars", &Vx_toolkit_scroll_bars,
-	       doc: /* If not nil, Emacs uses toolkit scroll bars.  */);
+	       doc: /* Which toolkit scroll bars Emacs uses, if any.
+A value of nil means Emacs doesn't use toolkit scroll bars.
+With the X Window system, the value is a symbol describing the
+X toolkit.  Possible values are: gtk, motif, xaw, or xaw3d.
+With MS Windows, the value is t.  */);
   Vx_toolkit_scroll_bars = Qt;
 
   staticpro (&last_mouse_motion_frame);
   last_mouse_motion_frame = Qnil;
 }
 
-/* arch-tag: 5fa70624-ab86-499c-8a85-473958ee4646
-   (do not change this comment) */
--- a/src/w32uniscribe.c	Thu Oct 14 16:21:40 2010 +0900
+++ b/src/w32uniscribe.c	Thu Oct 28 19:57:59 2010 +0900
@@ -439,7 +439,7 @@
 }
 
 /* Uniscribe implementation of encode_char for font backend.
-   Return a glyph code of FONT for characer C (Unicode code point).
+   Return a glyph code of FONT for character C (Unicode code point).
    If FONT doesn't have such a glyph, return FONT_INVALID_CODE.  */
 static unsigned
 uniscribe_encode_char (struct font *font, int c)
--- a/src/w32xfns.c	Thu Oct 14 16:21:40 2010 +0900
+++ b/src/w32xfns.c	Thu Oct 28 19:57:59 2010 +0900
@@ -408,7 +408,6 @@
 		return (0);
 	      strind = nextCharacter;
 	      mask |= YNegative;
-
 	    }
 	  else
 	    {
@@ -422,7 +421,7 @@
 	}
     }
 
-  /* If strind isn't at the end of the string the it's an invalid
+  /* If strind isn't at the end of the string then it's an invalid
      geometry specification. */
 
   if (*strind != '\0') return (0);
--- a/src/xdisp.c	Thu Oct 14 16:21:40 2010 +0900
+++ b/src/xdisp.c	Thu Oct 28 19:57:59 2010 +0900
@@ -1,8 +1,8 @@
 /* Display generation from window structure and buffer text.
-   Copyright (C) 1985, 1986, 1987, 1988, 1993, 1994, 1995,
-                 1997, 1998, 1999, 2000, 2001, 2002, 2003,
-                 2004, 2005, 2006, 2007, 2008, 2009, 2010
-                 Free Software Foundation, Inc.
+
+Copyright (C) 1985, 1986, 1987, 1988, 1993, 1994, 1995, 1997, 1998,
+  1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
+  2010  Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -1085,6 +1085,7 @@
                                        int, int, int, int);
 static void append_stretch_glyph (struct it *, Lisp_Object,
                                   int, int, int);
+static int coords_in_mouse_face_p (struct window *, int, int);
 
 
 
@@ -15333,10 +15334,12 @@
 	{
 	  struct glyph *g;
 
-	  if (NILP (XBUFFER (w->buffer)->bidi_display_reordering))
+	  if (NILP (XBUFFER (w->buffer)->bidi_display_reordering)
+	      || (!best_row && !row->continued_p))
 	    return row;
 	  /* In bidi-reordered rows, there could be several rows
-	     occluding point.  We need to find the one which fits
+	     occluding point, all of them belonging to the same
+	     continued line.  We need to find the row which fits
 	     CHARPOS the best.  */
 	  for (g = row->glyphs[TEXT_AREA];
 	       g < row->glyphs[TEXT_AREA] + row->used[TEXT_AREA];
@@ -15348,11 +15351,14 @@
 		    {
 		      mindif = eabs (g->charpos - charpos);
 		      best_row = row;
-		    }
-		}
-	    }
-	}
-      else if (best_row)
+		      /* Exact match always wins.  */
+		      if (mindif == 0)
+			return best_row;
+		    }
+		}
+	    }
+	}
+      else if (best_row && !row->continued_p)
 	return best_row;
       ++row;
     }
@@ -23411,13 +23417,7 @@
   /* If the cursor is in the mouse face area, redisplay that when
      we clear the cursor.  */
   if (! NILP (dpyinfo->mouse_face_window)
-      && w == XWINDOW (dpyinfo->mouse_face_window)
-      && (vpos > dpyinfo->mouse_face_beg_row
-	  || (vpos == dpyinfo->mouse_face_beg_row
-	      && hpos >= dpyinfo->mouse_face_beg_col))
-      && (vpos < dpyinfo->mouse_face_end_row
-	  || (vpos == dpyinfo->mouse_face_end_row
-	      && hpos < dpyinfo->mouse_face_end_col))
+      && coords_in_mouse_face_p (w, hpos, vpos)
       /* Don't redraw the cursor's spot in mouse face if it is at the
 	 end of a line (on a newline).  The cursor appears there, but
 	 mouse highlighting does not.  */
@@ -23640,8 +23640,30 @@
 	  /* For all but the first row, the highlight starts at column 0.  */
 	  if (row == first)
 	    {
-	      start_hpos = dpyinfo->mouse_face_beg_col;
-	      start_x = dpyinfo->mouse_face_beg_x;
+	      /* R2L rows have BEG and END in reversed order, but the
+		 screen drawing geometry is always left to right.  So
+		 we need to mirror the beginning and end of the
+		 highlighted area in R2L rows.  */
+	      if (!row->reversed_p)
+		{
+		  start_hpos = dpyinfo->mouse_face_beg_col;
+		  start_x = dpyinfo->mouse_face_beg_x;
+		}
+	      else if (row == last)
+		{
+		  start_hpos = dpyinfo->mouse_face_end_col;
+		  start_x = dpyinfo->mouse_face_end_x;
+		}
+	      else
+		{
+		  start_hpos = 0;
+		  start_x = 0;
+		}
+	    }
+	  else if (row->reversed_p && row == last)
+	    {
+	      start_hpos = dpyinfo->mouse_face_end_col;
+	      start_x = dpyinfo->mouse_face_end_x;
 	    }
 	  else
 	    {
@@ -23650,7 +23672,20 @@
 	    }
 
 	  if (row == last)
-	    end_hpos = dpyinfo->mouse_face_end_col;
+	    {
+	      if (!row->reversed_p)
+		end_hpos = dpyinfo->mouse_face_end_col;
+	      else if (row == first)
+		end_hpos = dpyinfo->mouse_face_beg_col;
+	      else
+		{
+		  end_hpos = row->used[TEXT_AREA];
+		  if (draw == DRAW_NORMAL_TEXT)
+		    row->fill_line_p = 1; /* Clear to end of line */
+		}
+	    }
+	  else if (row->reversed_p && row == first)
+	    end_hpos = dpyinfo->mouse_face_beg_col;
 	  else
 	    {
 	      end_hpos = row->used[TEXT_AREA];
@@ -23713,6 +23748,53 @@
   return cleared;
 }
 
+/* Return non-zero if the coordinates HPOS and VPOS on windows W are
+   within the mouse face on that window.  */
+static int
+coords_in_mouse_face_p (struct window *w, int hpos, int vpos)
+{
+  Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (XFRAME (w->frame));
+
+  /* Quickly resolve the easy cases.  */
+  if (!(WINDOWP (dpyinfo->mouse_face_window)
+	&& XWINDOW (dpyinfo->mouse_face_window) == w))
+    return 0;
+  if (vpos < dpyinfo->mouse_face_beg_row
+      || vpos > dpyinfo->mouse_face_end_row)
+    return 0;
+  if (vpos > dpyinfo->mouse_face_beg_row
+      && vpos < dpyinfo->mouse_face_end_row)
+    return 1;
+
+  if (!MATRIX_ROW (w->current_matrix, vpos)->reversed_p)
+    {
+      if (dpyinfo->mouse_face_beg_row == dpyinfo->mouse_face_end_row)
+	{
+	  if (dpyinfo->mouse_face_beg_col <= hpos && hpos < dpyinfo->mouse_face_end_col)
+	    return 1;
+	}
+      else if ((vpos == dpyinfo->mouse_face_beg_row
+		&& hpos >= dpyinfo->mouse_face_beg_col)
+	       || (vpos == dpyinfo->mouse_face_end_row
+		   && hpos < dpyinfo->mouse_face_end_col))
+	return 1;
+    }
+  else
+    {
+       if (dpyinfo->mouse_face_beg_row == dpyinfo->mouse_face_end_row)
+	{
+	  if (dpyinfo->mouse_face_end_col < hpos && hpos <= dpyinfo->mouse_face_beg_col)
+	    return 1;
+	}
+      else if ((vpos == dpyinfo->mouse_face_beg_row
+		&& hpos <= dpyinfo->mouse_face_beg_col)
+	       || (vpos == dpyinfo->mouse_face_end_row
+		   && hpos > dpyinfo->mouse_face_end_col))
+	return 1;
+    }
+  return 0;
+}
+
 
 /* EXPORT:
    Non-zero if physical cursor of window W is within mouse face.  */
@@ -23720,31 +23802,134 @@
 int
 cursor_in_mouse_face_p (struct window *w)
 {
-  Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (XFRAME (w->frame));
-  int in_mouse_face = 0;
-
-  if (WINDOWP (dpyinfo->mouse_face_window)
-      && XWINDOW (dpyinfo->mouse_face_window) == w)
-    {
-      int hpos = w->phys_cursor.hpos;
-      int vpos = w->phys_cursor.vpos;
-
-      if (vpos >= dpyinfo->mouse_face_beg_row
-	  && vpos <= dpyinfo->mouse_face_end_row
-	  && (vpos > dpyinfo->mouse_face_beg_row
-	      || hpos >= dpyinfo->mouse_face_beg_col)
-	  && (vpos < dpyinfo->mouse_face_end_row
-	      || hpos < dpyinfo->mouse_face_end_col
-	      || dpyinfo->mouse_face_past_end))
-	in_mouse_face = 1;
-    }
-
-  return in_mouse_face;
-}
-
-
-
-
+  return coords_in_mouse_face_p (w, w->phys_cursor.hpos, w->phys_cursor.vpos);
+}
+
+
+
+/* Find the glyph rows START_ROW and END_ROW of window W that display
+   characters between buffer positions START_CHARPOS and END_CHARPOS
+   (excluding END_CHARPOS).  This is similar to row_containing_pos,
+   but is more accurate when bidi reordering makes buffer positions
+   change non-linearly with glyph rows.  */
+static void
+rows_from_pos_range (struct window *w,
+		     EMACS_INT start_charpos, EMACS_INT end_charpos,
+		     struct glyph_row **start, struct glyph_row **end)
+{
+  struct glyph_row *first = MATRIX_FIRST_TEXT_ROW (w->current_matrix);
+  int last_y = window_text_bottom_y (w);
+  struct glyph_row *row;
+
+  *start = NULL;
+  *end = NULL;
+
+  while (!first->enabled_p
+	 && first < MATRIX_BOTTOM_TEXT_ROW (w->current_matrix, w))
+    first++;
+
+  /* Find the START row.  */
+  for (row = first;
+       row->enabled_p && MATRIX_ROW_BOTTOM_Y (row) <= last_y;
+       row++)
+    {
+      /* A row can potentially be the START row if the range of the
+	 characters it displays intersects the range
+	 [START_CHARPOS..END_CHARPOS).  */
+      if (! ((start_charpos < MATRIX_ROW_START_CHARPOS (row)
+	      && end_charpos < MATRIX_ROW_START_CHARPOS (row))
+	     /* See the commentary in row_containing_pos, for the
+		explanation of the complicated way to check whether
+		some position is beyond the end of the characters
+		displayed by a row.  */
+	     || ((start_charpos > MATRIX_ROW_END_CHARPOS (row)
+		  || (start_charpos == MATRIX_ROW_END_CHARPOS (row)
+		      && !row->ends_at_zv_p
+		      && !MATRIX_ROW_ENDS_IN_MIDDLE_OF_CHAR_P (row)))
+		 && (end_charpos > MATRIX_ROW_END_CHARPOS (row)
+		     || (end_charpos == MATRIX_ROW_END_CHARPOS (row)
+			 && !row->ends_at_zv_p
+			 && !MATRIX_ROW_ENDS_IN_MIDDLE_OF_CHAR_P (row))))))
+	{
+	  /* Found a candidate row.  Now make sure at least one of the
+	     glyphs it displays has a charpos from the range
+	     [START_CHARPOS..END_CHARPOS).
+
+	     This is not obvious because bidi reordering could make
+	     buffer positions of a row be 1,2,3,102,101,100, and if we
+	     want to highlight characters in [50..60), we don't want
+	     this row, even though [50..60) does intersect [1..103),
+	     the range of character positions given by the row's start
+	     and end positions.  */
+	  struct glyph *g = row->glyphs[TEXT_AREA];
+	  struct glyph *e = g + row->used[TEXT_AREA];
+
+	  while (g < e)
+	    {
+	      if (BUFFERP (g->object)
+		  && start_charpos <= g->charpos && g->charpos < end_charpos)
+		*start = row;
+	      g++;
+	    }
+	  if (*start)
+	    break;
+	}
+    }
+
+  /* Find the END row.  */
+  if (!*start
+      /* If the last row is partially visible, start looking for END
+	 from that row, instead of starting from FIRST.  */
+      && !(row->enabled_p
+	   && row->y < last_y && MATRIX_ROW_BOTTOM_Y (row) > last_y))
+    row = first;
+  for ( ; row->enabled_p && MATRIX_ROW_BOTTOM_Y (row) <= last_y; row++)
+    {
+      struct glyph_row *next = row + 1;
+
+      if (!next->enabled_p
+	  || next >= MATRIX_BOTTOM_TEXT_ROW (w->current_matrix, w)
+	  /* The first row >= START whose range of displayed characters
+	     does NOT intersect the range [START_CHARPOS..END_CHARPOS]
+	     is the row END + 1.  */
+	  || (start_charpos < MATRIX_ROW_START_CHARPOS (next)
+	      && end_charpos < MATRIX_ROW_START_CHARPOS (next))
+	  || ((start_charpos > MATRIX_ROW_END_CHARPOS (next)
+	       || (start_charpos == MATRIX_ROW_END_CHARPOS (next)
+		   && !next->ends_at_zv_p
+		   && !MATRIX_ROW_ENDS_IN_MIDDLE_OF_CHAR_P (next)))
+	      && (end_charpos > MATRIX_ROW_END_CHARPOS (next)
+		  || (end_charpos == MATRIX_ROW_END_CHARPOS (next)
+		      && !next->ends_at_zv_p
+		      && !MATRIX_ROW_ENDS_IN_MIDDLE_OF_CHAR_P (next)))))
+	{
+	  *end = row;
+	  break;
+	}
+      else
+	{
+	  /* If the next row's edges intersect [START_CHARPOS..END_CHARPOS],
+	     but none of the characters it displays are in the range, it is
+	     also END + 1. */
+	  struct glyph *g = next->glyphs[TEXT_AREA];
+	  struct glyph *e = g + next->used[TEXT_AREA];
+
+	  while (g < e)
+	    {
+	      if (BUFFERP (g->object)
+		  && start_charpos <= g->charpos && g->charpos < end_charpos)
+		break;
+	      g++;
+	    }
+	  if (g == e)
+	    {
+	      *end = row;
+	      break;
+	    }
+	}
+    }
+}
+
 /* This function sets the mouse_face_* elements of DPYINFO, assuming
    the mouse cursor is on a glyph with buffer charpos MOUSE_CHARPOS in
    window WINDOW.  START_CHARPOS and END_CHARPOS are buffer positions
@@ -23766,83 +23951,41 @@
 {
   struct window *w = XWINDOW (window);
   struct glyph_row *first = MATRIX_FIRST_TEXT_ROW (w->current_matrix);
-  struct glyph_row *row;
+  struct glyph_row *r1, *r2;
   struct glyph *glyph, *end;
-  EMACS_INT ignore;
+  EMACS_INT ignore, pos;
   int x;
 
   xassert (NILP (display_string) || STRINGP (display_string));
   xassert (NILP (before_string) || STRINGP (before_string));
   xassert (NILP (after_string) || STRINGP (after_string));
 
-  /* Find the first highlighted glyph.  */
-  if (start_charpos < MATRIX_ROW_START_CHARPOS (first))
-    {
-      dpyinfo->mouse_face_beg_col = 0;
-      dpyinfo->mouse_face_beg_row = MATRIX_ROW_VPOS (first, w->current_matrix);
-      dpyinfo->mouse_face_beg_x = first->x;
-      dpyinfo->mouse_face_beg_y = first->y;
-    }
-  else
-    {
-      row = row_containing_pos (w, start_charpos, first, NULL, 0);
-      if (row == NULL)
-	row = MATRIX_ROW (w->current_matrix, XFASTINT (w->window_end_vpos));
-
-      /* If the before-string or display-string contains newlines,
-	 row_containing_pos skips to its last row.  Move back.  */
-      if (!NILP (before_string) || !NILP (display_string))
-	{
-	  struct glyph_row *prev;
-	  while ((prev = row - 1, prev >= first)
-		 && MATRIX_ROW_END_CHARPOS (prev) == start_charpos
-		 && prev->used[TEXT_AREA] > 0)
-	    {
-	      struct glyph *beg = prev->glyphs[TEXT_AREA];
-	      glyph = beg + prev->used[TEXT_AREA];
-	      while (--glyph >= beg && INTEGERP (glyph->object));
-	      if (glyph < beg
-		  || !(EQ (glyph->object, before_string)
-		       || EQ (glyph->object, display_string)))
-		break;
-	      row = prev;
-	    }
-	}
-
-      glyph = row->glyphs[TEXT_AREA];
-      end = glyph + row->used[TEXT_AREA];
-      x = row->x;
-      dpyinfo->mouse_face_beg_y = row->y;
-      dpyinfo->mouse_face_beg_row = MATRIX_ROW_VPOS (row, w->current_matrix);
-
-      /* Skip truncation glyphs at the start of the glyph row.  */
-      if (row->displays_text_p)
-	for (; glyph < end
-	       && INTEGERP (glyph->object)
-	       && glyph->charpos < 0;
-	     ++glyph)
-	  x += glyph->pixel_width;
-
-      /* Scan the glyph row, stopping before BEFORE_STRING or
-	 DISPLAY_STRING or START_CHARPOS.  */
-      for (; glyph < end
-	     && !INTEGERP (glyph->object)
-	     && !EQ (glyph->object, before_string)
-	     && !EQ (glyph->object, display_string)
-	     && !(BUFFERP (glyph->object)
-		  && glyph->charpos >= start_charpos);
-	   ++glyph)
-	x += glyph->pixel_width;
-
-      dpyinfo->mouse_face_beg_x = x;
-      dpyinfo->mouse_face_beg_col = glyph - row->glyphs[TEXT_AREA];
-    }
-
-  /* Find the last highlighted glyph.  */
-  row = row_containing_pos (w, end_charpos, first, NULL, 0);
-  if (row == NULL)
-    {
-      row = MATRIX_ROW (w->current_matrix, XFASTINT (w->window_end_vpos));
+  /* Find the rows corresponding to START_CHARPOS and END_CHARPOS.  */
+  rows_from_pos_range (w, start_charpos, end_charpos, &r1, &r2);
+  if (r1 == NULL)
+    r1 = MATRIX_ROW (w->current_matrix, XFASTINT (w->window_end_vpos));
+  /* If the before-string or display-string contains newlines,
+     rows_from_pos_range skips to its last row.  Move back.  */
+  if (!NILP (before_string) || !NILP (display_string))
+    {
+      struct glyph_row *prev;
+      while ((prev = r1 - 1, prev >= first)
+	     && MATRIX_ROW_END_CHARPOS (prev) == start_charpos
+	     && prev->used[TEXT_AREA] > 0)
+	{
+	  struct glyph *beg = prev->glyphs[TEXT_AREA];
+	  glyph = beg + prev->used[TEXT_AREA];
+	  while (--glyph >= beg && INTEGERP (glyph->object));
+	  if (glyph < beg
+	      || !(EQ (glyph->object, before_string)
+		   || EQ (glyph->object, display_string)))
+	    break;
+	  r1 = prev;
+	}
+    }
+  if (r2 == NULL)
+    {
+      r2 = MATRIX_ROW (w->current_matrix, XFASTINT (w->window_end_vpos));
       dpyinfo->mouse_face_past_end = 1;
     }
   else if (!NILP (after_string))
@@ -23852,72 +23995,256 @@
       struct glyph_row *last
 	= MATRIX_ROW (w->current_matrix, XFASTINT (w->window_end_vpos));
 
-      for (next = row + 1;
+      for (next = r2 + 1;
 	   next <= last
 	     && next->used[TEXT_AREA] > 0
 	     && EQ (next->glyphs[TEXT_AREA]->object, after_string);
 	   ++next)
-	row = next;
-    }
-
-  glyph = row->glyphs[TEXT_AREA];
-  end = glyph + row->used[TEXT_AREA];
-  x = row->x;
-  dpyinfo->mouse_face_end_y = row->y;
-  dpyinfo->mouse_face_end_row = MATRIX_ROW_VPOS (row, w->current_matrix);
-
-  /* Skip truncation glyphs at the start of the row.  */
-  if (row->displays_text_p)
-    for (; glyph < end
-	   && INTEGERP (glyph->object)
-	   && glyph->charpos < 0;
-	 ++glyph)
-      x += glyph->pixel_width;
-
-  /* Scan the glyph row, stopping at END_CHARPOS or when we encounter
-     AFTER_STRING.  */
-  for (; glyph < end
-	 && !INTEGERP (glyph->object)
-	 && !EQ (glyph->object, after_string)
-	 && !(BUFFERP (glyph->object) && glyph->charpos >= end_charpos);
-       ++glyph)
-    x += glyph->pixel_width;
-
-  /* If we found AFTER_STRING, consume it and stop.  */
-  if (EQ (glyph->object, after_string))
-    {
-      for (; EQ (glyph->object, after_string) && glyph < end; ++glyph)
+	r2 = next;
+    }
+  /* The rest of the display engine assumes that mouse_face_beg_row is
+     either above below mouse_face_end_row or identical to it.  But
+     with bidi-reordered continued lines, the row for START_CHARPOS
+     could be below the row for END_CHARPOS.  If so, swap the rows and
+     store them in correct order.  */
+  if (r1->y > r2->y)
+    {
+      struct glyph_row *tem = r2;
+
+      r2 = r1;
+      r1 = tem;
+    }
+
+  dpyinfo->mouse_face_beg_y = r1->y;
+  dpyinfo->mouse_face_beg_row = MATRIX_ROW_VPOS (r1, w->current_matrix);
+  dpyinfo->mouse_face_end_y = r2->y;
+  dpyinfo->mouse_face_end_row = MATRIX_ROW_VPOS (r2, w->current_matrix);
+
+  /* For a bidi-reordered row, the positions of BEFORE_STRING,
+     AFTER_STRING, DISPLAY_STRING, START_CHARPOS, and END_CHARPOS
+     could be anywhere in the row and in any order.  The strategy
+     below is to find the leftmost and the rightmost glyph that
+     belongs to either of these 3 strings, or whose position is
+     between START_CHARPOS and END_CHARPOS, and highlight all the
+     glyphs between those two.  This may cover more than just the text
+     between START_CHARPOS and END_CHARPOS if the range of characters
+     strides the bidi level boundary, e.g. if the beginning is in R2L
+     text while the end is in L2R text or vice versa.  */
+  if (!r1->reversed_p)
+    {
+      /* This row is in a left to right paragraph.  Scan it left to
+	 right.  */
+      glyph = r1->glyphs[TEXT_AREA];
+      end = glyph + r1->used[TEXT_AREA];
+      x = r1->x;
+
+      /* Skip truncation glyphs at the start of the glyph row.  */
+      if (r1->displays_text_p)
+	for (; glyph < end
+	       && INTEGERP (glyph->object)
+	       && glyph->charpos < 0;
+	     ++glyph)
+	  x += glyph->pixel_width;
+
+      /* Scan the glyph row, looking for BEFORE_STRING, AFTER_STRING,
+	 or DISPLAY_STRING, and the first glyph from buffer whose
+	 position is between START_CHARPOS and END_CHARPOS.  */
+      for (; glyph < end
+	     && !INTEGERP (glyph->object)
+	     && !EQ (glyph->object, display_string)
+	     && !(BUFFERP (glyph->object)
+		  && (glyph->charpos >= start_charpos
+		      && glyph->charpos < end_charpos));
+	   ++glyph)
+	{
+	  /* BEFORE_STRING or AFTER_STRING are only relevant if they
+	     are present at buffer positions between START_CHARPOS and
+	     END_CHARPOS, or if they come from an overlay.  */
+	  if (EQ (glyph->object, before_string))
+	    {
+	      pos = string_buffer_position (w, before_string,
+					    start_charpos);
+	      /* If pos == 0, it means before_string came from an
+		 overlay, not from a buffer position.  */
+	      if (!pos || pos >= start_charpos && pos < end_charpos)
+		break;
+	    }
+	  else if (EQ (glyph->object, after_string))
+	    {
+	      pos = string_buffer_position (w, after_string, end_charpos);
+	      if (!pos || pos >= start_charpos && pos < end_charpos)
+		break;
+	    }
+	  x += glyph->pixel_width;
+	}
+      dpyinfo->mouse_face_beg_x = x;
+      dpyinfo->mouse_face_beg_col = glyph - r1->glyphs[TEXT_AREA];
+    }
+  else
+    {
+      /* This row is in a right to left paragraph.  Scan it right to
+	 left.  */
+      struct glyph *g;
+
+      end = r1->glyphs[TEXT_AREA] - 1;
+      glyph = end + r1->used[TEXT_AREA];
+
+      /* Skip truncation glyphs at the start of the glyph row.  */
+      if (r1->displays_text_p)
+	for (; glyph > end
+	       && INTEGERP (glyph->object)
+	       && glyph->charpos < 0;
+	     --glyph)
+	  ;
+
+      /* Scan the glyph row, looking for BEFORE_STRING, AFTER_STRING,
+	 or DISPLAY_STRING, and the first glyph from buffer whose
+	 position is between START_CHARPOS and END_CHARPOS.  */
+      for (; glyph > end
+	     && !INTEGERP (glyph->object)
+	     && !EQ (glyph->object, display_string)
+	     && !(BUFFERP (glyph->object)
+		  && (glyph->charpos >= start_charpos
+		      && glyph->charpos < end_charpos));
+	   --glyph)
+	{
+	  /* BEFORE_STRING or AFTER_STRING are only relevant if they
+	     are present at buffer positions between START_CHARPOS and
+	     END_CHARPOS, or if they come from an overlay.  */
+	  if (EQ (glyph->object, before_string))
+	    {
+	      pos = string_buffer_position (w, before_string, start_charpos);
+	      /* If pos == 0, it means before_string came from an
+		 overlay, not from a buffer position.  */
+	      if (!pos || pos >= start_charpos && pos < end_charpos)
+		break;
+	    }
+	  else if (EQ (glyph->object, after_string))
+	    {
+	      pos = string_buffer_position (w, after_string, end_charpos);
+	      if (!pos || pos >= start_charpos && pos < end_charpos)
+		break;
+	    }
+	}
+
+      glyph++; /* first glyph to the right of the highlighted area */
+      for (g = r1->glyphs[TEXT_AREA], x = r1->x; g < glyph; g++)
+	x += g->pixel_width;
+      dpyinfo->mouse_face_beg_x = x;
+      dpyinfo->mouse_face_beg_col = glyph - r1->glyphs[TEXT_AREA];
+    }
+
+  /* If the highlight ends in a different row, compute GLYPH and END
+     for the end row.  Otherwise, reuse the values computed above for
+     the row where the highlight begins.  */
+  if (r2 != r1)
+    {
+      if (!r2->reversed_p)
+	{
+	  glyph = r2->glyphs[TEXT_AREA];
+	  end = glyph + r2->used[TEXT_AREA];
+	  x = r2->x;
+	}
+      else
+	{
+	  end = r2->glyphs[TEXT_AREA] - 1;
+	  glyph = end + r2->used[TEXT_AREA];
+	}
+    }
+
+  if (!r2->reversed_p)
+    {
+      /* Skip truncation and continuation glyphs near the end of the
+	 row, and also blanks and stretch glyphs inserted by
+	 extend_face_to_end_of_line.  */
+      while (end > glyph
+	     && INTEGERP ((end - 1)->object)
+	     && (end - 1)->charpos <= 0)
+	--end;
+      /* Scan the rest of the glyph row from the end, looking for the
+	 first glyph that comes from BEFORE_STRING, AFTER_STRING, or
+	 DISPLAY_STRING, or whose position is between START_CHARPOS
+	 and END_CHARPOS */
+      for (--end;
+	     end > glyph
+	     && !INTEGERP (end->object)
+	     && !EQ (end->object, display_string)
+	     && !(BUFFERP (end->object)
+		  && (end->charpos >= start_charpos
+		      && end->charpos < end_charpos));
+	   --end)
+	{
+	  /* BEFORE_STRING or AFTER_STRING are only relevant if they
+	     are present at buffer positions between START_CHARPOS and
+	     END_CHARPOS, or if they come from an overlay.  */
+	  if (EQ (end->object, before_string))
+	    {
+	      pos = string_buffer_position (w, before_string, start_charpos);
+	      if (!pos || pos >= start_charpos && pos < end_charpos)
+		break;
+	    }
+	  else if (EQ (end->object, after_string))
+	    {
+	      pos = string_buffer_position (w, after_string, end_charpos);
+	      if (!pos || pos >= start_charpos && pos < end_charpos)
+		break;
+	    }
+	}
+      /* Find the X coordinate of the last glyph to be highlighted.  */
+      for (; glyph <= end; ++glyph)
 	x += glyph->pixel_width;
-    }
-  else
-    {
-      /* If there's no after-string, we must check if we overshot,
-	 which might be the case if we stopped after a string glyph.
-	 That glyph may belong to a before-string or display-string
-	 associated with the end position, which must not be
-	 highlighted.  */
-      Lisp_Object prev_object;
-      EMACS_INT pos;
-
-      while (glyph > row->glyphs[TEXT_AREA])
-	{
-	  prev_object = (glyph - 1)->object;
-	  if (!STRINGP (prev_object) || EQ (prev_object, display_string))
-	    break;
-
-	  pos = string_buffer_position (w, prev_object, end_charpos);
-	  if (pos && pos < end_charpos)
-	    break;
-
-	  for (; glyph > row->glyphs[TEXT_AREA]
-		 && EQ ((glyph - 1)->object, prev_object);
-	       --glyph)
-	    x -= (glyph - 1)->pixel_width;
-	}
-    }
-
-  dpyinfo->mouse_face_end_x = x;
-  dpyinfo->mouse_face_end_col = glyph - row->glyphs[TEXT_AREA];
+
+      dpyinfo->mouse_face_end_x = x;
+      dpyinfo->mouse_face_end_col = glyph - r2->glyphs[TEXT_AREA];
+    }
+  else
+    {
+      /* Skip truncation and continuation glyphs near the end of the
+	 row, and also blanks and stretch glyphs inserted by
+	 extend_face_to_end_of_line.  */
+      x = r2->x;
+      end++;
+      while (end < glyph
+	     && INTEGERP (end->object)
+	     && end->charpos <= 0)
+	{
+	  x += end->pixel_width;
+	  ++end;
+	}
+      /* Scan the rest of the glyph row from the end, looking for the
+	 first glyph that comes from BEFORE_STRING, AFTER_STRING, or
+	 DISPLAY_STRING, or whose position is between START_CHARPOS
+	 and END_CHARPOS */
+      for ( ;
+	     end < glyph
+	     && !INTEGERP (end->object)
+	     && !EQ (end->object, display_string)
+	     && !(BUFFERP (end->object)
+		  && (end->charpos >= start_charpos
+		      && end->charpos < end_charpos));
+	   ++end)
+	{
+	  /* BEFORE_STRING or AFTER_STRING are only relevant if they
+	     are present at buffer positions between START_CHARPOS and
+	     END_CHARPOS, or if they come from an overlay.  */
+	  if (EQ (end->object, before_string))
+	    {
+	      pos = string_buffer_position (w, before_string, start_charpos);
+	      if (!pos || pos >= start_charpos && pos < end_charpos)
+		break;
+	    }
+	  else if (EQ (end->object, after_string))
+	    {
+	      pos = string_buffer_position (w, after_string, end_charpos);
+	      if (!pos || pos >= start_charpos && pos < end_charpos)
+		break;
+	    }
+	  x += end->pixel_width;
+	}
+      dpyinfo->mouse_face_end_x = x;
+      dpyinfo->mouse_face_end_col = end - r2->glyphs[TEXT_AREA];
+    }
+
   dpyinfo->mouse_face_window = window;
   dpyinfo->mouse_face_face_id
     = face_at_buffer_position (w, mouse_charpos, 0, 0, &ignore,
@@ -23926,6 +24253,11 @@
   show_mouse_face (dpyinfo, DRAW_MOUSE_FACE);
 }
 
+/* The following function is not used anymore (replaced with
+   mouse_face_from_string_pos), but I leave it here for the time
+   being, in case someone would.  */
+
+#if 0	/* not used */
 
 /* Find the position of the glyph for position POS in OBJECT in
    window W's current matrix, and return in *X, *Y the pixel
@@ -24003,7 +24335,130 @@
 
   return best_glyph != NULL;
 }
-
+#endif	/* not used */
+
+/* Find the positions of the first and the last glyphs in window W's
+   current matrix that occlude positions [STARTPOS..ENDPOS] in OBJECT
+   (assumed to be a string), and return in DPYINFO's mouse_face
+   members the pixel and column/row coordinates of those glyphs.  */
+
+static void
+mouse_face_from_string_pos (struct window *w, Display_Info *dpyinfo,
+			    Lisp_Object object,
+			    EMACS_INT startpos, EMACS_INT endpos)
+{
+  int yb = window_text_bottom_y (w);
+  struct glyph_row *r;
+  struct glyph *g, *e;
+  int gx;
+  int found = 0;
+
+  /* Find the glyph row with at least one position in the range
+     [STARTPOS..ENDPOS], and the first glyph in that row whose
+     position belongs to that range.  */
+  for (r = MATRIX_FIRST_TEXT_ROW (w->current_matrix);
+       r->enabled_p && r->y < yb;
+       ++r)
+    {
+      if (!r->reversed_p)
+	{
+	  g = r->glyphs[TEXT_AREA];
+	  e = g + r->used[TEXT_AREA];
+	  for (gx = r->x; g < e; gx += g->pixel_width, ++g)
+	    if (EQ (g->object, object)
+		&& startpos <= g->charpos && g->charpos <= endpos)
+	      {
+		dpyinfo->mouse_face_beg_row = r - w->current_matrix->rows;
+		dpyinfo->mouse_face_beg_y = r->y;
+		dpyinfo->mouse_face_beg_col = g - r->glyphs[TEXT_AREA];
+		dpyinfo->mouse_face_beg_x = gx;
+		found = 1;
+		break;
+	      }
+	}
+      else
+	{
+	  struct glyph *g1;
+
+	  e = r->glyphs[TEXT_AREA];
+	  g = e + r->used[TEXT_AREA];
+	  for ( ; g > e; --g)
+	    if (EQ ((g-1)->object, object)
+		&& startpos <= (g-1)->charpos && (g-1)->charpos <= endpos)
+	      {
+		dpyinfo->mouse_face_beg_row = r - w->current_matrix->rows;
+		dpyinfo->mouse_face_beg_y = r->y;
+		dpyinfo->mouse_face_beg_col = g - r->glyphs[TEXT_AREA];
+		for (gx = r->x, g1 = r->glyphs[TEXT_AREA]; g1 < g; ++g1)
+		  gx += g1->pixel_width;
+		dpyinfo->mouse_face_beg_x = gx;
+		found = 1;
+		break;
+	      }
+	}
+      if (found)
+	break;
+    }
+
+  if (!found)
+    return;
+
+  /* Starting with the next row, look for the first row which does NOT
+     include any glyphs whose positions are in the range.  */
+  for (++r; r->enabled_p && r->y < yb; ++r)
+    {
+      g = r->glyphs[TEXT_AREA];
+      e = g + r->used[TEXT_AREA];
+      found = 0;
+      for ( ; g < e; ++g)
+	if (EQ (g->object, object)
+	    && startpos <= g->charpos && g->charpos <= endpos)
+	  {
+	    found = 1;
+	    break;
+	  }
+      if (!found)
+	break;
+    }
+
+  /* The highlighted region ends on the previous row.  */
+  r--;
+
+  /* Set the end row and its vertical pixel coordinate.  */
+  dpyinfo->mouse_face_end_row = r - w->current_matrix->rows;
+  dpyinfo->mouse_face_end_y = r->y;
+
+  /* Compute and set the end column and the end column's horizontal
+     pixel coordinate.  */
+  if (!r->reversed_p)
+    {
+      g = r->glyphs[TEXT_AREA];
+      e = g + r->used[TEXT_AREA];
+      for ( ; e > g; --e)
+	if (EQ ((e-1)->object, object)
+	    && startpos <= (e-1)->charpos && (e-1)->charpos <= endpos)
+	  break;
+      dpyinfo->mouse_face_end_col = e - g;
+
+      for (gx = r->x; g < e; ++g)
+	gx += g->pixel_width;
+      dpyinfo->mouse_face_end_x = gx;
+    }
+  else
+    {
+      e = r->glyphs[TEXT_AREA];
+      g = e + r->used[TEXT_AREA];
+      for (gx = r->x ; e < g; ++e)
+	{
+	  if (EQ (e->object, object)
+	      && startpos <= e->charpos && e->charpos <= endpos)
+	    break;
+	  gx += e->pixel_width;
+	}
+      dpyinfo->mouse_face_end_col = e - r->glyphs[TEXT_AREA];
+      dpyinfo->mouse_face_end_x = gx;
+    }
+}
 
 /* See if position X, Y is within a hot-spot of an image.  */
 
@@ -24205,6 +24660,8 @@
       int x0;
       struct glyph *end;
 
+      /* Kludge alert: mode_line_string takes X/Y in pixels, but
+	 returns them in row/column units!  */
       string = mode_line_string (w, area, &x, &y, &charpos,
 				 &object, &dx, &dy, &width, &height);
 
@@ -24212,7 +24669,7 @@
 	     ? MATRIX_MODE_LINE_ROW (w->current_matrix)
 	     : MATRIX_HEADER_LINE_ROW (w->current_matrix));
 
-      /* Find glyph */
+      /* Find the glyph under the mouse pointer.  */
       if (row->mode_line_p && row->enabled_p)
 	{
 	  glyph = row_start_glyph = row->glyphs[TEXT_AREA];
@@ -24230,6 +24687,8 @@
   else
     {
       x -= WINDOW_LEFT_SCROLL_BAR_AREA_WIDTH (w);
+      /* Kludge alert: marginal_area_string takes X/Y in pixels, but
+	 returns them in row/column units!  */
       string = marginal_area_string (w, area, &x, &y, &charpos,
 				     &object, &dx, &dy, &width, &height);
     }
@@ -24318,93 +24777,116 @@
 	  int gpos;
 	  int gseq_length;
 	  int total_pixel_width;
-	  EMACS_INT ignore;
+	  EMACS_INT begpos, endpos, ignore;
 
 	  int vpos, hpos;
 
 	  b = Fprevious_single_property_change (make_number (charpos + 1),
 						Qmouse_face, string, Qnil);
 	  if (NILP (b))
-	    b = make_number (0);
+	    begpos = 0;
+	  else
+	    begpos = XINT (b);
 
 	  e = Fnext_single_property_change (pos, Qmouse_face, string, Qnil);
 	  if (NILP (e))
-	    e = make_number (SCHARS (string));
-
-	  /* Calculate the position(glyph position: GPOS) of GLYPH in
-	     displayed string. GPOS is different from CHARPOS.
-
-	     CHARPOS is the position of glyph in internal string
-	     object. A mode line string format has structures which
-	     is converted to a flatten by emacs lisp interpreter.
-	     The internal string is an element of the structures.
-	     The displayed string is the flatten string. */
-	  gpos = 0;
-	  if (glyph > row_start_glyph)
-	    {
-	      tmp_glyph = glyph - 1;
-	      while (tmp_glyph >= row_start_glyph
-		     && tmp_glyph->charpos >= XINT (b)
-		     && EQ (tmp_glyph->object, glyph->object))
-		{
-		  tmp_glyph--;
-		  gpos++;
-		}
-	    }
-
-	  /* Calculate the lenght(glyph sequence length: GSEQ_LENGTH) of
-	     displayed string holding GLYPH.
-
-	     GSEQ_LENGTH is different from SCHARS (STRING).
-	     SCHARS (STRING) returns the length of the internal string. */
-	  for (tmp_glyph = glyph, gseq_length = gpos;
-	       tmp_glyph->charpos < XINT (e);
-	       tmp_glyph++, gseq_length++)
-	      {
-		if (!EQ (tmp_glyph->object, glyph->object))
-		  break;
-	      }
-
+	    endpos = SCHARS (string);
+	  else
+	    endpos = XINT (e);
+
+	  /* Calculate the glyph position GPOS of GLYPH in the
+	     displayed string, relative to the beginning of the
+	     highlighted part of the string.
+
+	     Note: GPOS is different from CHARPOS.  CHARPOS is the
+	     position of GLYPH in the internal string object.  A mode
+	     line string format has structures which are converted to
+	     a flattened string by the Emacs Lisp interpreter.  The
+	     internal string is an element of those structures.  The
+	     displayed string is the flattened string.  */
+	  tmp_glyph = row_start_glyph;
+	  while (tmp_glyph < glyph
+		 && (!(EQ (tmp_glyph->object, glyph->object)
+		       && begpos <= tmp_glyph->charpos
+		       && tmp_glyph->charpos < endpos)))
+	    tmp_glyph++;
+	  gpos = glyph - tmp_glyph;
+
+	  /* Calculate the length GSEQ_LENGTH of the glyph sequence of
+	     the highlighted part of the displayed string to which
+	     GLYPH belongs.  Note: GSEQ_LENGTH is different from
+	     SCHARS (STRING), because the latter returns the length of
+	     the internal string.  */
+	  for (tmp_glyph = row->glyphs[TEXT_AREA] + row->used[TEXT_AREA] - 1;
+	       tmp_glyph > glyph
+		 && (!(EQ (tmp_glyph->object, glyph->object)
+		       && begpos <= tmp_glyph->charpos
+		       && tmp_glyph->charpos < endpos));
+	       tmp_glyph--)
+	    ;
+	  gseq_length = gpos + (tmp_glyph - glyph) + 1;
+
+	  /* Calculate the total pixel width of all the glyphs between
+	     the beginning of the highlighted area and GLYPH.  */
 	  total_pixel_width = 0;
 	  for (tmp_glyph = glyph - gpos; tmp_glyph != glyph; tmp_glyph++)
 	    total_pixel_width += tmp_glyph->pixel_width;
 
-	  /* Pre calculation of re-rendering position */
-	  vpos = (x - gpos);
-	  hpos = (area == ON_MODE_LINE
+	  /* Pre calculation of re-rendering position.  Note: X is in
+	     column units here, after the call to mode_line_string or
+	     marginal_area_string.  */
+	  hpos = x - gpos;
+	  vpos = (area == ON_MODE_LINE
 		  ? (w->current_matrix)->nrows - 1
 		  : 0);
 
-	  /* If the re-rendering position is included in the last
-	     re-rendering area, we should do nothing. */
+	  /* If GLYPH's position is included in the region that is
+	     already drawn in mouse face, we have nothing to do.  */
 	  if ( EQ (window, dpyinfo->mouse_face_window)
-	       && dpyinfo->mouse_face_beg_col <= vpos
-	       && vpos < dpyinfo->mouse_face_end_col
-	       && dpyinfo->mouse_face_beg_row == hpos )
+	       && (!row->reversed_p
+		   ? (dpyinfo->mouse_face_beg_col <= hpos
+		      && hpos < dpyinfo->mouse_face_end_col)
+		   /* In R2L rows we swap BEG and END, see below.  */
+		   : (dpyinfo->mouse_face_end_col <= hpos
+		      && hpos < dpyinfo->mouse_face_beg_col))
+	       && dpyinfo->mouse_face_beg_row == vpos )
 	    return;
 
 	  if (clear_mouse_face (dpyinfo))
 	    cursor = No_Cursor;
 
-	  dpyinfo->mouse_face_beg_col = vpos;
-	  dpyinfo->mouse_face_beg_row = hpos;
-
-	  dpyinfo->mouse_face_beg_x   = original_x_pixel - (total_pixel_width + dx);
-	  dpyinfo->mouse_face_beg_y   = 0;
-
-	  dpyinfo->mouse_face_end_col = vpos + gseq_length;
-	  dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_beg_row;
-
-	  dpyinfo->mouse_face_end_x   = 0;
-	  dpyinfo->mouse_face_end_y   = 0;
-
+	  if (!row->reversed_p)
+	    {
+	      dpyinfo->mouse_face_beg_col = hpos;
+	      dpyinfo->mouse_face_beg_x   = original_x_pixel
+					    - (total_pixel_width + dx);
+	      dpyinfo->mouse_face_end_col = hpos + gseq_length;
+	      dpyinfo->mouse_face_end_x   = 0;
+	    }
+	  else
+	    {
+	      /* In R2L rows, show_mouse_face expects BEG and END
+		 coordinates to be swapped.  */
+	      dpyinfo->mouse_face_end_col = hpos;
+	      dpyinfo->mouse_face_end_x   = original_x_pixel
+					    - (total_pixel_width + dx);
+	      dpyinfo->mouse_face_beg_col = hpos + gseq_length;
+	      dpyinfo->mouse_face_beg_x   = 0;
+	    }
+
+	  dpyinfo->mouse_face_beg_row  = vpos;
+	  dpyinfo->mouse_face_end_row  = dpyinfo->mouse_face_beg_row;
+	  dpyinfo->mouse_face_beg_y    = 0;
+	  dpyinfo->mouse_face_end_y    = 0;
 	  dpyinfo->mouse_face_past_end = 0;
-	  dpyinfo->mouse_face_window  = window;
+	  dpyinfo->mouse_face_window   = window;
 
 	  dpyinfo->mouse_face_face_id = face_at_string_position (w, string,
 								 charpos,
-								 0, 0, 0, &ignore,
-								 glyph->face_id, 1);
+								 0, 0, 0,
+								 &ignore,
+								 glyph->face_id,
+								 1);
 	  show_mouse_face (dpyinfo, DRAW_MOUSE_FACE);
 
 	  if (NILP (pointer))
@@ -24573,7 +25055,15 @@
       /* Clear mouse face if X/Y not over text.  */
       if (glyph == NULL
 	  || area != TEXT_AREA
-	  || !MATRIX_ROW (w->current_matrix, vpos)->displays_text_p)
+	  || !MATRIX_ROW (w->current_matrix, vpos)->displays_text_p
+	  /* R2L rows have a stretch glyph at their front, which
+	     stands for no text, whereas L2R rows have no glyphs at
+	     all beyond the end of text.  Treat such stretch glyphs
+	     like we do with NULL glyphs in L2R rows.  */
+	  || (MATRIX_ROW (w->current_matrix, vpos)->reversed_p
+	      && glyph == MATRIX_ROW (w->current_matrix, vpos)->glyphs[TEXT_AREA]
+	      && glyph->type == STRETCH_GLYPH
+	      && glyph->avoid_cursor_p))
 	{
 	  if (clear_mouse_face (dpyinfo))
 	    cursor = No_Cursor;
@@ -24618,14 +25108,7 @@
       else
 	noverlays = 0;
 
-      same_region = (EQ (window, dpyinfo->mouse_face_window)
-		     && vpos >= dpyinfo->mouse_face_beg_row
-		     && vpos <= dpyinfo->mouse_face_end_row
-		     && (vpos > dpyinfo->mouse_face_beg_row
-			 || hpos >= dpyinfo->mouse_face_beg_col)
-		     && (vpos < dpyinfo->mouse_face_end_row
-			 || hpos < dpyinfo->mouse_face_end_col
-			 || dpyinfo->mouse_face_past_end));
+      same_region = coords_in_mouse_face_p (w, hpos, vpos);
 
       if (same_region)
 	cursor = No_Cursor;
@@ -24679,17 +25162,8 @@
 		b = make_number (0);
 	      if (NILP (e))
 		e = make_number (SCHARS (object) - 1);
-
-	      fast_find_string_pos (w, XINT (b), object,
-				    &dpyinfo->mouse_face_beg_col,
-				    &dpyinfo->mouse_face_beg_row,
-				    &dpyinfo->mouse_face_beg_x,
-				    &dpyinfo->mouse_face_beg_y, 0);
-	      fast_find_string_pos (w, XINT (e), object,
-				    &dpyinfo->mouse_face_end_col,
-				    &dpyinfo->mouse_face_end_row,
-				    &dpyinfo->mouse_face_end_x,
-				    &dpyinfo->mouse_face_end_y, 1);
+	      mouse_face_from_string_pos (w, dpyinfo, object,
+					  XINT (b), XINT (e));
 	      dpyinfo->mouse_face_past_end = 0;
 	      dpyinfo->mouse_face_window = window;
 	      dpyinfo->mouse_face_face_id
@@ -24729,17 +25203,33 @@
 		{
 		  Lisp_Object before, after;
 		  Lisp_Object before_string, after_string;
+		  /* To correctly find the limits of mouse highlight
+		     in a bidi-reordered buffer, we must not use the
+		     optimization of limiting the search in
+		     previous-single-property-change and
+		     next-single-property-change, because
+		     rows_from_pos_range needs the real start and end
+		     positions to DTRT in this case.  That's because
+		     the first row visible in a window does not
+		     necessarily display the character whose position
+		     is the smallest.  */
+		  Lisp_Object lim1 =
+		    NILP (XBUFFER (buffer)->bidi_display_reordering)
+		    ? Fmarker_position (w->start)
+		    : Qnil;
+		  Lisp_Object lim2 =
+		    NILP (XBUFFER (buffer)->bidi_display_reordering)
+		    ? make_number (BUF_Z (XBUFFER (buffer))
+				   - XFASTINT (w->window_end_pos))
+		    : Qnil;
 
 		  if (NILP (overlay))
 		    {
 		      /* Handle the text property case.  */
 		      before = Fprevious_single_property_change
-			(make_number (pos + 1), Qmouse_face, buffer,
-			 Fmarker_position (w->start));
+			(make_number (pos + 1), Qmouse_face, buffer, lim1);
 		      after = Fnext_single_property_change
-			(make_number (pos), Qmouse_face, buffer,
-			 make_number (BUF_Z (XBUFFER (buffer))
-				      - XFASTINT (w->window_end_pos)));
+			(make_number (pos), Qmouse_face, buffer, lim2);
 		      before_string = after_string = Qnil;
 		    }
 		  else
@@ -25974,7 +26464,9 @@
   Vblink_cursor_alist = Qnil;
 
   DEFVAR_BOOL ("auto-hscroll-mode", &automatic_hscrolling_p,
-    doc: /* *Non-nil means scroll the display automatically to make point visible.  */);
+    doc: /* Allow or disallow automatic horizontal scrolling of windows.
+If non-nil, windows are automatically scrolled horizontally to make
+point visible.  */);
   automatic_hscrolling_p = 1;
   Qauto_hscroll_mode = intern_c_string ("auto-hscroll-mode");
   staticpro (&Qauto_hscroll_mode);
@@ -26089,12 +26581,13 @@
   underline_minimum_offset = 1;
 
   DEFVAR_BOOL ("display-hourglass", &display_hourglass_p,
-	       doc: /* Non-zero means Emacs displays an hourglass pointer on window systems.  */);
+	       doc: /* Non-nil means show an hourglass pointer, when Emacs is busy.
+This feature only works when on a window system that can change
+cursor shapes.  */);
   display_hourglass_p = 1;
 
   DEFVAR_LISP ("hourglass-delay", &Vhourglass_delay,
-	       doc: /* *Seconds to wait before displaying an hourglass pointer.
-Value must be an integer or float.  */);
+	       doc: /* *Seconds to wait before displaying an hourglass pointer when Emacs is busy.  */);
   Vhourglass_delay = make_number (DEFAULT_HOURGLASS_DELAY);
 
   hourglass_atimer = NULL;
@@ -26216,5 +26709,3 @@
 }
 #endif /* ! WINDOWSNT  */
 
-/* arch-tag: eacc864d-bb6a-4b74-894a-1a4399a1358b
-   (do not change this comment) */
--- a/src/xfaces.c	Thu Oct 14 16:21:40 2010 +0900
+++ b/src/xfaces.c	Thu Oct 28 19:57:59 2010 +0900
@@ -1,6 +1,8 @@
 /* xfaces.c -- "Face" primitives.
-   Copyright (C) 1993, 1994, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-                 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+
+Copyright (C) 1993, 1994, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+  2005, 2006, 2007, 2008, 2009, 2010
+  Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -6731,7 +6733,8 @@
   Vface_default_stipple = make_pure_c_string ("gray3");
 
   DEFVAR_LISP ("tty-defined-color-alist", &Vtty_defined_color_alist,
-   doc: /* An alist of defined terminal colors and their RGB values.  */);
+   doc: /* An alist of defined terminal colors and their RGB values.
+See the docstring of `tty-color-alist' for the details.  */);
   Vtty_defined_color_alist = Qnil;
 
   DEFVAR_LISP ("scalable-fonts-allowed", &Vscalable_fonts_allowed,
@@ -6808,5 +6811,3 @@
 #endif
 }
 
-/* arch-tag: 8a0f7598-5517-408d-9ab3-1da6fcd4c749
-   (do not change this comment) */
--- a/src/xfns.c	Thu Oct 14 16:21:40 2010 +0900
+++ b/src/xfns.c	Thu Oct 28 19:57:59 2010 +0900
@@ -1,7 +1,8 @@
 /* Functions for the X window system.
-   Copyright (C) 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-                 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
-                 Free Software Foundation, Inc.
+
+Copyright (C) 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+  2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+  Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -99,6 +100,8 @@
 #include <Xm/Xm.h>
 #include <Xm/DialogS.h>
 #include <Xm/FileSB.h>
+#include <Xm/List.h>
+#include <Xm/TextF.h>
 #endif
 
 #ifdef USE_LUCID
@@ -4179,6 +4182,9 @@
 
 DEFUN ("x-synchronize", Fx_synchronize, Sx_synchronize, 1, 2, 0,
        doc: /* If ON is non-nil, report X errors as soon as the erring request is made.
+This function only has an effect on X Windows.  With MS Windows, it is
+defined but does nothing.
+
 If ON is nil, allow buffering of requests.
 Turning on synchronization prohibits the Xlib routines from buffering
 requests and seriously degrades performance, but makes debugging much
@@ -4213,12 +4219,12 @@
 DEFUN ("x-change-window-property", Fx_change_window_property,
        Sx_change_window_property, 2, 6, 0,
        doc: /* Change window property PROP to VALUE on the X window of FRAME.
-PROP must be a string.
-VALUE may be a string or a list of conses, numbers and/or strings.
-If an element in the list is a string, it is converted to
-an Atom and the value of the Atom is used.  If an element is a cons,
-it is converted to a 32 bit number where the car is the 16 top bits and the
-cdr is the lower 16 bits.
+PROP must be a string.  VALUE may be a string or a list of conses,
+numbers and/or strings.  If an element in the list is a string, it is
+converted to an atom and the value of the atom is used.  If an element
+is a cons, it is converted to a 32 bit number where the car is the 16
+top bits and the cdr is the lower 16 bits.
+
 FRAME nil or omitted means use the selected frame.
 If TYPE is given and non-nil, it is the name of the type of VALUE.
 If TYPE is not given or nil, the type is STRING.
@@ -4226,9 +4232,7 @@
 It must be one of 8, 16 or 32.
 If VALUE is a string or FORMAT is nil or not given, FORMAT defaults to 8.
 If OUTER_P is non-nil, the property is changed for the outer X window of
-FRAME.  Default is to change on the edit X window.
-
-Value is VALUE.  */)
+FRAME.  Default is to change on the edit X window.  */)
   (Lisp_Object prop, Lisp_Object value, Lisp_Object frame, Lisp_Object type, Lisp_Object format, Lisp_Object outer_p)
 {
   struct frame *f = check_x_frame (frame);
@@ -4329,15 +4333,19 @@
        1, 6, 0,
        doc: /* Value is the value of window property PROP on FRAME.
 If FRAME is nil or omitted, use the selected frame.
-If TYPE is nil or omitted, get the property as a string.  Otherwise TYPE
-is the name of the Atom that denotes the type expected.
+
+On MS Windows, this function only accepts the PROP and FRAME arguments.
+
+On X Windows, the following optional arguments are also accepted:
+If TYPE is nil or omitted, get the property as a string.
+Otherwise TYPE is the name of the atom that denotes the type expected.
 If SOURCE is non-nil, get the property on that window instead of from
 FRAME.  The number 0 denotes the root window.
 If DELETE_P is non-nil, delete the property after retreiving it.
 If VECTOR_RET_P is non-nil, don't return a string but a vector of values.
 
 Value is nil if FRAME hasn't a property with name PROP or if PROP has
-no value of TYPE.  */)
+no value of TYPE (always string in the MS Windows case).  */)
   (Lisp_Object prop, Lisp_Object frame, Lisp_Object type, Lisp_Object source, Lisp_Object delete_p, Lisp_Object vector_ret_p)
 {
   struct frame *f = check_x_frame (frame);
@@ -5299,9 +5307,7 @@
 /* Callback for "OK" and "Cancel" on file selection dialog.  */
 
 static void
-file_dialog_cb (widget, client_data, call_data)
-     Widget widget;
-     XtPointer call_data, client_data;
+file_dialog_cb (Widget widget, XtPointer client_data, XtPointer call_data)
 {
   int *result = (int *) client_data;
   XmAnyCallbackStruct *cb = (XmAnyCallbackStruct *) call_data;
@@ -5315,17 +5321,14 @@
    in this case.  */
 
 static void
-file_dialog_unmap_cb (widget, client_data, call_data)
-     Widget widget;
-     XtPointer call_data, client_data;
+file_dialog_unmap_cb (Widget widget, XtPointer client_data, XtPointer call_data)
 {
   int *result = (int *) client_data;
   *result = XmCR_CANCEL;
 }
 
 static Lisp_Object
-clean_up_file_dialog (arg)
-     Lisp_Object arg;
+clean_up_file_dialog (Lisp_Object arg)
 {
   struct Lisp_Save_Value *p = XSAVE_VALUE (arg);
   Widget dialog = (Widget) p->pointer;
@@ -5345,7 +5348,11 @@
        doc: /* Read file name, prompting with PROMPT in directory DIR.
 Use a file selection dialog.  Select DEFAULT-FILENAME in the dialog's file
 selection box, if specified.  If MUSTMATCH is non-nil, the returned file
-or directory must exist.  ONLY-DIR-P is ignored."  */)
+or directory must exist.
+
+This function is only defined on MS Windows, and X Windows with the
+Motif or Gtk toolkits.  With the Motif toolkit, ONLY-DIR-P is ignored.
+Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories.  */)
   (Lisp_Object prompt, Lisp_Object dir, Lisp_Object default_filename, Lisp_Object mustmatch, Lisp_Object only_dir_p)
 {
   int result;
@@ -5514,8 +5521,11 @@
        doc: /* Read file name, prompting with PROMPT in directory DIR.
 Use a file selection dialog.  Select DEFAULT-FILENAME in the dialog's file
 selection box, if specified.  If MUSTMATCH is non-nil, the returned file
-or directory must exist.  If ONLY-DIR-P is non-nil, the user can only select
-directories.  */)
+or directory must exist.
+
+This function is only defined on MS Windows, and X Windows with the
+Motif or Gtk toolkits.  With the Motif toolkit, ONLY-DIR-P is ignored.
+Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories.  */)
   (Lisp_Object prompt, Lisp_Object dir, Lisp_Object default_filename, Lisp_Object mustmatch, Lisp_Object only_dir_p)
 {
   FRAME_PTR f = SELECTED_FRAME ();
@@ -6019,5 +6029,3 @@
 
 #endif /* HAVE_X_WINDOWS */
 
-/* arch-tag: 55040d02-5485-4d58-8b22-95a7a05f3288
-   (do not change this comment) */
--- a/src/xftfont.c	Thu Oct 14 16:21:40 2010 +0900
+++ b/src/xftfont.c	Thu Oct 28 19:57:59 2010 +0900
@@ -32,6 +32,7 @@
 #include "blockinput.h"
 #include "character.h"
 #include "charset.h"
+#include "composite.h"
 #include "fontset.h"
 #include "font.h"
 #include "ftfont.h"
@@ -664,6 +665,23 @@
   return len;
 }
 
+Lisp_Object
+xftfont_shape (Lisp_Object lgstring)
+{
+  struct font *font;
+  struct xftfont_info *xftfont_info;
+  FT_Face ft_face;
+  Lisp_Object val;
+
+  CHECK_FONT_GET_OBJECT (LGSTRING_FONT (lgstring), font);
+  xftfont_info = (struct xftfont_info *) font;
+  ft_face = XftLockFace (xftfont_info->xftfont);
+  xftfont_info->ft_size = ft_face->size;
+  val = ftfont_driver.shape (lgstring);
+  XftUnlockFace (xftfont_info->xftfont);
+  return val;
+}
+
 static int
 xftfont_end_for_frame (FRAME_PTR f)
 {
@@ -753,6 +771,9 @@
   xftfont_driver.draw = xftfont_draw;
   xftfont_driver.end_for_frame = xftfont_end_for_frame;
   xftfont_driver.cached_font_ok = xftfont_cached_font_ok;
+#if defined (HAVE_M17N_FLT) && defined (HAVE_LIBOTF)
+  xftfont_driver.shape = xftfont_shape;
+#endif
 
   register_font_driver (&xftfont_driver, NULL);
 }
--- a/src/xmenu.c	Thu Oct 14 16:21:40 2010 +0900
+++ b/src/xmenu.c	Thu Oct 28 19:57:59 2010 +0900
@@ -89,6 +89,7 @@
 #include <X11/Xaw/Paned.h>
 #endif /* HAVE_XAW3D */
 #endif /* USE_LUCID */
+#include "../lwlib/lwlib.h"
 #else /* not USE_X_TOOLKIT */
 #ifndef USE_GTK
 #include "../oldXMenu/XMenu.h"
--- a/src/xrdb.c	Thu Oct 14 16:21:40 2010 +0900
+++ b/src/xrdb.c	Thu Oct 28 19:57:59 2010 +0900
@@ -48,6 +48,11 @@
 
 #include "lisp.h"
 
+#ifdef USE_MOTIF
+/* For Vdouble_click_time.  */
+#include "keyboard.h"
+#endif
+
 extern char *getenv (const char *);
 
 extern struct passwd *getpwuid (uid_t);
--- a/src/xterm.c	Thu Oct 14 16:21:40 2010 +0900
+++ b/src/xterm.c	Thu Oct 28 19:57:59 2010 +0900
@@ -1,7 +1,8 @@
 /* X Communication module for terminals which understand the X protocol.
-   Copyright (C) 1989, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
-                 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
-                 Free Software Foundation, Inc.
+
+Copyright (C) 1989, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
+  2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+  Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -7697,15 +7698,18 @@
 #endif
 
 #ifdef USE_GTK
-      /* Due to bugs in some Gtk+ versions, just exit here if this
-         is the last display/terminal. */
-      if (terminal_list->next_terminal == NULL)
-        {
-          fprintf (stderr, "%s\n", error_msg);
-          Fkill_emacs (make_number (70));
-          /* NOTREACHED */
-        }
-      xg_display_close (dpyinfo->display);
+      /* There is a long-standing bug in GTK that prevents the GTK
+	 main loop from recovering gracefully from disconnects
+	 (https://bugzilla.gnome.org/show_bug.cgi?id=85715).  Among
+	 other problems, this gives rise to a stream of Glib error
+	 messages that, in one incident, filled up a user's hard disk
+	 (http://lists.gnu.org/archive/html/emacs-devel/2010-10/msg00927.html).
+	 So, kill Emacs unconditionally if the display is closed.  */
+      {
+	fprintf (stderr, "%s\n", error_msg);
+	Fkill_emacs (make_number (70));
+	abort ();  /* NOTREACHED */
+      }
 #endif
 
       /* Indicate that this display is dead.  */
@@ -10682,9 +10686,11 @@
   x_mouse_click_focus_ignore_position = 0;
 
   DEFVAR_LISP ("x-toolkit-scroll-bars", &Vx_toolkit_scroll_bars,
-    doc: /* What X toolkit scroll bars Emacs uses.
-A value of nil means Emacs doesn't use X toolkit scroll bars.
-Otherwise, value is a symbol describing the X toolkit.  */);
+    doc: /* Which toolkit scroll bars Emacs uses, if any.
+A value of nil means Emacs doesn't use toolkit scroll bars.
+With the X Window system, the value is a symbol describing the
+X toolkit.  Possible values are: gtk, motif, xaw, or xaw3d.
+With MS Windows, the value is t.  */);
 #ifdef USE_TOOLKIT_SCROLL_BARS
 #ifdef USE_MOTIF
   Vx_toolkit_scroll_bars = intern_c_string ("motif");
@@ -10750,5 +10756,3 @@
 
 #endif /* HAVE_X_WINDOWS */
 
-/* arch-tag: 6d4e4cb7-abc1-4302-9585-d84dcfb09d0f
-   (do not change this comment) */
--- a/test/ChangeLog	Thu Oct 14 16:21:40 2010 +0900
+++ b/test/ChangeLog	Thu Oct 28 19:57:59 2010 +0900
@@ -1,3 +1,13 @@
+2010-10-27  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* indent/octave.m: Add a test to ensure indentation is local.
+
+2010-10-23  Glenn Morris  <rgm@gnu.org>
+
+	* comint-testsuite.el
+	(comint-testsuite--test-comint-password-prompt-regexp):
+	Add "Please enter the password".  (Bug#7224)
+
 2010-09-20  Stefan Monnier  <monnier@iro.umontreal.ca>
 
 	* indent/prolog.prolog: Use normal spacing around !.
--- a/test/comint-testsuite.el	Thu Oct 14 16:21:40 2010 +0900
+++ b/test/comint-testsuite.el	Thu Oct 28 19:57:59 2010 +0900
@@ -34,7 +34,8 @@
   (interactive)
   (let ((password-strings
 	 '("foo@example.net's password: " ;ssh
-	   "Password for foo@example.org: " ; knit
+	   "Password for foo@example.org: " ; kinit
+	   "Please enter the password for foo@example.org: "   ; kinit
 	   "Kerberos password for devnull/root <at> GNU.ORG: " ; ksu
 	   "Enter passphrase: " ; ssh-add
 	   "Enter passphrase (empty for no passphrase): " ; ssh-keygen
--- a/test/indent/octave.m	Thu Oct 14 16:21:40 2010 +0900
+++ b/test/indent/octave.m	Thu Oct 28 19:57:59 2010 +0900
@@ -17,15 +17,21 @@
   cnty = repmat(x(:,1)(:), 10, 1);
 
   pop = x(:,1:10)(:);
-  bir = x(:,11:20)(:);
-  dth = x(:,21:30)(:);
-  imig = x(:,31:40)(:);
-  dmig = x(:,41:50)(:);
-  gq = x(:,51:60)(:);
-  
-  yrs = repmat(2000:2009, 39, 1)(:);
+    ## Here and below, we test if the indentation aligns with a previous
+    ## fixindented line.  This is important so as to make it easier for the
+    ## user to verride some indentation somewhere, and also because it
+    ## reflects the fact that the indentation decision is taken with a minimum
+    ## amount of work (i.e. in the present case, without having to walk back
+    ## until the `function' line).
+    bir = x(:,11:20)(:);        # fixindent
+    dth = x(:,21:30)(:);
+    imig = x(:,31:40)(:);
+    dmig = x(:,41:50)(:);
+    gq = x(:,51:60)(:);
 
-  res = [yrs, cnty, pop, bir, dth, imig, dmig, gq];
+    yrs = repmat(2000:2009, 39, 1)(:);
+
+    res = [yrs, cnty, pop, bir, dth, imig, dmig, gq];
 
 endfunction